Samples/MaterialAndTexture/LayeredTexture.py

# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
# ...
# This scipt is to demonstrate the usage of material and texture.
# ...
#
# Topic: FBLayeredTexture, FBVector3d, FBColor, FBMaterialTextureType, FBTextureBlendMode
#

# for directory access
import os
#
from pyfbsdk import FBSystem, FBModel, FBModelPlane, FBMaterial, FBTexture, FBLayeredTexture, FBVector3d, FBColor, FBMaterialTextureType, FBTextureBlendMode

# Create a plane
lPlane = FBModelPlane("My Plane")
lPlane.Rotation = FBVector3d(90, 0, 0)
lPlane.Translation = FBVector3d(0, 40, 0)
lPlane.Show = True
lPlane.Visible = True

# Create texture layers
lTexture1 = FBTexture( os.path.abspath(os.path.join( FBSystem().ApplicationPath, "../system/material_background.tif" ) ) )
lTexture2 = FBTexture( os.path.abspath(os.path.join( FBSystem().ApplicationPath, "../system/actor-picture.tif" )) )

# Create layeredTexture and constuct its layers
lLayeredTexture = FBLayeredTexture("layeredTexture")
lLayeredTexture.Layers.append(lTexture2)
lLayeredTexture.Layers.append(lTexture1)

lTexture2.BlendMode = FBTextureBlendMode.kFBTextureBlendTranslucent


# HardSelect layeredTexture to bring up its setting UI
lLayeredTexture.HardSelect()

# Create a material and connect texture to material's diffuse channel.
lMaterial = FBMaterial("My Material")
lMaterial.SetTexture(lLayeredTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)

# Map material to plane
lPlane.Materials.append(lMaterial)