Attaching a GraphicItem to an entity?

FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
Just wondering if there's some way to parent/attach GUIItems to entities so that the gui's follow the entity around, i.e. like how ammo-gui's stick to weapons.

Comments

  • fsfodfsfod uk Join Date: 2004-04-09 Member: 27810Members, NS2 Developer, Constellation, NS2 Playtester, Squad Five Blue, Squad Five Silver, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    Ammo-gui stuff is set by a map node in the models material file <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><map type="flash_emissive" value="lua/GUIRifleDisplay.lua" /><!--c2--></div><!--ec2-->
    There no way to directly attach models that i know of, you can either do just what GUIPlayerNames does and do worldtoscreen for each player and draw stuff normally.

    The other way is a lot more effort and its kinda theoretical but the effect should be better. Your gonna have to create yourself a simple model thats just a single square face with some random texture stretched across it. After you exported it as a collada file you get to have fun converting it <a href="http://www.unknownworlds.com/ns2/wiki/index.php/Builder" target="_blank">http://www.unknownworlds.com/ns2/wiki/index.php/Builder</a> after that you can just just create RenderModel for each player you want to set a label above and set it to the model you created. Your gonna have to keep updating the rotation and position of these RenderModel's based on the camera rotation so there effectively billboards and when the players move
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
    edited June 2011
    I think the second approach you describe is what the infestation decals use. The contents of: ns2\models\misc\infestation seem to indicate this, i.e. the 1kb file: infestation.model.

    Anyway that approach would be fine for holograms (i.e. floating textures in 3D space which get obstructed by other objects), but what i had in mind is more of a augmented reality effect (i.e. the textures must show through obstructed objects, and i don't know if it's possible to enable that for a texture??).

    Which means i'm back to WorldToScreen, and the <i>fun</i> that is compensating for translational and angular motion.

    Surprisingly the devs never compensate for this in either GUIPlayerNames.lua (in commander view, move the camera quickly and watch the names bounce 10+ ft off the players in the direction of movement) or GUIHiveBlips.lua (hive sight, where blips go invisible for visible items, which sort of masks the problem).

    EDIT: I just wrote a simple fix for GUIPlayerNames.lua (it's simple for this because angular motion isn't possible) ... now to pm Cory and you'll probably see it in next patch xD.

    My current approach to compensation has been quite a battle. I wonder if their's an easier way then positioning the tags using spherical coordinates + tons of vector + trig operations (per update, per tag) so that rapid changes in pitch and yaw can be countered.
  • FocusedWolfFocusedWolf Join Date: 2005-01-09 Member: 34258Members
    edited June 2011
    68 variations later, i find the right combination of attempts to achieve what i was after. <u>Perfect</u> compensation for translational + angular velocities (i.e. the tags follow objects on screen PERFECTLY). Now to improve/optimize the solution and remove miles of commented out code xD

    EDIT: hmm it seems that camera-bobbing needs to be compensated for also, i.e. when you shoot (yes there is a little screen motion/recoil), reload or sprint there's a little wobble. It'll probably be easy to fix by comparison.
Sign In or Register to comment.