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

Removing some files from the project that I added by mistake.

Fixing paths in MatTexCollection.cpp to be relative.
parent c6e5d793
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ DEBUGGING =
# Example: -march=k8 would generate enhancements for the k8 family (opterons and some athlons).or -march=pentium4 for a pentium4
# For more info read this: http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
#
CFLAGS = -O2 -Wall -fPIC $(DEBUGGING)
CFLAGS = -O2 -Wall -fPIC $(DEBUGGING) -Iinclude
CXXFLAGS = $(CFLAGS)
#IT should find the libs used, but if it doesn't specify here. Ex: -lm for libm.so.<whatever>
LIBS =
......
......@@ -6,6 +6,9 @@ All rights reserved. Please see niflib.h for license. */
#include <iostream>
#include <iomanip>
#include <vector>
#include "gen/enums.h"
namespace Niflib {
using namespace std;
......@@ -31,5 +34,87 @@ ostream & operator<<( ostream & out, Key<T> const & val ) {
<< "Continuity: " << val.continuity << endl;
}
/*!
* A function to normalize the key times in a vector of keys to be in seconds,
* effectivly setting phase to zero and frequency to 1.
* \param[in/out] keys The vector of keys to be normalized.
* \param[in] phase The phase shift to remove during normalization.
* \param[in] frequency The original frequency of the keys which will be
* normalized to 1.
*/
template <class T>
void NormalizeKeys( vector< Key<T> > & keys, float phase, float frequency ) {
for ( size_t i = 0; i < keys.size(); ++i ) {
keys[i].time = ( keys[i].time - phase ) / frequency;
}
}
/*!
* A function to extract key values for a certain amount of time. Values will be
* duplicated if necessary when cycle_type is CYCLE_LOOP or CYCLE_REVERSE.
*/
template <class T>
vector< Key<T> > ExtractKeySlice( const vector< Key<T> > & keys, float slice_start, float slice_stop, float keys_start, float keys_stop, CycleType cycle = CYCLE_CLAMP ) {
vector< Key<T> > out;
//Get first set of keys
for ( size_t i = 0; i < keys.size(); ++i ) {
if ( keys[i].time >= slice_start && keys[i].time <= slice_stop ) {
out.push_back( keys[i] );
}
}
//Get additional keys based on cycle type.
if ( cycle == CYCLE_LOOP || cycle == CYCLE_REVERSE ) {
float c = floor( slice_start / (keys_stop - keys_start) ) + 1.0f;
bool reverse = false;
bool failed = false;
while ( failed == false ) {
if ( cycle == CYCLE_REVERSE ) {
if ( reverse == false ) {
reverse = true;
} else {
reverse = false;
}
}
int first, last, vec;
if ( reverse == true ) {
first = int(keys.size()) - 1;
last = -1;
vec = -1;
} else {
first = 0;
last = int(keys.size());
vec = 1;
}
for ( int i = first; i != last; i+=vec ) {
float time = keys[i].time;
time = keys_start + ( keys_stop - time ) + c * ( keys_stop - keys_start );
if ( time >= slice_start && time <= slice_stop ) {
bool add_key = true;
size_t prev_key = out.size() - 1;
if ( out.size() > 0 && out[prev_key].time == keys[i].time ) {
add_key = false;
}
if ( add_key == true ) {
out.push_back( keys[i] );
}
} else {
failed = true;
break;
}
}
c += 1.0;
}
}
return out;
}
} //end namespace Niflib
#endif
......@@ -54,9 +54,6 @@ public:
//--BEGIN MISC CUSTOM CODE--//
//--END CUSTOM CODE--//
protected:
/*! Unknown. */
array<6,float > unknownFloats;
public:
/*! NIFLIB_HIDDEN function. For internal use only. */
NIFLIB_HIDDEN virtual void Read( istream& in, list<unsigned int> & link_stack, const NifInfo & info );
......
......@@ -62,6 +62,14 @@ public:
//TODO: Lots of unknown data in this object
/*!
* This function will adjust the times in all the keys stored in this
* controller so that phase will equal 0 and frequency will equal one. In
* other words, it will cause the key times to be in seconds starting from
* zero.
*/
NIFLIB_API virtual void NormalizeKeys();
/*!
* Retrives a list of the interpolators used by this controller.
* \return The interpolators.
......
......@@ -57,6 +57,18 @@ public:
//--BEGIN MISC CUSTOM CODE--//
/*!
* This function will adjust the times in all the keys stored in this
* controller so that phase will equal 0 and frequency will equal one. In
* other words, it will cause the key times to be in seconds starting from
* zero.
* \param[in] phase The phase shift to remove from any keys stored in this
* object.
* \param[in] frequency The frequency to normalize to 1.0 for any keys
* stored in this object
*/
NIFLIB_API void NormalizeKeys( float frequency, float phase );
/*!
* 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 object stores data is attatched. This is not done automatically by Niflib.
* \return The number of vertices used in the morph target meshes.
......
......@@ -130,7 +130,7 @@ public:
* \return The number of references to this object that are in use.
*/
NIFLIB_API unsigned int GetNumRefs();
private:
//private:
mutable unsigned int _ref_count;
list<NiObject*> _cross_refs;
static unsigned int objectsInMemory;
......
......@@ -121,6 +121,14 @@ public:
*/
NIFLIB_API void SetPhase( float n );
/*!
* This function will adjust the times in all the keys stored in this
* controller so that phase will equal 0 and frequency will equal one. In
* other words, it will cause the key times to be in seconds starting from
* zero.
*/
NIFLIB_API virtual void NormalizeKeys();
/*!
* Retrieves the time index where this controller begins to take affect. If the animation type is set to wrap or cycle, the animation will not occur only between these time intervals but will be mapped to the right spot between them. This value is in controller time, i.e. phase and frequency are applied to transform it to application time.
* \return The start time for the controller animation.
......
......@@ -305,10 +305,6 @@
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\AnimSequence.cpp"
>
</File>
<File
RelativePath=".\src\ComplexShape.cpp"
>
......@@ -1539,10 +1535,6 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\include\AnimSequence.h"
>
</File>
<File
RelativePath=".\include\ComplexShape.h"
>
......
/* Copyright (c) 2006, NIF File Format Library and Tools
All rights reserved. Please see niflib.h for license. */
#include "MatTexCollection.h"
#include "obj/NiGeometry.h"
#include "obj/NiAVObject.h"
#include "obj/NiNode.h"
#include "obj/NiMaterialProperty.h"
#include "obj/NiTexturingProperty.h"
#include "obj/NiTextureProperty.h"
#include "obj/NiMultiTextureProperty.h"
#include "obj/NiSpecularProperty.h"
#include "obj/NiAlphaProperty.h"
#include "obj/NiSourceTexture.h"
#include "obj/NiImage.h"
#include "../include/MatTexCollection.h"
#include "../include/obj/NiGeometry.h"
#include "../include/obj/NiAVObject.h"
#include "../include/obj/NiNode.h"
#include "../include/obj/NiMaterialProperty.h"
#include "../include/obj/NiTexturingProperty.h"
#include "../include/obj/NiTextureProperty.h"
#include "../include/obj/NiMultiTextureProperty.h"
#include "../include/obj/NiSpecularProperty.h"
#include "../include/obj/NiAlphaProperty.h"
#include "../include/obj/NiSourceTexture.h"
#include "../include/obj/NiImage.h"
namespace Niflib {
......
......@@ -42,9 +42,6 @@ void NiBSplineCompPoint3Interpolator::Read( istream& in, list<unsigned int> & li
//--END CUSTOM CODE--//
NiBSplinePoint3Interpolator::Read( in, link_stack, info );
for (unsigned int i1 = 0; i1 < 6; i1++) {
NifStream( unknownFloats[i1], in, info );
};
//--BEGIN POST-READ CUSTOM CODE--//
//--END CUSTOM CODE--//
......@@ -55,9 +52,6 @@ void NiBSplineCompPoint3Interpolator::Write( ostream& out, const map<NiObjectRef
//--END CUSTOM CODE--//
NiBSplinePoint3Interpolator::Write( out, link_map, info );
for (unsigned int i1 = 0; i1 < 6; i1++) {
NifStream( unknownFloats[i1], out, info );
};
//--BEGIN POST-WRITE CUSTOM CODE--//
//--END CUSTOM CODE--//
......@@ -70,18 +64,6 @@ std::string NiBSplineCompPoint3Interpolator::asString( bool verbose ) const {
stringstream out;
unsigned int array_output_count = 0;
out << NiBSplinePoint3Interpolator::asString();
array_output_count = 0;
for (unsigned int i1 = 0; i1 < 6; 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++;
};
return out.str();
//--BEGIN POST-STRING CUSTOM CODE--//
......
......@@ -197,6 +197,16 @@ std::list<NiObjectRef> NiGeomMorpherController::GetRefs() const {
//--BEGIN MISC CUSTOM CODE--//
void NiGeomMorpherController::NormalizeKeys() {
//Normalize any keys that are stored in Morph Data
if ( data != NULL ) {}
//Call the NiTimeController version of this function to normalize the start
//and stop times and reset the phase and frequency
NiTimeController::NormalizeKeys();
}
vector< Ref<NiInterpolator> > NiGeomMorpherController::GetInterpolators() const {
return interpolators;
}
......
......@@ -173,6 +173,16 @@ void NiTimeController::SetPhase( float n ) {
phase = n;
}
void NiTimeController::NormalizeKeys() {
//Normalize the start and stop times
startTime = frequency * startTime + phase;
stopTime = frequency * stopTime + phase;
//Set phase to 0 and frequency to 1
phase = 0.0f;
frequency = 0.0f;
}
float NiTimeController::GetStartTime() const {
return startTime;
}
......
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