finding the point on the terrain
finding the point on the terrain
i want to find the 3d point on the terrain when i right click on the screen .... tyn i need ur help....
help frm anyone who knows this>>>>>>>>>>>>
help frm anyone who knows this>>>>>>>>>>>>
-
DarkWhoppy
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact:
-
LordNaikon
- Posts: 164
- Joined: Wed May 05, 2004 5:34 pm
- Location: Germany Berlin
- Contact:
You should be able to draw a ray from the camera out to the world, colliding with the world. Then the end of the ray should be at the point of collision and you can get it from there, it's stored as a vector within the ray function, check the API. I haven't tried it yet but it should work, if not then there is a problem. GameDev.net solves a lot of problems for me, they have some good advice in their reference system.
do mean this one tyn
something like this....?
guys actually i need the point on a node.....
that too in 3d space..... so if i use getSceneNodeFromScreenCoordinatesBB
i will get the scene node itself not a point on that node....
Code: Select all
core::line3d<f32> line;
scene::ISceneCollisionManager *colmgr ;
core::position2d<s32> mcursor;
core::vector3df target;
core::triangle3df outTriangle;
bool point;
colmgr = smgr->getSceneCollisionManager();
mcursor=device->getCursorControl()->getPosition();
selector=smgr->createOctTreeTriangleSelector(levelMesh->getMesh(0),levelNode,64);
line=colmgr->getRayFromScreenCoordinates(mcursor,camera);
point=colmgr->getCollisionPoint(line,selector,target,outTriangle);
return target;
guys actually i need the point on a node.....
that too in 3d space..... so if i use getSceneNodeFromScreenCoordinatesBB
i will get the scene node itself not a point on that node....
Yeah, that line that is created ( line3d ), the end point of that line should be the point of collision ( obviously use it after getRayFromScreenCoords ). I think the line has line.start and line.end, the line.end should be a vector which you can get:
This should work although I haven't tested it.
Code: Select all
core::vector3df collPoint = line.end;i used the triangle selector so now i am gettin the collision with the terrain also....
that has come rit..... but now i don't know how to rotate the model
*<-target position
|
*<-Current Position-----------------
how do i get the amount of rotation inorder to get the model rotate
from the current position to the target.............
TYN any idea or algorithms on this issue?
that has come rit..... but now i don't know how to rotate the model
*<-target position
|
*<-Current Position-----------------
how do i get the amount of rotation inorder to get the model rotate
from the current position to the target.............
TYN any idea or algorithms on this issue?
-
knightoflight
- Posts: 199
- Joined: Sun Aug 24, 2003 5:47 pm
- Location: Germany
> ... i used the triangle selector so now i am gettin the collision with the terrain also....
good idea, it works. Getting the triangles with getTriangles and comparing with the result from getCollisionPoint. But it feels a little bit like shooting from behind through my head, i think a new irrlicht-function would be better. There were other users, too, who asked for picking a point in a mesh (for example for damage at a car and other things). Maybe we can make a suggestion for improvement and Niko reads this ?
good idea, it works. Getting the triangles with getTriangles and comparing with the result from getCollisionPoint. But it feels a little bit like shooting from behind through my head, i think a new irrlicht-function would be better. There were other users, too, who asked for picking a point in a mesh (for example for damage at a car and other things). Maybe we can make a suggestion for improvement and Niko reads this ?