예제 #1
0
        public override void UpdateUserData(Mesh mesh)
        {
            List <Color4> colors = new List <Color4>();

            Color4 color = new Color4(1, 1, 1, mesh.DrawTransparent ? 0.25f : 1.0f);

            foreach (var x in mesh.Faces)
            {
                colors.AddRange(new Color4[] { color, color, color, color });
            }

            ClientArrayMeshUserData data = mesh.GetUserData <ClientArrayMeshUserData>();

            data.ColorArray = new float[colors.Count * 4];

            int vi = 0;

            foreach (var x in colors)
            {
                data.ColorArray[vi++] = x.R;
                data.ColorArray[vi++] = x.G;
                data.ColorArray[vi++] = x.B;
                data.ColorArray[vi++] = x.A;
            }
        }
예제 #2
0
        public override IMeshUserData CreateUserData(Mesh mesh)
        {
            ClientArrayMeshUserData data = new ClientArrayMeshUserData();

            List <Vector3> vertices  = new List <Vector3>();
            List <Vector2> texCoords = new List <Vector2>();
            List <byte>    indices   = new List <byte>();

            int totalCount = 0;

            foreach (var f in mesh.Faces)
            {
                vertices.AddRange(f.Vertices);
                texCoords.AddRange(f.TexCoords);

                foreach (var c in f.Indices)
                {
                    indices.Add((byte)(c + totalCount));
                }

                totalCount += f.Vertices.Length;
            }

            data.VerticeArray  = new float[vertices.Count * 3];
            data.TexCoordArray = new float[texCoords.Count * 2];
            data.IndiceArray   = indices.ToArray();

            int vi = 0;

            foreach (var x in vertices)
            {
                data.VerticeArray[vi++] = x.X;
                data.VerticeArray[vi++] = x.Y;
                data.VerticeArray[vi++] = x.Z;
            }

            vi = 0;
            foreach (var x in texCoords)
            {
                data.TexCoordArray[vi++] = x.X;
                data.TexCoordArray[vi++] = x.Y;
            }

            return(data);
        }
예제 #3
0
        public override IMeshUserData CreateUserData(Mesh mesh)
        {
            ClientArrayMeshUserData data = new ClientArrayMeshUserData();

            List<Vector3> vertices = new List<Vector3>();
            List<Vector2> texCoords = new List<Vector2>();
            List<byte> indices = new List<byte>();

            int totalCount = 0;
            foreach (var f in mesh.Faces)
            {
                vertices.AddRange(f.Vertices);
                texCoords.AddRange(f.TexCoords);

                foreach (var c in f.Indices)
                    indices.Add((byte)(c + totalCount));

                totalCount += f.Vertices.Length;
            }

            data.VerticeArray = new float[vertices.Count * 3];
            data.TexCoordArray = new float[texCoords.Count * 2];
            data.IndiceArray = indices.ToArray();

            int vi = 0;
            foreach (var x in vertices)
            {
                data.VerticeArray[vi++] = x.X;
                data.VerticeArray[vi++] = x.Y;
                data.VerticeArray[vi++] = x.Z;
            }

            vi = 0;
            foreach (var x in texCoords)
            {
                data.TexCoordArray[vi++] = x.X;
                data.TexCoordArray[vi++] = x.Y;
            }

            return data;
        }