• Create Account

### #ActualRickard_Hermansson

Posted 05 January 2013 - 06:26 PM

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.

### #4Rickard_Hermansson

Posted 05 January 2013 - 06:26 PM

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.

### #3Rickard_Hermansson

Posted 05 January 2013 - 06:23 PM

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.

The code for making the rotation:

/* 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;		    }

### #2Rickard_Hermansson

Posted 05 January 2013 - 06:21 PM

I asume this mean I should no longer use tha parent world matrix.
The code for creating the world matrix now looks like:

orientation.Normalize();		    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);		    }

How ever, the result is the same.

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.

The code for making the rotation:

 /* 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;
}

### #1Rickard_Hermansson

Posted 05 January 2013 - 06:16 PM

I asume this mean I should no longer use tha parent world matrix.

The code for creating the world matrix now looks like:

 orientation.Normalize();
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);
}

How ever, the result is the same.

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.

The code for making the rotation:

/* 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;
}

PARTNERS