Exemple #1
0
        public Urho.VertexBuffer.PositionNormalColorTexcoord[] GetTexturedVertextData()
        {
            var data = new Urho.VertexBuffer.PositionNormalColorTexcoord[Vertices.Count];

            for (int i = 0; i < Vertices.Count; i++)
            {
                var v = Vertices[i];
                var n = Normals[i];
                var t = UV[i];

                //Urho.Color clr = Urho.Color.Green;
                //if (Vertices.Count == Colors.Count)
                //{
                //    var c = Colors[i];
                //    clr = Urho.Color.FromByteFormat((byte)(c.R * 255), (byte)(c.G * 255), (byte)(c.B * 255), 255);
                //}

                var d = new Urho.VertexBuffer.PositionNormalColorTexcoord();

                d.Position = new Urho.Vector3(v.X, v.Y, v.Z);
                d.Normal   = new Urho.Vector3(n.X, n.Y, n.Z);
                d.Color    = 0;
                d.TexCoord = new Urho.Vector2(t.X, t.Y);

                data[i] = d;
            }

            return(data);
        }
Exemple #2
0
        private static Urho.VertexBuffer.PositionNormalColorTexcoord[] GetTexturedVertextData(List <Vector3> vertices, List <Vector2> uv, List <Vector3> normals, List <Mesh.Triangle> triangles)
        {
            var data = new Urho.VertexBuffer.PositionNormalColorTexcoord[triangles.Count * 3];

            for (int i = 0; i < triangles.Count; i++)
            {
                var t   = triangles[i];
                var idx = i * 3;
                var d   = new Urho.VertexBuffer.PositionNormalColorTexcoord
                {
                    Position = vertices[(int)t.I1],
                    Normal   = normals[(int)t.In1],
                    TexCoord = uv[(int)t.Iu1],
                    Color    = 0
                };
                data[idx] = d;

                d = new Urho.VertexBuffer.PositionNormalColorTexcoord
                {
                    Position = vertices[(int)t.I2],
                    Normal   = normals[(int)t.In2],
                    TexCoord = uv[(int)t.Iu2],
                    Color    = 0
                };
                data[idx + 1] = d;

                d = new Urho.VertexBuffer.PositionNormalColorTexcoord
                {
                    Position = vertices[(int)t.I3],
                    Normal   = normals[(int)t.In3],
                    TexCoord = uv[(int)t.Iu3],
                    Color    = 0
                };
                data[idx + 2] = d;
            }

            return(data);
        }