Inside3D!
     

duplicating prydoncursor's cursor_trace_endpos in csqc

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
daemon



Joined: 07 Nov 2007
Posts: 62

PostPosted: Sun Dec 16, 2007 5:29 am    Post subject: duplicating prydoncursor's cursor_trace_endpos in csqc Reply with quote

How would this be accomplished, and still allow fov and resolution changes while functioning correctly in every configuration?

cursor_trace_endpos works perfectly with prydon cursor, but I'm using a csqc cursor, and the math to get this to work seems beyond my scope. I can hack it to work, but if you change fov or go to a few certain resolutions, it breaks.

If I can somehow figure out how many quake units are visible within the view across a certain plane then I can make this work for me, but I have no idea how to do the math for that.

basically, my goal is to draw an entity in the world under the mouse cursor, on a plane intersecting or relative to '0 0 0' while the view is about 144 units away from '0 0 0'.
_________________
-daemon [ daemonforge.org ]
Back to top
View user's profile Send private message Visit poster's website
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Mon Dec 17, 2007 12:21 pm    Post subject: Reply with quote

there should be an unproject builtin.

projection of a 3d point converts a 3d vertex into a 2d position.
you want to do the oposite, thus use the unproject builtin.

set up the view properties first (this is required to get the right view angles, fov, and other stuff, presumably you already do this at the start of the frame).
then call the unproject function with 'x, y, z', where z is a value between 0 and 1. probably best to avoid 1 itself,and use 0.999 instead though (paranoia about infinitly distant far clip planes).
If you do use the two extremes, you have two points marking the 'line' that the cursor is on. Just traceline along it to find the wall or whatever it hits, or just normalise the difference to find a unit vector.

I'm still not sure what exactly you want to obtain, but hopefully you can figure out how to get it now.
Note that the near clip plane is typically around 4 (so z=0 will not give view origin, but should be fairly close).
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
daemon



Joined: 07 Nov 2007
Posts: 62

PostPosted: Tue Dec 18, 2007 4:48 am    Post subject: Reply with quote

Can you give a small example of how unproject is used. I can't seem to get any results that make any sense.
_________________
-daemon [ daemonforge.org ]
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group