rotation doesn't stop

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
Kirill
Posts: 3
Joined: Thu Dec 14, 2006 12:31 am
Location: Russia

rotation doesn't stop

Post by Kirill »

here is main loop:

while(Device->run() && driver)
if (Device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(150,50,50,50));
pv = node->getPosition();
pv1 = node3->getPosition();
pv2 = node8->getPosition();
pv3 = node5->getPosition();
pv4 = node6->getPosition();
pv10 = node10->getPosition();
// упраление NODE
RealControl();


cr = node6->getPosition();
x4=cr.X;
z4=cr.Y;
y4=cr.Z;

if (z10 > 0)
a = -1;
else
if (z10 < 0)
a = 1;
else a=0;

cosfi11=(x4)/sqrt((x4)*(x4) + (z4)*(z4));
cosfi21=(x10)/sqrt((x10)*(x10) + (z10)*(z10));

deltafi1 =cosfi11-cosfi21;

if (deltafi1>0)
OmegY = a * DeltOmeg;
else
if (deltafi1=0)
OmegY=0;
else
if (deltafi1<0)
OmegY=0;

smgr->drawAll();
env->drawAll();

// draw irrlicht engine logo
driver->draw2DImage(irrLogo,
core::position2d<s32>(10, driver->getScreenSize().Height - 50),
core::rect<s32>(0,0,108-20,460-429));

driver->endScene();

core::stringw str = L"FPS: ";
str += driver->getFPS();
fpstext->setText(str.c_str());
}

Device->drop();
return 0;

http://photofile.ru/photo/salomon777/23 ... 845356.jpg
x20,z10 are given earlier |red point|
black lines start position
yellow - at the end

here i try to make rotation around axe Y.
the problem is that object doesn't stop at the end and continue moving /as i understand from watch window x4,y4,z4 don't change -> cosfi1 doesn't change -> deltafi1 doesn't change ->program doesn't work/

how make them to change? how can i get information about node position?
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

hmm... you could try putting in a condition so it stops when it achieves the goal you want it to acheieve ;)
Kirill
Posts: 3
Joined: Thu Dec 14, 2006 12:31 am
Location: Russia

Post by Kirill »

I've done it like this, but it doesn't help
cr = node6->getPosition();
x4=cr.X;
y4=cr.Y;
z4=cr.Z;

if (z10 > 0)
a = -1;
else
if (z10 < 0)
a = 1;
else a=0;


cosfi1=(x4)/sqrt((x4)*(x4) + (z4)*(z4));
cosfi2=(x10)/sqrt((x10)*(x10) + (z10)*(z10));

if (cosfi1>cosfi2)
OmegY = a * DeltOmeg;
else OmegY=0;

I think the problem here /it doesn't change during loop/
cr = node6->getPosition();
x4=cr.X;
y4=cr.Y;
z4=cr.Z;

does in cr i get global position or it gives me position relative to parent node (position in parents co-ordinates)?
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

virtual const core::vector3df irr::scene::ISceneNode::getPosition ( ) const [inline, virtual]

Gets the position of the node.

Note that the position is relative to the parent.

Returns:
Returns the current position of the node relative to the parent.

So.. i guess this must be your problem

I think it would be a lot easier if you would use this:

virtual void irr::scene::ISceneNode::setRotation ( const core::vector3df & rotation ) [inline, virtual]

Sets the rotation of the node.

This only modifies the relative rotation of the node.

Parameters:
rotation,: New rotation of the node in degrees.



I don't know if i've got this right, but you could stop the rotation by determining how many degrees it has rotated, not by determining the coordinates

core::vector3df irr::core::matrix4::getRotationDegrees ( ) const [inline]

Returns the rotation, as set by setRotation(). This code was orginally written by by Chev.


It's all in the irrlicht help file :wink:
Kirill
Posts: 3
Joined: Thu Dec 14, 2006 12:31 am
Location: Russia

Post by Kirill »

i look at help and found "better" solution: i change getPosition() in the first line to getAbsolutePosition() and it works :D now i have in cr world position

cr = node6->getAbsolutePosition();
x4=cr.X;
y4=cr.Y;
z4=cr.Z;
hellbound
Posts: 51
Joined: Sat Jun 24, 2006 7:39 am

Post by hellbound »

yeah... i think that what i said before was not really applicable in this situation :oops:
Post Reply