public Game(GameWindow gameWindow, float frameRate) { this.camera = new FPVCamera(new Vector3(0, 0, 0), 1f); this.EntityManager = new EntityManager(); spider = ObjLoader.ObjLoader.LoadObj(@"C:\Users\majda\source\repos\SharpEngine-Core\SharpEngine-Core\TestModels\Spider\", "spider.obj", new Vector3(-100, 0, 0), this.EntityManager); spider.PhysicBody.RigidBody = new RigidBody(10f, spider.PhysicBody); var spider2 = ObjLoader.ObjLoader.LoadObj(@"C:\Users\majda\source\repos\SharpEngine-Core\SharpEngine-Core\TestModels\Spider\", "spider.obj", new Vector3(200, 0, 0), this.EntityManager); spider2.PhysicBody.RigidBody = new RigidBody(10f, spider.PhysicBody); spider.OnCollision += (o, e) => { e.Solid.Pos += new Vector3(200, 0, 0); }; EntityManager.Add(spider); EntityManager.Add(spider2); this.GW = gameWindow; this.FrameRate = frameRate; this.KeyboardProcessor = new KeyboardProcessor(this.GW); this.MouseProcessor = new MouseProcessor(this.GW); }
protected RenderPipeline(IRenderable renderable, ACamera camera) { Renderable = renderable; Camera = camera; if (_uniformBuffer != null) { return; } _uniformBuffer = new GLUniformBuffer(Marshal.SizeOf <Matrix4>() * 2, 0); _uniformBuffer.GpuAllocateDeferred(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); cameraView = FindViewById <TextureView>(Resource.Id.Texture_View); changeContrast = FindViewById <Button>(Resource.Id.changeContrast); changeZoom = FindViewById <Button>(Resource.Id.changeZoom); handler = new Handler(); changeContrast.Click += ChangeContrast_Click; changeZoom.Click += ChangeZoom_Click; aCamera = new ACamera(this, Android.Hardware.Camera2.LensFacing.Back, handler, cameraView); }
protected override void Initialize() { base.Initialize(); //Cameras _cameras[0] = new ACamera(graphics); _cameras[1] = new BCamera(graphics); _cameras[2] = new CCamera(graphics); //Mouse Mouse.SetPosition(graphics.PreferredBackBufferWidth / 2, graphics.PreferredBackBufferHeight / 2); originalMouseState = Mouse.GetState(); //BasicEffect basicEffect = new BasicEffect(GraphicsDevice); basicEffect.Alpha = 1f; basicEffect.TextureEnabled = true; //Cull RasterizerState rasterizerState = new RasterizerState(); rasterizerState.CullMode = CullMode.None; GraphicsDevice.RasterizerState = rasterizerState; //basicEffect.VertexColorEnabled = true; basicEffect.LightingEnabled = false; //Shapes floorVerts = new VertexPositionTexture[6]; floorVerts[0] = new VertexPositionTexture(new Vector3(-50, 0, -50), new Vector2(0, 0)); floorVerts[1] = new VertexPositionTexture(new Vector3(-50, 0, 50), new Vector2(0, 1)); floorVerts[2] = new VertexPositionTexture(new Vector3(50, -0, -50), new Vector2(1, 0)); floorVerts[3] = new VertexPositionTexture(floorVerts[1].Position, floorVerts[1].TextureCoordinate); floorVerts[4] = new VertexPositionTexture(new Vector3(50, 0, 50), new Vector2(1, 1)); floorVerts[5] = new VertexPositionTexture(floorVerts[4].Position, floorVerts[4].TextureCoordinate); //Vert buffer vertexBuffer = new VertexBuffer(GraphicsDevice, typeof( VertexPositionTexture), floorVerts.Length, BufferUsage. WriteOnly); vertexBuffer.SetData <VertexPositionTexture>(floorVerts); GraphicsDevice.SetVertexBuffer(vertexBuffer); }
public virtual void Draw(GraphicsDevice graphicsDevice, BasicEffect effect, ACamera camera) { effect.Projection = camera.Projection; effect.View = camera.View; GetModel().Draw(graphicsDevice, effect); }
public FPSCameraController(ACamera camera) { _assignedCamera = camera; _moveCamera = true; }
public GLForwardPipeline(IRenderable renderable, ACamera camera) : base(renderable, camera) { }
internal Window(string title, int width, int height, World world = null) { _requestedSize = new Size(width, height); // World Init World = world ?? new World(); // Native window and Render Context init NativeWindow = new NativeWindow(width, height, title, GameWindowFlags.Default, GraphicsMode.Default, DisplayDevice.Default) { Visible = true, Location = new Point(50, 50) }; DpiScale = NativeWindow.Width / (float)width; if (_renderContextNeedsInit) { RenderContext.Initialize(NativeWindow.WindowInfo); _renderContextNeedsInit = false; } // Cameras GuiCamera = new ACamera { IsOrthographic = true, Viewport = new Rectangle(0, 0, UnscaledSize.Width, UnscaledSize.Height), OrthographicBounds = new Rectangle(0, 0, UnscaledSize.Width, UnscaledSize.Height), NearZPlane = -100, FarZPlane = 100, ClearBufferMast = ClearBufferMask.DepthBufferBit }; MainCamera = new ACamera { AspectRatio = (UnscaledSize.Width / (float)UnscaledSize.Height), Viewport = new Rectangle(0, 0, UnscaledSize.Width, UnscaledSize.Height), ClearColor = Color.CornflowerBlue }; // Main Gui GuiElement MainGuiElement = new MainGuiElement(this) { Children = new List <GuiElement> { new GuiElement { BackgroundColor = Color.DarkRed, Width = (SFixed)300, MouseEnter = elem => elem.BackgroundColor = Color.White, MouseLeave = elem => elem.BackgroundColor = Color.DarkRed, ChildAlignment = ChildAlignments.Column, Children = new List <GuiElement> { new GuiElement { BackgroundColor = Color.DarkMagenta, Height = (SFixed)200, MouseEnter = elem => elem.BackgroundColor = Color.White, MouseLeave = elem => elem.BackgroundColor = Color.DarkMagenta, } } }, new GuiElement { Width = new SFill() }, new GuiElement { BackgroundColor = Color.DarkGreen, Width = (SFixed)400 } } }; MainGuiElement.LayoutChildren(new Rectangle(0, 0, NativeWindow.Width, NativeWindow.Height)); // Event Handler Registration RegisterEventHandlers(); // Viewport _viewport = new RenderViewport(NativeWindow.WindowInfo, new GLForwardPipeline(World, MainCamera), new GLForwardPipeline(MainGuiElement, GuiCamera)); }