-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransform.cpp
More file actions
56 lines (48 loc) · 1.53 KB
/
Transform.cpp
File metadata and controls
56 lines (48 loc) · 1.53 KB
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
#ifndef LINEARCHEXT_TRANSFORM_CPP
#define LINEARCHEXT_TRANSFORM_CPP
#include "Vector2.hpp"
#include "GameObject.hpp"
#include "Transform.hpp"
#include <vector>
namespace LinearchExt{
Transform::Transform(GameObject* gameObject){
gameObject->transform = this;
Component::Init(gameObject);
}
Transform* Transform::GetParent(){
return parent;
}
Transform* Transform::GetRoot(){
if (parent==0)
return this;
return parent->GetRoot();
}
Transform::~Transform(){
if(gameObject != 0 && gameObject->transform == this)
gameObject->transform = 0;
}
std::vector<Transform*> Transform::GetParentalVector(std::vector<Transform*> vt){
vt.push_back(this);
if (parent==0){
return vt;
}else{
return parent->GetParentalVector(vt);
}
}
std::vector<Transform*> Transform::GetParentalVector(){
std::vector<Transform*> vt;
return GetParentalVector(vt);
}
Vector2 Transform::WorldToLocalPoint(Vector2 point){
std::vector<Transform*> pv = GetParentalVector();
for(std::vector<Transform*>::iterator it = pv.begin(); it != pv.end(); ++it){
point -= (*it)->localPosition;
point = Vector2::Rotate(point, (*it)->localRotation);
point /= (*it)->localScale;
}
return point;
}
void Transform::RotateAround(double d, Vector2 point, Space relativeTo = worldSpace, bool keepRotation = true){
}
}
#endif // TRANSFORM_CPP