protected override void OnUpdateFrame(FrameEventArgs e) { if (Input.GetKey(Key.C)) { GameObject monkeyRigid = GameObject.Instantiate(Camera.Main.gameObject._transform.Position, new Quaternion(0, 0, 0, 0), 1); ///monkeyRigid.AddScript(new ScriptTest()); MeshRender meshLaucherPed = monkeyRigid.AddMeshRender(new MeshRender(monkeyRigid, new Mesh(AssetsManager.instance.GetMesh("Monkey")), new Shader(AssetsManager.instance.GetShader("Default")))); meshLaucherPed._shader.AddTexture(new Texture(AssetsManager.instance.GetTexture("woodplank01", "png"))); RigidBody body = monkeyRigid.AddRigidBody(); meshLaucherPed.Transparency = true; } if (Input.GetKeyDown(Key.F11)) { if (WindowState == WindowState.Fullscreen) { WindowState = WindowState.Normal; } else { WindowState = WindowState.Fullscreen; } } if (Input.GetKeyDown(Key.Escape)) { Exit(); } _UIManager.Text = "EvllyEngine FPS: " + FPS + " Tick: " + Time._Tick % 60 + " Objects: " + GameObjects.Count + " CameraPosition: " + Camera.Main.gameObject._transform.Position.ToString() + " CameraRotation: " + Camera.Main.gameObject._transform.Rotation.ToString(); Time._Time = (float)e.Time; Time._Tick++; _physics.UpdatePhisics((float)e.Time); base.OnUpdateFrame(e); }
public MeshRender AddMeshRender() { MeshRender meshrender = new MeshRender(this, AssetsManager.LoadModel("Assets/Models/", "Cube"), new Shader(AssetsManager.instance.GetShader("Default"))); meshrender._shader.AddTexture(new Texture(AssetsManager.instance.GetTexture("NewGrassTeste", "png"))); _MeshRender = meshrender; return(_MeshRender); }
public void OnDestroy() { _boxCollider.OnDestroy(); _meshRender.Dispose(); transform = null; _meshRender = null; _boxCollider = null; }
public void OnDestroy() { Engine.Instance.UpdateFrame -= Update; Engine.Instance.DrawUpdate -= Draw; if (_MeshRender != null) { _MeshRender.OnDestroy(); _MeshRender.gameObject = null; } if (_camera != null) { _camera.OnDestroy(); _camera.gameObject = null; } if (_boxCollider != null) { _boxCollider.OnDestroy(); } if (_meshCollider != null) { _meshCollider.OnDestroy(); } if (_rigidBody != null) { _rigidBody.OnDestroy(); } foreach (ScriptBase item in ScriptElements) { item.OnDestroy(); item.gameObject = null; } ScriptElements.Clear(); _transform._gameObject = null; _transform = null; _MeshRender = null; _camera = null; _meshCollider = null; _boxCollider = null; _rigidBody = null; ScriptElements = null; GC.Collect(); }
public Tree(Vector3 position, TreeType treeType) { HP = 100; MaxHP = 100; transform = new Transform(); System.Random rand = new System.Random(); float a = (float)rand.NextDouble(); float b = (float)rand.NextDouble(); float ChunkSeed = position.X * a + position.Z * b; transform.Position = position; transform.Rotation = new Quaternion(MathHelper.DegreesToRadians((float)new System.Random((int)ChunkSeed).Next(-10, 10)), MathHelper.DegreesToRadians((float)new System.Random((int)ChunkSeed).Next(0, 90)), MathHelper.DegreesToRadians((float)new System.Random((int)ChunkSeed).Next(-10, 10))); float size = ProjectEvlly.src.Utility.Random.Range(1.5f, 2f, (int)ChunkSeed); transform.Size = new Vector3(1, 1, 1); switch (treeType) { case TreeType.Oak: _meshRender = new MeshRender(transform, AssetsManager.GetMesh("oak"), AssetsManager.GetShader("Default"), AssetsManager.GetTexture("SpritesTreeHigt")); break; case TreeType.Pine: _meshRender = new MeshRender(transform, AssetsManager.GetMesh("Pine01"), AssetsManager.GetShader("Default"), AssetsManager.GetTexture("SpritesTreeHigt")); break; case TreeType.PineSnow: _meshRender = new MeshRender(transform, AssetsManager.GetMesh("Pine01"), AssetsManager.GetShader("Default"), AssetsManager.GetTexture("SpritesTreeHigt_Snow")); break; } _meshRender.ViewBoxWitdh = 3; _meshRender.ViewBoxHeight = 5; //_meshRender.Transparency = true; _meshRender._cullType = OpenTK.Graphics.OpenGL.CullFaceMode.FrontAndBack; _boxCollider = new BoxCollider(transform, new Vector3(0.7f, 5, 0.7f)); }
public MeshRender AddMeshRender(MeshRender meshrender) { _MeshRender = meshrender; return(_MeshRender); }
public override void OnDestroy() { Blocks = null; _MeshRender = null; base.OnDestroy(); }
protected override void OnLoad(EventArgs e) { //Load the Window/pre Graphics Stuff// VSync = VSyncMode.Off; WindowBorder = WindowBorder.Fixed; GL.ClearColor(Color4.DeepSkyBlue); GL.Enable(EnableCap.DepthTest); GL.CullFace(CullFaceMode.Front); GL.Viewport(0, 0, Width, Height); //Load the Engine Stuff// _assetsManager = new AssetsManager(); _UIManager = new UIManager(); _physics = new Physics(); SceneManager.LoadDontDestroyScene(); SceneManager.LoadDefaultScene(); GameObject Player = GameObject.Instantiate("Player", 1); Player._transform.Position = new Vector3(0, 50, 0); Player.AddRigidBody(); Player.AddScript(new PlayerEntity()); GameObject camobj = GameObject.Instantiate("Camera", 1); camobj._transform.Position = new Vector3(0, 1, 0); camobj.AddCamera(); camobj._transform.SetChild(Player._transform); GameObject World = GameObject.Instantiate(new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0), 1); World.AddScript(new World()); for (int x = 0; x < 2; x++) { if (x == 0) { GameObject obj = GameObject.Instantiate(new Vector3(x, 0, 0), Quaternion.Identity, 1); MeshRender mesh = obj.AddMeshRender(new MeshRender(obj, AssetsManager.instance.GetMesh("Cube"), new Shader(AssetsManager.instance.GetShader("Default")))); //obj.AddBoxCollider(new BoxCollider(obj, new Vector3(100,1,100))); obj.AddMeshCollider(); mesh._shader.AddTexture(new Texture(AssetsManager.instance.GetTexture("NewGrassTeste", "png"))); } else { GameObject obj = GameObject.Instantiate(new Vector3(x, 0.01f, 0), Quaternion.Identity, 1); MeshRender meshh = obj.AddMeshRender(new MeshRender(obj, AssetsManager.instance.GetMesh("Cube2"), new Shader(AssetsManager.instance.GetShader("Default")))); meshh._shader.AddTexture(new Texture(AssetsManager.instance.GetTexture("RockBrick_01", "png"))); obj.AddMeshCollider(); } } for (int i = 0; i < 1; i++) { GameObject wall = GameObject.Instantiate(new Vector3(0, 0, -100), new Quaternion(90, 0, 0, 0), 1); MeshRender mesh = wall.AddMeshRender(new MeshRender(wall, AssetsManager.instance.GetMesh("Cube"), new Shader(AssetsManager.instance.GetShader("Default")))); wall.AddBoxCollider(new BoxCollider(wall, new Vector3(100, 1, 100))); mesh._shader.AddTexture(new Texture(AssetsManager.instance.GetTexture("NewGrassTeste", "png"))); } GameObject obj2 = GameObject.Instantiate(new Vector3(0, 20, 0), new Quaternion(-90, 0, 0, 0), 1); MeshRender mesh2 = obj2.AddMeshRender(new MeshRender(obj2, _assetsManager.GetErrorMesh, new Shader(AssetsManager.instance.GetShader("Default")))); mesh2._shader.AddTexture(new Texture(AssetsManager.instance.GetTexture("RedTexture", "png"))); LaucherPed = GameObject.Instantiate(new Vector3(50, 1, 0), new Quaternion(0, 0, 0, 0), 1); LaucherPed.AddScript(new ScriptTest()); MeshRender meshLaucherPed = LaucherPed.AddMeshRender(new MeshRender(LaucherPed, new Mesh(AssetsManager.instance.GetMesh("Monkey")), new Shader(AssetsManager.instance.GetShader("Default")))); meshLaucherPed._shader.AddTexture(new Texture(AssetsManager.instance.GetTexture("woodplank01", "png"))); LaucherPed.AddRigidBody(); meshLaucherPed.Transparency = true; EngineReady = true; base.OnLoad(e); }