diff --git a/include/Ref.h b/include/Ref.h index 01bb038fce580de801e8c351be01f049d9c5f8de..16a047743b84ca9ab8a644b5dc3259fd19da7034 100644 --- a/include/Ref.h +++ b/include/Ref.h @@ -112,7 +112,7 @@ Ref<T> & Ref<T>::operator=( T * object ) { object->AddRef(); } - //Decriment reference count on previously referenced object, if any + //Decrement reference count on previously referenced object, if any if ( _object != NULL ) { _object->SubtractRef(); } @@ -136,7 +136,7 @@ Ref<T> & Ref<T>::operator=( const Ref & ref ) { ref._object->AddRef(); } - //Decriment reference count on previously referenced object, if any + //Decrement reference count on previously referenced object, if any if ( _object != NULL ) { _object->SubtractRef(); } diff --git a/include/obj/hkPackedNiTriStripsData.h b/include/obj/hkPackedNiTriStripsData.h index 61326f4736b491856d3c2a69d648fa19256bec9e..99b04fc35e2b10cfbeaeaadc5afe6f8ae53108fb 100644 --- a/include/obj/hkPackedNiTriStripsData.h +++ b/include/obj/hkPackedNiTriStripsData.h @@ -82,6 +82,32 @@ public: */ NIFLIB_API vector<Vector3> GetNormals() const; + /*! Returns the number of vertices that make up this mesh. + * \return The number of faces that make up this mesh. + */ + NIFLIB_API virtual int GetNumFace( ) const; + + /*! Returns the number of vertices that make up this mesh. + * \param value The number of faces that make up this mesh. + */ + NIFLIB_API virtual void SetNumFaces( int value ); + + /*! Replaces the triangle face data in this mesh with new data. + * \param in A vector containing the new face data. Maximum size is 65,535. + * \sa ITriShapeData::GetTriangles + */ + NIFLIB_API virtual void SetTriangles( const vector<Triangle> & in ); + + /*! Replaces the face normal data in this mesh with new data. + * \param in A vector containing the new face normal data. + */ + NIFLIB_API virtual void SetNormals( const vector<Vector3> & in ); + + /*! Replaces the vertex data in this mesh with new data. + * \param in A vector containing the new vertex data. + */ + NIFLIB_API virtual void SetVertices( const vector<Vector3> & in ); + //--END CUSTOM CODE--// protected: /*! Number of triangles? */ diff --git a/src/niflib.cpp b/src/niflib.cpp index a813f391aba915c2aeab61036945a40e75a9a32d..f5ee1079d24d8423445607ca5a87d4a7316ae7ad 100644 --- a/src/niflib.cpp +++ b/src/niflib.cpp @@ -55,7 +55,7 @@ NiObjectRef GetObjectByType( NiObject * root, const Type & type ); * \param kf_type What type of keyframe tree to write (Morrowind style, DAoC style, ...). * \param info A NifInfo structure that contains information such as the version of the NIF file to create. */ -static void SplitNifTree( NiObject * root_object, NiObject * xnif_root, list<NiObjectRef> & xkf_roots, Kfm & kfm, int kf_type, const NifInfo & info ); +static void SplitNifTree( NiObject * root_object, NiObjectRef& xnif_root, list<NiObjectRef> & xkf_roots, Kfm & kfm, int kf_type, const NifInfo & info ); //--Function Bodies--// @@ -600,7 +600,7 @@ static std::string CreateFileName(std::string name) { } //TODO: This was written by Amorilia. Figure out how to fix it. -static void SplitNifTree( NiObject * root_object, NiObject * xnif_root, list<NiObjectRef> & xkf_roots, Kfm & kfm, int kf_type, const NifInfo & info ) { +static void SplitNifTree( NiObject* root_object, NiObjectRef& xnif_root, list<NiObjectRef> & xkf_roots, Kfm & kfm, int kf_type, const NifInfo & info ) { // Do we have animation groups (a NiTextKeyExtraData object)? // If so, create XNif and XKf trees. NiObjectRef txtkey = GetObjectByType( root_object, NiTextKeyExtraData::TYPE ); @@ -611,7 +611,6 @@ static void SplitNifTree( NiObject * root_object, NiObject * xnif_root, list<NiO if ( txtkey_obj != NULL ) { if ( kf_type == KF_MW ) { // Construct the XNif file... - xnif_root = CloneNifTree( root_object, info.version, info.userVersion ); // Now search and locate newer timeframe controllers and convert to keyframecontrollers @@ -724,6 +723,7 @@ static void SplitNifTree( NiObject * root_object, NiObject * xnif_root, list<NiO for (vector<NiControllerSequenceRef>::iterator itr = seqs.begin(); itr != seqs.end(); ++itr) { xkf_roots.push_back( StaticCast<NiObject>(*itr) ); } + mgr->ClearSequences(); } } else { throw runtime_error("KF splitting for the requested game is not yet implemented."); diff --git a/src/obj/NiAVObject.cpp b/src/obj/NiAVObject.cpp index d83a7be9002826c7e8a20faf2b8779b88b86be45..befd911b0ccd51ed32345c96c7f14c152b138cde 100644 --- a/src/obj/NiAVObject.cpp +++ b/src/obj/NiAVObject.cpp @@ -53,6 +53,8 @@ NiObject * NiAVObject::Create() { return new NiAVObject; } +extern "C" int __stdcall IsDebuggerPresent(); + void NiAVObject::Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ) { //--BEGIN PRE-READ CUSTOM CODE--// //--END CUSTOM CODE--// @@ -61,6 +63,12 @@ void NiAVObject::Read( istream& in, list<unsigned int> & link_stack, const NifIn NiObjectNET::Read( in, link_stack, info ); NifStream( flags, in, info ); NifStream( translation, in, info ); + + //if (name.compare("Bip01 R Finger01") == 0) { + // if (IsDebuggerPresent()) + // __asm{ int 3 }; + //} + NifStream( rotation, in, info ); NifStream( scale, in, info ); if ( info.version <= 0x04020200 ) { diff --git a/src/obj/NiMorphData.cpp b/src/obj/NiMorphData.cpp index 9c059d0d33bfbdbe75ede1cfd1c3e1751a0daff2..848a931b38dcecd918664dc1fdb3da9ba00f7aed 100644 --- a/src/obj/NiMorphData.cpp +++ b/src/obj/NiMorphData.cpp @@ -20,7 +20,7 @@ using namespace Niflib; //Definition of TYPE constant const Type NiMorphData::TYPE("NiMorphData", &NiObject::TYPE ); -NiMorphData::NiMorphData() : numMorphs((unsigned int)0), numVertices((unsigned int)0), unknownByte((byte)0) { +NiMorphData::NiMorphData() : numMorphs((unsigned int)0), numVertices((unsigned int)0), unknownByte((byte)1) { //--BEGIN CONSTRUCTOR CUSTOM CODE--// //--END CUSTOM CODE--// } diff --git a/src/obj/NiSkinData.cpp b/src/obj/NiSkinData.cpp index bdefaeebb92e4d70ffc2326aa27f8c90317a76bb..250e34b64486140062ce078e1dd4e463e11c381c 100644 --- a/src/obj/NiSkinData.cpp +++ b/src/obj/NiSkinData.cpp @@ -234,9 +234,10 @@ void NiSkinData::SetBoneWeights( unsigned int bone_index, const vector<SkinWeigh throw runtime_error( "The specified bone index was larger than the number of bones in this NiSkinData." ); } + hasVertexWeights = true; boneList[bone_index].vertexWeights = weights; - boneList[bone_index].boundingSphereOffset = center; - boneList[bone_index].boundingSphereRadius = radius; + boneList[bone_index].boundingSphereOffset = center; + boneList[bone_index].boundingSphereRadius = radius; } Matrix44 NiSkinData::GetOverallTransform() const { diff --git a/src/obj/bhkListShape.cpp b/src/obj/bhkListShape.cpp index 4ff45a321d541e5bfc8f1c75d4283bb36be82df6..ce10aeacb2088be159cbb8570638379cdd5a26a9 100644 --- a/src/obj/bhkListShape.cpp +++ b/src/obj/bhkListShape.cpp @@ -193,6 +193,9 @@ vector<Ref<bhkShape > > bhkListShape::GetSubShapes() const { */ void bhkListShape::SetSubShapes(const vector<Ref<bhkShape > >& shapes) { subShapes = shapes; + + // Becuase this vector matches the subshape vector + unknownInts.resize(subShapes.size(), 0); } //--END CUSTOM CODE--// diff --git a/src/obj/hkPackedNiTriStripsData.cpp b/src/obj/hkPackedNiTriStripsData.cpp index ecf48621394963369219d87e7e75b10f5ee2792c..bc9efb2cd3573b8f31f87afc489aff54e716111f 100644 --- a/src/obj/hkPackedNiTriStripsData.cpp +++ b/src/obj/hkPackedNiTriStripsData.cpp @@ -169,5 +169,40 @@ vector<Vector3> hkPackedNiTriStripsData::GetVertices() const { return vertices; } +int hkPackedNiTriStripsData::GetNumFace( ) const { + return int(triangles.size()); +} + +void hkPackedNiTriStripsData::SetNumFaces( int value ) { + if ( value > 65535 || value < 0 ) { + throw runtime_error("Invalid Face Count: must be between 0 and 65535."); + } + triangles.resize(value); +} + +void hkPackedNiTriStripsData::SetTriangles( const vector<Triangle> & in ) { + if ( triangles.size() != in.size()) { + throw runtime_error("Invalid Face Count: triangle count must be same as face count."); + } + for (size_t i=0; i<triangles.size(); ++i) { + triangles[i].triangle = in[i]; + } +} + +void hkPackedNiTriStripsData::SetNormals( const vector<Vector3> & in ) { + if ( triangles.size() != in.size()) { + throw runtime_error("Invalid Face Count: normal count must be same as face count."); + } + for (size_t i=0; i<triangles.size(); ++i) { + triangles[i].normal = in[i]; + } +} + +void hkPackedNiTriStripsData::SetVertices( const vector<Vector3> & in ) { + if ( in.size() > 65535 || in.size() < 0 ) { + throw runtime_error("Invalid Vertex Count: must be between 0 and 65535."); + } + vertices = in; +} //--END CUSTOM CODE--//