def getObjectLights(curObj, exportData):
    objLightsList = []
    curName = curObj.GetName()
    for lightObj in exportData.allLights:
        inorExluded = lightObj[2].get(str(curObj.GetName()), None)
        if inorExluded is not None:
            if inorExluded == True:
                objLightsList.append(lightObj[0])
    newLightsList = []
    lightPickerString = ""
    while len(objLightsList) > 0:
        findSmallestName = 1000000
        findSmallestNameIdx = -1
        nameIdx = 0
        for curName in objLightsList:
            if int(curName) < int(findSmallestName):
                findSmallestName = int(curName)
                findSmallestNameIdx = nameIdx
            nameIdx += 1
        if findSmallestNameIdx != -1:
            newLightsList.append(findSmallestName)
            objLightsList.pop(findSmallestNameIdx)
            lightPickerString += str(findSmallestName) + "#"
        if findSmallestNameIdx == -1:
            print "Error in Lightrouting"
            objLightsList = []
            newLightsList = []
            lightPickerString = ""
    returnIdx = 0
    if len(exportData.lightPickerDic) == 0:
        exportData.lightPickerDic[str("")] = 0
    if lightPickerString != "":
        getLightPicker = exportData.lightPickerDic.get(str(lightPickerString),
                                                       None)
        if getLightPicker is not None:
            returnIdx = getLightPicker
        if getLightPicker is None:

            newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(
                None, "LightPicker", 51)
            newAWDBlock = classesAWDBlocks.LightPickerBlock(
                exportData.idCounter, 0, newLightsList)
            returnIdx = exportData.idCounter
            exportData.idCounter += 1
            exportData.lightPickerDic[str(lightPickerString)] = returnIdx
            newAWDWrapperBlock.data = newAWDBlock
            newAWDWrapperBlock.tagForExport = True
            exportData.allAWDBlocks.append(newAWDWrapperBlock)

    return returnIdx
Ejemplo n.º 2
0
def copyAsNewMaterialBlock(exportData, matBlock, lightPicker, repeat):
    # create a AWD-Material-Block for the C4D-Default-Color, in case some Objects have no Materials/ObjectColors Applied
    newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(matBlock.targetObject,
                                                       matBlock.name, 81)
    newAWDBlock = classesAWDBlocks.StandartMaterialBlock(
        exportData.idCounter, 0, matBlock.data.colorMat)
    newAWDBlock.mat = matBlock.data.mat
    newAWDBlock.saveLookUpName = matBlock.name
    newAWDBlock.name = matBlock.data.name
    newAWDBlock.lightPicker = lightPicker
    newAWDBlock.repeat = repeat
    newAWDWrapperBlock.data = newAWDBlock
    newAWDWrapperBlock.tagForExport = True
    exportData.allAWDBlocks.append(newAWDWrapperBlock)
    returner = exportData.idCounter
    exportData.idCounter += 1
    return returner
def buildSkeletonPose(exportData,curObj,curTime): 

    
    newAWDWrapperBlock=classesAWDBlocks.WrapperBlock(None,"",0)
    exportData.allAWDBlocks.append(newAWDWrapperBlock)  
    
    newAWDBlock=classesAWDBlocks.SkeletonPoseBlock(exportData.idCounter,0,curObj.GetTag(1028938)[1011])
    exportData.idCounter+=1
    newAWDBlock.name=curObj.GetTag(1028938)[1011]
    c4d.documents.SetDocumentTime(exportData.doc, curTime)# set original Time
    c4d.DrawViews( c4d.DRAWFLAGS_FORCEFULLREDRAW|c4d.DRAWFLAGS_NO_THREAD|c4d.DRAWFLAGS_NO_REDUCTION|c4d.DRAWFLAGS_STATICBREAK )
    c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED)
    c4d.EventAdd(c4d.EVENT_ANIMATE)
    c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
    c4d.DrawViews( c4d.DRAWFLAGS_FORCEFULLREDRAW)
    c4d.GeSyncMessage(c4d.EVMSG_ASYNCEDITORMOVE)
    newAWDBlock.transformations=[]
    buildJointTransform([curObj],newAWDBlock.transformations,exportData,True) # recursive function to get all Joints as JointBlocks
    newAWDWrapperBlock.data=newAWDBlock
    newAWDWrapperBlock.blockType=102
    newAWDWrapperBlock.tagForExport=True
    return newAWDWrapperBlock
Ejemplo n.º 4
0
def getObjectColorMatBlock(exportData, colorVector):
    newColorVecString = "#" + str(colorVector)
    colorMat = exportData.colorMaterials.get(newColorVecString, None)
    #print str(newColorVecString) + "  /  "+str()
    if colorMat is not None:
        return colorMat

    newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(None, "", 11)
    newAWDBlock = classesAWDBlocks.StandartMaterialBlock(
        exportData.idCounter, 0, True)
    newAWDBlock.name = "Material"
    newAWDBlock.matColor = [
        colorVector.z * 255, colorVector.y * 255, colorVector.x * 255, 0
    ]
    newAWDBlock.saveMatProps.append(1)
    newAWDBlock.isCreated = True
    newAWDWrapperBlock.tagForExport = False
    newAWDWrapperBlock.data = newAWDBlock
    exportData.idCounter += 1
    exportData.allAWDBlocks.append(newAWDWrapperBlock)
    exportData.colorMaterials[newColorVecString] = newAWDWrapperBlock
    #exportData.MaterialsToAWDBlocksDic[str(defaultMaterial)]=newAWDBlock
    return newAWDWrapperBlock
Ejemplo n.º 5
0
def startExport(mainDialog, doc):
    exportData = classMainScene.mainScene(
        doc, mainDialog
    )  # create a new "mainScene". this class will store all the data collected for export

    # not needed anymor ?
    #exportData.doc.SetMode(11)#set EditMode to 11 (Model-Mode) - otherwise the triangulate method will only affect the selected polygons!
    objectsToExport = exportData.doc.GetObjects(
    )  # get a list of all objects in the scene

    # check if there is anything to export
    if len(objectsToExport) == 0:  # if no object is in the scene:
        if exportData.unusedMats == False:  # if no unsued materials should be exported:
            newError = classesHelper.AWDerrorObject(
                ids.ERRORMESSAGE2, None)  # create a new errorObject
            exportData.AWDerrorObjects.append(
                newError
            )  # append the new errorObject to the errorlist, so it will be displayed at the end of export process
            return exportData  # return from function
        if exportData.unusedMats == True:  # if unused materials should be exported:
            exportData.allc4dMaterials = doc.GetMaterials(
            )  # get a list of all materials
            if len(exportData.allc4dMaterials
                   ) == 0:  # if no material was found:
                newError = classesHelper.AWDerrorObject(
                    ids.ERRORMESSAGE2, None)  # create a new errorObject
                exportData.AWDerrorObjects.append(
                    newError
                )  # append the new errorObject to the errorlist, so it will be displayed at the end of export process
                return exportData  # return from function
    exportData.objList = objectsToExport

    # calculate progressbar
    exportData.allStatusLength = 2  # used to calculate the progress-bar
    exportData.allStatus = 1  # used to calculate the progress-bar
    exportData.status = 1

    # open save as dialog
    datei = c4d.storage.SaveDialog(c4d.FILESELECTTYPE_ANYTHING,
                                   "save as *.AWD", "awd")
    if datei is None:
        newError = classesHelper.AWDerrorObject(
            ids.ERRORMESSAGE2, None)  # create a new errorObject
        exportData.AWDerrorObjects.append(
            newError
        )  # append the new errorObject to the errorlist, so it will be displayed at the end of export process
        return None

    # disable the all GUI-elements, so the user can not change anything while exporting
    maindialogHelpers.enableAll(mainDialog, False)
    exportData.datei = datei

    # if this is executed, we know there is something to export!

    # create the MetaDataBlock
    newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(None, "", 255)
    exportData.idCounter += 1
    newMetaDataBlock = classesAWDBlocks.MetaDataBlock(0, 0)
    newMetaDataBlock.timestamp = 0  # to do
    newMetaDataBlock.encoder = "AWDToolsC4D"
    newMetaDataBlock.encoderVersion = "0.9"
    newMetaDataBlock.app = "Cinema4D"
    newMetaDataBlock.appVersion = "R13 / R14"  # to do
    newAWDWrapperBlock.data = newMetaDataBlock
    newAWDWrapperBlock.tagForExport = True
    exportData.allAWDBlocks.append(newAWDWrapperBlock)

    # create a AWD-Material-Block for the C4D-Default-Color, in case some Objects have no Materials/ObjectColors Applied
    newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(None,
                                                       "C4D-DefaultMaterial",
                                                       81)
    defaultColor = exportData.doc[c4d.DOCUMENT_DEFAULTMATERIAL_COLOR]
    newAWDBlock = classesAWDBlocks.StandartMaterialBlock(
        exportData.idCounter, 0, True)
    newAWDBlock.saveLookUpName = "C4D-DefaultMat"
    exportData.allMatBlocks.append(newAWDBlock)
    defaultColorString = "#" + str(defaultColor)
    exportData.colorMaterials[defaultColorString] = newAWDBlock
    newAWDBlock.matColor = [
        defaultColor.z * 255, defaultColor.y * 255, defaultColor.x * 255, 0
    ]
    newAWDBlock.saveMatProps.append(1)
    newAWDBlock.isCreated = True
    newAWDWrapperBlock.data = newAWDBlock
    newAWDWrapperBlock.tagForExport = False
    exportData.allAWDBlocks.append(newAWDWrapperBlock)
    exportData.idCounter += 1

    # create a AWD-Material-Block for all the C4D-Materials in the scene, regardless if they will be exported or not.
    for mat in exportData.allc4dMaterials:
        newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(
            mat, mat.GetName(), 81)
        newAWDBlock = classesAWDBlocks.StandartMaterialBlock(
            exportData.idCounter, 0, False)
        newAWDBlock.saveLookUpName = mat.GetName()
        newAWDBlock.name = mat.GetName()
        newAWDBlock.mat = mat
        mat.SetName(str(exportData.idCounter))
        exportData.idCounter += 1
        newAWDWrapperBlock.data = newAWDBlock
        newAWDWrapperBlock.tagForExport = False
        exportData.allAWDBlocks.append(newAWDWrapperBlock)
        exportData.allMatBlocks.append(newAWDBlock)

    # create a AWD-Block for all Objects in the Scene (and their tags) regardless if they will be exported or not
    mainParseObjectToAWDBlock.createAllAWDBlocks(exportData, objectsToExport)

    # create a SceneBlock for all Objects that should be exported
    mainParseObjectToAWDBlock.createAllSceneBlocks(
        exportData, objectsToExport, exportData.defaultObjectSettings)

    exportData.allStatusLength = 2 + (10 *
                                      int(exportData.animationCounter)) + (
                                          10 * len(exportData.allMeshObjects)
                                      )  # used to calculate the progress-bar
    exportData.allStatus = 1  # used to calculate the progress-bar
    exportData.status = 1  # used to calculate the progress-bar
    mainHelpers.updateCanvas(mainDialog, exportData)  # update the progress-bar
    mainSkeletonReader.createSkeletonBlocks(exportData.objList, exportData,
                                            mainDialog)
    if mainDialog.GetBool(ids.CBOX_VANIMATION) == True:
        mainVertexAnimationReader.getVertexAnimationData(
            exportData.objList, exportData, mainDialog)
    exportData.status = 2
    mainHelpers.updateCanvas(mainDialog, exportData)
    return exportData
Ejemplo n.º 6
0
def createSingleTextureBlock(exportData,texturePath):
    if texturePath is None or str(texturePath)=="":
        return
    isInList=exportData.texturePathToAWDBlocksDic.get(str(texturePath),None)
    if isInList is None:
        pathName=os.path.basename(texturePath)
        
        newAWDWrapperBlock=classesAWDBlocks.WrapperBlock(None,"",82)
        exportData.allAWDBlocks.append(newAWDWrapperBlock) 
        
        newAWDBlock=classesAWDBlocks.TextureBlock(exportData.idCounter,0,str(texturePath),exportData.embedTextures,pathName)
        
        exportData.texturePathToAWDBlocksDic[str(texturePath)]=newAWDBlock
        exportData.idCounter+=1
        extensionAr=pathName.split(".")
        extension=extensionAr[(len(extensionAr)-1)]
        filenamecount=0 
        newAWDBlock.saveLookUpName=""
        newAWDBlock.tagForExport=True
        newAWDBlock.isOK=False
        while filenamecount<(len(extensionAr)-1):
            newAWDBlock.saveLookUpName+=extensionAr[filenamecount]
            filenamecount+=1

        #if extension!="jpg" and extension!="jpeg" and extension!="JPG" and extension!="JPEG" and extension!="png" and extension!="PNG":
        #    exportData.AWDerrorObjects.append(classesHelper.AWDerrorObject(ids.ERRORMESSAGE3,texturePath))
        #    return
        inDocumentPath=texturePath
        try:
            with open(texturePath) as f: pass
        except IOError as e:
            try:
                inDocumentPath=os.path.join(c4d.documents.GetActiveDocument().GetDocumentPath(),texturePath)
                with open(inDocumentPath) as f: pass
            except IOError as e:
                try:
                    inDocumentPath=os.path.join(c4d.documents.GetActiveDocument().GetDocumentPath(),"tex",texturePath)
                    with open(inDocumentPath) as f: pass
                except IOError as e:
                    exportData.AWDerrorObjects.append(classesHelper.AWDerrorObject(ids.ERRORMESSAGE4,inDocumentPath))
                    return
                    
               
        curBmp = c4d.bitmaps.BaseBitmap()
        result, ismovie = curBmp.InitWith(str(inDocumentPath))
        if result==c4d.IMAGERESULT_NOTEXISTING:
            print "Image loade NOTEXISTING"
        if result==c4d.IMAGERESULT_WRONGTYPE:
            print "Image loade WRONGTYPE"
        if result==c4d.IMAGERESULT_OUTOFMEMORY:
            print "Image loade OUTOFMEMORY"
        if result==c4d.IMAGERESULT_FILEERROR:
            print "Image loade FILEERROR"
        if result==c4d.IMAGERESULT_FILESTRUCTURE:
            print "Image loade FILESTRUCTURE"
        if result==c4d.IMAGERESULT_MISC_ERROR:
            print "Image loade MISC_ERROR"
        if result==c4d.IMAGERESULT_PARAM_ERROR:
            print "Image loade PARAM_ERROR"
        if result==c4d.IMAGERESULT_OK: #int check
            #print "Image loadet OK"
            # picture loaded
            if ismovie==True: #bool check
                print "Texture is Movie...There is no movie suupport in AWD..."
            else:
                validWidth, validHeight=checkTextureForPowerOfTwo(curBmp)  #pass # file is a movie
                if validWidth!=True and validHeight!=True:
                    exportData.AWDerrorObjects.append(classesHelper.AWDerrorObject(ids.ERRORMESSAGE5,inDocumentPath))
                    return
                if validWidth!=True:
                    exportData.AWDerrorObjects.append(classesHelper.AWDerrorObject(ids.ERRORMESSAGE5,inDocumentPath))
                    return
                if validHeight!=True:
                    exportData.AWDerrorObjects.append(classesHelper.AWDerrorObject(ids.ERRORMESSAGE5,inDocumentPath))
                    return
                hasAlpha=curBmp.GetInternalChannel()
                fileType="jpg"
                fileFormat=c4d.FILTER_JPG
                if hasAlpha is not None:
                    fileType="png"
                    fileFormat=c4d.FILTER_PNG
                fileName=str(newAWDBlock.saveLookUpName)+"."+str(fileType)
                filePath=os.path.dirname(exportData.datei)
                inDocumentPath=os.path.join(filePath,fileName)  
                didExist=False
                try:
                    with open(inDocumentPath) as f: didExist=True
                except IOError as e:    
                    pass
                
                #f = open(inDocumentPath, 'wb')    
                saveResult=curBmp.Save(inDocumentPath,fileFormat,savebits=c4d.SAVEBIT_ALPHA)
                if saveResult==c4d.IMAGERESULT_OK:
                    #print "ImageSave OK"
                    if exportData.embedTextures==0:                     # if the texture should be embed in the awd file:
                        texturefile=open(str(inDocumentPath),"rb")          # if the function has not returned yet, the 'inDocumentPath' points to a valid file, so we open this file
                        newAWDBlock.saveTextureData=texturefile.read()      # we just read all the bits of the file into a the bytestring 'saveTextureData'    
                        texturefile.close()
                        if didExist!=True:
                            os.remove(str(inDocumentPath))
                    newAWDWrapperBlock.tagForExport=True
                    newAWDWrapperBlock.data=newAWDBlock
                    
                newAWDBlock.isOK=True
                if saveResult==c4d.IMAGERESULT_NOTEXISTING:
                    newAWDBlock.isOK=False
                    print "ImageSave NOTEXISTING"
                if saveResult==c4d.IMAGERESULT_WRONGTYPE:
                    newAWDBlock.isOK=False
                    print "ImageSave WRONGTYPE"
                if saveResult==c4d.IMAGERESULT_OUTOFMEMORY:
                    newAWDBlock.isOK=False
                    print "ImageSave OUTOFMEMORY"
                if saveResult==c4d.IMAGERESULT_FILEERROR:
                    newAWDBlock.isOK=False
                    print "ImageSave FILEERROR"
                if saveResult==c4d.IMAGERESULT_FILESTRUCTURE:
                    newAWDBlock.isOK=False
                    print "ImageSave FILESTRUCTURE"
                if saveResult==c4d.IMAGERESULT_MISC_ERROR:
                    newAWDBlock.isOK=False
                    print "ImageSave MISC_ERROR"
                if saveResult==c4d.IMAGERESULT_PARAM_ERROR:
                    newAWDBlock.isOK=False
                    print "ImageSave PARAM_ERROR"
Ejemplo n.º 7
0
def createSceneBlock(exportData,
                     curObj,
                     tagForExport,
                     returner=True,
                     onlyNullObject=False):

    if onlyNullObject == False:
        if curObj.GetType() == c4d.Oextrude:
            if len(curObj.GetChildren()) == 0:
                return False, False

        if curObj.GetType() == c4d.Ospline:
            if len(curObj.GetChildren()) == 0:
                return False, False

    #####	Primitives
        isPrimitv = False
        if curObj.GetType() == c4d.Oplane:
            isPrimitv = True
            newAWDBlockGEO = classesAWDBlocks.PrimitiveGeometrieBlock(
                exportData.idCounter, 0, curObj)
            newAWDBlockGEO.primType = 1
            if curObj[c4d.PRIM_PLANE_WIDTH] != 100:
                newAWDBlockGEO.primitiveProps.append(101)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_PLANE_WIDTH])
            if curObj[c4d.PRIM_PLANE_HEIGHT] != 100:
                newAWDBlockGEO.primitiveProps.append(102)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_PLANE_HEIGHT])
            if curObj[c4d.PRIM_PLANE_SUBW] != 1:
                newAWDBlockGEO.primitiveProps.append(301)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_PLANE_SUBW])
            if curObj[c4d.PRIM_PLANE_SUBH] != 1:
                newAWDBlockGEO.primitiveProps.append(302)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_PLANE_SUBH])
            # to do: add yaxis up curObj[c4d.PRIM_AXIS]

        if curObj.GetType() == c4d.Ocube:
            isPrimitv = True
            newAWDBlockGEO = classesAWDBlocks.PrimitiveGeometrieBlock(
                exportData.idCounter, 0, curObj)
            newAWDBlockGEO.primType = 2
            if curObj[c4d.PRIM_CUBE_LEN].x != 100:
                newAWDBlockGEO.primitiveProps.append(101)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CUBE_LEN].x)
            if curObj[c4d.PRIM_CUBE_LEN].y != 100:
                newAWDBlockGEO.primitiveProps.append(102)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CUBE_LEN].y)
            if curObj[c4d.PRIM_CUBE_LEN].z != 100:
                newAWDBlockGEO.primitiveProps.append(103)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CUBE_LEN].z)
            if curObj[c4d.PRIM_CUBE_SUBX] != 1:
                newAWDBlockGEO.primitiveProps.append(301)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CUBE_SUBX])
            if curObj[c4d.PRIM_CUBE_SUBY] != 1:
                newAWDBlockGEO.primitiveProps.append(302)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CUBE_SUBY])
            if curObj[c4d.PRIM_CUBE_SUBZ] != 1:
                newAWDBlockGEO.primitiveProps.append(303)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CUBE_SUBZ])
            newAWDBlockGEO.primitiveProps.append(701)
            newAWDBlockGEO.primitiveValues.append(False)
            # for a cube exportet from c4d cube.tile6 will allways be false

        if curObj.GetType() == c4d.Osphere:
            isPrimitv = True
            newAWDBlockGEO = classesAWDBlocks.PrimitiveGeometrieBlock(
                exportData.idCounter, 0, curObj)
            newAWDBlockGEO.primType = 3
            if curObj[c4d.PRIM_SPHERE_RAD] != 50:
                newAWDBlockGEO.primitiveProps.append(101)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_SPHERE_RAD])
            if curObj[c4d.PRIM_SPHERE_SUB] != 16:
                newAWDBlockGEO.primitiveProps.append(301)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_SPHERE_SUB])
            # to do: sphere has two segments properties in away but only 1 in c4d
            #Sphere[c4d.PRIM_SPHERE_TYPE]
            #Sphere[c4d.PRIM_SPHERE_PERFECT]

        if curObj.GetType() == c4d.Ocylinder:
            isPrimitv = True
            newAWDBlockGEO = classesAWDBlocks.PrimitiveGeometrieBlock(
                exportData.idCounter, 0, curObj)
            newAWDBlockGEO.primType = 4
            if curObj[c4d.PRIM_CYLINDER_RADIUS] != 50:
                newAWDBlockGEO.primitiveProps.append(101)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CYLINDER_RADIUS])
            if curObj[c4d.PRIM_CYLINDER_HEIGHT] != 100:
                newAWDBlockGEO.primitiveProps.append(103)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CYLINDER_HEIGHT])
            if curObj[c4d.PRIM_CYLINDER_SEG] != 16:
                newAWDBlockGEO.primitiveProps.append(301)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CYLINDER_SEG])
            if curObj[c4d.PRIM_CYLINDER_HSUB] != 1:
                newAWDBlockGEO.primitiveProps.append(302)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CYLINDER_HSUB])
            #Cylinder[c4d.PRIM_AXIS]

        if curObj.GetType() == c4d.Ocone:
            isPrimitv = True
            newAWDBlockGEO = classesAWDBlocks.PrimitiveGeometrieBlock(
                exportData.idCounter, 0, curObj)
            if curObj[c4d.PRIM_CONE_TRAD] == 0:
                newAWDBlockGEO.primType = 5
            if curObj[c4d.PRIM_CONE_TRAD] > 0:
                newAWDBlockGEO.primType = 4
                if curObj[c4d.PRIM_CONE_TRAD] != 50:
                    newAWDBlockGEO.primitiveProps.append(101)
                    newAWDBlockGEO.primitiveValues.append(
                        curObj[c4d.PRIM_CONE_TRAD])
            if curObj[c4d.PRIM_CONE_BRAD] != 50:
                if curObj[c4d.PRIM_CONE_TRAD] > 0:
                    newAWDBlockGEO.primitiveProps.append(102)
                if curObj[c4d.PRIM_CONE_TRAD] == 0:
                    newAWDBlockGEO.primitiveProps.append(101)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CONE_BRAD])
            if curObj[c4d.PRIM_CONE_HEIGHT] != 100:
                if curObj[c4d.PRIM_CONE_TRAD] > 0:
                    newAWDBlockGEO.primitiveProps.append(103)
                if curObj[c4d.PRIM_CONE_TRAD] == 0:
                    newAWDBlockGEO.primitiveProps.append(102)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CONE_HEIGHT])
            if curObj[c4d.PRIM_CONE_SEG] != 16:
                newAWDBlockGEO.primitiveProps.append(301)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CONE_SEG])
            if curObj[c4d.PRIM_CONE_HSUB] != 1:
                newAWDBlockGEO.primitiveProps.append(302)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CONE_HSUB])
            #Cone[c4d.PRIM_AXIS]

        if curObj.GetType() == c4d.Ocapsule:
            isPrimitv = True
            newAWDBlockGEO = classesAWDBlocks.PrimitiveGeometrieBlock(
                exportData.idCounter, 0, curObj)
            newAWDBlockGEO.primType = 6
            if curObj[c4d.PRIM_CAPSULE_RADIUS] != 50:
                newAWDBlockGEO.primitiveProps.append(101)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CAPSULE_RADIUS])
            if curObj[c4d.PRIM_CAPSULE_HEIGHT] != 100:
                newAWDBlockGEO.primitiveProps.append(102)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CAPSULE_HEIGHT])
            if curObj[c4d.PRIM_CAPSULE_SEG] != 16:
                newAWDBlockGEO.primitiveProps.append(301)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_CAPSULE_SEG])
            #allHeightSegments=curObj[c4d.PRIM_CAPSULE_HSUB]+(curObj[c4d.PRIM_CAPSULE_FSUB]*2)
            #if allHeightSegments!=15:
            #    checkHeight=float(allHeightSegments/2);
            #    if float(math.round(checkHeight))!=float(checkHeight):
            #        allHeightSegments+=1
            #    newAWDBlockGEO.primitiveProps.append(302)
            #    newAWDBlockGEO.primitiveValues.append(allHeightSegments)
            #Cone[c4d.PRIM_AXIS]

        if curObj.GetType() == c4d.Otorus:
            isPrimitv = True
            newAWDBlockGEO = classesAWDBlocks.PrimitiveGeometrieBlock(
                exportData.idCounter, 0, curObj)
            newAWDBlockGEO.primType = 7
            if curObj[c4d.PRIM_TORUS_OUTERRAD] != 50:
                newAWDBlockGEO.primitiveProps.append(101)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_TORUS_OUTERRAD])
            if curObj[c4d.PRIM_TORUS_INNERRAD] != 50:
                newAWDBlockGEO.primitiveProps.append(102)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_TORUS_INNERRAD])
            if curObj[c4d.PRIM_TORUS_SEG] != 16:
                newAWDBlockGEO.primitiveProps.append(301)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_TORUS_SEG])
            if curObj[c4d.PRIM_TORUS_CSUB] != 8:
                newAWDBlockGEO.primitiveProps.append(302)
                newAWDBlockGEO.primitiveValues.append(
                    curObj[c4d.PRIM_TORUS_CSUB])
            #Torus[c4d.PRIM_AXIS]

        if isPrimitv == True:
            if curObj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == False and len(
                    curObj.GetChildren()) == 0:
                return False, False
            if curObj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == True:
                newAWDBlockGEO.name = "Geo_" + str(exportData.allAWDBlocks[int(
                    curObj.GetName())].name)

                newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(
                    curObj,
                    str(curObj.GetName()) + "_geom", 11)
                newAWDWrapperBlock.tagForExport = tagForExport
                exportData.idCounter += 1
                newAWDWrapperBlock.data = newAWDBlockGEO
                exportData.allAWDBlocks.append(newAWDWrapperBlock)

                newAWDBlock = classesAWDBlocks.MeshInstanceBlock(
                    exportData.idCounter, 0, exportData.idCounter - 1, curObj)
                newAWDBlock.dataParentBlockID = 0
                if curObj.GetTag(1019365):
                    newAWDBlock.isSkinned = True
                if curObj.GetUp():
                    parentID = exportData.allAWDBlocks[int(
                        curObj.GetUp().GetName())]
                    if parentID != None:
                        newAWDBlock.dataParentBlockID = int(
                            curObj.GetUp().GetName())
                newAWDBlock.name = exportData.allAWDBlocks[int(
                    curObj.GetName())].name
                exportData.allAWDBlocks[int(
                    curObj.GetName())].data = newAWDBlock
                exportData.allAWDBlocks[int(curObj.GetName())].blockType = 23
                exportData.allAWDBlocks[int(
                    curObj.GetName())].tagForExport = tagForExport
                newAWDBlockGEO.sceneBlocks.append(exportData.allAWDBlocks[int(
                    curObj.GetName())])
                exportData.allSceneObjects.append(exportData.allAWDBlocks[int(
                    curObj.GetName())])
                exportData.primitives.append(exportData.allAWDBlocks[int(
                    curObj.GetName())])
                return True, True

        if curObj.GetType() == c4d.Oinstance:
            allowedInstynceTypes = [
                c4d.Opolygon, c4d.Ocube, c4d.Osphere, c4d.Oplane,
                c4d.Ocylinder, c4d.Ocone, c4d.Ocapsule, c4d.Otorus
            ]
            if curObj[c4d.INSTANCEOBJECT_LINK].GetType() != c4d.Opolygon:
                if curObj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == False and len(
                        curObj.GetChildren()) == 0:
                    return False, False
            for allowedtype in allowedInstynceTypes:
                if curObj[c4d.INSTANCEOBJECT_LINK].GetType() == allowedtype:
                    newAWDBlock = classesAWDBlocks.MeshInstanceBlock(
                        int(curObj.GetName()), 0, None, curObj)
                    newAWDBlock.geoObj = curObj[c4d.INSTANCEOBJECT_LINK]
                    if curObj[c4d.INSTANCEOBJECT_RENDERINSTANCE] == True:
                        newAWDBlock.isRenderInstance = True

                    newAWDBlock.dataParentBlockID = 0
                    parentObj = curObj.GetUp()
                    if parentObj is not None:
                        parentID = exportData.allAWDBlocks[int(
                            curObj.GetUp().GetName())]
                        if parentID != None:
                            newAWDBlock.dataParentBlockID = int(
                                parentObj.GetName())
                    newAWDBlock.name = exportData.allAWDBlocks[int(
                        curObj.GetName())].name
                    exportData.allAWDBlocks[int(
                        curObj.GetName())].data = newAWDBlock
                    exportData.allAWDBlocks[int(
                        curObj.GetName())].blockType = 23
                    exportData.allAWDBlocks[int(
                        curObj.GetName())].tagForExport = tagForExport
                    exportData.allSceneObjects.append(
                        exportData.allAWDBlocks[int(curObj.GetName())])
                    exportData.unconnectedInstances.append(
                        exportData.allAWDBlocks[int(curObj.GetName())])
                    return True, True

            #print "Instance objects are only allowed to point to Mesh objects"
            if len(curObj.GetChildren()) == 0:
                return False, False

        if curObj.GetType() == c4d.Opolygon:

            meshInstanceID = int(curObj.GetName())
            newAWDBlockGEO = classesAWDBlocks.TriangleGeometrieBlock(
                exportData.idCounter, 0, curObj)

            newAWDWrapperBlock = classesAWDBlocks.WrapperBlock(
                curObj,
                str(exportData.allAWDBlocks[int(curObj.GetName())].name) +
                "_geom", 11)
            newAWDWrapperBlock.tagForExport = tagForExport
            newAWDBlockGEO.name = newAWDWrapperBlock.name
            newAWDWrapperBlock.data = newAWDBlockGEO
            exportData.allAWDBlocks.append(newAWDWrapperBlock)
            exportData.allMeshObjects.append(newAWDWrapperBlock)
            exportData.idCounter += 1

            newAWDBlock = classesAWDBlocks.MeshInstanceBlock(
                meshInstanceID, 0, exportData.idCounter - 1, curObj)
            newAWDBlock.dataParentBlockID = 0
            if curObj.GetTag(1019365):
                newAWDBlock.isSkinned = True
            if curObj.GetUp():
                parentID = exportData.allAWDBlocks[int(
                    curObj.GetUp().GetName())]
                if parentID != None:
                    newAWDBlock.dataParentBlockID = int(
                        curObj.GetUp().GetName())

            newAWDBlock.name = exportData.allAWDBlocks[int(
                curObj.GetName())].name
            exportData.allAWDBlocks[meshInstanceID].data = newAWDBlock
            exportData.allAWDBlocks[meshInstanceID].blockType = 23
            exportData.allAWDBlocks[meshInstanceID].tagForExport = tagForExport
            exportData.allSceneObjects.append(
                exportData.allAWDBlocks[meshInstanceID])
            newAWDBlockGEO.sceneBlocks.append(
                exportData.allAWDBlocks[meshInstanceID])
            return True, True

        if curObj.GetType() == c4d.Oskin:
            if len(curObj.GetChildren()) == 0:
                return False, False

        if curObj.GetType() == c4d.Ojoint:
            if curObj.GetTag(1028937):
                skeletonTag = curObj.GetTag(1028937)
                if skeletonTag[1014] == False or skeletonTag[1010] == False:
                    #print "Do not export Skeleton as SceneObjects"
                    tagForExport = False
                    returner = True

                return False, False

        if curObj.GetType() == c4d.Ocamera:
            newAWDBlock = classesAWDBlocks.CameraBlock(int(curObj.GetName()),
                                                       0, curObj)
            if curObj.GetUp():
                parentID = exportData.allAWDBlocks[int(
                    curObj.GetUp().GetName())]
                if parentID != None:
                    newAWDBlock.dataParentBlockID = int(
                        curObj.GetUp().GetName())
            newAWDBlock.name = exportData.allAWDBlocks[int(
                curObj.GetName())].name

            projectionMode = curObj[c4d.CAMERA_PROJECTION]
            if projectionMode == 0:
                newAWDBlock.lensType = 5001
                newAWDBlock.lensFOV = curObj[c4d.CAMERAOBJECT_FOV_VERTICAL] * (
                    180 / math.pi)

            exportData.allAWDBlocks[int(curObj.GetName())].data = newAWDBlock
            exportData.allAWDBlocks[int(curObj.GetName())].blockType = 41
            exportData.allAWDBlocks[int(
                curObj.GetName())].tagForExport = tagForExport
            exportData.allSceneObjects.append(exportData.allAWDBlocks[int(
                curObj.GetName())])
            return True, True

        if curObj.GetType() == c4d.Olight:
            if curObj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == False and len(
                    curObj.GetChildren()) == 0:
                return False, False
            if curObj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == True:
                lightType = None
                if curObj[c4d.LIGHT_TYPE] == 0:
                    lightType = 1
                if curObj[c4d.LIGHT_TYPE] == 3:
                    lightType = 2
                if lightType is not None:
                    newAWDBlock = classesAWDBlocks.LightBlock(
                        int(curObj.GetName()), 0, curObj, lightType)
                    if exportData.unusedMats == True:
                        newAWDBlock.tagForExport = True
                    if curObj.GetUp():
                        parentID = exportData.allAWDBlocks[int(
                            curObj.GetUp().GetName())]
                        if parentID != None:
                            newAWDBlock.dataParentBlockID = int(
                                curObj.GetUp().GetName())
                    newAWDBlock.name = exportData.allAWDBlocks[int(
                        curObj.GetName())].name
                    mainLightRouting.createLight(newAWDBlock)
                    exportData.allAWDBlocks[int(
                        curObj.GetName())].data = newAWDBlock
                    exportData.allAWDBlocks[int(
                        curObj.GetName())].blockType = 41
                    exportData.allAWDBlocks[int(
                        curObj.GetName())].tagForExport = tagForExport
                    exportData.allSceneObjects.append(
                        exportData.allAWDBlocks[int(curObj.GetName())])
                    exportData.allLightBlocks.append(
                        exportData.allAWDBlocks[int(curObj.GetName())])
                    return True, True

    newAWDBlock = classesAWDBlocks.ContainerBlock(exportData.idCounter, 0,
                                                  curObj)
    newAWDBlock.dataParentBlockID = 0
    if curObj.GetUp():
        parentID = exportData.allAWDBlocks[int(curObj.GetUp().GetName())]
        if parentID != None:
            newAWDBlock.dataParentBlockID = int(curObj.GetUp().GetName())
    newAWDBlock.name = exportData.allAWDBlocks[int(curObj.GetName())].name
    exportData.allAWDBlocks[int(curObj.GetName())].data = newAWDBlock
    exportData.allAWDBlocks[int(curObj.GetName())].blockType = 22
    exportData.allAWDBlocks[int(curObj.GetName())].tagForExport = tagForExport
    exportData.allSceneObjects.append(exportData.allAWDBlocks[int(
        curObj.GetName())])

    return returner, tagForExport
Ejemplo n.º 8
0
def createBaseBlock(exportData, object):
    newAWDBlock = classesAWDBlocks.WrapperBlock(object, object.GetName(), 0)
    exportData.allAWDBlocks.append(newAWDBlock)
    object.SetName(str(exportData.idCounter))
    exportData.idCounter += 1