示例#1
0
        protected OgreMesh processEntity(XmlElement XMLNode)
        {
            // Process attributes
            String name       = XML.GetAttrib(XMLNode, "name");
            String userDataID = XML.GetAttrib(XMLNode, "id");
            String meshFile   = XML.GetAttrib(XMLNode, "meshFile") + ".xml";

            bool bstatic = XML.GetAttribBool(XMLNode, "static", false);

            if (bstatic)
            {
                StaticObjects.Add(name);
            }
            else
            {
                DynamicObjects.Add(name);
            }

            bool  bvisible           = XML.GetAttribBool(XMLNode, "visible", true);
            bool  bcastshadows       = XML.GetAttribBool(XMLNode, "castShadows", true);
            float brenderingDistance = XML.GetAttribFloat(XMLNode, "renderingDistance", 0);

            meshFile = Settings.ModelDir + dir + meshFile;

            OgreMesh mesh;

            try
            {
                mesh = new OgreMesh(name, meshFile);
                if (name.StartsWith("Path_"))
                {
                    return(null);                          // pathia ei lisätä sceneen
                }
                mesh.Visible    = bvisible;
                mesh.CastShadow = bcastshadows;
                mesh.UserDataID = userDataID;

                XmlElement pElement;
                // Process subentities
                pElement = (XmlElement)XMLNode.SelectSingleNode("subentities");
                if (pElement != null)
                {
                    pElement = (XmlElement)pElement.FirstChild;
                    while (pElement != null)
                    {
                        mesh.MaterialName = XML.GetAttrib(pElement, "materialName");
                        mesh.Material     = Material.GetMaterial(mesh.MaterialName);

                        pElement = (XmlElement)pElement.NextSibling;
                    }
                }
                return(mesh);
            }
            catch (Exception e)
            {
                Log.Error("Error loading " + meshFile + "\n" + e.Message);
            }

            return(null);
        }
示例#2
0
        protected override void RenderModel()
        {
            if (VBO.FastRenderPass)
            {
                return;
            }
            GameClass.NumOfObjects++;

            GL.Disable(EnableCap.DepthTest);
            GL.DepthMask(false); // ei kirjoiteta z-bufferiin
            GLExt.SetLighting(false);

            GLExt.PushMatrix();
            GLExt.ModelViewMatrix.Row3.X = GLExt.ModelViewMatrix.Row3.Y = GLExt.ModelViewMatrix.Row3.Z = 0;
            GLExt.Scale(10, 10, 10);
            for (int q = 0; q < 6; q++)
            {
                OgreMesh m = skyboxSides[q];
                m.Material.SetMaterial();
                m.Vbo.Render();
            }
            GLExt.PopMatrix();

            GLExt.SetLighting(true);
            GL.DepthMask(true);
            GL.Enable(EnableCap.DepthTest);
        }
示例#3
0
 public void SetSkyShader(string shaderFileName)
 {
     GetList(true);
     for (int q = 0; q < ObjList.Count; q++)
     {
         OgreMesh m = ObjList[q] as OgreMesh;
         m.Vbo.Shader = GLSLShader.Load(shaderFileName);
     }
 }
示例#4
0
文件: OgreMesh.cs 项目: bosoni/csat
        public static OgreMesh Load(string name, string fileName)
        {
            OgreMesh mesh;
            // jos mesh on jo ladattu, kloonaa se
            meshes.TryGetValue(fileName, out mesh);
            if (mesh != null)
                return (OgreMesh)mesh.Clone();

            mesh = new OgreMesh(name, fileName);
            return mesh;
        }
示例#5
0
文件: OgreMesh.cs 项目: Keilerr/csat
        public static OgreMesh Load(string name, string fileName)
        {
            OgreMesh mesh;

            // jos mesh on jo ladattu, kloonaa se
            meshes.TryGetValue(fileName, out mesh);
            if (mesh != null)
            {
                return((OgreMesh)mesh.Clone());
            }

            mesh = new OgreMesh(name, fileName);
            return(mesh);
        }
示例#6
0
        /// <summary>
        /// lataa skybox (ei cubemap). skyName on nimen alkuosa eli esim plainsky_  jos tiedostot on plainsky_front.jpg, plainsky_back.jpg jne
        /// ext on tiedoston pääte eli esim jpg, dds
        /// </summary>
        public static Sky Load(string skyName, string ext)
        {
            Sky sky = new Sky();

            string[] sideStr = { "top", "bottom", "left", "right", "front", "back" };
            Node     skyNode = new Node();
            DotScene ds      = DotScene.Load("sky/sky.scene", skyNode);

            int side = 0;

            TextureLoaderParameters.WrapModeS  = TextureWrapMode.ClampToEdge;
            TextureLoaderParameters.WrapModeT  = TextureWrapMode.ClampToEdge;
            TextureLoaderParameters.FlipImages = false;
            skyNode.GetList(true);
            for (int q = 0; q < ObjList.Count; q++)
            {
                OgreMesh m = ObjList[q] as OgreMesh;

                if (m != null)
                {
                    sky.skyboxSides[side] = m;
                    m.Boundings           = null;
                    m.CastShadow          = false;

                    string fileName = skyName + sideStr[side] + "." + ext;
                    m.MaterialName = fileName;
                    m.Material     = Material.GetMaterial(fileName + "_material");
                    m.Material.Textures[Settings.COLOR_TEXUNIT].Tex = Texture.Load(m.MaterialName);
                    side++;
                }
            }
            TextureLoaderParameters.FlipImages = true;
            TextureLoaderParameters.WrapModeS  = TextureWrapMode.Repeat;
            TextureLoaderParameters.WrapModeT  = TextureWrapMode.Repeat;

            return(sky);
        }
示例#7
0
        protected OgreMesh processEntity(XmlElement XMLNode)
        {
            // Process attributes
            String name = XML.GetAttrib(XMLNode, "name");
            String userDataID = XML.GetAttrib(XMLNode, "id");
            String meshFile = XML.GetAttrib(XMLNode, "meshFile") + ".xml";

            bool bstatic = XML.GetAttribBool(XMLNode, "static", false);
            if (bstatic)
                StaticObjects.Add(name);
            else
                DynamicObjects.Add(name);

            bool bvisible = XML.GetAttribBool(XMLNode, "visible", true);
            bool bcastshadows = XML.GetAttribBool(XMLNode, "castShadows", true);
            float brenderingDistance = XML.GetAttribFloat(XMLNode, "renderingDistance", 0);

            meshFile = Settings.ModelDir + dir + meshFile;

            OgreMesh mesh;
            try
            {
                mesh = new OgreMesh(name, meshFile);
                if (name.StartsWith("Path_")) return null; // pathia ei lisätä sceneen

                mesh.Visible = bvisible;
                mesh.CastShadow = bcastshadows;
                mesh.UserDataID = userDataID;

                XmlElement pElement;
                // Process subentities 
                pElement = (XmlElement)XMLNode.SelectSingleNode("subentities");
                if (pElement != null)
                {
                    pElement = (XmlElement)pElement.FirstChild;
                    while (pElement != null)
                    {
                        mesh.MaterialName = XML.GetAttrib(pElement, "materialName");
                        mesh.Material = Material.GetMaterial(mesh.MaterialName);

                        pElement = (XmlElement)pElement.NextSibling;
                    }
                }
                return mesh;
            }
            catch (Exception e)
            {
                Log.Error("Error loading " + meshFile + "\n" + e.Message);
            }

            return null;
        }