示例#1
0
    /// <summary>
    /// Draw the representation of the socket into the scene view.  Will draw the
    /// arc limits.
    /// </summary>
    /// <param name="socket">The socket to draw.</param>
    /// <param name="position">The position of the socket in world space.</param>
    /// <param name="rotation">The rotation of the socket in world space.</param>
    private void SceneGUIDrawSocket(ref Hardpoint socket, Vector3 position, Quaternion rotation)
    {
        Matrix4x4 mat4  = Handles.matrix;
        Color     color = Handles.color;

        // Set the matrix to make it local to the socket.
        Handles.matrix = Matrix4x4.TRS(position, rotation, Vector3.one);

        // Draw the horizontal arc limits.
        Handles.color = new Color(1, 0, 0, 0.3f);
        Handles.DrawSolidArc(
            Vector3.zero, Vector3.up,
            AHMath.HeadingAngleToVectorXZ(socket.arcLimits.left),
            socket.arcLimits.left + socket.arcLimits.right,
            0.05f
            );
        // Draw the vertical arg limits.
        Handles.color = new Color(0, 1, 0, 0.3f);
        Handles.DrawSolidArc(
            Vector3.zero, Vector3.left,
            AHMath.HeadingAngleToVectorYZ(-socket.arcLimits.down),
            socket.arcLimits.down + socket.arcLimits.up,
            0.05f
            );

        // Restore the Handles stuff.
        Handles.matrix = mat4;
        Handles.color  = color;
    }
 /** Set the desired heading vector */
 public void SetDesiredHeading(Vector3 headingVector)
 {
     desiredHeading = AHMath.VectorXZToHeadingAngle(headingVector);
     turnScale      = headingVector.magnitude;
 }