/// <summary> /// Compute the inverse of the transform. When the inverse of the transform is applied, it undoes the effects of the transform. /// </summary> /// <param name="inverted">Returns the inverted transform.</param> public void Invert(out Transform inverted) { inverted.Scale = 1f / Scale; Quaternion.Inverse(ref Orientation, out inverted.Orientation); Vector3.Negate(ref Position, out inverted.Position); CombineInverse(inverted.Scale, ref inverted.Position, ref inverted.Orientation, out inverted.Combined); }
/// <summary> /// Apply a transform to the collision skin part to bring it into world space. /// </summary> /// <param name="transform">The world-space transform to apply.</param> public override void ApplyTransform(ref Transform transform) { Transform = transform; transform.Invert(out TransformInverse); if (transform.Combined != Matrix.Identity) { _boundingBox = AlignedBox.Null; for (int i = 0; i < _body.Body.Length; i++) { Vector3 p; Vector3.Transform(ref _body.Body[i], ref transform.Combined, out p); _boundingBox.Add(ref p); } } else _boundingBox = _body.Nodes[0].BoundingBox; }
/// <summary> /// Transforms a bounding box into world-space or local-space using the specified transform. The box may grow /// significantly depending on the size and new/old basis axes. /// </summary> /// <param name="box">The bounding box to transform.</param> /// <param name="transform">The transformation to apply.</param> /// <param name="output">Returns the transformed bounding box.</param> public static void Transform(ref AlignedBox box, ref Transform transform, out AlignedBox output) { Vector3 dim = box.Maximum - box.Minimum; Vector3 p1, p2, p3, p4, p5, p6, p7, p8; p1 = p2 = p3 = p4 = p5 = p6 = p7 = p8 = box.Minimum; p2.X += dim.X; p3.X += dim.X; p3.Y += dim.Y; p4.Y += dim.Y; p5.Z += dim.Z; p6.X += dim.X; p6.Z += dim.Z; p7.X += dim.X; p7.Y += dim.Y; p7.Z += dim.Z; p8.Y += dim.Y; p8.Z += dim.Z; Vector3.Transform(ref p1, ref transform.Combined, out p1); Vector3.Transform(ref p2, ref transform.Combined, out p2); Vector3.Transform(ref p3, ref transform.Combined, out p3); Vector3.Transform(ref p4, ref transform.Combined, out p4); Vector3.Transform(ref p5, ref transform.Combined, out p5); Vector3.Transform(ref p6, ref transform.Combined, out p6); Vector3.Transform(ref p7, ref transform.Combined, out p7); Vector3.Transform(ref p8, ref transform.Combined, out p8); output = AlignedBox.Null; output.Add(ref p1); output.Add(ref p2); output.Add(ref p3); output.Add(ref p4); output.Add(ref p5); output.Add(ref p6); output.Add(ref p7); output.Add(ref p8); }
/// <summary> /// Transform the segment using the specified transformation. /// </summary> /// <param name="s">The segment to transform.</param> /// <param name="transform">the transform to apply.</param> /// <param name="output">Returns the transformed segment.</param> public static void Transform(ref Segment s, ref Transform transform, out Segment output) { Vector3.Transform(ref s.P1, ref transform.Combined, out output.P1); Vector3.Transform(ref s.P2, ref transform.Combined, out output.P2); }
public static void Transform(ref Triangle tri, ref Transform transform, out Triangle output) { Vector3.Transform(ref tri.V1, ref transform.Combined, out output.V1); Vector3.Transform(ref tri.V2, ref transform.Combined, out output.V2); Vector3.Transform(ref tri.V3, ref transform.Combined, out output.V3); Vector3.Transform(ref tri.Normal, ref transform.Orientation, out output.Normal); }
/// <summary> /// Apply a transform to the collision skin part to bring it into world space. /// </summary> /// <param name="transform">The world-space transform to apply.</param> public override void ApplyTransform(ref Transform transform) { Vector3.Transform(ref _body.Center, ref transform.Combined, out World.Center); World.Radius = _body.Radius * transform.Scale; }
/// <summary> /// Apply a transform to the collision skin part to bring it into world space. /// </summary> /// <param name="transform">The world-space transform to apply.</param> public override void ApplyTransform(ref Transform transform) { Vector3.Transform(ref _point, ref transform.Combined, out Plane.P); Vector3.Transform(ref _normal, ref transform.Orientation, out Plane.Normal); }
/// <summary> /// Apply a transform to a frame to produce a new frame. /// </summary> /// <param name="input">The frame to transform.</param> /// <param name="transform">The transform to apply.</param> /// <param name="output">Returns the new, transformed frame.</param> public static void Transform(ref Frame input, ref Transform transform, out Frame output) { Vector3.Transform(ref input.X, ref transform.Orientation, out output.X); Vector3.Transform(ref input.Y, ref transform.Orientation, out output.Y); Vector3.Transform(ref input.Z, ref transform.Orientation, out output.Z); Vector3.Transform(ref input.Origin, ref transform.Combined, out output.Origin); }
/// <summary> /// When overridden in a derived class, applies a world transform to the collision part. /// </summary> /// <param name="transform">The transform used to bring the part into world-space.</param> public abstract void ApplyTransform(ref Transform transform);
/// <summary> /// Applies the specified transform to bring all parts of the composition into world-space. /// </summary> /// <param name="transform">The world-space transform to apply.</param> public virtual void ApplyTransform(ref Transform transform) { for (int i = 0; i < _parts.Count; i++) { _parts[i].ApplyTransform(ref transform); } if (_parts.Count > 0) { AlignedBox tmp; _parts[0].BoundingBox(out BoundingBox); for (int i = 1; i < _parts.Count; i++) { _parts[i].BoundingBox(out tmp); AlignedBox.Merge(ref BoundingBox, ref tmp, out BoundingBox); } } }
/// <summary> /// Apply a transform to the collision skin part to bring it into world space. /// </summary> /// <param name="transform">The world-space transform to apply.</param> public override void ApplyTransform(ref Transform transform) { Vector3.Transform(ref _body.P1, ref transform.Combined, out World.P1); Vector3.Transform(ref _body.P2, ref transform.Combined, out World.P2); }
/// <summary> /// Apply a transform to the collision skin part to bring it into world space. /// </summary> /// <param name="transform">The world-space transform to apply.</param> public override void ApplyTransform(ref Transform transform) { Vector3.Transform(_compiled.Body, ref transform.Combined, _world); Vector3.Transform(_compiled.FaceNormals, ref transform.Orientation, _faceNormals); Vector3.Transform(_compiled.EdgeVectors, ref transform.Orientation, _edgeVectors); _center = transform.Position; }