Samples/HUD/HUDElements.py
 
 
 
Samples/HUD/HUDElements.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 script is to demonstrate the usage of material and texture.
# ...
#
# Topic: FBHUD, FBHUDFlashElement, FBHUDTextElement, FBHUDTextureElement, FBHUDRectElement, FBTexture
#

# for directory access
import os
from pyfbsdk import FBHUD, FBScene, FBApplication, FBSystem, FBHUDFlashElement, FBHUDTextElement, FBHUDTextureElement, FBHUDRectElement, FBTexture, FBHUDElementHAlignment

FBApplication().FileNew()

lHud = FBHUD("MyHUD 1")
lHud.Visibility = True
FBSystem().Scene.ConnectSrc(lHud)          # Connect the HUD to the scene
FBSystem().Scene.Cameras[0].ConnectSrc(lHud) # Connect to Perspective camera

lRect = FBHUDRectElement("My Rect");
lHud.ConnectSrc(lRect);

# Note that if ScaleUniformly is set True (As it is by default)
# then Height is dominant.

lRect.ScaleUniformly = False
lRect.Width = 100


lText = FBHUDTextureElement("My Texture");
lHud.ConnectSrc(lText);

# Note that if ScaleUniformly is set True (As it is by default)
# then Height is dominant.

lText.Height = 34
lText.Y = 50
lText.X = 60

# Modify lTextureFile according if you like to use your own texture image file.
lTextureFile = os.path.join(FBSystem().ConfigPath, 'Scripts/Samples/HUD/hud_texture.tif')
lTextureFile = os.path.normpath(lTextureFile)

lTexture1 = FBTexture(lTextureFile)
lText.Texture.append(lTexture1)

# Modify lFlashFile according if you like to use your own flash file.
# Also, you can find the same sample flash file for other flash versions in the folder containing this sample script.
lFlashFile = os.path.join(FBSystem().ConfigPath, 'Scripts/Samples/HUD/hud_flash_v10.swf')
lFlashFile = os.path.normpath(lFlashFile)

lFlash = FBHUDFlashElement("My Flash");
lHud.ConnectSrc(lFlash);

lFlash.FilePath = lFlashFile;

lFlash.Height = 50
lFlash.Y = 20
lFlash.Align = FBHUDElementHAlignment.kFBHUDRight;

lRecordLight = lHud.CreateElement(FBHUD.eRecordLight, "The record light")