diff --git a/include/obj/NiBSplineCompFloatInterpolator.h b/include/obj/NiBSplineCompFloatInterpolator.h index a2752d13700137d3bc3030a2dfe84792338270e7..86d78d9f4bc9be397d772b93b2b86b3b5d57c4c5 100644 --- a/include/obj/NiBSplineCompFloatInterpolator.h +++ b/include/obj/NiBSplineCompFloatInterpolator.h @@ -53,10 +53,72 @@ public: NIFLIB_API virtual const Type & GetType() const; //--BEGIN MISC CUSTOM CODE--// + + /*! + * Gets the base value when a curve is not defined. + * \return The base value. + */ + NIFLIB_API float GetBase() const; + + /*! + * Sets the base value when a curve is not defined. + * \param[in] value The new base value. + */ + NIFLIB_API void SetBase( float value ); + + /*! + * Gets value bias. + * \return The value bias. + */ + NIFLIB_API float GetBias() const; + + /*! + * Sets value bias. + * \param[in] value The new value bias. + */ + NIFLIB_API void SetBias( float value ); + + /*! + * Gets value multiplier. + * \return The value multiplier. + */ + NIFLIB_API float GetMultiplier() const; + + /*! + * Sets value multiplier. + * \param[in] value The new value multiplier. + */ + NIFLIB_API void SetMultiplier( float value ); + + /*! + * Retrieves the key data. + * \return A vector containing control float data which specify a value over time. + */ + NIFLIB_API vector< float > GetControlData() const; + + /*! + * Retrieves the sampled data between start and stop time. + * \param npoints The number of data points to sample between start and stop time. + * \param degree N-th order degree of polynomial used to fit the data. + * \return A vector containing Key<float> data which specify a value over time. + */ + NIFLIB_API vector< Key<float> > SampleKeys(int npoints, int degree) const; + + /*! + * Retrieves the number of control points used in the spline curve. + * \return The number of control points used in the spline curve. + */ + NIFLIB_API int GetNumControlPt() const; //--END CUSTOM CODE--// protected: - /*! Unknown. */ - array<4,float > unknownFloats; + /*! Base value when curve not defined. */ + float base; + /*! Starting offset for the scale data. (USHRT_MAX for no data.) */ + unsigned int offset; + /*! Bias */ + float bias; + /*! Multiplier */ + float multiplier; public: /*! NIFLIB_HIDDEN function. For internal use only. */ NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ); diff --git a/include/obj/NiMorphData.h b/include/obj/NiMorphData.h index 9c05d69183a707956ded4fb0be6f72fc6a12c2ce..3c619480a95c64f37e1c8a2dc06234402ef5b0ad 100644 --- a/include/obj/NiMorphData.h +++ b/include/obj/NiMorphData.h @@ -144,6 +144,19 @@ public: */ NIFLIB_API void SetMorphVerts( int n, const vector<Vector3> & in ); + /*! + * Retrieves the morph frame name for a specified morph target. + * \return A string which specifies the name of the morph frame. + */ + NIFLIB_API string GetFrameName( int n ) const; + + /*! + * Sets the morph frame name for a specified morph target. + * \param n The index of the morph target to set the name for. + * \param keys A frame name which will replace any existing data for this morph target. + */ + NIFLIB_API void SetFrameName( int n, string const & key ); + //--END CUSTOM CODE--// protected: /*! Number of morphing object. */ diff --git a/include/obj/bhkConvexVerticesShape.h b/include/obj/bhkConvexVerticesShape.h index 4d488c317d30e308811489f5106cd55221e26566..80ffff5c84be66a47fd94a04c6522d07313e38d0 100644 --- a/include/obj/bhkConvexVerticesShape.h +++ b/include/obj/bhkConvexVerticesShape.h @@ -96,6 +96,17 @@ public: */ NIFLIB_API void SetDistToCenter( const vector<float> & in ); + /*! + * Used to retrieve the normal and the distance to center for vertices. The size of the vector will either be zero if no normals are used, or be the same as the vertex count retrieved with the IShapeData::GetVertexCount function. + * \return A vector containing the normals used by this mesh, if any. + */ + NIFLIB_API vector<Float4> GetNormalsAndDist() const; + + /*! + * Used to set the normal and the distance to center for vertices. The size of the vector will either be zero if no normals are used, or be the same as the vertex count retrieved with the IShapeData::GetVertexCount function. + */ + NIFLIB_API void SetNormalsAndDist(const vector<Float4>& value); + //--END CUSTOM CODE--// protected: /*! Unknown. */ diff --git a/src/obj/NiBSplineCompFloatInterpolator.cpp b/src/obj/NiBSplineCompFloatInterpolator.cpp index 9e45c50051f2ae394786f938d07cbda8c283f3e4..3bb0fb8602adb415ab3e6ef6c4b1db219cda3bfd 100644 --- a/src/obj/NiBSplineCompFloatInterpolator.cpp +++ b/src/obj/NiBSplineCompFloatInterpolator.cpp @@ -8,6 +8,9 @@ All rights reserved. Please see niflib.h for license. */ //-----------------------------------NOTICE----------------------------------// //--BEGIN FILE HEAD CUSTOM CODE--// +#include "../../include/obj/NiBSplineBasisData.h" +#include "../../include/obj/NiBSplineData.h" +static const int SizeofValue = 1; //--END CUSTOM CODE--// #include "../../include/FixLink.h" @@ -42,9 +45,10 @@ void NiBSplineCompFloatInterpolator::Read( istream& in, list<unsigned int> & lin //--END CUSTOM CODE--// NiBSplineFloatInterpolator::Read( in, link_stack, info ); - for (unsigned int i1 = 0; i1 < 4; i1++) { - NifStream( unknownFloats[i1], in, info ); - }; + NifStream( base, in, info ); + NifStream( offset, in, info ); + NifStream( bias, in, info ); + NifStream( multiplier, in, info ); //--BEGIN POST-READ CUSTOM CODE--// //--END CUSTOM CODE--// @@ -55,9 +59,10 @@ void NiBSplineCompFloatInterpolator::Write( ostream& out, const map<NiObjectRef, //--END CUSTOM CODE--// NiBSplineFloatInterpolator::Write( out, link_map, info ); - for (unsigned int i1 = 0; i1 < 4; i1++) { - NifStream( unknownFloats[i1], out, info ); - }; + NifStream( base, out, info ); + NifStream( offset, out, info ); + NifStream( bias, out, info ); + NifStream( multiplier, out, info ); //--BEGIN POST-WRITE CUSTOM CODE--// //--END CUSTOM CODE--// @@ -68,20 +73,11 @@ std::string NiBSplineCompFloatInterpolator::asString( bool verbose ) const { //--END CUSTOM CODE--// stringstream out; - unsigned int array_output_count = 0; out << NiBSplineFloatInterpolator::asString(); - array_output_count = 0; - for (unsigned int i1 = 0; i1 < 4; i1++) { - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; - break; - }; - if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { - break; - }; - out << " Unknown Floats[" << i1 << "]: " << unknownFloats[i1] << endl; - array_output_count++; - }; + out << " Base: " << base << endl; + out << " Offset: " << offset << endl; + out << " Bias: " << bias << endl; + out << " Multiplier: " << multiplier << endl; return out.str(); //--BEGIN POST-STRING CUSTOM CODE--// @@ -105,4 +101,89 @@ std::list<NiObjectRef> NiBSplineCompFloatInterpolator::GetRefs() const { } //--BEGIN MISC CUSTOM CODE--// + +float NiBSplineCompFloatInterpolator::GetBase() const { + return base; +} + +void NiBSplineCompFloatInterpolator::SetBase( float value ) { + base = value; +} + + +float NiBSplineCompFloatInterpolator::GetBias() const { + return bias; +} + +void NiBSplineCompFloatInterpolator::SetBias( float value ) { + bias = value; +} + +float NiBSplineCompFloatInterpolator::GetMultiplier() const { + return multiplier; +} + +void NiBSplineCompFloatInterpolator::SetMultiplier( float value ) { + multiplier = value; +} + +vector< float > NiBSplineCompFloatInterpolator::GetControlData() const +{ + vector< float > value; + if ((offset != USHRT_MAX) && splineData && basisData) { // has translation data + int nctrl = basisData->GetNumControlPt(); + int npts = nctrl * SizeofValue; + vector<short> points = splineData->GetControlPointRange(offset, npts); + value.reserve(nctrl); + for (int i=0; i<npts; ) { + float data = float(points[i++]) / float (32767) * multiplier + bias; + value.push_back(data); + } + } + return value; +} + + +vector< Key<float> > NiBSplineCompFloatInterpolator::SampleKeys(int npoints, int degree) const +{ + vector< Key<float> > value; + if ((offset != USHRT_MAX) && splineData && basisData) // has rotation data + { + int nctrl = basisData->GetNumControlPt(); + int npts = nctrl * SizeofValue; + vector<short> points = splineData->GetControlPointRange(offset, npts); + vector<float> control(npts); + vector<float> output(npoints*SizeofValue); + for (int i=0, j=0; i<nctrl; ++i) { + control[i] = float(points[j++]) / float (32767); + } + // fit data + bspline(nctrl-1, degree+1, SizeofValue, &control[0], &output[0], npoints); + + // copy to key + float time = GetStartTime(); + float incr = (GetStopTime() - GetStartTime()) / float(npoints) ; + value.reserve(npoints); + for (int i=0, j=0; i<npoints; i++) { + Key<float> key; + key.time = time; + key.backward_tangent = 0.0f; + key.forward_tangent = 0.0f; + key.data = output[j++] * multiplier + bias; + value.push_back(key); + time += incr; + } + } + return value; +} + +int NiBSplineCompFloatInterpolator::GetNumControlPt() const +{ + if (basisData) + { + return basisData->GetNumControlPt(); + } + return 0; +} + //--END CUSTOM CODE--// diff --git a/src/obj/NiMorphData.cpp b/src/obj/NiMorphData.cpp index 37313610fe2777ea6c66a3ec06510284076956a2..e8d99fbeb78d2a834adf33508d8cfcf9b69d7dba 100644 --- a/src/obj/NiMorphData.cpp +++ b/src/obj/NiMorphData.cpp @@ -237,4 +237,13 @@ void NiMorphData::SetMorphVerts( int n, const vector<Vector3> & in ) { morphs[n].vectors = in; } +string NiMorphData::GetFrameName( int n ) const +{ + return morphs[n].frameName; +} + +void NiMorphData::SetFrameName( int n, string const & key ) { + morphs[n].frameName = key; +} + //--END CUSTOM CODE--// diff --git a/src/obj/bhkConvexVerticesShape.cpp b/src/obj/bhkConvexVerticesShape.cpp index 7f82e41fea8a00d8a050efc4de4fb274f8f30e46..24d77e9f1b27a47bb993db086d814892dd2221a4 100644 --- a/src/obj/bhkConvexVerticesShape.cpp +++ b/src/obj/bhkConvexVerticesShape.cpp @@ -233,5 +233,15 @@ void bhkConvexVerticesShape::SetDistToCenter( const vector<float> & in ) } } +vector<Float4> bhkConvexVerticesShape::GetNormalsAndDist() const +{ + return normals; +} + +void bhkConvexVerticesShape::SetNormalsAndDist(const vector<Float4>& value) +{ + normals = value; +} + //--END CUSTOM CODE--//