Samples/HUD/HUDElements.py

Samples/HUD/HUDElements.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 script is to demonstrate the usage of material and texture.
7 # ...
8 #
9 # Topic: FBHUD, FBHUDFlashElement, FBHUDTextElement, FBHUDTextureElement, FBHUDRectElement, FBTexture
10 #
11 
12 # for directory access
13 import os
14 from pyfbsdk import FBHUD, FBScene, FBApplication, FBSystem, FBHUDFlashElement, FBHUDTextElement, FBHUDTextureElement, FBHUDRectElement, FBTexture, FBHUDElementHAlignment
15 
16 FBApplication().FileNew()
17 
18 lHud = FBHUD("MyHUD 1")
19 lHud.Visibility = True
20 FBSystem().Scene.ConnectSrc(lHud) # Connect the HUD to the scene
21 FBSystem().Scene.Cameras[0].ConnectSrc(lHud) # Connect to Perspective camera
22 
23 lRect = FBHUDRectElement("My Rect");
24 lHud.ConnectSrc(lRect);
25 
26 # Note that if ScaleUniformly is set True (As it is by default)
27 # then Height is dominant.
28 
29 lRect.ScaleUniformly = False
30 lRect.Width = 100
31 
32 
33 lText = FBHUDTextureElement("My Texture");
34 lHud.ConnectSrc(lText);
35 
36 # Note that if ScaleUniformly is set True (As it is by default)
37 # then Height is dominant.
38 
39 lText.Height = 34
40 lText.Y = 50
41 lText.X = 60
42 
43 # Modify lTextureFile according if you like to use your own texture image file.
44 lTextureFile = os.path.join(FBSystem().ConfigPath, 'Scripts/Samples/HUD/hud_texture.tif')
45 lTextureFile = os.path.normpath(lTextureFile)
46 
47 lTexture1 = FBTexture(lTextureFile)
48 lText.Texture.append(lTexture1)
49 
50 # Modify lFlashFile according if you like to use your own flash file.
51 # Also, you can find the same sample flash file for other flash versions in the folder containing this sample script.
52 lFlashFile = os.path.join(FBSystem().ConfigPath, 'Scripts/Samples/HUD/hud_flash_v10.swf')
53 lFlashFile = os.path.normpath(lFlashFile)
54 
55 lFlash = FBHUDFlashElement("My Flash");
56 lHud.ConnectSrc(lFlash);
57 
58 lFlash.FilePath = lFlashFile;
59 
60 lFlash.Height = 50
61 lFlash.Y = 20
62 lFlash.Align = FBHUDElementHAlignment.kFBHUDRight;
63 
64 lRecordLight = lHud.CreateElement(FBHUD.eRecordLight, "The record light")
65