示例#1
0
    public void DrawEllipse()
    {
        Vector3[] vertices = new Vector3[segments + 1];
        for (int i = 0; i < segments; i++)
        {
            // Turn into floats to prevent issues
            float h = i;
            float l = segments;
            float t = h / l;
            // create ellipse position
            Vectors pos = orbit.Create(t, new Vectors(xOrigin, yOrigin, 0));

            Matrix4X4 yawMatrix   = Matrix4X4.CreateYaw(yaw);
            Matrix4X4 pitchMatrix = Matrix4X4.CreatePitch(pitch);
            Matrix4X4 rollMatrix  = Matrix4X4.CreateRoll(roll);

            Vectors rollVertex  = rollMatrix * pos;
            Vectors pitchVertex = pitchMatrix * rollVertex;
            Vectors yawVertex   = yawMatrix * pitchVertex;

            // Store the position
            vertices[i] = new Vector3(yawVertex.x, yawVertex.y, yawVertex.z);
        }
        // Set the last point to the first (closes the loop)
        vertices[segments] = vertices[0];

        LR.positionCount = segments + 1;
        LR.SetPositions(vertices);

        // Set line width based on distance from camera
        float magnitude = ResizeOrbitMesh(vertices);

        LR.endWidth   = magnitude;
        LR.startWidth = magnitude;
    }
示例#2
0
    // Set Orbit vertex data for current position
    void setOrbit()
    {
        // Grab position along orbit
        Vectors orbitPosition = orbit.orbit.Create(Oprogress, RotationOrigin);

        // Sort out matrix conversion
        Matrix4X4 yawMatrix   = Matrix4X4.CreateYaw(orbit.yaw);
        Matrix4X4 pitchMatrix = Matrix4X4.CreatePitch(orbit.pitch);
        Matrix4X4 rollMatrix  = Matrix4X4.CreateRoll(orbit.roll);

        Vectors rollVertex  = rollMatrix * orbitPosition;
        Vectors pitchVertex = pitchMatrix * rollVertex;
        Vectors yawVertex   = yawMatrix * pitchVertex;

        // Set position to this position
        CurrentPosition = yawVertex;
        //Debug.Log(orbitPosition.x + " " + orbitPosition.y + " " + orbitPosition.z);
    }
示例#3
0
    // Combine RPY angles together into a quaternion
    public static Quarts QCombinedAxis(Vectors A)
    {
        Quarts r = new Quarts(0, new Vectors(0, 0, 0));

        // Create matrices from axes
        Matrix4X4 R = Matrix4X4.CreateRoll(A.x);
        Matrix4X4 P = Matrix4X4.CreatePitch(A.y);
        Matrix4X4 Y = Matrix4X4.CreateYaw(A.z);

        // Convert to quaternion
        Quarts RQ = MatToQuat(R);
        Quarts PQ = MatToQuat(P);
        Quarts YQ = MatToQuat(Y);

        // Multiply together to get combined quarternion
        r = (RQ * PQ) * YQ;

        return(r);
    }