Beispiel #1
0
        public List <Vector3> GetModelVertices(float Scale)
        {
            List <Vector3> verts = new List <Vector3>();

            VertexStaticModel[] vertices = new VertexStaticModel[numVertices];
            vertexBuffer.GetData(vertices);
            foreach (VertexStaticModel vertex in vertices)
            {
                verts.Add(vertex.Position * Scale);
            }

            return(verts);
        }
Beispiel #2
0
        public void ConvertVertexPositionNormalToStaticModelVertex(VertexPositionNormal vertex, Vector2 texCoords, out VertexStaticModel outVertex)
        {
            // @NOTE: Since we don't have UVs we don't have a relative up, so all this does is give
            // us two vectors orthagonal to the vertex.Normal

            Vector3 referenceVector = Vector3.UnitY;
            float   refDot          = Vector3.Dot(referenceVector, vertex.Normal);

            if (refDot == 1.0f || refDot == -1.0f)
            {
                referenceVector = Vector3.UnitZ;
            }
            Vector3 tangent  = Vector3.Cross(vertex.Normal, referenceVector);
            Vector3 binormal = Vector3.Cross(vertex.Normal, -tangent);

            outVertex = new VertexStaticModel(vertex.Position, vertex.Normal, tangent, binormal, texCoords);
        }