-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCloudsVisualSystem.h
More file actions
executable file
·415 lines (324 loc) · 10.4 KB
/
CloudsVisualSystem.h
File metadata and controls
executable file
·415 lines (324 loc) · 10.4 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#pragma once
#include "ofMain.h"
//#include "ofxCameraSaveLoad.h"
#include "ofxTimeline.h"
#include "ofxUI.h"
#include "ofxTLCameraTrack.h"
//#include "CloudsRGBDCamera.h"
//tenuous
#include "ofxLight.h"
#include "ofxGenerative.h"
#ifdef OCULUS_RIFT
#include "ofxOculusRift.h"
#endif
/**
* The CLOUDS Visual System super class
* All visual systems will extend from this class
*
* It works pretty much the same as testApp, with the addition of a few
* methods for interacting with play time duration, on screen start and stop, and accessing CLOUDS global state
*/
class CloudsRGBDVideoPlayer;
enum ofxViewType
{
OFX_VIEW_TOP = 0,
OFX_VIEW_BOTTOM,
OFX_VIEW_FRONT,
OFX_VIEW_BACK,
OFX_VIEW_RIGHT,
OFX_VIEW_LEFT,
OFX_VIEW_3D
};
class CloudsVisualSystem {
public:
CloudsVisualSystem();
~CloudsVisualSystem();
enum RGBDTransitionType
{
TWO_DIMENSIONAL = 0,
FLY_THROUGH = 1,
WHIP_PAN = 2,
RGBD = 3
};
static string getVisualSystemDataPath(string systemName){
// building from src project file
string datapath;
if(ofDirectory("../../../CloudsLibrary/").exists()){
datapath = "../../../CloudsLibrary/src/VisualSystems/"+ systemName + "/bin/data/";
}
// stand alone full app
else if(ofDirectory("CloudsData/").exists()){
datapath = "CloudsData/VisualSystems/"+ systemName + "/";
}
else{
datapath = "../../../data/";
}
return datapath;
}
static ofFbo& getStaticRenderTarget(); //default
static void loadBackgroundShader();
static CloudsRGBDVideoPlayer& getRGBDVideoPlayer();
static void getBackgroundMesh(ofMesh& mesh, ofImage& image, float width, float height);
#ifdef OCULUS_RIFT
static ofxOculusRift& getOculusRift();
#endif
ofFbo& getSharedRenderTarget();
ofImage& getCursor();
//SUB CLASSES USE THESE METHODS:
virtual void selfSetup();
virtual void selfSetupGuis();
virtual void selfUpdate();
virtual void selfDrawBackground();
virtual void selfDrawDebug();
virtual void selfSceneTransformation();
virtual void selfDraw();
virtual void selfDrawOverlay();
virtual void selfPostDraw();
virtual void selfPresetLoaded(string presetPath);
virtual void selfExit();
virtual void selfBegin();
virtual void selfEnd();
virtual void selfKeyPressed(ofKeyEventArgs & args);
virtual void selfKeyReleased(ofKeyEventArgs & args);
virtual void selfMouseDragged(ofMouseEventArgs& data);
virtual void selfMouseMoved(ofMouseEventArgs& data);
virtual void selfMousePressed(ofMouseEventArgs& data);
virtual void selfMouseReleased(ofMouseEventArgs& data);
virtual void selfSetupGui();
virtual void selfGuiEvent(ofxUIEventArgs &e);
virtual void selfSetupSystemGui();
virtual void guiSystemEvent(ofxUIEventArgs &e);
virtual void selfSetupRenderGui();
virtual void guiRenderEvent(ofxUIEventArgs &e);
virtual void selfSetupCameraGui();
virtual void guiCameraEvent(ofxUIEventArgs &e);
virtual void selfSetupTimeline();
virtual void selfSetupTimelineGui();
virtual void selfTimelineGuiEvent(ofxUIEventArgs &e);
//END SUBCLASS METHODS
virtual string getSystemName();
void setupRGBDTransforms();
//Data Folder Path
string getVisualSystemDataPath();
ofxTimeline* getTimeline();
//APP CYCLE EVENTS
//pre allocate any assets that will cause freezes
virtual void setup();
//these events are registered only when running the simulation
virtual void update(ofEventArgs & args);
virtual void draw(ofEventArgs & args);
//application exit, clean up and don't crash
virtual void exit(ofEventArgs & args);
//INTERACTION EVENTS -- registered only
virtual void keyPressed(ofKeyEventArgs & args);
virtual void keyReleased(ofKeyEventArgs & args);
virtual void mouseDragged(ofMouseEventArgs & args);
virtual void mouseMoved(ofMouseEventArgs & args);
virtual void mousePressed(ofMouseEventArgs & args);
virtual void mouseReleased(ofMouseEventArgs & args);
//these two methods are called by the controller class,
//they register events and result in a calls to begin/end on the subclass
void playSystem();
void stopSystem();
bool isSetup();
// void setRenderer(CloudsRGBDVideoPlayer& newRenderer);
void setupSpeaker(string speakerFirstName,
string speakerLastName,
string quoteName);
void speakerEnded();
//how much time left to show this visual system?
//once seconds is set to zero the end() event will be called by the controller
float getSecondsRemaining();
void setSecondsRemaining(float seconds);
//this will always match what you offered in relevant keywords
void setCurrentKeyword(string theme);
string getCurrentKeyword();
//set before calling begin so the class can react to the topic
void setCurrentTopic(string keyword);
string getCurrentTopic();
//Drawing Helpers
void drawDebug();
void drawAxis(float size, float color);
void drawGrid(float x, float y, float w, float h, float color);
void billBoard(ofVec3f globalCamPosition, ofVec3f globelObjectPosition);
void drawTexturedQuad();
void drawNormalizedTexturedQuad();
void drawBackground();
void ofLayerGradient(const ofColor& start, const ofColor& end);
//Core Param Setup
void setupAppParams();
void setupDebugParams();
void setupCameraParams();
void setupLightingParams();
void setupMaterialParams();
void setupTimeLineParams();
//Core UI[S]
void setupCoreGuis();
void setupGui();
void guiEvent(ofxUIEventArgs &e);
void setupSystemGui();
void setupRenderGui();
void setupBackgroundGui();
void guiBackgroundEvent(ofxUIEventArgs &e);
void setupLightingGui();
void guiLightingEvent(ofxUIEventArgs &e);
void setupCameraGui();
void setupPresetGui();
void guiPresetEvent(ofxUIEventArgs &e);
void setupMaterial(string name, ofMaterial *m);
void guiMaterialEvent(ofxUIEventArgs &e);
void setupPointLight(string name);
void setupSpotLight(string name);
void setupBeamLight(string name);
void setupGenericLightProperties(ofxUISuperCanvas *g, ofxLight *l);
void guiLightEvent(ofxUIEventArgs &e);
void setupTimeline();
//override with caution, you still need to always call this when a bang occurs
virtual void timelineBangEvent(ofxTLBangEventArgs& args);
void setupTimelineGui();
void guiTimelineEvent(ofxUIEventArgs &e);
void setTimelineTrackCreation(bool state);
void setTimelineTrackDeletion(bool state);
void guiAllEvents(ofxUIEventArgs &e);
void updateTimelineUIParams();
void saveTimelineUIMappings(string path);
void loadTimelineUIMappings(string path);
//Lighting Helpers
void lightsBegin();
void lightsEnd();
//UI Helpers
vector<string> getPresets();
void loadGUIS();
void loadPresetGUISFromName(string presetName);
void loadPresetGUISFromPath(string presetPath);
void saveGUIS();
void savePresetGUIS(string presetName);
void showGUIS();
void hideGUIS();
void toggleGUIS();
void toggleGuiAndPosition(ofxUISuperCanvas *g);
void deleteGUIS();
void setCurrentCamera( ofCamera& cam );
void setCurrentCamera( ofCamera* swappedInCam );
virtual ofCamera& getCameraRef();
ofCamera* getCurrentCamera();
ofVec3f translatedHeadPosition;
float pointcloudScale;
float pointcloudOffsetZ;
CloudsRGBDCamera cloudsCamera;
//LB
ofVec3f getCameraPosition();
ofVec3f positionOffset;
RGBDTransitionType getTransitionType();
bool cursorIsOverGUI();
void setDrawToScreen( bool state );
bool getDrawToScreen();
float getCurrentAudioAmplitude();
protected:
//UI
ofxUISuperCanvas *gui;
ofxUISuperCanvas *sysGui;
ofxUISuperCanvas *rdrGui;
ofxUISuperCanvas *bgGui;
ofxUISuperCanvas *lgtGui;
ofxUISuperCanvas *camGui;
ofxUISuperCanvas *presetGui;
ofxUISuperCanvas *tlGui;
void stackGuiWindows();
void drawScene();
vector<ofxUISuperCanvas *> guis;
map<string, ofxUICanvas *> guimap;
//Background Props
float bgAspectRatio;
bool bBarGradient;
int gradientMode;
ofColor bgColor;
ofColor bgColor2;
float bgHue;
float bgSat;
float bgBri;
float bgHue2;
float bgSat2;
float bgBri2;
// ofx1DExtruder *bgHue;
// ofx1DExtruder *bgSat;
// ofx1DExtruder *bgBri;
// ofx1DExtruder *bgHue2;
// ofx1DExtruder *bgSat2;
// ofx1DExtruder *bgBri2;
ofxUISlider *hueSlider;
ofxUISlider *satSlider;
ofxUISlider *briSlider;
ofxUIRadio *presetRadio;
ofxUIRadio *transitionRadio;
//ANIMATORS
vector<ofx1DExtruder *> extruders;
//MATERIAL
ofMaterial *mat;
map<string, ofMaterial *> materials;
map<string, ofxUISuperCanvas *> materialGuis;
bool bIsSetup;
//LIGHTING
float *globalAmbientColor;
bool bSmoothLighting;
bool bEnableLights;
//LIGHTS
map<string, ofxLight *> lights;
map<string, ofxUISuperCanvas *> lightGuis;
//APP
bool bRenderSystem;
bool bUpdateSystem;
bool bDebug;
float debugGridSize;
bool bClearBackground;
bool bDrawToScreen;
bool bUseOculusRift;
//CAM
float camDistance;
float camFOV;
ofxViewType view;
ofCamera* currentCamera;
ofEasyCam cam;
ofx1DExtruder *xRot;
ofx1DExtruder *yRot;
ofx1DExtruder *zRot;
//TIMELINE
void resetTimeline();
void bindWidgetToTimeline(ofxUIWidget* widget);
void unBindWidgetFromTimeline(ofxUIWidget* widget);
ofxTimeline* timeline;
ofxTLCameraTrack* cameraTrack;
ofxTLFlags* introOutroTrack;
map<ofxTLBangs*, ofxUIButton*> tlButtonMap;
map<ofxUIToggle*, ofxTLSwitches*> tlToggleMap;
map<ofxUISlider*, ofxTLCurves*> tlSliderMap;
map<ofxUINumberDialer*, ofxTLCurves*> tlDialerMap;
bool bTimelineIsIndefinite;
float getIntroDuration();
float getOutroDuration();
float timelineDuration;
bool bUseCameraTrack;
bool bEnableTimeline;
bool bDeleteTimelineTrack;
bool bShowTimeline;
bool bEnableTimelineTrackCreation;
//background stuff
bool bMatchBackgrounds;
//these variables are set by the playback controller when displaying
//ways to interact with the pointcloud data
CloudsRGBDVideoPlayer* sharedRenderer;
//set to true if the pointcloud renderer has valid speaker
bool hasSpeaker;
bool confirmedDataPath;
string cachedDataPath;
//speaker and quote info, constantly updated
string speakerFirstName;
string speakerLastName;
string quoteName;
//keyword is the topic of conversation
string currentTopic;
//theme is the topic chosen
string currentKeyword;
bool isPlaying;
float secondsRemaining;
};