Permalink
Browse files

replace with ofxStateMachine

  • Loading branch information...
1 parent 38a8b13 commit e4380dff93f79991124fe58aa57e16a776f890e3 hideyukisaito committed Mar 12, 2013

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,7 +1,7 @@
-#include "ofxArsUIButton.h"
+#include "ArsUIButton.h"
#include "ofxEasingFunc.h"
-ofxArsUIButton::ofxArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _angle){
+ArsUIButton::ArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _angle){
x = _x;
y = _y;
bid = _bid;
@@ -18,15 +18,15 @@ ofxArsUIButton::ofxArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, floa
viewAngle = _angle;
}
-void ofxArsUIButton::update(){
+void ArsUIButton::update(){
float v = sinf((float)bcnt/speed * 2 * PI);
radius = 30 + v*4;
bcnt++;
if(bcnt == speed) bcnt =0;
}
-void ofxArsUIButton::draw(){
+void ArsUIButton::draw(){
//status: 0:default 1:select
ofColor c;
@@ -70,7 +70,7 @@ void ofxArsUIButton::draw(){
ofPopMatrix();
}
-int ofxArsUIButton::tapped(float _x, float _y){
+int ArsUIButton::tapped(float _x, float _y){
double distance = sqrt( (double)((_x - x) * (_x - x) + (_y - y)*(_y - y))) ;
if (distance < radius/2) {
return bid;
@@ -79,7 +79,7 @@ int ofxArsUIButton::tapped(float _x, float _y){
}
//return radian
-double ofxArsUIButton::calcDirection(ofPoint *_p1, ofPoint *_p2){
+double ArsUIButton::calcDirection(ofPoint *_p1, ofPoint *_p2){
double v1[] = {100.0, 0};
double v2[] = { _p2->x - _p1->x, _p2->y - _p1->y };
double cosTheta,theta,innerProduct;
@@ -92,21 +92,21 @@ double ofxArsUIButton::calcDirection(ofPoint *_p1, ofPoint *_p2){
return theta;
}
-void ofxArsUIButton::setAngle(float _angle){
+void ArsUIButton::setAngle(float _angle){
viewAngle = _angle;
}
-void ofxArsUIButton::setStatus(int _status){
+void ArsUIButton::setStatus(int _status){
status = _status;
}
-int ofxArsUIButton::getStatus(){
+int ArsUIButton::getStatus(){
return bid;
}
-int ofxArsUIButton::getId(){
+int ArsUIButton::getId(){
return bid;
}
-void ofxArsUIButton::setCameraStatus(double _lat, double _lon){
+void ArsUIButton::setCameraStatus(double _lat, double _lon){
latitude = _lat;
longtitude = _lon;
ofPoint place = GPStoXY(_lat, _lon);
@@ -115,7 +115,7 @@ void ofxArsUIButton::setCameraStatus(double _lat, double _lon){
}
-ofPoint ofxArsUIButton::GPStoXY(double _lat,double _lon){
+ofPoint ArsUIButton::GPStoXY(double _lat,double _lon){
//calibration set
//fuji benchmark (富士 中心)
double fujiLat = 35.362841;
View
@@ -0,0 +1,30 @@
+#include "ofMain.h"
+
+
+class ArsUIButton
+{
+ protected:
+ int status,bcnt,speed,tcnt; //status 0: not selected, 1:selected, 2: broken
+ ofImage mark,markShadow;
+ float x,y,radius;
+ int bid;
+ ofPoint fuji;
+ double directionToFuji; //radian
+ double currentDirection;
+ double calcDirection(ofPoint *_p1, ofPoint *_p2);
+ double viewAngle;
+ double latitude;
+ double longtitude;
+
+ public:
+ ArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _angle );
+ virtual void draw();
+ virtual void update();
+ virtual int tapped(float _x, float _y);
+ void setAngle(float _angle);
+ void setStatus(int _status);
+ int getStatus();
+ int getId();
+ void setCameraStatus(double _lat, double _lon);
+ ofPoint GPStoXY(double _lat,double _lon);
+};
@@ -1,14 +1,14 @@
-#include "ofxArsUIRoboCam.h"
+#include "ArsUIRoboCam.h"
-ofxArsUIRoboCam::ofxArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji,float _angle):ofxArsUIButton(_x,_y,_bid,_fuji,_angle){
- ofxArsUIButton::mark.loadImage("markyellow.png");
+ArsUIRoboCam::ArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji,float _angle):ArsUIButton(_x,_y,_bid,_fuji,_angle){
+ ArsUIButton::mark.loadImage("markyellow.png");
}
-void ofxArsUIRoboCam::update(){
- ofxArsUIButton::update();
+void ArsUIRoboCam::update(){
+ ArsUIButton::update();
}
-void ofxArsUIRoboCam::draw(){
+void ArsUIRoboCam::draw(){
//status: 0:default 1:select
ofColor c;
@@ -66,29 +66,29 @@ void ofxArsUIRoboCam::draw(){
}
-int ofxArsUIRoboCam::tapped(float _x, float _y){
- int _bid = ofxArsUIButton::tapped(_x,_y);
+int ArsUIRoboCam::tapped(float _x, float _y){
+ int _bid = ArsUIButton::tapped(_x,_y);
if (_bid != -1 && status ==1){
setDefaultAngle();
}
return _bid;
}
-void ofxArsUIRoboCam::dragAngle(float _x, float _y){
+void ArsUIRoboCam::dragAngle(float _x, float _y){
if(status == 1){
float distance = sqrt((x - _x) * (x - _x) + (y - _y) *(y - _y) );
if (distance > radius && distance < radius *1.5) {
ofPoint p1 = ofPoint(x,y);
ofPoint p2 = ofPoint(_x,_y);
- float newAngle = ofxArsUIButton::calcDirection(&p1,&p2);
+ float newAngle = ArsUIButton::calcDirection(&p1,&p2);
// if(newAngle < directionToFuji + 0.8 && newAngle > directionToFuji - 0.8 ){
currentDirection = newAngle;
// }
}
}
}
-bool ofxArsUIRoboCam::dragAngleEnded (float _x, float _y){
+bool ArsUIRoboCam::dragAngleEnded (float _x, float _y){
if(status == 1){
float distance = sqrt((x - _x) * (x - _x) + (y - _y) *(y - _y) );
if (distance > radius && distance < radius *1.5) {
@@ -99,11 +99,11 @@ bool ofxArsUIRoboCam::dragAngleEnded (float _x, float _y){
return false;
}
-void ofxArsUIRoboCam::setDefaultAngle(){
+void ArsUIRoboCam::setDefaultAngle(){
currentDirection = directionToFuji;
}
-void ofxArsUIRoboCam::setRoboStatus(string _udid, double _lat, double _long, double _robox, double _roboy, double _buttery, bool _living){
+void ArsUIRoboCam::setRoboStatus(string _udid, double _lat, double _long, double _robox, double _roboy, double _buttery, bool _living){
udid = _udid;
latitude = _lat;
longtitude = _long;
@@ -1,14 +1,14 @@
-#include "ofxArsUIButton.h"
+#include "ArsUIButton.h"
-class ofxArsUIRoboCam: public ofxArsUIButton
+class ArsUIRoboCam: public ArsUIButton
{
private:
string udid;
double xpos, ypos, buttery;
bool living;
public:
- ofxArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji, float angle);
+ ArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji, float angle);
void draw();
void update();
View
@@ -0,0 +1,41 @@
+//
+// ArsUISharedData.h
+// arsUI
+//
+// Created by Circuit Lab. Mac mini on 3/12/13.
+//
+//
+
+#ifndef arsUI_ArsUISharedData_h
+#define arsUI_ArsUISharedData_h
+
+#include "ofxXmlSettings.h"
+#include "ofxTuioClient.h"
+#include "ArsUITappedPoint.h"
+#include "ofxOsc.h"
+
+class ArsUISharedData
+{
+ public:
+ ofxXmlSettings config;
+ ofxTuioClient tuioClient;
+
+ vector<ArsUITappedPoint> tappedPoints;
+
+ string displayHost;
+ int displayPort;
+
+ string serverHost;
+ int serverPort;
+
+ int incomingPort;
+
+ int numRobots;
+ int camId1, camId2;
+
+ ofxOscSender oscSenderToDisplay;
+ ofxOscSender oscSenderToServer;
+ ofxOscReceiver oscReceiverFromServer;
+};
+
+#endif
@@ -6,10 +6,10 @@
//
//
-#include "ofxArsUITappedPoint.h"
+#include "ArsUITappedPoint.h"
#include "ofxEasingFunc.h"
-ofxArsUITappedPoint::ofxArsUITappedPoint(float _x, float _y, int tid)
+ArsUITappedPoint::ArsUITappedPoint(float _x, float _y, int tid)
{
x = _x;
y = _y;
@@ -20,7 +20,7 @@ ofxArsUITappedPoint::ofxArsUITappedPoint(float _x, float _y, int tid)
tapid = tid;
}
-void ofxArsUITappedPoint::update()
+void ArsUITappedPoint::update()
{
float v = ofxEasingFunc::Circ::easeOut((float)tcnt / cntmax);
//cout << " v " << v;
@@ -29,15 +29,15 @@ void ofxArsUITappedPoint::update()
tcnt++;
}
-void ofxArsUITappedPoint::draw()
+void ArsUITappedPoint::draw()
{
ofSetColor(51, 205, 255, alpha);
//cout<< " alpha " << alpha << " radius " << radius ;
ofCircle(x, y, radius);
ofSetColor(255, 255, 255, 255);
}
-bool ofxArsUITappedPoint::alive()
+bool ArsUITappedPoint::alive()
{
return tcnt <= cntmax ;
View
@@ -0,0 +1,17 @@
+#include "ofMain.h"
+
+
+class ArsUITappedPoint
+{
+ private:
+ float x, y, radius;
+ float alpha;
+ int tcnt,cntmax;
+ int tapid;
+
+ public:
+ ArsUITappedPoint(float _x, float _y, int tid);
+ void draw();
+ void update();
+ bool alive();
+};
Oops, something went wrong.

0 comments on commit e4380df

Please sign in to comment.