comparison src/melodyTriangle.cpp @ 10:a8f71b5bdb0e

Toned down colours, increased buffer zone, added visual constraint feedback.
author samer
date Fri, 27 Jan 2012 09:23:43 +0000
parents 3d9e0db254dc
children 066104f9a2e2
comparison
equal deleted inserted replaced
9:3dff71c0e7fd 10:a8f71b5bdb0e
1 #include "melodyTriangle.h" 1 #include "melodyTriangle.h"
2 #include <GLUT/GLUT.h> 2 #include <GLUT/GLUT.h>
3 3
4 #define BUFFER_ZONE 50 // have to drag this far to snap out of triange.
4 /* 5 /*
5 /birth id 6 /birth id
6 /death id 7 /death id
7 /start id 8 /start id
8 /stop id 9 /stop id
122 123
123 } 124 }
124 125
125 //-------------------------------------------------------------- 126 //--------------------------------------------------------------
126 void melodyTriangle::draw(){ 127 void melodyTriangle::draw(){
127 128 bool constrained=false;
128 129
129 //let's draw our triangle
130 ofSetColor(0,0,255);
131
132 ofFill();
133 ofTriangle(x1, y1, x2, y2, x3, y3);
134 bool sendStart=false; 130 bool sendStart=false;
135 if (voiceGrabbed!=-1){ 131 if (voiceGrabbed!=-1){
136 if (mouseX!=(*voices[voiceGrabbed]).posx || mouseY!=(*voices[voiceGrabbed]).posy){ 132 if (mouseX!=(*voices[voiceGrabbed]).posx || mouseY!=(*voices[voiceGrabbed]).posy){
137 //(*voices[voiceGrabbed]).posx=mouseX; 133 //(*voices[voiceGrabbed]).posx=mouseX;
138 //(*voices[voiceGrabbed]).posy=mouseY; 134 //(*voices[voiceGrabbed]).posy=mouseY;
139 if ((*voices[voiceGrabbed]).inTriangle && !isInTriangle(mouseX,mouseY)){ 135 if ((*voices[voiceGrabbed]).inTriangle && !isInTriangle(mouseX,mouseY)){
140 ///death id 136 ///death id
141 137
142 if (ofDist((*voices[voiceGrabbed]).posx, (*voices[voiceGrabbed]).posy, mouseX, mouseY) > (*voices[voiceGrabbed]).radius*2){ 138 if (ofDist((*voices[voiceGrabbed]).posx, (*voices[voiceGrabbed]).posy, mouseX, mouseY)
139 > BUFFER_ZONE) {
143 140
144 141
145 ofxOscMessage m; 142 ofxOscMessage m;
146 ///track id x y left right top bottom area 143 ///track id x y left right top bottom area
147 m.setAddress( "/death" ); 144 m.setAddress( "/death" );
148 m.addIntArg( (*voices[voiceGrabbed]).id ); 145 m.addIntArg( (*voices[voiceGrabbed]).id );
149 sender.sendMessage( m ); 146 sender.sendMessage( m );
150 147
151 printf("sent /death %i \n",(*voices[voiceGrabbed]).id); 148 printf("sent /death %i \n",(*voices[voiceGrabbed]).id);
152 (*voices[voiceGrabbed]).posx=mouseX; 149 (*voices[voiceGrabbed]).posx=mouseX;
153 (*voices[voiceGrabbed]).posy=mouseY; 150 (*voices[voiceGrabbed]).posy=mouseY;
154
155 } else { 151 } else {
156 //printf("e"); 152 //printf("e");
157 //On Edge 153 //On Edge
154 constrained=true;
158 } 155 }
159 156
160 }else{ 157 }else{
161 (*voices[voiceGrabbed]).posx=mouseX; 158 (*voices[voiceGrabbed]).posx=mouseX;
162 (*voices[voiceGrabbed]).posy=mouseY; 159 (*voices[voiceGrabbed]).posy=mouseY;
197 } 194 }
198 } 195 }
199 196
200 } 197 }
201 }; 198 };
199
200 //let's draw our triangle
201 ofSetColor(128,128,128);
202 ofFill();
203 ofTriangle(x1, y1, x2, y2, x3, y3);
204 if (constrained) ofSetColor(255,128,128);
205
206 // draw smooth edge, brighter if a token is constrained
207 ofNoFill();
208 ofTriangle(x1, y1, x2, y2, x3, y3);
209
202 for (int i=0; i<numVoices; i++){ 210 for (int i=0; i<numVoices; i++){
203 (*voices[i]).draw(); 211 (*voices[i]).draw();
204 } 212 }
205 213
206 214