-
Notifications
You must be signed in to change notification settings - Fork 0
/
Region2D.h
65 lines (52 loc) · 2.37 KB
/
Region2D.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef REGION2D_H
#define REGION2D_H
#pragma once
#include "SDL.h"
#include "SDL_opengl.h"
#include "Object2D.h"
#include "HandCursor.h"
// Stores an Region as a series of vertices, and enables rendering capabilties
class Region2D
{
private:
GLint nSides;
GLfloat Vertices[10][2]; //vertices in meters from the origin (bottom left corner of the screen)
GLfloat color[3]; //rgb array, with range 0-1
GLfloat borderColor[3]; //rgb array, with range 0-1
GLfloat borderWidth;
GLint drawOn;
GLint borderOn;
GLfloat xcenter;
GLfloat ycenter;
public:
~Region2D() { }
GLfloat GetRegionVert(GLint i, GLint j); // Gets a requsted polygon vertex
GLint GetRegionSides(); // Gets number of sides of the polygon
GLfloat GetRegionCenterX(); // Gets center X of the polygon
GLfloat GetRegionCenterY(); // Gets center Y of the polygon
void SetNSides(GLint sides); //set the number of sides in the polygon
void SetOneVert(GLint i, GLint j, GLfloat vert); // Sets one polygon vertex of the object (in meters)
void SetRegionCenter(GLfloat centerx, GLfloat centery); //set the center position of the region
void SetRegionVerts(GLfloat Verts[][2]); // Sets the polygon vertices of the object (in meters)
void SetRegionColor(GLfloat clr[]); // Sets the polygon color
void SetBorderColor(GLfloat clr[]); // Sets the polygon color
void SetBorderWidth(GLfloat width); //sets the polygon border width
int SetRectDims(GLfloat width, GLfloat height); // Sets rectangular polygon vertices of the object (in meters) from specified width and heigh
int SetCenteredRectDims(GLfloat width, GLfloat height); // Sets rectangular polygon vertices of the object (in meters) from specified width and heigh, centered at (0,0)
GLfloat GetRectWidth(); // Gets width, for rectangular polygon
GLfloat GetRectHeight(); // Gets height, for rectangular polygon
static Region2D LoadRegionFromFile(char* filePath); //load polygon from file
void Draw(); // Draw the object
void On(); //set draw flag on
void Off(); //set draw flag off
void BorderOn(); //set draw flag on
void BorderOff(); //set draw flag off
int DrawState(); //returns the draw flag
// Determines if the cursor is located within the region
bool InRegion(Object2D* cursor);
bool InRegion(HandCursor* cursor);
bool InRegion(GLfloat xcurs, GLfloat ycurs);
GLfloat Distance(Circle* c);
GLfloat Distance(Object2D* c);
};
#endif