Samples/MaterialAndTexture/MaterialAndTexture.py

Samples/MaterialAndTexture/MaterialAndTexture.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
10 #
11 
12 from pyfbsdk import FBSystem, FBModel, FBModelCube, FBMaterial, FBTexture, FBVector3d, FBColor, FBMaterialTextureType
13 
14 
15 # for directory access
16 import os
17 
18 # Create a cube
19 lCube = FBModelCube("My Cube")
20 lCube.Scaling = FBVector3d(40, 40, 20)
21 lCube.Show = True
22 lCube.Visible = True
23 
24 # Create a material
25 lMaterial = FBMaterial("My Material")
26 
27 # HardSelect Material to bring up Material Settings Pane
28 lMaterial.HardSelect()
29 
30 # Set Material basic properties
31 lMaterial.Diffuse = FBColor(1, 0, 0)
32 lMaterial.Ambient = FBColor(0.5, 0.5, 0)
33 
34 # Create a texture
35 lTexture = FBTexture(os.path.abspath(os.path.join( FBSystem().ApplicationPath, "../system/actor-picture.tif" )))
36 
37 # Set texture to material's diffuse channel.
38 lMaterial.SetTexture(lTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)
39 
40 # Attach material to cube
41 lCube.Materials.append(lMaterial)
42 
43