Beispiel #1
0
        /**
         * @brief create an empty scene
         *
         * @param game the game engine
         *
         * @result an empty scene
         * */
        public static Scene CreateEmptyScene(CatProject _project)
        {
            Scene newScene = new Scene();

            // basic
            newScene.setYAngle(45.0f);
            newScene._XBound = new Vector2(-4.0f, 4.0f);
            newScene._YBound = new Vector2(-0.2f, 0.2f);
            newScene._ZBound = new Vector2(0.0f, 4.0f);

            // working list
            newScene._renderList = new RenderList();
            //newScene._colliderList = new ColliderList();
            newScene.m_physicsSystem = new PhysicsSystem();
            newScene.m_shadowSystem  = new ShadowSystem(_project);
            newScene._renderList.SetShadowRender(newScene.m_shadowSystem);
            newScene._uiRenderer = new UIRenderer();
            newScene.m_physicsSystem.Initialize();

            if (Mgr <GameEngine> .Singleton._gameEngineMode == GameEngine.GameEngineMode.MapEditor)
            {
                newScene._debugDrawableList = new DebugDrawableList();
                newScene._debugDrawableList.AddItem(newScene);

                newScene._selectableList = new RepeatableList <ISelectable>();
            }

            // empty list
            newScene._gameObjectList      = new GameObjectList();
            newScene.m_postProcessManager = new PostProcessManager();
            //newScene.m_postProcessManager.AddPostProcess()
            CreatePostProcess(newScene);
            return(newScene);
        }
Beispiel #2
0
        /**
         * @brief create a scene from an XML file
         *
         * @param node the XML node
         * @param game the game engine
         *
         * @result scene
         * */
        public static Scene LoadScene(string _filename) // node is the current node
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(_filename);
            XmlNode node = doc.SelectSingleNode("Scene");

            Scene newScene = new Scene();

            // working list
            newScene._renderList = new RenderList();
            //newScene._colliderList = new ColliderList();
            newScene.m_physicsSystem = new PhysicsSystem();
            newScene.m_shadowSystem  = new ShadowSystem(Mgr <CatProject> .Singleton);
            newScene._renderList.SetShadowRender(newScene.m_shadowSystem);
            newScene._uiRenderer = new UIRenderer();
            newScene.m_physicsSystem.Initialize();

            if (Mgr <GameEngine> .Singleton._gameEngineMode == GameEngine.GameEngineMode.MapEditor)
            {
                newScene._debugDrawableList = new DebugDrawableList();
                newScene._debugDrawableList.AddItem(newScene);

                newScene._selectableList = new RepeatableList <ISelectable>();
            }
            // bind to current scene
            //Mgr<Scene>.Singleton = newScene;

            // init scene basic list
            // load and construct scene here
            XmlNode    basic      = node.SelectSingleNode("SceneBasic");
            XmlElement sceneBasic = (XmlElement)basic;

            newScene.setYAngle(float.Parse(sceneBasic.GetAttribute("viewAngle")));
            String playerGameObjectName = sceneBasic.GetAttribute("playerGameObjectName");

            XmlElement XBound = (XmlElement)sceneBasic.SelectSingleNode("XBound");

            newScene._XBound = new Vector2(float.Parse(XBound.GetAttribute("min")),
                                           float.Parse(XBound.GetAttribute("max")));

            XmlElement YBound = (XmlElement)sceneBasic.SelectSingleNode("YBound");

            newScene._YBound = new Vector2(float.Parse(YBound.GetAttribute("min")),
                                           float.Parse(YBound.GetAttribute("max")));

            XmlElement ZBound = (XmlElement)sceneBasic.SelectSingleNode("ZBound");

            newScene._ZBound = new Vector2(float.Parse(ZBound.GetAttribute("min")),
                                           float.Parse(ZBound.GetAttribute("max")));

            // camera
            XmlNode nodeCamera = node.SelectSingleNode(typeof(Camera).ToString());

            Serialable.BeginSupportingDelayBinding();
            Camera camera = Serialable.DoUnserial((XmlElement)nodeCamera) as Camera;

            Serialable.EndSupportingDelayBinding();
            //Mgr<Camera>.Singleton = camera;
            newScene.m_camera = camera;
            newScene.m_camera.UpdateView();
            newScene.m_camera.UpdateProjection();

            // postprocess manager
            XmlNode nodePostProcessManager =
                node.SelectSingleNode(typeof(PostProcessManager).ToString());

            Serialable.BeginSupportingDelayBinding();
            newScene.m_postProcessManager =
                Serialable.DoUnserial((XmlElement)nodePostProcessManager) as PostProcessManager;
            Serialable.EndSupportingDelayBinding();

            // gameObjects
            XmlNode gameObjects = node.SelectSingleNode("GameObjects");

            newScene._gameObjectList = GameObjectList.LoadFromNode(gameObjects, newScene);

            PostLoadScene(newScene);

            return(newScene);
        }