public override void draw() { texture ??= new Texture(bitmap); preDraw(); float aspectRatio = (float)bitmap.Width / bitmap.Height; Vector3 size = new Vector3(height * aspectRatio, height, 1); vertexList = new VertexList() { vertices = new List <Vertex> { new Vertex { point = new Vector3(-0.5f, -0.5f, pos.Z), color = color, texCoord = new Vector2(0, 1) }, new Vertex { point = new Vector3(-0.5f, 0.5f, pos.Z), color = color, texCoord = new Vector2(0, 0) }, new Vertex { point = new Vector3(0.5f, -0.5f, pos.Z), color = color, texCoord = new Vector2(1, 1) }, new Vertex { point = new Vector3(0.5f, 0.5f, pos.Z), color = color, texCoord = new Vector2(1, 0) } }, indices = new List <uint> { 0, 1, 2, 2, 3, 1 } }; transformationMatrix = Matrix4.Identity * Matrix4.CreateScale(size.ToOpenTKVector3()); switch (anchor) { case Anchor.Left: transformationMatrix *= Matrix4.CreateTranslation(size.X / 2, 0, 0); break; case Anchor.Right: transformationMatrix *= Matrix4.CreateTranslation(-size.X / 2, 0, 0); break; } transformationMatrix *= Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(rotationDegrees)) * Matrix4.CreateTranslation(pos.ToOpenTKVector3()); draw(PrimitiveType.Triangles); }
public override void draw() { preDraw(); vertexList = new VertexList() { vertices = points.Select(p => new Vertex { point = p, color = color }), indices = points.Select((p, i) => (uint)i) }; draw(PrimitiveType.LineStrip); }
public override void draw() { preDraw(); vertexList = new VertexList() { vertices = new List <Vertex> { new Vertex { point = new Vector3(-0.5f, -0.5f, pos.Z), color = color, texCoord = new Vector2(0, 1) }, new Vertex { point = new Vector3(-0.5f, 0.5f, pos.Z), color = color, texCoord = new Vector2(0, 0) }, new Vertex { point = new Vector3(0.5f, -0.5f, pos.Z), color = color, texCoord = new Vector2(1, 1) }, new Vertex { point = new Vector3(0.5f, 0.5f, pos.Z), color = color, texCoord = new Vector2(1, 0) } }, indices = new List <uint> { 0, 1, 2, 2, 3, 1 } }; transformationMatrix = Matrix4.Identity * Matrix4.CreateScale(size.ToOpenTKVector3()) * Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(rotationDegrees)) * Matrix4.CreateTranslation(pos.ToOpenTKVector3()); draw(PrimitiveType.Triangles); }
public override void draw() { preDraw(); vertexList = new VertexList() { vertices = new List <Vertex>() { new Vertex() { point = p1, color = color, texCoord = new Vector2(0, 0) }, new Vertex() { point = p2, color = color, texCoord = new Vector2(0, 0) }, new Vertex() { point = p3, color = color, texCoord = new Vector2(0, 0) }, }, indices = new List <uint> { 1, 2, 3 } }; transformationMatrix = Matrix4.Identity * Matrix4.CreateScale(scale.ToOpenTKVector3()) * Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(rotationDegrees)); draw(PrimitiveType.Triangles); }