Refactor: Apply editor config rules to tools
parent
83defdddc4
commit
5ae1c28881
File diff suppressed because it is too large
Load Diff
|
@ -1,169 +1,169 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
using namespace AssimpView;
|
using namespace AssimpView;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor on a given animation.
|
// Constructor on a given animation.
|
||||||
AnimEvaluator::AnimEvaluator( const aiAnimation* pAnim)
|
AnimEvaluator::AnimEvaluator( const aiAnimation* pAnim)
|
||||||
{
|
{
|
||||||
mAnim = pAnim;
|
mAnim = pAnim;
|
||||||
mLastTime = 0.0;
|
mLastTime = 0.0;
|
||||||
mLastPositions.resize( pAnim->mNumChannels, boost::make_tuple( 0, 0, 0));
|
mLastPositions.resize( pAnim->mNumChannels, boost::make_tuple( 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Evaluates the animation tracks for a given time stamp.
|
// Evaluates the animation tracks for a given time stamp.
|
||||||
void AnimEvaluator::Evaluate( double pTime)
|
void AnimEvaluator::Evaluate( double pTime)
|
||||||
{
|
{
|
||||||
// extract ticks per second. Assume default value if not given
|
// extract ticks per second. Assume default value if not given
|
||||||
double ticksPerSecond = mAnim->mTicksPerSecond != 0.0 ? mAnim->mTicksPerSecond : 25.0;
|
double ticksPerSecond = mAnim->mTicksPerSecond != 0.0 ? mAnim->mTicksPerSecond : 25.0;
|
||||||
// every following time calculation happens in ticks
|
// every following time calculation happens in ticks
|
||||||
pTime *= ticksPerSecond;
|
pTime *= ticksPerSecond;
|
||||||
|
|
||||||
// map into anim's duration
|
// map into anim's duration
|
||||||
double time = 0.0f;
|
double time = 0.0f;
|
||||||
if( mAnim->mDuration > 0.0)
|
if( mAnim->mDuration > 0.0)
|
||||||
time = fmod( pTime, mAnim->mDuration);
|
time = fmod( pTime, mAnim->mDuration);
|
||||||
|
|
||||||
if( mTransforms.size() != mAnim->mNumChannels)
|
if( mTransforms.size() != mAnim->mNumChannels)
|
||||||
mTransforms.resize( mAnim->mNumChannels);
|
mTransforms.resize( mAnim->mNumChannels);
|
||||||
|
|
||||||
// calculate the transformations for each animation channel
|
// calculate the transformations for each animation channel
|
||||||
for( unsigned int a = 0; a < mAnim->mNumChannels; a++)
|
for( unsigned int a = 0; a < mAnim->mNumChannels; a++)
|
||||||
{
|
{
|
||||||
const aiNodeAnim* channel = mAnim->mChannels[a];
|
const aiNodeAnim* channel = mAnim->mChannels[a];
|
||||||
|
|
||||||
// ******** Position *****
|
// ******** Position *****
|
||||||
aiVector3D presentPosition( 0, 0, 0);
|
aiVector3D presentPosition( 0, 0, 0);
|
||||||
if( channel->mNumPositionKeys > 0)
|
if( channel->mNumPositionKeys > 0)
|
||||||
{
|
{
|
||||||
// Look for present frame number. Search from last position if time is after the last time, else from beginning
|
// Look for present frame number. Search from last position if time is after the last time, else from beginning
|
||||||
// Should be much quicker than always looking from start for the average use case.
|
// Should be much quicker than always looking from start for the average use case.
|
||||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<0>() : 0;
|
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<0>() : 0;
|
||||||
while( frame < channel->mNumPositionKeys - 1)
|
while( frame < channel->mNumPositionKeys - 1)
|
||||||
{
|
{
|
||||||
if( time < channel->mPositionKeys[frame+1].mTime)
|
if( time < channel->mPositionKeys[frame+1].mTime)
|
||||||
break;
|
break;
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// interpolate between this frame's value and next frame's value
|
// interpolate between this frame's value and next frame's value
|
||||||
unsigned int nextFrame = (frame + 1) % channel->mNumPositionKeys;
|
unsigned int nextFrame = (frame + 1) % channel->mNumPositionKeys;
|
||||||
const aiVectorKey& key = channel->mPositionKeys[frame];
|
const aiVectorKey& key = channel->mPositionKeys[frame];
|
||||||
const aiVectorKey& nextKey = channel->mPositionKeys[nextFrame];
|
const aiVectorKey& nextKey = channel->mPositionKeys[nextFrame];
|
||||||
double diffTime = nextKey.mTime - key.mTime;
|
double diffTime = nextKey.mTime - key.mTime;
|
||||||
if( diffTime < 0.0)
|
if( diffTime < 0.0)
|
||||||
diffTime += mAnim->mDuration;
|
diffTime += mAnim->mDuration;
|
||||||
if( diffTime > 0)
|
if( diffTime > 0)
|
||||||
{
|
{
|
||||||
float factor = float( (time - key.mTime) / diffTime);
|
float factor = float( (time - key.mTime) / diffTime);
|
||||||
presentPosition = key.mValue + (nextKey.mValue - key.mValue) * factor;
|
presentPosition = key.mValue + (nextKey.mValue - key.mValue) * factor;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
presentPosition = key.mValue;
|
presentPosition = key.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastPositions[a].get<0>() = frame;
|
mLastPositions[a].get<0>() = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******** Rotation *********
|
// ******** Rotation *********
|
||||||
aiQuaternion presentRotation( 1, 0, 0, 0);
|
aiQuaternion presentRotation( 1, 0, 0, 0);
|
||||||
if( channel->mNumRotationKeys > 0)
|
if( channel->mNumRotationKeys > 0)
|
||||||
{
|
{
|
||||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<1>() : 0;
|
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<1>() : 0;
|
||||||
while( frame < channel->mNumRotationKeys - 1)
|
while( frame < channel->mNumRotationKeys - 1)
|
||||||
{
|
{
|
||||||
if( time < channel->mRotationKeys[frame+1].mTime)
|
if( time < channel->mRotationKeys[frame+1].mTime)
|
||||||
break;
|
break;
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// interpolate between this frame's value and next frame's value
|
// interpolate between this frame's value and next frame's value
|
||||||
unsigned int nextFrame = (frame + 1) % channel->mNumRotationKeys;
|
unsigned int nextFrame = (frame + 1) % channel->mNumRotationKeys;
|
||||||
const aiQuatKey& key = channel->mRotationKeys[frame];
|
const aiQuatKey& key = channel->mRotationKeys[frame];
|
||||||
const aiQuatKey& nextKey = channel->mRotationKeys[nextFrame];
|
const aiQuatKey& nextKey = channel->mRotationKeys[nextFrame];
|
||||||
double diffTime = nextKey.mTime - key.mTime;
|
double diffTime = nextKey.mTime - key.mTime;
|
||||||
if( diffTime < 0.0)
|
if( diffTime < 0.0)
|
||||||
diffTime += mAnim->mDuration;
|
diffTime += mAnim->mDuration;
|
||||||
if( diffTime > 0)
|
if( diffTime > 0)
|
||||||
{
|
{
|
||||||
float factor = float( (time - key.mTime) / diffTime);
|
float factor = float( (time - key.mTime) / diffTime);
|
||||||
aiQuaternion::Interpolate( presentRotation, key.mValue, nextKey.mValue, factor);
|
aiQuaternion::Interpolate( presentRotation, key.mValue, nextKey.mValue, factor);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
presentRotation = key.mValue;
|
presentRotation = key.mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastPositions[a].get<1>() = frame;
|
mLastPositions[a].get<1>() = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******** Scaling **********
|
// ******** Scaling **********
|
||||||
aiVector3D presentScaling( 1, 1, 1);
|
aiVector3D presentScaling( 1, 1, 1);
|
||||||
if( channel->mNumScalingKeys > 0)
|
if( channel->mNumScalingKeys > 0)
|
||||||
{
|
{
|
||||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<2>() : 0;
|
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<2>() : 0;
|
||||||
while( frame < channel->mNumScalingKeys - 1)
|
while( frame < channel->mNumScalingKeys - 1)
|
||||||
{
|
{
|
||||||
if( time < channel->mScalingKeys[frame+1].mTime)
|
if( time < channel->mScalingKeys[frame+1].mTime)
|
||||||
break;
|
break;
|
||||||
frame++;
|
frame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (thom) interpolation maybe? This time maybe even logarithmic, not linear
|
// TODO: (thom) interpolation maybe? This time maybe even logarithmic, not linear
|
||||||
presentScaling = channel->mScalingKeys[frame].mValue;
|
presentScaling = channel->mScalingKeys[frame].mValue;
|
||||||
mLastPositions[a].get<2>() = frame;
|
mLastPositions[a].get<2>() = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
// build a transformation matrix from it
|
// build a transformation matrix from it
|
||||||
aiMatrix4x4& mat = mTransforms[a];
|
aiMatrix4x4& mat = mTransforms[a];
|
||||||
mat = aiMatrix4x4( presentRotation.GetMatrix());
|
mat = aiMatrix4x4( presentRotation.GetMatrix());
|
||||||
mat.a1 *= presentScaling.x; mat.b1 *= presentScaling.x; mat.c1 *= presentScaling.x;
|
mat.a1 *= presentScaling.x; mat.b1 *= presentScaling.x; mat.c1 *= presentScaling.x;
|
||||||
mat.a2 *= presentScaling.y; mat.b2 *= presentScaling.y; mat.c2 *= presentScaling.y;
|
mat.a2 *= presentScaling.y; mat.b2 *= presentScaling.y; mat.c2 *= presentScaling.y;
|
||||||
mat.a3 *= presentScaling.z; mat.b3 *= presentScaling.z; mat.c3 *= presentScaling.z;
|
mat.a3 *= presentScaling.z; mat.b3 *= presentScaling.z; mat.c3 *= presentScaling.z;
|
||||||
mat.a4 = presentPosition.x; mat.b4 = presentPosition.y; mat.c4 = presentPosition.z;
|
mat.a4 = presentPosition.x; mat.b4 = presentPosition.y; mat.c4 = presentPosition.z;
|
||||||
//mat.Transpose();
|
//mat.Transpose();
|
||||||
}
|
}
|
||||||
|
|
||||||
mLastTime = time;
|
mLastTime = time;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,91 +1,91 @@
|
||||||
/** Calculates a pose for a given time of an animation */
|
/** Calculates a pose for a given time of an animation */
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AV_ANIMEVALUATOR_H_INCLUDED
|
#ifndef AV_ANIMEVALUATOR_H_INCLUDED
|
||||||
#define AV_ANIMEVALUATOR_H_INCLUDED
|
#define AV_ANIMEVALUATOR_H_INCLUDED
|
||||||
|
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
|
||||||
namespace AssimpView
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Calculates transformations for a given timestamp from a set of animation tracks. Not directly useful,
|
/** Calculates transformations for a given timestamp from a set of animation tracks. Not directly useful,
|
||||||
* better use the AnimPlayer class.
|
* better use the AnimPlayer class.
|
||||||
*/
|
*/
|
||||||
class AnimEvaluator
|
class AnimEvaluator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Constructor on a given animation. The animation is fixed throughout the lifetime of
|
/** Constructor on a given animation. The animation is fixed throughout the lifetime of
|
||||||
* the object.
|
* the object.
|
||||||
* @param pAnim The animation to calculate poses for. Ownership of the animation object stays
|
* @param pAnim The animation to calculate poses for. Ownership of the animation object stays
|
||||||
* at the caller, the evaluator just keeps a reference to it as long as it persists.
|
* at the caller, the evaluator just keeps a reference to it as long as it persists.
|
||||||
*/
|
*/
|
||||||
AnimEvaluator( const aiAnimation* pAnim);
|
AnimEvaluator( const aiAnimation* pAnim);
|
||||||
|
|
||||||
/** Evaluates the animation tracks for a given time stamp. The calculated pose can be retrieved as a
|
/** Evaluates the animation tracks for a given time stamp. The calculated pose can be retrieved as a
|
||||||
* array of transformation matrices afterwards by calling GetTransformations().
|
* array of transformation matrices afterwards by calling GetTransformations().
|
||||||
* @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so
|
* @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so
|
||||||
* it can be an arbitrary value. Best use with ever-increasing time stamps.
|
* it can be an arbitrary value. Best use with ever-increasing time stamps.
|
||||||
*/
|
*/
|
||||||
void Evaluate( double pTime);
|
void Evaluate( double pTime);
|
||||||
|
|
||||||
/** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of
|
/** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of
|
||||||
* the aiAnimation. */
|
* the aiAnimation. */
|
||||||
const std::vector<aiMatrix4x4>& GetTransformations() const { return mTransforms; }
|
const std::vector<aiMatrix4x4>& GetTransformations() const { return mTransforms; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** The animation we're working on */
|
/** The animation we're working on */
|
||||||
const aiAnimation* mAnim;
|
const aiAnimation* mAnim;
|
||||||
|
|
||||||
/** At which frame the last evaluation happened for each channel.
|
/** At which frame the last evaluation happened for each channel.
|
||||||
* Useful to quickly find the corresponding frame for slightly increased time stamps
|
* Useful to quickly find the corresponding frame for slightly increased time stamps
|
||||||
*/
|
*/
|
||||||
double mLastTime;
|
double mLastTime;
|
||||||
std::vector<boost::tuple<unsigned int, unsigned int, unsigned int> > mLastPositions;
|
std::vector<boost::tuple<unsigned int, unsigned int, unsigned int> > mLastPositions;
|
||||||
|
|
||||||
/** The array to store the transformations results of the evaluation */
|
/** The array to store the transformations results of the evaluation */
|
||||||
std::vector<aiMatrix4x4> mTransforms;
|
std::vector<aiMatrix4x4> mTransforms;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace AssimpView
|
} // end of namespace AssimpView
|
||||||
|
|
||||||
#endif // AV_ANIMEVALUATOR_H_INCLUDED
|
#endif // AV_ANIMEVALUATOR_H_INCLUDED
|
||||||
|
|
|
@ -1,246 +1,246 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if (!defined AV_ASSET_HELPER_H_INCLUDED)
|
#if (!defined AV_ASSET_HELPER_H_INCLUDED)
|
||||||
#define AV_ASSET_HELPER_H_INCLUDED
|
#define AV_ASSET_HELPER_H_INCLUDED
|
||||||
|
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
#include <d3dx9.h>
|
#include <d3dx9.h>
|
||||||
#include <d3dx9mesh.h>
|
#include <d3dx9mesh.h>
|
||||||
|
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
class SceneAnimator;
|
class SceneAnimator;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \brief Class to wrap ASSIMP's asset output structures
|
/** \brief Class to wrap ASSIMP's asset output structures
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class AssetHelper
|
class AssetHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// the original normal set will be used
|
// the original normal set will be used
|
||||||
ORIGINAL = 0x0u,
|
ORIGINAL = 0x0u,
|
||||||
|
|
||||||
// a smoothed normal set will be used
|
// a smoothed normal set will be used
|
||||||
SMOOTH = 0x1u,
|
SMOOTH = 0x1u,
|
||||||
|
|
||||||
// a hard normal set will be used
|
// a hard normal set will be used
|
||||||
HARD = 0x2u,
|
HARD = 0x2u,
|
||||||
};
|
};
|
||||||
|
|
||||||
// default constructor
|
// default constructor
|
||||||
AssetHelper()
|
AssetHelper()
|
||||||
: iNormalSet( ORIGINAL )
|
: iNormalSet( ORIGINAL )
|
||||||
{
|
{
|
||||||
mAnimator = NULL;
|
mAnimator = NULL;
|
||||||
apcMeshes = NULL;
|
apcMeshes = NULL;
|
||||||
pcScene = NULL;
|
pcScene = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// default vertex data structure
|
// default vertex data structure
|
||||||
// (even if tangents, bitangents or normals aren't
|
// (even if tangents, bitangents or normals aren't
|
||||||
// required by the shader they will be committed to the GPU)
|
// required by the shader they will be committed to the GPU)
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
struct Vertex
|
struct Vertex
|
||||||
{
|
{
|
||||||
aiVector3D vPosition;
|
aiVector3D vPosition;
|
||||||
aiVector3D vNormal;
|
aiVector3D vNormal;
|
||||||
|
|
||||||
D3DCOLOR dColorDiffuse;
|
D3DCOLOR dColorDiffuse;
|
||||||
aiVector3D vTangent;
|
aiVector3D vTangent;
|
||||||
aiVector3D vBitangent;
|
aiVector3D vBitangent;
|
||||||
aiVector2D vTextureUV;
|
aiVector2D vTextureUV;
|
||||||
aiVector2D vTextureUV2;
|
aiVector2D vTextureUV2;
|
||||||
unsigned char mBoneIndices[ 4 ];
|
unsigned char mBoneIndices[ 4 ];
|
||||||
unsigned char mBoneWeights[ 4 ]; // last Weight not used, calculated inside the vertex shader
|
unsigned char mBoneWeights[ 4 ]; // last Weight not used, calculated inside the vertex shader
|
||||||
|
|
||||||
/** Returns the vertex declaration elements to create a declaration from. */
|
/** Returns the vertex declaration elements to create a declaration from. */
|
||||||
static D3DVERTEXELEMENT9* GetDeclarationElements()
|
static D3DVERTEXELEMENT9* GetDeclarationElements()
|
||||||
{
|
{
|
||||||
static D3DVERTEXELEMENT9 decl[] =
|
static D3DVERTEXELEMENT9 decl[] =
|
||||||
{
|
{
|
||||||
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
||||||
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
|
{ 0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
|
||||||
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
{ 0, 24, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
||||||
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
|
{ 0, 28, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
|
||||||
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
|
{ 0, 40, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
|
||||||
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
|
{ 0, 52, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
|
||||||
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
|
{ 0, 60, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1 },
|
||||||
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
|
{ 0, 68, D3DDECLTYPE_UBYTE4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 },
|
||||||
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
|
{ 0, 72, D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 },
|
||||||
D3DDECL_END()
|
D3DDECL_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
return decl;
|
return decl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// FVF vertex structure used for normals
|
// FVF vertex structure used for normals
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
struct LineVertex
|
struct LineVertex
|
||||||
{
|
{
|
||||||
aiVector3D vPosition;
|
aiVector3D vPosition;
|
||||||
DWORD dColorDiffuse;
|
DWORD dColorDiffuse;
|
||||||
|
|
||||||
// retrieves the FVF code of the vertex type
|
// retrieves the FVF code of the vertex type
|
||||||
static DWORD GetFVF()
|
static DWORD GetFVF()
|
||||||
{
|
{
|
||||||
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
|
return D3DFVF_DIFFUSE | D3DFVF_XYZ;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Helper class to store GPU related resources created for
|
// Helper class to store GPU related resources created for
|
||||||
// a given aiMesh
|
// a given aiMesh
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
class MeshHelper
|
class MeshHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MeshHelper()
|
MeshHelper()
|
||||||
:
|
:
|
||||||
piVB( NULL ),
|
piVB( NULL ),
|
||||||
piIB( NULL ),
|
piIB( NULL ),
|
||||||
piVBNormals( NULL ),
|
piVBNormals( NULL ),
|
||||||
piEffect( NULL ),
|
piEffect( NULL ),
|
||||||
bSharedFX( false ),
|
bSharedFX( false ),
|
||||||
piDiffuseTexture( NULL ),
|
piDiffuseTexture( NULL ),
|
||||||
piSpecularTexture( NULL ),
|
piSpecularTexture( NULL ),
|
||||||
piAmbientTexture( NULL ),
|
piAmbientTexture( NULL ),
|
||||||
piEmissiveTexture( NULL ),
|
piEmissiveTexture( NULL ),
|
||||||
piNormalTexture( NULL ),
|
piNormalTexture( NULL ),
|
||||||
piOpacityTexture( NULL ),
|
piOpacityTexture( NULL ),
|
||||||
piShininessTexture( NULL ),
|
piShininessTexture( NULL ),
|
||||||
piLightmapTexture( NULL ),
|
piLightmapTexture( NULL ),
|
||||||
twosided( false ),
|
twosided( false ),
|
||||||
pvOriginalNormals( NULL )
|
pvOriginalNormals( NULL )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~MeshHelper()
|
~MeshHelper()
|
||||||
{
|
{
|
||||||
// NOTE: This is done in DeleteAssetData()
|
// NOTE: This is done in DeleteAssetData()
|
||||||
// TODO: Make this a proper d'tor
|
// TODO: Make this a proper d'tor
|
||||||
}
|
}
|
||||||
|
|
||||||
// shading mode to use. Either Lambert or otherwise phong
|
// shading mode to use. Either Lambert or otherwise phong
|
||||||
// will be used in every case
|
// will be used in every case
|
||||||
aiShadingMode eShadingMode;
|
aiShadingMode eShadingMode;
|
||||||
|
|
||||||
// vertex buffer
|
// vertex buffer
|
||||||
IDirect3DVertexBuffer9* piVB;
|
IDirect3DVertexBuffer9* piVB;
|
||||||
|
|
||||||
// index buffer. For partially transparent meshes
|
// index buffer. For partially transparent meshes
|
||||||
// created with dynamic usage to be able to update
|
// created with dynamic usage to be able to update
|
||||||
// the buffer contents quickly
|
// the buffer contents quickly
|
||||||
IDirect3DIndexBuffer9* piIB;
|
IDirect3DIndexBuffer9* piIB;
|
||||||
|
|
||||||
// vertex buffer to be used to draw vertex normals
|
// vertex buffer to be used to draw vertex normals
|
||||||
// (vertex normals are generated in every case)
|
// (vertex normals are generated in every case)
|
||||||
IDirect3DVertexBuffer9* piVBNormals;
|
IDirect3DVertexBuffer9* piVBNormals;
|
||||||
|
|
||||||
// shader to be used
|
// shader to be used
|
||||||
ID3DXEffect* piEffect;
|
ID3DXEffect* piEffect;
|
||||||
bool bSharedFX;
|
bool bSharedFX;
|
||||||
|
|
||||||
// material textures
|
// material textures
|
||||||
IDirect3DTexture9* piDiffuseTexture;
|
IDirect3DTexture9* piDiffuseTexture;
|
||||||
IDirect3DTexture9* piSpecularTexture;
|
IDirect3DTexture9* piSpecularTexture;
|
||||||
IDirect3DTexture9* piAmbientTexture;
|
IDirect3DTexture9* piAmbientTexture;
|
||||||
IDirect3DTexture9* piEmissiveTexture;
|
IDirect3DTexture9* piEmissiveTexture;
|
||||||
IDirect3DTexture9* piNormalTexture;
|
IDirect3DTexture9* piNormalTexture;
|
||||||
IDirect3DTexture9* piOpacityTexture;
|
IDirect3DTexture9* piOpacityTexture;
|
||||||
IDirect3DTexture9* piShininessTexture;
|
IDirect3DTexture9* piShininessTexture;
|
||||||
IDirect3DTexture9* piLightmapTexture;
|
IDirect3DTexture9* piLightmapTexture;
|
||||||
|
|
||||||
// material colors
|
// material colors
|
||||||
D3DXVECTOR4 vDiffuseColor;
|
D3DXVECTOR4 vDiffuseColor;
|
||||||
D3DXVECTOR4 vSpecularColor;
|
D3DXVECTOR4 vSpecularColor;
|
||||||
D3DXVECTOR4 vAmbientColor;
|
D3DXVECTOR4 vAmbientColor;
|
||||||
D3DXVECTOR4 vEmissiveColor;
|
D3DXVECTOR4 vEmissiveColor;
|
||||||
|
|
||||||
// opacity for the material
|
// opacity for the material
|
||||||
float fOpacity;
|
float fOpacity;
|
||||||
|
|
||||||
// shininess for the material
|
// shininess for the material
|
||||||
float fShininess;
|
float fShininess;
|
||||||
|
|
||||||
// strength of the specular highlight
|
// strength of the specular highlight
|
||||||
float fSpecularStrength;
|
float fSpecularStrength;
|
||||||
|
|
||||||
// two-sided?
|
// two-sided?
|
||||||
bool twosided;
|
bool twosided;
|
||||||
|
|
||||||
// Stores a pointer to the original normal set of the asset
|
// Stores a pointer to the original normal set of the asset
|
||||||
aiVector3D* pvOriginalNormals;
|
aiVector3D* pvOriginalNormals;
|
||||||
};
|
};
|
||||||
|
|
||||||
// One instance per aiMesh in the globally loaded asset
|
// One instance per aiMesh in the globally loaded asset
|
||||||
MeshHelper** apcMeshes;
|
MeshHelper** apcMeshes;
|
||||||
|
|
||||||
// Scene wrapper instance
|
// Scene wrapper instance
|
||||||
aiScene* pcScene;
|
aiScene* pcScene;
|
||||||
|
|
||||||
// Animation player to animate the scene if necessary
|
// Animation player to animate the scene if necessary
|
||||||
SceneAnimator* mAnimator;
|
SceneAnimator* mAnimator;
|
||||||
|
|
||||||
// Specifies the normal set to be used
|
// Specifies the normal set to be used
|
||||||
unsigned int iNormalSet;
|
unsigned int iNormalSet;
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// set the normal set to be used
|
// set the normal set to be used
|
||||||
void SetNormalSet( unsigned int iSet );
|
void SetNormalSet( unsigned int iSet );
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// flip all normal vectors
|
// flip all normal vectors
|
||||||
void FlipNormals();
|
void FlipNormals();
|
||||||
void FlipNormalsInt();
|
void FlipNormalsInt();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! IG
|
#endif // !! IG
|
||||||
|
|
|
@ -1,470 +1,470 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
extern std::string g_szSkyboxShader;
|
extern std::string g_szSkyboxShader;
|
||||||
|
|
||||||
// From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
|
// From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
/** \brief Vertex structure for the skybox
|
/** \brief Vertex structure for the skybox
|
||||||
*/
|
*/
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
struct SkyBoxVertex
|
struct SkyBoxVertex
|
||||||
{
|
{
|
||||||
float x,y,z;
|
float x,y,z;
|
||||||
float u,v,w;
|
float u,v,w;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
/** \brief Vertices for the skybox
|
/** \brief Vertices for the skybox
|
||||||
*/
|
*/
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
SkyBoxVertex g_cubeVertices_indexed[] =
|
SkyBoxVertex g_cubeVertices_indexed[] =
|
||||||
{
|
{
|
||||||
{ -1.0f, 1.0f, -1.0f, -1.0f,1.0f,-1.0f }, // 0
|
{ -1.0f, 1.0f, -1.0f, -1.0f,1.0f,-1.0f }, // 0
|
||||||
{ 1.0f, 1.0f, -1.0f, 1.0f,1.0f,-1.0f }, // 1
|
{ 1.0f, 1.0f, -1.0f, 1.0f,1.0f,-1.0f }, // 1
|
||||||
{ -1.0f, -1.0f, -1.0f, -1.0f,-1.0f,-1.0f }, // 2
|
{ -1.0f, -1.0f, -1.0f, -1.0f,-1.0f,-1.0f }, // 2
|
||||||
{ 1.0f,-1.0f,-1.0f, 1.0f,-1.0f,-1.0f }, // 3
|
{ 1.0f,-1.0f,-1.0f, 1.0f,-1.0f,-1.0f }, // 3
|
||||||
{-1.0f, 1.0f, 1.0f, -1.0f,1.0f,1.0f }, // 4
|
{-1.0f, 1.0f, 1.0f, -1.0f,1.0f,1.0f }, // 4
|
||||||
{-1.0f,-1.0f, 1.0f, -1.0f,-1.0f,1.0f }, // 5
|
{-1.0f,-1.0f, 1.0f, -1.0f,-1.0f,1.0f }, // 5
|
||||||
{ 1.0f, 1.0f, 1.0f, 1.0f,1.0f,1.0f }, // 6
|
{ 1.0f, 1.0f, 1.0f, 1.0f,1.0f,1.0f }, // 6
|
||||||
{ 1.0f,-1.0f, 1.0f, 1.0f,-1.0f,1.0f } // 7
|
{ 1.0f,-1.0f, 1.0f, 1.0f,-1.0f,1.0f } // 7
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
/** \brief Indices for the skybox
|
/** \brief Indices for the skybox
|
||||||
*/
|
*/
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
unsigned short g_cubeIndices[] =
|
unsigned short g_cubeIndices[] =
|
||||||
{
|
{
|
||||||
0, 1, 2, 3, 2, 1,4, 5, 6,
|
0, 1, 2, 3, 2, 1,4, 5, 6,
|
||||||
7, 6, 5, 4, 6, 0, 1, 6, 0,
|
7, 6, 5, 4, 6, 0, 1, 6, 0,
|
||||||
5, 2, 7,3, 2, 7, 1, 6, 3,
|
5, 2, 7,3, 2, 7, 1, 6, 3,
|
||||||
7, 3, 6, 0, 2, 4, 5, 4, 2,
|
7, 3, 6, 0, 2, 4, 5, 4, 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
CBackgroundPainter CBackgroundPainter::s_cInstance;
|
CBackgroundPainter CBackgroundPainter::s_cInstance;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::SetColor (D3DCOLOR p_clrNew)
|
void CBackgroundPainter::SetColor (D3DCOLOR p_clrNew)
|
||||||
{
|
{
|
||||||
if (TEXTURE_CUBE == eMode)
|
if (TEXTURE_CUBE == eMode)
|
||||||
RemoveSBDeps();
|
RemoveSBDeps();
|
||||||
|
|
||||||
clrColor = p_clrNew;
|
clrColor = p_clrNew;
|
||||||
eMode = SIMPLE_COLOR;
|
eMode = SIMPLE_COLOR;
|
||||||
|
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::RemoveSBDeps()
|
void CBackgroundPainter::RemoveSBDeps()
|
||||||
{
|
{
|
||||||
MODE e = eMode;
|
MODE e = eMode;
|
||||||
eMode = SIMPLE_COLOR;
|
eMode = SIMPLE_COLOR;
|
||||||
if (g_pcAsset && g_pcAsset->pcScene)
|
if (g_pcAsset && g_pcAsset->pcScene)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
if (aiShadingMode_Gouraud != g_pcAsset->apcMeshes[i]->eShadingMode)
|
if (aiShadingMode_Gouraud != g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||||
{
|
{
|
||||||
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
||||||
CMaterialManager::Instance().CreateMaterial(
|
CMaterialManager::Instance().CreateMaterial(
|
||||||
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eMode = e;
|
eMode = e;
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::ResetSB()
|
void CBackgroundPainter::ResetSB()
|
||||||
{
|
{
|
||||||
mMatrix = aiMatrix4x4();
|
mMatrix = aiMatrix4x4();
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::SetCubeMapBG (const char* p_szPath)
|
void CBackgroundPainter::SetCubeMapBG (const char* p_szPath)
|
||||||
{
|
{
|
||||||
bool bHad = false;
|
bool bHad = false;
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = NULL;
|
||||||
if(TEXTURE_CUBE ==eMode)bHad = true;
|
if(TEXTURE_CUBE ==eMode)bHad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
eMode = TEXTURE_CUBE;
|
eMode = TEXTURE_CUBE;
|
||||||
|
|
||||||
szPath = std::string( p_szPath );
|
szPath = std::string( p_szPath );
|
||||||
|
|
||||||
// ARRRGHH... ugly. TODO: Rewrite this!
|
// ARRRGHH... ugly. TODO: Rewrite this!
|
||||||
aiString sz;
|
aiString sz;
|
||||||
sz.Set(szPath);
|
sz.Set(szPath);
|
||||||
CMaterialManager::Instance().FindValidPath(&sz);
|
CMaterialManager::Instance().FindValidPath(&sz);
|
||||||
szPath = std::string( sz.data );
|
szPath = std::string( sz.data );
|
||||||
|
|
||||||
// now recreate all native resources
|
// now recreate all native resources
|
||||||
RecreateNativeResource();
|
RecreateNativeResource();
|
||||||
|
|
||||||
if (SIMPLE_COLOR != this->eMode)
|
if (SIMPLE_COLOR != this->eMode)
|
||||||
{
|
{
|
||||||
// this influences all material with specular components
|
// this influences all material with specular components
|
||||||
if (!bHad)
|
if (!bHad)
|
||||||
{
|
{
|
||||||
if (g_pcAsset && g_pcAsset->pcScene)
|
if (g_pcAsset && g_pcAsset->pcScene)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||||
{
|
{
|
||||||
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
||||||
CMaterialManager::Instance().CreateMaterial(
|
CMaterialManager::Instance().CreateMaterial(
|
||||||
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (g_pcAsset && g_pcAsset->pcScene)
|
if (g_pcAsset && g_pcAsset->pcScene)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||||
{
|
{
|
||||||
g_pcAsset->apcMeshes[i]->piEffect->SetTexture(
|
g_pcAsset->apcMeshes[i]->piEffect->SetTexture(
|
||||||
"lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
|
"lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::RotateSB(const aiMatrix4x4* pm)
|
void CBackgroundPainter::RotateSB(const aiMatrix4x4* pm)
|
||||||
{
|
{
|
||||||
this->mMatrix = mMatrix * (*pm);
|
this->mMatrix = mMatrix * (*pm);
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::SetTextureBG (const char* p_szPath)
|
void CBackgroundPainter::SetTextureBG (const char* p_szPath)
|
||||||
{
|
{
|
||||||
if (TEXTURE_CUBE == this->eMode)this->RemoveSBDeps();
|
if (TEXTURE_CUBE == this->eMode)this->RemoveSBDeps();
|
||||||
|
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
eMode = TEXTURE_2D;
|
eMode = TEXTURE_2D;
|
||||||
szPath = std::string( p_szPath );
|
szPath = std::string( p_szPath );
|
||||||
|
|
||||||
// ARRRGHH... ugly. TODO: Rewrite this!
|
// ARRRGHH... ugly. TODO: Rewrite this!
|
||||||
aiString sz;
|
aiString sz;
|
||||||
sz.Set(szPath);
|
sz.Set(szPath);
|
||||||
CMaterialManager::Instance().FindValidPath(&sz);
|
CMaterialManager::Instance().FindValidPath(&sz);
|
||||||
szPath = std::string( sz.data );
|
szPath = std::string( sz.data );
|
||||||
|
|
||||||
// now recreate all native resources
|
// now recreate all native resources
|
||||||
RecreateNativeResource();
|
RecreateNativeResource();
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::OnPreRender()
|
void CBackgroundPainter::OnPreRender()
|
||||||
{
|
{
|
||||||
if (SIMPLE_COLOR != eMode)
|
if (SIMPLE_COLOR != eMode)
|
||||||
{
|
{
|
||||||
// clear the z-buffer only (in wireframe mode we must also clear
|
// clear the z-buffer only (in wireframe mode we must also clear
|
||||||
// the color buffer )
|
// the color buffer )
|
||||||
if (g_sOptions.eDrawMode == RenderOptions::WIREFRAME)
|
if (g_sOptions.eDrawMode == RenderOptions::WIREFRAME)
|
||||||
{
|
{
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
|
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
|
||||||
D3DCOLOR_ARGB(0xff,100,100,100),1.0f,0);
|
D3DCOLOR_ARGB(0xff,100,100,100),1.0f,0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TEXTURE_2D == eMode)
|
if (TEXTURE_2D == eMode)
|
||||||
{
|
{
|
||||||
RECT sRect;
|
RECT sRect;
|
||||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
||||||
sRect.right -= sRect.left;
|
sRect.right -= sRect.left;
|
||||||
sRect.bottom -= sRect.top;
|
sRect.bottom -= sRect.top;
|
||||||
|
|
||||||
struct SVertex
|
struct SVertex
|
||||||
{
|
{
|
||||||
float x,y,z,w,u,v;
|
float x,y,z,w,u,v;
|
||||||
};
|
};
|
||||||
|
|
||||||
UINT dw;
|
UINT dw;
|
||||||
this->piSkyBoxEffect->Begin(&dw,0);
|
this->piSkyBoxEffect->Begin(&dw,0);
|
||||||
this->piSkyBoxEffect->BeginPass(0);
|
this->piSkyBoxEffect->BeginPass(0);
|
||||||
|
|
||||||
SVertex as[4];
|
SVertex as[4];
|
||||||
as[1].x = 0.0f;
|
as[1].x = 0.0f;
|
||||||
as[1].y = 0.0f;
|
as[1].y = 0.0f;
|
||||||
as[1].z = 0.2f;
|
as[1].z = 0.2f;
|
||||||
as[1].w = 1.0f;
|
as[1].w = 1.0f;
|
||||||
as[1].u = 0.0f;
|
as[1].u = 0.0f;
|
||||||
as[1].v = 0.0f;
|
as[1].v = 0.0f;
|
||||||
|
|
||||||
as[3].x = (float)sRect.right;
|
as[3].x = (float)sRect.right;
|
||||||
as[3].y = 0.0f;
|
as[3].y = 0.0f;
|
||||||
as[3].z = 0.2f;
|
as[3].z = 0.2f;
|
||||||
as[3].w = 1.0f;
|
as[3].w = 1.0f;
|
||||||
as[3].u = 1.0f;
|
as[3].u = 1.0f;
|
||||||
as[3].v = 0.0f;
|
as[3].v = 0.0f;
|
||||||
|
|
||||||
as[0].x = 0.0f;
|
as[0].x = 0.0f;
|
||||||
as[0].y = (float)sRect.bottom;
|
as[0].y = (float)sRect.bottom;
|
||||||
as[0].z = 0.2f;
|
as[0].z = 0.2f;
|
||||||
as[0].w = 1.0f;
|
as[0].w = 1.0f;
|
||||||
as[0].u = 0.0f;
|
as[0].u = 0.0f;
|
||||||
as[0].v = 1.0f;
|
as[0].v = 1.0f;
|
||||||
|
|
||||||
as[2].x = (float)sRect.right;
|
as[2].x = (float)sRect.right;
|
||||||
as[2].y = (float)sRect.bottom;
|
as[2].y = (float)sRect.bottom;
|
||||||
as[2].z = 0.2f;
|
as[2].z = 0.2f;
|
||||||
as[2].w = 1.0f;
|
as[2].w = 1.0f;
|
||||||
as[2].u = 1.0f;
|
as[2].u = 1.0f;
|
||||||
as[2].v = 1.0f;
|
as[2].v = 1.0f;
|
||||||
|
|
||||||
as[0].x -= 0.5f;as[1].x -= 0.5f;as[2].x -= 0.5f;as[3].x -= 0.5f;
|
as[0].x -= 0.5f;as[1].x -= 0.5f;as[2].x -= 0.5f;as[3].x -= 0.5f;
|
||||||
as[0].y -= 0.5f;as[1].y -= 0.5f;as[2].y -= 0.5f;as[3].y -= 0.5f;
|
as[0].y -= 0.5f;as[1].y -= 0.5f;as[2].y -= 0.5f;as[3].y -= 0.5f;
|
||||||
|
|
||||||
DWORD dw2;g_piDevice->GetFVF(&dw2);
|
DWORD dw2;g_piDevice->GetFVF(&dw2);
|
||||||
g_piDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
g_piDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||||
|
|
||||||
g_piDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,
|
g_piDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,
|
||||||
&as,sizeof(SVertex));
|
&as,sizeof(SVertex));
|
||||||
|
|
||||||
piSkyBoxEffect->EndPass();
|
piSkyBoxEffect->EndPass();
|
||||||
piSkyBoxEffect->End();
|
piSkyBoxEffect->End();
|
||||||
|
|
||||||
g_piDevice->SetFVF(dw2);
|
g_piDevice->SetFVF(dw2);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// clear both the render target and the z-buffer
|
// clear both the render target and the z-buffer
|
||||||
g_piDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
g_piDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||||
clrColor,1.0f,0);
|
clrColor,1.0f,0);
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::OnPostRender()
|
void CBackgroundPainter::OnPostRender()
|
||||||
{
|
{
|
||||||
if (TEXTURE_CUBE == eMode)
|
if (TEXTURE_CUBE == eMode)
|
||||||
{
|
{
|
||||||
aiMatrix4x4 pcProj;
|
aiMatrix4x4 pcProj;
|
||||||
GetProjectionMatrix(pcProj);
|
GetProjectionMatrix(pcProj);
|
||||||
|
|
||||||
aiMatrix4x4 pcCam;
|
aiMatrix4x4 pcCam;
|
||||||
aiVector3D vPos = GetCameraMatrix(pcCam);
|
aiVector3D vPos = GetCameraMatrix(pcCam);
|
||||||
|
|
||||||
aiMatrix4x4 aiMe;
|
aiMatrix4x4 aiMe;
|
||||||
aiMe[3][0] = vPos.x;
|
aiMe[3][0] = vPos.x;
|
||||||
aiMe[3][1] = vPos.y;
|
aiMe[3][1] = vPos.y;
|
||||||
aiMe[3][2] = vPos.z;
|
aiMe[3][2] = vPos.z;
|
||||||
aiMe = mMatrix * aiMe;
|
aiMe = mMatrix * aiMe;
|
||||||
|
|
||||||
pcProj = (aiMe * pcCam) * pcProj;
|
pcProj = (aiMe * pcCam) * pcProj;
|
||||||
|
|
||||||
piSkyBoxEffect->SetMatrix("WorldViewProjection",
|
piSkyBoxEffect->SetMatrix("WorldViewProjection",
|
||||||
(const D3DXMATRIX*)&pcProj);
|
(const D3DXMATRIX*)&pcProj);
|
||||||
|
|
||||||
UINT dwPasses;
|
UINT dwPasses;
|
||||||
piSkyBoxEffect->Begin(&dwPasses,0);
|
piSkyBoxEffect->Begin(&dwPasses,0);
|
||||||
piSkyBoxEffect->BeginPass(0);
|
piSkyBoxEffect->BeginPass(0);
|
||||||
|
|
||||||
DWORD dw2;
|
DWORD dw2;
|
||||||
g_piDevice->GetFVF(&dw2);
|
g_piDevice->GetFVF(&dw2);
|
||||||
g_piDevice->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
|
g_piDevice->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
|
||||||
|
|
||||||
g_piDevice->DrawIndexedPrimitiveUP(
|
g_piDevice->DrawIndexedPrimitiveUP(
|
||||||
D3DPT_TRIANGLELIST,0,8,12,g_cubeIndices,D3DFMT_INDEX16,
|
D3DPT_TRIANGLELIST,0,8,12,g_cubeIndices,D3DFMT_INDEX16,
|
||||||
g_cubeVertices_indexed,sizeof(SkyBoxVertex));
|
g_cubeVertices_indexed,sizeof(SkyBoxVertex));
|
||||||
|
|
||||||
g_piDevice->SetFVF(dw2);
|
g_piDevice->SetFVF(dw2);
|
||||||
|
|
||||||
piSkyBoxEffect->EndPass();
|
piSkyBoxEffect->EndPass();
|
||||||
piSkyBoxEffect->End();
|
piSkyBoxEffect->End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::ReleaseNativeResource()
|
void CBackgroundPainter::ReleaseNativeResource()
|
||||||
{
|
{
|
||||||
if ( piSkyBoxEffect)
|
if ( piSkyBoxEffect)
|
||||||
{
|
{
|
||||||
piSkyBoxEffect->Release();
|
piSkyBoxEffect->Release();
|
||||||
piSkyBoxEffect = NULL;
|
piSkyBoxEffect = NULL;
|
||||||
}
|
}
|
||||||
if (pcTexture)
|
if (pcTexture)
|
||||||
{
|
{
|
||||||
pcTexture->Release();
|
pcTexture->Release();
|
||||||
pcTexture = NULL;
|
pcTexture = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CBackgroundPainter::RecreateNativeResource()
|
void CBackgroundPainter::RecreateNativeResource()
|
||||||
{
|
{
|
||||||
if (SIMPLE_COLOR == eMode)return;
|
if (SIMPLE_COLOR == eMode)return;
|
||||||
if (TEXTURE_CUBE == eMode)
|
if (TEXTURE_CUBE == eMode)
|
||||||
{
|
{
|
||||||
|
|
||||||
// many skyboxes are 16bit FP format which isn't supported
|
// many skyboxes are 16bit FP format which isn't supported
|
||||||
// with bilinear filtering on older cards
|
// with bilinear filtering on older cards
|
||||||
D3DFORMAT eFmt = D3DFMT_UNKNOWN;
|
D3DFORMAT eFmt = D3DFMT_UNKNOWN;
|
||||||
if(FAILED(g_piD3D->CheckDeviceFormat(0,D3DDEVTYPE_HAL,
|
if(FAILED(g_piD3D->CheckDeviceFormat(0,D3DDEVTYPE_HAL,
|
||||||
D3DFMT_X8R8G8B8,D3DUSAGE_QUERY_FILTER,D3DRTYPE_CUBETEXTURE,D3DFMT_A16B16G16R16F)))
|
D3DFMT_X8R8G8B8,D3DUSAGE_QUERY_FILTER,D3DRTYPE_CUBETEXTURE,D3DFMT_A16B16G16R16F)))
|
||||||
{
|
{
|
||||||
eFmt = D3DFMT_A8R8G8B8;
|
eFmt = D3DFMT_A8R8G8B8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(D3DXCreateCubeTextureFromFileEx(
|
if (FAILED(D3DXCreateCubeTextureFromFileEx(
|
||||||
g_piDevice,
|
g_piDevice,
|
||||||
szPath.c_str(),
|
szPath.c_str(),
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
eFmt,
|
eFmt,
|
||||||
D3DPOOL_MANAGED,
|
D3DPOOL_MANAGED,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(IDirect3DCubeTexture9**)&pcTexture)))
|
(IDirect3DCubeTexture9**)&pcTexture)))
|
||||||
{
|
{
|
||||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||||
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
||||||
if (!szEnd)szEnd = szPath.c_str()-1;
|
if (!szEnd)szEnd = szPath.c_str()-1;
|
||||||
|
|
||||||
char szTemp[1024];
|
char szTemp[1024];
|
||||||
sprintf(szTemp,"[ERROR] Unable to load background cubemap %s",szEnd+1);
|
sprintf(szTemp,"[ERROR] Unable to load background cubemap %s",szEnd+1);
|
||||||
|
|
||||||
CLogDisplay::Instance().AddEntry(szTemp,
|
CLogDisplay::Instance().AddEntry(szTemp,
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
|
||||||
eMode = SIMPLE_COLOR;
|
eMode = SIMPLE_COLOR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else CLogDisplay::Instance().AddEntry("[OK] The skybox has been imported successfully",
|
else CLogDisplay::Instance().AddEntry("[OK] The skybox has been imported successfully",
|
||||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (FAILED(D3DXCreateTextureFromFileEx(
|
if (FAILED(D3DXCreateTextureFromFileEx(
|
||||||
g_piDevice,
|
g_piDevice,
|
||||||
szPath.c_str(),
|
szPath.c_str(),
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
D3DFMT_A8R8G8B8,
|
D3DFMT_A8R8G8B8,
|
||||||
D3DPOOL_MANAGED,
|
D3DPOOL_MANAGED,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
D3DX_DEFAULT,
|
D3DX_DEFAULT,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(IDirect3DTexture9**)&pcTexture)))
|
(IDirect3DTexture9**)&pcTexture)))
|
||||||
{
|
{
|
||||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||||
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
||||||
if (!szEnd)szEnd = szPath.c_str()-1;
|
if (!szEnd)szEnd = szPath.c_str()-1;
|
||||||
|
|
||||||
char szTemp[1024];
|
char szTemp[1024];
|
||||||
sprintf(szTemp,"[ERROR] Unable to load background texture %s",szEnd+1);
|
sprintf(szTemp,"[ERROR] Unable to load background texture %s",szEnd+1);
|
||||||
|
|
||||||
CLogDisplay::Instance().AddEntry(szTemp,
|
CLogDisplay::Instance().AddEntry(szTemp,
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
|
||||||
eMode = SIMPLE_COLOR;
|
eMode = SIMPLE_COLOR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else CLogDisplay::Instance().AddEntry("[OK] The background texture has been imported successfully",
|
else CLogDisplay::Instance().AddEntry("[OK] The background texture has been imported successfully",
|
||||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||||
}
|
}
|
||||||
if (!piSkyBoxEffect)
|
if (!piSkyBoxEffect)
|
||||||
{
|
{
|
||||||
ID3DXBuffer* piBuffer = NULL;
|
ID3DXBuffer* piBuffer = NULL;
|
||||||
if(FAILED( D3DXCreateEffect(
|
if(FAILED( D3DXCreateEffect(
|
||||||
g_piDevice,
|
g_piDevice,
|
||||||
g_szSkyboxShader.c_str(),
|
g_szSkyboxShader.c_str(),
|
||||||
(UINT)g_szSkyboxShader.length(),
|
(UINT)g_szSkyboxShader.length(),
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
AI_SHADER_COMPILE_FLAGS,
|
AI_SHADER_COMPILE_FLAGS,
|
||||||
NULL,
|
NULL,
|
||||||
&piSkyBoxEffect,&piBuffer)))
|
&piSkyBoxEffect,&piBuffer)))
|
||||||
{
|
{
|
||||||
// failed to compile the shader
|
// failed to compile the shader
|
||||||
if( piBuffer) {
|
if( piBuffer) {
|
||||||
MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK);
|
MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK);
|
||||||
piBuffer->Release();
|
piBuffer->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to compile skybox shader",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to compile skybox shader",
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
eMode = SIMPLE_COLOR;
|
eMode = SIMPLE_COLOR;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// commit the correct textures to the shader
|
// commit the correct textures to the shader
|
||||||
if (TEXTURE_CUBE == eMode)
|
if (TEXTURE_CUBE == eMode)
|
||||||
{
|
{
|
||||||
piSkyBoxEffect->SetTexture("lw_tex_envmap",pcTexture);
|
piSkyBoxEffect->SetTexture("lw_tex_envmap",pcTexture);
|
||||||
piSkyBoxEffect->SetTechnique("RenderSkyBox");
|
piSkyBoxEffect->SetTechnique("RenderSkyBox");
|
||||||
}
|
}
|
||||||
else if (TEXTURE_2D == eMode)
|
else if (TEXTURE_2D == eMode)
|
||||||
{
|
{
|
||||||
piSkyBoxEffect->SetTexture("TEXTURE_2D",pcTexture);
|
piSkyBoxEffect->SetTexture("TEXTURE_2D",pcTexture);
|
||||||
piSkyBoxEffect->SetTechnique("RenderImage2D");
|
piSkyBoxEffect->SetTechnique("RenderImage2D");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,128 +1,128 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace AssimpView
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
|
|
||||||
class CBackgroundPainter
|
class CBackgroundPainter
|
||||||
{
|
{
|
||||||
CBackgroundPainter()
|
CBackgroundPainter()
|
||||||
:
|
:
|
||||||
clrColor( D3DCOLOR_ARGB( 0xFF, 100, 100, 100 ) ),
|
clrColor( D3DCOLOR_ARGB( 0xFF, 100, 100, 100 ) ),
|
||||||
pcTexture( NULL ),
|
pcTexture( NULL ),
|
||||||
piSkyBoxEffect( NULL ),
|
piSkyBoxEffect( NULL ),
|
||||||
eMode( SIMPLE_COLOR )
|
eMode( SIMPLE_COLOR )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Supported background draw modi
|
// Supported background draw modi
|
||||||
enum MODE { SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE };
|
enum MODE { SIMPLE_COLOR, TEXTURE_2D, TEXTURE_CUBE };
|
||||||
|
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CBackgroundPainter s_cInstance;
|
static CBackgroundPainter s_cInstance;
|
||||||
inline static CBackgroundPainter& Instance()
|
inline static CBackgroundPainter& Instance()
|
||||||
{
|
{
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the current background color
|
// set the current background color
|
||||||
// (this removes any textures loaded)
|
// (this removes any textures loaded)
|
||||||
void SetColor( D3DCOLOR p_clrNew );
|
void SetColor( D3DCOLOR p_clrNew );
|
||||||
|
|
||||||
// Setup a cubemap/a 2d texture as background
|
// Setup a cubemap/a 2d texture as background
|
||||||
void SetCubeMapBG( const char* p_szPath );
|
void SetCubeMapBG( const char* p_szPath );
|
||||||
void SetTextureBG( const char* p_szPath );
|
void SetTextureBG( const char* p_szPath );
|
||||||
|
|
||||||
// Called by the render loop
|
// Called by the render loop
|
||||||
void OnPreRender();
|
void OnPreRender();
|
||||||
void OnPostRender();
|
void OnPostRender();
|
||||||
|
|
||||||
// Release any native resources associated with the instance
|
// Release any native resources associated with the instance
|
||||||
void ReleaseNativeResource();
|
void ReleaseNativeResource();
|
||||||
|
|
||||||
// Recreate any native resources associated with the instance
|
// Recreate any native resources associated with the instance
|
||||||
void RecreateNativeResource();
|
void RecreateNativeResource();
|
||||||
|
|
||||||
// Rotate the skybox
|
// Rotate the skybox
|
||||||
void RotateSB( const aiMatrix4x4* pm );
|
void RotateSB( const aiMatrix4x4* pm );
|
||||||
|
|
||||||
// Reset the state of the skybox
|
// Reset the state of the skybox
|
||||||
void ResetSB();
|
void ResetSB();
|
||||||
|
|
||||||
inline MODE GetMode() const
|
inline MODE GetMode() const
|
||||||
{
|
{
|
||||||
return this->eMode;
|
return this->eMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline IDirect3DBaseTexture9* GetTexture()
|
inline IDirect3DBaseTexture9* GetTexture()
|
||||||
{
|
{
|
||||||
return this->pcTexture;
|
return this->pcTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ID3DXBaseEffect* GetEffect()
|
inline ID3DXBaseEffect* GetEffect()
|
||||||
{
|
{
|
||||||
return this->piSkyBoxEffect;
|
return this->piSkyBoxEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void RemoveSBDeps();
|
void RemoveSBDeps();
|
||||||
|
|
||||||
// current background color
|
// current background color
|
||||||
D3DCOLOR clrColor;
|
D3DCOLOR clrColor;
|
||||||
|
|
||||||
// current background texture
|
// current background texture
|
||||||
IDirect3DBaseTexture9* pcTexture;
|
IDirect3DBaseTexture9* pcTexture;
|
||||||
ID3DXEffect* piSkyBoxEffect;
|
ID3DXEffect* piSkyBoxEffect;
|
||||||
|
|
||||||
// current background mode
|
// current background mode
|
||||||
MODE eMode;
|
MODE eMode;
|
||||||
|
|
||||||
// path to the texture
|
// path to the texture
|
||||||
std::string szPath;
|
std::string szPath;
|
||||||
|
|
||||||
// transformation matrix for the skybox
|
// transformation matrix for the skybox
|
||||||
aiMatrix4x4 mMatrix;
|
aiMatrix4x4 mMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,85 +1,85 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (!defined AV_CAMERA_H_INCLUDED)
|
#if (!defined AV_CAMERA_H_INCLUDED)
|
||||||
#define AV_CAMERA_H_INCLUDED
|
#define AV_CAMERA_H_INCLUDED
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \brief Camera class
|
/** \brief Camera class
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class Camera
|
class Camera
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
Camera ()
|
Camera ()
|
||||||
:
|
:
|
||||||
|
|
||||||
vPos(0.0f,0.0f,-10.0f),
|
vPos(0.0f,0.0f,-10.0f),
|
||||||
vUp(0.0f,1.0f,0.0f),
|
vUp(0.0f,1.0f,0.0f),
|
||||||
vLookAt(0.0f,0.0f,1.0f),
|
vLookAt(0.0f,0.0f,1.0f),
|
||||||
vRight(0.0f,1.0f,0.0f)
|
vRight(0.0f,1.0f,0.0f)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// position of the camera
|
// position of the camera
|
||||||
aiVector3D vPos;
|
aiVector3D vPos;
|
||||||
|
|
||||||
// up-vector of the camera
|
// up-vector of the camera
|
||||||
aiVector3D vUp;
|
aiVector3D vUp;
|
||||||
|
|
||||||
// camera's looking point is vPos + vLookAt
|
// camera's looking point is vPos + vLookAt
|
||||||
aiVector3D vLookAt;
|
aiVector3D vLookAt;
|
||||||
|
|
||||||
// right vector of the camera
|
// right vector of the camera
|
||||||
aiVector3D vRight;
|
aiVector3D vRight;
|
||||||
|
|
||||||
|
|
||||||
// Equation
|
// Equation
|
||||||
// (vRight ^ vUp) - vLookAt == 0
|
// (vRight ^ vUp) - vLookAt == 0
|
||||||
// needn't apply
|
// needn't apply
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#endif // !!IG
|
#endif // !!IG
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,108 +1,108 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
#include "richedit.h"
|
#include "richedit.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Message procedure for the help dialog
|
// Message procedure for the help dialog
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam)
|
WPARAM wParam,LPARAM lParam)
|
||||||
{
|
{
|
||||||
(void)lParam;
|
(void)lParam;
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
// load the help file ...
|
// load the help file ...
|
||||||
HRSRC res = FindResource(NULL,MAKEINTRESOURCE(IDR_TEXT1),"TEXT");
|
HRSRC res = FindResource(NULL,MAKEINTRESOURCE(IDR_TEXT1),"TEXT");
|
||||||
HGLOBAL hg = LoadResource(NULL,res);
|
HGLOBAL hg = LoadResource(NULL,res);
|
||||||
void* pData = LockResource(hg);
|
void* pData = LockResource(hg);
|
||||||
|
|
||||||
SETTEXTEX sInfo;
|
SETTEXTEX sInfo;
|
||||||
sInfo.flags = ST_DEFAULT;
|
sInfo.flags = ST_DEFAULT;
|
||||||
sInfo.codepage = CP_ACP;
|
sInfo.codepage = CP_ACP;
|
||||||
|
|
||||||
SendDlgItemMessage(hwndDlg,IDC_RICHEDIT21,
|
SendDlgItemMessage(hwndDlg,IDC_RICHEDIT21,
|
||||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM) pData);
|
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM) pData);
|
||||||
|
|
||||||
FreeResource(hg);
|
FreeResource(hg);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
EndDialog(hwndDlg,0);
|
EndDialog(hwndDlg,0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
|
||||||
if (IDOK == LOWORD(wParam))
|
if (IDOK == LOWORD(wParam))
|
||||||
{
|
{
|
||||||
EndDialog(hwndDlg,0);
|
EndDialog(hwndDlg,0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
PAINTSTRUCT sPaint;
|
PAINTSTRUCT sPaint;
|
||||||
HDC hdc = BeginPaint(hwndDlg,&sPaint);
|
HDC hdc = BeginPaint(hwndDlg,&sPaint);
|
||||||
|
|
||||||
HBRUSH hBrush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
|
HBRUSH hBrush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
|
||||||
|
|
||||||
RECT sRect;
|
RECT sRect;
|
||||||
sRect.left = 0;
|
sRect.left = 0;
|
||||||
sRect.top = 26;
|
sRect.top = 26;
|
||||||
sRect.right = 1000;
|
sRect.right = 1000;
|
||||||
sRect.bottom = 507;
|
sRect.bottom = 507;
|
||||||
FillRect(hdc, &sRect, hBrush);
|
FillRect(hdc, &sRect, hBrush);
|
||||||
|
|
||||||
EndPaint(hwndDlg,&sPaint);
|
EndPaint(hwndDlg,&sPaint);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,372 +1,372 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Handle mouse input for the FPS input behaviour
|
// Handle mouse input for the FPS input behaviour
|
||||||
//
|
//
|
||||||
// Movement in x and y axis is possible
|
// Movement in x and y axis is possible
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleMouseInputFPS( void )
|
void HandleMouseInputFPS( void )
|
||||||
{
|
{
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
GetCursorPos( &mousePos );
|
GetCursorPos( &mousePos );
|
||||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||||
|
|
||||||
g_mousePos.x = mousePos.x;
|
g_mousePos.x = mousePos.x;
|
||||||
g_mousePos.y = mousePos.y;
|
g_mousePos.y = mousePos.y;
|
||||||
|
|
||||||
D3DXMATRIX matRotation;
|
D3DXMATRIX matRotation;
|
||||||
|
|
||||||
if (g_bMousePressed)
|
if (g_bMousePressed)
|
||||||
{
|
{
|
||||||
int nXDiff = (g_mousePos.x - g_LastmousePos.x);
|
int nXDiff = (g_mousePos.x - g_LastmousePos.x);
|
||||||
int nYDiff = (g_mousePos.y - g_LastmousePos.y);
|
int nYDiff = (g_mousePos.y - g_LastmousePos.y);
|
||||||
|
|
||||||
if( 0 != nYDiff)
|
if( 0 != nYDiff)
|
||||||
{
|
{
|
||||||
D3DXMatrixRotationAxis( &matRotation, (D3DXVECTOR3*)& g_sCamera.vRight, D3DXToRadian((float)nYDiff / 6.0f));
|
D3DXMatrixRotationAxis( &matRotation, (D3DXVECTOR3*)& g_sCamera.vRight, D3DXToRadian((float)nYDiff / 6.0f));
|
||||||
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vLookAt, (D3DXVECTOR3*)& g_sCamera.vLookAt, &matRotation );
|
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vLookAt, (D3DXVECTOR3*)& g_sCamera.vLookAt, &matRotation );
|
||||||
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vUp, (D3DXVECTOR3*)&g_sCamera.vUp, &matRotation );
|
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vUp, (D3DXVECTOR3*)&g_sCamera.vUp, &matRotation );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( 0 != nXDiff )
|
if( 0 != nXDiff )
|
||||||
{
|
{
|
||||||
D3DXVECTOR3 v(0,1,0);
|
D3DXVECTOR3 v(0,1,0);
|
||||||
D3DXMatrixRotationAxis( &matRotation, (D3DXVECTOR3*)&g_sCamera.vUp, D3DXToRadian((float)nXDiff / 6.0f) );
|
D3DXMatrixRotationAxis( &matRotation, (D3DXVECTOR3*)&g_sCamera.vUp, D3DXToRadian((float)nXDiff / 6.0f) );
|
||||||
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vLookAt, (D3DXVECTOR3*)&g_sCamera.vLookAt, &matRotation );
|
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vLookAt, (D3DXVECTOR3*)&g_sCamera.vLookAt, &matRotation );
|
||||||
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vRight,(D3DXVECTOR3*) &g_sCamera.vRight, &matRotation );
|
D3DXVec3TransformCoord( (D3DXVECTOR3*)&g_sCamera.vRight,(D3DXVECTOR3*) &g_sCamera.vRight, &matRotation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_LastmousePos.x = g_mousePos.x;
|
g_LastmousePos.x = g_mousePos.x;
|
||||||
g_LastmousePos.y = g_mousePos.y;
|
g_LastmousePos.y = g_mousePos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Handle mouse input for the FPS input behaviour
|
// Handle mouse input for the FPS input behaviour
|
||||||
//
|
//
|
||||||
// Movement in x and y axis is possible
|
// Movement in x and y axis is possible
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleMouseInputTextureView( void )
|
void HandleMouseInputTextureView( void )
|
||||||
{
|
{
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
GetCursorPos( &mousePos );
|
GetCursorPos( &mousePos );
|
||||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||||
|
|
||||||
g_mousePos.x = mousePos.x;
|
g_mousePos.x = mousePos.x;
|
||||||
g_mousePos.y = mousePos.y;
|
g_mousePos.y = mousePos.y;
|
||||||
|
|
||||||
D3DXMATRIX matRotation;
|
D3DXMATRIX matRotation;
|
||||||
|
|
||||||
if (g_bMousePressed)
|
if (g_bMousePressed)
|
||||||
{
|
{
|
||||||
CDisplay::Instance().SetTextureViewOffsetX((float)(g_mousePos.x - g_LastmousePos.x));
|
CDisplay::Instance().SetTextureViewOffsetX((float)(g_mousePos.x - g_LastmousePos.x));
|
||||||
CDisplay::Instance().SetTextureViewOffsetY((float)(g_mousePos.y - g_LastmousePos.y));
|
CDisplay::Instance().SetTextureViewOffsetY((float)(g_mousePos.y - g_LastmousePos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_LastmousePos.x = g_mousePos.x;
|
g_LastmousePos.x = g_mousePos.x;
|
||||||
g_LastmousePos.y = g_mousePos.y;
|
g_LastmousePos.y = g_mousePos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// handle mouse input for the light rotation
|
// handle mouse input for the light rotation
|
||||||
//
|
//
|
||||||
// Axes: global x/y axis
|
// Axes: global x/y axis
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleMouseInputLightRotate( void )
|
void HandleMouseInputLightRotate( void )
|
||||||
{
|
{
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
GetCursorPos( &mousePos );
|
GetCursorPos( &mousePos );
|
||||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||||
|
|
||||||
g_mousePos.x = mousePos.x;
|
g_mousePos.x = mousePos.x;
|
||||||
g_mousePos.y = mousePos.y;
|
g_mousePos.y = mousePos.y;
|
||||||
|
|
||||||
if (g_bMousePressedR)
|
if (g_bMousePressedR)
|
||||||
{
|
{
|
||||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||||
|
|
||||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||||
aiMatrix4x4 mTemp;
|
aiMatrix4x4 mTemp;
|
||||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||||
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
||||||
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
||||||
|
|
||||||
v = aiVector3D(0.0f,1.0f,0.0f);
|
v = aiVector3D(0.0f,1.0f,0.0f);
|
||||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f));
|
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f));
|
||||||
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
||||||
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Handle mouse input for movements of the skybox
|
// Handle mouse input for movements of the skybox
|
||||||
//
|
//
|
||||||
// The skybox can be moved by holding both the left and the right mouse button
|
// The skybox can be moved by holding both the left and the right mouse button
|
||||||
// pressed. Rotation is possible in x and y direction.
|
// pressed. Rotation is possible in x and y direction.
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleMouseInputSkyBox( void )
|
void HandleMouseInputSkyBox( void )
|
||||||
{
|
{
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
GetCursorPos( &mousePos );
|
GetCursorPos( &mousePos );
|
||||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||||
|
|
||||||
g_mousePos.x = mousePos.x;
|
g_mousePos.x = mousePos.x;
|
||||||
g_mousePos.y = mousePos.y;
|
g_mousePos.y = mousePos.y;
|
||||||
|
|
||||||
aiMatrix4x4 matRotation;
|
aiMatrix4x4 matRotation;
|
||||||
|
|
||||||
if (g_bMousePressedBoth )
|
if (g_bMousePressedBoth )
|
||||||
{
|
{
|
||||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||||
|
|
||||||
aiMatrix4x4 matWorld;
|
aiMatrix4x4 matWorld;
|
||||||
|
|
||||||
if( 0 != nYDiff)
|
if( 0 != nYDiff)
|
||||||
{
|
{
|
||||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||||
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( 0 != nXDiff)
|
if( 0 != nXDiff)
|
||||||
{
|
{
|
||||||
aiMatrix4x4 matWorldOld;
|
aiMatrix4x4 matWorldOld;
|
||||||
if( 0 != nYDiff)
|
if( 0 != nYDiff)
|
||||||
{
|
{
|
||||||
matWorldOld = matWorld;
|
matWorldOld = matWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
||||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
||||||
matWorld = matWorldOld * matWorld;
|
matWorld = matWorldOld * matWorld;
|
||||||
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleMouseInputLightIntensityAndColor( void )
|
void HandleMouseInputLightIntensityAndColor( void )
|
||||||
{
|
{
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
GetCursorPos( &mousePos );
|
GetCursorPos( &mousePos );
|
||||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||||
|
|
||||||
g_mousePos.x = mousePos.x;
|
g_mousePos.x = mousePos.x;
|
||||||
g_mousePos.y = mousePos.y;
|
g_mousePos.y = mousePos.y;
|
||||||
|
|
||||||
if (g_bMousePressedM)
|
if (g_bMousePressedM)
|
||||||
{
|
{
|
||||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||||
|
|
||||||
g_fLightIntensity -= (float)nXDiff / 400.0f;
|
g_fLightIntensity -= (float)nXDiff / 400.0f;
|
||||||
if ((nYDiff > 2 || nYDiff < -2) && (nXDiff < 20 && nXDiff > -20))
|
if ((nYDiff > 2 || nYDiff < -2) && (nXDiff < 20 && nXDiff > -20))
|
||||||
{
|
{
|
||||||
if (!g_bFPSView)
|
if (!g_bFPSView)
|
||||||
{
|
{
|
||||||
g_sCamera.vPos.z += nYDiff / 120.0f;
|
g_sCamera.vPos.z += nYDiff / 120.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_sCamera.vPos += (nYDiff / 120.0f) * g_sCamera.vLookAt.Normalize();
|
g_sCamera.vPos += (nYDiff / 120.0f) * g_sCamera.vLookAt.Normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleMouseInputLocal( void )
|
void HandleMouseInputLocal( void )
|
||||||
{
|
{
|
||||||
POINT mousePos;
|
POINT mousePos;
|
||||||
GetCursorPos( &mousePos );
|
GetCursorPos( &mousePos );
|
||||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||||
|
|
||||||
g_mousePos.x = mousePos.x;
|
g_mousePos.x = mousePos.x;
|
||||||
g_mousePos.y = mousePos.y;
|
g_mousePos.y = mousePos.y;
|
||||||
|
|
||||||
aiMatrix4x4 matRotation;
|
aiMatrix4x4 matRotation;
|
||||||
|
|
||||||
if (g_bMousePressed)
|
if (g_bMousePressed)
|
||||||
{
|
{
|
||||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||||
|
|
||||||
aiMatrix4x4 matWorld;
|
aiMatrix4x4 matWorld;
|
||||||
if (g_eClick != EClickPos_Outside)
|
if (g_eClick != EClickPos_Outside)
|
||||||
{
|
{
|
||||||
if( 0 != nYDiff && g_eClick != EClickPos_CircleHor)
|
if( 0 != nYDiff && g_eClick != EClickPos_CircleHor)
|
||||||
{
|
{
|
||||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( 0 != nXDiff && g_eClick != EClickPos_CircleVert)
|
if( 0 != nXDiff && g_eClick != EClickPos_CircleVert)
|
||||||
{
|
{
|
||||||
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
||||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
||||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(0 != nYDiff || 0 != nXDiff)
|
if(0 != nYDiff || 0 != nXDiff)
|
||||||
{
|
{
|
||||||
// rotate around the z-axis
|
// rotate around the z-axis
|
||||||
RECT sRect;
|
RECT sRect;
|
||||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
||||||
sRect.right -= sRect.left;
|
sRect.right -= sRect.left;
|
||||||
sRect.bottom -= sRect.top;
|
sRect.bottom -= sRect.top;
|
||||||
|
|
||||||
int xPos = g_mousePos.x - sRect.right/2;
|
int xPos = g_mousePos.x - sRect.right/2;
|
||||||
int yPos = g_mousePos.y - sRect.bottom/2;
|
int yPos = g_mousePos.y - sRect.bottom/2;
|
||||||
float fXDist = (float)xPos;
|
float fXDist = (float)xPos;
|
||||||
float fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
float fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
||||||
|
|
||||||
bool bSign1;
|
bool bSign1;
|
||||||
if (fXDist < 0.0f)bSign1 = false;
|
if (fXDist < 0.0f)bSign1 = false;
|
||||||
else bSign1 = true;
|
else bSign1 = true;
|
||||||
float fAngle = asin(fYDist);
|
float fAngle = asin(fYDist);
|
||||||
|
|
||||||
xPos = g_LastmousePos.x - sRect.right/2;
|
xPos = g_LastmousePos.x - sRect.right/2;
|
||||||
yPos = g_LastmousePos.y - sRect.bottom/2;
|
yPos = g_LastmousePos.y - sRect.bottom/2;
|
||||||
|
|
||||||
fXDist = (float)xPos;
|
fXDist = (float)xPos;
|
||||||
fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
||||||
|
|
||||||
bool bSign2;
|
bool bSign2;
|
||||||
if (fXDist < 0.0f)bSign2 = false;
|
if (fXDist < 0.0f)bSign2 = false;
|
||||||
else bSign2 = true;
|
else bSign2 = true;
|
||||||
float fAngle2 = asin(fYDist);
|
float fAngle2 = asin(fYDist);
|
||||||
fAngle -= fAngle2;
|
fAngle -= fAngle2;
|
||||||
|
|
||||||
if (bSign1 != bSign2)
|
if (bSign1 != bSign2)
|
||||||
{
|
{
|
||||||
g_bInvert = !g_bInvert;
|
g_bInvert = !g_bInvert;
|
||||||
}
|
}
|
||||||
if (g_bInvert)fAngle *= -1.0f;
|
if (g_bInvert)fAngle *= -1.0f;
|
||||||
|
|
||||||
aiVector3D v = aiVector3D(0.0f,0.0f,1.0f);
|
aiVector3D v = aiVector3D(0.0f,0.0f,1.0f);
|
||||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, (float) (fAngle * 1.2) );
|
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, (float) (fAngle * 1.2) );
|
||||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_LastmousePos.x = g_mousePos.x;
|
g_LastmousePos.x = g_mousePos.x;
|
||||||
g_LastmousePos.y = g_mousePos.y;
|
g_LastmousePos.y = g_mousePos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleKeyboardInputFPS( void )
|
void HandleKeyboardInputFPS( void )
|
||||||
{
|
{
|
||||||
unsigned char keys[256];
|
unsigned char keys[256];
|
||||||
GetKeyboardState( keys );
|
GetKeyboardState( keys );
|
||||||
|
|
||||||
aiVector3D tmpLook = g_sCamera.vLookAt;
|
aiVector3D tmpLook = g_sCamera.vLookAt;
|
||||||
aiVector3D tmpRight = g_sCamera.vRight;
|
aiVector3D tmpRight = g_sCamera.vRight;
|
||||||
|
|
||||||
aiVector3D vOldPos = g_sCamera.vPos;
|
aiVector3D vOldPos = g_sCamera.vPos;
|
||||||
|
|
||||||
// Up Arrow Key - View moves forward
|
// Up Arrow Key - View moves forward
|
||||||
if( keys[VK_UP] & 0x80 )
|
if( keys[VK_UP] & 0x80 )
|
||||||
g_sCamera.vPos -= (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
g_sCamera.vPos -= (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
||||||
|
|
||||||
// Down Arrow Key - View moves backward
|
// Down Arrow Key - View moves backward
|
||||||
if( keys[VK_DOWN] & 0x80 )
|
if( keys[VK_DOWN] & 0x80 )
|
||||||
g_sCamera.vPos += (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
g_sCamera.vPos += (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
||||||
|
|
||||||
// Left Arrow Key - View side-steps or strafes to the left
|
// Left Arrow Key - View side-steps or strafes to the left
|
||||||
if( keys[VK_LEFT] & 0x80 )
|
if( keys[VK_LEFT] & 0x80 )
|
||||||
g_sCamera.vPos -= (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
g_sCamera.vPos -= (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
||||||
|
|
||||||
// Right Arrow Key - View side-steps or strafes to the right
|
// Right Arrow Key - View side-steps or strafes to the right
|
||||||
if( keys[VK_RIGHT] & 0x80 )
|
if( keys[VK_RIGHT] & 0x80 )
|
||||||
g_sCamera.vPos += (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
g_sCamera.vPos += (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
||||||
|
|
||||||
// Home Key - View elevates up
|
// Home Key - View elevates up
|
||||||
if( keys[VK_HOME] & 0x80 )
|
if( keys[VK_HOME] & 0x80 )
|
||||||
g_sCamera.vPos .y += MOVE_SPEED*g_fElpasedTime;
|
g_sCamera.vPos .y += MOVE_SPEED*g_fElpasedTime;
|
||||||
|
|
||||||
// End Key - View elevates down
|
// End Key - View elevates down
|
||||||
if( keys[VK_END] & 0x80 )
|
if( keys[VK_END] & 0x80 )
|
||||||
g_sCamera.vPos.y -= MOVE_SPEED*g_fElpasedTime;
|
g_sCamera.vPos.y -= MOVE_SPEED*g_fElpasedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleKeyboardInputTextureView( void )
|
void HandleKeyboardInputTextureView( void )
|
||||||
{
|
{
|
||||||
unsigned char keys[256];
|
unsigned char keys[256];
|
||||||
GetKeyboardState( keys );
|
GetKeyboardState( keys );
|
||||||
|
|
||||||
// Up Arrow Key
|
// Up Arrow Key
|
||||||
if( keys[VK_UP] & 0x80 )
|
if( keys[VK_UP] & 0x80 )
|
||||||
CDisplay::Instance().SetTextureViewOffsetY ( g_fElpasedTime * 150.0f );
|
CDisplay::Instance().SetTextureViewOffsetY ( g_fElpasedTime * 150.0f );
|
||||||
|
|
||||||
// Down Arrow Key
|
// Down Arrow Key
|
||||||
if( keys[VK_DOWN] & 0x80 )
|
if( keys[VK_DOWN] & 0x80 )
|
||||||
CDisplay::Instance().SetTextureViewOffsetY ( -g_fElpasedTime * 150.0f );
|
CDisplay::Instance().SetTextureViewOffsetY ( -g_fElpasedTime * 150.0f );
|
||||||
|
|
||||||
// Left Arrow Key
|
// Left Arrow Key
|
||||||
if( keys[VK_LEFT] & 0x80 )
|
if( keys[VK_LEFT] & 0x80 )
|
||||||
CDisplay::Instance().SetTextureViewOffsetX ( g_fElpasedTime * 150.0f );
|
CDisplay::Instance().SetTextureViewOffsetX ( g_fElpasedTime * 150.0f );
|
||||||
|
|
||||||
// Right Arrow Key
|
// Right Arrow Key
|
||||||
if( keys[VK_RIGHT] & 0x80 )
|
if( keys[VK_RIGHT] & 0x80 )
|
||||||
CDisplay::Instance().SetTextureViewOffsetX ( -g_fElpasedTime * 150.0f );
|
CDisplay::Instance().SetTextureViewOffsetX ( -g_fElpasedTime * 150.0f );
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,233 +1,233 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
CLogDisplay CLogDisplay::s_cInstance;
|
CLogDisplay CLogDisplay::s_cInstance;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogDisplay::AddEntry(const std::string& szText,
|
void CLogDisplay::AddEntry(const std::string& szText,
|
||||||
const D3DCOLOR clrColor)
|
const D3DCOLOR clrColor)
|
||||||
{
|
{
|
||||||
SEntry sNew;
|
SEntry sNew;
|
||||||
sNew.clrColor = clrColor;
|
sNew.clrColor = clrColor;
|
||||||
sNew.szText = szText;
|
sNew.szText = szText;
|
||||||
sNew.dwStartTicks = (DWORD)GetTickCount();
|
sNew.dwStartTicks = (DWORD)GetTickCount();
|
||||||
|
|
||||||
this->asEntries.push_back(sNew);
|
this->asEntries.push_back(sNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogDisplay::ReleaseNativeResource()
|
void CLogDisplay::ReleaseNativeResource()
|
||||||
{
|
{
|
||||||
if (this->piFont)
|
if (this->piFont)
|
||||||
{
|
{
|
||||||
this->piFont->Release();
|
this->piFont->Release();
|
||||||
this->piFont = NULL;
|
this->piFont = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogDisplay::RecreateNativeResource()
|
void CLogDisplay::RecreateNativeResource()
|
||||||
{
|
{
|
||||||
if (!this->piFont)
|
if (!this->piFont)
|
||||||
{
|
{
|
||||||
if (FAILED(D3DXCreateFont(g_piDevice,
|
if (FAILED(D3DXCreateFont(g_piDevice,
|
||||||
16, //Font height
|
16, //Font height
|
||||||
0, //Font width
|
0, //Font width
|
||||||
FW_BOLD, //Font Weight
|
FW_BOLD, //Font Weight
|
||||||
1, //MipLevels
|
1, //MipLevels
|
||||||
false, //Italic
|
false, //Italic
|
||||||
DEFAULT_CHARSET, //CharSet
|
DEFAULT_CHARSET, //CharSet
|
||||||
OUT_DEFAULT_PRECIS, //OutputPrecision
|
OUT_DEFAULT_PRECIS, //OutputPrecision
|
||||||
//CLEARTYPE_QUALITY, //Quality
|
//CLEARTYPE_QUALITY, //Quality
|
||||||
5, //Quality
|
5, //Quality
|
||||||
DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily
|
DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily
|
||||||
"Verdana", //pFacename,
|
"Verdana", //pFacename,
|
||||||
&this->piFont)))
|
&this->piFont)))
|
||||||
{
|
{
|
||||||
CLogDisplay::Instance().AddEntry("Unable to load font",D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
CLogDisplay::Instance().AddEntry("Unable to load font",D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||||
|
|
||||||
this->piFont = NULL;
|
this->piFont = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogDisplay::OnRender()
|
void CLogDisplay::OnRender()
|
||||||
{
|
{
|
||||||
DWORD dwTick = (DWORD) GetTickCount();
|
DWORD dwTick = (DWORD) GetTickCount();
|
||||||
DWORD dwLimit = dwTick - 8000;
|
DWORD dwLimit = dwTick - 8000;
|
||||||
DWORD dwLimit2 = dwLimit + 3000;
|
DWORD dwLimit2 = dwLimit + 3000;
|
||||||
|
|
||||||
unsigned int iCnt = 0;
|
unsigned int iCnt = 0;
|
||||||
RECT sRect;
|
RECT sRect;
|
||||||
sRect.left = 10;
|
sRect.left = 10;
|
||||||
sRect.top = 10;
|
sRect.top = 10;
|
||||||
|
|
||||||
RECT sWndRect;
|
RECT sWndRect;
|
||||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sWndRect);
|
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sWndRect);
|
||||||
sWndRect.right -= sWndRect.left;
|
sWndRect.right -= sWndRect.left;
|
||||||
sWndRect.bottom -= sWndRect.top;
|
sWndRect.bottom -= sWndRect.top;
|
||||||
sWndRect.left = sWndRect.top = 0;
|
sWndRect.left = sWndRect.top = 0;
|
||||||
|
|
||||||
sRect.right = sWndRect.right - 30;
|
sRect.right = sWndRect.right - 30;
|
||||||
sRect.bottom = sWndRect.bottom;
|
sRect.bottom = sWndRect.bottom;
|
||||||
|
|
||||||
// if no asset is loaded draw a "no asset loaded" text in the center
|
// if no asset is loaded draw a "no asset loaded" text in the center
|
||||||
if (!g_pcAsset)
|
if (!g_pcAsset)
|
||||||
{
|
{
|
||||||
const char* szText = "Nothing to display ... \r\nTry [Viewer | Open asset] to load an asset";
|
const char* szText = "Nothing to display ... \r\nTry [Viewer | Open asset] to load an asset";
|
||||||
|
|
||||||
// shadow
|
// shadow
|
||||||
RECT sCopy;
|
RECT sCopy;
|
||||||
sCopy.left = sWndRect.left+1;
|
sCopy.left = sWndRect.left+1;
|
||||||
sCopy.top = sWndRect.top+1;
|
sCopy.top = sWndRect.top+1;
|
||||||
sCopy.bottom = sWndRect.bottom+1;
|
sCopy.bottom = sWndRect.bottom+1;
|
||||||
sCopy.right = sWndRect.right+1;
|
sCopy.right = sWndRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(NULL,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
sCopy.left = sWndRect.left+1;
|
sCopy.left = sWndRect.left+1;
|
||||||
sCopy.top = sWndRect.top+1;
|
sCopy.top = sWndRect.top+1;
|
||||||
sCopy.bottom = sWndRect.bottom-1;
|
sCopy.bottom = sWndRect.bottom-1;
|
||||||
sCopy.right = sWndRect.right-1;
|
sCopy.right = sWndRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(NULL,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
sCopy.left = sWndRect.left-1;
|
sCopy.left = sWndRect.left-1;
|
||||||
sCopy.top = sWndRect.top-1;
|
sCopy.top = sWndRect.top-1;
|
||||||
sCopy.bottom = sWndRect.bottom+1;
|
sCopy.bottom = sWndRect.bottom+1;
|
||||||
sCopy.right = sWndRect.right+1;
|
sCopy.right = sWndRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(NULL,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
sCopy.left = sWndRect.left-1;
|
sCopy.left = sWndRect.left-1;
|
||||||
sCopy.top = sWndRect.top-1;
|
sCopy.top = sWndRect.top-1;
|
||||||
sCopy.bottom = sWndRect.bottom-1;
|
sCopy.bottom = sWndRect.bottom-1;
|
||||||
sCopy.right = sWndRect.right-1;
|
sCopy.right = sWndRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(NULL,szText ,
|
||||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||||
|
|
||||||
// text
|
// text
|
||||||
this->piFont->DrawText(NULL,szText ,
|
this->piFont->DrawText(NULL,szText ,
|
||||||
-1,&sWndRect,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF));
|
-1,&sWndRect,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
// update all elements in the queue and render them
|
// update all elements in the queue and render them
|
||||||
for (std::list<SEntry>::iterator
|
for (std::list<SEntry>::iterator
|
||||||
i = this->asEntries.begin();
|
i = this->asEntries.begin();
|
||||||
i != this->asEntries.end();++i,++iCnt)
|
i != this->asEntries.end();++i,++iCnt)
|
||||||
{
|
{
|
||||||
if ((*i).dwStartTicks < dwLimit)
|
if ((*i).dwStartTicks < dwLimit)
|
||||||
{
|
{
|
||||||
i = this->asEntries.erase(i);
|
i = this->asEntries.erase(i);
|
||||||
|
|
||||||
if(i == this->asEntries.end())break;
|
if(i == this->asEntries.end())break;
|
||||||
}
|
}
|
||||||
else if (NULL != this->piFont)
|
else if (NULL != this->piFont)
|
||||||
{
|
{
|
||||||
float fAlpha = 1.0f;
|
float fAlpha = 1.0f;
|
||||||
if ((*i).dwStartTicks <= dwLimit2)
|
if ((*i).dwStartTicks <= dwLimit2)
|
||||||
{
|
{
|
||||||
// linearly interpolate to create the fade out effect
|
// linearly interpolate to create the fade out effect
|
||||||
fAlpha = 1.0f - (float)(dwLimit2 - (*i).dwStartTicks) / 3000.0f;
|
fAlpha = 1.0f - (float)(dwLimit2 - (*i).dwStartTicks) / 3000.0f;
|
||||||
}
|
}
|
||||||
D3DCOLOR& clrColor = (*i).clrColor;
|
D3DCOLOR& clrColor = (*i).clrColor;
|
||||||
clrColor &= ~(0xFFu << 24);
|
clrColor &= ~(0xFFu << 24);
|
||||||
clrColor |= (((unsigned char)(fAlpha * 255.0f)) & 0xFFu) << 24;
|
clrColor |= (((unsigned char)(fAlpha * 255.0f)) & 0xFFu) << 24;
|
||||||
|
|
||||||
const char* szText = (*i).szText.c_str();
|
const char* szText = (*i).szText.c_str();
|
||||||
if (sRect.top + 30 > sWndRect.bottom)
|
if (sRect.top + 30 > sWndRect.bottom)
|
||||||
{
|
{
|
||||||
// end of window. send a special message
|
// end of window. send a special message
|
||||||
szText = "... too many errors";
|
szText = "... too many errors";
|
||||||
clrColor = D3DCOLOR_ARGB(0xFF,0xFF,100,0x0);
|
clrColor = D3DCOLOR_ARGB(0xFF,0xFF,100,0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw the black shadow
|
// draw the black shadow
|
||||||
RECT sCopy;
|
RECT sCopy;
|
||||||
sCopy.left = sRect.left+1;
|
sCopy.left = sRect.left+1;
|
||||||
sCopy.top = sRect.top+1;
|
sCopy.top = sRect.top+1;
|
||||||
sCopy.bottom = sRect.bottom+1;
|
sCopy.bottom = sRect.bottom+1;
|
||||||
sCopy.right = sRect.right+1;
|
sCopy.right = sRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(NULL,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
sCopy.left = sRect.left-1;
|
sCopy.left = sRect.left-1;
|
||||||
sCopy.top = sRect.top-1;
|
sCopy.top = sRect.top-1;
|
||||||
sCopy.bottom = sRect.bottom-1;
|
sCopy.bottom = sRect.bottom-1;
|
||||||
sCopy.right = sRect.right-1;
|
sCopy.right = sRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(NULL,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
sCopy.left = sRect.left-1;
|
sCopy.left = sRect.left-1;
|
||||||
sCopy.top = sRect.top-1;
|
sCopy.top = sRect.top-1;
|
||||||
sCopy.bottom = sRect.bottom+1;
|
sCopy.bottom = sRect.bottom+1;
|
||||||
sCopy.right = sRect.right+1;
|
sCopy.right = sRect.right+1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(NULL,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
sCopy.left = sRect.left+1;
|
sCopy.left = sRect.left+1;
|
||||||
sCopy.top = sRect.top+1;
|
sCopy.top = sRect.top+1;
|
||||||
sCopy.bottom = sRect.bottom-1;
|
sCopy.bottom = sRect.bottom-1;
|
||||||
sCopy.right = sRect.right-1;
|
sCopy.right = sRect.right-1;
|
||||||
this->piFont->DrawText(NULL,szText,
|
this->piFont->DrawText(NULL,szText,
|
||||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||||
|
|
||||||
// draw the text itself
|
// draw the text itself
|
||||||
int iPX = this->piFont->DrawText(NULL,szText,
|
int iPX = this->piFont->DrawText(NULL,szText,
|
||||||
-1,&sRect,DT_RIGHT | DT_TOP,clrColor);
|
-1,&sRect,DT_RIGHT | DT_TOP,clrColor);
|
||||||
|
|
||||||
sRect.top += iPX;
|
sRect.top += iPX;
|
||||||
sRect.bottom += iPX;
|
sRect.bottom += iPX;
|
||||||
|
|
||||||
if (szText != (*i).szText.c_str())break;
|
if (szText != (*i).szText.c_str())break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,99 +1,99 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace AssimpView
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \brief Class to display log strings in the upper right corner of the view
|
/** \brief Class to display log strings in the upper right corner of the view
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class CLogDisplay
|
class CLogDisplay
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CLogDisplay() {}
|
CLogDisplay() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// data structure for an entry in the log queue
|
// data structure for an entry in the log queue
|
||||||
struct SEntry
|
struct SEntry
|
||||||
{
|
{
|
||||||
SEntry()
|
SEntry()
|
||||||
:
|
:
|
||||||
clrColor( D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) ), dwStartTicks( 0 )
|
clrColor( D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) ), dwStartTicks( 0 )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string szText;
|
std::string szText;
|
||||||
D3DCOLOR clrColor;
|
D3DCOLOR clrColor;
|
||||||
DWORD dwStartTicks;
|
DWORD dwStartTicks;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CLogDisplay s_cInstance;
|
static CLogDisplay s_cInstance;
|
||||||
inline static CLogDisplay& Instance()
|
inline static CLogDisplay& Instance()
|
||||||
{
|
{
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an entry to the log queue
|
// Add an entry to the log queue
|
||||||
void AddEntry( const std::string& szText,
|
void AddEntry( const std::string& szText,
|
||||||
const D3DCOLOR clrColor = D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) );
|
const D3DCOLOR clrColor = D3DCOLOR_ARGB( 0xFF, 0xFF, 0xFF, 0x00 ) );
|
||||||
|
|
||||||
// Release any native resources associated with the instance
|
// Release any native resources associated with the instance
|
||||||
void ReleaseNativeResource();
|
void ReleaseNativeResource();
|
||||||
|
|
||||||
// Recreate any native resources associated with the instance
|
// Recreate any native resources associated with the instance
|
||||||
void RecreateNativeResource();
|
void RecreateNativeResource();
|
||||||
|
|
||||||
// Called during the render loop
|
// Called during the render loop
|
||||||
void OnRender();
|
void OnRender();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::list<SEntry> asEntries;
|
std::list<SEntry> asEntries;
|
||||||
ID3DXFont* piFont;
|
ID3DXFont* piFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,255 +1,255 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
#include "richedit.h"
|
#include "richedit.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
CLogWindow CLogWindow::s_cInstance;
|
CLogWindow CLogWindow::s_cInstance;
|
||||||
|
|
||||||
extern HKEY g_hRegistry;
|
extern HKEY g_hRegistry;
|
||||||
|
|
||||||
// header for the RTF log file
|
// header for the RTF log file
|
||||||
static const char* AI_VIEW_RTF_LOG_HEADER =
|
static const char* AI_VIEW_RTF_LOG_HEADER =
|
||||||
"{\\rtf1"
|
"{\\rtf1"
|
||||||
"\\ansi"
|
"\\ansi"
|
||||||
"\\deff0"
|
"\\deff0"
|
||||||
"{"
|
"{"
|
||||||
"\\fonttbl{\\f0 Courier New;}"
|
"\\fonttbl{\\f0 Courier New;}"
|
||||||
"}"
|
"}"
|
||||||
"{\\colortbl;"
|
"{\\colortbl;"
|
||||||
"\\red255\\green0\\blue0;" // red for errors
|
"\\red255\\green0\\blue0;" // red for errors
|
||||||
"\\red255\\green120\\blue0;" // orange for warnings
|
"\\red255\\green120\\blue0;" // orange for warnings
|
||||||
"\\red0\\green150\\blue0;" // green for infos
|
"\\red0\\green150\\blue0;" // green for infos
|
||||||
"\\red0\\green0\\blue180;" // blue for debug messages
|
"\\red0\\green0\\blue180;" // blue for debug messages
|
||||||
"\\red0\\green0\\blue0;" // black for everything else
|
"\\red0\\green0\\blue0;" // black for everything else
|
||||||
"}}";
|
"}}";
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Message procedure for the log window
|
// Message procedure for the log window
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam)
|
WPARAM wParam,LPARAM lParam)
|
||||||
{
|
{
|
||||||
(void)lParam;
|
(void)lParam;
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
int x = LOWORD(lParam);
|
int x = LOWORD(lParam);
|
||||||
int y = HIWORD(lParam);
|
int y = HIWORD(lParam);
|
||||||
|
|
||||||
SetWindowPos(GetDlgItem(hwndDlg,IDC_EDIT1),NULL,0,0,
|
SetWindowPos(GetDlgItem(hwndDlg,IDC_EDIT1),NULL,0,0,
|
||||||
x-10,y-12,SWP_NOMOVE|SWP_NOZORDER);
|
x-10,y-12,SWP_NOMOVE|SWP_NOZORDER);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
EndDialog(hwndDlg,0);
|
EndDialog(hwndDlg,0);
|
||||||
|
|
||||||
CLogWindow::Instance().bIsVisible = false;
|
CLogWindow::Instance().bIsVisible = false;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
};
|
};
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogWindow::Init ()
|
void CLogWindow::Init ()
|
||||||
{
|
{
|
||||||
this->hwnd = ::CreateDialog(g_hInstance,MAKEINTRESOURCE(IDD_LOGVIEW),
|
this->hwnd = ::CreateDialog(g_hInstance,MAKEINTRESOURCE(IDD_LOGVIEW),
|
||||||
NULL,&LogDialogProc);
|
NULL,&LogDialogProc);
|
||||||
|
|
||||||
if (!this->hwnd)
|
if (!this->hwnd)
|
||||||
{
|
{
|
||||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create logger window",
|
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create logger window",
|
||||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup the log text
|
// setup the log text
|
||||||
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
||||||
this->szPlainText = "";
|
this->szPlainText = "";
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogWindow::Show()
|
void CLogWindow::Show()
|
||||||
{
|
{
|
||||||
if (this->hwnd)
|
if (this->hwnd)
|
||||||
{
|
{
|
||||||
ShowWindow(this->hwnd,SW_SHOW);
|
ShowWindow(this->hwnd,SW_SHOW);
|
||||||
this->bIsVisible = true;
|
this->bIsVisible = true;
|
||||||
|
|
||||||
// contents aren't updated while the logger isn't displayed
|
// contents aren't updated while the logger isn't displayed
|
||||||
this->Update();
|
this->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CMyLogStream::write(const char* message)
|
void CMyLogStream::write(const char* message)
|
||||||
{
|
{
|
||||||
CLogWindow::Instance().WriteLine(message);
|
CLogWindow::Instance().WriteLine(message);
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogWindow::Clear()
|
void CLogWindow::Clear()
|
||||||
{
|
{
|
||||||
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
||||||
this->szPlainText = "";
|
this->szPlainText = "";
|
||||||
|
|
||||||
this->Update();
|
this->Update();
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogWindow::Update()
|
void CLogWindow::Update()
|
||||||
{
|
{
|
||||||
if (this->bIsVisible)
|
if (this->bIsVisible)
|
||||||
{
|
{
|
||||||
SETTEXTEX sInfo;
|
SETTEXTEX sInfo;
|
||||||
sInfo.flags = ST_DEFAULT;
|
sInfo.flags = ST_DEFAULT;
|
||||||
sInfo.codepage = CP_ACP;
|
sInfo.codepage = CP_ACP;
|
||||||
|
|
||||||
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
||||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogWindow::Save()
|
void CLogWindow::Save()
|
||||||
{
|
{
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
|
|
||||||
DWORD dwTemp = MAX_PATH;
|
DWORD dwTemp = MAX_PATH;
|
||||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LogDestination",NULL,NULL,
|
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LogDestination",NULL,NULL,
|
||||||
(BYTE*)szFileName,&dwTemp))
|
(BYTE*)szFileName,&dwTemp))
|
||||||
{
|
{
|
||||||
// Key was not found. Use C:
|
// Key was not found. Use C:
|
||||||
strcpy(szFileName,"");
|
strcpy(szFileName,"");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// need to remove the file name
|
// need to remove the file name
|
||||||
char* sz = strrchr(szFileName,'\\');
|
char* sz = strrchr(szFileName,'\\');
|
||||||
if (!sz)sz = strrchr(szFileName,'/');
|
if (!sz)sz = strrchr(szFileName,'/');
|
||||||
if (!sz)*sz = 0;
|
if (!sz)*sz = 0;
|
||||||
}
|
}
|
||||||
OPENFILENAME sFilename1 = {
|
OPENFILENAME sFilename1 = {
|
||||||
sizeof(OPENFILENAME),
|
sizeof(OPENFILENAME),
|
||||||
g_hDlg,GetModuleHandle(NULL),
|
g_hDlg,GetModuleHandle(NULL),
|
||||||
"Log files\0*.txt", NULL, 0, 1,
|
"Log files\0*.txt", NULL, 0, 1,
|
||||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
szFileName, MAX_PATH, NULL, 0, NULL,
|
||||||
"Save log to file",
|
"Save log to file",
|
||||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||||
0, 1, ".txt", 0, NULL, NULL
|
0, 1, ".txt", 0, NULL, NULL
|
||||||
};
|
};
|
||||||
if(GetSaveFileName(&sFilename1) == 0) return;
|
if(GetSaveFileName(&sFilename1) == 0) return;
|
||||||
|
|
||||||
// Now store the file in the registry
|
// Now store the file in the registry
|
||||||
RegSetValueExA(g_hRegistry,"LogDestination",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH);
|
RegSetValueExA(g_hRegistry,"LogDestination",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH);
|
||||||
|
|
||||||
FILE* pFile = fopen(szFileName,"wt");
|
FILE* pFile = fopen(szFileName,"wt");
|
||||||
fprintf(pFile,this->szPlainText.c_str());
|
fprintf(pFile,this->szPlainText.c_str());
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
|
|
||||||
CLogDisplay::Instance().AddEntry("[INFO] The log file has been saved",
|
CLogDisplay::Instance().AddEntry("[INFO] The log file has been saved",
|
||||||
D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0));
|
D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0));
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void CLogWindow::WriteLine(const char* message)
|
void CLogWindow::WriteLine(const char* message)
|
||||||
{
|
{
|
||||||
this->szPlainText.append(message);
|
this->szPlainText.append(message);
|
||||||
this->szPlainText.append("\r\n");
|
this->szPlainText.append("\r\n");
|
||||||
|
|
||||||
if (0 != this->szText.length())
|
if (0 != this->szText.length())
|
||||||
{
|
{
|
||||||
this->szText.resize(this->szText.length()-1);
|
this->szText.resize(this->szText.length()-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (message[0])
|
switch (message[0])
|
||||||
{
|
{
|
||||||
case 'e':
|
case 'e':
|
||||||
case 'E':
|
case 'E':
|
||||||
this->szText.append("{\\pard \\cf1 \\b \\fs18 ");
|
this->szText.append("{\\pard \\cf1 \\b \\fs18 ");
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
case 'W':
|
case 'W':
|
||||||
this->szText.append("{\\pard \\cf2 \\b \\fs18 ");
|
this->szText.append("{\\pard \\cf2 \\b \\fs18 ");
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'I':
|
case 'I':
|
||||||
this->szText.append("{\\pard \\cf3 \\b \\fs18 ");
|
this->szText.append("{\\pard \\cf3 \\b \\fs18 ");
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'D':
|
case 'D':
|
||||||
this->szText.append("{\\pard \\cf4 \\b \\fs18 ");
|
this->szText.append("{\\pard \\cf4 \\b \\fs18 ");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this->szText.append("{\\pard \\cf5 \\b \\fs18 ");
|
this->szText.append("{\\pard \\cf5 \\b \\fs18 ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string _message = message;
|
std::string _message = message;
|
||||||
for (unsigned int i = 0; i < _message.length();++i)
|
for (unsigned int i = 0; i < _message.length();++i)
|
||||||
{
|
{
|
||||||
if ('\\' == _message[i] ||
|
if ('\\' == _message[i] ||
|
||||||
'}' == _message[i] ||
|
'}' == _message[i] ||
|
||||||
'{' == _message[i])
|
'{' == _message[i])
|
||||||
{
|
{
|
||||||
_message.insert(i++,"\\");
|
_message.insert(i++,"\\");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->szText.append(_message);
|
this->szText.append(_message);
|
||||||
this->szText.append("\\par}}");
|
this->szText.append("\\par}}");
|
||||||
|
|
||||||
if (this->bIsVisible && this->bUpdate)
|
if (this->bIsVisible && this->bUpdate)
|
||||||
{
|
{
|
||||||
SETTEXTEX sInfo;
|
SETTEXTEX sInfo;
|
||||||
sInfo.flags = ST_DEFAULT;
|
sInfo.flags = ST_DEFAULT;
|
||||||
sInfo.codepage = CP_ACP;
|
sInfo.codepage = CP_ACP;
|
||||||
|
|
||||||
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
||||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; //! AssimpView
|
}; //! AssimpView
|
|
@ -1,133 +1,133 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (!defined AV_LOG_WINDOW_H_INCLUDED)
|
#if (!defined AV_LOG_WINDOW_H_INCLUDED)
|
||||||
#define AV_LOG_WINDOW_H_INCLUDE
|
#define AV_LOG_WINDOW_H_INCLUDE
|
||||||
|
|
||||||
namespace AssimpView
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \brief Subclass of Assimp::LogStream used to add all log messages to the
|
/** \brief Subclass of Assimp::LogStream used to add all log messages to the
|
||||||
* log window.
|
* log window.
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class CMyLogStream : public Assimp::LogStream
|
class CMyLogStream : public Assimp::LogStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** @brief Implementation of the abstract method */
|
/** @brief Implementation of the abstract method */
|
||||||
void write( const char* message );
|
void write( const char* message );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \brief Class to display log strings in a separate window
|
/** \brief Class to display log strings in a separate window
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class CLogWindow
|
class CLogWindow
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class CMyLogStream;
|
friend class CMyLogStream;
|
||||||
friend INT_PTR CALLBACK LogDialogProc( HWND hwndDlg, UINT uMsg,
|
friend INT_PTR CALLBACK LogDialogProc( HWND hwndDlg, UINT uMsg,
|
||||||
WPARAM wParam, LPARAM lParam );
|
WPARAM wParam, LPARAM lParam );
|
||||||
|
|
||||||
CLogWindow() : hwnd( NULL ), bIsVisible( false ), bUpdate( true ) {}
|
CLogWindow() : hwnd( NULL ), bIsVisible( false ), bUpdate( true ) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CLogWindow s_cInstance;
|
static CLogWindow s_cInstance;
|
||||||
inline static CLogWindow& Instance()
|
inline static CLogWindow& Instance()
|
||||||
{
|
{
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initializes the log window
|
// initializes the log window
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
// Shows the log window
|
// Shows the log window
|
||||||
void Show();
|
void Show();
|
||||||
|
|
||||||
// Clears the log window
|
// Clears the log window
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
// Save the log window to an user-defined file
|
// Save the log window to an user-defined file
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
// write a line to the log window
|
// write a line to the log window
|
||||||
void WriteLine( const char* message );
|
void WriteLine( const char* message );
|
||||||
|
|
||||||
// Set the bUpdate member
|
// Set the bUpdate member
|
||||||
inline void SetAutoUpdate( bool b )
|
inline void SetAutoUpdate( bool b )
|
||||||
{
|
{
|
||||||
this->bUpdate = b;
|
this->bUpdate = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// updates the log file
|
// updates the log file
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Window handle
|
// Window handle
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
|
|
||||||
// current text of the window (contains RTF tags)
|
// current text of the window (contains RTF tags)
|
||||||
std::string szText;
|
std::string szText;
|
||||||
std::string szPlainText;
|
std::string szPlainText;
|
||||||
|
|
||||||
// is the log window currently visible?
|
// is the log window currently visible?
|
||||||
bool bIsVisible;
|
bool bIsVisible;
|
||||||
|
|
||||||
// Specified whether each new log message updates the log automatically
|
// Specified whether each new log message updates the log automatically
|
||||||
bool bUpdate;
|
bool bUpdate;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// associated log stream
|
// associated log stream
|
||||||
CMyLogStream* pcStream;
|
CMyLogStream* pcStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // AV_LOG_DISPLA
|
#endif // AV_LOG_DISPLA
|
File diff suppressed because it is too large
Load Diff
|
@ -1,208 +1,208 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "AssetHelper.h"
|
#include "AssetHelper.h"
|
||||||
|
|
||||||
namespace AssimpView
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/* Helper class to create, access and destroy materials
|
/* Helper class to create, access and destroy materials
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class CMaterialManager
|
class CMaterialManager
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class CDisplay;
|
friend class CDisplay;
|
||||||
|
|
||||||
// default constructor
|
// default constructor
|
||||||
CMaterialManager()
|
CMaterialManager()
|
||||||
: m_iShaderCount( 0 ), sDefaultTexture() {}
|
: m_iShaderCount( 0 ), sDefaultTexture() {}
|
||||||
|
|
||||||
~CMaterialManager() {
|
~CMaterialManager() {
|
||||||
if( sDefaultTexture ) {
|
if( sDefaultTexture ) {
|
||||||
sDefaultTexture->Release();
|
sDefaultTexture->Release();
|
||||||
}
|
}
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CMaterialManager s_cInstance;
|
static CMaterialManager s_cInstance;
|
||||||
inline static CMaterialManager& Instance()
|
inline static CMaterialManager& Instance()
|
||||||
{
|
{
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Delete all resources of a given material
|
// Delete all resources of a given material
|
||||||
//
|
//
|
||||||
// Must be called before CreateMaterial() to prevent memory leaking
|
// Must be called before CreateMaterial() to prevent memory leaking
|
||||||
void DeleteMaterial( AssetHelper::MeshHelper* pcIn );
|
void DeleteMaterial( AssetHelper::MeshHelper* pcIn );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Create the material for a mesh.
|
// Create the material for a mesh.
|
||||||
//
|
//
|
||||||
// The function checks whether an identical shader is already in use.
|
// The function checks whether an identical shader is already in use.
|
||||||
// A shader is considered to be identical if it has the same input
|
// A shader is considered to be identical if it has the same input
|
||||||
// signature and takes the same number of texture channels.
|
// signature and takes the same number of texture channels.
|
||||||
int CreateMaterial( AssetHelper::MeshHelper* pcMesh,
|
int CreateMaterial( AssetHelper::MeshHelper* pcMesh,
|
||||||
const aiMesh* pcSource );
|
const aiMesh* pcSource );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Setup the material for a given mesh
|
// Setup the material for a given mesh
|
||||||
// pcMesh Mesh to be rendered
|
// pcMesh Mesh to be rendered
|
||||||
// pcProj Projection matrix
|
// pcProj Projection matrix
|
||||||
// aiMe Current world matrix
|
// aiMe Current world matrix
|
||||||
// pcCam Camera matrix
|
// pcCam Camera matrix
|
||||||
// vPos Position of the camera
|
// vPos Position of the camera
|
||||||
// TODO: Extract camera position from matrix ...
|
// TODO: Extract camera position from matrix ...
|
||||||
//
|
//
|
||||||
int SetupMaterial( AssetHelper::MeshHelper* pcMesh,
|
int SetupMaterial( AssetHelper::MeshHelper* pcMesh,
|
||||||
const aiMatrix4x4& pcProj,
|
const aiMatrix4x4& pcProj,
|
||||||
const aiMatrix4x4& aiMe,
|
const aiMatrix4x4& aiMe,
|
||||||
const aiMatrix4x4& pcCam,
|
const aiMatrix4x4& pcCam,
|
||||||
const aiVector3D& vPos );
|
const aiVector3D& vPos );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// End the material for a given mesh
|
// End the material for a given mesh
|
||||||
// Called after mesh rendering is complete
|
// Called after mesh rendering is complete
|
||||||
// pcMesh Mesh object
|
// pcMesh Mesh object
|
||||||
int EndMaterial( AssetHelper::MeshHelper* pcMesh );
|
int EndMaterial( AssetHelper::MeshHelper* pcMesh );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Recreate all specular materials depending on the current
|
// Recreate all specular materials depending on the current
|
||||||
// specularity settings
|
// specularity settings
|
||||||
//
|
//
|
||||||
// Diffuse-only materials are ignored.
|
// Diffuse-only materials are ignored.
|
||||||
// Must be called after specular highlights have been toggled
|
// Must be called after specular highlights have been toggled
|
||||||
int UpdateSpecularMaterials();
|
int UpdateSpecularMaterials();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// find a valid path to a texture file
|
// find a valid path to a texture file
|
||||||
//
|
//
|
||||||
// Handle 8.3 syntax correctly, search the environment of the
|
// Handle 8.3 syntax correctly, search the environment of the
|
||||||
// executable and the asset for a texture with a name very similar
|
// executable and the asset for a texture with a name very similar
|
||||||
// to a given one
|
// to a given one
|
||||||
int FindValidPath( aiString* p_szString );
|
int FindValidPath( aiString* p_szString );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Load a texture into memory and create a native D3D texture resource
|
// Load a texture into memory and create a native D3D texture resource
|
||||||
//
|
//
|
||||||
// The function tries to find a valid path for a texture
|
// The function tries to find a valid path for a texture
|
||||||
int LoadTexture( IDirect3DTexture9** p_ppiOut, aiString* szPath );
|
int LoadTexture( IDirect3DTexture9** p_ppiOut, aiString* szPath );
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Getter for m_iShaderCount
|
// Getter for m_iShaderCount
|
||||||
//
|
//
|
||||||
inline unsigned int GetShaderCount()
|
inline unsigned int GetShaderCount()
|
||||||
{
|
{
|
||||||
return this->m_iShaderCount;
|
return this->m_iShaderCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Reset the state of the class
|
// Reset the state of the class
|
||||||
// Called whenever a new asset is loaded
|
// Called whenever a new asset is loaded
|
||||||
inline void Reset()
|
inline void Reset()
|
||||||
{
|
{
|
||||||
this->m_iShaderCount = 0;
|
this->m_iShaderCount = 0;
|
||||||
for( TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it ) {
|
for( TextureCache::iterator it = sCachedTextures.begin(); it != sCachedTextures.end(); ++it ) {
|
||||||
( *it ).second->Release();
|
( *it ).second->Release();
|
||||||
}
|
}
|
||||||
sCachedTextures.clear();
|
sCachedTextures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// find a valid path to a texture file
|
// find a valid path to a texture file
|
||||||
//
|
//
|
||||||
// Handle 8.3 syntax correctly, search the environment of the
|
// Handle 8.3 syntax correctly, search the environment of the
|
||||||
// executable and the asset for a texture with a name very similar
|
// executable and the asset for a texture with a name very similar
|
||||||
// to a given one
|
// to a given one
|
||||||
bool TryLongerPath( char* szTemp, aiString* p_szString );
|
bool TryLongerPath( char* szTemp, aiString* p_szString );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Setup the default texture for a texture channel
|
// Setup the default texture for a texture channel
|
||||||
//
|
//
|
||||||
// Generates a default checker pattern for a texture
|
// Generates a default checker pattern for a texture
|
||||||
int SetDefaultTexture( IDirect3DTexture9** p_ppiOut );
|
int SetDefaultTexture( IDirect3DTexture9** p_ppiOut );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Convert a height map to a normal map if necessary
|
// Convert a height map to a normal map if necessary
|
||||||
//
|
//
|
||||||
// The function tries to detect the type of a texture automatically.
|
// The function tries to detect the type of a texture automatically.
|
||||||
// However, this wont work in every case.
|
// However, this wont work in every case.
|
||||||
void HMtoNMIfNecessary( IDirect3DTexture9* piTexture,
|
void HMtoNMIfNecessary( IDirect3DTexture9* piTexture,
|
||||||
IDirect3DTexture9** piTextureOut,
|
IDirect3DTexture9** piTextureOut,
|
||||||
bool bWasOriginallyHM = true );
|
bool bWasOriginallyHM = true );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Search for non-opaque pixels in a texture
|
// Search for non-opaque pixels in a texture
|
||||||
//
|
//
|
||||||
// A pixel is considered to be non-opaque if its alpha value is
|
// A pixel is considered to be non-opaque if its alpha value is
|
||||||
// less than 255
|
// less than 255
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool HasAlphaPixels( IDirect3DTexture9* piTexture );
|
bool HasAlphaPixels( IDirect3DTexture9* piTexture );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//
|
//
|
||||||
// Specifies the number of different shaders generated for
|
// Specifies the number of different shaders generated for
|
||||||
// the current asset. This number is incremented by CreateMaterial()
|
// the current asset. This number is incremented by CreateMaterial()
|
||||||
// each time a shader isn't found in cache and needs to be created
|
// each time a shader isn't found in cache and needs to be created
|
||||||
//
|
//
|
||||||
unsigned int m_iShaderCount;
|
unsigned int m_iShaderCount;
|
||||||
IDirect3DTexture9* sDefaultTexture;
|
IDirect3DTexture9* sDefaultTexture;
|
||||||
|
|
||||||
typedef std::map<std::string, IDirect3DTexture9*> TextureCache;
|
typedef std::map<std::string, IDirect3DTexture9*> TextureCache;
|
||||||
TextureCache sCachedTextures;
|
TextureCache sCachedTextures;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,166 +1,166 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
CMeshRenderer CMeshRenderer::s_cInstance;
|
CMeshRenderer CMeshRenderer::s_cInstance;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CMeshRenderer::DrawUnsorted(unsigned int iIndex)
|
int CMeshRenderer::DrawUnsorted(unsigned int iIndex)
|
||||||
{
|
{
|
||||||
ai_assert(iIndex < g_pcAsset->pcScene->mNumMeshes);
|
ai_assert(iIndex < g_pcAsset->pcScene->mNumMeshes);
|
||||||
|
|
||||||
// set vertex and index buffer
|
// set vertex and index buffer
|
||||||
g_piDevice->SetStreamSource(0,g_pcAsset->apcMeshes[iIndex]->piVB,0,
|
g_piDevice->SetStreamSource(0,g_pcAsset->apcMeshes[iIndex]->piVB,0,
|
||||||
sizeof(AssetHelper::Vertex));
|
sizeof(AssetHelper::Vertex));
|
||||||
|
|
||||||
g_piDevice->SetIndices(g_pcAsset->apcMeshes[iIndex]->piIB);
|
g_piDevice->SetIndices(g_pcAsset->apcMeshes[iIndex]->piIB);
|
||||||
|
|
||||||
D3DPRIMITIVETYPE type = D3DPT_POINTLIST;
|
D3DPRIMITIVETYPE type = D3DPT_POINTLIST;
|
||||||
switch (g_pcAsset->pcScene->mMeshes[iIndex]->mPrimitiveTypes) {
|
switch (g_pcAsset->pcScene->mMeshes[iIndex]->mPrimitiveTypes) {
|
||||||
case aiPrimitiveType_POINT:
|
case aiPrimitiveType_POINT:
|
||||||
type = D3DPT_POINTLIST;break;
|
type = D3DPT_POINTLIST;break;
|
||||||
case aiPrimitiveType_LINE:
|
case aiPrimitiveType_LINE:
|
||||||
type = D3DPT_LINELIST;break;
|
type = D3DPT_LINELIST;break;
|
||||||
case aiPrimitiveType_TRIANGLE:
|
case aiPrimitiveType_TRIANGLE:
|
||||||
type = D3DPT_TRIANGLELIST;break;
|
type = D3DPT_TRIANGLELIST;break;
|
||||||
}
|
}
|
||||||
// and draw the mesh
|
// and draw the mesh
|
||||||
g_piDevice->DrawIndexedPrimitive(type,
|
g_piDevice->DrawIndexedPrimitive(type,
|
||||||
0,0,
|
0,0,
|
||||||
g_pcAsset->pcScene->mMeshes[iIndex]->mNumVertices,0,
|
g_pcAsset->pcScene->mMeshes[iIndex]->mNumVertices,0,
|
||||||
g_pcAsset->pcScene->mMeshes[iIndex]->mNumFaces);
|
g_pcAsset->pcScene->mMeshes[iIndex]->mNumFaces);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int CMeshRenderer::DrawSorted(unsigned int iIndex,const aiMatrix4x4& mWorld)
|
int CMeshRenderer::DrawSorted(unsigned int iIndex,const aiMatrix4x4& mWorld)
|
||||||
{
|
{
|
||||||
ai_assert(iIndex < g_pcAsset->pcScene->mNumMeshes);
|
ai_assert(iIndex < g_pcAsset->pcScene->mNumMeshes);
|
||||||
|
|
||||||
AssetHelper::MeshHelper* pcHelper = g_pcAsset->apcMeshes[iIndex];
|
AssetHelper::MeshHelper* pcHelper = g_pcAsset->apcMeshes[iIndex];
|
||||||
const aiMesh* pcMesh = g_pcAsset->pcScene->mMeshes[iIndex];
|
const aiMesh* pcMesh = g_pcAsset->pcScene->mMeshes[iIndex];
|
||||||
|
|
||||||
if (!pcHelper || !pcMesh || !pcHelper->piIB)
|
if (!pcHelper || !pcMesh || !pcHelper->piIB)
|
||||||
return -5;
|
return -5;
|
||||||
|
|
||||||
if (pcMesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE || pcMesh->HasBones() || g_sOptions.bNoAlphaBlending)
|
if (pcMesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE || pcMesh->HasBones() || g_sOptions.bNoAlphaBlending)
|
||||||
return DrawUnsorted(iIndex);
|
return DrawUnsorted(iIndex);
|
||||||
|
|
||||||
|
|
||||||
// compute the position of the camera in worldspace
|
// compute the position of the camera in worldspace
|
||||||
aiMatrix4x4 mWorldInverse = mWorld;
|
aiMatrix4x4 mWorldInverse = mWorld;
|
||||||
mWorldInverse.Inverse();
|
mWorldInverse.Inverse();
|
||||||
mWorldInverse.Transpose();
|
mWorldInverse.Transpose();
|
||||||
const aiVector3D vLocalCamera = mWorldInverse * g_sCamera.vPos;
|
const aiVector3D vLocalCamera = mWorldInverse * g_sCamera.vPos;
|
||||||
|
|
||||||
// well ... this is really funny now. We must compute their distance
|
// well ... this is really funny now. We must compute their distance
|
||||||
// from the camera. We take the average distance of a face and add it
|
// from the camera. We take the average distance of a face and add it
|
||||||
// to a map which sorts it
|
// to a map which sorts it
|
||||||
std::map<float,unsigned int, std::greater<float> > smap;
|
std::map<float,unsigned int, std::greater<float> > smap;
|
||||||
|
|
||||||
for (unsigned int iFace = 0; iFace < pcMesh->mNumFaces;++iFace)
|
for (unsigned int iFace = 0; iFace < pcMesh->mNumFaces;++iFace)
|
||||||
{
|
{
|
||||||
const aiFace* pcFace = &pcMesh->mFaces[iFace];
|
const aiFace* pcFace = &pcMesh->mFaces[iFace];
|
||||||
float fDist = 0.0f;
|
float fDist = 0.0f;
|
||||||
for (unsigned int c = 0; c < 3;++c)
|
for (unsigned int c = 0; c < 3;++c)
|
||||||
{
|
{
|
||||||
aiVector3D vPos = pcMesh->mVertices[pcFace->mIndices[c]];
|
aiVector3D vPos = pcMesh->mVertices[pcFace->mIndices[c]];
|
||||||
vPos -= vLocalCamera;
|
vPos -= vLocalCamera;
|
||||||
fDist += vPos.SquareLength();
|
fDist += vPos.SquareLength();
|
||||||
}
|
}
|
||||||
smap.insert(std::pair<float, unsigned int>(fDist,iFace));
|
smap.insert(std::pair<float, unsigned int>(fDist,iFace));
|
||||||
}
|
}
|
||||||
|
|
||||||
// now we can lock the index buffer and rebuild it
|
// now we can lock the index buffer and rebuild it
|
||||||
D3DINDEXBUFFER_DESC sDesc;
|
D3DINDEXBUFFER_DESC sDesc;
|
||||||
pcHelper->piIB->GetDesc(&sDesc);
|
pcHelper->piIB->GetDesc(&sDesc);
|
||||||
|
|
||||||
if (D3DFMT_INDEX16 == sDesc.Format)
|
if (D3DFMT_INDEX16 == sDesc.Format)
|
||||||
{
|
{
|
||||||
uint16_t* aiIndices;
|
uint16_t* aiIndices;
|
||||||
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
||||||
|
|
||||||
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
||||||
i = smap.begin();
|
i = smap.begin();
|
||||||
i != smap.end();++i)
|
i != smap.end();++i)
|
||||||
{
|
{
|
||||||
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
||||||
*aiIndices++ = (uint16_t)pcFace->mIndices[0];
|
*aiIndices++ = (uint16_t)pcFace->mIndices[0];
|
||||||
*aiIndices++ = (uint16_t)pcFace->mIndices[1];
|
*aiIndices++ = (uint16_t)pcFace->mIndices[1];
|
||||||
*aiIndices++ = (uint16_t)pcFace->mIndices[2];
|
*aiIndices++ = (uint16_t)pcFace->mIndices[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (D3DFMT_INDEX32 == sDesc.Format)
|
else if (D3DFMT_INDEX32 == sDesc.Format)
|
||||||
{
|
{
|
||||||
uint32_t* aiIndices;
|
uint32_t* aiIndices;
|
||||||
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
||||||
|
|
||||||
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
||||||
i = smap.begin();
|
i = smap.begin();
|
||||||
i != smap.end();++i)
|
i != smap.end();++i)
|
||||||
{
|
{
|
||||||
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
||||||
*aiIndices++ = (uint32_t)pcFace->mIndices[0];
|
*aiIndices++ = (uint32_t)pcFace->mIndices[0];
|
||||||
*aiIndices++ = (uint32_t)pcFace->mIndices[1];
|
*aiIndices++ = (uint32_t)pcFace->mIndices[1];
|
||||||
*aiIndices++ = (uint32_t)pcFace->mIndices[2];
|
*aiIndices++ = (uint32_t)pcFace->mIndices[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pcHelper->piIB->Unlock();
|
pcHelper->piIB->Unlock();
|
||||||
|
|
||||||
// set vertex and index buffer
|
// set vertex and index buffer
|
||||||
g_piDevice->SetStreamSource(0,pcHelper->piVB,0,sizeof(AssetHelper::Vertex));
|
g_piDevice->SetStreamSource(0,pcHelper->piVB,0,sizeof(AssetHelper::Vertex));
|
||||||
|
|
||||||
// and draw the mesh
|
// and draw the mesh
|
||||||
g_piDevice->SetIndices(pcHelper->piIB);
|
g_piDevice->SetIndices(pcHelper->piIB);
|
||||||
g_piDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
|
g_piDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
|
||||||
0,0,
|
0,0,
|
||||||
pcMesh->mNumVertices,0,
|
pcMesh->mNumVertices,0,
|
||||||
pcMesh->mNumFaces);
|
pcMesh->mNumFaces);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1,99 +1,99 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (!defined AV_MESH_RENDERER_H_INCLUDED)
|
#if (!defined AV_MESH_RENDERER_H_INCLUDED)
|
||||||
#define AV_MESH_RENDERER_H_INCLUDED
|
#define AV_MESH_RENDERER_H_INCLUDED
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/* Helper class tp render meshes
|
/* Helper class tp render meshes
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class CMeshRenderer
|
class CMeshRenderer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// default constructor
|
// default constructor
|
||||||
CMeshRenderer()
|
CMeshRenderer()
|
||||||
|
|
||||||
{
|
{
|
||||||
// no other members to initialize
|
// no other members to initialize
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Singleton accessors
|
// Singleton accessors
|
||||||
static CMeshRenderer s_cInstance;
|
static CMeshRenderer s_cInstance;
|
||||||
inline static CMeshRenderer& Instance()
|
inline static CMeshRenderer& Instance()
|
||||||
{
|
{
|
||||||
return s_cInstance;
|
return s_cInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Draw a mesh in the global mesh list using the current pipeline state
|
// Draw a mesh in the global mesh list using the current pipeline state
|
||||||
// iIndex Index of the mesh to be drawn
|
// iIndex Index of the mesh to be drawn
|
||||||
//
|
//
|
||||||
// The function draws all faces in order, regardless of their distance
|
// The function draws all faces in order, regardless of their distance
|
||||||
int DrawUnsorted( unsigned int iIndex );
|
int DrawUnsorted( unsigned int iIndex );
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// Draw a mesh in the global mesh list using the current pipeline state
|
// Draw a mesh in the global mesh list using the current pipeline state
|
||||||
// iIndex Index of the mesh to be drawn
|
// iIndex Index of the mesh to be drawn
|
||||||
//
|
//
|
||||||
// The method sorts all vertices by their distance (back to front)
|
// The method sorts all vertices by their distance (back to front)
|
||||||
//
|
//
|
||||||
// mWorld World matrix for the node
|
// mWorld World matrix for the node
|
||||||
int DrawSorted( unsigned int iIndex,
|
int DrawSorted( unsigned int iIndex,
|
||||||
const aiMatrix4x4& mWorld );
|
const aiMatrix4x4& mWorld );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif //!! include guard
|
#endif //!! include guard
|
File diff suppressed because it is too large
Load Diff
|
@ -1,2 +1,2 @@
|
||||||
text1.bin is the corresponding bin file to be included with the executable file.
|
text1.bin is the corresponding bin file to be included with the executable file.
|
||||||
When updating the rich formatted text inside Visual Studio, a terminating 0 character must be appended
|
When updating the rich formatted text inside Visual Studio, a terminating 0 character must be appended
|
|
@ -1,175 +1,175 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
// note: these are no longer part of the public API, but they are
|
// note: these are no longer part of the public API, but they are
|
||||||
// exported on Windows to keep AssimpView alive.
|
// exported on Windows to keep AssimpView alive.
|
||||||
#include "GenFaceNormalsProcess.h"
|
#include "GenFaceNormalsProcess.h"
|
||||||
#include "GenVertexNormalsProcess.h"
|
#include "GenVertexNormalsProcess.h"
|
||||||
#include "JoinVerticesProcess.h"
|
#include "JoinVerticesProcess.h"
|
||||||
#include "CalcTangentsProcess.h"
|
#include "CalcTangentsProcess.h"
|
||||||
#include "MakeVerboseFormat.h"
|
#include "MakeVerboseFormat.h"
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
bool g_bWasFlipped = false;
|
bool g_bWasFlipped = false;
|
||||||
float g_smoothAngle = 80.f;
|
float g_smoothAngle = 80.f;
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Flip all normal vectors
|
// Flip all normal vectors
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void AssetHelper::FlipNormalsInt()
|
void AssetHelper::FlipNormalsInt()
|
||||||
{
|
{
|
||||||
// invert all normal vectors
|
// invert all normal vectors
|
||||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
aiMesh* pcMesh = this->pcScene->mMeshes[i];
|
aiMesh* pcMesh = this->pcScene->mMeshes[i];
|
||||||
|
|
||||||
if (!pcMesh->mNormals)
|
if (!pcMesh->mNormals)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a){
|
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a){
|
||||||
pcMesh->mNormals[a] *= -1.0f;
|
pcMesh->mNormals[a] *= -1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void AssetHelper::FlipNormals()
|
void AssetHelper::FlipNormals()
|
||||||
{
|
{
|
||||||
FlipNormalsInt();
|
FlipNormalsInt();
|
||||||
|
|
||||||
// recreate native data
|
// recreate native data
|
||||||
DeleteAssetData(true);
|
DeleteAssetData(true);
|
||||||
CreateAssetData();
|
CreateAssetData();
|
||||||
g_bWasFlipped = ! g_bWasFlipped;
|
g_bWasFlipped = ! g_bWasFlipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Set the normal set of the scene
|
// Set the normal set of the scene
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void AssetHelper::SetNormalSet(unsigned int iSet)
|
void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||||
{
|
{
|
||||||
// we need to build an unique set of vertices for this ...
|
// we need to build an unique set of vertices for this ...
|
||||||
{
|
{
|
||||||
MakeVerboseFormatProcess* pcProcess = new MakeVerboseFormatProcess();
|
MakeVerboseFormatProcess* pcProcess = new MakeVerboseFormatProcess();
|
||||||
pcProcess->Execute(pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
if (!apcMeshes[i]->pvOriginalNormals)
|
if (!apcMeshes[i]->pvOriginalNormals)
|
||||||
{
|
{
|
||||||
apcMeshes[i]->pvOriginalNormals = new aiVector3D[pcScene->mMeshes[i]->mNumVertices];
|
apcMeshes[i]->pvOriginalNormals = new aiVector3D[pcScene->mMeshes[i]->mNumVertices];
|
||||||
memcpy( apcMeshes[i]->pvOriginalNormals,pcScene->mMeshes[i]->mNormals,
|
memcpy( apcMeshes[i]->pvOriginalNormals,pcScene->mMeshes[i]->mNormals,
|
||||||
pcScene->mMeshes[i]->mNumVertices * sizeof(aiVector3D));
|
pcScene->mMeshes[i]->mNumVertices * sizeof(aiVector3D));
|
||||||
}
|
}
|
||||||
delete[] pcScene->mMeshes[i]->mNormals;
|
delete[] pcScene->mMeshes[i]->mNormals;
|
||||||
pcScene->mMeshes[i]->mNormals = NULL;
|
pcScene->mMeshes[i]->mNormals = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// now we can start to calculate a new set of normals
|
// now we can start to calculate a new set of normals
|
||||||
if (HARD == iSet)
|
if (HARD == iSet)
|
||||||
{
|
{
|
||||||
GenFaceNormalsProcess* pcProcess = new GenFaceNormalsProcess();
|
GenFaceNormalsProcess* pcProcess = new GenFaceNormalsProcess();
|
||||||
pcProcess->Execute(pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
FlipNormalsInt();
|
FlipNormalsInt();
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
else if (SMOOTH == iSet)
|
else if (SMOOTH == iSet)
|
||||||
{
|
{
|
||||||
GenVertexNormalsProcess* pcProcess = new GenVertexNormalsProcess();
|
GenVertexNormalsProcess* pcProcess = new GenVertexNormalsProcess();
|
||||||
pcProcess->SetMaxSmoothAngle((float)AI_DEG_TO_RAD(g_smoothAngle));
|
pcProcess->SetMaxSmoothAngle((float)AI_DEG_TO_RAD(g_smoothAngle));
|
||||||
pcProcess->Execute(pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
FlipNormalsInt();
|
FlipNormalsInt();
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
}
|
}
|
||||||
else if (ORIGINAL == iSet)
|
else if (ORIGINAL == iSet)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
if (apcMeshes[i]->pvOriginalNormals)
|
if (apcMeshes[i]->pvOriginalNormals)
|
||||||
{
|
{
|
||||||
delete[] pcScene->mMeshes[i]->mNormals;
|
delete[] pcScene->mMeshes[i]->mNormals;
|
||||||
pcScene->mMeshes[i]->mNormals = apcMeshes[i]->pvOriginalNormals;
|
pcScene->mMeshes[i]->mNormals = apcMeshes[i]->pvOriginalNormals;
|
||||||
apcMeshes[i]->pvOriginalNormals = NULL;
|
apcMeshes[i]->pvOriginalNormals = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// recalculate tangents and bitangents
|
// recalculate tangents and bitangents
|
||||||
Assimp::BaseProcess* pcProcess = new CalcTangentsProcess();
|
Assimp::BaseProcess* pcProcess = new CalcTangentsProcess();
|
||||||
pcProcess->Execute(pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
// join the mesh vertices again
|
// join the mesh vertices again
|
||||||
pcProcess = new JoinVerticesProcess();
|
pcProcess = new JoinVerticesProcess();
|
||||||
pcProcess->Execute(pcScene);
|
pcProcess->Execute(pcScene);
|
||||||
delete pcProcess;
|
delete pcProcess;
|
||||||
|
|
||||||
iNormalSet = iSet;
|
iNormalSet = iSet;
|
||||||
|
|
||||||
if (g_bWasFlipped)
|
if (g_bWasFlipped)
|
||||||
{
|
{
|
||||||
// invert all normal vectors
|
// invert all normal vectors
|
||||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
aiMesh* pcMesh = pcScene->mMeshes[i];
|
aiMesh* pcMesh = pcScene->mMeshes[i];
|
||||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a)
|
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a)
|
||||||
{
|
{
|
||||||
pcMesh->mNormals[a] *= -1.0f;
|
pcMesh->mNormals[a] *= -1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// recreate native data
|
// recreate native data
|
||||||
DeleteAssetData(true);
|
DeleteAssetData(true);
|
||||||
CreateAssetData();
|
CreateAssetData();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,113 +1,113 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (!defined AV_RO_H_INCLUDED)
|
#if (!defined AV_RO_H_INCLUDED)
|
||||||
#define AV_RO_H_INCLUDED
|
#define AV_RO_H_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \brief Class to manage render options. One global instance
|
/** \brief Class to manage render options. One global instance
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class RenderOptions
|
class RenderOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// enumerates different drawing modi. POINT is currently
|
// enumerates different drawing modi. POINT is currently
|
||||||
// not supported and probably will never be.
|
// not supported and probably will never be.
|
||||||
enum DrawMode {NORMAL, WIREFRAME, POINT};
|
enum DrawMode {NORMAL, WIREFRAME, POINT};
|
||||||
|
|
||||||
inline RenderOptions (void) :
|
inline RenderOptions (void) :
|
||||||
bMultiSample (true),
|
bMultiSample (true),
|
||||||
bSuperSample (false),
|
bSuperSample (false),
|
||||||
bRenderMats (true),
|
bRenderMats (true),
|
||||||
bRenderNormals (false),
|
bRenderNormals (false),
|
||||||
b3Lights (false),
|
b3Lights (false),
|
||||||
bLightRotate (false),
|
bLightRotate (false),
|
||||||
bRotate (true),
|
bRotate (true),
|
||||||
bLowQuality (false),
|
bLowQuality (false),
|
||||||
bNoSpecular (false),
|
bNoSpecular (false),
|
||||||
bStereoView (false),
|
bStereoView (false),
|
||||||
bNoAlphaBlending(false),
|
bNoAlphaBlending(false),
|
||||||
eDrawMode (NORMAL),
|
eDrawMode (NORMAL),
|
||||||
bCulling (false),
|
bCulling (false),
|
||||||
bSkeleton (false)
|
bSkeleton (false)
|
||||||
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool bMultiSample;
|
bool bMultiSample;
|
||||||
|
|
||||||
// SuperSampling has not yet been implemented
|
// SuperSampling has not yet been implemented
|
||||||
bool bSuperSample;
|
bool bSuperSample;
|
||||||
|
|
||||||
// Display the real material of the object
|
// Display the real material of the object
|
||||||
bool bRenderMats;
|
bool bRenderMats;
|
||||||
|
|
||||||
// Render the normals
|
// Render the normals
|
||||||
bool bRenderNormals;
|
bool bRenderNormals;
|
||||||
|
|
||||||
// Use 2 directional light sources
|
// Use 2 directional light sources
|
||||||
bool b3Lights;
|
bool b3Lights;
|
||||||
|
|
||||||
// Automatically rotate the light source(s)
|
// Automatically rotate the light source(s)
|
||||||
bool bLightRotate;
|
bool bLightRotate;
|
||||||
|
|
||||||
// Automatically rotate the asset around its origin
|
// Automatically rotate the asset around its origin
|
||||||
bool bRotate;
|
bool bRotate;
|
||||||
|
|
||||||
// use standard lambertian lighting
|
// use standard lambertian lighting
|
||||||
bool bLowQuality;
|
bool bLowQuality;
|
||||||
|
|
||||||
// disable specular lighting got all elements in the scene
|
// disable specular lighting got all elements in the scene
|
||||||
bool bNoSpecular;
|
bool bNoSpecular;
|
||||||
|
|
||||||
// enable stereo view
|
// enable stereo view
|
||||||
bool bStereoView;
|
bool bStereoView;
|
||||||
|
|
||||||
bool bNoAlphaBlending;
|
bool bNoAlphaBlending;
|
||||||
|
|
||||||
// wireframe or solid rendering?
|
// wireframe or solid rendering?
|
||||||
DrawMode eDrawMode;
|
DrawMode eDrawMode;
|
||||||
|
|
||||||
bool bCulling,bSkeleton;
|
bool bCulling,bSkeleton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !! IG
|
#endif // !! IG
|
|
@ -1,245 +1,245 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2015, assimp team
|
Copyright (c) 2006-2015, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @file SceneAnimator.cpp
|
/** @file SceneAnimator.cpp
|
||||||
* @brief Implementation of the utility class SceneAnimator
|
* @brief Implementation of the utility class SceneAnimator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
using namespace AssimpView;
|
using namespace AssimpView;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor for a given scene.
|
// Constructor for a given scene.
|
||||||
SceneAnimator::SceneAnimator( const aiScene* pScene, size_t pAnimIndex)
|
SceneAnimator::SceneAnimator( const aiScene* pScene, size_t pAnimIndex)
|
||||||
{
|
{
|
||||||
mScene = pScene;
|
mScene = pScene;
|
||||||
mCurrentAnimIndex = -1;
|
mCurrentAnimIndex = -1;
|
||||||
mAnimEvaluator = NULL;
|
mAnimEvaluator = NULL;
|
||||||
mRootNode = NULL;
|
mRootNode = NULL;
|
||||||
|
|
||||||
// build the nodes-for-bones table
|
// build the nodes-for-bones table
|
||||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||||
{
|
{
|
||||||
const aiMesh* mesh = pScene->mMeshes[i];
|
const aiMesh* mesh = pScene->mMeshes[i];
|
||||||
for (unsigned int n = 0; n < mesh->mNumBones;++n)
|
for (unsigned int n = 0; n < mesh->mNumBones;++n)
|
||||||
{
|
{
|
||||||
const aiBone* bone = mesh->mBones[n];
|
const aiBone* bone = mesh->mBones[n];
|
||||||
|
|
||||||
mBoneNodesByName[bone->mName.data] = pScene->mRootNode->FindNode(bone->mName);
|
mBoneNodesByName[bone->mName.data] = pScene->mRootNode->FindNode(bone->mName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// changing the current animation also creates the node tree for this animation
|
// changing the current animation also creates the node tree for this animation
|
||||||
SetAnimIndex( pAnimIndex);
|
SetAnimIndex( pAnimIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor
|
// Destructor
|
||||||
SceneAnimator::~SceneAnimator()
|
SceneAnimator::~SceneAnimator()
|
||||||
{
|
{
|
||||||
delete mRootNode;
|
delete mRootNode;
|
||||||
delete mAnimEvaluator;
|
delete mAnimEvaluator;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Sets the animation to use for playback.
|
// Sets the animation to use for playback.
|
||||||
void SceneAnimator::SetAnimIndex( size_t pAnimIndex)
|
void SceneAnimator::SetAnimIndex( size_t pAnimIndex)
|
||||||
{
|
{
|
||||||
// no change
|
// no change
|
||||||
if( pAnimIndex == mCurrentAnimIndex)
|
if( pAnimIndex == mCurrentAnimIndex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// kill data of the previous anim
|
// kill data of the previous anim
|
||||||
delete mRootNode; mRootNode = NULL;
|
delete mRootNode; mRootNode = NULL;
|
||||||
delete mAnimEvaluator; mAnimEvaluator = NULL;
|
delete mAnimEvaluator; mAnimEvaluator = NULL;
|
||||||
mNodesByName.clear();
|
mNodesByName.clear();
|
||||||
|
|
||||||
mCurrentAnimIndex = pAnimIndex;
|
mCurrentAnimIndex = pAnimIndex;
|
||||||
|
|
||||||
// create the internal node tree. Do this even in case of invalid animation index
|
// create the internal node tree. Do this even in case of invalid animation index
|
||||||
// so that the transformation matrices are properly set up to mimic the current scene
|
// so that the transformation matrices are properly set up to mimic the current scene
|
||||||
mRootNode = CreateNodeTree( mScene->mRootNode, NULL);
|
mRootNode = CreateNodeTree( mScene->mRootNode, NULL);
|
||||||
|
|
||||||
// invalid anim index
|
// invalid anim index
|
||||||
if( mCurrentAnimIndex >= mScene->mNumAnimations)
|
if( mCurrentAnimIndex >= mScene->mNumAnimations)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// create an evaluator for this animation
|
// create an evaluator for this animation
|
||||||
mAnimEvaluator = new AnimEvaluator( mScene->mAnimations[mCurrentAnimIndex]);
|
mAnimEvaluator = new AnimEvaluator( mScene->mAnimations[mCurrentAnimIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Calculates the node transformations for the scene.
|
// Calculates the node transformations for the scene.
|
||||||
void SceneAnimator::Calculate( double pTime)
|
void SceneAnimator::Calculate( double pTime)
|
||||||
{
|
{
|
||||||
// invalid anim
|
// invalid anim
|
||||||
if( !mAnimEvaluator)
|
if( !mAnimEvaluator)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// calculate current local transformations
|
// calculate current local transformations
|
||||||
mAnimEvaluator->Evaluate( pTime);
|
mAnimEvaluator->Evaluate( pTime);
|
||||||
|
|
||||||
// and update all node transformations with the results
|
// and update all node transformations with the results
|
||||||
UpdateTransforms( mRootNode, mAnimEvaluator->GetTransformations());
|
UpdateTransforms( mRootNode, mAnimEvaluator->GetTransformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Retrieves the most recent local transformation matrix for the given node.
|
// Retrieves the most recent local transformation matrix for the given node.
|
||||||
const aiMatrix4x4& SceneAnimator::GetLocalTransform( const aiNode* node) const
|
const aiMatrix4x4& SceneAnimator::GetLocalTransform( const aiNode* node) const
|
||||||
{
|
{
|
||||||
NodeMap::const_iterator it = mNodesByName.find( node);
|
NodeMap::const_iterator it = mNodesByName.find( node);
|
||||||
if( it == mNodesByName.end())
|
if( it == mNodesByName.end())
|
||||||
return mIdentityMatrix;
|
return mIdentityMatrix;
|
||||||
|
|
||||||
return it->second->mLocalTransform;
|
return it->second->mLocalTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Retrieves the most recent global transformation matrix for the given node.
|
// Retrieves the most recent global transformation matrix for the given node.
|
||||||
const aiMatrix4x4& SceneAnimator::GetGlobalTransform( const aiNode* node) const
|
const aiMatrix4x4& SceneAnimator::GetGlobalTransform( const aiNode* node) const
|
||||||
{
|
{
|
||||||
NodeMap::const_iterator it = mNodesByName.find( node);
|
NodeMap::const_iterator it = mNodesByName.find( node);
|
||||||
if( it == mNodesByName.end())
|
if( it == mNodesByName.end())
|
||||||
return mIdentityMatrix;
|
return mIdentityMatrix;
|
||||||
|
|
||||||
return it->second->mGlobalTransform;
|
return it->second->mGlobalTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Calculates the bone matrices for the given mesh.
|
// Calculates the bone matrices for the given mesh.
|
||||||
const std::vector<aiMatrix4x4>& SceneAnimator::GetBoneMatrices( const aiNode* pNode, size_t pMeshIndex /* = 0 */)
|
const std::vector<aiMatrix4x4>& SceneAnimator::GetBoneMatrices( const aiNode* pNode, size_t pMeshIndex /* = 0 */)
|
||||||
{
|
{
|
||||||
ai_assert( pMeshIndex < pNode->mNumMeshes);
|
ai_assert( pMeshIndex < pNode->mNumMeshes);
|
||||||
size_t meshIndex = pNode->mMeshes[pMeshIndex];
|
size_t meshIndex = pNode->mMeshes[pMeshIndex];
|
||||||
ai_assert( meshIndex < mScene->mNumMeshes);
|
ai_assert( meshIndex < mScene->mNumMeshes);
|
||||||
const aiMesh* mesh = mScene->mMeshes[meshIndex];
|
const aiMesh* mesh = mScene->mMeshes[meshIndex];
|
||||||
|
|
||||||
// resize array and initialise it with identity matrices
|
// resize array and initialise it with identity matrices
|
||||||
mTransforms.resize( mesh->mNumBones, aiMatrix4x4());
|
mTransforms.resize( mesh->mNumBones, aiMatrix4x4());
|
||||||
|
|
||||||
// calculate the mesh's inverse global transform
|
// calculate the mesh's inverse global transform
|
||||||
aiMatrix4x4 globalInverseMeshTransform = GetGlobalTransform( pNode);
|
aiMatrix4x4 globalInverseMeshTransform = GetGlobalTransform( pNode);
|
||||||
globalInverseMeshTransform.Inverse();
|
globalInverseMeshTransform.Inverse();
|
||||||
|
|
||||||
// Bone matrices transform from mesh coordinates in bind pose to mesh coordinates in skinned pose
|
// Bone matrices transform from mesh coordinates in bind pose to mesh coordinates in skinned pose
|
||||||
// Therefore the formula is offsetMatrix * currentGlobalTransform * inverseCurrentMeshTransform
|
// Therefore the formula is offsetMatrix * currentGlobalTransform * inverseCurrentMeshTransform
|
||||||
for( size_t a = 0; a < mesh->mNumBones; ++a)
|
for( size_t a = 0; a < mesh->mNumBones; ++a)
|
||||||
{
|
{
|
||||||
const aiBone* bone = mesh->mBones[a];
|
const aiBone* bone = mesh->mBones[a];
|
||||||
const aiMatrix4x4& currentGlobalTransform = GetGlobalTransform( mBoneNodesByName[ bone->mName.data ]);
|
const aiMatrix4x4& currentGlobalTransform = GetGlobalTransform( mBoneNodesByName[ bone->mName.data ]);
|
||||||
mTransforms[a] = globalInverseMeshTransform * currentGlobalTransform * bone->mOffsetMatrix;
|
mTransforms[a] = globalInverseMeshTransform * currentGlobalTransform * bone->mOffsetMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
// and return the result
|
// and return the result
|
||||||
return mTransforms;
|
return mTransforms;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Recursively creates an internal node structure matching the current scene and animation.
|
// Recursively creates an internal node structure matching the current scene and animation.
|
||||||
SceneAnimNode* SceneAnimator::CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent)
|
SceneAnimNode* SceneAnimator::CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent)
|
||||||
{
|
{
|
||||||
// create a node
|
// create a node
|
||||||
SceneAnimNode* internalNode = new SceneAnimNode( pNode->mName.data);
|
SceneAnimNode* internalNode = new SceneAnimNode( pNode->mName.data);
|
||||||
internalNode->mParent = pParent;
|
internalNode->mParent = pParent;
|
||||||
mNodesByName[pNode] = internalNode;
|
mNodesByName[pNode] = internalNode;
|
||||||
|
|
||||||
// copy its transformation
|
// copy its transformation
|
||||||
internalNode->mLocalTransform = pNode->mTransformation;
|
internalNode->mLocalTransform = pNode->mTransformation;
|
||||||
CalculateGlobalTransform( internalNode);
|
CalculateGlobalTransform( internalNode);
|
||||||
|
|
||||||
// find the index of the animation track affecting this node, if any
|
// find the index of the animation track affecting this node, if any
|
||||||
if( mCurrentAnimIndex < mScene->mNumAnimations)
|
if( mCurrentAnimIndex < mScene->mNumAnimations)
|
||||||
{
|
{
|
||||||
internalNode->mChannelIndex = -1;
|
internalNode->mChannelIndex = -1;
|
||||||
const aiAnimation* currentAnim = mScene->mAnimations[mCurrentAnimIndex];
|
const aiAnimation* currentAnim = mScene->mAnimations[mCurrentAnimIndex];
|
||||||
for( unsigned int a = 0; a < currentAnim->mNumChannels; a++)
|
for( unsigned int a = 0; a < currentAnim->mNumChannels; a++)
|
||||||
{
|
{
|
||||||
if( currentAnim->mChannels[a]->mNodeName.data == internalNode->mName)
|
if( currentAnim->mChannels[a]->mNodeName.data == internalNode->mName)
|
||||||
{
|
{
|
||||||
internalNode->mChannelIndex = a;
|
internalNode->mChannelIndex = a;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue for all child nodes and assign the created internal nodes as our children
|
// continue for all child nodes and assign the created internal nodes as our children
|
||||||
for( unsigned int a = 0; a < pNode->mNumChildren; a++)
|
for( unsigned int a = 0; a < pNode->mNumChildren; a++)
|
||||||
{
|
{
|
||||||
SceneAnimNode* childNode = CreateNodeTree( pNode->mChildren[a], internalNode);
|
SceneAnimNode* childNode = CreateNodeTree( pNode->mChildren[a], internalNode);
|
||||||
internalNode->mChildren.push_back( childNode);
|
internalNode->mChildren.push_back( childNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return internalNode;
|
return internalNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Recursively updates the internal node transformations from the given matrix array
|
// Recursively updates the internal node transformations from the given matrix array
|
||||||
void SceneAnimator::UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms)
|
void SceneAnimator::UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms)
|
||||||
{
|
{
|
||||||
// update node local transform
|
// update node local transform
|
||||||
if( pNode->mChannelIndex != -1)
|
if( pNode->mChannelIndex != -1)
|
||||||
{
|
{
|
||||||
ai_assert( pNode->mChannelIndex < pTransforms.size());
|
ai_assert( pNode->mChannelIndex < pTransforms.size());
|
||||||
pNode->mLocalTransform = pTransforms[pNode->mChannelIndex];
|
pNode->mLocalTransform = pTransforms[pNode->mChannelIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
// update global transform as well
|
// update global transform as well
|
||||||
CalculateGlobalTransform( pNode);
|
CalculateGlobalTransform( pNode);
|
||||||
|
|
||||||
// continue for all children
|
// continue for all children
|
||||||
for( std::vector<SceneAnimNode*>::iterator it = pNode->mChildren.begin(); it != pNode->mChildren.end(); ++it)
|
for( std::vector<SceneAnimNode*>::iterator it = pNode->mChildren.begin(); it != pNode->mChildren.end(); ++it)
|
||||||
UpdateTransforms( *it, pTransforms);
|
UpdateTransforms( *it, pTransforms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Calculates the global transformation matrix for the given internal node
|
// Calculates the global transformation matrix for the given internal node
|
||||||
void SceneAnimator::CalculateGlobalTransform( SceneAnimNode* pInternalNode)
|
void SceneAnimator::CalculateGlobalTransform( SceneAnimNode* pInternalNode)
|
||||||
{
|
{
|
||||||
// concatenate all parent transforms to get the global transform for this node
|
// concatenate all parent transforms to get the global transform for this node
|
||||||
pInternalNode->mGlobalTransform = pInternalNode->mLocalTransform;
|
pInternalNode->mGlobalTransform = pInternalNode->mLocalTransform;
|
||||||
SceneAnimNode* node = pInternalNode->mParent;
|
SceneAnimNode* node = pInternalNode->mParent;
|
||||||
while( node)
|
while( node)
|
||||||
{
|
{
|
||||||
pInternalNode->mGlobalTransform = node->mLocalTransform * pInternalNode->mGlobalTransform;
|
pInternalNode->mGlobalTransform = node->mLocalTransform * pInternalNode->mGlobalTransform;
|
||||||
node = node->mParent;
|
node = node->mParent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,243 +1,243 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @file SceneAnimator.h
|
/** @file SceneAnimator.h
|
||||||
* Manages animations for a given scene and calculates present
|
* Manages animations for a given scene and calculates present
|
||||||
* transformations for all nodes
|
* transformations for all nodes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AV_SCENEANIMATOR_H_INCLUDED
|
#ifndef AV_SCENEANIMATOR_H_INCLUDED
|
||||||
#define AV_SCENEANIMATOR_H_INCLUDED
|
#define AV_SCENEANIMATOR_H_INCLUDED
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** A little tree structure to match the scene's node structure, but holding
|
/** A little tree structure to match the scene's node structure, but holding
|
||||||
* additional data. Needs to be public to allow using it in templates at
|
* additional data. Needs to be public to allow using it in templates at
|
||||||
* certain compilers.
|
* certain compilers.
|
||||||
*/
|
*/
|
||||||
struct SceneAnimNode
|
struct SceneAnimNode
|
||||||
{
|
{
|
||||||
std::string mName;
|
std::string mName;
|
||||||
SceneAnimNode* mParent;
|
SceneAnimNode* mParent;
|
||||||
std::vector<SceneAnimNode*> mChildren;
|
std::vector<SceneAnimNode*> mChildren;
|
||||||
|
|
||||||
//! most recently calculated local transform
|
//! most recently calculated local transform
|
||||||
aiMatrix4x4 mLocalTransform;
|
aiMatrix4x4 mLocalTransform;
|
||||||
|
|
||||||
//! same, but in world space
|
//! same, but in world space
|
||||||
aiMatrix4x4 mGlobalTransform;
|
aiMatrix4x4 mGlobalTransform;
|
||||||
|
|
||||||
//! index in the current animation's channel array. -1 if not animated.
|
//! index in the current animation's channel array. -1 if not animated.
|
||||||
size_t mChannelIndex;
|
size_t mChannelIndex;
|
||||||
|
|
||||||
//! Default construction
|
//! Default construction
|
||||||
SceneAnimNode() {
|
SceneAnimNode() {
|
||||||
mChannelIndex = -1; mParent = NULL;
|
mChannelIndex = -1; mParent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Construction from a given name
|
//! Construction from a given name
|
||||||
SceneAnimNode( const std::string& pName)
|
SceneAnimNode( const std::string& pName)
|
||||||
: mName( pName) {
|
: mName( pName) {
|
||||||
mChannelIndex = -1; mParent = NULL;
|
mChannelIndex = -1; mParent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Destruct all children recursively
|
//! Destruct all children recursively
|
||||||
~SceneAnimNode() {
|
~SceneAnimNode() {
|
||||||
for( std::vector<SceneAnimNode*>::iterator it = mChildren.begin(); it != mChildren.end(); ++it)
|
for( std::vector<SceneAnimNode*>::iterator it = mChildren.begin(); it != mChildren.end(); ++it)
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
/** Calculates the animated node transformations for a given scene and timestamp.
|
/** Calculates the animated node transformations for a given scene and timestamp.
|
||||||
*
|
*
|
||||||
* Create an instance for a aiScene you want to animate and set the current animation
|
* Create an instance for a aiScene you want to animate and set the current animation
|
||||||
* to play. You can then have the instance calculate the current pose for all nodes
|
* to play. You can then have the instance calculate the current pose for all nodes
|
||||||
* by calling Calculate() for a given timestamp. After this you can retrieve the
|
* by calling Calculate() for a given timestamp. After this you can retrieve the
|
||||||
* present transformation for a given node by calling GetLocalTransform() or
|
* present transformation for a given node by calling GetLocalTransform() or
|
||||||
* GetGlobalTransform(). A full set of bone matrices can be retrieved by
|
* GetGlobalTransform(). A full set of bone matrices can be retrieved by
|
||||||
* GetBoneMatrices() for a given mesh.
|
* GetBoneMatrices() for a given mesh.
|
||||||
*/
|
*/
|
||||||
class SceneAnimator
|
class SceneAnimator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Constructor for a given scene.
|
/** Constructor for a given scene.
|
||||||
*
|
*
|
||||||
* The object keeps a reference to the scene during its lifetime, but
|
* The object keeps a reference to the scene during its lifetime, but
|
||||||
* ownership stays at the caller.
|
* ownership stays at the caller.
|
||||||
* @param pScene The scene to animate.
|
* @param pScene The scene to animate.
|
||||||
* @param pAnimIndex [optional] Index of the animation to play. Assumed to
|
* @param pAnimIndex [optional] Index of the animation to play. Assumed to
|
||||||
* be 0 if not given.
|
* be 0 if not given.
|
||||||
*/
|
*/
|
||||||
SceneAnimator( const aiScene* pScene, size_t pAnimIndex = 0);
|
SceneAnimator( const aiScene* pScene, size_t pAnimIndex = 0);
|
||||||
|
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
~SceneAnimator();
|
~SceneAnimator();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Sets the animation to use for playback. This also recreates the internal
|
/** Sets the animation to use for playback. This also recreates the internal
|
||||||
* mapping structures, which might take a few cycles.
|
* mapping structures, which might take a few cycles.
|
||||||
* @param pAnimIndex Index of the animation in the scene's animation array
|
* @param pAnimIndex Index of the animation in the scene's animation array
|
||||||
*/
|
*/
|
||||||
void SetAnimIndex( size_t pAnimIndex);
|
void SetAnimIndex( size_t pAnimIndex);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Calculates the node transformations for the scene. Call this to get
|
/** Calculates the node transformations for the scene. Call this to get
|
||||||
* uptodate results before calling one of the getters.
|
* uptodate results before calling one of the getters.
|
||||||
* @param pTime Current time. Can be an arbitrary range.
|
* @param pTime Current time. Can be an arbitrary range.
|
||||||
*/
|
*/
|
||||||
void Calculate( double pTime);
|
void Calculate( double pTime);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Retrieves the most recent local transformation matrix for the given node.
|
/** Retrieves the most recent local transformation matrix for the given node.
|
||||||
*
|
*
|
||||||
* The returned matrix is in the node's parent's local space, just like the
|
* The returned matrix is in the node's parent's local space, just like the
|
||||||
* original node's transformation matrix. If the node is not animated, the
|
* original node's transformation matrix. If the node is not animated, the
|
||||||
* node's original transformation is returned so that you can safely use or
|
* node's original transformation is returned so that you can safely use or
|
||||||
* assign it to the node itsself. If there is no node with the given name,
|
* assign it to the node itsself. If there is no node with the given name,
|
||||||
* the identity matrix is returned. All transformations are updated whenever
|
* the identity matrix is returned. All transformations are updated whenever
|
||||||
* Calculate() is called.
|
* Calculate() is called.
|
||||||
* @param pNodeName Name of the node
|
* @param pNodeName Name of the node
|
||||||
* @return A reference to the node's most recently calculated local
|
* @return A reference to the node's most recently calculated local
|
||||||
* transformation matrix.
|
* transformation matrix.
|
||||||
*/
|
*/
|
||||||
const aiMatrix4x4& GetLocalTransform( const aiNode* node) const;
|
const aiMatrix4x4& GetLocalTransform( const aiNode* node) const;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Retrieves the most recent global transformation matrix for the given node.
|
/** Retrieves the most recent global transformation matrix for the given node.
|
||||||
*
|
*
|
||||||
* The returned matrix is in world space, which is the same coordinate space
|
* The returned matrix is in world space, which is the same coordinate space
|
||||||
* as the transformation of the scene's root node. If the node is not animated,
|
* as the transformation of the scene's root node. If the node is not animated,
|
||||||
* the node's original transformation is returned so that you can safely use or
|
* the node's original transformation is returned so that you can safely use or
|
||||||
* assign it to the node itsself. If there is no node with the given name, the
|
* assign it to the node itsself. If there is no node with the given name, the
|
||||||
* identity matrix is returned. All transformations are updated whenever
|
* identity matrix is returned. All transformations are updated whenever
|
||||||
* Calculate() is called.
|
* Calculate() is called.
|
||||||
* @param pNodeName Name of the node
|
* @param pNodeName Name of the node
|
||||||
* @return A reference to the node's most recently calculated global
|
* @return A reference to the node's most recently calculated global
|
||||||
* transformation matrix.
|
* transformation matrix.
|
||||||
*/
|
*/
|
||||||
const aiMatrix4x4& GetGlobalTransform( const aiNode* node) const;
|
const aiMatrix4x4& GetGlobalTransform( const aiNode* node) const;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** Calculates the bone matrices for the given mesh.
|
/** Calculates the bone matrices for the given mesh.
|
||||||
*
|
*
|
||||||
* Each bone matrix transforms from mesh space in bind pose to mesh space in
|
* Each bone matrix transforms from mesh space in bind pose to mesh space in
|
||||||
* skinned pose, it does not contain the mesh's world matrix. Thus the usual
|
* skinned pose, it does not contain the mesh's world matrix. Thus the usual
|
||||||
* matrix chain for using in the vertex shader is
|
* matrix chain for using in the vertex shader is
|
||||||
* @code
|
* @code
|
||||||
* boneMatrix * worldMatrix * viewMatrix * projMatrix
|
* boneMatrix * worldMatrix * viewMatrix * projMatrix
|
||||||
* @endcode
|
* @endcode
|
||||||
* @param pNode The node carrying the mesh.
|
* @param pNode The node carrying the mesh.
|
||||||
* @param pMeshIndex Index of the mesh in the node's mesh array. The NODE's
|
* @param pMeshIndex Index of the mesh in the node's mesh array. The NODE's
|
||||||
* mesh array, not the scene's mesh array! Leave out to use the first mesh
|
* mesh array, not the scene's mesh array! Leave out to use the first mesh
|
||||||
* of the node, which is usually also the only one.
|
* of the node, which is usually also the only one.
|
||||||
* @return A reference to a vector of bone matrices. Stays stable till the
|
* @return A reference to a vector of bone matrices. Stays stable till the
|
||||||
* next call to GetBoneMatrices();
|
* next call to GetBoneMatrices();
|
||||||
*/
|
*/
|
||||||
const std::vector<aiMatrix4x4>& GetBoneMatrices( const aiNode* pNode,
|
const std::vector<aiMatrix4x4>& GetBoneMatrices( const aiNode* pNode,
|
||||||
size_t pMeshIndex = 0);
|
size_t pMeshIndex = 0);
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** @brief Get the current animation index
|
/** @brief Get the current animation index
|
||||||
*/
|
*/
|
||||||
size_t CurrentAnimIndex() const {
|
size_t CurrentAnimIndex() const {
|
||||||
return mCurrentAnimIndex;
|
return mCurrentAnimIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/** @brief Get the current animation or NULL
|
/** @brief Get the current animation or NULL
|
||||||
*/
|
*/
|
||||||
aiAnimation* CurrentAnim() const {
|
aiAnimation* CurrentAnim() const {
|
||||||
return mCurrentAnimIndex < mScene->mNumAnimations ? mScene->mAnimations[ mCurrentAnimIndex ] : NULL;
|
return mCurrentAnimIndex < mScene->mNumAnimations ? mScene->mAnimations[ mCurrentAnimIndex ] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** Recursively creates an internal node structure matching the
|
/** Recursively creates an internal node structure matching the
|
||||||
* current scene and animation.
|
* current scene and animation.
|
||||||
*/
|
*/
|
||||||
SceneAnimNode* CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent);
|
SceneAnimNode* CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent);
|
||||||
|
|
||||||
/** Recursively updates the internal node transformations from the
|
/** Recursively updates the internal node transformations from the
|
||||||
* given matrix array
|
* given matrix array
|
||||||
*/
|
*/
|
||||||
void UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms);
|
void UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms);
|
||||||
|
|
||||||
/** Calculates the global transformation matrix for the given internal node */
|
/** Calculates the global transformation matrix for the given internal node */
|
||||||
void CalculateGlobalTransform( SceneAnimNode* pInternalNode);
|
void CalculateGlobalTransform( SceneAnimNode* pInternalNode);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** The scene we're operating on */
|
/** The scene we're operating on */
|
||||||
const aiScene* mScene;
|
const aiScene* mScene;
|
||||||
|
|
||||||
/** Current animation index */
|
/** Current animation index */
|
||||||
size_t mCurrentAnimIndex;
|
size_t mCurrentAnimIndex;
|
||||||
|
|
||||||
/** The AnimEvaluator we use to calculate the current pose for the current animation */
|
/** The AnimEvaluator we use to calculate the current pose for the current animation */
|
||||||
AnimEvaluator* mAnimEvaluator;
|
AnimEvaluator* mAnimEvaluator;
|
||||||
|
|
||||||
/** Root node of the internal scene structure */
|
/** Root node of the internal scene structure */
|
||||||
SceneAnimNode* mRootNode;
|
SceneAnimNode* mRootNode;
|
||||||
|
|
||||||
/** Name to node map to quickly find nodes by their name */
|
/** Name to node map to quickly find nodes by their name */
|
||||||
typedef std::map<const aiNode*, SceneAnimNode*> NodeMap;
|
typedef std::map<const aiNode*, SceneAnimNode*> NodeMap;
|
||||||
NodeMap mNodesByName;
|
NodeMap mNodesByName;
|
||||||
|
|
||||||
/** Name to node map to quickly find nodes for given bones by their name */
|
/** Name to node map to quickly find nodes for given bones by their name */
|
||||||
typedef std::map<const char*, const aiNode*> BoneMap;
|
typedef std::map<const char*, const aiNode*> BoneMap;
|
||||||
BoneMap mBoneNodesByName;
|
BoneMap mBoneNodesByName;
|
||||||
|
|
||||||
/** Array to return transformations results inside. */
|
/** Array to return transformations results inside. */
|
||||||
std::vector<aiMatrix4x4> mTransforms;
|
std::vector<aiMatrix4x4> mTransforms;
|
||||||
|
|
||||||
/** Identity matrix to return a reference to in case of error */
|
/** Identity matrix to return a reference to in case of error */
|
||||||
aiMatrix4x4 mIdentityMatrix;
|
aiMatrix4x4 mIdentityMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace AssimpView
|
} // end of namespace AssimpView
|
||||||
|
|
||||||
#endif // AV_SCENEANIMATOR_H_INCLUDED
|
#endif // AV_SCENEANIMATOR_H_INCLUDED
|
|
@ -1,63 +1,63 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (!defined AV_SHADERS_H_INCLUDED)
|
#if (!defined AV_SHADERS_H_INCLUDED)
|
||||||
#define AV_SHADERS_H_INCLUDED
|
#define AV_SHADERS_H_INCLUDED
|
||||||
|
|
||||||
// Shader used for rendering a skybox background
|
// Shader used for rendering a skybox background
|
||||||
extern std::string g_szSkyboxShader;
|
extern std::string g_szSkyboxShader;
|
||||||
|
|
||||||
// Shader used for visualizing normal vectors
|
// Shader used for visualizing normal vectors
|
||||||
extern std::string g_szNormalsShader;
|
extern std::string g_szNormalsShader;
|
||||||
|
|
||||||
// Default shader
|
// Default shader
|
||||||
extern std::string g_szDefaultShader;
|
extern std::string g_szDefaultShader;
|
||||||
|
|
||||||
// Material shader
|
// Material shader
|
||||||
extern std::string g_szMaterialShader;
|
extern std::string g_szMaterialShader;
|
||||||
|
|
||||||
// Shader used to draw the yellow circle on top of everything
|
// Shader used to draw the yellow circle on top of everything
|
||||||
extern std::string g_szPassThroughShader;
|
extern std::string g_szPassThroughShader;
|
||||||
|
|
||||||
// Shader used to draw the checker pattern background for the texture view
|
// Shader used to draw the checker pattern background for the texture view
|
||||||
extern std::string g_szCheckerBackgroundShader;
|
extern std::string g_szCheckerBackgroundShader;
|
||||||
|
|
||||||
#endif // !! AV_SHADERS_H_INCLUDED
|
#endif // !! AV_SHADERS_H_INCLUDED
|
||||||
|
|
|
@ -1,286 +1,286 @@
|
||||||
/*
|
/*
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2012, assimp team
|
Copyright (c) 2006-2012, assimp team
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
with or without modification, are permitted provided that the following
|
with or without modification, are permitted provided that the following
|
||||||
conditions are met:
|
conditions are met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above
|
* Redistributions of source code must retain the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer.
|
following disclaimer.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above
|
||||||
copyright notice, this list of conditions and the
|
copyright notice, this list of conditions and the
|
||||||
following disclaimer in the documentation and/or other
|
following disclaimer in the documentation and/or other
|
||||||
materials provided with the distribution.
|
materials provided with the distribution.
|
||||||
|
|
||||||
* Neither the name of the assimp team, nor the names of its
|
* Neither the name of the assimp team, nor the names of its
|
||||||
contributors may be used to endorse or promote products
|
contributors may be used to endorse or promote products
|
||||||
derived from this software without specific prior
|
derived from this software without specific prior
|
||||||
written permission of the assimp team.
|
written permission of the assimp team.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (!defined AV_MAIN_H_INCLUDED)
|
#if (!defined AV_MAIN_H_INCLUDED)
|
||||||
#define AV_MAIN_H_INCLUDED
|
#define AV_MAIN_H_INCLUDED
|
||||||
|
|
||||||
#define AI_SHADER_COMPILE_FLAGS D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
|
#define AI_SHADER_COMPILE_FLAGS D3DXSHADER_USE_LEGACY_D3DX9_31_DLL
|
||||||
|
|
||||||
// include resource definitions
|
// include resource definitions
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
// Include ASSIMP headers (XXX: do we really need all of them?)
|
// Include ASSIMP headers (XXX: do we really need all of them?)
|
||||||
#include <assimp/cimport.h>
|
#include <assimp/cimport.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/ai_assert.h>
|
#include <assimp/ai_assert.h>
|
||||||
#include <assimp/cfileio.h>
|
#include <assimp/cfileio.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/IOSystem.hpp>
|
#include <assimp/IOSystem.hpp>
|
||||||
#include <assimp/IOStream.hpp>
|
#include <assimp/IOStream.hpp>
|
||||||
#include <assimp/LogStream.hpp>
|
#include <assimp/LogStream.hpp>
|
||||||
#include <assimp/DefaultLogger.hpp>
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include "../../code/MaterialSystem.h" // aiMaterial class
|
#include "../../code/MaterialSystem.h" // aiMaterial class
|
||||||
#include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp
|
#include "../../code/StringComparison.h" // ASSIMP_stricmp and ASSIMP_strincmp
|
||||||
|
|
||||||
// in order for std::min and std::max to behave properly
|
// in order for std::min and std::max to behave properly
|
||||||
#ifndef max
|
#ifndef max
|
||||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
#endif // max
|
#endif // max
|
||||||
#ifndef min
|
#ifndef min
|
||||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||||
#endif // min
|
#endif // min
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
// default movement speed
|
// default movement speed
|
||||||
#define MOVE_SPEED 3.f
|
#define MOVE_SPEED 3.f
|
||||||
|
|
||||||
#include "AssetHelper.h"
|
#include "AssetHelper.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "RenderOptions.h"
|
#include "RenderOptions.h"
|
||||||
#include "Shaders.h"
|
#include "Shaders.h"
|
||||||
#include "Background.h"
|
#include "Background.h"
|
||||||
#include "LogDisplay.h"
|
#include "LogDisplay.h"
|
||||||
#include "LogWindow.h"
|
#include "LogWindow.h"
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
#include "MeshRenderer.h"
|
#include "MeshRenderer.h"
|
||||||
#include "MaterialManager.h"
|
#include "MaterialManager.h"
|
||||||
|
|
||||||
|
|
||||||
// outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle
|
// outside of namespace, to help Intellisense and solve boost::metatype_stuff_miracle
|
||||||
#include "AnimEvaluator.h"
|
#include "AnimEvaluator.h"
|
||||||
#include "SceneAnimator.h"
|
#include "SceneAnimator.h"
|
||||||
|
|
||||||
namespace AssimpView
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Function prototypes
|
// Function prototypes
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
int InitD3D(void);
|
int InitD3D(void);
|
||||||
int ShutdownD3D(void);
|
int ShutdownD3D(void);
|
||||||
int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true);
|
int CreateDevice (bool p_bMultiSample,bool p_bSuperSample, bool bHW = true);
|
||||||
int CreateDevice (void);
|
int CreateDevice (void);
|
||||||
int ShutdownDevice(void);
|
int ShutdownDevice(void);
|
||||||
int GetProjectionMatrix (aiMatrix4x4& p_mOut);
|
int GetProjectionMatrix (aiMatrix4x4& p_mOut);
|
||||||
int LoadAsset(void);
|
int LoadAsset(void);
|
||||||
int CreateAssetData(void);
|
int CreateAssetData(void);
|
||||||
int DeleteAssetData(bool bNoMaterials = false);
|
int DeleteAssetData(bool bNoMaterials = false);
|
||||||
int ScaleAsset(void);
|
int ScaleAsset(void);
|
||||||
int DeleteAsset(void);
|
int DeleteAsset(void);
|
||||||
int SetupFPSView();
|
int SetupFPSView();
|
||||||
|
|
||||||
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
|
aiVector3D GetCameraMatrix (aiMatrix4x4& p_mOut);
|
||||||
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
|
int CreateMaterial(AssetHelper::MeshHelper* pcMesh,const aiMesh* pcSource);
|
||||||
|
|
||||||
void HandleMouseInputFPS( void );
|
void HandleMouseInputFPS( void );
|
||||||
void HandleMouseInputLightRotate( void );
|
void HandleMouseInputLightRotate( void );
|
||||||
void HandleMouseInputLocal( void );
|
void HandleMouseInputLocal( void );
|
||||||
void HandleKeyboardInputFPS( void );
|
void HandleKeyboardInputFPS( void );
|
||||||
void HandleMouseInputLightIntensityAndColor( void );
|
void HandleMouseInputLightIntensityAndColor( void );
|
||||||
void HandleMouseInputSkyBox( void );
|
void HandleMouseInputSkyBox( void );
|
||||||
void HandleKeyboardInputTextureView( void );
|
void HandleKeyboardInputTextureView( void );
|
||||||
void HandleMouseInputTextureView( void );
|
void HandleMouseInputTextureView( void );
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Dialog procedure for the progress bar window
|
// Dialog procedure for the progress bar window
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam);
|
WPARAM wParam,LPARAM lParam);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Main message procedure of the application
|
// Main message procedure of the application
|
||||||
//
|
//
|
||||||
// The function handles all incoming messages for the main window.
|
// The function handles all incoming messages for the main window.
|
||||||
// However, if does not directly process input commands.
|
// However, if does not directly process input commands.
|
||||||
// NOTE: Due to the impossibility to process WM_CHAR messages in dialogs
|
// NOTE: Due to the impossibility to process WM_CHAR messages in dialogs
|
||||||
// properly the code for all hotkeys has been moved to the WndMain
|
// properly the code for all hotkeys has been moved to the WndMain
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam);
|
WPARAM wParam,LPARAM lParam);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Dialog procedure for the about dialog
|
// Dialog procedure for the about dialog
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam);
|
WPARAM wParam,LPARAM lParam);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Dialog procedure for the help dialog
|
// Dialog procedure for the help dialog
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam);
|
WPARAM wParam,LPARAM lParam);
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Handle command line parameters
|
// Handle command line parameters
|
||||||
//
|
//
|
||||||
// The function loads an asset specified on the command line as first argument
|
// The function loads an asset specified on the command line as first argument
|
||||||
// Other command line parameters are not handled
|
// Other command line parameters are not handled
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
void HandleCommandLine(char* p_szCommand);
|
void HandleCommandLine(char* p_szCommand);
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
template <class type, class intype>
|
template <class type, class intype>
|
||||||
type clamp(intype in)
|
type clamp(intype in)
|
||||||
{
|
{
|
||||||
// for unsigned types only ...
|
// for unsigned types only ...
|
||||||
intype mask = (0x1u << (sizeof(type)*8))-1;
|
intype mask = (0x1u << (sizeof(type)*8))-1;
|
||||||
return (type)max((intype)0,min(in,mask));
|
return (type)max((intype)0,min(in,mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Position of the cursor relative to the 3ds max' like control circle
|
// Position of the cursor relative to the 3ds max' like control circle
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
enum EClickPos
|
enum EClickPos
|
||||||
{
|
{
|
||||||
// The click was inside the inner circle (x,y axis)
|
// The click was inside the inner circle (x,y axis)
|
||||||
EClickPos_Circle,
|
EClickPos_Circle,
|
||||||
// The click was inside one of tghe vertical snap-ins
|
// The click was inside one of tghe vertical snap-ins
|
||||||
EClickPos_CircleVert,
|
EClickPos_CircleVert,
|
||||||
// The click was inside onf of the horizontal snap-ins
|
// The click was inside onf of the horizontal snap-ins
|
||||||
EClickPos_CircleHor,
|
EClickPos_CircleHor,
|
||||||
// the cklick was outside the circle (z-axis)
|
// the cklick was outside the circle (z-axis)
|
||||||
EClickPos_Outside
|
EClickPos_Outside
|
||||||
};
|
};
|
||||||
|
|
||||||
#if (!defined AI_VIEW_CAPTION_BASE)
|
#if (!defined AI_VIEW_CAPTION_BASE)
|
||||||
# define AI_VIEW_CAPTION_BASE "Open Asset Import Library : Viewer "
|
# define AI_VIEW_CAPTION_BASE "Open Asset Import Library : Viewer "
|
||||||
#endif // !! AI_VIEW_CAPTION_BASE
|
#endif // !! AI_VIEW_CAPTION_BASE
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
// Evil globals
|
// Evil globals
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
extern HINSTANCE g_hInstance /*= NULL*/;
|
extern HINSTANCE g_hInstance /*= NULL*/;
|
||||||
extern HWND g_hDlg /*= NULL*/;
|
extern HWND g_hDlg /*= NULL*/;
|
||||||
extern IDirect3D9* g_piD3D /*= NULL*/;
|
extern IDirect3D9* g_piD3D /*= NULL*/;
|
||||||
extern IDirect3DDevice9* g_piDevice /*= NULL*/;
|
extern IDirect3DDevice9* g_piDevice /*= NULL*/;
|
||||||
extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/;
|
extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/;
|
||||||
extern double g_fFPS /*= 0.0f*/;
|
extern double g_fFPS /*= 0.0f*/;
|
||||||
extern char g_szFileName[MAX_PATH];
|
extern char g_szFileName[MAX_PATH];
|
||||||
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/;
|
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/;
|
||||||
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/;
|
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/;
|
||||||
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/;
|
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/;
|
||||||
extern ID3DXEffect* g_piPatternEffect /*= NULL*/;
|
extern ID3DXEffect* g_piPatternEffect /*= NULL*/;
|
||||||
extern bool g_bMousePressed /*= false*/;
|
extern bool g_bMousePressed /*= false*/;
|
||||||
extern bool g_bMousePressedR /*= false*/;
|
extern bool g_bMousePressedR /*= false*/;
|
||||||
extern bool g_bMousePressedM /*= false*/;
|
extern bool g_bMousePressedM /*= false*/;
|
||||||
extern bool g_bMousePressedBoth /*= false*/;
|
extern bool g_bMousePressedBoth /*= false*/;
|
||||||
extern float g_fElpasedTime /*= 0.0f*/;
|
extern float g_fElpasedTime /*= 0.0f*/;
|
||||||
extern D3DCAPS9 g_sCaps;
|
extern D3DCAPS9 g_sCaps;
|
||||||
extern bool g_bLoadingFinished /*= false*/;
|
extern bool g_bLoadingFinished /*= false*/;
|
||||||
extern HANDLE g_hThreadHandle /*= NULL*/;
|
extern HANDLE g_hThreadHandle /*= NULL*/;
|
||||||
extern float g_fWheelPos /*= -10.0f*/;
|
extern float g_fWheelPos /*= -10.0f*/;
|
||||||
extern bool g_bLoadingCanceled /*= false*/;
|
extern bool g_bLoadingCanceled /*= false*/;
|
||||||
extern IDirect3DTexture9* g_pcTexture /*= NULL*/;
|
extern IDirect3DTexture9* g_pcTexture /*= NULL*/;
|
||||||
|
|
||||||
extern aiMatrix4x4 g_mWorld;
|
extern aiMatrix4x4 g_mWorld;
|
||||||
extern aiMatrix4x4 g_mWorldRotate;
|
extern aiMatrix4x4 g_mWorldRotate;
|
||||||
extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/;
|
extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/;
|
||||||
|
|
||||||
extern aiVector3D g_avLightDirs[1] /* =
|
extern aiVector3D g_avLightDirs[1] /* =
|
||||||
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
||||||
aiVector3D(-0.5f,0.5f,0.5f)} */;
|
aiVector3D(-0.5f,0.5f,0.5f)} */;
|
||||||
|
|
||||||
|
|
||||||
extern POINT g_mousePos /*= {0,0};*/;
|
extern POINT g_mousePos /*= {0,0};*/;
|
||||||
extern POINT g_LastmousePos /*= {0,0}*/;
|
extern POINT g_LastmousePos /*= {0,0}*/;
|
||||||
extern bool g_bFPSView /*= false*/;
|
extern bool g_bFPSView /*= false*/;
|
||||||
extern bool g_bInvert /*= false*/;
|
extern bool g_bInvert /*= false*/;
|
||||||
extern EClickPos g_eClick;
|
extern EClickPos g_eClick;
|
||||||
extern unsigned int g_iCurrentColor /*= 0*/;
|
extern unsigned int g_iCurrentColor /*= 0*/;
|
||||||
|
|
||||||
// NOTE: The light intensity is separated from the color, it can
|
// NOTE: The light intensity is separated from the color, it can
|
||||||
// directly be manipulated using the middle mouse button.
|
// directly be manipulated using the middle mouse button.
|
||||||
// When the user chooses a color from the palette the intensity
|
// When the user chooses a color from the palette the intensity
|
||||||
// is reset to 1.0
|
// is reset to 1.0
|
||||||
// index[2] is the ambient color
|
// index[2] is the ambient color
|
||||||
extern float g_fLightIntensity /*=0.0f*/;
|
extern float g_fLightIntensity /*=0.0f*/;
|
||||||
extern D3DCOLOR g_avLightColors[3];
|
extern D3DCOLOR g_avLightColors[3];
|
||||||
|
|
||||||
extern RenderOptions g_sOptions;
|
extern RenderOptions g_sOptions;
|
||||||
extern Camera g_sCamera;
|
extern Camera g_sCamera;
|
||||||
extern AssetHelper *g_pcAsset /*= NULL*/;
|
extern AssetHelper *g_pcAsset /*= NULL*/;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Contains the mask image for the HUD
|
// Contains the mask image for the HUD
|
||||||
// (used to determine the position of a click)
|
// (used to determine the position of a click)
|
||||||
//
|
//
|
||||||
// The size of the image is identical to the size of the main
|
// The size of the image is identical to the size of the main
|
||||||
// HUD texture
|
// HUD texture
|
||||||
//
|
//
|
||||||
extern unsigned char* g_szImageMask /*= NULL*/;
|
extern unsigned char* g_szImageMask /*= NULL*/;
|
||||||
|
|
||||||
|
|
||||||
extern float g_fACMR /*= 3.0f*/;
|
extern float g_fACMR /*= 3.0f*/;
|
||||||
extern IDirect3DQuery9* g_piQuery;
|
extern IDirect3DQuery9* g_piQuery;
|
||||||
|
|
||||||
extern bool g_bPlay /*= false*/;
|
extern bool g_bPlay /*= false*/;
|
||||||
|
|
||||||
extern double g_dCurrent;
|
extern double g_dCurrent;
|
||||||
extern float g_smoothAngle /*= 80.f*/;
|
extern float g_smoothAngle /*= 80.f*/;
|
||||||
|
|
||||||
extern unsigned int ppsteps,ppstepsdefault;
|
extern unsigned int ppsteps,ppstepsdefault;
|
||||||
extern bool nopointslines;
|
extern bool nopointslines;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! AV_MAIN_H_INCLUDED
|
#endif // !! AV_MAIN_H_INCLUDED
|
|
@ -1,74 +1,74 @@
|
||||||
// stdafx.h : Includedatei fĂĽr Standardsystem-Includedateien
|
// stdafx.h : Includedatei fĂĽr Standardsystem-Includedateien
|
||||||
// oder häufig verwendete projektspezifische Includedateien,
|
// oder häufig verwendete projektspezifische Includedateien,
|
||||||
// die nur in unregelmäßigen Abständen geändert werden.
|
// die nur in unregelmäßigen Abständen geändert werden.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Ändern Sie folgende Definitionen für Plattformen, die älter als die unten angegebenen sind.
|
// Ändern Sie folgende Definitionen für Plattformen, die älter als die unten angegebenen sind.
|
||||||
// In MSDN finden Sie die neuesten Informationen ĂĽber die entsprechenden Werte fĂĽr die unterschiedlichen Plattformen.
|
// In MSDN finden Sie die neuesten Informationen ĂĽber die entsprechenden Werte fĂĽr die unterschiedlichen Plattformen.
|
||||||
#ifndef WINVER // Lassen Sie die Verwendung spezifischer Features von Windows XP oder später zu.
|
#ifndef WINVER // Lassen Sie die Verwendung spezifischer Features von Windows XP oder später zu.
|
||||||
# define WINVER 0x0501 // Ă„ndern Sie dies in den geeigneten Wert fĂĽr andere Versionen von Windows.
|
# define WINVER 0x0501 // Ă„ndern Sie dies in den geeigneten Wert fĂĽr andere Versionen von Windows.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_WINNT // Lassen Sie die Verwendung spezifischer Features von Windows XP oder später zu.
|
#ifndef _WIN32_WINNT // Lassen Sie die Verwendung spezifischer Features von Windows XP oder später zu.
|
||||||
# define _WIN32_WINNT 0x0501 // Ă„ndern Sie dies in den geeigneten Wert fĂĽr andere Versionen von Windows.
|
# define _WIN32_WINNT 0x0501 // Ă„ndern Sie dies in den geeigneten Wert fĂĽr andere Versionen von Windows.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_WINDOWS // Lassen Sie die Verwendung spezifischer Features von Windows 98 oder später zu.
|
#ifndef _WIN32_WINDOWS // Lassen Sie die Verwendung spezifischer Features von Windows 98 oder später zu.
|
||||||
# define _WIN32_WINDOWS 0x0410 // Ändern Sie dies in den geeigneten Wert für Windows Me oder höher.
|
# define _WIN32_WINDOWS 0x0410 // Ändern Sie dies in den geeigneten Wert für Windows Me oder höher.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32_IE // Lassen Sie die Verwendung spezifischer Features von IE 6.0 oder später zu.
|
#ifndef _WIN32_IE // Lassen Sie die Verwendung spezifischer Features von IE 6.0 oder später zu.
|
||||||
#define _WIN32_IE 0x0600 // Ă„ndern Sie dies in den geeigneten Wert fĂĽr andere Versionen von IE.
|
#define _WIN32_IE 0x0600 // Ă„ndern Sie dies in den geeigneten Wert fĂĽr andere Versionen von IE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN // Selten verwendete Teile der Windows-Header nicht einbinden.
|
#define WIN32_LEAN_AND_MEAN // Selten verwendete Teile der Windows-Header nicht einbinden.
|
||||||
// Windows-Headerdateien:
|
// Windows-Headerdateien:
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
// C RunTime-Headerdateien
|
// C RunTime-Headerdateien
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
// D3D9 includes
|
// D3D9 includes
|
||||||
|
|
||||||
#if (defined _DEBUG)
|
#if (defined _DEBUG)
|
||||||
# define D3D_DEBUG_INFO
|
# define D3D_DEBUG_INFO
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
#include <d3dx9.h>
|
#include <d3dx9.h>
|
||||||
#include <d3dx9mesh.h>
|
#include <d3dx9mesh.h>
|
||||||
|
|
||||||
// ShellExecute()
|
// ShellExecute()
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
||||||
// GetOpenFileName()
|
// GetOpenFileName()
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if defined _MSC_VER
|
#if defined _MSC_VER
|
||||||
// Windows CommonControls 6.0 Manifest Extensions
|
// Windows CommonControls 6.0 Manifest Extensions
|
||||||
# if defined _M_IX86
|
# if defined _M_IX86
|
||||||
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||||
# elif defined _M_IA64
|
# elif defined _M_IA64
|
||||||
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||||
# elif defined _M_X64
|
# elif defined _M_X64
|
||||||
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||||
# else
|
# else
|
||||||
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
# pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue