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);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.