Hello phil_t,
Your Solution works perfect with one exception, if i want to set the cube on a special Point, as example of the X axis of 3, than he just added 3 steps to the translation with the rotated axis instead of to reset the cube of 3 of the X axis.
With = instead of += i haven't this problem, but than he rotate the cube only around the middle of the scene again 0, 0, 0, instead of around him self?
My Code:
public void TranslateX(float units)
{
this.translate += this.localSide * units;
}
public void TranslateY(float units)
{
this.translate += this.localUp * units;
}
public void TranslateZ(float units)
{
this.translate += this.localLook * units;
}
public void _Rotate(Vector3 result)
{
this.rotate = result;
this.rotation = Matrix.RotationYawPitchRoll(Mathematics.DegreesToRadians(this.rotate.Y),
Mathematics.DegreesToRadians(this.rotate.X),
Mathematics.DegreesToRadians(this.rotate.Z));
this.localSide = Vector3.TransformNormal(Vector3.UnitX, this.rotation);
this.localUp = Vector3.TransformNormal(Vector3.UnitY, this.rotation);
this.localLook = Vector3.TransformNormal(Vector3.UnitZ, this.rotation);
}
public void _Scale(Vector3 result)
{
this.scale = result;
}
public void UpdateWorld()
{
Matrix scale = Matrix.Scaling(this.scale);
Matrix translate = Matrix.Translation(this.translate);
this.world = (scale * this.rotation * translate);
}
Greets