Exemple #1
0
        /// <summary>
        /// initialize the scene
        /// </summary>
        private void InitializeScene()
        {
            //create scene mgr
            sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC);

            // Every viewport has a camera associated with it.
            // The second number is a z-order. Higher z-order viewports
            // are rendered on top (in the case of multiple viewports).
            Camera cam = sceneMgr.CreateCamera("cam");

            root.AutoCreatedWindow.AddViewport(cam, 0);

            Viewport vp = root.AutoCreatedWindow.GetViewport(0);

            vp.BackgroundColour = ColourValue.Black;

            // have the frustum set the aspect ratio automatically
            cam.AutoAspectRatio = true;

            Vector3    position    = new Vector3(0.0f, 0.0f, 0.0f);
            Quaternion orientation = Quaternion.IDENTITY;

            // In Ogre, an entity is a renderable object. An entity must be attached
            // to a scene node, however, in order to be rendered. Every entity (really,
            // every object in Ogre) must be assigned a unique name.

            shipCam        = new ArcballCamera(cam);
            shipCam.Radius = 250.0f;
            shipCam.Target = sceneMgr.RootSceneNode;

            Light l = sceneMgr.CreateLight("point1");

            l.DiffuseColour = new ColourValue(1.0f, 1.0f, 1.0f);
            l.Position      = Vector3.UNIT_Y * 100.0f;
            l.CastShadows   = true;
            l.Type          = Light.LightTypes.LT_POINT;

            sceneMgr.SetSkyBox(true, "Space", 5000);

            grid = sceneMgr.CreateStaticGeometry("grid");
            float radius = 100.0f;

            Entity cube;

            const int NUM_CUBES_HALF_WIDTH = 2;

            for (int i = -NUM_CUBES_HALF_WIDTH; i < NUM_CUBES_HALF_WIDTH; ++i)
            {
                for (int j = -NUM_CUBES_HALF_WIDTH; j < NUM_CUBES_HALF_WIDTH; ++j)
                {
                    for (int k = -NUM_CUBES_HALF_WIDTH; k < NUM_CUBES_HALF_WIDTH; ++k)
                    {
                        if (i != 0)
                        {
                            cube = sceneMgr.CreateEntity("cube-" + i + "-" + j + "-" + k,
                                                         SceneManager.PrefabType.PT_CUBE);
                            grid.AddEntity(cube, new Vector3(i, j, k) * radius * 10);
                        }
                    }
                }
            }
            grid.Build();

            shipMgr = new ShipManager(this);
        }
Exemple #2
0
        /// <summary>
        /// initialize the scene
        /// </summary>
        private void InitializeScene()
        {
            //create scene mgr
            sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC);

            // Every viewport has a camera associated with it.
            // The second number is a z-order. Higher z-order viewports
            // are rendered on top (in the case of multiple viewports).
            Camera cam = sceneMgr.CreateCamera("cam");
            root.AutoCreatedWindow.AddViewport(cam, 0);

            Viewport vp = root.AutoCreatedWindow.GetViewport(0);
            vp.BackgroundColour = ColourValue.Black;

            // have the frustum set the aspect ratio automatically
            cam.AutoAspectRatio = true;

            Vector3 position = new Vector3(0.0f, 0.0f, 0.0f);
            Quaternion orientation = Quaternion.IDENTITY;

            // In Ogre, an entity is a renderable object. An entity must be attached
            // to a scene node, however, in order to be rendered. Every entity (really,
            // every object in Ogre) must be assigned a unique name.

            shipCam = new ArcballCamera(cam);
            shipCam.Radius = 250.0f;
            shipCam.Target = sceneMgr.RootSceneNode;

            Light l = sceneMgr.CreateLight("point1");
            l.DiffuseColour = new ColourValue(1.0f, 1.0f, 1.0f);
            l.Position = Vector3.UNIT_Y * 100.0f;
            l.CastShadows = true;
            l.Type = Light.LightTypes.LT_POINT;

            sceneMgr.SetSkyBox(true, "Space", 5000);

            grid = sceneMgr.CreateStaticGeometry("grid");
            float radius = 100.0f;

            Entity cube;

            const int NUM_CUBES_HALF_WIDTH = 2;
            for (int i = -NUM_CUBES_HALF_WIDTH; i < NUM_CUBES_HALF_WIDTH; ++i)
                for (int j = -NUM_CUBES_HALF_WIDTH; j < NUM_CUBES_HALF_WIDTH; ++j)
                    for (int k = -NUM_CUBES_HALF_WIDTH; k < NUM_CUBES_HALF_WIDTH; ++k)
                    {
                        if (i != 0)
                        {
                            cube = sceneMgr.CreateEntity("cube-" + i + "-" + j + "-" + k,
                                SceneManager.PrefabType.PT_CUBE);
                            grid.AddEntity(cube, new Vector3(i, j, k) * radius * 10);
                        }
                    }
            grid.Build();

            shipMgr = new ShipManager(this);
        }