Permalink
Browse files

Added sphere of influence members to Overlay

  • Loading branch information...
Arvind Satyanarayan
Arvind Satyanarayan committed Feb 9, 2011
1 parent b0b1dd1 commit 71595acf9513e6ee9610b775bcb10f043a459df9
Showing with 22 additions and 2 deletions.
  1. +18 −0 overlay.cpp
  2. +4 −2 overlay.h
View
@@ -16,6 +16,7 @@ Overlay::Overlay(GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat h, GLfloat
this->color[0] = color[0];
this->color[1] = color[1];
this->color[2] = color[2];
+ this->sphere_size = 0.5f;
}
GLfloat Overlay::getX() {
@@ -36,6 +37,10 @@ GLfloat Overlay::getWidth() {
GLfloat Overlay::getHeight() {
return this->height;
+}
+
+GLfloat Overlay::getSphereSize() {
+ return this->sphere_size;
}
void Overlay::drawOverlayShape(void) {
@@ -111,6 +116,19 @@ void Overlay::getBoundingBox(GLfloat * bounding_box) {
bounding_box[3] = this->y + (this->height / 2);
}
+void Overlay::getBoundingBoxWithSOI(GLfloat * bounding_box) {
+ // [0] - minX
+ // [1] - minY
+ // [2] - maxX
+ // [3] - maxY
+
+ bounding_box[0] = this->x - (this->width / 2) - this->sphere_size;
+ bounding_box[1] = this->y - (this->height / 2) - this->sphere_size;
+
+ bounding_box[2] = this->x + (this->width / 2) + this->sphere_size;
+ bounding_box[3] = this->y + (this->height / 2) + this->sphere_size;
+}
+
void Overlay::addFinger(std::string id, GLfloat x, GLfloat y, GLfloat width, GLfloat height) {
Finger * f = new Finger(this, x, y, width, height);
this->fingers.insert(std::pair<std::string, Finger*>(id, f));
View
@@ -26,7 +26,7 @@ class Overlay {
void getPosInOverlay(GLfloat * posInOverlay);
};
- GLfloat x, y, z, width, height, color[3];
+ GLfloat x, y, z, width, height, color[3], sphere_size;
std::map<std::string, Overlay::Finger *> fingers;
void drawOverlayShape(void);
@@ -38,13 +38,15 @@ class Overlay {
GLfloat getY();
GLfloat getZ();
GLfloat getWidth();
- GLfloat getHeight();
+ GLfloat getHeight();
+ GLfloat getSphereSize();
void setOverlay(GLfloat new_x, GLfloat new_y, GLfloat new_w, GLfloat new_h);
void setOverlaySize(GLfloat new_w, GLfloat new_h);
void setOverlayPos(GLfloat new_x, GLfloat new_y);
void drawOverlay(void);
void getBoundingBox(GLfloat * bounding_box);
+ void getBoundingBoxWithSOI(GLfloat * bounding_box);
void addFinger(std::string id, GLfloat x, GLfloat y, GLfloat width, GLfloat height);
void removeFinger(std::string id);

0 comments on commit 71595ac

Please sign in to comment.