summaryrefslogtreecommitdiff
path: root/src/testApp.cpp
blob: 6091759ebfb538c837a11fee2322ab82cd30bc5b (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#include "testApp.h"

/*
openBTS visualisation

ALL units relative to screen size in H or W

viewpoint dynamic? focus on 'interesting' events?

FRAMING

REPRESENTATION OF TIME

LABELLING & INFO

handset class
represents a handset

how to deal with time/ range being limited
-exponential
-choose VP carefully- perspective
-just decide the longest time that it will be active

scalability
-amount of text on screen

icons
-worthwhile?

call/sms -pointer from caller to callee

position update

function to interpolate position

*/

void testApp::setup(){

    printf("setup: %ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight());

    int windowMode = ofGetWindowMode();
    if(windowMode == OF_FULLSCREEN){
        this->windowWidth = ofGetScreenWidth();
        this->windowHeight = ofGetScreenHeight();
    }
    else if(windowMode == OF_WINDOW){
        this->windowWidth = ofGetWidth();
        this->windowHeight = ofGetHeight();
    }

    //Q Why is it that if you put a camera at (0,0,-100) looking at (0,0,0) and an object at (0,0,0) the camera isn't pointing at the object?
    //A Because ortho is different
	/*
	camera.enableOrtho();
	camera.setPosition(-windowWidth/2,-windowHeight*4.1f,windowWidth);
	//camera.lookAt(ofVec3f(-windowWidth/2,-windowHeight,0),ofVec3f(0, 1, 0));
	camera.rotate(70,1,0,0);
	camera.cacheMatrices(); //stop error messages
    */

	ofSetFrameRate(60);

	ofSetCircleResolution(windowWidth);
	ofEnableSmoothing();

	camera.setPosition(0,windowHeight*10,windowHeight);
	camera.lookAt(ofVec3f(0,0,-windowHeight*.5),ofVec3f(0, 0, 1));
	camera.setFov(6.5);
	camera.cacheMatrices();

	numLines=20;

	lines = new ofPoint[numLines];
	imeis = new string[numLines];
	for (int i=0;i<numLines;i++) {
		float a=ofRandom(TWO_PI);
		float r=ofRandom(windowWidth/2);
		float l=ofRandom(windowHeight);
		lines[i]=ofPoint(a,r,-l); //polar coords
		for (int j=0;j<15;j++) {
			imeis[i]+=(char)(ofRandom(10)+48);
		}
	}


	//bgimg.allocate(256,256,OF_IMAGE_COLOR);
	//
	/*
	cols=new ofColor[4];
	cols[0]=ofColor(80,80,80);
	cols[1]=ofColor(80,80,80);
	cols[2]=ofColor(0,0,0);
	cols[3]=ofColor(0,0,0);
    float fi,fj,ifi,ifj;
    float si=1.0f/bgimg.width;
    float sj=1.0f/bgimg.height;
	for (int i=0,fi=0.0f,ifi=1.0f;i<bgimg.width;i++,fi+=si,ifi-=si){
        for (int j=0,fj=0.0f,ifj=1.0f;j<bgimg.width;j++,fj+=sj,ifj-=sj){
            bgimg.getPixels()[(j*bgimg.width+i)*3]=(unsigned char)((ifj*((ifi*cols[0].r)+(fi*cols[1].r)))+(fj*((ifi*cols[2].r)+(fi*cols[3].r))));
            bgimg.getPixels()[(j*bgimg.width+i)*3+1]=(unsigned char)((ifj*((ifi*cols[0].g)+(fi*cols[1].g)))+(fj*((ifi*cols[2].g)+(fi*cols[3].g))));
            bgimg.getPixels()[(j*bgimg.width+i)*3+2]=(unsigned char)((ifj*((ifi*cols[0].b)+(fi*cols[1].b)))+(fj*((ifi*cols[2].b)+(fi*cols[3].b))));
                    }
	}

    */
    bgimg.loadImage("TextureTrapdoor.jpg");
    bgimg.setUseTexture(true);
    bgimg.update();


}


//--------------------------------------------------------------
void testApp::update(){


}

//--------------------------------------------------------------
void testApp::draw(){

	glDisable(GL_LIGHTING);
	bgimg.draw(0,0,256,256); //windowWidth,windowHeight);

	camera.begin();

	//ofSphere(0,0,0,10);

	glDisable(GL_DEPTH_TEST);
	glDisable(GL_BLEND);

	ofPushMatrix();
	ofRotate(ofGetElapsedTimef(),0,0,1);

	ofNoFill();

	float rt=((ofGetElapsedTimef()*.25f)-floor(ofGetElapsedTimef()*.25f));
	for (float f=rt*(windowWidth/10);f<windowWidth*0.9;f+=windowWidth/10) {
		float rf=sin((f/(windowWidth*0.9))*TWO_PI);
		ofSetColor(0x7f*rf,0x7f*rf,0xff*rf);
		ofCircle(0,0,0,f);
	}


	for (int i=0;i<numLines;i++) {
		float rf=sin((lines[i].y/(windowWidth*0.9))*TWO_PI);
		ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
		ofLine(cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,0,cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,lines[i].z);
	}

	ofPopMatrix();
	camera.end();

	for (int i=0;i<numLines;i++) {
		float rf=sin((lines[i].y/(windowWidth*0.9))*TWO_PI);
		ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
		ofVec3f p=camera.worldToScreen(ofVec3f(cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,lines[i].z).rotated(ofGetElapsedTimef(),ofVec3f(0,0,1)),ofGetCurrentViewport());
		ofDrawBitmapString(imeis[i],p.x-20,p.y,p.z);
	}

	ofSetHexColor(0xffffff);
	char reportStr[1024];
	sprintf(reportStr, "fps: %f", ofGetFrameRate());
	ofDrawBitmapString(reportStr, 10, windowHeight-10);
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
	switch (key){
		case ' ':
			break;
	}
}

//--------------------------------------------------------------
void testApp::keyReleased(int key){

}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void testApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){

}