Point and Click Mouse node control

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
Aristarh
Posts: 11
Joined: Wed Jul 14, 2010 3:47 pm
Location: Penza

Point and Click Mouse node control

Post by Aristarh »

I am sorry but English not native for me,so my grammar is bad
Hello again! Trying get translating mesh into new position on mouse click i got a problem. Remember trigonometry course i got idea how it must be done:
1)Create a Terrain Node
2)Set Collusion Manager for it.
3)Create a Animated Mesh node. Put it on Terrain
4)Set Collusion Manager for mesh node
5)Create a camera node which is child for mesh to follow
6)Got a mouse x,y - position2d<s32> pos = cursor->getPosition();

7)make a line3d<f32> ray = collisionManager->
getRayFromScreenCoordinates(pos);

if (collisionManager->getCollisionPoint
(ray, selector, point, triangle, node))
{
// do something
}

8)If Mouse buttom down

Code: Select all

//this is not a real code just a plan
core::vector3df target=point;	
core::vector3df totarget(target - meshnode->getAbsolutePosition());
toTarget.Y = 0; // Ignore  vertical difference
f32 requiredYaw = atan2(totarget.Z, totarget.X) * RADTODEG;
core::vector3df deltaMove(sin(requiredYaw), 0.f, cos(requiredYaw));
 meshnode->setPosition(meshnode->getAbsolutePosition() + deltaMove);
all steps 1-7 i have done myself
but on step 8 my mesh fly away absolutly not on click.
i tryed Google it and search this forum
find only one close relative http://irrlicht.sourceforge.net/phpBB2/ ... ent+player
but it's complicated like hell
Where is way to do it simple.
I'm just need little piece of code which translate mesh to mouse click.No Mesh rotation or something in steps 1-7 else.Plain translating.

Thx for help.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

6)Got a mouse x,y - position2d<s32> pos = cursor->getPosition();

7)make a line3d<f32> ray = collisionManager->
getRayFromScreenCoordinates(pos);

if (collisionManager->getCollisionPoint
(ray, selector, point, triangle, node))
{
// do something
}
I think these steps should go into the 8 step so it only checks for mouse position and searches for collision point when the mouse button is actually clicked.
I hope I'm right :wink:
Working on game: Marrbles (Currently stopped).
Aristarh
Posts: 11
Joined: Wed Jul 14, 2010 3:47 pm
Location: Penza

Post by Aristarh »

SOLVED thx dude :) !
Post Reply