-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cpp
113 lines (91 loc) · 3.88 KB
/
Player.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// Player.cpp
// 3ngine
//
// Created by gh00st on 5/26/14.
//
//
#include "Player.h"
//--------------------------------------------------------------
Player::Player(int _ID) {
ID = _ID;
gui.setup("PLAYER "+ofToString(ID)+" SETUP", "", ofGetWidth()-500, (70*ID)+10);
gui.add(enabled.set("ENABLED", false));
gui.add(hasBody.set("HAS BODY", false));
gui.add(showBody.set("SHOW BODY", false));
gui.add(movePlayer.set("MOVE PLAYER", false));
gui.add(chooseModel.setup("CHOOSE MODEL"));
gui.add(chooseTexture.setup("CHOOSE TEXTURE"));
chooseModel.addListener(this, &Player::setChooseModel);
chooseTexture.addListener(this, &Player::setChooseTexture);
gui.add(movementSpeed.set("MOVEMENT SPEED", 7, 0, 100));
gui.add(startPos.set("START POSITION", ofVec3f(0,0,0), ofVec3f(-10000,-10000,-10000), ofVec3f(10000,10000,10000)));
model = new Model();
setPosition(0,0,0);
}
//--------------------------------------------------------------
void Player::setChooseModel() {
ofSendMessage("SETMODEL,PLAYER,"+ofToString(ID));
}
//--------------------------------------------------------------
void Player::setChooseTexture() {
ofSendMessage("SETTEXTURE,PLAYER,"+ofToString(ID));
}
//--------------------------------------------------------------
void Player::drawGui() {
if(enabledGui) {
gui.draw();
model->preview.draw(gui.getPosition().x, gui.getPosition().y+gui.getHeight()+5, gui.getWidth(), gui.getWidth());
model->drawGui();
}
}
//--------------------------------------------------------------
void Player::customDraw() {
if(showBody) {
model->drawEditor(true);
}
ofPushStyle();
ofSetColor(0,255,0,100);
ofDrawBox(0, 40, 0, 40,80,40);
ofPopStyle();
}
//--------------------------------------------------------------
void Player::drawEditor() {
if(movePlayer) {
ofVec3f forward = ofVec3f(0,0,1) * getOrientationQuat();
ofVec3f sideways = ofVec3f(1,0,0) * getOrientationQuat();
if( ofGetKeyPressed('w') ) setPosition( getPosition() + (-forward * movementSpeed) );
if( ofGetKeyPressed('s') ) setPosition( getPosition() + ( forward * movementSpeed) );
if( ofGetKeyPressed('a') ) setPosition( getPosition() + (-sideways * movementSpeed) );
if( ofGetKeyPressed('d') ) setPosition( getPosition() + ( sideways * movementSpeed) );
ofPoint mouse = ofPoint(ofGetMouseX(), ofGetMouseY());
ofPoint mouseVel = mouse - lastMouse;
pan(mouseVel.x/4);
lastMouse = mouse;
}
draw();
}
//--------------------------------------------------------------
void Player::drawPlayer() {
if(enabled) {
}
}
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------
//--------------------------------------------------------------