Page 1 of 1

How Rotate a node 45 degrees around x axis

Posted: Wed Nov 10, 2010 3:38 pm
by speedy15453
Can someone help me with some simple code to rotate a node around the x axis 45 degrees and the stop every time the user presses x.
as opposed to this:

Code: Select all

    if IsKeyDown(EKEY_CODE.KEY_KEY_X) = true then
      KeyIsDown(EKEY_CODE.KEY_KEY_X) = false
      x=1
      // add rotation animator
      dim position as core_vector3df = new core_vector3df(0,0,0)
      position = new core_vector3df(x,y,z)
      anim = scene.createRotationAnimator(position)
      node.addAnimator(anim)
    end

Thanks

Posted: Wed Nov 10, 2010 7:00 pm
by neil_123
For rotating part, wont following way work?

Code: Select all

node->setRotation( vector3df(45, 0, 0) );

It works

Posted: Wed Nov 10, 2010 9:54 pm
by speedy15453
I'm using RealStudio with the Franklin3d plugin for Irrlicht so my code looks like this:

Code: Select all

    
    if IsKeyDown(EKEY_CODE.KEY_KEY_X) = true then
      KeyIsDown(EKEY_CODE.KEY_KEY_X) = false
      x = x +45
      // add rotation animator
      dim position as core_vector3df = new core_vector3df(x,y,z)
      position = new core_vector3df(x,y,z)
      node.setRotation( position )
      node.updateAbsolutePosition()
      if x =360 then x=0
    end
Thank You!

This node jumps to the next position. Is there an easy way to see it rotate the 45 degrees ? I am working on a variation of the rubik's cube.