[SOLVED] Turn arround an Axis?
[SOLVED] Turn arround an Axis?
Hi All;
How can I make a node turn arround an axis?
I can just rotate it around him self
How can I make a node turn arround an axis?
I can just rotate it around him self
Last edited by USE.IRR on Wed Aug 29, 2007 9:33 am, edited 2 times in total.
If you just want an orbiting object (like the moon around the earth) you can use the createFlyCircleAnimator(...) function...
If you want to controll the object, a little bit trigonometry would help...
look at this thread and just use the cameras target for positioning your object: http://irrlicht.sourceforge.net/phpBB2/ ... 75f608d2c6
If you want to controll the object, a little bit trigonometry would help...
look at this thread and just use the cameras target for positioning your object: http://irrlicht.sourceforge.net/phpBB2/ ... 75f608d2c6
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
I can not have a correct animation with this:
is there a bug in createFlyCircleAnimator?
Code: Select all
scene::ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(core::vector3df(0,1,0),20.0f,0.0005f,core::vector3df(1,0,0));
box1_node->addAnimator(anim);
anim->drop();
hmm, yes it seems it can only rotate around the Y axis !?!?!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Try this topic, may be you can find there something usefull:
http://irrlicht.sourceforge.net/phpBB2/ ... ht=#128212
http://irrlicht.sourceforge.net/phpBB2/ ... ht=#128212
Code: Select all
void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs)
{
if ( 0 == node )
return;
const f32 t = (timeMs-StartTime) * Speed;
//the problem is here
[b]core::vector3df circle(Radius * sinf(t), 0, Radius * cosf(t));[/b]
circle = circle.crossProduct ( Direction );
node->setPosition(Center + circle);
}
so it's really a bug with createFlyCircleAnimator ???
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
I'm not especially familiar with the fly circle animator, but it seems like this code:
[code]scene::ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(core::vector3df(0,1,0),20.0f,0.0005f,core::vector3df(1,0,0));
box1_node->addAnimator(anim);
anim->drop(); [/code]
is specifying an upvector along the x-axis. Wouldn't that make it orbit around the x-axis and not the y-axis?
Nobody kiss me, please.
[code]scene::ISceneNodeAnimator* anim = smgr->createFlyCircleAnimator(core::vector3df(0,1,0),20.0f,0.0005f,core::vector3df(1,0,0));
box1_node->addAnimator(anim);
anim->drop(); [/code]
is specifying an upvector along the x-axis. Wouldn't that make it orbit around the x-axis and not the y-axis?
Nobody kiss me, please.
well, it should, but it doesn't, the node only moves up and down (that's the bug)...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Hi all, I am using this code to have the animation shown in the picture. But I can not see the correct animation.
What is the problem with my code
Code: Select all
f32 gradius = 1.0f;
//Current rotation
matrix4 currentRotation;
currentRotation= node1->getRelativeTransformation();
//Constant rotation1
matrix4 constRotation1;
//SUN Axis
constRotation1.setRotationDegrees(core::vector3df (0 ,1 , 0) );
//Next rotation
matrix4 nextRotation;
nextRotation = constRotation1 * currentRotation;
//Constant rotation2
matrix4 constRotation2;
// Earth Axis
constRotation2.setRotationDegrees(core::vector3df (50 ,50 , 0));
//relative rotation
matrix4 relativeRotation;
relativeRotation=currentRotation * constRotation2;
core::vector3df dir = core::vector3df(0,gradius,0);
nextRotation.rotateVect(dir);
rot = relativeRotation.getRotationDegrees();
//node1 is earth
node1->setRotation(rot);
node1->setPosition(dir);
What is the problem with my code
Code: Select all
#include <irrlicht.h>
using namespace irr;
int main()
{
IrrlichtDevice *device = createDevice( video::EDT_OPENGL,
core::dimension2d<s32>(640, 480), 32, false, false, false, 0);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
smgr->addCameraSceneNode(0, core::vector3df(0,10,-30), core::vector3df(0,0,0));
scene::ISceneNode *star = smgr->addSphereSceneNode();
star->setMaterialFlag(video::EMF_LIGHTING ,false);
star->setRotation(core::vector3df(-5,1,10));
scene::ISceneNode *planet = smgr->addSphereSceneNode(3.0f);
planet->setMaterialFlag(video::EMF_LIGHTING ,false);
f32 radius = 20.0f;
f32 rotationSpeed = 0.1f;
f32 rotation = 0.0f;
while(device->run())
{
driver->beginScene(true, true, video::SColor(255,100,101,140));
rotation += rotationSpeed;
core::vector3df pos= core::vector3df(0,0,radius);
core::matrix4 matrix;
matrix.setRotationDegrees(core::vector3df (0 ,rotation , 0) );
matrix.rotateVect(pos);
matrix = star->getAbsoluteTransformation();
matrix.rotateVect(pos);
planet->setPosition(pos+ star->getPosition());
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
Code: Select all
#include <irrlicht.h>
using namespace irr;
int main()
{
IrrlichtDevice *device = createDevice( video::EDT_OPENGL,
core::dimension2d<s32>(640, 480), 32, false, false, false, 0);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
smgr->addCameraSceneNode(0, core::vector3df(0,10,-30), core::vector3df(0,0,0));
scene::ISceneNode *star = smgr->addSphereSceneNode();
star->setMaterialFlag(video::EMF_LIGHTING ,false);
star->setRotation(core::vector3df(-5,1,10));
scene::ISceneNode *planet = smgr->addSphereSceneNode(3.0f, 16, star);
planet->setMaterialFlag(video::EMF_LIGHTING ,false);
f32 radius = 20.0f;
f32 rotationSpeed = 0.1f;
f32 rotation = 0.0f;
while(device->run())
{
driver->beginScene(true, true, video::SColor(255,100,101,140));
rotation += rotationSpeed;
core::vector3df pos = core::vector3df(0,0,radius);
core::matrix4 matrix;
matrix.setRotationDegrees(core::vector3df (0 ,rotation , 0) );
matrix.rotateVect(pos);
planet->setPosition(pos);
smgr->drawAll();
driver->endScene();
}
device->drop();
return 0;
}