protected override void OnLoad(EventArgs e) { base.OnLoad(e); renderer = new MasterRenderer(WIDTH, HEIGHT); var playerModelMesh = objLoader.LoadObjModel("player", loader); var playerTexture = new ModelTexture(loader.LoadTexture("texture_player")) { ShineDamper = 5.0f, Reflectivity = 1.0f }; var texturedPlayerModel = new TexturedModel(playerModelMesh, playerTexture); player = new Player(texturedPlayerModel, new Vector3(0.0f, 0.0f, -2.0f), new Vector3(0.0f), 0.05f); var rawModel = objLoader.LoadObjModel("entity", loader); var texture = new ModelTexture(loader.LoadTexture("texture_entity")) { ShineDamper = 10.0f, Reflectivity = 1.0f }; var texturedModel = new TexturedModel(rawModel, texture); entity = new Entity(texturedModel, new Vector3(0.0f, 0.0f, -7.0f), new Vector3(0.0f), 1.0f); var terrainTexture = new ModelTexture(loader.LoadTexture("texture_terrain")); for (int x = -1; x < 1; x++) { for (int z = -1; z < 1; z++) { terrain.Add(new Terrain(x, z, loader, terrainTexture)); } } }
public void OnLoad() { arialFont = new FontData("Arial", "./Game/Fonts/Arial.fnt", 1024); arialFontMaterial = new Material(new UIShader(arialFont.TextureId), false, false, false); invertColorPostProcessing = new InvertedColorPostProcessing(); engineStartTime = DateTime.UtcNow; light = new Light(new Vector3d(10000000, 10000000, 10000000), new Vector3d(0, 1, 0), 100000000, 3f); mainLight = new Light(new Vector3d(-10000000, 10000000, 10000000), new Vector3d(1, 0, 0), 100000000, 3f); anotherLight = new Light(new Vector3d(0, -10000000, 10000000), new Vector3d(0, 0, 1), 100000000, 3f); camera = new Camera(RenderDataLoader.GenerateFrameBuffer(), RenderDataLoader.GenerateTexture(), RenderDataLoader.GenerateRenderBuffer()) { Position = new Vector3d(0, 0, 5), Rotation = new Vector3d(0, 0, 0), FarPlane = 1000f, NearPlane = 0.01f, FOV = 60, IsPerspective = true, ViewPortOffset = Vector2.Zero, ViewPortSize = Vector2.One, ClearColor = new Vector4(0.2f, 0.2f, 0.2f, 1f) }; secondCamera = new Camera(RenderDataLoader.GenerateFrameBuffer(), RenderDataLoader.GenerateTexture(), RenderDataLoader.GenerateRenderBuffer()) { Position = new Vector3d(0, 0, 0), Rotation = new Vector3d(0, 0, 0), FarPlane = 1000f, NearPlane = 0.01f, FOV = 60, IsPerspective = true, ViewPortOffset = Vector2.One * -0.5f, ViewPortSize = Vector2.One * 0.5f, ClearColor = new Vector4(0, 0, 0, 0), PostProcessing = new Material(invertColorPostProcessing, false, false, false) }; treeMesh = OBJLoader.LoadObjModel("Tree"); treeTexture = RenderDataLoader.LoadTexture("Tree"); standardMaterial = new Material(new StaticShader(treeTexture), true, true, false); uiMaterial = new Material(new UIShader(treeTexture), false, false, false); }