-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameObject.cpp
75 lines (61 loc) · 1.56 KB
/
GameObject.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
#include "GameObject.h"
#include <stdio.h>
#include <assert.h>
#include <string>
using std::cout;
GameObject::GameObject() :
name(),
sceneMgr(0),
rootNode(0),
geom(0),
simulator(0),
ms(0),
shape(0),
body(0),
position(0.0f,0.0f,0.0f),
rotation(0.0f,0.0f,0.0f,0.0f){
}
void GameObject::setPos(btVector3 pos){
position=pos;
}
void GameObject::addToSimulator() {
simulator->addObject(this);
}
void GameObject::updateTransform(){
btTransform tr;
ms->getWorldTransform(tr);
if(this->name.compare("Court")!=0){
rootNode->setPosition(tr.getOrigin().getX(),
tr.getOrigin().getY(),
tr.getOrigin().getZ());
}
position=btVector3(tr.getOrigin().getX(),
tr.getOrigin().getY(),
tr.getOrigin().getZ());
}
void GameObject::setTransform(Ogre::Vector3 tr){
const btTransform trans=btTransform(rotation,btVector3(tr.x,tr.y,tr.z));
ms->setWorldTransform(trans);
}
void GameObject::setTransform(btVector3 tr){
const btTransform trans=btTransform(rotation,tr);
ms->setWorldTransform(trans);
}
void GameObject::setSimulator(Simulator * insim){
simulator=insim;
}
btRigidBody* GameObject::getBody(){
return body;
}
void GameObject::printpos(){
cout << "{"<< position.x()<<","<< position.y()<<","<< position.z()<<"}\n";
}
Ogre::SceneNode* GameObject::getNode(){
return rootNode;
}
Ogre::String GameObject::getName(){
return name;
}
Ogre::Vector3 GameObject::getPos(){
return rootNode->getPosition();
}