示例#1
0
        public RenderWindow CreateRenderWindow(Control target)
        {
            // We cannot set up a window without an active rendersystem.
            //  Debug.Assert(Root.Instance.RenderSystem != null, "Cannot create	a RenderWindow without an active RenderSystem.");


            // Create a	new render window via the current render system
            // The parameters are as follows:
            //	string window name	-	Name of this render window. Must be unique.
            //	int width		-	The width of the render window (for clean image)of the control. Default 100??.
            //	int height		-	The height of the render window of the control. Default 100??.
            //	int colorDepth		-	The color depth of this window. Will be either 16, 24, 32
            //	bool isFullscreen	-	boolean indicating whether or not this window should be fullscreen
            //	int left		-	The horizontal origin of the render surface in the control. Default is 0.
            //	int top			-	The vertical origin of the render surface in the control. Default is 0.
            //	bool depthBuffer	-	Boolean indicating whether or not to use a depth buffer. Default true.
            //	bool vsync		-	Boolean indicating whether or not to synch rendering to the monitor's refresh rate.
            //	Control target		-	Target control to render onto. This must be a Form or PictureBox.
            Axiom.Collections.NamedParameterList paramList = new Axiom.Collections.NamedParameterList();
            paramList["externalWindowHandle"] = target.Handle;

            engine.Initialize(false);

            RenderWindow rWin = engine.CreateRenderWindow(
                "__window" + windowCount.ToString(), target.Width, target.Height, false, paramList);


            // Here, windowCount maintains a count of render windows created. If the count is zero,
            // then we want to do some setup. Doing this for every window created will cause exceptions.
            if (windowCount == 0)
            {
                //      Root.Instance.SceneManager.ShadowTechnique = ShadowTechnique.StencilModulative;


                // set default mipmap level
//TextureManager.Instance.DefaultNumMipMaps = 5;
                // retreive and initialize the input system
                //   input = PlatformManager.Instance.CreateInputReader();


                // The details of input handling are up to you. In this case, I'm instructing the
                // window to not capture control of the mouse.
                //    input.Initialize(rWin, true, true, false, false);
            }
            windowCount++;
            return(rWin);
        }
示例#2
0
        public RenderWindow CreateRenderWindow(Control target)
        {
            // We cannot set up a window without an active rendersystem.
              //  Debug.Assert(Root.Instance.RenderSystem != null, "Cannot create	a RenderWindow without an active RenderSystem.");

            // Create a	new render window via the current render system
            // The parameters are as follows:
            //	string window name	-	Name of this render window. Must be unique.
            //	int width		-	The width of the render window (for clean image)of the control. Default 100??.
            //	int height		-	The height of the render window of the control. Default 100??.
            //	int colorDepth		-	The color depth of this window. Will be either 16, 24, 32
            //	bool isFullscreen	-	boolean indicating whether or not this window should be fullscreen
            //	int left		-	The horizontal origin of the render surface in the control. Default is 0.
            //	int top			-	The vertical origin of the render surface in the control. Default is 0.
            //	bool depthBuffer	-	Boolean indicating whether or not to use a depth buffer. Default true.
            //	bool vsync		-	Boolean indicating whether or not to synch rendering to the monitor's refresh rate.
            //	Control target		-	Target control to render onto. This must be a Form or PictureBox.
            Axiom.Collections.NamedParameterList paramList = new Axiom.Collections.NamedParameterList();
            paramList["externalWindowHandle"] = target.Handle;

            engine.Initialize(false);

            RenderWindow rWin = engine.CreateRenderWindow(
                    "__window" + windowCount.ToString(), target.Width, target.Height, false,paramList);

            // Here, windowCount maintains a count of render windows created. If the count is zero,
            // then we want to do some setup. Doing this for every window created will cause exceptions.
            if (windowCount == 0)
            {
              //      Root.Instance.SceneManager.ShadowTechnique = ShadowTechnique.StencilModulative;

                // set default mipmap level
            //TextureManager.Instance.DefaultNumMipMaps = 5;
                // retreive and initialize the input system
             //   input = PlatformManager.Instance.CreateInputReader();

                // The details of input handling are up to you. In this case, I'm instructing the
                // window to not capture control of the mouse.
            //    input.Initialize(rWin, true, true, false, false);
            }
            windowCount++;
            return rWin;
        }
示例#3
0
            //
            public void axiom_init(PictureBox pictureBox1)
            {
                //
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US", false);

                //
                _engine = new Root("Game.log");
                _engine.RenderSystem = _engine.RenderSystems[0];
                _engine.Initialize(false);

                //
                Axiom.Collections.NamedParameterList paramList = new Axiom.Collections.NamedParameterList();
                paramList["externalWindowHandle"] = pictureBox1.Handle;
                _window = _engine.CreateRenderWindow("RenderWindow", pictureBox1.Width, pictureBox1.Height, false, paramList);

                //
                ResourceGroupManager.Instance.AddResourceLocation("media", "Folder", true);

                //
                _scene = _engine.CreateSceneManager("DefaultSceneManager", "DefaultSM");
                _scene.ClearScene();
                //_scene = Root.Instance.CreateSceneManager(SceneType.ExteriorClose);
                //_scene.LoadWorldGeometry("Terrain.xml");

                _camera          = _scene.CreateCamera("MainCamera");
                _camera.Position = new Vector3(0, 170, 300); // x=right/left from screen,y=bottom/up from screen,z=in/out from scren
                _camera.LookAt(Vector3.Zero);
                _camera.Near            = 5;
                _camera.AutoAspectRatio = true;

                //
                var vp = _window.AddViewport(_camera, 0, 0, 1.0f, 1.0f, 100);

                vp.BackgroundColor = ColorEx.CornflowerBlue;
                ResourceGroupManager.Instance.InitializeAllResourceGroups();



                //shadows and ambient light
                _scene.AmbientLight = ColorEx.Black;

                //_scene.ShadowTechnique = ShadowTechnique.StencilAdditive;
                _scene.ShadowTechnique = ShadowTechnique.StencilModulative;
                //_scene.ShadowTechnique = ShadowTechnique.TextureAdditive;
                //_scene.ShadowTechnique = ShadowTechnique.TextureModulative;


                Entity ent = _scene.CreateEntity("Penguin", "penguin.mesh");

                ent.CastShadows = true;


                node = _scene.RootSceneNode.CreateChildSceneNode("PenguinNode");
                node.AttachObject(ent);
                node.Position += new Vector3(25, 0, 0);
                //node.Scale = new Vector3(0.5f, 0.5f, 0.5f);
                //node2.ScaleBy(new Vector3(10, 10, 10));
                node.Yaw(180);
                node.Pitch(30);
                node.Roll(30);
                node.Position   += new Vector3(0, 50, 0);
                node.Orientation = Quaternion.FromEulerAngles(0, 0, 0);

                /*
                 * Entity ent2 = _scene.CreateEntity("Penguin2", "penguin.mesh");
                 * //ent2.IsVisible = false;
                 * //ent2.Name;
                 * //ent2.ParentSceneNode;
                 * ent2.CastShadows = true;
                 * SceneNode node2 = _scene.RootSceneNode.CreateChildSceneNode("Penguin2", new Vector3(0, 0, 0));
                 * node2.AttachObject(ent2);
                 * node2.Position += new Vector3(-50, 25, -50);
                 */

                //create ground
                Plane plane = new Plane(Vector3.UnitY, 0);

                MeshManager.Instance.CreatePlane("ground", ResourceGroupManager.DefaultResourceGroupName, plane, 300, 300, 20, 20, true, 1, 5, 5, Vector3.UnitZ);
                Entity groundEnt = _scene.CreateEntity("GroundEntity", "ground");

                _scene.RootSceneNode.CreateChildSceneNode().AttachObject(groundEnt);
                groundEnt.CastShadows  = false;
                groundEnt.MaterialName = "Rockwall";

                //create light
                Light pointLight = _scene.CreateLight("pointLight");

                pointLight.Type     = LightType.Point;
                pointLight.Position = new Vector3(0, 200, 0);
                pointLight.Diffuse  = ColorEx.White;
                pointLight.Specular = ColorEx.White;


                _timer_frame.Interval = 30;
                _timer_frame.Tick    += _timer_frame_Tick;
                _timer_frame.Start();
            }