示例#1
0
        public void Init(UStaticMesh mesh, OpenGL gl)
        {
            int i         = 0;
            var materials = mesh.GetMaterials();

            foreach (SMeshFace face in mesh.Faces)
            {
                MeshSurfice s          = new MeshSurfice();
                int         end_offset = face.index_offset + (face.triangle_count * 3);
                for (int j = face.index_offset; j < end_offset; j += 3)
                {
                    s.Vertices.Add(mesh.Verteces[mesh.vertex_indicies_1[j]].Location.ToVertex());
                    s.Vertices.Add(mesh.Verteces[mesh.vertex_indicies_1[j + 1]].Location.ToVertex());
                    s.Vertices.Add(mesh.Verteces[mesh.vertex_indicies_1[j + 2]].Location.ToVertex());
                    s.UVs.Add(mesh.texture_coords[0].elements[mesh.vertex_indicies_1[j]].UV.ToUV());
                    s.UVs.Add(mesh.texture_coords[0].elements[mesh.vertex_indicies_1[j + 1]].UV.ToUV());
                    s.UVs.Add(mesh.texture_coords[0].elements[mesh.vertex_indicies_1[j + 2]].UV.ToUV());
                    s.Normals.Add(mesh.Verteces[mesh.vertex_indicies_1[j]].Normal.ToVertex());
                    s.Normals.Add(mesh.Verteces[mesh.vertex_indicies_1[j + 1]].Normal.ToVertex());
                    s.Normals.Add(mesh.Verteces[mesh.vertex_indicies_1[j + 2]].Normal.ToVertex());
                }
                SceneGraph.Assets.Material mat = new SharpGL.SceneGraph.Assets.Material();
                Texture texture             = new Texture();
                System.Drawing.Bitmap image = LibSquish.GetImage(materials[i].Texture);
                texture.Create(gl, image);
                mat.Texture     = texture;
                s.Material      = mat;
                s.TriangleCount = face.triangle_count;
                Surfices.Add(s);
                i++;
            }
            vertices = Surfices.SelectMany(s => s.Vertices).ToList();
            Console.WriteLine();
        }
示例#2
0
        private static unsafe byte[] CompressToDxt5(int w, int h, byte[] rgba)
        {
            var retn = new byte[LibSquish.dxt5_size(w, h)];

            fixed(byte *dataUCFixed = rgba)
            {
                fixed(byte *retnFixed = retn)
                {
                    LibSquish.compress_dxt5((IntPtr)dataUCFixed, w, h, (IntPtr)retnFixed);
                }
            }

            return(retn);
        }