Exemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            Camera          = new Camera(this);
            Camera.Position = new Vector2(0, 10);
            this.Components.Add(Camera);

            DebugDrawer = new DebugDrawer(this);
            this.Components.Add(DebugDrawer);

            Display           = new Display(this);
            Display.DrawOrder = int.MaxValue;
            this.Components.Add(Display);

            this.PhysicScenes = new List <Scenes.Scene>();

            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (type.Namespace == "JitterDemo.Scenes" && !type.IsAbstract)
                {
                    if (type.Name == "Pyramid")
                    {
                        currentScene = PhysicScenes.Count;
                    }
                    Scenes.Scene scene = (Scenes.Scene)Activator.CreateInstance(type, this);
                    this.PhysicScenes.Add(scene);
                }
            }

            if (PhysicScenes.Count > 0)
            {
                this.PhysicScenes[currentScene].Build();
            }

            base.Initialize();
        }
Exemplo n.º 2
0
        protected override void Initialize()
        {
            Camera          = new Camera(this);
            Camera.Position = new Vector3(15, 15, 30);
            Camera.Target   = Camera.Position + Vector3.Normalize(new Vector3(10, 5, 20));
            this.Components.Add(Camera);

            DebugDrawer = new DebugDrawer(this);
            this.Components.Add(DebugDrawer);

            Display           = new Display(this);
            Display.DrawOrder = int.MaxValue;
            this.Components.Add(Display);

            primitives[(int)Primitives.box]      = new Primitives3D.BoxPrimitive(GraphicsDevice);
            primitives[(int)Primitives.capsule]  = new Primitives3D.CapsulePrimitive(GraphicsDevice);
            primitives[(int)Primitives.cone]     = new Primitives3D.ConePrimitive(GraphicsDevice);
            primitives[(int)Primitives.cylinder] = new Primitives3D.CylinderPrimitive(GraphicsDevice);
            primitives[(int)Primitives.sphere]   = new Primitives3D.SpherePrimitive(GraphicsDevice);

            BasicEffect = new BasicEffect(GraphicsDevice);
            BasicEffect.EnableDefaultLighting();
            BasicEffect.PreferPerPixelLighting = true;

            this.PhysicScenes = new List <Scenes.Scene>();


            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (type.Namespace == "JitterDemo.Scenes" && !type.IsAbstract && type.DeclaringType == null)
                {
                    if (type.Name == "SoftBodyJenga")
                    {
                        currentScene = PhysicScenes.Count;
                    }
                    Scenes.Scene scene = (Scenes.Scene)Activator.CreateInstance(type, this);
                    this.PhysicScenes.Add(scene);
                }
            }

            if (PhysicScenes.Count > 0)
            {
                this.PhysicScenes[currentScene].Build();
            }

            base.Initialize();
        }
        protected override void Initialize()
        {
            Camera          = new Camera(this);
            Camera.Position = new Vector3(15, 15, 30);
            Camera.Target   = Camera.Position + Vector3.Normalize(new Vector3(0, 0, 1));
            this.Components.Add(Camera);

            DebugDrawer = new DebugDrawer(this);
            this.Components.Add(DebugDrawer);

            Display           = new Display(this);
            Display.DrawOrder = int.MaxValue;
            this.Components.Add(Display);

            primitives[(int)Primitives.box]        = new Primitives3D.BoxPrimitive(GraphicsDevice);
            primitives[(int)Primitives.capsule]    = new Primitives3D.CapsulePrimitive(GraphicsDevice);
            primitives[(int)Primitives.cone]       = new Primitives3D.ConePrimitive(GraphicsDevice);
            primitives[(int)Primitives.cylinder]   = new Primitives3D.CylinderPrimitive(GraphicsDevice);
            primitives[(int)Primitives.sphere]     = new Primitives3D.SpherePrimitive(GraphicsDevice);
            primitives[(int)Primitives.convexHull] = new Primitives3D.SpherePrimitive(GraphicsDevice);



            BasicEffect = new BasicEffect(GraphicsDevice);
            BasicEffect.EnableDefaultLighting();
            BasicEffect.PreferPerPixelLighting = true;

            this.PhysicScenes = new List <Scenes.Scene>();


            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                if (type.Namespace == "JitterDemo.Scenes" && !type.IsAbstract && type.DeclaringType == null)
                {
                    if (type.Name == "SoftBodyJenga")
                    {
                        currentScene = PhysicScenes.Count;
                    }
                    Scenes.Scene scene = (Scenes.Scene)Activator.CreateInstance(type, this);
                    this.PhysicScenes.Add(scene);
                }
            }

            if (PhysicScenes.Count > 0)
            {
                this.PhysicScenes[currentScene].Build();
            }



            //Vector3 cameraPosition = new Vector3(30.0f, 30.0f, 30.0f);
            //Vector3 cameraTarget = new Vector3(0.0f, 0.0f, 0.0f); // Look back at the origin

            fovAngle    = MathHelper.ToRadians(90); // convert 45 degrees to radians //(float)Math.PI
            aspectRatio = graphics.PreferredBackBufferWidth / graphics.PreferredBackBufferHeight;
            near        = 0.01f;                    // the near clipping plane distance
            far         = 1000f;                    // the far clipping plane distance

            //worldMatrix = Matrix.CreateTranslation(10.0f, 0.0f, 10.0f);
            //viewMatrix = Matrix.CreateLookAt(cameraPosition, cameraTarget, Vector3.Up);
            //projectionMatrix = Matrix.CreatePerspectiveFieldOfView(fovAngle, aspectRatio, near, far);


            //GraphicsDevice.BlendState = BlendState.Opaque;
            //GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.RasterizerState = cullMode;
            GraphicsDevice.RasterizerState = normal;
            // initialize the Rift
            int result = rift.Init(GraphicsDevice);

            if (result != 0)
            {
                throw new InvalidOperationException("rift.Init result: " + result);
            }
            //manyCubes = new ManyCubes(GraphicsDevice);
            for (int eye = 0; eye < 2; eye++)
            {
                renderTargetEye[eye] = rift.CreateRenderTargetForEye(eye);
            }

            base.Initialize();

            hasInit = 1;
        }