protected override void OnLoad(EventArgs e) { base.OnLoad(e); GL.Enable(EnableCap.DepthTest); GL.Disable(EnableCap.CullFace); SceneManager.LoadScene("Content/Scenes/Game.txt"); return; SceneManager.CurrentScene = new Scene(); SceneManager.CurrentScene.Name = "Game.txt"; GameObject camera = GameObject.Instantiate(null) as GameObject; camera.Name = "Main Camera"; camera.LocalTransform.Position = new Vector3(10, 15, 10); Camera camComponent = camera.AddComponent <Camera>(); camComponent.orthographic = false; quadObject = GameObject.Instantiate(null, Vector3.Zero, Quaternion.Identity) as GameObject; quadObject.Name = "Muro"; quadObject.LocalTransform.Scale = new Vector3(0.05f, 0.05f, 0.05f); MeshRenderer renderer = quadObject.AddComponent <MeshRenderer>(); StaticModel model = new StaticModel("Content/Models/muro.fbx"); renderer.StaticMesh = model; GameObject sun = GameObject.Instantiate(null, new Vector3(0, 5, 5), Quaternion.Identity) as GameObject; sun.Name = "Sun"; sun.AddComponent <DirectionalLight>(); MeshRenderer sunRenderer = sun.AddComponent <MeshRenderer>(); StaticModel sunModel = PrimitiveFactory.CreateCube(1); sunRenderer.StaticMesh = sunModel; Material sunmat = new Material(new Shader("Content/Shaders/default")); sunmat.DiffuseTexture = new Texture2D("Content/Images/checker.png"); sunModel.Meshes[0].MeshMaterial = sunmat; GameObject plane = GameObject.Instantiate(null, new Vector3(-10, 0, -10), Quaternion.Identity) as GameObject; plane.Name = "Plane"; MeshRenderer planeRenderer = plane.AddComponent <MeshRenderer>(); StaticModel planeModel = PrimitiveFactory.CreatePlane(20, 20); planeRenderer.StaticMesh = planeModel; Material mat = new Material(new Shader("Content/Shaders/default")); mat.DiffuseTexture = new Texture2D("Content/Images/checker.png"); planeModel.Meshes[0].MeshMaterial = mat; }
internal void CreateCubeGameObject() { GameObject obj = GameObject.Instantiate(null) as GameObject; obj.Name = "Cube" + currentScene.GameObjects.Count; Material mat = new Material(new Shader("Content/Shaders/default")); mat.DiffuseTexture = new Texture2D("Content/Images/cube.png"); MeshRenderer renderer = obj.AddComponent <MeshRenderer>(); renderer.StaticMesh = PrimitiveFactory.CreateCube(1); renderer.StaticMesh.Meshes[0].MeshMaterial = mat; AddObjectToHierarchy(obj); }