public Rectangle Copy() { Rectangle temp = new Rectangle(); temp.X = X; temp.Y = Y; temp.Width = Width; temp.Height = Height; return temp; }
public static Rectangle Create(double x, double y, double width, double height) { Rectangle temp = new Rectangle(); temp.X = x; temp.Y = y; temp.Width = width; temp.Height = height; return temp; }
public static GlyphItem Create(string glyph, Rectangle uv, Vector2d size, Vector2d extents) { GlyphItem temp = new GlyphItem(glyph); temp.Glyph = glyph; temp.UVRect = uv; temp.Size = size; temp.Extents = extents; temp.ReferenceCount = 1; return temp; }
public void AddGlyphPoints(List<PositionTexture> pointList, Vector2d size, Rectangle position, Rectangle uv) { PositionTexture[] points = new PositionTexture[6]; for(int i=0; i<6;i++) { points[i] = new PositionTexture(); } Vector3d left = Vector3d.Cross(center, up); Vector3d right = Vector3d.Cross(up, center); left.Normalize(); right.Normalize(); up.Normalize(); Vector3d upTan = Vector3d.Cross(center, right); upTan.Normalize(); if (alignment == Alignment.Center) { left.Multiply(width - position.Left * 2); right.Multiply(width - ((width * 2) - position.Right * 2)); } else if (alignment == Alignment.Left) { left.Multiply(-position.Left * 2); right.Multiply(position.Right * 2); } Vector3d top = upTan.Copy(); Vector3d bottom = Vector3d.SubtractVectors(Vector3d.Empty,upTan); top.Multiply(height - position.Top * 2); bottom.Multiply(height - ((height * 2) - position.Bottom * 2)); Vector3d ul = center.Copy(); ul.Add(top); if (sky) { ul.Add(left); } else { ul.Subtract(left); } Vector3d ur = center.Copy(); ur.Add(top); if (sky) { ur.Add(right); } else { ur.Subtract(right); } Vector3d ll = center.Copy(); if (sky) { ll.Add(left); } else { ll.Subtract(left); } ll.Add(bottom); Vector3d lr = center.Copy(); if (sky) { lr.Add(right); } else { lr.Subtract(right); } lr.Add(bottom); points[0].Position = ul.Copy(); points[0].Tu = uv.Left; points[0].Tv = uv.Top; // points[0].Color = Color; points[2].Tu = uv.Left; points[2].Tv = uv.Bottom; points[2].Position = ll.Copy(); // points[2].Color = Color; points[1].Tu = uv.Right; points[1].Tv = uv.Top; points[1].Position = ur.Copy(); // points[1].Color = Color; points[3].Tu = uv.Right; points[3].Tv = uv.Bottom; points[3].Position = lr.Copy(); // points[3].Color = Color; points[5].Tu = uv.Right; points[5].Tv = uv.Top; points[5].Position = ur.Copy(); // points[5].Color = Color; points[4].Tu = uv.Left; points[4].Tv = uv.Bottom; points[4].Position = ll.Copy(); // points[4].Color = Color; if (Rotation != 0 || Tilt != 0 || Bank != 0) { if (!matInit) { Matrix3d lookAt = Matrix3d.LookAtLH(center, new Vector3d(), up); Matrix3d lookAtInv = lookAt.Clone(); lookAtInv.Invert(); rtbMat = Matrix3d.MultiplyMatrix(Matrix3d.MultiplyMatrix(Matrix3d.MultiplyMatrix( Matrix3d.MultiplyMatrix(lookAt, Matrix3d.RotationZ(-Rotation / 180 * Math.PI)), Matrix3d.RotationX(-Tilt / 180 * Math.PI)), Matrix3d.RotationY(-Bank / 180 * Math.PI)), lookAtInv); //todo make this true after debug matInit = true; } for (int i = 0; i < 6; i++) { points[i].Position = Vector3d.TransformCoordinate(points[i].Position, rtbMat); } } pointList.AddRange(points); }
public GlyphItem(string glyph) { Glyph = glyph; UVRect = new Rectangle(); Size = new Vector2d(); ReferenceCount = 1; }