public GUISprite(Point2f pos, Size2f size) { vertices= new Point3f[4]; texcoords= new TexCoord[4]; colors= new Color[4]; faces= new ushort[6]; vertices[0]= new Point3f(pos.x, pos.y, 0f); vertices[1]= new Point3f(pos.x, pos.y+size.height, 0f); vertices[2]= new Point3f(pos.x+size.width, pos.y+size.height, 0f); vertices[3]= new Point3f(pos.x+size.width, pos.y, 0f); texcoords[0]= new TexCoord(0f, 0f); texcoords[1]= new TexCoord(0f, 1f); texcoords[2]= new TexCoord(1f, 1f); texcoords[3]= new TexCoord(1f, 0f); applyColor(new Color(255, 255, 255, 255)); faces[0]= 0; faces[1]= 1; faces[2]= 3; faces[3]= 1; faces[4]= 2; faces[5]= 3; bvolume= new BVRectangle(pos, pos+size); comp= null; tb= new Rectangle(0f, 0f, 1f, 1f); }
public BVSector(Point2f pmPos, Vector2 pmDir, float radians, bool pmClockwise) { pPos= pmPos; dir= pmDir; theta= radians; bClockwise= pmClockwise; }
// Creates a circular bounding volume from the given 2d points public static BVCircle createFromPoints(Point2f[] vertices) { if(vertices== null) throw new ArgumentNullException(); if(vertices.Length== 0) throw new ArgumentException("No vertices declared"); // Variables Point2f min= new Point2f(float.MinValue); Point2f max= new Point2f(float.MaxValue); float r; for(int i= 0; i< vertices.Length; i++) { min= Mathx.min(vertices[i], min); max= Mathx.max(vertices[i], max); } r= Mathx.calcLength(max.x-min.x, max.y-min.y); r/= 2f; return new BVCircle(max|min, r); }
// Creates a bounding volume rectangle from the given 2d points public static BVRectangle createFromPoints(Point2f[] vertices) { if(vertices== null) throw new ArgumentNullException(); if(vertices.Length== 0) throw new ArgumentException("No vertices declared"); // Variables Point2f pmMin= new Point2f(float.MinValue); Point2f pmMax= new Point2f(float.MaxValue); for(int i= 0; i< vertices.Length; i++) { pmMin= Mathx.min(vertices[i], pmMin); pmMax= Mathx.max(vertices[i], pmMax); } return new BVRectangle(pmMin, pmMax); }
public override bool contains(ref Point2f pt) { return contains(ref pt.x, ref pt.y); }
public BVSector(Point2f pmPos, Vector2 pmDir, float radians) : this(pmPos, pmDir, radians, false) { }
// Adds the point with the size to get another point public Point2f add(Point2f pt) { return new Point2f(width+pt.x, height+pt.y); }
// Gets the minimum value of the point public static Point2f min(Point2f value, Point2f min) { // Variables Point2f temp= value; if(value.x< min.x) temp.x= min.x; if(value.y< min.y) temp.y= min.y; return temp; }
// Subtracts the two points to get a vector pointing in between both public Vector3 subtract(Point2f pt) { return new Vector3((float)x-pt.x, (float)y-pt.y, (float)z); }
// Subtracts the point with the vector to get a new point public Point2f subtract(Point2f pt) { return new Point2f(x-pt.x, y-pt.y); }
// Adds the point with the vector to get a new point public Point2f add(Point2f pt) { return new Point2f(x+pt.x, y+pt.y); }
public abstract bool contains(ref Point2f pt);
public virtual bool contains(Point2f pt) { return contains(ref pt); }
// Multiplies a 2d floating point to affect it public Point2f multiply(Point2f pt) { return new Point2f ( xx*pt.x+yx*pt.y+ox, xy*pt.x+yy*pt.y+oy ); }
public BVRectangle(Point2f pmMin, Point2f pmMax) { pMin= pmMin; pMax= pmMax; pPos= pMax|pMin; }
// Gets the most minimum point of the two given points public static Point2f getMostMin(Point2f val1, Point2f val2) { // Variables Point2f pt= Point2f.ORIGIN; if(val1.x< val2.x) pt.x= val1.x; else pt.x= val2.x; if(val1.y< val2.y) pt.y= val1.y; else pt.y= val2.y; return pt; }
// Gets the maximum value of the point public static Point2f max(Point2f value, Point2f max) { // Variables Point2f temp= value; if(value.x> max.x) temp.x= max.x; if(value.y> max.y) temp.y= max.y; return temp; }
// Subtracts the two points to get a vector pointing in between both public Vector2 subtract(Point2f pt) { return new Vector2(x-pt.x, y-pt.y); }
// Clamps the point to the given min and max bounds public static Point2f clamp(Point2f value, Point2f min, Point2f max) { // Variables Point2f temp= value; if(value.x< min.x) temp.x= min.x; else if(value.x> max.x) temp.x= max.x; if(value.y< min.y) temp.y= min.y; else if(value.y> max.y) temp.y= max.y; return temp; }
// Gets the midpoint of the two points public Point3f getMidpoint(Point2f pt) { return new Point3f((x+pt.x)/2f, (y+pt.y)/2f, z/2f); }
// Subtracts the point with the size to get another point public Point2f subtract(Point2f pt) { return new Point2f(width-pt.x, height-pt.y); }
// Subtracts the two points to get a vector pointing in between both public Vector3 subtract(Point2f pt) { return new Vector3(x-pt.x, y-pt.y, z); }
// Finds if the two points are equal public bool equals(Point2f pt) { return (x== (int)pt.x && y== (int)pt.y); }
// Gets the midpoint of the two points public Point2f getMidpoint(Point2f pt) { return new Point2f(((float)x+pt.x)/2f, ((float)y+pt.y)/2f); }
// Creates a circular bounding volume from the given 3d points public static BVCircle createFromPoints(Point3f[] vertices) { if(vertices== null) throw new ArgumentNullException(); // Variables Point2f[] results= new Point2f[vertices.Length]; for(int i= 0; i< vertices.Length; i++) { results[i].x= vertices[i].x; results[i].y= vertices[i].y; } return createFromPoints(results); }
// Subtracts the two points to get a vector pointing in between both public Vector2 subtract(Point2f pt) { return new Vector2((float)x-pt.x, (float)y-pt.y); }
public BVCircle(Point2f position, float pmRadius) { pPos= position; pRadius= Math.Abs(pmRadius); }
// Gives you a set of points that create a circle with the given position public static Point2f[] createCircularPoints(Point2f pos, float radius, int vertexAmount) { // Variables Point2f[] points= new Point2f[vertexAmount]; float segment= TWO_PI_F/(float)vertexAmount; for(int i= 0; i< vertexAmount; i++) { points[i].x= pos.x+radius*(float)(Math.Cos(i*segment)); points[i].y= pos.y+radius*(float)(Math.Sin(i*segment)); } return points; }
public Rectangle(Point2f pmPos, Size2f pmSize) { pPos= pmPos; pSize= pmSize; bvolume= new BVRectangle(pPos, pPos+pSize); }
// Finds if the texture coordinates are equal to the given 2d point public bool equals(Point2f pt) { return (u== pt.x && v== pt.y); }