protected override void LoadContent() { for (int eye = 0; eye < 2; eye++) { renderTargetEye[eye] = rift.CreateRenderTargetForEye(eye); } _spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here }
public override RenderTarget2D CreateRenderTargetForEye(int eye) { return(_oculusRift.CreateRenderTargetForEye(eye)); }
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; }