2d->3d

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
mart

2d->3d

Post by mart »

hi

i have a 3d landscape, and i want set a model to the position where i click with the mouse.

Code: Select all

//m2 is the mouse click position

line.setLine(smgr->getSceneCollisionManager()->getRayFromScreenCoordinates(m2,smgr->getActiveCamera()));		

//this is the model 	
node2->setPosition(line.getVector());


but this don't work.....
what is my mistake..


thanks for help
Homer
Posts: 58
Joined: Tue Nov 18, 2003 7:11 pm
Location: Germany

Post by Homer »

Hm, can you please be a bit more specific, e.g. show a bit more of your code. What type of line do you use? Maybe you can try using Irrlicht's line datatypes. Check if line.getVector() returns the vector you want to have.
mart

w

Post by mart »

core::line3d<f32> line;

i want convert screen into world coordinates......


thanks very much for help..
Homer
Posts: 58
Joined: Tue Nov 18, 2003 7:11 pm
Location: Germany

Post by Homer »

I'm not quite sure if "getRayFromScreenCoordinates" returns the ray you want to have. Where is your model set with your code?
mart

sd

Post by mart »

Code: Select all

scene::IAnimatedMesh* mesh = smgr->getMesh("../../media/wiese.3ds");
	scene::IAnimatedMesh* man = smgr->getMesh("../../media/man.3ds");
	scene::ISceneNode* node = 0;
	scene::ISceneNode* node2 = 0;

	core::vector3d<f32> v;
	
	
	if (mesh)
		node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
	if (man)
		node2 = smgr->addOctTreeSceneNode(man->getMesh(0));


i have a ground called "wiese" and there should "run" (at the moment jump) a model to the position i click with the mouse.

thanks
mart

sdsad

Post by mart »

[img]
http://www.delikon.de/wiese.jpg
[/img]

on this screenshot you can, see a simple model man.3ds on a green ground wiese.3ds, now want use my mouse to move the model "man.3ds"
but i have problems to convert windows coordinates to world coordinates,

from my posts above you can see the code i have used, where is my mistake....

please can anybody point me in the right direction.
Tyn
Posts: 932
Joined: Thu Nov 20, 2003 7:53 pm
Location: England
Contact:

Post by Tyn »

What you need is to find out where this point collides with the world, then move your model to that point. What you are trying to do is move your model along a line from the camera out into the scene to the far value. You've got the first bit of the collision right but have missed out a bit.
Post Reply