Skip to content
Snippets Groups Projects
Commit a1f23a36 authored by Shon Ferguson's avatar Shon Ferguson
Browse files

Fixed Matrix44 != operator

Added bounding box related functions to NiAVObject.  Forgot to commit this earlier, so it removes the versions created by Tazpn.
Hopefully fixed the skin calculations.  Results in skin files that always seem to look correct in Morrowind but do not always look correct in NifSkope.
parent ad463c0d
No related branches found
No related tags found
No related merge requests found
...@@ -362,11 +362,11 @@ bool Matrix44::operator==( const Matrix44 & rh ) const { ...@@ -362,11 +362,11 @@ bool Matrix44::operator==( const Matrix44 & rh ) const {
bool Matrix44::operator!=( const Matrix44 & rh ) const { bool Matrix44::operator!=( const Matrix44 & rh ) const {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) { for (int j = 0; j < 4; j++) {
if ( (*this)[i][j] == rh[i][j] ) if ( (*this)[i][j] != rh[i][j] )
return false; return true;
} }
} }
return true; return false;
} }
Matrix44 Matrix44::Transpose() const { Matrix44 Matrix44::Transpose() const {
......
...@@ -189,34 +189,23 @@ void NiAVObject::SetVisibility( bool n ) { ...@@ -189,34 +189,23 @@ void NiAVObject::SetVisibility( bool n ) {
} }
} }
bool NiAVObject::GetHasBoundingBox() const { bool NiAVObject::HasBoundingBox() const {
return hasBoundingBox; return hasBoundingBox;
} }
void NiAVObject::SetHasBoundingBox( bool value ) { void NiAVObject::ClearBoundingBox() {
hasBoundingBox = value; hasBoundingBox = false;
} }
BoundingBox NiAVObject::GetBoundingBox() const { BoundingBox NiAVObject::GetBoundingBox() const {
return boundingBox; if ( hasBoundingBox == true ) {
} return boundingBox;
} else {
void NiAVObject::SetBoundingBox( const BoundingBox & value ) { throw runtime_error("This NIAVObject has no Bounding Box.");
boundingBox = value; }
}
Ref<NiCollisionData > NiAVObject::GetCollisionData() const {
return collisionData;
}
void NiAVObject::SetCollisionData( Ref<NiCollisionData > value ) {
collisionData = value;
}
Ref<NiCollisionObject > NiAVObject::GetCollisionObject() const {
return collisionObject;
} }
void NiAVObject::SetCollisionObject( Ref<NiCollisionObject > value ) { void NiAVObject::SetBoundingBox( const BoundingBox & n ) {
collisionObject = value; boundingBox = n;
hasBoundingBox = true;
} }
...@@ -40,7 +40,11 @@ public: ...@@ -40,7 +40,11 @@ public:
virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version ); virtual void FixLinks( const vector<NiObjectRef> & objects, list<uint> & link_stack, unsigned int version, unsigned int user_version );
virtual list<NiObjectRef> GetRefs() const; virtual list<NiObjectRef> GetRefs() const;
//TODO: Bounding Box. What to do with newer files that have a link? Wrap this in a function and translate? //TODO: What to do with newer files that have a link for a bounding box? Wrap this in a function and translate?
void ClearBoundingBox();
BoundingBox GetBoundingBox() const;
void SetBoundingBox( const BoundingBox & n );
bool HasBoundingBox() const;
/*! /*!
* This is a conveniance function that allows you to retrieve the full 4x4 matrix transform of a node. It accesses the "Rotation," "Translation," and "Scale" attributes and builds a complete 4x4 transformation matrix from them. * This is a conveniance function that allows you to retrieve the full 4x4 matrix transform of a node. It accesses the "Rotation," "Translation," and "Scale" attributes and builds a complete 4x4 transformation matrix from them.
...@@ -92,31 +96,6 @@ public: ...@@ -92,31 +96,6 @@ public:
bool GetVisibility() const; bool GetVisibility() const;
void SetVisibility( bool n ); void SetVisibility( bool n );
/*!
* Gets whether there is a bounding box associated with this object.
* \return True if there is a bounding box.
* \sa NiAVObject::SetHasBoundingBox
*/
bool GetHasBoundingBox() const;
/*!
* Assigns whether there is a bounding box associated with this object.
* \sa NiAVObject::GetHasBoundingBox
*/
void SetHasBoundingBox( bool value );
/*!
* The bounding box.
*/
BoundingBox GetBoundingBox() const;
void SetBoundingBox( const BoundingBox & value );
/*!
* Bounding box: refers to NiCollisionData
*/
Ref<NiCollisionData > GetCollisionData() const;
void SetCollisionData( Ref<NiCollisionData> value );
/*! /*!
* In Oblivion this links the havok objects. * In Oblivion this links the havok objects.
*/ */
......
...@@ -94,10 +94,11 @@ NiSkinData::NiSkinData( const Ref<NiTriBasedGeom> & owner ) { ...@@ -94,10 +94,11 @@ NiSkinData::NiSkinData( const Ref<NiTriBasedGeom> & owner ) {
Matrix44 owner_mat = owner->GetWorldTransform(); Matrix44 owner_mat = owner->GetWorldTransform();
//Get Skeleton root world transform //Get Skeleton root world transform
Matrix44 skel_root_mat = skinInst->GetSkeletonRoot()->GetWorldTransform(); Matrix44 sr_world = skinInst->GetSkeletonRoot()->GetWorldTransform();
//Inverse owner NiTriBasedGeom matrix & multiply with skeleton root matrix //Inverse owner NiTriBasedGeom matrix & multiply with skeleton root matrix
Matrix44 res_mat = owner_mat.Inverse() * skel_root_mat; Matrix44 res_mat = owner_mat.Inverse() * sr_world;
//Matrix44 res_mat = (sr_world.Inverse() * owner_mat).Inverse() * sr_world;
//Store result //Store result
res_mat.Decompose( translation, rotation, scale ); res_mat.Decompose( translation, rotation, scale );
...@@ -111,12 +112,13 @@ NiSkinData::NiSkinData( const Ref<NiTriBasedGeom> & owner ) { ...@@ -111,12 +112,13 @@ NiSkinData::NiSkinData( const Ref<NiTriBasedGeom> & owner ) {
//Get bone world position //Get bone world position
bone_mat = bone_nodes[i]->GetWorldTransform(); bone_mat = bone_nodes[i]->GetWorldTransform();
bone_mat = bone_mat * sr_world;
//Multiply NiTriBasedGeom matrix with inversed bone matrix //Multiply NiTriBasedGeom matrix with inversed bone matrix
res_mat = owner_mat * bone_mat.Inverse(); res_mat = owner_mat * bone_mat.Inverse();
//Store result //Store result
res_mat.Decompose( boneList[i].translation, boneList[i].rotation, boneList[i].scale ); res_mat.Decompose( boneList[i].translation, boneList[i].rotation, boneList[i].scale );
//TODO: Calculate center and radius of each bone
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment