Skip to content
Snippets Groups Projects
Commit 80d2eb21 authored by Tazpn's avatar Tazpn
Browse files

Update NiBSplineCompFloatInterpolator and some other collision, animation related objects.

parent 516409d1
No related branches found
No related tags found
No related merge requests found
...@@ -53,10 +53,72 @@ public: ...@@ -53,10 +53,72 @@ public:
NIFLIB_API virtual const Type & GetType() const; NIFLIB_API virtual const Type & GetType() const;
//--BEGIN MISC CUSTOM CODE--// //--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--// //--END CUSTOM CODE--//
protected: protected:
/*! Unknown. */ /*! Base value when curve not defined. */
array<4,float > unknownFloats; float base;
/*! Starting offset for the scale data. (USHRT_MAX for no data.) */
unsigned int offset;
/*! Bias */
float bias;
/*! Multiplier */
float multiplier;
public: public:
/*! NIFLIB_HIDDEN function. For internal use only. */ /*! NIFLIB_HIDDEN function. For internal use only. */
NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info ); NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info );
......
...@@ -144,6 +144,19 @@ public: ...@@ -144,6 +144,19 @@ public:
*/ */
NIFLIB_API void SetMorphVerts( int n, const vector<Vector3> & in ); 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--// //--END CUSTOM CODE--//
protected: protected:
/*! Number of morphing object. */ /*! Number of morphing object. */
......
...@@ -96,6 +96,17 @@ public: ...@@ -96,6 +96,17 @@ public:
*/ */
NIFLIB_API void SetDistToCenter( const vector<float> & in ); 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--// //--END CUSTOM CODE--//
protected: protected:
/*! Unknown. */ /*! Unknown. */
......
...@@ -8,6 +8,9 @@ All rights reserved. Please see niflib.h for license. */ ...@@ -8,6 +8,9 @@ All rights reserved. Please see niflib.h for license. */
//-----------------------------------NOTICE----------------------------------// //-----------------------------------NOTICE----------------------------------//
//--BEGIN FILE HEAD CUSTOM CODE--// //--BEGIN FILE HEAD CUSTOM CODE--//
#include "../../include/obj/NiBSplineBasisData.h"
#include "../../include/obj/NiBSplineData.h"
static const int SizeofValue = 1;
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
#include "../../include/FixLink.h" #include "../../include/FixLink.h"
...@@ -42,9 +45,10 @@ void NiBSplineCompFloatInterpolator::Read( istream& in, list<unsigned int> & lin ...@@ -42,9 +45,10 @@ void NiBSplineCompFloatInterpolator::Read( istream& in, list<unsigned int> & lin
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
NiBSplineFloatInterpolator::Read( in, link_stack, info ); NiBSplineFloatInterpolator::Read( in, link_stack, info );
for (unsigned int i1 = 0; i1 < 4; i1++) { NifStream( base, in, info );
NifStream( unknownFloats[i1], in, info ); NifStream( offset, in, info );
}; NifStream( bias, in, info );
NifStream( multiplier, in, info );
//--BEGIN POST-READ CUSTOM CODE--// //--BEGIN POST-READ CUSTOM CODE--//
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
...@@ -55,9 +59,10 @@ void NiBSplineCompFloatInterpolator::Write( ostream& out, const map<NiObjectRef, ...@@ -55,9 +59,10 @@ void NiBSplineCompFloatInterpolator::Write( ostream& out, const map<NiObjectRef,
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
NiBSplineFloatInterpolator::Write( out, link_map, info ); NiBSplineFloatInterpolator::Write( out, link_map, info );
for (unsigned int i1 = 0; i1 < 4; i1++) { NifStream( base, out, info );
NifStream( unknownFloats[i1], out, info ); NifStream( offset, out, info );
}; NifStream( bias, out, info );
NifStream( multiplier, out, info );
//--BEGIN POST-WRITE CUSTOM CODE--// //--BEGIN POST-WRITE CUSTOM CODE--//
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
...@@ -68,20 +73,11 @@ std::string NiBSplineCompFloatInterpolator::asString( bool verbose ) const { ...@@ -68,20 +73,11 @@ std::string NiBSplineCompFloatInterpolator::asString( bool verbose ) const {
//--END CUSTOM CODE--// //--END CUSTOM CODE--//
stringstream out; stringstream out;
unsigned int array_output_count = 0;
out << NiBSplineFloatInterpolator::asString(); out << NiBSplineFloatInterpolator::asString();
array_output_count = 0; out << " Base: " << base << endl;
for (unsigned int i1 = 0; i1 < 4; i1++) { out << " Offset: " << offset << endl;
if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { out << " Bias: " << bias << endl;
out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; out << " Multiplier: " << multiplier << endl;
break;
};
if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) {
break;
};
out << " Unknown Floats[" << i1 << "]: " << unknownFloats[i1] << endl;
array_output_count++;
};
return out.str(); return out.str();
//--BEGIN POST-STRING CUSTOM CODE--// //--BEGIN POST-STRING CUSTOM CODE--//
...@@ -105,4 +101,89 @@ std::list<NiObjectRef> NiBSplineCompFloatInterpolator::GetRefs() const { ...@@ -105,4 +101,89 @@ std::list<NiObjectRef> NiBSplineCompFloatInterpolator::GetRefs() const {
} }
//--BEGIN MISC CUSTOM CODE--// //--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--// //--END CUSTOM CODE--//
...@@ -237,4 +237,13 @@ void NiMorphData::SetMorphVerts( int n, const vector<Vector3> & in ) { ...@@ -237,4 +237,13 @@ void NiMorphData::SetMorphVerts( int n, const vector<Vector3> & in ) {
morphs[n].vectors = 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--// //--END CUSTOM CODE--//
...@@ -233,5 +233,15 @@ void bhkConvexVerticesShape::SetDistToCenter( const vector<float> & in ) ...@@ -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--// //--END CUSTOM CODE--//
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