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

Added functions to NiMorphData.

parent 4fbd9f0d
No related branches found
No related tags found
No related merge requests found
...@@ -35,3 +35,57 @@ const Type & NiMorphData::GetType() const { ...@@ -35,3 +35,57 @@ const Type & NiMorphData::GetType() const {
return TYPE; return TYPE;
}; };
int NiMorphData::GetVertexCount() const {
return numVertices;
}
void NiMorphData::SetVertexCount( int n ) {
numVertices = n;
for ( uint i = 0; i < morphs.size(); ++i ) {
morphs[i].vectors.resize( n );
}
}
int NiMorphData::GetMorphCount() const {
return int(morphs.size());
}
void NiMorphData::SetMorphCount( int n ) {
int old_size = morphs.size();
morphs.resize( n );
//Make sure any new vertex groups are the right size
for (uint i = old_size; i < morphs.size(); ++i ) {
morphs[i].vectors.resize( numVertices );
}
}
KeyType NiMorphData::GetMorphKeyType( int n ) const {
return morphs[n].morphInterpolation;
}
void NiMorphData::SetMorphKeyType( int n, KeyType t ) {
morphs[n].morphInterpolation = t;
}
vector< Key<float> > NiMorphData::GetMorphKeys( int n ) const {
return morphs[n].morphKeys;
}
void NiMorphData::SetMorphKeys( int n, vector< Key<float> > const & keys ) {
morphs[n].morphKeys = keys;
}
vector<Vector3> NiMorphData::GetMorphVerts( int n) const {
return morphs[n].vectors;
}
void NiMorphData::SetMorphVerts( int n, const vector<Vector3> & in ) {
// Make sure the size of the incoming vector equal vertCount
if ( in.size() != numVertices )
throw runtime_error("Input array size must equal Vertex Count. Call SetVertexCount() to resize.");
//It's the right size, so go ahead and set it
morphs[n].vectors = in;
}
...@@ -29,6 +29,71 @@ public: ...@@ -29,6 +29,71 @@ 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;
virtual const Type & GetType() const; virtual const Type & GetType() const;
/*! Retrieves the number of verticies used in the morph targets. This must be the same as the number of verticies in the base mesh that the morph controller for which this block stores data is attatched. This is not done automatically by Niflib.
* \return The number of vertices used in the morph target meshes.
* \sa NiMorphData::SetVertexCount
*/
int GetVertexCount() const;
/*! Sets the number of verticies used in the morph targets. This must be the same as the number of verticies in the base mesh that the morph controller for which this block stores data is attatched. This is not done automatically by Niflib. If the new size is smaller, vertices at the ends of the morph targets will be lost.
* \param n The new size of the morph target's vertex arrays.
* \sa NiMorphData::GetVertexCount
*/
void SetVertexCount( int n );
/*! Retrieves the number of morph targets used by this morph controller data.
* \return The number of morph targets used by this morph controller data.
* \sa NiMorphData::SetMorphCount
*/
int GetMorphCount() const;
/*! Resizes the morph target array used by this morph controller data. If the new size is smaller, morph targets at the end of the array and all associated data will be lost.
* \param n The new size of the morph target array.
* \sa NiMorphData::GetMorphCount
*/
void SetMorphCount( int n );
/*! Retrieves the type of morph interpolation being used by a specific morph target.
* \param n The index of the morph to get the interpolation key type from. A zero-based positive value which must be less than that returned by IMoprhData::GetMorphCount.
* \return The morph key type specifing the type of interpolation being used by the specified morph target.
* \sa NiMorphData::SetMorphKeyType
*/
KeyType GetMorphKeyType( int n ) const;
/*! Sets the type of morph interpolation being used by a specific morph target. Does not affect existing key data.
* \param n The index of the morph to get the interpolation key type from. A zero-based positive value which must be less than that returned by IMoprhData::GetMorphCount.
* \param t The new morph key type specifing the type of interpolation to be used by the specified morph target.
* \sa NiMorphData::GetMorphKeyType
*/
void SetMorphKeyType( int n, KeyType t );
/*! Retrieves the morph key data for a specified morph target.
* \return A vector containing Key<float> data which specify the influence of this morph target over time.
* \sa NiMorphData::SetMorphKeys, Key
*/
vector< Key<float> > GetMorphKeys( int n ) const;
/*! Sets the morph key data.
* \param keys A vector containing new Key<float> data which will replace any existing data for this morph target.
* \sa NiMorphData::GetMorphKeys, Key
*/
void SetMorphKeys( int n, vector< Key<float> > const & keys );
/*! Retrieves the vertex data from the specified morph target
* \param n The index of the morph target to retrieve vertex data for. This is a zero-based index whoes value that must be less than that returned by NiMorphData::GetMorphCount.
* \return A vector containing the vertices used by this morph target. The size will be equal to the value returned by NiMorphData::GetVertexCount.
* \sa NiMorphData::SetMorphVerts
*/
vector<Vector3> GetMorphVerts( int n) const;
/*! Sets the vertex data for a specified morph target
* \param n The index of the morph target to set vertex data for. This is a zero-based index whoes value that must be less than that returned by NiMorphData::GetMorphCount.
* \param in A vector containing the new vertices to be used by this morph target. The size will be equal to the value returned by NiMorphData::GetVertexCount.
* \sa NiMorphData::SetMorphVerts
*/
void SetMorphVerts( int n, const vector<Vector3> & in );
protected: protected:
NI_MORPH_DATA_MEMBERS NI_MORPH_DATA_MEMBERS
}; };
......
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