Difference between revisions of "DevDoc:HUD"
From SfzWiki
Ghoulsblade (Talk | contribs) |
(replace indenting with <code> blocks) |
||
(One intermediate revision by one user not shown) | |||
Line 8: | Line 8: | ||
otherwise use autotracking : to avoid iterating over all objects/hudelements which is expansive in lua, see gfx2D.h | otherwise use autotracking : to avoid iterating over all objects/hudelements which is expansive in lua, see gfx2D.h | ||
+ | <code> | ||
+ | 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; | ||
+ | </code> | ||
− | + | (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) | 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. | |
− | + | ||
− | + | <code> | |
+ | function MakeObjectHudMarker (trackgfx,col) | ||
local mat = GetPlainTextureMat("raute.png") | local mat = GetPlainTextureMat("raute.png") | ||
mat = GetHuedMat(mat,1,1,1, 1,1,1,0.5) -- white color, halftransparent | mat = GetHuedMat(mat,1,1,1, 1,1,1,0.5) -- white color, halftransparent | ||
local e = 32 -- image-size | local e = 32 -- image-size | ||
local hudmarker = guimaker.MakePlane(gHudMarkerDialogLayer.panel,mat,-0.5*e,-0.5*e,e,e) | 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:SetTrackOffset(-0.5*e,-0.5*e) | ||
hudmarker.gfx:SetTrackPosSceneNode(trackgfx) | hudmarker.gfx:SetTrackPosSceneNode(trackgfx) | ||
hudmarker.gfx.mbTrackHideIfClamped = false | hudmarker.gfx.mbTrackHideIfClamped = false | ||
hudmarker.gfx.mbTrackHideIfBehindCam = false | hudmarker.gfx.mbTrackHideIfBehindCam = false | ||
+ | |||
local vw,vh = GetViewportSize() | local vw,vh = GetViewportSize() | ||
+ | |||
hudmarker.gfx.mbTrackClamp = true | hudmarker.gfx.mbTrackClamp = true | ||
hudmarker.gfx.mvTrackClampMin = {0,0} | hudmarker.gfx.mvTrackClampMin = {0,0} | ||
hudmarker.gfx.mvTrackClampMax = {vw,vh} | hudmarker.gfx.mvTrackClampMax = {vw,vh} | ||
return hudmarker | return hudmarker | ||
− | + | end | |
− | + | </code> | |
[[Category:DevDoc]] | [[Category:DevDoc]] |
Latest revision as of 09:13, 22 August 2007
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