Beispiel #1
0
 public Quad(Vector3 normal, UvVertex v0, UvVertex v1, UvVertex v2, UvVertex v3)
 {
     Normal = normal;
     V0     = v0;
     V1     = v1;
     V2     = v2;
     V3     = v3;
 }
Beispiel #2
0
        /// <summary>
        /// Adds the quad face for a block at the position provided, using the uv coordinates and offset.
        /// </summary>
        /// <param name="quad"></param>
        /// <param name="position"></param>
        /// <param name="uv"></param>
        /// <param name="uvOffset"></param>
        public void AddFace(Quad quad, Vector3 position, Vector2 uv, Vector2 uvOffset)
        {
            Vector3 normal = quad.Normal;
            Vector2 vertUv;

            for (int i = 0; i < 4; ++i)
            {
                UvVertex quadVert     = quad.At(i);
                Vector3  vertPosition = quadVert.Vertex + position;

                ApplyOffset(uv, quadVert.UV, uvOffset, out vertUv);
                AddVertex(vertPosition, vertUv, normal);
            }

            _triangles.Add(_triangleCount + 0);
            _triangles.Add(_triangleCount + 1);
            _triangles.Add(_triangleCount + 2);
            _triangles.Add(_triangleCount + 2);
            _triangles.Add(_triangleCount + 3);
            _triangles.Add(_triangleCount + 0);

            _triangleCount += 4;
        }