Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Configured the app to run real tracking with the projector
  • Loading branch information
wdlindmeier committed Oct 20, 2012
1 parent c598628 commit 58be77e
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 126 deletions.
2 changes: 1 addition & 1 deletion Cinder/LCTracker/include/Car.h
Expand Up @@ -23,7 +23,7 @@ class Car {
Car(const Vec2f &initialPosition, const Vec2f &initialDirection);
void setPositionAndDirection(const Vec2f &initialPosition, const Vec2f &initialDirection);
void draw();
void update(const Vec2f &posLaser, const float &relativeSpeed);
void update(const Vec2f &posLaser, const float &relativeSpeed, const Vec2f &windowSize);
const Vec2f getTrackerA(){ return _posTrackerA; };
const Vec2f getTrackerB(){ return _posTrackerB; };
const Vec2f getCenter(){ return _center; };
Expand Down
22 changes: 15 additions & 7 deletions Cinder/LCTracker/src/Car.cpp
Expand Up @@ -42,7 +42,7 @@ void Car::draw()

glLineWidth(5);

gl::color(1,1,1);
gl::color(0.2,0.2,0.2);

// Vec
gl::drawLine(_posTrackerA, _posTrackerB);
Expand All @@ -58,7 +58,6 @@ void Car::draw()
gl::color(0, 0, 1);
gl::drawSolidCircle(_posTrackerB, 10.0f);


}

Vec2f Car::normalBetweenTrackingPoints()
Expand All @@ -75,7 +74,9 @@ Vec2f Car::normalBetweenTrackingPoints()
return Vec2f(normX, normY);
}

void Car::update(const Vec2f &posLaser, const float &relativeSpeed)
void Car::update(const Vec2f &posLaser,
const float &relativeSpeed,
const Vec2f &windowSize)
{

// Whats the vector between the _center and the green laser?
Expand All @@ -101,17 +102,24 @@ void Car::update(const Vec2f &posLaser, const float &relativeSpeed)

Vec2f newA = RotatePointAroundCenter(_posTrackerA, _center, degrees);
Vec2f newB = RotatePointAroundCenter(_posTrackerB, _center, degrees);
_posTrackerA = newA;
_posTrackerB = newB;

// Then move forward a little

Vec2f newVec = _posTrackerA - _posTrackerB; //normalBetweenTrackingPoints();
Vec2f newVec = newA - newB; //normalBetweenTrackingPoints();
newVec.normalize();

float goForwardDist = (_center.distance(posLaser) - (_size*0.5)) * relativeSpeed;
Vec2f newCenter = _center + (newVec * goForwardDist);
setPositionAndDirection(newCenter, newVec);
if(Area(_size,_size,windowSize.x-(_size*2),windowSize.y-(_size*2)).contains(newCenter)){

/*
_posTrackerA = newA;
_posTrackerB = newB;
*/

// Don't let the car leave the bounds, otherwise we cant track it
setPositionAndDirection(newCenter, newVec);
}

}

0 comments on commit 58be77e

Please sign in to comment.