Ejemplo n.º 1
0
def get_texture(pGeometry):
    textures = {}
    lNbMat = pGeometry.GetNode().GetSrcObjectCount(
        FbxCriteria.ObjectType(FbxSurfaceMaterial.ClassId))
    for lMaterialIndex in range(lNbMat):
        lMaterial = pGeometry.GetNode().GetSrcObject(
            FbxCriteria.ObjectType(FbxSurfaceMaterial.ClassId), lMaterialIndex)
        if lMaterial:
            for lTextureIndex in range(FbxLayerElement.sTypeTextureCount()):
                lProperty = lMaterial.FindProperty(
                    FbxLayerElement.sTextureChannelNames(lTextureIndex))
                if not lProperty.IsValid():
                    continue
                lLayeredTextureCount = lProperty.GetSrcObjectCount(
                    FbxCriteria.ObjectType(FbxLayeredTexture.ClassId))
                lNbTextures = lProperty.GetSrcObjectCount(
                    FbxCriteria.ObjectType(FbxTexture.ClassId))
                for j in range(lNbTextures):
                    lTexture = lProperty.GetSrcObject(
                        FbxCriteria.ObjectType(FbxTexture.ClassId), j)
                    if lTexture:
                        textures[lMaterial.GetName(
                        )] = lTexture.GetRelativeFileName()

    return textures
Ejemplo n.º 2
0
def DisplayGenericInfo(pScene):
    lRootNode = pScene.GetRootNode()

    for i in range(lRootNode.GetChildCount()):
        DisplayNodeGenericInfo(lRootNode.GetChild(i), 0)

    #Other objects directly connected onto the scene
    for i in range(pScene.GetSrcObjectCount(FbxCriteria.ObjectType(FbxObject.ClassId))):
        DisplayProperties(pScene.GetSrcObject(FbxCriteria.ObjectType(FbxObject.ClassId), i))
Ejemplo n.º 3
0
def DisplayTexture(pGeometry):
    lNbMat = pGeometry.GetNode().GetSrcObjectCount(FbxCriteria.ObjectType(FbxSurfaceMaterial.ClassId))
    for lMaterialIndex in range(lNbMat):
        lMaterial = pGeometry.GetNode().GetSrcObject(FbxCriteria.ObjectType(FbxSurfaceMaterial.ClassId), lMaterialIndex)
        lDisplayHeader = True

        #go through all the possible textures
        if lMaterial:            
            for lTextureIndex in range(FbxLayerElement.sTypeTextureCount()):
                lProperty = lMaterial.FindProperty(FbxLayerElement.sTextureChannelNames(lTextureIndex))
                FindAndDisplayTextureInfoByProperty(lProperty, lDisplayHeader, lMaterialIndex) 
Ejemplo n.º 4
0
def DisplayTextureNames(pProperty):
    lTextureName = ""

    lLayeredTextureCount = pProperty.GetSrcObjectCount(
        FbxCriteria.ObjectType(FbxLayeredTexture.ClassId))
    if lLayeredTextureCount > 0:
        for j in range(lLayeredTextureCount):
            lLayeredTexture = pProperty.GetSrcObject(
                FbxCriteria.ObjectType(FbxLayeredTexture.ClassId), j)
            lNbTextures = lLayeredTexture.GetSrcObjectCount(
                FbxCriteria.ObjectType(FbxTexture.ClassId))
            lTextureName = " Texture "

            for k in range(lNbTextures):
                lTextureName += "\""
                lTextureName += lLayeredTexture.GetName()
                lTextureName += "\""
                lTextureName += " "
            lTextureName += "of "
            lTextureName += pProperty.GetName().Buffer()
            lTextureName += " on layer "
            lTextureName += j
        lTextureName += " |"
    else:
        #no layered texture simply get on the property
        lNbTextures = pProperty.GetSrcObjectCount(
            FbxCriteria.ObjectType(FbxTexture.ClassId))

        if lNbTextures > 0:
            lTextureName = " Texture "
            lTextureName += " "

            for j in range(lNbTextures):
                lTexture = pProperty.GetSrcObject(
                    FbxCriteria.ObjectType(FbxTexture.ClassId), j)
                if lTexture:
                    lTextureName += "\""
                    lTextureName += lTexture.GetName()
                    lTextureName += "\""
                    lTextureName += " "
            lTextureName += "of "
            lTextureName += pProperty.GetName().Buffer()
            lTextureName += " |"

    return lTextureName
def FindAndDisplayTextureInfoByProperty(pProperty, pDisplayHeader,
                                        pMaterialIndex):
    if pProperty.IsValid():
        #Here we have to check if it's layeredtextures, or just textures:
        lLayeredTextureCount = pProperty.GetSrcObjectCount(
            FbxCriteria.ObjectType(FbxLayeredTexture.ClassId))
        if lLayeredTextureCount > 0:
            for j in range(lLayeredTextureCount):
                DisplayInt("    Layered Texture: ", j)
                lLayeredTexture = pProperty.GetSrcObject(
                    FbxCriteria.ObjectType(FbxLayeredTexture.ClassId), j)
                lNbTextures = lLayeredTexture.GetSrcObjectCount(
                    FbxCriteria.ObjectType(FbxTexture.ClassId))
                for k in range(lNbTextures):
                    lTexture = lLayeredTexture.GetSrcObject(
                        FbxCriteria.ObjectType(FbxTexture.ClassId), k)
                    if lTexture:
                        if pDisplayHeader:
                            DisplayInt("    Textures connected to Material ",
                                       pMaterialIndex)
                            pDisplayHeader = False

                        # NOTE the blend mode is ALWAYS on the LayeredTexture and NOT the one on the texture.
                        # Why is that?  because one texture can be shared on different layered textures and might
                        # have different blend modes.

                        lBlendMode = lLayeredTexture.GetTextureBlendMode(k)
                        DisplayString("    Textures for ", pProperty.GetName())
                        DisplayInt("        Texture ", k)
                        DisplayTextureInfo(lTexture, lBlendMode)
        else:
            # no layered texture simply get on the property
            lNbTextures = pProperty.GetSrcObjectCount(
                FbxCriteria.ObjectType(FbxTexture.ClassId))
            for j in range(lNbTextures):
                lTexture = pProperty.GetSrcObject(
                    FbxCriteria.ObjectType(FbxTexture.ClassId), j)
                if lTexture:
                    # display connectMareial header only at the first time
                    if pDisplayHeader:
                        DisplayInt("    Textures connected to Material ",
                                   pMaterialIndex)
                        pDisplayHeader = False

                    DisplayString("    Textures for ",
                                  pProperty.GetName().Buffer())
                    DisplayInt("        Texture ", j)
                    DisplayTextureInfo(lTexture, -1)

        lNbTex = pProperty.GetSrcObjectCount(
            FbxCriteria.ObjectType(FbxTexture.ClassId))
        for lTextureIndex in range(lNbTex):
            lTexture = pProperty.GetSrcObject(
                FbxCriteria.ObjectType(FbxTexture.ClassId), lTextureIndex)