finnding the height when we click the mouse(solved)

prath

03-07-2008 12:28:32

hi,iam not able to get the correct hit point when we click the mouse,iam writing some code that i have used

ogre::ray camray;

OgreNewt::BasicRaycast myRay(me->getWorld(),camray.origin(), camray.getpoint(1000) );

info=myRay.getfirsthit() ;

real distance=info.distance;
vector3 pos=camray.getpoint(distance);

mynode->setposition(pos);
this is the code iam usning.

when i press the mouse on the terrain i need to position the scenenode(mynode) at the ray hit position,but iam not getting the exact height at the given position, my object is placing very high on the terrain

my aim is to find the height of the terrain where we click the mouse on the entitty

help me how can i solve the problem

albino

03-07-2008 15:49:44

have you read the examples,

theres code for that, in them you can drag objects but it uses

the raycast, those examples helped me alot

prath

04-07-2008 05:27:24

hi albino,

i searched in the sample raycast and in buyancy there he is using basicraycast i tried with that, info.distance always returns between 0 and 1 ,due to this iam not getting exact hit point for the ray.

please it will be very helpful for me if u send me the sample where can i get the exact hit point and tell me how can i use the raycast instead of basicraycast

walaber

04-07-2008 14:03:43

the returned value between 0 and 1 is "how far between start, and end.

so, to get the exact hit point in world space, you do this:

start + ((end - start) * info.distance);

prath

05-07-2008 04:41:11

thanks walaber,
i got the solution