Unable to login >-[
If you know your camera position in 3d space you can use math to compute your intersection -> this is a line/plane intersection, your line being defined by your camera center and the "looking-at" direction vector.
line equation :
x = xC + dir.x*t
y = yC + dir.y*t
z = zC + dir.z*t
plane :
ax + by +cz + d = 0 -> being xz plane gives :
by = 0;
then combining with line equation :
yC + dir.y*t = 0 ->
t = -yC / dir.y
then
x = xC + dir.x*t
z = zC + dir.z*t
If your terrain is not a plane it''s a bit more complicated, but it can also be done.
How to find cords of a mouse on a 2d plane?
Ok I wrote some code to find the point on a plance between 2 points.
I''m getting conflicting information.
"for eg. in your RTS game, this would be a point on your heightmap"
Or is the point on the far clipping plane?
I havnt had time to dl and look at the samle code, ill do that in a few hours when i get time.
I''m getting conflicting information.
"for eg. in your RTS game, this would be a point on your heightmap"
Or is the point on the far clipping plane?
I havnt had time to dl and look at the samle code, ill do that in a few hours when i get time.
The way I''ve always heard to do 3d selection is the ray method. What you do is unProject to the near clip plane and then you unProject to the far clip plane. This gives you two points from which a ray can be created. Using this ray you can hit test all of the objects in your scene ( that are relevant, like your terrain ) and then and if the ray passes through, you select the object. This also allows for full 3d selection, instead of being restrained to one plane. Of course the math is slightly more complicated though.
Yeah, i can just use the camera posistion for the close point. By defualt does it return the point of the mouse on the far clip plane?
I ran the demo on http://onemancrew.sinfree.net
has the cords on the far clipping plane, unless some polygon was in the way (the read pixels).
If i do it with out the read pixels and just set the wz for a high number will that just give me the back clipping plane?
BTW i apricate the help, thanks guys
[edited by - skow on July 9, 2003 12:49:59 PM]
I ran the demo on http://onemancrew.sinfree.net
has the cords on the far clipping plane, unless some polygon was in the way (the read pixels).
If i do it with out the read pixels and just set the wz for a high number will that just give me the back clipping plane?
BTW i apricate the help, thanks guys
[edited by - skow on July 9, 2003 12:49:59 PM]
Erm nevermind, I just tested it, if i omit the pixel check and set the wz to 1, it will always give me the back cliping plane.
I dont know why i didnt jsut check instead of asking first
Thanks again for the help.
I dont know why i didnt jsut check instead of asking first

Thanks again for the help.
Hmmm, your (Gytis) code seems to work fine in your exe, but placed after some of my render code, it''s throwing funny numbers.
http://spongemop.dyndns.org/arch_mouse.jpg The last three numbers, after time and fps.
Looks to me like a bad cast between floating point and integer, but all the data types are the same as they are in your program. The three double coordinates are sprintf''ed as doubles in that screenshot, then printed using my bitmap font-print function.
Any idea what would be causing that?
http://spongemop.dyndns.org/arch_mouse.jpg The last three numbers, after time and fps.
Looks to me like a bad cast between floating point and integer, but all the data types are the same as they are in your program. The three double coordinates are sprintf''ed as doubles in that screenshot, then printed using my bitmap font-print function.
Any idea what would be causing that?

convert it to an int before being displayed.
do a
int temp = ox
then display temp and see if the numbers are still that funkey.
do a
int temp = ox
then display temp and see if the numbers are still that funkey.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement