rt300@0: // rt300@0: // globalForces.cpp rt300@0: // wablet rt300@0: // rt300@0: // Created by Robert Tubb on 18/07/2011. rt300@0: // Copyright 2011 __MyCompanyName__. All rights reserved. rt300@0: // rt300@0: rt300@0: #include "globalForces.h" rt300@0: rt300@0: rt300@0: //----------------------------------------------------------- rt300@0: GlobalForces::GlobalForces(): grav(0.0,0.0){ rt300@0: //construct rt300@0: gravityOn = true; rt300@0: rt300@0: speedLimit = 100.0; rt300@0: wallBounce = 0.5; rt300@0: rt300@0: pressureAmt = 0.0; rt300@0: gravityAmt = 0.2; rt300@0: touchStrength = 1.0; rt300@0: homingAmt = 0.0; rt300@0: avFilterAmt = 0.0; rt300@0: rt300@0: pressure = 0.0; rt300@14: volume = 6.0; rt300@0: rt300@0: maxForcePoints = 11; rt300@0: excitationType = POSITION; rt300@12: excitationShape = SINE; rt300@12: excitationStrength = 2; rt300@0: rt300@12: exciteShapeX = 2; rt300@12: exciteShapeY = 3; rt300@0: forceTouchPoints = new forceTouchPoint[maxForcePoints]; rt300@0: for(int i = 0; i< 11; i++){ rt300@0: forceTouchPoints[i].x = 0.0; rt300@0: forceTouchPoints[i].y = 0.0; rt300@0: forceTouchPoints[i].tid = -1; rt300@0: rt300@0: } rt300@0: rt300@0: rt300@0: } rt300@0: rt300@0: //----------------------------------------------------------- rt300@0: GlobalForces::~GlobalForces(){ rt300@0: //destruct rt300@0: rt300@0: } rt300@0: void GlobalForces::update(){ rt300@0: // gravity rt300@0: grav.setCoord(ofxAccelerometer.getForce().y * 0.015 * gravityAmt, ofxAccelerometer.getForce().x * 0.015 * gravityAmt); rt300@0: // time step rt300@0: delt = 1/ofGetFrameRate(); rt300@0: rt300@0: } rt300@0: //----------------------------------------------------------- rt300@0: // this is actually only called from dropletmesh.update rt300@0: void GlobalForces::setPressure(double aP){ rt300@0: rt300@0: pressure = pressureAmt*aP; rt300@0: } rt300@0: //----------------------------------------------------------- rt300@0: void GlobalForces::createForceTouchPoint(double ax,double ay, int touchId){ rt300@0: rt300@0: forceTouchPoints[touchId].x = ax; rt300@0: forceTouchPoints[touchId].y = ay; rt300@0: forceTouchPoints[touchId].tid = touchId; rt300@0: rt300@0: rt300@0: rt300@0: } rt300@0: //----------------------------------------------------------- rt300@0: void GlobalForces::moveForceTouchPoint(double ax,double ay, int touchId){ rt300@0: // rt300@0: for(int i = 0;i