Example #1
0
        public static int GetTrianglesForShape(RenderShape renderShape, RenderProjection projection)
        {
            // Tris is the number of triangles in each shape
            int tris = 0;

            switch (renderShape)
            {
            case RenderShape.Cube:
                tris = 12;
                break;

            case RenderShape.Arrow:
                tris = (projection == RenderProjection.FirstPerson) ? 2 : 3;
                break;

            case RenderShape.Square:
                tris = 2;
                break;

            case RenderShape.Triangle:
                tris = 1;
                break;

            case RenderShape.PointToPoint:
                tris = 4;
                break;
            }
            return(tris);
        }
Example #2
0
        public static int GetVecticesForShape(RenderShape renderShape, RenderProjection projection)
        {
            // Verts is the number of UNIQUE vertices in each shape
            int verts = 0;

            switch (renderShape)
            {
            case RenderShape.Cube:
                verts = 8;
                break;

            case RenderShape.Arrow:
                verts = (projection == RenderProjection.FirstPerson) ? 4 : 7;
                break;

            case RenderShape.Square:
                verts = 4;
                break;

            case RenderShape.Triangle:
                verts = 3;
                break;

            case RenderShape.PointToPoint:
                verts = 8;
                break;
            }
            return(verts);
        }
Example #3
0
 public void UpdateProjection(RenderProjection projection)
 {
     if (projection != m_Projection)
     {
         m_Projection  = projection;
         m_RenderState = k_BeginRenderer;
     }
 }
Example #4
0
        //Generate an arrow mesh procedurally
        public static int[] AddArrowTrisToMesh(int offset, RenderProjection projection)
        {
            if (projection == RenderProjection.FirstPerson)
            {
                return(AddSquareTrisToMesh(offset));
            }

            var tris = new int[]
            {
                0, 1, 5,        // left
                6, 0, 5,        //right
                3, 4, 2         // head
            };

            for (int a = 0; a < tris.Length; a++)
            {
                tris[a] += offset;
            }
            return(tris);
        }
Example #5
0
 public void UpdateProjection(RenderProjection projection)
 {
     //TODO
 }
Example #6
0
        public static Vector3[] AddArrowVectorsToMesh(float m_ParticleSize, Vector3 position, Vector3 rotation, RenderProjection projection)
        {
            float stemLength = 5f * m_ParticleSize;

            if (projection == RenderProjection.FirstPerson)
            {
                Quaternion q1 = Quaternion.Euler(rotation);
                Matrix4x4  m1 = Matrix4x4.TRS(position, q1, Vector3.one);
                Vector3    projectedPosition = m1.MultiplyPoint3x4(new Vector3(0f, 0f, m_ParticleSize * (stemLength + 1f)));
                return(AddDiamondVectorsToMesh(m_ParticleSize, RenderDirection.Billboard, projectedPosition, position));
            }

            float thirdP = m_ParticleSize / 3f;


            var p0 = new Vector3(-thirdP, 0f, 0f);
            var p1 = new Vector3(-thirdP, 0f, m_ParticleSize * stemLength);
            var p2 = new Vector3(-m_ParticleSize, 0f, m_ParticleSize * stemLength);
            var p3 = new Vector3(0f, 0f, m_ParticleSize * (stemLength + 1f));
            var p4 = new Vector3(m_ParticleSize, 0f, m_ParticleSize * stemLength);
            var p5 = new Vector3(thirdP, 0f, m_ParticleSize * stemLength);
            var p6 = new Vector3(thirdP, 0f, 0f);

            var v = new Vector3[] { p0, p1, p2, p3, p4, p5, p6 };

            Quaternion q = Quaternion.Euler(rotation);
            Matrix4x4  m = Matrix4x4.TRS(position, q, Vector3.one);

            for (int a = 0; a < v.Length; a++)
            {
                v[a] = m.MultiplyPoint3x4(v[a]);
            }
            return(v);
        }