Help - Wheel Rotation
Help - Wheel Rotation
I have a wheel and i want to rotate it like a wheel
im doing Y rotation then if im doing the Z rotation it's like the Z1, i want it like the Z2. Any Help ??
im doing Y rotation then if im doing the Z rotation it's like the Z1, i want it like the Z2. Any Help ??
-
- Posts: 10
- Joined: Sun Oct 17, 2010 8:45 am
- Location: Belgium
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
what you want is a local transformation
check out this thread http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=42036
check out this thread http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=42036
okay, finnalyRadikalizm wrote:what you want is a local transformation
check out this thread http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=42036
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
Are you talking about the line in my function or are you talking about applying the rotation yourself? Keep in mind that calling "setRotation" on a scene node is NOT local and is NOT affected by the node's current rotation.
BTW, it's great to see other people using this code.
BTW, it's great to see other people using this code.
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
here's my code :
i want the wheel turn when i press the D key, but it turn in wrong.
the wheel spin well when im not press the D key.
Code: Select all
if(rcv.IsKeyDown(KEY_KEY_D))
rotateNode(MyNode,vector3df(0,0.1f,0));
else
rotateNode(MyNode,vector3df(0,0,1));
the wheel spin well when im not press the D key.
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
Hmmm...
You could try increasing the amount that the wheel turns along the Y axis,
0.1 won't go very fast.
I would try something like:
You could try increasing the amount that the wheel turns along the Y axis,
0.1 won't go very fast.
I would try something like:
Code: Select all
if(rcv.IsKeyDown(KEY_KEY_D))
rotateNode(MyNode,vector3df(0,1,0));
else
rotateNode(MyNode,vector3df(0,0,1));
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
it seem the Y Axis rotated by this code :
the speed is normal, i did change the 0.1f value to 1.
Code: Select all
rotateNode(MyNode,vector3df(0,0,1));
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
Uhm, actually the last parameter is the Z axis. But as long as you get the
effect you want, it doesn't matter.
I'm not sure I understand your problem perfectly, is the node rotating in the
wrong direction, wrong axis, or is it not rotating at all?
If it's rotating in the wrong direction, you could try negating the value like so:
effect you want, it doesn't matter.
I'm not sure I understand your problem perfectly, is the node rotating in the
wrong direction, wrong axis, or is it not rotating at all?
If it's rotating in the wrong direction, you could try negating the value like so:
Code: Select all
rotateNode(MyNode, vector3df(0,-0.1f,0))
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
-
- Posts: 194
- Joined: Thu Mar 18, 2010 3:31 am
- Contact:
Okay, I think I understand the problem then.
You see the XYZ axis', are relative to the mesh. They are completely unaffected by the global axis. So whatever got exported from the 3d modeler as the Y axis, will be preserved in Irrlicht.
So in short, your XYZ axis' might be different for every mesh/sceneNode. Try rotating along a different axis and see what happens.
BTW I'm online right now in the #irrlicht channel on irc.freenode.net, so you might want to join it there so that we both won't have to go through this agonizing pain and mental anguish of checking the forum again and again.
You see the XYZ axis', are relative to the mesh. They are completely unaffected by the global axis. So whatever got exported from the 3d modeler as the Y axis, will be preserved in Irrlicht.
So in short, your XYZ axis' might be different for every mesh/sceneNode. Try rotating along a different axis and see what happens.
BTW I'm online right now in the #irrlicht channel on irc.freenode.net, so you might want to join it there so that we both won't have to go through this agonizing pain and mental anguish of checking the forum again and again.
LazerBlade
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
When your mind is racing, make sure it's not racing in a circle.
3d game engine: http://sites.google.com/site/lazerbladegames/home/ray3d
lazerBlade blog: http://lazerbladegames.blogspot.com/
any help ???
i want to make the wheel spin while turning
here my whole code :
i want to make the wheel spin while turning
here my whole code :
Code: Select all
#include <irrlicht.h>
#include "eventreceiver.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
/*
==========
rotateNode -- rotate a scene node locally
==========
*/
void rotateNode(irr::scene::ISceneNode *node, irr::core::vector3df rot)
{
irr::core::matrix4 m;
m = node->getAbsoluteTransformation();
irr::core::matrix4 n;
n.setRotationDegrees(rot);
m *=n;
node->setRotation(m.getRotationDegrees());
node->updateAbsolutePosition();
}
int main(){
IrrlichtDevice* device = createDevice(video::EDT_DIRECT3D9,dimension2d<u32>(800,600),32);
MyEventReceiver rcv;
device->setEventReceiver(&rcv);
ISceneManager* Mgr = device->getSceneManager();
IVideoDriver* Video = device->getVideoDriver();
IMeshSceneNode* Wheel= Mgr->addMeshSceneNode(Mgr->getMesh("ban.x"));
ICameraSceneNode* kamera = Mgr->addCameraSceneNodeFPS();//,vector3df(70,20,5),vector3df(0,0,0));
while(device->run()){
rotateNode(Wheel,vector3df(0,0,1));
rotateNode(Wheel,vector3df(0,1,0));
Video->beginScene(true,true,SColor(255,255,255,255));
Mgr->drawAll();
Video->endScene();
}
device->drop();
return 0;
}