Refactor: Apply editor config rules to tools
parent
83defdddc4
commit
5ae1c28881
File diff suppressed because it is too large
Load Diff
|
@ -47,123 +47,123 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,36 +54,36 @@ namespace AssimpView
|
||||||
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
|
||||||
|
|
|
@ -54,7 +54,7 @@ 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
|
||||||
|
|
|
@ -47,43 +47,43 @@ 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;
|
||||||
|
@ -91,380 +91,380 @@ 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -43,43 +43,43 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#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
|
@ -47,11 +47,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
|
||||||
// see CDisplay::m_aiImageList
|
// see CDisplay::m_aiImageList
|
||||||
#define AI_VIEW_IMGLIST_NODE 0x0
|
#define AI_VIEW_IMGLIST_NODE 0x0
|
||||||
#define AI_VIEW_IMGLIST_MATERIAL 0x1
|
#define AI_VIEW_IMGLIST_MATERIAL 0x1
|
||||||
#define AI_VIEW_IMGLIST_TEXTURE 0x2
|
#define AI_VIEW_IMGLIST_TEXTURE 0x2
|
||||||
#define AI_VIEW_IMGLIST_TEXTURE_INVALID 0x3
|
#define AI_VIEW_IMGLIST_TEXTURE_INVALID 0x3
|
||||||
#define AI_VIEW_IMGLIST_MODEL 0x4
|
#define AI_VIEW_IMGLIST_MODEL 0x4
|
||||||
|
|
||||||
namespace AssimpView
|
namespace AssimpView
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,60 +49,60 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -49,40 +49,40 @@ namespace AssimpView {
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -91,25 +91,25 @@ void HandleMouseInputFPS( void )
|
||||||
// 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
|
||||||
|
@ -117,32 +117,32 @@ void HandleMouseInputTextureView( void )
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -152,221 +152,221 @@ void HandleMouseInputLightRotate( void )
|
||||||
// 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 );
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -47,187 +47,187 @@ 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;
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -46,7 +46,7 @@ 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
|
||||||
|
|
|
@ -50,206 +50,206 @@ 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
|
|
@ -47,20 +47,20 @@ 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
|
||||||
|
|
|
@ -63,56 +63,56 @@ namespace AssimpView {
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
extern std::string g_szMaterialShader;
|
extern std::string g_szMaterialShader;
|
||||||
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*/;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -122,13 +122,13 @@ extern AssetHelper *g_pcAsset /*= NULL*/;
|
||||||
// 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*/;
|
||||||
|
@ -319,7 +319,7 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != p_szString);
|
ai_assert(NULL != p_szString);
|
||||||
aiString pcpy = *p_szString;
|
aiString pcpy = *p_szString;
|
||||||
if ('*' == p_szString->data[0]) {
|
if ('*' == p_szString->data[0]) {
|
||||||
// '*' as first character indicates an embedded file
|
// '*' as first character indicates an embedded file
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
@ -1161,7 +1161,7 @@ int CMaterialManager::CreateMaterial(
|
||||||
++iCurrent;
|
++iCurrent;
|
||||||
|
|
||||||
int idx;
|
int idx;
|
||||||
if(AI_SUCCESS == aiGetMaterialInteger(pcMat,AI_MATKEY_UVWSRC_LIGHTMAP(0),&idx) && idx >= 1 && pcSource->mTextureCoords[idx]) {
|
if(AI_SUCCESS == aiGetMaterialInteger(pcMat,AI_MATKEY_UVWSRC_LIGHTMAP(0),&idx) && idx >= 1 && pcSource->mTextureCoords[idx]) {
|
||||||
sMacro[iCurrent].Name = "AV_TWO_UV";
|
sMacro[iCurrent].Name = "AV_TWO_UV";
|
||||||
sMacro[iCurrent].Definition = "1";
|
sMacro[iCurrent].Definition = "1";
|
||||||
++iCurrent;
|
++iCurrent;
|
||||||
|
@ -1360,9 +1360,9 @@ int CMaterialManager::SetupMaterial (
|
||||||
D3DXVec4Normalize(&apcVec[1],&apcVec[1]);
|
D3DXVec4Normalize(&apcVec[1],&apcVec[1]);
|
||||||
piEnd->SetVectorArray("afLightDir",apcVec,5);
|
piEnd->SetVectorArray("afLightDir",apcVec,5);
|
||||||
|
|
||||||
apcVec[0].x = ((g_avLightColors[0] >> 16) & 0xFF) / 255.0f;
|
apcVec[0].x = ((g_avLightColors[0] >> 16) & 0xFF) / 255.0f;
|
||||||
apcVec[0].y = ((g_avLightColors[0] >> 8) & 0xFF) / 255.0f;
|
apcVec[0].y = ((g_avLightColors[0] >> 8) & 0xFF) / 255.0f;
|
||||||
apcVec[0].z = ((g_avLightColors[0]) & 0xFF) / 255.0f;
|
apcVec[0].z = ((g_avLightColors[0]) & 0xFF) / 255.0f;
|
||||||
apcVec[0].w = 1.0f;
|
apcVec[0].w = 1.0f;
|
||||||
|
|
||||||
if( g_sOptions.b3Lights)
|
if( g_sOptions.b3Lights)
|
||||||
|
@ -1383,14 +1383,14 @@ int CMaterialManager::SetupMaterial (
|
||||||
apcVec[1] *= g_fLightIntensity;
|
apcVec[1] *= g_fLightIntensity;
|
||||||
piEnd->SetVectorArray("afLightColor",apcVec,5);
|
piEnd->SetVectorArray("afLightColor",apcVec,5);
|
||||||
|
|
||||||
apcVec[0].x = ((g_avLightColors[2] >> 16) & 0xFF) / 255.0f;
|
apcVec[0].x = ((g_avLightColors[2] >> 16) & 0xFF) / 255.0f;
|
||||||
apcVec[0].y = ((g_avLightColors[2] >> 8) & 0xFF) / 255.0f;
|
apcVec[0].y = ((g_avLightColors[2] >> 8) & 0xFF) / 255.0f;
|
||||||
apcVec[0].z = ((g_avLightColors[2]) & 0xFF) / 255.0f;
|
apcVec[0].z = ((g_avLightColors[2]) & 0xFF) / 255.0f;
|
||||||
apcVec[0].w = 1.0f;
|
apcVec[0].w = 1.0f;
|
||||||
|
|
||||||
apcVec[1].x = ((g_avLightColors[2] >> 16) & 0xFF) / 255.0f;
|
apcVec[1].x = ((g_avLightColors[2] >> 16) & 0xFF) / 255.0f;
|
||||||
apcVec[1].y = ((g_avLightColors[2] >> 8) & 0xFF) / 255.0f;
|
apcVec[1].y = ((g_avLightColors[2] >> 8) & 0xFF) / 255.0f;
|
||||||
apcVec[1].z = ((g_avLightColors[2]) & 0xFF) / 255.0f;
|
apcVec[1].z = ((g_avLightColors[2]) & 0xFF) / 255.0f;
|
||||||
apcVec[1].w = 0.0f;
|
apcVec[1].w = 0.0f;
|
||||||
|
|
||||||
// FIX: light intensity doesn't apply to ambient color
|
// FIX: light intensity doesn't apply to ambient color
|
||||||
|
|
|
@ -51,116 +51,116 @@ 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;
|
||||||
}
|
}
|
||||||
};
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -62,29 +62,29 @@ float g_smoothAngle = 80.f;
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -92,84 +92,84 @@ void AssetHelper::FlipNormals()
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -44,70 +44,70 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
/** \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
|
|
@ -51,195 +51,195 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#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
|
||||||
|
@ -58,35 +58,35 @@ namespace AssimpView {
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
@ -103,139 +103,139 @@ 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
|
||||||
|
|
|
@ -138,7 +138,7 @@ void HandleMouseInputTextureView( void );
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
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
|
||||||
|
@ -149,7 +149,7 @@ INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
// 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);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -157,7 +157,7 @@ INT_PTR CALLBACK MessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam);
|
WPARAM wParam,LPARAM lParam);
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -165,7 +165,7 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
||||||
//
|
//
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
||||||
WPARAM wParam,LPARAM lParam);
|
WPARAM wParam,LPARAM lParam);
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
|
@ -181,9 +181,9 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,95 +192,95 @@ type clamp(intype in)
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
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
|
|
@ -7,23 +7,23 @@
|
||||||
|
|
||||||
// Ä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>
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
// 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>
|
||||||
|
@ -63,12 +63,12 @@
|
||||||
#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