Esempio n. 1
0
        protected void processEntity(XmlElement XMLNode, SceneNode pParent)
        {
            // Process attributes
            String name = getAttrib(XMLNode, "name");
            String meshFile = getAttrib(XMLNode, "meshFile");

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

            bool bvisible = getAttribBool(XMLNode, "visible", true);
            bool bcastshadows = getAttribBool(XMLNode, "castShadows", true);
            float brenderingDistance = getAttribReal(XMLNode, "renderingDistance", 0);

            // Create the entity
            Entity pEntity = null;
            try
            {
                //Mogre.MeshPtr mesh = Mogre.MeshManager.Singleton.Load(meshFile, m_sGroupName);
                //ushort src, dest;
                //mesh.SuggestTangentVectorBuildParams(Mogre.VertexElementSemantic.VES_TANGENT, out src, out dest);
                //mesh.BuildTangentVectors(Mogre.VertexElementSemantic.VES_TANGENT, src, dest);

                pEntity = mSceneMgr.CreateEntity(name, meshFile);
                pEntity.Visible = bvisible;
                pEntity.CastShadows = bcastshadows;
                pEntity.RenderingDistance = brenderingDistance;

                XmlElement pElement;
                // Process subentities (?)
                pElement = (XmlElement)XMLNode.SelectSingleNode("subentities");
                if (pElement != null)
                {
                    pElement = (XmlElement)pElement.FirstChild;
                    while (pElement != null)
                    {
                        string mat = getAttrib(pElement, "materialName");
                        pEntity.SetMaterialName(mat);
                        pElement = (XmlElement)pElement.NextSibling;
                    }
                }

                pParent.AttachObject(pEntity);
            }
            catch (Exception e)
            {
                m_log.Error("[DotSceneLoader] Error loading an entity! " + e.Message);
            }
        }