summaryrefslogtreecommitdiff
path: root/gaunt01/src/player.cpp
blob: efcdd0a8ca8eb05ed1f279633b6b5cbe1b2c2311 (plain)
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
#include "player.h"

player::player()
{
    isCaught=false;
    active=true;
}

player::~player()
{
    //dtor
}

void player::setWorldPosition(ofVec3f _pos) {
	worldPosition.set(_pos);
}
void player::setScreenPosition(ofVec2f _pos) {
	screenPosition.set(_pos);
}


ofVec3f player::getWorldPosition() {
	return worldPosition;
}
ofVec2f player::getScreenPosition() {
	return screenPosition;
}
ofVec3f player::getCaughtPos(){
	return caughtPos;
}

void player::update(ofxCvBlob blob) {
	outline=ofPolyline(blob.pts);
	tessellateToMesh(outline,OF_POLY_WINDING_NONZERO,billboard,true);
	for (int i=0;i<billboard.getNumVertices();i++) {
		ofVec3f v=billboard.getVertex(i);
		billboard.addTexCoord(ofVec2f(v.x/ofGetWidth(),v.y/ofGetHeight()));
	}
}

void player::draw(){
	ofPushMatrix();
		if (isCaught) {
			ofTranslate(caughtPos-screenPosition);
			ofTranslate(catchPos);
			ofTranslate(screenPosition);
			ofScale(catchScale.x,catchScale.y,catchScale.z);
			ofTranslate(-screenPosition);
		}
		billboard.draw();
	ofPopMatrix();
}

void player::caught(){
	isCaught=true;
	caughtPos=screenPosition;
}

void player::setCatchTransform(ofVec3f _catchPos,ofVec3f _catchScale){
	catchPos=_catchPos;
	catchScale=_catchScale;
}