Tasks/HUD.py

Tasks/HUD.py
1 # Copyright 2011 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 # Script description:
7 # Creates a "static" FBHUDTextElement (at center) and a moving
8 # FBHUDTextElement (scrolling up vertically).
9 #
10 # Topic: FBHUD, FBHUDTextElement
11 #
12 from pyfbsdk import *
13 
14 def HUDDisplay(HUD, event):
15  HUDTextElement.Y = HUDTextElement.Y + 1
16  if(HUDTextElement.Y > 100):
17  HUDTextElement.Y = 0
18 
19 #Init
20 Scene = FBSystem().Scene
21 System = FBSystem()
22 Application = FBApplication()
23 
24 #Create HUD with Text Element
25 Application.FileNew()
26 
27 HUD = FBHUD("MyHUD")
28 HUDTextElement = FBHUDTextElement("Center Element")
29 Scene.ConnectSrc(HUD) # Connect the HUD to the scene
30 HUDTextElement.Content = "HUD Element in the Center of the viewer"
31 HUDTextElement.X = 0
32 HUDTextElement.Y = 0
33 HUDTextElement.Scale = 2
34 HUDTextElement.Justification = FBHUDElementHAlignment.kFBHUDCenter
35 HUDTextElement.HorizontalDock = FBHUDElementHAlignment.kFBHUDCenter
36 HUDTextElement.VerticalDock = FBHUDElementVAlignment.kFBHUDVCenter
37 HUD.ConnectSrc(HUDTextElement) # Connect HUDTextElement to the HUD
38 Scene.Cameras[0].ConnectSrc(HUD) # Connect to Perspective camera
39 
40 HUDTextElement = FBHUDTextElement("Top Element")
41 Scene.ConnectSrc(HUD) # Connect the HUD to the scene
42 HUDTextElement.Content = "Free memory : %d MB"
43 HUDTextElement.X = 0
44 HUDTextElement.Y = 0
45 HUDTextElement.Scale = 2
46 HUDTextElement.Justification = FBHUDElementHAlignment.kFBHUDCenter
47 HUDTextElement.HorizontalDock = FBHUDElementHAlignment.kFBHUDCenter
48 HUDTextElement.VerticalDock = FBHUDElementVAlignment.kFBHUDTop
49 HUDTextElement.PropertyAddReferenceProperty(HUD.PropertyList.Find("FreeMemory"))
50 HUD.ConnectSrc(HUDTextElement) # Connect HUDTextElement to the HUD
51 Scene.Cameras[0].ConnectSrc(HUD) # Connect to Perspective camera
52 
53 # Register for HUD Display
54 HUD.OnDisplay.Add(HUDDisplay)