示例#1
0
// ============================================================================================
// follow action at presence column
// ============================================================================================
bool presenceWave(bool wave){
    bool updated = false;
    
    if(newPresence)
        newPresence = false;
    
    // wave still propogating vars
    static int startTime = 0;
    static bool reverb = false;
    

    if(neighborData[LEFT].strength > STRENGTH_THRESHOLD || neighborData[RIGHT].strength > STRENGTH_THRESHOLD){
        startTime = sec_counter;
        reverb = true;
    }
    else if(startTime + 5 < sec_counter){ // wave lasts 5 seconds after presense is no longer there
        reverb = false;
    }
    
    // my coloumn is active
    if (presenceDetected && !ignorePresence){
        // wiggle
        curAngle = wiggle();
        updated = true;
    }
    
    // presense is detected somewhere in the system
    else if(reverb){
        
        if(wave){
            if(lastStrengthDir == RIGHT) // direction it is moving not where it came from
            {
                curAngle = lastStrength * getDelNeighbor(RIGHT, 600 + offsetVar[0] * 100);
                updated = true;
            }
            else if(lastStrengthDir == LEFT)
            {
                curAngle = lastStrength * getDelNeighbor(LEFT, 600 + offsetVar[0] * 100);
                updated = true;
            }
        }
    }
    
    return updated;
}
示例#2
0
void driveStraight(float dist)
{
	float timeStart = get_time();
	Point prevPt = {currentPt.x, currentPt.y};

	motor_vel = speedLimit(KD*dist);
	straight(motor_vel);
	pause(500);
	update();
	if (distanceTo(prevPt) < 0.01)  //working too hard, what to do?
	{
		brake();
		wiggle(5);
		straight(70); //backward at speed 70
		pause(1000);
		pointTurn(0);
	}
}
示例#3
0
benDance() {
	wiggle();
}
ofVec3f testApp::animate(int pos1, int pos2)
{
    
    float smoothnessFactor=2400,timeInterval=10;
    
    if(animationCounter<=smoothnessFactor-timeInterval)
    { tweenvalue = (animationCounter) /smoothnessFactor;
        animationCounter+=timeInterval;
    }
    else {
        tweenvalue=0;
        animationMode=false;
        
        if(combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth())
            return ofVec3f(35*SpiralPoints[700*pos2]+ofVec3f(0,0,1.6*combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight())+wiggle());
        
        else return ofVec3f(35*SpiralPoints[700*pos2]+ofVec3f(0,0,1.05*combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth())+wiggle());
        
    }
    tweenedCameraPosition.x=ofLerp(35*SpiralPoints[700*pos1].x,35*SpiralPoints[700*pos2].x,tweenvalue);
    tweenedCameraPosition.y=ofLerp(35*SpiralPoints[700*pos1].y,35*SpiralPoints[700*pos2].y,tweenvalue);
    
    
    // Setting the Z value ..
    
    if(combinedImageObjects[numberofImages-pos1].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-pos1].theloadedimage.getWidth())
        position1_z=1.6*combinedImageObjects[numberofImages-pos1].theloadedimage.getHeight()+35*SpiralPoints[700*pos1].z;
    else position1_z=1.05*combinedImageObjects[numberofImages-pos1].theloadedimage.getWidth()+35*SpiralPoints[700*pos1].z;
    
    if(combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth())
        position2_z=1.6*combinedImageObjects[numberofImages-pos2].theloadedimage.getHeight()+35*SpiralPoints[700*pos2].z;
    else position2_z=1.05*combinedImageObjects[numberofImages-pos2].theloadedimage.getWidth()+35*SpiralPoints[700*pos2].z;
    
    
    tweenedCameraPosition.z=ofLerp(position1_z,position2_z,tweenvalue);
    
    return tweenedCameraPosition;
    
}
//--------------------------------------------------------------
void testApp::draw()
{
    
    // Only if the wii-mote accelerates a bit i.e the swing moves or if the user presses "Enter"

    if(startInstallation)
    {
        // Play the Movie first
        
        if(!startingMovieFinished)
        {
            startingMovie.draw(0, 0);
        }
        
        else
        {
#ifndef DEBUGMODE
            ofBackground(0, 0, 0);
            ofSetColor(255,255,255);
            
            // If startinganimation is active,have the startingCameraAnimation or the overshotCameraPosition
            if(isstartingAnimationActive)
            {
                if(!startoverShotCameraAnimation)
                    camera.setPosition(startAnimationCameraPosition());
                else camera.setPosition(adjustoverShotCameraPosition());
                
                timesinceLastTransition=ofGetElapsedTimeMillis();
                //animationMode=true;
            }
            
            else
            {
                if((ofGetElapsedTimeMillis()-timesinceLastTransition)>timeGap&&cameraindex!=0&&!animationMode)
                {
                 
                    cameraindex--;
                    
                    //        cout<<"The current camera index value is "<<imageData[cameraindex].y<<endl;
                    animationMode=true;
                    animationCounter=0;
                    timesinceLastTransition=ofGetElapsedTimeMillis();
                    
                }
                
                // 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.
                else if(cameraindex==0||BluementhalMp3.getPosition()>0.92)
                {
                    startingMovieFinished=false;
                    ending=true;
                    startingMovie.setSpeed(-1); // Reverse the video being played
                    startingMovie.play();
                    fadeAudio=true;
                    
                }
                
                if(animationMode)
                {
                    // Animate the camera from one index to another ..
                    if(combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth())
                        camera.setPosition(animate(cameraindex+1, cameraindex));
                    else camera.setPosition(animate(cameraindex+1, cameraindex));
                }
                
                else
                {
                    // 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.
                    
                    if(combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth())
                    {
                        camera.setPosition(35*SpiralPoints[700*cameraindex]+ofVec3f(0,0,1.6*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight())+wiggle());

                    }
                    else camera.setPosition(35*SpiralPoints[700*cameraindex]+ofVec3f(0,0,1.05*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth())+wiggle());
                    
                }
                
            }
            
#endif
            
            camera.begin();
            
            ofPushMatrix();
            ofRotateX(180);
            ofPopMatrix();
            drawImages();
                        
            camera.end();
            
        }
        
#ifdef USEWII
        
        // If acceleration is greater than a particular value ,Adjust the timegap or see if it is going backward or forward 
        
        if(accel-0.2>0.008&&accel!=0)
        {
            if(angular_velocity<=-0.03)
            {
                ofSetColor(255, 0, 0);
                
                if(State.compare("Front")==0)
                    isturnCompleted=true;
                
                State="Back";
                
            }
            
            else if(angular_velocity>=0.03)
            {
                
                ofSetColor(0,255, 0);
                // fonttodisplayWiimoteValues.drawString("Front", ofGetWidth()/2,ofGetHeight()/2+50);
                
                if(State.compare("Back")==0)
                    isturnCompleted=true;
                
                State="Front";
            }
            
#ifdef ADJUSTTIMEGAP
            
            if(angular_velocity<minAngularVelocity)
                minAngularVelocity=angular_velocity;
            if(angular_velocity>maxAngularVelocity)
                maxAngularVelocity=angular_velocity;
            
            if(accel<minAccel)
                minAccel=accel;
            if(accel>maxAccel&&accel*1000<400)
                maxAccel=accel;
            
            if(isturnCompleted)
            {
                
                // Adjust the time gap between 2 images.Depending upon the acceleration we adjust the timegap between 2 which 2 images are seen .
                
                maxAccel*=1000;
                if(maxAccel>204&&maxAccel<=214)
                    timeGap=9000;
                if(maxAccel>214&&maxAccel<=224)
                    timeGap=7500;
                if(maxAccel>224&&maxAccel<=234)
                    timeGap=6000;
                if(maxAccel>234&&maxAccel<=244)
                    timeGap=5000;
                if(maxAccel>244&&maxAccel<=254)
                    timeGap=4000;
                
                
                maxAccel=0;
                isturnCompleted=false;
            }
            //        fonttodisplayWiimoteValues.drawString(ofToString(timeGap), ofGetWidth()/2+200, ofGetHeight()/2+50);
            
            
#endif
            
        }
        
        ofSetColor(255, 255, 255);
        
        /* Use these to get the Acceleration and Velocity values from the Wii-mote*/
        
        //    fonttodisplayWiimoteValues.drawString("Acceleration "+ofToString(accel*1000), ofGetWidth()/2, ofGetHeight()/2+100);
        //    fonttodisplayWiimoteValues.drawString("Velocity "+ofToString(angular_velocity*1000), ofGetWidth()/2, ofGetHeight()/2+200);
        //   fonttodisplayWiimoteValues.drawString("Max Acceleration "+ofToString(maxAccel*1000), ofGetWidth()/2, ofGetHeight()/2+250);
        //    fonttodisplayWiimoteValues.drawString("Max Velocity "+ofToString(max*1000), ofGetWidth()/2, ofGetHeight()/2+350);
    
    //     cout<<"Acceleration "<<accel*1000   <<"\n Max Acceleration "<<maxAccel*1000<<"\n\n Min Acceleration "<<minAccel<<endl;
    //
    //    cout<<"\nAngular Velocity "<<angular_velocity<<"\n Max Velocity "<<max*1000<<"\n\n Min Velocity "<<minAngularVelocity<<endl;;
    
    
#endif
        
}
    else{
        
        startingMovie.draw(0, 0);
        
        ofSetColor(255, 255, 255);
        
        tempText="Start Swinging !";
        
        previewText.drawString(tempText, 500, startingMovie.getHeight()-25);
        
        
        
    }
}