Samples/MaterialAndTexture/TextureAnimation.py

Samples/MaterialAndTexture/TextureAnimation.py
1 # Copyright 2009 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 # ...
6 # This scipt is to demonstrate the usage of material and texture.
7 # ...
8 #
9 # Topic: FBMaterial, FBTexture, FBMaterialTextureType, FBTextureBlendMode
10 #
11 # for directory access
12 import os
13 #
14 from pyfbsdk import FBSystem, FBModel, FBModelPlane, FBMaterial, FBTexture, FBLayeredTexture, FBVector3d, FBColor, FBMaterialTextureType, FBTextureBlendMode
15 
16 # Create a plane
17 lPlane = FBModelPlane("My Plane")
18 lPlane.Rotation = FBVector3d(90, 0, 0)
19 lPlane.Translation = FBVector3d(0, 40, 0)
20 lPlane.Show = True
21 lPlane.Visible = True
22 
23 # Create texture layers
24 lTexture1 = FBTexture( os.path.abspath(os.path.join( FBSystem().ApplicationPath, "../system/material_background.tif" ) ) )
25 lTexture2 = FBTexture( os.path.abspath(os.path.join( FBSystem().ApplicationPath, "../system/actor-picture.tif" )) )
26 
27 # Create layeredTexture and constuct its layers
28 lLayeredTexture = FBLayeredTexture("layeredTexture")
29 
30 lLayeredTexture.Layers.append(lTexture1)
31 
32 lTexture2.BlendMode = FBTextureBlendMode.kFBTextureBlendTranslucent
33 lTexture2.Alpha = 0.6
34 lLayeredTexture.Layers.append(lTexture2)
35 
36 # HardSelect layeredTexture to bring up its setting UI
37 lLayeredTexture.HardSelect()
38 
39 # Create a material and connect texture to material's diffuse channel.
40 lMaterial = FBMaterial("My Material")
41 lMaterial.SetTexture(lLayeredTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)
42 
43 # Map material to plane
44 lPlane.Materials.append(lMaterial)
45