fixed global to local position method

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent e07f30e3f7
commit d430bc6fc0
3 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -220,6 +220,8 @@ namespace vb01{
}
Vector3 Node::globalToLocalPosition(Vector3 globalPos){
Vector3 currentGlobalPos = localToGlobalPosition(Vector3::VEC_ZERO);
mat3 mat;
mat[0][0]=globalAxis[0].x;
mat[1][0]=globalAxis[0].y;
@@ -232,7 +234,7 @@ namespace vb01{
mat[2][2]=globalAxis[2].z;
mat=inverse(mat);
vec3 local = vec3(globalPos.x, globalPos.y, globalPos.z) * mat;
vec3 local = vec3(globalPos.x - currentGlobalPos.x, globalPos.y - currentGlobalPos.y, globalPos.z - currentGlobalPos.z) * mat;
return Vector3(local.x, local.y, local.z);
}