NostalgiaRoom docs
nostalgia.media.mit.edu
 All Classes Files Functions Variables Macros Groups Pages
testApp.cpp
Go to the documentation of this file.
1 #include "testApp.h"
2 
4 {
5  ofHideCursor();
6  ofBackground(0, 0, 0);
7 
10 
11  ofSetLogLevel(OF_LOG_VERBOSE);
12  ofSetFrameRate(200);
13 
14 #ifdef DEBUGMODE
15  camera.setDistance(200);
16  camera.setFarClip(1000000);
17 #else
18 
19  camera.setFov(40);
20 
22  camera.setFarClip(10000000);
24 
25  camera.setPosition(cameraStartPosition);
26  animationMode=false;
28 
30 
31  overshotCameraStartingPosition=ofVec3f(0,0,0);
36  startInstallation=false;
37 
38 #endif
39 
40  ofEnableAlphaBlending();
41  ofSetBackgroundAuto(true);
43 
44 #ifdef USEWII
45 
46  // For debug purposes
47  //cout << "listening for osc messages on port " << PORT << "\n";
48  receiver.setup( PORT );
49 
50  accel_x=accel_y=accel_z;
51 
52  Message="";
53  accel=0;
54 
55 #ifdef ADJUSTTIMEGAP
56  minAngularVelocity=10000;
57  maxAngularVelocity=(-1000);
58  minAccel=1000;maxAccel=-1000;
59 #endif
60 
61  State="";
62  fonttodisplayWiimoteValues.loadFont("Inconsolata.otf", 20);
63 
64 #endif
65 
66  BluementhalMp3.loadSound("Blumenthal.mp3");
67  BluementhalMp3.setVolume(1.0f);
68 
69  timeGap=6000; // This is the default timeGap .Can be easily changed.
70 
71  ofSetFullscreen(true);
72  currentVolume=1;
73  fadeAudio=false;
74 
76  startingMovie.loadMovie("Intro_new.mov", OF_QTKIT_DECODE_TEXTURE_ONLY);
77  startingMovie.setLoopState(OF_LOOP_NONE);
78 
79  cout<<startingMovie.getDuration()<<endl;
80  cout<<startingMovie.getWidth()<<" "<<startingMovie.getHeight();
81 
82  previewText.loadFont("asyouwish.ttf",42);
83  ending=false;
84 
85 }
86 
87 //--------------------------------------------------------------
89 
90  // Update the frame
91  startingMovie.update();
92 
93  if(startingMovie.getIsMovieDone())
95 
96  if(startingMovie.getCurrentFrame()==0&&ending)
97  {cout<<"ending"<<endl;
98  ofExit();
99  }
100  ofSoundUpdate();
101 
102 #ifdef USEWII
103 
104  // Check if there are any pending messages to be received from OSCulator
105 
106  while( receiver.hasWaitingMessages())
107  {
108  if(windowWidth == 0 || windowHeight == 0){
109  windowWidth = ofGetWidth();
110  windowHeight = ofGetHeight();
111  }
112 
113  // Get the next message
114  ofxOscMessage m;
115  float x,y;
116  receiver.getNextMessage( &m );
117 
118  // For Debugging Purposes
119  // cout<<m.getArgAsFloat( 0 )<<endl;
120 
121  if ( m.getAddress() == "/wii/2/ir/0" )
122  {
123  x = m.getArgAsFloat( 0 );
124 
125  wiiX = x * windowWidth;
126  cout << "x: " << wiiX << " y: " << wiiY << "\n";
127  }
128  else if ( m.getAddress() == "/wii/2/ir/1" )
129  {
130  y = 1 - m.getArgAsFloat( 0 );
131  wiiY = y * windowHeight;
132  cout << "x: " << wiiX << " y: " << wiiY << "\n";
133  }
134  else if (m.getAddress() == "/wii/1/accel/pry/1") {
135  roll = m.getArgAsFloat(0);
136 
137  } else if (m.getAddress() == "/wii/1/accel/pry/2") {
138  yaw = m.getArgAsFloat(0);
139  }
140  else if (m.getAddress() == "/wii/1/accel/pry/0") {
141  pitch = m.getArgAsFloat(0);
142 
143  } else if (m.getAddress() == "/wii/1/accel/pry/3") {
144  accel = m.getArgAsFloat(0);
145  }
146 
147  else if(m.getAddress()=="/wii/1/accel/xyz/0")
148  {
149  accel_x=m.getArgAsFloat(0);
150  }
151 
152  else if(m.getAddress()=="/wii/1/accel/xyz/1")
153  {
154  accel_y=m.getArgAsFloat(0);
155  }
156 
157  else if(m.getAddress()=="/wii/1/accel/xyz/2")
158  {
159  accel_z=m.getArgAsFloat(0);
160  }
161 
162  else if(m.getAddress()=="/wii/1/motion/velo/0")
163  angular_velocity=m.getArgAsFloat(0);
164 
165  else
166  {
167 #ifdef DEBUG
168  cout << "unrecognized message: " << m.getAddress() << "\n";
169 #endif
170  }
171  }
172 
173  if(abs(angular_velocity*1000)<400)
174  prevAngVel=angular_velocity;
175 
176  if(abs(accel*1000)-200>2&&!startInstallation)
177  {
178  startInstallation=true;
179  BluementhalMp3.play();
180  startingMovie.play();
181  }
182  cout<<"Acceleration :"<<accel<<endl;
183 #endif
184 
185 #ifndef USEWII
187  {
188  //BluementhalMp3.play();
189  startingMovie.play();
190 }
191 #endif
192 
193 
194  if(fadeAudio)
195  currentVolume-=0.001;
196 
197  BluementhalMp3.setVolume(currentVolume);
198 }
199 
200 //--------------------------------------------------------------
202 {
203 
204  // Only if the wii-mote accelerates a bit i.e the swing moves or if the user presses "Enter"
205 
207  {
208  // Play the Movie first
209 
211  {
212  startingMovie.draw(0, 0);
213  }
214 
215  else
216  {
217 #ifndef DEBUGMODE
218  ofBackground(0, 0, 0);
219  ofSetColor(255,255,255);
220 
221  // If startinganimation is active,have the startingCameraAnimation or the overshotCameraPosition
223  {
225  camera.setPosition(startAnimationCameraPosition());
226  else camera.setPosition(adjustoverShotCameraPosition());
227 
228  timesinceLastTransition=ofGetElapsedTimeMillis();
229  //animationMode=true;
230  }
231 
232  else
233  {
234  if((ofGetElapsedTimeMillis()-timesinceLastTransition)>timeGap&&cameraindex!=0&&!animationMode)
235  {
236 
237  cameraindex--;
238 
239  // cout<<"The current camera index value is "<<imageData[cameraindex].y<<endl;
240  animationMode=true;
242  timesinceLastTransition=ofGetElapsedTimeMillis();
243 
244  }
245 
246  // If we are at the last image,or if the song is almost towards the end . End the experience by playing the startingMovie in reverse.
247  else if(cameraindex==0||BluementhalMp3.getPosition()>0.92)
248  {
249  startingMovieFinished=false;
250  ending=true;
251  startingMovie.setSpeed(-1); // Reverse the video being played
252  startingMovie.play();
253  fadeAudio=true;
254 
255  }
256 
257  if(animationMode)
258  {
259  // Animate the camera from one index to another ..
260  if(combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth())
261  camera.setPosition(animate(cameraindex+1, cameraindex));
262  else camera.setPosition(animate(cameraindex+1, cameraindex));
263  }
264 
265  else
266  {
267  // Depending on whether the image is more wide or tall,we set the camera's position to be at a fixed position from the image and also wiggle the position of the camera.
268 
269  if(combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth())
270  {
271  camera.setPosition(35*SpiralPoints[700*cameraindex]+ofVec3f(0,0,1.6*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight())+wiggle());
272 
273  }
274  else camera.setPosition(35*SpiralPoints[700*cameraindex]+ofVec3f(0,0,1.05*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth())+wiggle());
275 
276  }
277 
278  }
279 
280 #endif
281 
282  camera.begin();
283 
284  ofPushMatrix();
285  ofRotateX(180);
286  ofPopMatrix();
287  drawImages();
288 
289  camera.end();
290 
291  }
292 
293 #ifdef USEWII
294 
295  // If acceleration is greater than a particular value ,Adjust the timegap or see if it is going backward or forward
296 
297  if(accel-0.2>0.008&&accel!=0)
298  {
299  if(angular_velocity<=-0.03)
300  {
301  ofSetColor(255, 0, 0);
302 
303  if(State.compare("Front")==0)
304  isturnCompleted=true;
305 
306  State="Back";
307 
308  }
309 
310  else if(angular_velocity>=0.03)
311  {
312 
313  ofSetColor(0,255, 0);
314  // fonttodisplayWiimoteValues.drawString("Front", ofGetWidth()/2,ofGetHeight()/2+50);
315 
316  if(State.compare("Back")==0)
317  isturnCompleted=true;
318 
319  State="Front";
320  }
321 
322 #ifdef ADJUSTTIMEGAP
323 
324  if(angular_velocity<minAngularVelocity)
325  minAngularVelocity=angular_velocity;
326  if(angular_velocity>maxAngularVelocity)
327  maxAngularVelocity=angular_velocity;
328 
329  if(accel<minAccel)
330  minAccel=accel;
331  if(accel>maxAccel&&accel*1000<400)
332  maxAccel=accel;
333 
334  if(isturnCompleted)
335  {
336 
337  // Adjust the time gap between 2 images.Depending upon the acceleration we adjust the timegap between 2 which 2 images are seen .
338 
339  maxAccel*=1000;
340  if(maxAccel>204&&maxAccel<=214)
341  timeGap=9000;
342  if(maxAccel>214&&maxAccel<=224)
343  timeGap=7500;
344  if(maxAccel>224&&maxAccel<=234)
345  timeGap=6000;
346  if(maxAccel>234&&maxAccel<=244)
347  timeGap=5000;
348  if(maxAccel>244&&maxAccel<=254)
349  timeGap=4000;
350 
351 
352  maxAccel=0;
353  isturnCompleted=false;
354  }
355  // fonttodisplayWiimoteValues.drawString(ofToString(timeGap), ofGetWidth()/2+200, ofGetHeight()/2+50);
356 
357 
358 #endif
359 
360  }
361 
362  ofSetColor(255, 255, 255);
363 
364  /* Use these to get the Acceleration and Velocity values from the Wii-mote*/
365 
366  // fonttodisplayWiimoteValues.drawString("Acceleration "+ofToString(accel*1000), ofGetWidth()/2, ofGetHeight()/2+100);
367  // fonttodisplayWiimoteValues.drawString("Velocity "+ofToString(angular_velocity*1000), ofGetWidth()/2, ofGetHeight()/2+200);
368  // fonttodisplayWiimoteValues.drawString("Max Acceleration "+ofToString(maxAccel*1000), ofGetWidth()/2, ofGetHeight()/2+250);
369  // fonttodisplayWiimoteValues.drawString("Max Velocity "+ofToString(max*1000), ofGetWidth()/2, ofGetHeight()/2+350);
370 
371  // cout<<"Acceleration "<<accel*1000 <<"\n Max Acceleration "<<maxAccel*1000<<"\n\n Min Acceleration "<<minAccel<<endl;
372  //
373  // cout<<"\nAngular Velocity "<<angular_velocity<<"\n Max Velocity "<<max*1000<<"\n\n Min Velocity "<<minAngularVelocity<<endl;;
374 
375 
376 #endif
377 
378 }
379  else{
380 
381  startingMovie.draw(0, 0);
382 
383  ofSetColor(255, 255, 255);
384 
385  tempText="Start Swinging !";
386 
387  previewText.drawString(tempText, 500, startingMovie.getHeight()-25);
388 
389 
390 
391  }
392 }
393 
394 //--------------------------------------------------------------
395 void testApp::keyPressed(int key){
396 
397  if(key=='f'||key=='F')
398  {
399  ofToggleFullscreen();
400  }
401 
402 #ifndef DEBUGMODE
403 
404  else if(key==OF_KEY_UP&&cameraindex!=numberofImages&&!animationMode)
405  {
406  cameraindex++;
407  animationMode=true;
408 
409  }
410 
412  {
413  cameraindex--;
414  // cout<<"The current camera index value is "<<imageData[cameraindex].y<<endl;
415  animationMode=true;
417 
418  }
419  else if(key==OF_KEY_RETURN&&!startInstallation)
420  {
421  startInstallation=true;
422  BluementhalMp3.play();
423  startingMovie.play();
424  }
425 
427 #endif
428 
429 }
430 
431 //--------------------------------------------------------------
432 void testApp::keyReleased(int key){
433 
434 }
435 
436 //--------------------------------------------------------------
437 void testApp::mouseMoved(int x, int y){
438 
439 }
440 
441 //--------------------------------------------------------------
442 void testApp::mouseDragged(int x, int y, int button){
443 
444 }
445 
446 //--------------------------------------------------------------
447 void testApp::mousePressed(int x, int y, int button){
448 
449 }
450 
451 //--------------------------------------------------------------
452 void testApp::mouseReleased(int x, int y, int button){
453 
454 }
455 
456 //--------------------------------------------------------------
457 void testApp::windowResized(int w, int h){
458 
459 }
460 
461 //--------------------------------------------------------------
462 void testApp::gotMessage(ofMessage msg){
463 
464 }
465 
466 //--------------------------------------------------------------
467 void testApp::dragEvent(ofDragInfo dragInfo){
468 
469 }
470 
472 {
473  int spreadDistance=30;
474 
475 
476  /* Conical Concentric Circles */
477 
478  // for(int r=0;r<200;r+=spreadDistance)
479  // {
480  // for(float angle=0;angle<=360;angle+=4)
481  // SpiralPoints.push_back(ofVec3f(r*cos(ofDegToRad(angle)),r*sin(ofDegToRad(angle)),r));
482  // }
483 
484  // Generating a Cylindrical Helix Structure ,equation adapted from http://www.mathematische-basteleien.de/spiral.htm .Few Tweaks have been made to get the right structure
485 
486 
487  float height=10000,radius=200,ang_freq=3.2;
488 
489 
490  for(float angle=0;angle<=3600;angle+=0.01)
491  {
492 
493  float angle2=angle;
494 
495  SpiralPoints.push_back(ofVec3f(((height-angle2)/height)*radius*cos(ofDegToRad(ang_freq*angle2)),((height-angle2)/height)*radius*sin(ofDegToRad(ang_freq*angle2)),6*angle2));
496 
497  }
498 
499 #ifndef DEBUGMODE
502 #endif
503 
504 }
505 
507 {
508 
509  std::multimap<int,int>::iterator it;
510  int imageIterator=0;
511 
512 
513  for(int i=numberofImages-1;i>=0;i--) // Draw images in reverse order ....
514  {
515 
516  ofPushMatrix();
517 
518  ofTranslate(35*SpiralPoints[700*(combinedImageObjects.size()-1-i)].x,35*SpiralPoints[700*(combinedImageObjects.size()-1-i)].y,35*SpiralPoints[700*(combinedImageObjects.size()-1-i)].z); // 35 gives good results .You can use a higher number for more spread ,but you have to change this number throughout this file.
519 
520  combinedImageObjects[i].theloadedimage.draw(-combinedImageObjects[i].theloadedimage.getWidth()/2,-combinedImageObjects[i].theloadedimage.getHeight()/2);
521 
522  ofPopMatrix();
523 
524  }
525 }
526 
527 #ifndef DEBUGMODE
528 
529 // This function will animate the camera from one point in the spiral to another point
530 
531 ofVec3f testApp::animate(int pos1, int pos2)
532 {
533 
534  float smoothnessFactor=2400,timeInterval=10;
535 
536  if(animationCounter<=smoothnessFactor-timeInterval)
537  { tweenvalue = (animationCounter) /smoothnessFactor;
538  animationCounter+=timeInterval;
539  }
540  else {
541  tweenvalue=0;
542  animationMode=false;
543 
544  if(combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth())
545  return ofVec3f(35*SpiralPoints[700*pos2]+ofVec3f(0,0,1.6*combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight())+wiggle());
546 
547  else return ofVec3f(35*SpiralPoints[700*pos2]+ofVec3f(0,0,1.05*combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth())+wiggle());
548 
549  }
550  tweenedCameraPosition.x=ofLerp(35*SpiralPoints[700*pos1].x,35*SpiralPoints[700*pos2].x,tweenvalue);
551  tweenedCameraPosition.y=ofLerp(35*SpiralPoints[700*pos1].y,35*SpiralPoints[700*pos2].y,tweenvalue);
552 
553 
554  // Setting the Z value ..
555 
556  if(combinedImageObjects[numberofImages-pos1].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-pos1].theloadedimage.getWidth())
557  position1_z=1.6*combinedImageObjects[numberofImages-pos1].theloadedimage.getHeight()+35*SpiralPoints[700*pos1].z;
558  else position1_z=1.05*combinedImageObjects[numberofImages-pos1].theloadedimage.getWidth()+35*SpiralPoints[700*pos1].z;
559 
560  if(combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth())
561  position2_z=1.6*combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight()+35*SpiralPoints[700*pos2].z;
562  else position2_z=1.05*combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth()+35*SpiralPoints[700*pos2].z;
563 
564 
566 
567  return tweenedCameraPosition;
568 
569 }
570 
572 {
573 
574  float smoothnessFactor=35*SpiralPoints[700*cameraindex].z +1.6*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight();
575 
576  float timeInterval=smoothnessFactor/1500;
577 
578  if(startAnimationCounter<=smoothnessFactor-timeInterval)
579  {
580  tweenvalue = (startAnimationCounter) /smoothnessFactor;
581 
582  if(tweenvalue<0.98)
583  startAnimationCounter+=timeInterval;
584  else startAnimationCounter+=(timeInterval);
585 
587  }
588 
589  //else isstartingAnimationActive=false;
591  }
592 
593  tweenedCameraPosition.x=ofLerp(0, 0 , tweenvalue);
594  tweenedCameraPosition.y=ofLerp(0, 0, tweenvalue);
595  tweenedCameraPosition.z=ofLerp(0, 35*SpiralPoints[700*cameraindex].z +21.6*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight(), tweenvalue);
596 
597  return tweenedCameraPosition;
598 
599 }
600 
601 #endif
602 
603 testApp::testApp(long long int id)
604 {
605  userid=id;
606  cout<<"\n User ID:"<<id<<endl;
607 }
608 
610 {
611 
612  // wigglePositions.push_back(ofVec3f(0,0,0));
613 
614  wigglePositions.push_back(ofVec3f(1,1,0));
615  wigglePositions.push_back(ofVec3f(1,1,0));
616  wigglePositions.push_back(ofVec3f(0,1,0));
617  wigglePositions.push_back(ofVec3f(0,1,0));
618  wigglePositions.push_back(ofVec3f(1,0,0));
619  wigglePositions.push_back(ofVec3f(1,0,0));
620 
621 }
622 
624 {
625 
626  int maxValue=20; // Change this for adjusting the maximum Value of Wiggling .
627 
628  // For every even value of currentwiggleindex,we move to the right, or down or bottom right. and move in left,up or top left for every odd index .
629  // To change the wiggle motion Just change the wigglePositions points.
630 
631  if(currentwiggleindex%2==0)
632  {
633 
634  if(wiggleAnimationCounter<=maxValue)
635  wiggleAnimationCounter+=0.05; // Increase the wiggleAnimationCounter till it reaches 20
636 
637  else { // Once it reaches 20,advance the wiggleindex,The Image will wiggle to another direction
640  wiggleAnimationCounter=maxValue;
641  }
642  }
643 
644  else
645  {
646 
648  wiggleAnimationCounter-=0.05 ;
649 
650  else {
654  }
655  }
656 
657 
661 
662  return currentwigglePosition;
663 }
664 
666 {
667  ofSetColor(255, 255, 255);
668 
669  for(int i=0;i<StarPositions.size();i++)
670  ofSphere(StarPositions[i], 1);
671 
672 }
673 
675 {
676  for(int i=0;i<10000;i++)
677  StarPositions.push_back(ofVec3f(ofRandom(100000), ofRandom(10000),ofRandom(10000)));
678 
679 }
680 
681 
683 {
684  // Change this to your Directory Path
685  string untaggedDirpath=PathToImageFolder+ofToString(userid)+"/untaggedImages/";
686 
687  ofDirectory untaggeddir(untaggedDirpath);
688  untaggeddir.allowExt("png");
689  untaggeddir.allowExt("jpg");
690  untaggeddir.allowExt("gif");
691 
692  if(untaggeddir.listDir()==0)
693  {
694 
695  // Debug Statements
696  cout<<"Nothing"; ofExit();
697  }
698 
699  cout<<untaggeddir.listDir();
700  cout<<"NUMBER OF FILES"<<untaggeddir.numFiles()<<endl;
701 
702  ofImage TempImage;
703 
704  int imageCounter=0;
705 
706  string xmlpath=PathToImageFolder+ofToString(userid)+"/imagedata.xml";
707 
708  // Just a temporary ImageData object
709  ImageData imagedataObject;
710 
711  // Parse the XML,Load all the UntaggedImages into the combinedImageObjects data structure .These images will be already sorted in descending order of their scores .
712 
713  if(pictures_XML.loadFile(xmlpath))
714  {
715 
716  pictures_XML.pushTag("xml");
717  pictures_XML.pushTag("ImageList");
718 
719  if(pictures_XML.pushTag("Untagged"))
720  {
721 
722  for (int j=0;j<pictures_XML.getNumTags("Image");j++)
723  {
724  pictures_XML.pushTag("Image",j);
725 
726  imagedataObject.imageNumber=imageCounter;
727  imagedataObject.imageScore=pictures_XML.getValue("Score",0.0);
728  imagedataObject.albumnumber=pictures_XML.getValue("AlbumNumber",0);
729  imagedataObject.theloadedimage.loadImage(ofToString(untaggedDirpath+ofToString(j)+".jpg"));
730 
731  imagedataObject.theloadedimage.resize(imagedataObject.theloadedimage.getWidth(), imagedataObject.theloadedimage.getHeight());
732 
733 #ifndef BLUR
734 
735  imagedataObject.theloadedimage.mirror(true,false);
736 #endif
737 
738  combinedImageObjects.push_back(imagedataObject);
739 
740  pictures_XML.popTag();
741 
742  imageCounter++;
743 
744  }
745  pictures_XML.popTag();
746  }
747  }
748 
749  // Debug statement
750 
751  cout<<combinedImageObjects.size()<<"\t this was the size of untaggedIamgeobjects";
752 
753  ImageVector.clear();
754  imageCounter=0;
755 
756 
757 
758 
759  string taggedDirpath=PathToImageFolder+ofToString(userid)+"/taggedImages/";
760  ofDirectory taggeddir(taggedDirpath);
761 
762  taggeddir.allowExt("png");
763  taggeddir.allowExt("jpg");
764  taggeddir.allowExt("gif");
765 
766  // Now all the Tagged images need to be linked and added to the data structure .
767 
768  if(pictures_XML.pushTag("Tagged"))
769 
770  {
771  for (int j=0;j<pictures_XML.getNumTags("Image");j++)
772  {
773  pictures_XML.pushTag("Image",j);
774 
775  imagedataObject.imageNumber=imageCounter;
776  imagedataObject.imageScore=pictures_XML.getValue("Score",0.0);
777  imagedataObject.albumnumber=pictures_XML.getValue("AlbumNumber",0);
778  imagedataObject.theloadedimage.loadImage(ofToString(taggedDirpath+ofToString(j)+".jpg"));
779 #ifndef BLUR
780  imagedataObject.theloadedimage.mirror(true,false);
781 #endif
782 
783  taggedImageObjects.push_back(imagedataObject);
784 
785  pictures_XML.popTag();
786 
787  imageCounter++;
788 
789  }
790  }
791 
792 
793  cout<<taggedImageObjects.size()<<"\t this was the size of taggedImgeobjects";
794 
795  // Now combine the untagged and Tagged in the correct ratio ..
796 
797  int ratio= 3; // This ratio defines how many images should be taken from the untagged Images compared to the TaggedImages .For every 2 untaggedimages,1 taggedimage is displayed.This usually strikes a nice balance based on our experience with 50 + users.However,it could be modified .
798 
799  int untaggedImageCount=0,taggedImageCount=0,i;
800  int num_untaggedImages=combinedImageObjects.size(),num_taggedImages=taggedImageObjects.size();
801  int taggedImgCount=0;
802 
803  cout<<"Combining and shuffling the tagged and untagged images";
804 
805  // The below loop shuffles the images so that the structure based on the defined ratio
806 
807  for(int i=0;i<combinedImageObjects.size();i++)
808  {
809  if(i%ratio==0&&i!=0&&taggedImgCount<num_taggedImages)
810  combinedImageObjects.insert(combinedImageObjects.begin()+i,taggedImageObjects[taggedImgCount++]);
811 
812  }
813 
814  // Parse the data structure again,to make sure that no 2 images having the same albumnumber are next to each other.This is done so that different images are shown.This can be experimented with.Images from alternate albums have worked for us.
815 
816  int j,tempVal;
817 
818  for(int i=0;i<combinedImageObjects.size()-1;i++)
819  {
820  j=i+1;
821  cout<<i;
822 
823  if(combinedImageObjects[i].albumnumber==combinedImageObjects[j].albumnumber)
824  {
825  cout<<"doing this when i= \t "<<combinedImageObjects[i].albumnumber<<"\t";
826 
827  while(j<combinedImageObjects.size()-1&&(combinedImageObjects[i].albumnumber==combinedImageObjects[j].albumnumber) && (j-i)<8) // This is because j is
828  {
829  j++;
830  }
831  cout<<" and then j= \t"<<combinedImageObjects[j].albumnumber<<endl;
832 
833  std::swap(combinedImageObjects[i+1], combinedImageObjects[j]);
834 
835  }
836  }
837 
838  cout<<"Now checking the album numbers ,Size of the array = \t"<<combinedImageObjects.size()<<endl;
839 
840  for(int i=0;i<combinedImageObjects.size();i++)
841  cout<<"Album number:"<<combinedImageObjects[i].albumnumber<<"\t Score"<<combinedImageObjects[i].imageScore<<endl;
842 
843 }
844 
845 /* This function will bring the cameraposition to the starting image once it has 'overshot' while zooming out of the spiral */
846 
848 {
849 
850  float smoothnessFactor=35*SpiralPoints[700*cameraindex].z +1.6*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight();
851 
852  float timeInterval=smoothnessFactor/500;
853 
854  // cout<<"smoothness factor\n"<<smoothnessFactor;
855 
856  if(startAnimationCounter<=smoothnessFactor-timeInterval)
857  {
858 
859  cout<<"\nCamera Position"<< tweenedCameraPosition.z;
860 
861  tweenvalue = (startAnimationCounter) /smoothnessFactor;
862 
863  if(tweenvalue<0.98)
864  startAnimationCounter+=timeInterval;
865  else startAnimationCounter+=(timeInterval);
866 
867  }
868 
870 
874 
875  return tweenedCameraPosition;
876 
877 }