Forum

duplicating prydoncursor's cursor_trace_endpos in csqc

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

duplicating prydoncursor's cursor_trace_endpos in csqc

Postby daemon » Sun Dec 16, 2007 5:29 am

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 ]
User avatar
daemon
 
Posts: 63
Joined: Wed Nov 07, 2007 11:10 pm

Postby Spike » Mon Dec 17, 2007 12:21 pm

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).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby daemon » Tue Dec 18, 2007 4:48 am

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 ]
User avatar
daemon
 
Posts: 63
Joined: Wed Nov 07, 2007 11:10 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest