/// <summary> /// The main entry point for the application. /// </summary> //[STAThread] static void Main() { var engine = new EngineMain(); #if Game GameMain game = new GameMain(engine); game.Start(); #else Demo demo = new Demo(engine); demo.DemoLevel(1); #endif using (engine) engine.Run(); }
public static void Main() { //string[] args = System.Environment.GetCommandLineArgs(); using (var engine = new EngineMain()) { var scene = engine.NewScene(); var factory = engine.Factory; new DebugKeys(scene, engine.Debug); var proceduralPlanets = new ProceduralPlanets(scene); { var entity = scene.AddEntity(); fpc = entity.AddComponent <FirstPersonCamera>(); fpc.planets = proceduralPlanets; //var flashLight = entity.AddComponent<Light>(); //flashLight.LighType = LightType.Point; var cam = scene.MainCamera = entity.AddComponent <Camera>(); cam.NearClipPlane = 0.5f; cam.FarClipPlane = 5000000; cam.AmbientColor = Vector3.One * 0.01f; // post process effects { entity.AddComponent <Bloom>(); entity.AddComponent <Tonemapping>(); var gr = entity.AddComponent <GodRays>(); gr.lightWorldRadius = 1000; entity.EventSystem.On <MyEngine.Events.PreRenderUpdate>((e) => { gr.lightScreenPos = cam.WorldToScreenPos(sunEntity.Transform.Position); gr.lightWorldPos = cam.Transform.Position.Towards(sunEntity.Transform.Position).ToVector3(); }); } string skyboxName = "skybox/generated/"; scene.skyBox = factory.GetCubeMap(new[] { skyboxName + "left.png", skyboxName + "right.png", skyboxName + "top.png", skyboxName + "bottom.png", skyboxName + "front.png", skyboxName + "back.png" }); entity.Transform.Position = new WorldPos(100, 100, 100); entity.Transform.LookAt(new WorldPos(0, 0, 100)); //engine.camera.entity.AddComponent<SSAO>(); } /* * { * var entity = scene.AddEntity(); * var mr = entity.AddComponent<MeshRenderer>(); * mr.Mesh = Factory.GetMesh("cube.obj"); * entity.Transform.Scale = new Vector3(100, 10, 10); * } */ // SUN { var entity = sunEntity = scene.AddEntity("sun"); entity.Transform.Scale *= sunRadius; var renderer = entity.AddComponent <MeshRenderer>(); renderer.Mesh = factory.GetMesh("sphere_smooth.obj"); renderer.RenderingMode = MyRenderingMode.RenderGeometryAndCastShadows; var mat = renderer.Material = factory.NewMaterial(); mat.RenderShader = factory.GetShader("shaders/sun.glsl"); mat.Uniforms.Set("param_turbulenceColorGradient", factory.GetTexture2D("textures/fire_gradient.png")); mat.Uniforms.Set("param_turbulenceMap", factory.GetTexture2D("textures/turbulence_map.png")); mat.Uniforms.Set("param_surfaceDiffuse", factory.GetTexture2D("textures/sun_surface_d.png")); mat.Uniforms.Set("param_perlinNoise", factory.GetTexture2D("textures/perlin_noise.png")); mat.Uniforms.Set("param_radius", sunRadius); } { var entity = scene.AddEntity("scene directional light"); var light = entity.AddComponent <Light>(); light.LighType = LightType.Point; light.Color = Vector3.One * 1f; light.Shadows = LightShadows.None; } engine.Run(); } }
public static void Main() { //string[] args = System.Environment.GetCommandLineArgs(); using (var engine = new EngineMain()) { { var go = new GameObject(); go.AddComponent <FirstPersonCamera>(); go.AddComponent <CreatePhysicsObject>(); engine.camera = go.AddComponent <Camera>(); //var c=go.AddComponent<BoxCollider>(); c.size = Vector3.One*5; string skyboxName = "skybox/sunny/"; engine.skyboxCubeMap = Factory.GetCubeMap(new Resource[] { skyboxName + "left.jpg", skyboxName + "right.jpg", skyboxName + "top.jpg", skyboxName + "bottom.jpg", skyboxName + "front.jpg", skyboxName + "back.jpg" }); go.transform.position = (new Vector3(1, 1, 1)) * 100; go.transform.LookAt(new Vector3(0, 0, 100)); var drag = go.AddComponent <DragLegoPieces>(); var t = new GameObject(); var renderer = t.AddComponent <MeshRenderer>(); renderer.mesh = Factory.GetMesh("sphere.obj"); drag.visualiseHitTarget = t; //engine.camera.gameObject.AddComponent<SSAO>(); } { var go = new GameObject(); //go.AddComponent<Rigidbody>(); var renderer = go.AddComponent <MeshRenderer>(); renderer.mesh = Factory.GetMesh("internal/cube_bigUVs.obj"); renderer.material.albedoTexture = Factory.GetTexture2D("textures/grassDIFFUSE.jpg"); renderer.material.normalMap = Factory.GetTexture2D("textures/grassNORMAL.jpg"); renderer.material.depthMap = Factory.GetTexture2D("textures/grassDISP.jpg"); //renderer.material.albedoTexture = Factory.GetTexture2D("textures/cobblestonesDiffuse.bmp"); //renderer.material.normalMap = Factory.GetTexture2D("textures/cobblestonesNormal.bmp"); //renderer.material.depthMap = Factory.GetTexture2D("textures/cobblestonesDepth.bmp"); //renderer.material.albedoTexture = Factory.GetTexture2D("textures/stonewallDiffuse.bmp"); //renderer.material.normalMap = Factory.GetTexture2D("textures/stonewallNormal.bmp"); //renderer.material.depthMap = Factory.GetTexture2D("textures/stonewallDepth.bmp"); go.transform.Translate(new Vector3(0, -10, 0)); go.transform.scale = new Vector3(1000, 1, 1000); go.AddComponent <BoxCollider>(); } { var go = new GameObject(); var renderer = go.AddComponent <MeshRenderer>(); renderer.mesh = Factory.GetMesh("lego/block_20x20x05.obj"); renderer.material.albedo = LegoPiece.colors[5]; go.transform.Translate(new Vector3(30, 1, 20)); go.AddComponent <Rigidbody>(); var c = go.AddComponent <BoxCollider>(); go.AddComponent <LegoPiece>(); } /*{ * var go = new GameObject(); * //go.AddComponent<Rigidbody>(); * var renderer = go.AddComponent<MeshRenderer>(); * renderer.mesh = Factory.GetMesh("internal/cube.obj"); * go.transform.Translate(new Vector3(0, 0, 2)); * go.AddComponent<BoxCollider>(); * renderer.material.albedoTexture = Factory.GetTexture2D("textures/cobblestonesDiffuse.bmp"); * renderer.material.albedo = Vector4.One; * renderer.material.normalMap = Factory.GetTexture2D("textures/cobblestonesNormal.bmp"); * renderer.material.depthMap = Factory.GetTexture2D("textures/cobblestonesDepth.bmp"); * }*/ { var go = new GameObject(); var renderer = go.AddComponent <MeshRenderer>(); renderer.mesh = Factory.GetMesh("dragon.obj"); go.transform.position += new Vector3(-30, 0, 0); go.GetComponent <MeshRenderer>().material.smoothness = 0.8f; go.AddComponent <Rigidbody>(); go.AddComponent <BoxCollider>(); } { var go = new GameObject(); go.transform.position = new Vector3(-10, 10, -10); go.transform.LookAt(Vector3.Zero); var light = go.AddComponent <Light>(); light.type = LightType.Directional; light.color = Vector3.One * 0.7f; light.shadows = LightShadows.Soft; var renderer = go.AddComponent <MeshRenderer>(); renderer.mesh = Factory.GetMesh("internal/cube.obj"); go.AddComponent <BoxCollider>(); go.AddComponent <MoveWithArrowKeys>(); go.AddComponent <VisualizeDir>(); //go.AddComponent<LightMovement>(); } { var go = new GameObject(); go.transform.position = new Vector3(10, 10, 10); go.transform.LookAt(Vector3.Zero); var light = go.AddComponent <Light>(); light.type = LightType.Directional; light.color = Vector3.One * 0.7f; light.shadows = LightShadows.Soft; var renderer = go.AddComponent <MeshRenderer>(); renderer.mesh = Factory.GetMesh("internal/cube.obj"); go.AddComponent <VisualizeDir>(); //go.AddComponent<LightMovement>(); } { var go = new GameObject(); go.transform.position = new Vector3(0, 10, 0); go.transform.LookAt(Vector3.Zero); var light = go.AddComponent <Light>(); light.type = LightType.Point; light.color = Vector3.One * 0.3f; light.shadows = LightShadows.Soft; var renderer = go.AddComponent <MeshRenderer>(); renderer.mesh = Factory.GetMesh("internal/cube.obj"); go.AddComponent <VisualizeDir>(); } engine.Run(30); } }