The first weblog devoted to Demoniak3D Demo-System

HUD and Z-Order

April 29th, 2008 Posted in Lua, Tips'n'Tricks, Tutorials
  • English
  • French

It’s possible to specify the order in which HUDs will be displayed by tuning HUD’s z position and enabling depth test. The following code snippet show us how to display a red HUD over a white one (although the red HUD has been specified first in the XML script). Just pay attention to the z range: -1.0 to +1.0.

<hud name="Red_Hud" render="TRUE" >
	<position x="-30.0" y="-20.0" z="0.7" />
	<size width="100" height="100" />

	<vertex_color index="0"
				  r="1.0" g="0.0" b="0.0" a="1.0"  />
	<vertex_color index="1"
				  r="1.0" g="0.0" b="0.0" a="1.0"  />
	<vertex_color index="2"
				  r="1.0" g="0.0" b="0.0" a="1.0"  />
	<vertex_color index="3"
				  r="1.0" g="0.0" b="0.0" a="1.0"  />
</hud>

<hud name="White_Hud" render="TRUE" >
	<position x="-50.0" y="0.0" z="0.8" />
	<size width="100" height="100" />
</hud>

<script name="init_scene" run_mode="INIT" >
	<raw_data><![CDATA[	 

	HYP_Object.SetDepthBufferState("White_Hud", 1);
	HYP_Object.SetDepthBufferState("Red_Hud", 1);

	HYP_Object.SetPosition("Red_Hud", -30, -20, 0.9);

	]]></raw_data>
</script>

Of course, this is also valid if the HUDs are LUA-dynamically created.

DOWNLOAD:
- DEMONIAK3D-HUD-Z-ORDER-DEMO.zip


[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

You must be logged in to post a comment.