public override void Draw() { camera.Use(); { // grid draw shapesMaterial.Use(); Core.graphics.DrawMesh(gridMesh); // model test draw testmaterial.Use(); Core.graphics.SetModelToWorldMatrix(testtransform.GetLocalToWorldMatrix()); Core.graphics.DrawMesh(testmesh); // model test bounding box draw shapesMaterial.Use(); Core.graphics.SetWireframe(true); Models.DrawCube(testmesh.boundingBox, Color.red); Core.graphics.SetWireframe(false); // ray test draw shapesMaterial.Use(); Core.graphics.SetModelToWorldMatrix(Matrix4.identity); for (int i = 0; i < rays.Count; ++i) { Shapes.DrawLine(rays[i].position, rays[i].GetPoint(100), new Color(1, 0, 0, 0.5f)); } // model draw test //shapesMaterial.Use(); //Core.graphics.SetModelToWorldMatrix(Matrix4.identity); //Models.DrawCylinder(new Vector3f(10, 1, 10), 5f, 5f, 8f, 32, Color.green); //Core.graphics.SetWireframe(true); //Models.DrawCylinder(new Vector3f(10, 1, 10), 5f, 5f, 8f, 32, Color.maroon); //Core.graphics.SetWireframe(false); // billboard draw (note: last because is transparent object) spritesMaterial.Set("_MainTex", billboard); spritesMaterial.Use(); Core.graphics.SetModelToWorldMatrix(testtransformbillboard.GetLocalToWorldMatrix()); Sprites.DrawQuad(billboard.GetSize(), new IntRect(new Vector2i(-billboard.GetWidth() / 2, 0), billboard.GetSize())); } hudCamera.Use(); { // square indicator test draw shapesMaterial.Use(); Shapes.DrawRectangle((camera.WorldToScreenPixel(Vector2f.zero) / hudCamera.GetZoom()) - new Vector2f(5, 5), 10, 10, Color.blue); // procedural texture draw spritesMaterial.Set("_MainTex", proceduralTexture); spritesMaterial.Use(); Sprites.DrawQuad(proceduralTexture.GetSize(), new IntRect(Vector2i.zero, Math.Round(proceduralTexture.GetSize() * 0.125f))); } }
public static void Texture_Positions() { var texture = Core.resource.LoadTexture("Sprites/TestTexture"); for (int i = 0; i < 9; ++i) { for (int j = 0; j < 5; ++j) { // TODO: Material + Use() (Sprites/Default) Sprites.DrawQuad(texture.GetSize(), new IntRect(i * 100 + 25, j * 100 + 25, 100, 100)); } } }
public static void Textures_DestinationRect() { for (int i = 0; i < 10; ++i) { var color = Random.Color(); var textureId = Random.Range(0, textures.Count); var destinationRectBottomLeft = new Vector2i(Random.Range(0, Core.screen.width), Random.Range(0, Core.screen.height)); var destinationRectangle = new IntRect(destinationRectBottomLeft.x, destinationRectBottomLeft.y, Random.Range(0, Core.screen.width - destinationRectBottomLeft.x), Random.Range(0, Core.screen.height - destinationRectBottomLeft.y)); // TODO: Material + Use() (Sprites/Default) Sprites.DrawQuad(textures[textureId].GetSize(), destinationRectangle, color); } }
public static void Textures_SourceRect() { for (int i = 0; i < 10; ++i) { var position = new Vector2f(Random.Range(0, Core.screen.width), Random.Range(0, Core.screen.height)); var color = Random.Color(); var textureId = Random.Range(0, textures.Count); var sourceRectBottomLeft = new Vector2i(Random.Range(0, textures[textureId].GetWidth()), Random.Range(0, textures[textureId].GetHeight())); var sourceRectangle = new IntRect(sourceRectBottomLeft.x, sourceRectBottomLeft.y, Random.Range(sourceRectBottomLeft.x, textures[textureId].GetWidth()), Random.Range(sourceRectBottomLeft.y, textures[textureId].GetHeight())); // TODO: Material + Use() (Sprites/Default) Sprites.DrawQuad(textures[textureId].GetSize(), position, sourceRectangle, color); } }