Example #1
0
        public override void load(MediaLoader ml, FileSystem fs, string path)
        {
            MeshDef mesh = MeshFile.Load(fs, path);

            mesh.compile(ml);
            this.mesh = mesh.Compiled;
        }
Example #2
0
        public MeshPart(MediaLoader ml, MeshDef.MaterialDef m, MeshDef def, Poseable poseable)
        {
            this.poseable = poseable;

            mat = new Material(m.diffuse, ml.fetch <Texture>(m.texture));
            foreach (MeshDef.Tri tri in def.TrianglesFor(m))
            {
                faces.Add(def.lookup(tri));
            }
        }
Example #3
0
 public SimpleWorld(MediaLoader loader, string file)
 {
     using (var s = loader.FS.open(file))
     {
         XmlElement level = Xml.Open(Xml.FromStream(s), "level");
         addMeshes(loader, level["world"], add);
         addMeshes(loader, level["camera"], addCamera);
         addEntities(loader, level["entity"]);
     }
 }
Example #4
0
        public override void load(MediaLoader ml, FileSystem fs, string path)
        {
            Bitmap b = new Bitmap(fs.open(path));

            b.RotateFlip(RotateFlipType.RotateNoneFlipY);
            Rectangle  rectangle  = new Rectangle(0, 0, b.Width, b.Height);
            BitmapData bitmapData = b.LockBits(rectangle, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);

            img = new Image(false, b.Width, b.Height, bitmapData.Scan0, false, Gl.GL_BGR_EXT);
            b.UnlockBits(bitmapData);
        }
Example #5
0
 private void addMeshes(MediaLoader loader, XmlElement level, RenderableAddTarget target)
 {
     foreach (XmlElement entity in Xml.ElementsNamed(level, "entity"))
     {
         string       t        = Xml.GetAttributeString(entity, "type");
         string       name     = Xml.GetAttributeString(entity, "name");
         string       meshpath = t + ".mdf";
         MeshInstance mesh     = new MeshInstance(loader.fetch <Mesh>(meshpath));
         mesh.pos = GetPosition(entity["position"]);
         mesh.rot = GetRotation(entity["rotation"]);
         target(mesh);
     }
 }
Example #6
0
        internal static Entity Create(MediaLoader loader, string name, System.Xml.XmlElement root, vec3 pos, quat rot)
        {
            Entity ent = new Entity(name);

            XmlElement visual = root["visual"];

            foreach (XmlElement meshel in Xml.ElementsNamed(visual, "mesh"))
            {
                string       meshpath = Xml.GetAttributeString(meshel, "file");
                MeshInstance mesh     = new MeshInstance(loader.fetch <Mesh>(meshpath));
                mesh.pos = pos;
                mesh.rot = rot;
                ent.add(mesh);
            }

            return(ent);
        }
Example #7
0
        private void addEntities(MediaLoader loader, XmlElement level)
        {
            foreach (XmlElement entity in Xml.ElementsNamed(level, "entity"))
            {
                string t = Xml.GetAttributeString(entity, "type");
                if (t[0] == '_')
                {
                    continue;              // ignore for now
                }
                string name     = Xml.GetAttributeString(entity, "name");
                string meshpath = t + ".gob";
                vec3   pos      = GetPosition(entity["position"]);
                quat   rot      = GetRotation(entity["rotation"]);

                using (var gobstream = loader.FS.open(meshpath))
                {
                    addEntity(Entity.Create(loader, name, Xml.Open(Xml.FromStream(gobstream), "object"), pos, rot));
                }
            }
        }
Example #8
0
        public CompiledMesh(MediaLoader ml, MeshDef def)
        {
            List<Exception> errors = new List<Exception>();
            foreach (MeshDef.MaterialDef m in def.Materials)
            {
                if (def.hasTrianglesFor(m))
                {
                    try
                    {
                        parts.Add(new MeshPart(ml, m, def, this));
                    }
                    catch (Exception e)
                    {
                        errors.Add(e);
                    }
                }
            }

            if (errors.Count != 0)
            {
                throw new Exception("Several errors occured");
            }
        }
Example #9
0
 public void compile(MediaLoader ml)
 {
     compiledMesh = new CompiledMesh(ml, this);
 }
Example #10
0
 public static World Load(MediaLoader loader, string file)
 {
     return(new SimpleWorld(loader, file));
 }
Example #11
0
 public abstract void load(MediaLoader ml, FileSystem fs, string path);