Example #1
0
        /*private IMeshPart findOrCreatePart(MeshCoreData.Material original)
         * {
         *  foreach (var mat in materials)
         *      if (isIdenticalMaterial(original, mat.Key)) return mat.Value;
         *
         *  var copy = createMaterialCopy(original);
         *  var ret = createPart(copy);
         *  materials.Add(copy, ret);
         *
         *  return ret;
         *
         * }*/

        private IMeshPart createPart(MeshCoreData.Material material)
        {
            var ret  = new RAMMeshPart();
            var part = new MeshCoreData.Part();

            part.MeshMaterial = material;
            part.ObjectMatrix = Matrix.Identity;
            part.MeshPart     = ret;

            mesh.GetCoreData().Parts.Add(part);

            return(ret);
        }
        public static IMesh Transform(IMesh mesh, Matrix transform)
        {
            //TODO: first take deep copy?
            var ret = new RAMMesh();

            ret.GetCoreData().Parts = mesh.GetCoreData().Parts.Select(p =>
            {
                var nPart          = new MeshCoreData.Part();
                nPart.ObjectMatrix = p.ObjectMatrix * transform.xna();
                nPart.MeshMaterial = p.MeshMaterial;
                nPart.MeshPart     = p.MeshPart;
                return(nPart);
            }).ToList();
            return(ret);
        }
        public static IMesh CreateSimpleTestMesh()
        {
            IMesh mesh;

            mesh = new RAMMesh();

            var part = new MeshCoreData.Part();

            part.ObjectMatrix = Matrix.Identity;
            part.MeshPart     = new RAMMeshPart();
            ((RAMMeshPart)part.MeshPart).SetGeometryData(MeshPartGeometryData.CreateTestSquare());

            var mat = new MeshCoreData.Material();

            mat.DiffuseMap = GetTestTexture();

            part.MeshMaterial = mat;
            mesh.GetCoreData().Parts.Add(part);

            return(mesh);
        }