// palce and object relative to another object // i.e. place and object to the left of the camera (left from the view of the camera) public void PlaceRelativeTo(Axis3D pReferenceAxis, double x, double y, double z) { Vector3 pos = new Vector3(x, y, z); pos = Vector3.Transform(pos, pReferenceAxis.AxisToWorld); Vector3 RefPos = pReferenceAxis.Origin; pos += RefPos; MoveToAbsolute(pos.x, pos.y, pos.z); }
public void RotateAbsolute(Axis3D pSourceAxis) { Vector3 save1; // save the old position save1.x = AxisToWorld[3, 0]; save1.y = AxisToWorld[3, 1]; save1.z = AxisToWorld[3, 2]; AxisToWorld = pSourceAxis.AxisToWorld; // stuff the old position back in AxisToWorld[3, 0] = save1.x; AxisToWorld[3, 1] = save1.y; AxisToWorld[3, 2] = save1.z; AxisToWorld = Matrix4X4.Invert(WorldToAxis); }
// move an object relative to it's current position relative to the rotation of another axis // i.e. move an object left relative to the camera (left from the view of the camera) public void MoveToRelativeTo(Axis3D pReferenceAxis, double x, double y, double z) { Vector3 add; add.x = x; add.y = y; add.z = z; add = Vector3.Transform(add, pReferenceAxis.AxisToWorld); AxisToWorld[3, 0] += add.x; AxisToWorld[3, 1] += add.y; AxisToWorld[3, 2] += add.z; // and do it for the inverse add = Vector3.Transform(add, WorldToAxis); WorldToAxis[3, 0] -= add.x; WorldToAxis[3, 1] -= add.y; WorldToAxis[3, 2] -= add.z; }
// move an object relative to it's current position relative to the rotation of another axis // i.e. move an object left relative to the camera (left from the view of the camera) public void MoveToRelativeTo(Axis3D pReferenceAxis, double x, double y, double z) { Vector3 add; add.X = x; add.Y = y; add.Z = z; add = Vector3Ex.Transform(add, pReferenceAxis.AxisToWorld); AxisToWorld[3, 0] += add.X; AxisToWorld[3, 1] += add.Y; AxisToWorld[3, 2] += add.Z; // and do it for the inverse add = Vector3Ex.Transform(add, WorldToAxis); WorldToAxis[3, 0] -= add.X; WorldToAxis[3, 1] -= add.Y; WorldToAxis[3, 2] -= add.Z; }
public void PointAtOrigin(Axis3D pTarget, bool YandX = true) { PointAt(pTarget.Origin, YandX); }
public void SetPosAndRotation(Axis3D pSourceAxis) { AxisToWorld = pSourceAxis.AxisToWorld; WorldToAxis = pSourceAxis.WorldToAxis; }