public REngine() { RootPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); RLog.Info("Engine startup sequence activated."); _stopWatch = new Stopwatch(); _fpsTimer = new System.Timers.Timer(); _fpsTimer.Interval = 1000; _fpsTimer.Elapsed += _fpsTimer_Tick; _fpsTimer.Start(); _viewport = new RViewport(0, 0, 800, 600); camera = new RCamera(); lastFrameTime = new TimeSpan(); }
public void Begin() { oldCamera = REngine.Instance.GetCamera(); REngine.Instance.SetCamera(camera2d); GL.Disable(EnableCap.DepthTest); //GL.Viewport(0, (int)viewport.Width, 0, (int)viewport.Height); //blendState.ColorWriteChannels = RColorWriteChannels.All; GL.Enable(EnableCap.Blend); blendState.PlatformApplyState(); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); //GL.FrontFace(FrontFaceDirection.Ccw); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); REngine.CheckGLError(); GL.Disable(EnableCap.CullFace); camera2d.Update(); }
/// <summary> /// Constructs a new instance of the CameraComponent class. The /// camera will have a spectator behavior, and will be initially /// positioned at the world origin looking down the world negative /// z axis. An initial perspective projection matrix is created /// as well as setting up initial key bindings to the actions. /// </summary> public RCameraComponent(Game game) : base(game) { camera = new RCamera(); camera.CurrentBehavior = RCamera.Behavior.Spectator; movingAlongPosX = false; movingAlongNegX = false; movingAlongPosY = false; movingAlongNegY = false; movingAlongPosZ = false; movingAlongNegZ = false; savedMousePosX = -1; savedMousePosY = -1; rotationSpeed = DEFAULT_SPEED_ROTATION; orbitRollSpeed = DEFAULT_SPEED_ORBIT_ROLL; flightYawSpeed = DEFAULT_SPEED_FLIGHT_YAW; mouseWheelSpeed = DEFAULT_SPEED_MOUSE_WHEEL; mouseSmoothingSensitivity = DEFAULT_MOUSE_SMOOTHING_SENSITIVITY; acceleration = new Vector3(DEFAULT_ACCELERATION_X, DEFAULT_ACCELERATION_Y, DEFAULT_ACCELERATION_Z); velocity = new Vector3(DEFAULT_VELOCITY_X, DEFAULT_VELOCITY_Y, DEFAULT_VELOCITY_Z); mouseSmoothingCache = new Vector2[MOUSE_SMOOTHING_CACHE_SIZE]; mouseIndex = 0; mouseMovement = new Vector2[2]; mouseMovement[0].X = 0.0f; mouseMovement[0].Y = 0.0f; mouseMovement[1].X = 0.0f; mouseMovement[1].Y = 0.0f; Rectangle clientBounds = game.Window.ClientBounds; float aspect = (float)clientBounds.Width / (float)clientBounds.Height; Perspective(RCamera.DEFAULT_FOVX, aspect, RCamera.DEFAULT_ZNEAR, RCamera.DEFAULT_ZFAR); actionKeys = new Dictionary<Actions, Keys>(); actionKeys.Add(Actions.FlightYawLeftPrimary, Keys.Left); actionKeys.Add(Actions.FlightYawLeftAlternate, Keys.A); actionKeys.Add(Actions.FlightYawRightPrimary, Keys.Right); actionKeys.Add(Actions.FlightYawRightAlternate, Keys.D); actionKeys.Add(Actions.MoveForwardsPrimary, Keys.Up); actionKeys.Add(Actions.MoveForwardsAlternate, Keys.W); actionKeys.Add(Actions.MoveBackwardsPrimary, Keys.Down); actionKeys.Add(Actions.MoveBackwardsAlternate, Keys.S); actionKeys.Add(Actions.MoveDownPrimary, Keys.Q); actionKeys.Add(Actions.MoveDownAlternate, Keys.PageDown); actionKeys.Add(Actions.MoveUpPrimary, Keys.E); actionKeys.Add(Actions.MoveUpAlternate, Keys.PageUp); actionKeys.Add(Actions.OrbitRollLeftPrimary, Keys.Left); actionKeys.Add(Actions.OrbitRollLeftAlternate, Keys.A); actionKeys.Add(Actions.OrbitRollRightPrimary, Keys.Right); actionKeys.Add(Actions.OrbitRollRightAlternate, Keys.D); actionKeys.Add(Actions.StrafeRightPrimary, Keys.Right); actionKeys.Add(Actions.StrafeRightAlternate, Keys.D); actionKeys.Add(Actions.StrafeLeftPrimary, Keys.Left); actionKeys.Add(Actions.StrafeLeftAlternate, Keys.A); Game.Activated += new EventHandler<System.EventArgs>(HandleGameActivatedEvent); Game.Deactivated += new EventHandler<System.EventArgs>(HandleGameDeactivatedEvent); UpdateOrder = 1; }
public void SetCamera(RCamera camera) { REngine.camera = camera; }
public override void Init() { #if !XBOX this.Reactor.Init3DGame(1280, 720, false); #else this.Reactor.Init3DGame(180, 720, true); this.Reactor.SetXBox360Resolution(CONST_REACTOR_XBOX_RESOLUTION.r720P); #endif this.Reactor.SetWatermarkPosition(CONST_REACTOR_WATERMARK_POSITION.BOTTOM_RIGHT); Reactor.ShowFPS(true); Reactor.AllowEscapeQuit(true); Reactor.ShowMouse(false); //Reactor.SetDebugFile("debug.txt"); //Reactor.SetDebugMode(true); scene = new RScene(); screen = new RScreen2D(); textures = new RTextureFactory(); //lighting = new RLightingFactory(); //materials = new RMaterialFactory(); Reactor.Resized += new ViewportResized(Reactor_Resized); camera = this.Reactor.GetCamera(); camera.SetClipPlanes(1f, 180000); atmosphere = new RAtmosphere(); atmosphere.Initialize(); input = new RInput(); camera.Position = R3DVECTOR.Zero; camera.LookAt(new R3DVECTOR(0.5f,0f,0.5f)); font = screen.Create_TextureFont("Font1", "Font1"); //emitter = (RParticleEmitter)scene.CreateNode<RParticleEmitter>("myemitter"); //emitter2 = scene.CreateParticleEmitter(CONST_REACTOR_PARTICLETYPE.Billboard, "myemitter2"); landscape = (RLandscape)scene.CreateNode<RLandscape>("myland"); water = (RWater)scene.CreateNode<RWater>("mywater"); //mesh = (RActor)scene.CreateNode<RActor>("mymesh"); }