-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathObject.cpp
154 lines (114 loc) · 3.71 KB
/
Object.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* File: Object.cpp
* Author: Aztyu
*
* Created on 21 avril 2015, 17:07
*/
#include <cmath>
#include "Object.h"
using namespace std;
Object::Object(irr::scene::ISceneNode* obj, const char* name, irr::scene::ISceneNode* parent) : object_name(name){
this->objet = obj; //Stock le pointeur vers le node
this->objet->setPosition(irr::core::vector3df(0, 0, 0));
this->default_parent = parent;
}
Object::Object(irr::scene::ISceneNode* obj, const char* name, irr::scene::ISceneNode* parent, float total_scale) : object_name(name){
this->objet = obj;
this->objet->setPosition(irr::core::vector3df(0, 0, 0));
this->objet->setScale(irr::core::vector3df(total_scale, total_scale, total_scale));
this->default_parent = parent;
}
Object::Object(irr::scene::ISceneNode* obj, const char* name, irr::scene::ISceneNode* parent, const irr::core::vector3df& position) : object_name(name){
this->objet = obj;
this->objet->setPosition(position);
this->default_parent = parent;
}
Object::~Object() {
cout << "Object deleted" << endl;
}
void Object::setPosition(float x, float y, float z){ //Methodes absolues
objet->setPosition(irr::core::vector3df(x, y, z));
}
void Object::setPosition(irr::core::vector3df values) {
objet->setPosition(values);
}
void Object::setScale(float x, float y, float z){
objet->setScale(irr::core::vector3df(x, y, z));
}
void Object::setScale(irr::core::vector3df values) {
objet->setScale(values);
}
void Object::setRotation(float x, float y, float z){
objet->setRotation(irr::core::vector3df(x, y, z));
}
void Object::setRotation(irr::core::vector3df values){
objet->setRotation(values);
}
void Object::modifyPositionBy(float x, float y, float z){ //Methodes relatives, utilise la valeur de base plus celle que vous rajoutez
objet->setPosition(irr::core::vector3df(x, y, z) + objet->getPosition());
}
void Object::modifyPositionBy(irr::core::vector3df values) {
this->objet->setPosition(values + this->objet->getPosition());
}
void Object::modifyScaleBy(float x, float y, float z){
irr::core::vector3df scale = objet->getScale();
if(x > 0){
scale.X *= x;
}else if(x < 0){
scale.X /= abs(x);
}
if(y > 0){
scale.Y *= y;
}else if(y < 0){
scale.Y /= abs(y);
}
if(z > 0){
scale.Z *= z;
}else if(z < 0){
scale.Z /= abs(z);
}
objet->setScale(scale);
}
void Object::modifyScaleBy(irr::core::vector3df values) {
irr::core::vector3df scale = objet->getScale();
if(values.X > 0){
scale.X *= values.X;
}else if(values.X < 0){
scale.X /= std::abs(values.X);
}
if(values.Y > 0){
scale.Y *= values.Y;
}else if(values.Y < 0){
scale.Y /= std::abs(values.Y);
}
if(values.Z > 0){
scale.Z *= values.Z;
}else if(values.Z < 0){
scale.Z /= abs(values.Z);
}
objet->setScale(scale);
}
void Object::modifyRotationBy(float x, float y, float z){
objet->setRotation(irr::core::vector3df(x, y, z) + objet->getRotation());
}
void Object::modifyRotationBy(irr::core::vector3df values) {
objet->setRotation(values + objet->getRotation());
}
const irr::core::vector3df& Object::getPosition() {
return this->objet->getPosition();
}
const irr::core::vector3df& Object::getScale() {
return this->objet->getScale();
}
const irr::core::vector3df& Object::getRotation() {
return this->objet->getRotation();
}
irr::scene::ISceneNode* Object::getSceneNode(){ //Retourne le pointeur vers le node
return objet;
}
std::string Object::getName() {
return this->object_name;
}
void Object::setName(std::string name) {
this->object_name = name;
}