# 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: FBMaterial, FBTexture, FBMaterialTextureType
#

from pyfbsdk import FBModel, FBModelCube, FBMaterial, FBTexture, FBVector3d, FBColor, FBMaterialTextureType

# Create a cube
lCube = FBModelCube("My Cube")
lCube.Scaling = FBVector3d(40, 40, 20)
lCube.Show = True
lCube.Visible = True

# Create a material
lMaterial = FBMaterial("My Material")

# HardSelect Material to bring up Material Settings Pane
lMaterial.HardSelect()

# Set Material basic properties
lMaterial.Diffuse = FBColor(1, 0, 0)
lMaterial.Ambient = FBColor(0.5, 0.5, 0)

# Create a texture
lTexture = FBTexture(os.path.realpath("../../../../system/characterctrl/character-picture.tif"))

# Set texture to material's diffuse channel.
lMaterial.SetTexture(lTexture, FBMaterialTextureType.kFBMaterialTextureDiffuse)

# Attach material to cube
lCube.Materials.append(lMaterial)