public Player(Scene parent, Vector3 spawnPos, Vector3 viewDir, GameInput gameInput) { Parent = parent; this.gameInput = gameInput; //create hud renderer hud = new Hud(this); parent.guis.Add(hud); Position = spawnPos; PointingDirection = viewDir; upVector = new Vector3(0, 1, 0); zNear = 0.1f; zFar = 100; Shape boxShape = new BoxShape(new JVector(0.5f, 2, 0.5f)); Body = new RigidBody(boxShape); Body.Position = new JVector(Position.X, Position.Y, Position.Z); Body.AllowDeactivation = false; JMatrix mMatrix = JMatrix.Identity; //mBody.SetMassProperties(mMatrix, 2,false); Jitter.Dynamics.Constraints.SingleBody.FixedAngle mConstraint = new Jitter.Dynamics.Constraints.SingleBody.FixedAngle(Body); parent.world.AddConstraint(mConstraint); parent.world.AddBody(Body); viewInfo = new ViewInfo(this); viewInfo.aspect = (float)gameWindow.Width / (float)gameWindow.Height; viewInfo.updateProjectionMatrix(); tools.Add(new GameMenu(this, gameInput)); tools.Add(new Spawner(this, gameInput)); tools.Add(new Grabber(this, gameInput)); tools.Add(new Remover(this, gameInput)); tools.Add(new TerrainGun(this, gameInput)); tool = tools[1]; }
public CubemapBufferSets(Scene parent, FramebufferCreator mFramebufferCreator, int size) { this.Scene = parent; Parent = parent; Vector2 vecSize = new Vector2(size,size); float fovy = (float)Math.PI/2; for (int i = 0; i < 6; i++) { outFrameBuffers[i] = mFramebufferCreator.createFrameBuffer(size, size, PixelInternalFormat.Rgba8, true); outTextures[i] = outFrameBuffers[i].ColorTexture; FrameBufferSets[i] = new FramebufferSet(mFramebufferCreator, vecSize, outFrameBuffers[i]); cubeView[i] = new ViewInfo(this); cubeView[i].PointingDirection = viewDirections[i]; cubeView[i].upVec = upDirections[i]; cubeView[i].aspect = 1f; cubeView[i].fovy = fovy; cubeView[i].updateProjectionMatrix(); } }
protected override void OnLoad(System.EventArgs e) { //generate stopwatch sw = new Stopwatch(); //set size of the render virtual_size = new Vector2(1920, 1080); state = new GameState(); string versionOpenGL = GL.GetString(StringName.Version); log(versionOpenGL); // make the Coursor disapear Cursor.Hide(); // center it on the window Cursor.Position = new Point( (Bounds.Left + Bounds.Right) / 2, (Bounds.Top + Bounds.Bottom) / 2); // other state GL.ClearColor(System.Drawing.Color.Black); VSync = VSyncMode.On; screenSize = new Vector2(Width, Height); // create instances of necessary objects textureLoader = new TextureLoader(this); framebufferCreator = new FramebufferCreator(this); meshLoader = new MeshLoader(this); shaderLoader = new ShaderLoader(this); materialLoader = new MaterialLoader(this); templateLoader = new TemplateLoader(this); mScene = new Scene(this); // create gameInput gameInput = new GameInput(mScene, Keyboard, Mouse); // set files for displaying loading screen shaderLoader.fromXmlFile("shaders\\composite.xsp"); shaderLoader.fromTextFile("shaders\\composite.vs", "shaders\\splash_shader.fs"); meshLoader.fromObj("models\\sprite_plane.obj"); textureLoader.fromFile("materials\\ultra_engine_back.png",true); textureLoader.fromFile("materials\\ultra_engine_back_h.png",true); materialLoader.fromXmlFile("materials\\composite.xmf"); //loading noise manualy so we can disable multisampling textureLoader.fromFile("materials\\noise_pixel.png", false); // load files for loading screen textureLoader.LoadTextures(); meshLoader.loadMeshes(); shaderLoader.loadShaders(); materialLoader.loadMaterials(); // setup 2d filter (loading screen) splashFilter2d = new Quad2d(this); // set time to zero spawnTime = get_time(); }