finding the point on the terrain

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
smartwhiz
Posts: 120
Joined: Wed Jan 14, 2004 6:03 pm
Location: India

finding the point on the terrain

Post by smartwhiz »

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>>>>>>>>>>>>
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

A point... like a "dot" ? Draw a line from the mouse pointers position to.. wherever a collosion happens and see if you can get the coords of the place the line and terrian intersect. Not sure of what you're askin though... :?:
Programmer of the Irrlicht Scene Editor:
Homepage - Forum Thread
Version 2 on its way!!
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

the point you are looking at or the point you are stand of?
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

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.
smartwhiz
Posts: 120
Joined: Wed Jan 14, 2004 6:03 pm
Location: India

Post by smartwhiz »

do mean this one tyn

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;
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....
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

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:

Code: Select all

core::vector3df collPoint = line.end;
This should work although I haven't tested it.
smartwhiz
Posts: 120
Joined: Wed Jan 14, 2004 6:03 pm
Location: India

Post by smartwhiz »

i tried it.... but the execution crashes whereever i use that line.end
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

Try dumping the line.end to the console using printf, see if the position looks about right.
smartwhiz
Posts: 120
Joined: Wed Jan 14, 2004 6:03 pm
Location: India

Post by smartwhiz »

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?
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

> ... 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 ?
Post Reply