Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

104 Neutral

About Rickard_Hermansson

  • Rank
  1. Rickard_Hermansson

    Parent child relatioship using quaternions

    I asked around in tge Ogre 3D forum how it's done there. I seems that the quaternion multiplication order differs from ogre and sharp dx (atleast is seems that way), I have asked on their forum. In ogre the multplication order is right to left. in the XNA documentation is say the product of a quaternion multiplication = Q2 * Q1, e.g right to left. any ways, my code for rotating in the desired transform space :   case TransformSpace.Parent: relativeOrientation = relativeOrientation * q; break; case TransformSpace.World: relativeOrientation = WorldOrientation * q * worldOrientationInverse * relativeOrientation; break; case TransformSpace.Local: relativeOrientation = q * relativeOrientation; break; Now, the order of multiplication here is the reverse of what ogre is using. When I send the worldmatrix to the shader I have to transpose it, Sharp DX use row major and the HLSL shader expect matrices as column major. So I transpose the world matrix before sending it to the shader. Is this why I must reverse the order?  
  2. Rickard_Hermansson

    Parent child relatioship using quaternions

    Well I made a mistake.   Since the parent is rotated forward the inital rotation of the child will also be rotated forward. I used, being a bit stupid, a unit cube to visualize the child, so I did not notice that it had the same inital orientation of the parent. (ofcoruse it did!)   Thank you for your help!
  3. Rickard_Hermansson

    Parent child relatioship using quaternions

    The code for making th rotations   /* The rotation we wan't too add to this orientation*/ Quaternion q = Quaternion.RotationAxis(axis, angle); q.Normalize(); switch (space) { case TransformSpace.World: orientation = q * orientation; break; case TransformSpace.Local: orientation = orientation * q; break; }
  4. Rickard_Hermansson

    Parent child relatioship using quaternions

    I asume this mean I should no longer use tha parent world matrix. The code for creating the world matrix now looks like: How ever, the result is the same.if (parent != null) { Quaternion q = orientation * parent.orientation; Vector3 p = parent.Position + position; p = Vector3.Transform(p, parent.orientation); world = Matrix.Scaling(scale) * Matrix.RotationQuaternion(q) * Matrix.Translation(p); // world *= parent.world; } else { world = Matrix.Scaling(scale) * Matrix.RotationQuaternion(orientation) * Matrix.Translation(position); } if i do:childMesh.Transform.Roll(deltaTime * 5f, TransformSpace.World);The child will rotate around the y-axis because of the parent orientation and I wan't it tor rotate around the z-axis.
  5. Rickard_Hermansson

    Parent child relatioship using quaternions

      Do you mean when creating my world matrix or when performing the rotaion?   currently the object position,orientation, and scale is relative to the parent.   premultiplying it would mean that the orientation is stored relative to the world rather than the parent?
  6. Hello. I have two game objects. The final world transform of each object is calculated by concatenating the objects local transform with that parents transform, like so:world = Matrix.Scaling(scale) * Matrix.RotationQuaternion(orientation) * Matrix.Translation(position) world *= parent.world;Now, to my problem. the scenario is: 1. I pitch objectA 90 deg around the world x-axis (position is (0,0,0)) 2. I move objectB a few units along the x-axis (position is (3,0,0)) 3. I set the objectA as the parent of objectB Now I decide to yaw objectB in world space, the operation would be (using quaternions):objectB.orientation = qYaw * objectB.orientation;BbjectB will rotate around the world z-axis since it is parallel to the parents y-axis. I need to account for the parent's oerientaton when performing rotations in world space, and I have no idéa how to do that. I have tried to use the conjugate of the parents orientation, but without success.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!