How to use Viewport.Project() in the GUI?
by Trent · in Torque X 3D · 01/14/2010 (12:36 am) · 5 replies
In my pre-TX engine that I wrote I had some code that would project the position of an onject onto my gui using Viewport.Project(). I'm trying to use that code now, but I think TX using +Y as forward is giving me grief, and I don't know how to adapt it to work with TX.
Any ideas?
Do I need to switch Y & Z in my position before calling Project()?
Is GUICanvas.Instance.RenderState.Projection independent of this axis system?
Any ideas?
Do I need to switch Y & Z in my position before calling Project()?
Is GUICanvas.Instance.RenderState.Projection independent of this axis system?
About the author
#2
John K.
01/16/2010 (1:34 am)
Trent, I've already done exactly this. Have you solved this already, or should I start posting up some code?John K.
#3
01/16/2010 (2:12 am)
It seems to be working fine, except the Z value hovers very close to 1.0 no matter what, somewhere like 0.999 to 1.0004 or something like that. I'll take another look and see if I can confirm these values.
#4
It gets to about 0.998 when looking up at my ship (+Z) and about 1.0015 when looking down at the ship (-Z) and about 1.00014 when facing -Y.
I should also mention that I am using graph.CurrentSceneRenderState.World.Top for my world matrix.
01/16/2010 (2:18 am)
Ok, when facing the object Z is 0.9998873 at 800 Y, and the far distance of my camera is 20000. I don't know what the near plane distance is, I think that is internal to the engine and I haven't found it yet, nor have I actually looked.It gets to about 0.998 when looking up at my ship (+Z) and about 1.0015 when looking down at the ship (-Z) and about 1.00014 when facing -Y.
I should also mention that I am using graph.CurrentSceneRenderState.World.Top for my world matrix.
#5
01/16/2010 (6:39 am)
I should say that I have achieved what I was after, so to me at the moment, the Z value isn't important. Whether it's buggy or not though I don't really know.
Torque Owner Trent