DevDoc:HUD

From SfzWiki
Revision as of 20:34, 24 June 2007 by Ghoulsblade (Talk | contribs)

Jump to: navigation, search

HUD : Head-up display, a visual display technology for fighter airplanes, cars and others

HUD-elements includes object markers such as the edges around objects and the text next to them

such hud elements are 2d graphics aligned to the projected positions of 3d objects

for special hudelements with custom geometry (lines) use Hook_HUDStep and project object pos manually (obj.mvPos, obj.mfBoundingRad, ProjectSizeAndPosEx)

otherwise use autotracking : to avoid iterating over all objects/hudelements which is expansive in lua, see gfx2D.h

 Vector2	mvTrackPosOffset;	///< in pixels
 Vector2	mvTrackPosTargetSizeFactor;
 Vector2	mvTrackPosOwnSizeFactor;
 Vector2	mvTrackClampMin; ///< left top border, in pixels, clamps projected target pos
 Vector2	mvTrackClampMax; ///< right bottom border
 Vector2	mvTrackSetSizeFactor; ///< for mbTrackSetSize
 bool		mbTrackClamp;
 bool		mbTrackHideIfClamped;		///< warning, overrides manual visibility
 bool		mbTrackHideIfBehindCam;		///< warning, overrides manual visibility
 bool		mbTrackClampMaxXIfBehindCam;
 bool		mbTrackClampMaxYIfBehindCam;
 bool		mbTrackSetSize; ///< see also mvTrackSetSizeFactor
 bool		mbTrackMouse;

(these fields are also accessible from lua) mvTrackClampMin,mvTrackClampMax : clamp to border l,t,r,b (can be smaller than screen e.g. menu bar on a side)


example for a simple marker over an object

 function MakeObjectHudMarker (trackgfx,col) 
   local mat = GetPlainTextureMat("raute.png")
   mat = GetHuedMat(mat,1,1,1, 1,1,1,0.5)  -- white color, halftransparent
   local e = 32 -- image-size
   local hudmarker = guimaker.MakePlane(gHudMarkerDialogLayer.panel,mat,-0.5*e,-0.5*e,e,e)
   hudmarker.gfx:SetTrackOffset(-0.5*e,-0.5*e)
   hudmarker.gfx:SetTrackPosSceneNode(trackgfx)
   hudmarker.gfx.mbTrackHideIfClamped = false
   hudmarker.gfx.mbTrackHideIfBehindCam = false
   local vw,vh = GetViewportSize()
   hudmarker.gfx.mbTrackClamp = true
   hudmarker.gfx.mvTrackClampMin = {0,0}
   hudmarker.gfx.mvTrackClampMax = {vw,vh}
   return hudmarker
 end