Rotation Around connecting axis

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

Rotation Around connecting axis

Post by levan »

Hello, Please Help me with this. I really dont know if its correst as I am doing.

I am using in my project. Ogre,net and Axiom.


Need to implement rotation around axis that are connecting two points. To make it more obviouse will better put an example.

So we have 4 points in a space that are creating a rectangle. Points are childnodes to each other so if we rotate one the rest will be rotated as well.

Entities[0] = _scene.CreateEntity("O4", "O4.mesh"); Nodes[0] = _scene.RootSceneNode.CreateChildSceneNode("O40", Positions.O40); Nodes[0].AttachObject(Entities[0]);
Entities[1] = _scene.CreateEntity("C4", "C4.mesh"); Nodes[1] = Nodes[0].CreateChildSceneNode("C41", vectors.DisplC4O4); Nodes[1].AttachObject(Entities[1]);
Entities[2] = _scene.CreateEntity("CG", "CG.mesh"); Nodes[2] = Nodes[1].CreateChildSceneNode("CG2", vectors.DisplCGC4); Nodes[2].AttachObject(Entities[2]);
Entities[3] = _scene.CreateEntity("C1", "C1.mesh"); Nodes[3] = Nodes[2].CreateChildSceneNode("C13", vectors.DisplC1CG); Nodes[3].AttachObject(Entities[3]);


O4 ********************************* C4
*
*
*
*
*
*
*
*
CG ********************************** C1

now I need this rectangle to be rotated around side of lets say O4-C4. How is it proper to do that ?? ?

I am doing that like this (but guess its not a right way to do):

SceneNode NOOD = OnLoadSyst.Nodes[0];
NOOD.Rotate(OnLoadSyst.Nodes[0].DerivedPosition - OnLoadSyst.Nodes[1].DerivedPosition, 30, TransformSpace.Local);





Many Thanks in advance


levan
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Rotation Around connecting axis

Post by Kojack »

The axis of rotation needs to be a unit vector. (I just looked at the code, the axis given the Rotate isn't normalised internally, it then builds a quaternion from it to do the actual rotation. But a quaternion with the wrong axis length is invalid). The transform space should also be World, since the positions you are using to get the axis are also in world coordinates.
I don't know axiom's exact syntax, but it would be something like this:

Code: Select all

SceneNode NOOD = OnLoadSyst.Nodes[0];
NOOD.Rotate((OnLoadSyst.Nodes[0].DerivedPosition - OnLoadSyst.Nodes[1].DerivedPosition).NormalisedCopy(), 30, TransformSpace.World);
levan
Halfling
Posts: 41
Joined: Sun Oct 27, 2013 11:57 pm
x 1

Re: Rotation Around connecting axis

Post by levan »

Many thanks, it helped me a lot.

Axiom forum is kind of dead :)
Post Reply