예제 #1
0
파일: Part.cs 프로젝트: dewiniaid/krpc
 public Tuple3 CenterOfMass(ReferenceFrame referenceFrame)
 {
     if (ReferenceEquals(referenceFrame, null))
     {
         throw new ArgumentNullException("referenceFrame");
     }
     return(referenceFrame.PositionFromWorldSpace(InternalPart.CenterOfMass()).ToTuple());
 }
예제 #2
0
 public Tuple3 Position(ReferenceFrame referenceFrame)
 {
     if (ReferenceEquals(referenceFrame, null))
     {
         throw new ArgumentNullException(nameof(referenceFrame));
     }
     return(referenceFrame.PositionFromWorldSpace(InternalPart.transform.position).ToTuple());
 }
예제 #3
0
 public Tuple3 Position(ReferenceFrame referenceFrame)
 {
     if (ReferenceEquals(referenceFrame, null))
     {
         throw new ArgumentNullException("referenceFrame");
     }
     return(referenceFrame.PositionFromWorldSpace(port.nodeTransform.position).ToTuple());
 }
예제 #4
0
        /// <summary>
        /// Computes the axis-aligned bounding box for a part in the given reference frame.
        /// </summary>
        /// <remarks>
        /// This is an expensive calculation. It iterates over the parts collider meshes
        /// to compute a tight axis-aligned bounding box.
        /// It does not use part.collider.bounds, as this is aligned to world space and
        /// would not provide a tight bounding box in the given reference frame.
        /// </remarks>
        public static Bounds GetBounds(this Part part, ReferenceFrame referenceFrame)
        {
            var colliders = part.GetComponentsInChildren <MeshCollider> ();
            var bounds    = new Bounds(referenceFrame.PositionFromWorldSpace(part.WCoM), Vector3.zero);

            foreach (var collider in colliders)
            {
                var vertices = collider.sharedMesh.bounds.ToVertices();
                for (int i = 0; i < vertices.Length; i++)
                {
                    // part space -> world space -> reference frame space
                    var vertex = referenceFrame.PositionFromWorldSpace(collider.transform.TransformPoint(vertices [i]));
                    bounds.Encapsulate(vertex);
                }
            }
            return(bounds);
        }
예제 #5
0
        /// <summary>
        /// Computes the axis-aligned bounding box for a part in the given reference frame.
        /// </summary>
        /// <remarks>
        /// This is an expensive calculation. It iterates over the parts collider meshes
        /// to compute a tight axis-aligned bounding box.
        /// It does not use part.collider.bounds, as this is aligned to world space and
        /// would not provide a tight bounding box in the given reference frame.
        /// </remarks>
        public static Bounds GetBounds(this Part part, ReferenceFrame referenceFrame)
        {
            var bounds = new Bounds(referenceFrame.PositionFromWorldSpace(part.WCoM), Vector3.zero);
            var meshes = part.GetComponentsInChildren <MeshFilter> ();

            for (int i = 0; i < meshes.Length; i++)
            {
                var mesh     = meshes [i];
                var vertices = mesh.mesh.bounds.ToVertices();
                for (int j = 0; j < vertices.Length; j++)
                {
                    // mesh space -> world space -> reference frame space
                    var vertex = referenceFrame.PositionFromWorldSpace(mesh.transform.TransformPoint(vertices [j]));
                    bounds.Encapsulate(vertex);
                }
            }
            return(bounds);
        }
예제 #6
0
파일: Thruster.cs 프로젝트: thinkyfish/krpc
 public Tuple3 GimbalPosition(ReferenceFrame referenceFrame)
 {
     if (ReferenceEquals(referenceFrame, null))
     {
         throw new ArgumentNullException(nameof(referenceFrame));
     }
     CheckGimballed();
     return(referenceFrame.PositionFromWorldSpace(gimbal.gimbalTransforms [transformIndex].position).ToTuple());
 }
예제 #7
0
파일: Thruster.cs 프로젝트: thinkyfish/krpc
        public Tuple3 InitialThrustPosition(ReferenceFrame referenceFrame)
        {
            if (ReferenceEquals(referenceFrame, null))
            {
                throw new ArgumentNullException(nameof(referenceFrame));
            }
            StashGimbalRotation();
            var position = WorldTransform.position;

            RestoreGimbalRotation();
            return(referenceFrame.PositionFromWorldSpace(position).ToTuple());
        }
예제 #8
0
파일: SpaceCenter.cs 프로젝트: krpc/krpc
 public static Tuple3 TransformPosition (Tuple3 position, ReferenceFrame from, ReferenceFrame to)
 {
     CheckReferenceFrames (from, to);
     return to.PositionFromWorldSpace (from.PositionToWorldSpace (position.ToVector ())).ToTuple ();
 }
예제 #9
0
 public Tuple3 Position(ReferenceFrame referenceFrame)
 {
     return(referenceFrame.PositionFromWorldSpace(InternalPart.transform.position).ToTuple());
 }
예제 #10
0
 public Tuple3 Position(ReferenceFrame referenceFrame)
 {
     return(referenceFrame.PositionFromWorldSpace(port.nodeTransform.position).ToTuple());
 }