mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
fixed global to local position method
This commit is contained in:
@@ -30,7 +30,7 @@ namespace vb01{
|
||||
Vector3 Bone::getModelSpacePos(){
|
||||
Vector3 modelSpacePos = Vector3::VEC_ZERO;
|
||||
Bone *rootBone = skeleton->getRootBone();
|
||||
vector<Node*> boneHierarchy = getAncestors(this, rootBone->getParent());
|
||||
vector<Node*> boneHierarchy = getAncestors(this, rootBone);
|
||||
|
||||
while(!boneHierarchy.empty()){
|
||||
int id = boneHierarchy.size() - 1;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,8 @@ namespace vb01{
|
||||
rotAxis = Vector3::VEC_I;
|
||||
}
|
||||
|
||||
//rotAxis = (boneChain[i]->getInitAxis(0) * rotAxis.x + boneChain[i]->getInitAxis(1) * rotAxis.y + boneChain[i]->getInitAxis(2) * rotAxis.z).norm();
|
||||
|
||||
boneAngles[i] = angle;
|
||||
axis[i] = rotAxis;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user