Help - Wheel Rotation

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.
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

Try the inner code from this :

Code: Select all

	/*====================================================================
	local rotation of the entity --- by nespa */

	DLL_EXPORT void DLL_APIENTRY TurnEntity(ISceneNode* Entity,float X,float Y,float Z)

	{
		
		vector3df rp(X,Y,Z);
		vector3df r = Entity->getRotation(); //get current rotation (euler) 

		matrix4 m; 
		matrix4 mp; 
		m.setRotationDegrees(r); //set matrix to current rotation 
		mp.setRotationDegrees(rp); //set second matrix to rotation to add 
		m *= mp; //multipy them 

		r = m.getRotationDegrees(); //get rotation vector from matrix (euler) 
		if(r.Y == 0.0f) 
		{
			r.Y = 0.001f; 
		}
		if(r.Y == 180.0f) 
		{
			r.Y = 180.001f;
		}
		Entity->setRotation(r); //rotates node 
	}
It is from Ninfa3D engine, an Irrlicht wrapper for FreeBasic.
It turns around the local axes.
Use the wrapvalue in a loop or make an animator.

Good luck !
lazerblade
Posts: 194
Joined: Thu Mar 18, 2010 3:31 am
Contact:

Post by lazerblade »

Aha! I finally see your problem. Try using this code in replacement of yours and see if it works:

Code: Select all


   while(device->run()){ 
             
      rotateNode(Wheel,vector3df(0,0,1)); 
      Wheel->rotate(vector3df(0,1,0)); 

      Video->beginScene(true,true,SColor(255,255,255,255)); 
      Mgr->drawAll(); 
      Video->endScene(); 
       
   } 

And if that doesn't work, try this one:

Code: Select all


   while(device->run()){ 
              
      Wheel->rotate(vector3df(0,0,1)); 
      rotateNode(Wheel,vector3df(0,1,0));

      Video->beginScene(true,true,SColor(255,255,255,255)); 
      Mgr->drawAll(); 
      Video->endScene(); 
       
   } 




@nespa

That code does essentially the same thing as mine, but I don't understand why you're doing this:

Code: Select all

      if(r.Y == 0.0f) 
      { 
         r.Y = 0.001f; 
      } 
      if(r.Y == 180.0f) 
      { 
         r.Y = 180.001f; 
      } 
I don't quite understand why and I'd hate to have something important missing from my 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/
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

lazerBlade, You can delete them, they were for an individual case
lazerblade
Posts: 194
Joined: Thu Mar 18, 2010 3:31 am
Contact:

Post by lazerblade »

Okay, thanks. 8)
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/
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

kaliber,
if you want your wheel to act as a real wheel, you must make a parent axe(another mesh like a cylinder) for the wheel.
The parent axe-cylinder turns around its Y of the local axes(+- few degrees) and the wheel turns around the its X of the local axes.
You must count the + - rotation of the cylinder to stop at the + - max value.(adding each step and stop at -max_value or +max_value).
The wheel turns infinite.
kaliber
Posts: 117
Joined: Sat Jan 17, 2009 12:51 pm

Post by kaliber »

i've give up,

i'll use animation as the wheel z rotation.. :cry: :cry: :cry:
Post Reply