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.
|
||||
AnimEvaluator::AnimEvaluator( const aiAnimation* pAnim)
|
||||
{
|
||||
mAnim = pAnim;
|
||||
mLastTime = 0.0;
|
||||
mLastPositions.resize( pAnim->mNumChannels, boost::make_tuple( 0, 0, 0));
|
||||
mAnim = pAnim;
|
||||
mLastTime = 0.0;
|
||||
mLastPositions.resize( pAnim->mNumChannels, boost::make_tuple( 0, 0, 0));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Evaluates the animation tracks for a given time stamp.
|
||||
void AnimEvaluator::Evaluate( double pTime)
|
||||
{
|
||||
// extract ticks per second. Assume default value if not given
|
||||
double ticksPerSecond = mAnim->mTicksPerSecond != 0.0 ? mAnim->mTicksPerSecond : 25.0;
|
||||
// every following time calculation happens in ticks
|
||||
pTime *= ticksPerSecond;
|
||||
// extract ticks per second. Assume default value if not given
|
||||
double ticksPerSecond = mAnim->mTicksPerSecond != 0.0 ? mAnim->mTicksPerSecond : 25.0;
|
||||
// every following time calculation happens in ticks
|
||||
pTime *= ticksPerSecond;
|
||||
|
||||
// map into anim's duration
|
||||
double time = 0.0f;
|
||||
if( mAnim->mDuration > 0.0)
|
||||
time = fmod( pTime, mAnim->mDuration);
|
||||
// map into anim's duration
|
||||
double time = 0.0f;
|
||||
if( mAnim->mDuration > 0.0)
|
||||
time = fmod( pTime, mAnim->mDuration);
|
||||
|
||||
if( mTransforms.size() != mAnim->mNumChannels)
|
||||
mTransforms.resize( mAnim->mNumChannels);
|
||||
if( mTransforms.size() != mAnim->mNumChannels)
|
||||
mTransforms.resize( mAnim->mNumChannels);
|
||||
|
||||
// calculate the transformations for each animation channel
|
||||
for( unsigned int a = 0; a < mAnim->mNumChannels; a++)
|
||||
{
|
||||
const aiNodeAnim* channel = mAnim->mChannels[a];
|
||||
// calculate the transformations for each animation channel
|
||||
for( unsigned int a = 0; a < mAnim->mNumChannels; a++)
|
||||
{
|
||||
const aiNodeAnim* channel = mAnim->mChannels[a];
|
||||
|
||||
// ******** Position *****
|
||||
aiVector3D presentPosition( 0, 0, 0);
|
||||
if( channel->mNumPositionKeys > 0)
|
||||
{
|
||||
// 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.
|
||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<0>() : 0;
|
||||
while( frame < channel->mNumPositionKeys - 1)
|
||||
{
|
||||
if( time < channel->mPositionKeys[frame+1].mTime)
|
||||
break;
|
||||
frame++;
|
||||
}
|
||||
// ******** Position *****
|
||||
aiVector3D presentPosition( 0, 0, 0);
|
||||
if( channel->mNumPositionKeys > 0)
|
||||
{
|
||||
// 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.
|
||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<0>() : 0;
|
||||
while( frame < channel->mNumPositionKeys - 1)
|
||||
{
|
||||
if( time < channel->mPositionKeys[frame+1].mTime)
|
||||
break;
|
||||
frame++;
|
||||
}
|
||||
|
||||
// interpolate between this frame's value and next frame's value
|
||||
unsigned int nextFrame = (frame + 1) % channel->mNumPositionKeys;
|
||||
const aiVectorKey& key = channel->mPositionKeys[frame];
|
||||
const aiVectorKey& nextKey = channel->mPositionKeys[nextFrame];
|
||||
double diffTime = nextKey.mTime - key.mTime;
|
||||
if( diffTime < 0.0)
|
||||
diffTime += mAnim->mDuration;
|
||||
if( diffTime > 0)
|
||||
{
|
||||
float factor = float( (time - key.mTime) / diffTime);
|
||||
presentPosition = key.mValue + (nextKey.mValue - key.mValue) * factor;
|
||||
} else
|
||||
{
|
||||
presentPosition = key.mValue;
|
||||
}
|
||||
// interpolate between this frame's value and next frame's value
|
||||
unsigned int nextFrame = (frame + 1) % channel->mNumPositionKeys;
|
||||
const aiVectorKey& key = channel->mPositionKeys[frame];
|
||||
const aiVectorKey& nextKey = channel->mPositionKeys[nextFrame];
|
||||
double diffTime = nextKey.mTime - key.mTime;
|
||||
if( diffTime < 0.0)
|
||||
diffTime += mAnim->mDuration;
|
||||
if( diffTime > 0)
|
||||
{
|
||||
float factor = float( (time - key.mTime) / diffTime);
|
||||
presentPosition = key.mValue + (nextKey.mValue - key.mValue) * factor;
|
||||
} else
|
||||
{
|
||||
presentPosition = key.mValue;
|
||||
}
|
||||
|
||||
mLastPositions[a].get<0>() = frame;
|
||||
}
|
||||
mLastPositions[a].get<0>() = frame;
|
||||
}
|
||||
|
||||
// ******** Rotation *********
|
||||
aiQuaternion presentRotation( 1, 0, 0, 0);
|
||||
if( channel->mNumRotationKeys > 0)
|
||||
{
|
||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<1>() : 0;
|
||||
while( frame < channel->mNumRotationKeys - 1)
|
||||
{
|
||||
if( time < channel->mRotationKeys[frame+1].mTime)
|
||||
break;
|
||||
frame++;
|
||||
}
|
||||
// ******** Rotation *********
|
||||
aiQuaternion presentRotation( 1, 0, 0, 0);
|
||||
if( channel->mNumRotationKeys > 0)
|
||||
{
|
||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<1>() : 0;
|
||||
while( frame < channel->mNumRotationKeys - 1)
|
||||
{
|
||||
if( time < channel->mRotationKeys[frame+1].mTime)
|
||||
break;
|
||||
frame++;
|
||||
}
|
||||
|
||||
// interpolate between this frame's value and next frame's value
|
||||
unsigned int nextFrame = (frame + 1) % channel->mNumRotationKeys;
|
||||
const aiQuatKey& key = channel->mRotationKeys[frame];
|
||||
const aiQuatKey& nextKey = channel->mRotationKeys[nextFrame];
|
||||
double diffTime = nextKey.mTime - key.mTime;
|
||||
if( diffTime < 0.0)
|
||||
diffTime += mAnim->mDuration;
|
||||
if( diffTime > 0)
|
||||
{
|
||||
float factor = float( (time - key.mTime) / diffTime);
|
||||
aiQuaternion::Interpolate( presentRotation, key.mValue, nextKey.mValue, factor);
|
||||
} else
|
||||
{
|
||||
presentRotation = key.mValue;
|
||||
}
|
||||
// interpolate between this frame's value and next frame's value
|
||||
unsigned int nextFrame = (frame + 1) % channel->mNumRotationKeys;
|
||||
const aiQuatKey& key = channel->mRotationKeys[frame];
|
||||
const aiQuatKey& nextKey = channel->mRotationKeys[nextFrame];
|
||||
double diffTime = nextKey.mTime - key.mTime;
|
||||
if( diffTime < 0.0)
|
||||
diffTime += mAnim->mDuration;
|
||||
if( diffTime > 0)
|
||||
{
|
||||
float factor = float( (time - key.mTime) / diffTime);
|
||||
aiQuaternion::Interpolate( presentRotation, key.mValue, nextKey.mValue, factor);
|
||||
} else
|
||||
{
|
||||
presentRotation = key.mValue;
|
||||
}
|
||||
|
||||
mLastPositions[a].get<1>() = frame;
|
||||
}
|
||||
mLastPositions[a].get<1>() = frame;
|
||||
}
|
||||
|
||||
// ******** Scaling **********
|
||||
aiVector3D presentScaling( 1, 1, 1);
|
||||
if( channel->mNumScalingKeys > 0)
|
||||
{
|
||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<2>() : 0;
|
||||
while( frame < channel->mNumScalingKeys - 1)
|
||||
{
|
||||
if( time < channel->mScalingKeys[frame+1].mTime)
|
||||
break;
|
||||
frame++;
|
||||
}
|
||||
// ******** Scaling **********
|
||||
aiVector3D presentScaling( 1, 1, 1);
|
||||
if( channel->mNumScalingKeys > 0)
|
||||
{
|
||||
unsigned int frame = (time >= mLastTime) ? mLastPositions[a].get<2>() : 0;
|
||||
while( frame < channel->mNumScalingKeys - 1)
|
||||
{
|
||||
if( time < channel->mScalingKeys[frame+1].mTime)
|
||||
break;
|
||||
frame++;
|
||||
}
|
||||
|
||||
// TODO: (thom) interpolation maybe? This time maybe even logarithmic, not linear
|
||||
presentScaling = channel->mScalingKeys[frame].mValue;
|
||||
mLastPositions[a].get<2>() = frame;
|
||||
}
|
||||
// TODO: (thom) interpolation maybe? This time maybe even logarithmic, not linear
|
||||
presentScaling = channel->mScalingKeys[frame].mValue;
|
||||
mLastPositions[a].get<2>() = frame;
|
||||
}
|
||||
|
||||
// build a transformation matrix from it
|
||||
aiMatrix4x4& mat = mTransforms[a];
|
||||
mat = aiMatrix4x4( presentRotation.GetMatrix());
|
||||
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.a3 *= presentScaling.z; mat.b3 *= presentScaling.z; mat.c3 *= presentScaling.z;
|
||||
mat.a4 = presentPosition.x; mat.b4 = presentPosition.y; mat.c4 = presentPosition.z;
|
||||
//mat.Transpose();
|
||||
}
|
||||
// build a transformation matrix from it
|
||||
aiMatrix4x4& mat = mTransforms[a];
|
||||
mat = aiMatrix4x4( presentRotation.GetMatrix());
|
||||
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.a3 *= presentScaling.z; mat.b3 *= presentScaling.z; mat.c3 *= presentScaling.z;
|
||||
mat.a4 = presentPosition.x; mat.b4 = presentPosition.y; mat.c4 = presentPosition.z;
|
||||
//mat.Transpose();
|
||||
}
|
||||
|
||||
mLastTime = time;
|
||||
mLastTime = time;
|
||||
}
|
||||
|
|
|
@ -54,36 +54,36 @@ namespace AssimpView
|
|||
class AnimEvaluator
|
||||
{
|
||||
public:
|
||||
/** Constructor on a given animation. The animation is fixed throughout the lifetime of
|
||||
* the object.
|
||||
* @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.
|
||||
*/
|
||||
AnimEvaluator( const aiAnimation* pAnim);
|
||||
/** Constructor on a given animation. The animation is fixed throughout the lifetime of
|
||||
* the object.
|
||||
* @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.
|
||||
*/
|
||||
AnimEvaluator( const aiAnimation* pAnim);
|
||||
|
||||
/** 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().
|
||||
* @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.
|
||||
*/
|
||||
void Evaluate( double pTime);
|
||||
/** 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().
|
||||
* @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.
|
||||
*/
|
||||
void Evaluate( double pTime);
|
||||
|
||||
/** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of
|
||||
* the aiAnimation. */
|
||||
const std::vector<aiMatrix4x4>& GetTransformations() const { return mTransforms; }
|
||||
/** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of
|
||||
* the aiAnimation. */
|
||||
const std::vector<aiMatrix4x4>& GetTransformations() const { return mTransforms; }
|
||||
|
||||
protected:
|
||||
/** The animation we're working on */
|
||||
const aiAnimation* mAnim;
|
||||
/** The animation we're working on */
|
||||
const aiAnimation* mAnim;
|
||||
|
||||
/** At which frame the last evaluation happened for each channel.
|
||||
* Useful to quickly find the corresponding frame for slightly increased time stamps
|
||||
*/
|
||||
double mLastTime;
|
||||
std::vector<boost::tuple<unsigned int, unsigned int, unsigned int> > mLastPositions;
|
||||
/** At which frame the last evaluation happened for each channel.
|
||||
* Useful to quickly find the corresponding frame for slightly increased time stamps
|
||||
*/
|
||||
double mLastTime;
|
||||
std::vector<boost::tuple<unsigned int, unsigned int, unsigned int> > mLastPositions;
|
||||
|
||||
/** The array to store the transformations results of the evaluation */
|
||||
std::vector<aiMatrix4x4> mTransforms;
|
||||
/** The array to store the transformations results of the evaluation */
|
||||
std::vector<aiMatrix4x4> mTransforms;
|
||||
};
|
||||
|
||||
} // end of namespace AssimpView
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace AssimpView {
|
|||
class SceneAnimator;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
/** \brief Class to wrap ASSIMP's asset output structures
|
||||
/** \brief Class to wrap ASSIMP's asset output structures
|
||||
*/
|
||||
//-------------------------------------------------------------------------------
|
||||
class AssetHelper
|
||||
|
|
|
@ -47,43 +47,43 @@ extern std::string g_szSkyboxShader;
|
|||
|
||||
// From: U3D build 1256 (src\kernel\graphic\scenegraph\SkyBox.cpp)
|
||||
// ------------------------------------------------------------------------------
|
||||
/** \brief Vertex structure for the skybox
|
||||
/** \brief Vertex structure for the skybox
|
||||
*/
|
||||
// ------------------------------------------------------------------------------
|
||||
struct SkyBoxVertex
|
||||
{
|
||||
float x,y,z;
|
||||
float u,v,w;
|
||||
float x,y,z;
|
||||
float u,v,w;
|
||||
};
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
/** \brief Vertices for the skybox
|
||||
/** \brief Vertices for the skybox
|
||||
*/
|
||||
// ------------------------------------------------------------------------------
|
||||
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 }, // 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 }, // 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 }, // 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 } // 7
|
||||
{ -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 }, // 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 }, // 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 }, // 6
|
||||
{ 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[] =
|
||||
{
|
||||
0, 1, 2, 3, 2, 1,4, 5, 6,
|
||||
7, 6, 5, 4, 6, 0, 1, 6, 0,
|
||||
5, 2, 7,3, 2, 7, 1, 6, 3,
|
||||
7, 3, 6, 0, 2, 4, 5, 4, 2,
|
||||
0, 1, 2, 3, 2, 1,4, 5, 6,
|
||||
7, 6, 5, 4, 6, 0, 1, 6, 0,
|
||||
5, 2, 7,3, 2, 7, 1, 6, 3,
|
||||
7, 3, 6, 0, 2, 4, 5, 4, 2,
|
||||
};
|
||||
|
||||
CBackgroundPainter CBackgroundPainter::s_cInstance;
|
||||
|
@ -91,380 +91,380 @@ CBackgroundPainter CBackgroundPainter::s_cInstance;
|
|||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::SetColor (D3DCOLOR p_clrNew)
|
||||
{
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
RemoveSBDeps();
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
RemoveSBDeps();
|
||||
|
||||
clrColor = p_clrNew;
|
||||
eMode = SIMPLE_COLOR;
|
||||
clrColor = p_clrNew;
|
||||
eMode = SIMPLE_COLOR;
|
||||
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
}
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::RemoveSBDeps()
|
||||
{
|
||||
MODE e = eMode;
|
||||
eMode = SIMPLE_COLOR;
|
||||
if (g_pcAsset && g_pcAsset->pcScene)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (aiShadingMode_Gouraud != g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||
{
|
||||
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
||||
CMaterialManager::Instance().CreateMaterial(
|
||||
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
eMode = e;
|
||||
MODE e = eMode;
|
||||
eMode = SIMPLE_COLOR;
|
||||
if (g_pcAsset && g_pcAsset->pcScene)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (aiShadingMode_Gouraud != g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||
{
|
||||
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
||||
CMaterialManager::Instance().CreateMaterial(
|
||||
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
eMode = e;
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::ResetSB()
|
||||
{
|
||||
mMatrix = aiMatrix4x4();
|
||||
mMatrix = aiMatrix4x4();
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::SetCubeMapBG (const char* p_szPath)
|
||||
{
|
||||
bool bHad = false;
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
if(TEXTURE_CUBE ==eMode)bHad = true;
|
||||
}
|
||||
bool bHad = false;
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
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!
|
||||
aiString sz;
|
||||
sz.Set(szPath);
|
||||
CMaterialManager::Instance().FindValidPath(&sz);
|
||||
szPath = std::string( sz.data );
|
||||
// ARRRGHH... ugly. TODO: Rewrite this!
|
||||
aiString sz;
|
||||
sz.Set(szPath);
|
||||
CMaterialManager::Instance().FindValidPath(&sz);
|
||||
szPath = std::string( sz.data );
|
||||
|
||||
// now recreate all native resources
|
||||
RecreateNativeResource();
|
||||
// now recreate all native resources
|
||||
RecreateNativeResource();
|
||||
|
||||
if (SIMPLE_COLOR != this->eMode)
|
||||
{
|
||||
// this influences all material with specular components
|
||||
if (!bHad)
|
||||
{
|
||||
if (g_pcAsset && g_pcAsset->pcScene)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||
{
|
||||
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
||||
CMaterialManager::Instance().CreateMaterial(
|
||||
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_pcAsset && g_pcAsset->pcScene)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||
{
|
||||
g_pcAsset->apcMeshes[i]->piEffect->SetTexture(
|
||||
"lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SIMPLE_COLOR != this->eMode)
|
||||
{
|
||||
// this influences all material with specular components
|
||||
if (!bHad)
|
||||
{
|
||||
if (g_pcAsset && g_pcAsset->pcScene)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||
{
|
||||
CMaterialManager::Instance().DeleteMaterial(g_pcAsset->apcMeshes[i]);
|
||||
CMaterialManager::Instance().CreateMaterial(
|
||||
g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_pcAsset && g_pcAsset->pcScene)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode)
|
||||
{
|
||||
g_pcAsset->apcMeshes[i]->piEffect->SetTexture(
|
||||
"lw_tex_envmap",CBackgroundPainter::Instance().GetTexture());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::RotateSB(const aiMatrix4x4* pm)
|
||||
{
|
||||
this->mMatrix = mMatrix * (*pm);
|
||||
this->mMatrix = mMatrix * (*pm);
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::SetTextureBG (const char* p_szPath)
|
||||
{
|
||||
if (TEXTURE_CUBE == this->eMode)this->RemoveSBDeps();
|
||||
if (TEXTURE_CUBE == this->eMode)this->RemoveSBDeps();
|
||||
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
}
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
}
|
||||
|
||||
eMode = TEXTURE_2D;
|
||||
szPath = std::string( p_szPath );
|
||||
eMode = TEXTURE_2D;
|
||||
szPath = std::string( p_szPath );
|
||||
|
||||
// ARRRGHH... ugly. TODO: Rewrite this!
|
||||
aiString sz;
|
||||
sz.Set(szPath);
|
||||
CMaterialManager::Instance().FindValidPath(&sz);
|
||||
szPath = std::string( sz.data );
|
||||
// ARRRGHH... ugly. TODO: Rewrite this!
|
||||
aiString sz;
|
||||
sz.Set(szPath);
|
||||
CMaterialManager::Instance().FindValidPath(&sz);
|
||||
szPath = std::string( sz.data );
|
||||
|
||||
// now recreate all native resources
|
||||
RecreateNativeResource();
|
||||
// now recreate all native resources
|
||||
RecreateNativeResource();
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::OnPreRender()
|
||||
{
|
||||
if (SIMPLE_COLOR != eMode)
|
||||
{
|
||||
// clear the z-buffer only (in wireframe mode we must also clear
|
||||
// the color buffer )
|
||||
if (g_sOptions.eDrawMode == RenderOptions::WIREFRAME)
|
||||
{
|
||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
|
||||
D3DCOLOR_ARGB(0xff,100,100,100),1.0f,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
||||
}
|
||||
if (SIMPLE_COLOR != eMode)
|
||||
{
|
||||
// clear the z-buffer only (in wireframe mode we must also clear
|
||||
// the color buffer )
|
||||
if (g_sOptions.eDrawMode == RenderOptions::WIREFRAME)
|
||||
{
|
||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
|
||||
D3DCOLOR_ARGB(0xff,100,100,100),1.0f,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_piDevice->Clear(0,NULL,D3DCLEAR_ZBUFFER,0,1.0f,0);
|
||||
}
|
||||
|
||||
if (TEXTURE_2D == eMode)
|
||||
{
|
||||
RECT sRect;
|
||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
||||
sRect.right -= sRect.left;
|
||||
sRect.bottom -= sRect.top;
|
||||
if (TEXTURE_2D == eMode)
|
||||
{
|
||||
RECT sRect;
|
||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
||||
sRect.right -= sRect.left;
|
||||
sRect.bottom -= sRect.top;
|
||||
|
||||
struct SVertex
|
||||
{
|
||||
float x,y,z,w,u,v;
|
||||
};
|
||||
struct SVertex
|
||||
{
|
||||
float x,y,z,w,u,v;
|
||||
};
|
||||
|
||||
UINT dw;
|
||||
this->piSkyBoxEffect->Begin(&dw,0);
|
||||
this->piSkyBoxEffect->BeginPass(0);
|
||||
UINT dw;
|
||||
this->piSkyBoxEffect->Begin(&dw,0);
|
||||
this->piSkyBoxEffect->BeginPass(0);
|
||||
|
||||
SVertex as[4];
|
||||
as[1].x = 0.0f;
|
||||
as[1].y = 0.0f;
|
||||
as[1].z = 0.2f;
|
||||
as[1].w = 1.0f;
|
||||
as[1].u = 0.0f;
|
||||
as[1].v = 0.0f;
|
||||
SVertex as[4];
|
||||
as[1].x = 0.0f;
|
||||
as[1].y = 0.0f;
|
||||
as[1].z = 0.2f;
|
||||
as[1].w = 1.0f;
|
||||
as[1].u = 0.0f;
|
||||
as[1].v = 0.0f;
|
||||
|
||||
as[3].x = (float)sRect.right;
|
||||
as[3].y = 0.0f;
|
||||
as[3].z = 0.2f;
|
||||
as[3].w = 1.0f;
|
||||
as[3].u = 1.0f;
|
||||
as[3].v = 0.0f;
|
||||
as[3].x = (float)sRect.right;
|
||||
as[3].y = 0.0f;
|
||||
as[3].z = 0.2f;
|
||||
as[3].w = 1.0f;
|
||||
as[3].u = 1.0f;
|
||||
as[3].v = 0.0f;
|
||||
|
||||
as[0].x = 0.0f;
|
||||
as[0].y = (float)sRect.bottom;
|
||||
as[0].z = 0.2f;
|
||||
as[0].w = 1.0f;
|
||||
as[0].u = 0.0f;
|
||||
as[0].v = 1.0f;
|
||||
as[0].x = 0.0f;
|
||||
as[0].y = (float)sRect.bottom;
|
||||
as[0].z = 0.2f;
|
||||
as[0].w = 1.0f;
|
||||
as[0].u = 0.0f;
|
||||
as[0].v = 1.0f;
|
||||
|
||||
as[2].x = (float)sRect.right;
|
||||
as[2].y = (float)sRect.bottom;
|
||||
as[2].z = 0.2f;
|
||||
as[2].w = 1.0f;
|
||||
as[2].u = 1.0f;
|
||||
as[2].v = 1.0f;
|
||||
as[2].x = (float)sRect.right;
|
||||
as[2].y = (float)sRect.bottom;
|
||||
as[2].z = 0.2f;
|
||||
as[2].w = 1.0f;
|
||||
as[2].u = 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].y -= 0.5f;as[1].y -= 0.5f;as[2].y -= 0.5f;as[3].y -= 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;
|
||||
|
||||
DWORD dw2;g_piDevice->GetFVF(&dw2);
|
||||
g_piDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
DWORD dw2;g_piDevice->GetFVF(&dw2);
|
||||
g_piDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
|
||||
|
||||
g_piDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,
|
||||
&as,sizeof(SVertex));
|
||||
g_piDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,
|
||||
&as,sizeof(SVertex));
|
||||
|
||||
piSkyBoxEffect->EndPass();
|
||||
piSkyBoxEffect->End();
|
||||
piSkyBoxEffect->EndPass();
|
||||
piSkyBoxEffect->End();
|
||||
|
||||
g_piDevice->SetFVF(dw2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// clear both the render target and the z-buffer
|
||||
g_piDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||
clrColor,1.0f,0);
|
||||
g_piDevice->SetFVF(dw2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// clear both the render target and the z-buffer
|
||||
g_piDevice->Clear(0,NULL,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||
clrColor,1.0f,0);
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::OnPostRender()
|
||||
{
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
{
|
||||
aiMatrix4x4 pcProj;
|
||||
GetProjectionMatrix(pcProj);
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
{
|
||||
aiMatrix4x4 pcProj;
|
||||
GetProjectionMatrix(pcProj);
|
||||
|
||||
aiMatrix4x4 pcCam;
|
||||
aiVector3D vPos = GetCameraMatrix(pcCam);
|
||||
aiMatrix4x4 pcCam;
|
||||
aiVector3D vPos = GetCameraMatrix(pcCam);
|
||||
|
||||
aiMatrix4x4 aiMe;
|
||||
aiMe[3][0] = vPos.x;
|
||||
aiMe[3][1] = vPos.y;
|
||||
aiMe[3][2] = vPos.z;
|
||||
aiMe = mMatrix * aiMe;
|
||||
aiMatrix4x4 aiMe;
|
||||
aiMe[3][0] = vPos.x;
|
||||
aiMe[3][1] = vPos.y;
|
||||
aiMe[3][2] = vPos.z;
|
||||
aiMe = mMatrix * aiMe;
|
||||
|
||||
pcProj = (aiMe * pcCam) * pcProj;
|
||||
pcProj = (aiMe * pcCam) * pcProj;
|
||||
|
||||
piSkyBoxEffect->SetMatrix("WorldViewProjection",
|
||||
(const D3DXMATRIX*)&pcProj);
|
||||
piSkyBoxEffect->SetMatrix("WorldViewProjection",
|
||||
(const D3DXMATRIX*)&pcProj);
|
||||
|
||||
UINT dwPasses;
|
||||
piSkyBoxEffect->Begin(&dwPasses,0);
|
||||
piSkyBoxEffect->BeginPass(0);
|
||||
UINT dwPasses;
|
||||
piSkyBoxEffect->Begin(&dwPasses,0);
|
||||
piSkyBoxEffect->BeginPass(0);
|
||||
|
||||
DWORD dw2;
|
||||
g_piDevice->GetFVF(&dw2);
|
||||
g_piDevice->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
|
||||
DWORD dw2;
|
||||
g_piDevice->GetFVF(&dw2);
|
||||
g_piDevice->SetFVF(D3DFVF_XYZ | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0));
|
||||
|
||||
g_piDevice->DrawIndexedPrimitiveUP(
|
||||
D3DPT_TRIANGLELIST,0,8,12,g_cubeIndices,D3DFMT_INDEX16,
|
||||
g_cubeVertices_indexed,sizeof(SkyBoxVertex));
|
||||
g_piDevice->DrawIndexedPrimitiveUP(
|
||||
D3DPT_TRIANGLELIST,0,8,12,g_cubeIndices,D3DFMT_INDEX16,
|
||||
g_cubeVertices_indexed,sizeof(SkyBoxVertex));
|
||||
|
||||
g_piDevice->SetFVF(dw2);
|
||||
g_piDevice->SetFVF(dw2);
|
||||
|
||||
piSkyBoxEffect->EndPass();
|
||||
piSkyBoxEffect->End();
|
||||
}
|
||||
piSkyBoxEffect->EndPass();
|
||||
piSkyBoxEffect->End();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::ReleaseNativeResource()
|
||||
{
|
||||
if ( piSkyBoxEffect)
|
||||
{
|
||||
piSkyBoxEffect->Release();
|
||||
piSkyBoxEffect = NULL;
|
||||
}
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
}
|
||||
if ( piSkyBoxEffect)
|
||||
{
|
||||
piSkyBoxEffect->Release();
|
||||
piSkyBoxEffect = NULL;
|
||||
}
|
||||
if (pcTexture)
|
||||
{
|
||||
pcTexture->Release();
|
||||
pcTexture = NULL;
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CBackgroundPainter::RecreateNativeResource()
|
||||
{
|
||||
if (SIMPLE_COLOR == eMode)return;
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
{
|
||||
if (SIMPLE_COLOR == eMode)return;
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
{
|
||||
|
||||
// many skyboxes are 16bit FP format which isn't supported
|
||||
// with bilinear filtering on older cards
|
||||
D3DFORMAT eFmt = D3DFMT_UNKNOWN;
|
||||
if(FAILED(g_piD3D->CheckDeviceFormat(0,D3DDEVTYPE_HAL,
|
||||
D3DFMT_X8R8G8B8,D3DUSAGE_QUERY_FILTER,D3DRTYPE_CUBETEXTURE,D3DFMT_A16B16G16R16F)))
|
||||
{
|
||||
eFmt = D3DFMT_A8R8G8B8;
|
||||
}
|
||||
// many skyboxes are 16bit FP format which isn't supported
|
||||
// with bilinear filtering on older cards
|
||||
D3DFORMAT eFmt = D3DFMT_UNKNOWN;
|
||||
if(FAILED(g_piD3D->CheckDeviceFormat(0,D3DDEVTYPE_HAL,
|
||||
D3DFMT_X8R8G8B8,D3DUSAGE_QUERY_FILTER,D3DRTYPE_CUBETEXTURE,D3DFMT_A16B16G16R16F)))
|
||||
{
|
||||
eFmt = D3DFMT_A8R8G8B8;
|
||||
}
|
||||
|
||||
if (FAILED(D3DXCreateCubeTextureFromFileEx(
|
||||
g_piDevice,
|
||||
szPath.c_str(),
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
0,
|
||||
eFmt,
|
||||
D3DPOOL_MANAGED,
|
||||
D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
(IDirect3DCubeTexture9**)&pcTexture)))
|
||||
{
|
||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
||||
if (!szEnd)szEnd = szPath.c_str()-1;
|
||||
if (FAILED(D3DXCreateCubeTextureFromFileEx(
|
||||
g_piDevice,
|
||||
szPath.c_str(),
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
0,
|
||||
eFmt,
|
||||
D3DPOOL_MANAGED,
|
||||
D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
(IDirect3DCubeTexture9**)&pcTexture)))
|
||||
{
|
||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
||||
if (!szEnd)szEnd = szPath.c_str()-1;
|
||||
|
||||
char szTemp[1024];
|
||||
sprintf(szTemp,"[ERROR] Unable to load background cubemap %s",szEnd+1);
|
||||
char szTemp[1024];
|
||||
sprintf(szTemp,"[ERROR] Unable to load background cubemap %s",szEnd+1);
|
||||
|
||||
CLogDisplay::Instance().AddEntry(szTemp,
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
CLogDisplay::Instance().AddEntry(szTemp,
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
|
||||
eMode = SIMPLE_COLOR;
|
||||
return;
|
||||
}
|
||||
else CLogDisplay::Instance().AddEntry("[OK] The skybox has been imported successfully",
|
||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(D3DXCreateTextureFromFileEx(
|
||||
g_piDevice,
|
||||
szPath.c_str(),
|
||||
D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
0,
|
||||
D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED,
|
||||
D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
(IDirect3DTexture9**)&pcTexture)))
|
||||
{
|
||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
||||
if (!szEnd)szEnd = szPath.c_str()-1;
|
||||
eMode = SIMPLE_COLOR;
|
||||
return;
|
||||
}
|
||||
else CLogDisplay::Instance().AddEntry("[OK] The skybox has been imported successfully",
|
||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FAILED(D3DXCreateTextureFromFileEx(
|
||||
g_piDevice,
|
||||
szPath.c_str(),
|
||||
D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
0,
|
||||
D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_MANAGED,
|
||||
D3DX_DEFAULT,
|
||||
D3DX_DEFAULT,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
(IDirect3DTexture9**)&pcTexture)))
|
||||
{
|
||||
const char* szEnd = strrchr(szPath.c_str(),'\\');
|
||||
if (!szEnd)szEnd = strrchr(szPath.c_str(),'/');
|
||||
if (!szEnd)szEnd = szPath.c_str()-1;
|
||||
|
||||
char szTemp[1024];
|
||||
sprintf(szTemp,"[ERROR] Unable to load background texture %s",szEnd+1);
|
||||
char szTemp[1024];
|
||||
sprintf(szTemp,"[ERROR] Unable to load background texture %s",szEnd+1);
|
||||
|
||||
CLogDisplay::Instance().AddEntry(szTemp,
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
CLogDisplay::Instance().AddEntry(szTemp,
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
|
||||
eMode = SIMPLE_COLOR;
|
||||
return;
|
||||
}
|
||||
else CLogDisplay::Instance().AddEntry("[OK] The background texture has been imported successfully",
|
||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||
}
|
||||
if (!piSkyBoxEffect)
|
||||
{
|
||||
ID3DXBuffer* piBuffer = NULL;
|
||||
if(FAILED( D3DXCreateEffect(
|
||||
g_piDevice,
|
||||
g_szSkyboxShader.c_str(),
|
||||
(UINT)g_szSkyboxShader.length(),
|
||||
NULL,
|
||||
NULL,
|
||||
AI_SHADER_COMPILE_FLAGS,
|
||||
NULL,
|
||||
&piSkyBoxEffect,&piBuffer)))
|
||||
{
|
||||
// failed to compile the shader
|
||||
if( piBuffer) {
|
||||
MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK);
|
||||
piBuffer->Release();
|
||||
}
|
||||
eMode = SIMPLE_COLOR;
|
||||
return;
|
||||
}
|
||||
else CLogDisplay::Instance().AddEntry("[OK] The background texture has been imported successfully",
|
||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||
}
|
||||
if (!piSkyBoxEffect)
|
||||
{
|
||||
ID3DXBuffer* piBuffer = NULL;
|
||||
if(FAILED( D3DXCreateEffect(
|
||||
g_piDevice,
|
||||
g_szSkyboxShader.c_str(),
|
||||
(UINT)g_szSkyboxShader.length(),
|
||||
NULL,
|
||||
NULL,
|
||||
AI_SHADER_COMPILE_FLAGS,
|
||||
NULL,
|
||||
&piSkyBoxEffect,&piBuffer)))
|
||||
{
|
||||
// failed to compile the shader
|
||||
if( piBuffer) {
|
||||
MessageBox(g_hDlg,(LPCSTR)piBuffer->GetBufferPointer(),"HLSL",MB_OK);
|
||||
piBuffer->Release();
|
||||
}
|
||||
|
||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to compile skybox shader",
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
eMode = SIMPLE_COLOR;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
// commit the correct textures to the shader
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
{
|
||||
piSkyBoxEffect->SetTexture("lw_tex_envmap",pcTexture);
|
||||
piSkyBoxEffect->SetTechnique("RenderSkyBox");
|
||||
}
|
||||
else if (TEXTURE_2D == eMode)
|
||||
{
|
||||
piSkyBoxEffect->SetTexture("TEXTURE_2D",pcTexture);
|
||||
piSkyBoxEffect->SetTechnique("RenderImage2D");
|
||||
}
|
||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to compile skybox shader",
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
eMode = SIMPLE_COLOR;
|
||||
return ;
|
||||
}
|
||||
}
|
||||
// commit the correct textures to the shader
|
||||
if (TEXTURE_CUBE == eMode)
|
||||
{
|
||||
piSkyBoxEffect->SetTexture("lw_tex_envmap",pcTexture);
|
||||
piSkyBoxEffect->SetTechnique("RenderSkyBox");
|
||||
}
|
||||
else if (TEXTURE_2D == eMode)
|
||||
{
|
||||
piSkyBoxEffect->SetTexture("TEXTURE_2D",pcTexture);
|
||||
piSkyBoxEffect->SetTechnique("RenderImage2D");
|
||||
}
|
||||
}
|
||||
};
|
|
@ -43,43 +43,43 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define AV_CAMERA_H_INCLUDED
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
/** \brief Camera class
|
||||
/** \brief Camera class
|
||||
*/
|
||||
//-------------------------------------------------------------------------------
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
Camera ()
|
||||
:
|
||||
Camera ()
|
||||
:
|
||||
|
||||
vPos(0.0f,0.0f,-10.0f),
|
||||
vUp(0.0f,1.0f,0.0f),
|
||||
vLookAt(0.0f,0.0f,1.0f),
|
||||
vRight(0.0f,1.0f,0.0f)
|
||||
{
|
||||
vPos(0.0f,0.0f,-10.0f),
|
||||
vUp(0.0f,1.0f,0.0f),
|
||||
vLookAt(0.0f,0.0f,1.0f),
|
||||
vRight(0.0f,1.0f,0.0f)
|
||||
{
|
||||
|
||||
}
|
||||
public:
|
||||
}
|
||||
public:
|
||||
|
||||
// position of the camera
|
||||
aiVector3D vPos;
|
||||
// position of the camera
|
||||
aiVector3D vPos;
|
||||
|
||||
// up-vector of the camera
|
||||
aiVector3D vUp;
|
||||
// up-vector of the camera
|
||||
aiVector3D vUp;
|
||||
|
||||
// camera's looking point is vPos + vLookAt
|
||||
aiVector3D vLookAt;
|
||||
// camera's looking point is vPos + vLookAt
|
||||
aiVector3D vLookAt;
|
||||
|
||||
// right vector of the camera
|
||||
aiVector3D vRight;
|
||||
// right vector of the camera
|
||||
aiVector3D vRight;
|
||||
|
||||
|
||||
// Equation
|
||||
// (vRight ^ vUp) - vLookAt == 0
|
||||
// needn't apply
|
||||
// Equation
|
||||
// (vRight ^ vUp) - vLookAt == 0
|
||||
// needn't apply
|
||||
|
||||
} ;
|
||||
} ;
|
||||
|
||||
#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>
|
||||
|
||||
// see CDisplay::m_aiImageList
|
||||
#define AI_VIEW_IMGLIST_NODE 0x0
|
||||
#define AI_VIEW_IMGLIST_MATERIAL 0x1
|
||||
#define AI_VIEW_IMGLIST_TEXTURE 0x2
|
||||
#define AI_VIEW_IMGLIST_NODE 0x0
|
||||
#define AI_VIEW_IMGLIST_MATERIAL 0x1
|
||||
#define AI_VIEW_IMGLIST_TEXTURE 0x2
|
||||
#define AI_VIEW_IMGLIST_TEXTURE_INVALID 0x3
|
||||
#define AI_VIEW_IMGLIST_MODEL 0x4
|
||||
#define AI_VIEW_IMGLIST_MODEL 0x4
|
||||
|
||||
namespace AssimpView
|
||||
{
|
||||
|
|
|
@ -49,60 +49,60 @@ namespace AssimpView {
|
|||
// Message procedure for the help dialog
|
||||
//-------------------------------------------------------------------------------
|
||||
INT_PTR CALLBACK HelpDialogProc(HWND hwndDlg,UINT uMsg,
|
||||
WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
(void)lParam;
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
// load the help file ...
|
||||
HRSRC res = FindResource(NULL,MAKEINTRESOURCE(IDR_TEXT1),"TEXT");
|
||||
HGLOBAL hg = LoadResource(NULL,res);
|
||||
void* pData = LockResource(hg);
|
||||
WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
(void)lParam;
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
// load the help file ...
|
||||
HRSRC res = FindResource(NULL,MAKEINTRESOURCE(IDR_TEXT1),"TEXT");
|
||||
HGLOBAL hg = LoadResource(NULL,res);
|
||||
void* pData = LockResource(hg);
|
||||
|
||||
SETTEXTEX sInfo;
|
||||
sInfo.flags = ST_DEFAULT;
|
||||
sInfo.codepage = CP_ACP;
|
||||
SETTEXTEX sInfo;
|
||||
sInfo.flags = ST_DEFAULT;
|
||||
sInfo.codepage = CP_ACP;
|
||||
|
||||
SendDlgItemMessage(hwndDlg,IDC_RICHEDIT21,
|
||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM) pData);
|
||||
SendDlgItemMessage(hwndDlg,IDC_RICHEDIT21,
|
||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM) pData);
|
||||
|
||||
FreeResource(hg);
|
||||
return TRUE;
|
||||
}
|
||||
FreeResource(hg);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_CLOSE:
|
||||
EndDialog(hwndDlg,0);
|
||||
return TRUE;
|
||||
case WM_CLOSE:
|
||||
EndDialog(hwndDlg,0);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
case WM_COMMAND:
|
||||
|
||||
if (IDOK == LOWORD(wParam))
|
||||
{
|
||||
EndDialog(hwndDlg,0);
|
||||
return TRUE;
|
||||
}
|
||||
if (IDOK == LOWORD(wParam))
|
||||
{
|
||||
EndDialog(hwndDlg,0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT sPaint;
|
||||
HDC hdc = BeginPaint(hwndDlg,&sPaint);
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT sPaint;
|
||||
HDC hdc = BeginPaint(hwndDlg,&sPaint);
|
||||
|
||||
HBRUSH hBrush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
|
||||
HBRUSH hBrush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF));
|
||||
|
||||
RECT sRect;
|
||||
sRect.left = 0;
|
||||
sRect.top = 26;
|
||||
sRect.right = 1000;
|
||||
sRect.bottom = 507;
|
||||
FillRect(hdc, &sRect, hBrush);
|
||||
RECT sRect;
|
||||
sRect.left = 0;
|
||||
sRect.top = 26;
|
||||
sRect.right = 1000;
|
||||
sRect.bottom = 507;
|
||||
FillRect(hdc, &sRect, hBrush);
|
||||
|
||||
EndPaint(hwndDlg,&sPaint);
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
return FALSE;
|
||||
}
|
||||
EndPaint(hwndDlg,&sPaint);
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
};
|
|
@ -49,40 +49,40 @@ namespace AssimpView {
|
|||
// Movement in x and y axis is possible
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleMouseInputFPS( void )
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
|
||||
D3DXMATRIX matRotation;
|
||||
D3DXMATRIX matRotation;
|
||||
|
||||
if (g_bMousePressed)
|
||||
{
|
||||
int nXDiff = (g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = (g_mousePos.y - g_LastmousePos.y);
|
||||
if (g_bMousePressed)
|
||||
{
|
||||
int nXDiff = (g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = (g_mousePos.y - g_LastmousePos.y);
|
||||
|
||||
if( 0 != nYDiff)
|
||||
{
|
||||
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.vUp, (D3DXVECTOR3*)&g_sCamera.vUp, &matRotation );
|
||||
}
|
||||
if( 0 != nYDiff)
|
||||
{
|
||||
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.vUp, (D3DXVECTOR3*)&g_sCamera.vUp, &matRotation );
|
||||
}
|
||||
|
||||
if( 0 != nXDiff )
|
||||
{
|
||||
D3DXVECTOR3 v(0,1,0);
|
||||
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.vRight,(D3DXVECTOR3*) &g_sCamera.vRight, &matRotation );
|
||||
}
|
||||
}
|
||||
if( 0 != nXDiff )
|
||||
{
|
||||
D3DXVECTOR3 v(0,1,0);
|
||||
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.vRight,(D3DXVECTOR3*) &g_sCamera.vRight, &matRotation );
|
||||
}
|
||||
}
|
||||
|
||||
g_LastmousePos.x = g_mousePos.x;
|
||||
g_LastmousePos.y = g_mousePos.y;
|
||||
}
|
||||
g_LastmousePos.x = g_mousePos.x;
|
||||
g_LastmousePos.y = g_mousePos.y;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
@ -91,25 +91,25 @@ void HandleMouseInputFPS( void )
|
|||
// Movement in x and y axis is possible
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleMouseInputTextureView( void )
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
|
||||
D3DXMATRIX matRotation;
|
||||
D3DXMATRIX matRotation;
|
||||
|
||||
if (g_bMousePressed)
|
||||
{
|
||||
CDisplay::Instance().SetTextureViewOffsetX((float)(g_mousePos.x - g_LastmousePos.x));
|
||||
CDisplay::Instance().SetTextureViewOffsetY((float)(g_mousePos.y - g_LastmousePos.y));
|
||||
}
|
||||
if (g_bMousePressed)
|
||||
{
|
||||
CDisplay::Instance().SetTextureViewOffsetX((float)(g_mousePos.x - g_LastmousePos.x));
|
||||
CDisplay::Instance().SetTextureViewOffsetY((float)(g_mousePos.y - g_LastmousePos.y));
|
||||
}
|
||||
|
||||
g_LastmousePos.x = g_mousePos.x;
|
||||
g_LastmousePos.y = g_mousePos.y;
|
||||
}
|
||||
g_LastmousePos.x = g_mousePos.x;
|
||||
g_LastmousePos.y = g_mousePos.y;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// handle mouse input for the light rotation
|
||||
|
@ -117,32 +117,32 @@ void HandleMouseInputTextureView( void )
|
|||
// Axes: global x/y axis
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleMouseInputLightRotate( void )
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
|
||||
if (g_bMousePressedR)
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
if (g_bMousePressedR)
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
|
||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||
aiMatrix4x4 mTemp;
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
||||
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||
aiMatrix4x4 mTemp;
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
||||
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
||||
|
||||
v = aiVector3D(0.0f,1.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f));
|
||||
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
||||
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
v = aiVector3D(0.0f,1.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &mTemp, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f));
|
||||
D3DXVec3TransformCoord((D3DXVECTOR3*)&g_avLightDirs[0],
|
||||
(const D3DXVECTOR3*)&g_avLightDirs[0],(const D3DXMATRIX*)&mTemp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
@ -152,221 +152,221 @@ void HandleMouseInputLightRotate( void )
|
|||
// pressed. Rotation is possible in x and y direction.
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleMouseInputSkyBox( void )
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
|
||||
aiMatrix4x4 matRotation;
|
||||
aiMatrix4x4 matRotation;
|
||||
|
||||
if (g_bMousePressedBoth )
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
if (g_bMousePressedBoth )
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
|
||||
aiMatrix4x4 matWorld;
|
||||
aiMatrix4x4 matWorld;
|
||||
|
||||
if( 0 != nYDiff)
|
||||
{
|
||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
||||
}
|
||||
if( 0 != nYDiff)
|
||||
{
|
||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
||||
}
|
||||
|
||||
if( 0 != nXDiff)
|
||||
{
|
||||
aiMatrix4x4 matWorldOld;
|
||||
if( 0 != nYDiff)
|
||||
{
|
||||
matWorldOld = matWorld;
|
||||
}
|
||||
if( 0 != nXDiff)
|
||||
{
|
||||
aiMatrix4x4 matWorldOld;
|
||||
if( 0 != nYDiff)
|
||||
{
|
||||
matWorldOld = matWorld;
|
||||
}
|
||||
|
||||
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
||||
matWorld = matWorldOld * matWorld;
|
||||
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
||||
}
|
||||
}
|
||||
}
|
||||
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
||||
matWorld = matWorldOld * matWorld;
|
||||
CBackgroundPainter::Instance().RotateSB(&matWorld);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleMouseInputLightIntensityAndColor( void )
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
|
||||
if (g_bMousePressedM)
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
if (g_bMousePressedM)
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
|
||||
g_fLightIntensity -= (float)nXDiff / 400.0f;
|
||||
if ((nYDiff > 2 || nYDiff < -2) && (nXDiff < 20 && nXDiff > -20))
|
||||
{
|
||||
if (!g_bFPSView)
|
||||
{
|
||||
g_sCamera.vPos.z += nYDiff / 120.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_sCamera.vPos += (nYDiff / 120.0f) * g_sCamera.vLookAt.Normalize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
g_fLightIntensity -= (float)nXDiff / 400.0f;
|
||||
if ((nYDiff > 2 || nYDiff < -2) && (nXDiff < 20 && nXDiff > -20))
|
||||
{
|
||||
if (!g_bFPSView)
|
||||
{
|
||||
g_sCamera.vPos.z += nYDiff / 120.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_sCamera.vPos += (nYDiff / 120.0f) * g_sCamera.vLookAt.Normalize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleMouseInputLocal( void )
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
{
|
||||
POINT mousePos;
|
||||
GetCursorPos( &mousePos );
|
||||
ScreenToClient( GetDlgItem(g_hDlg,IDC_RT), &mousePos );
|
||||
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
g_mousePos.x = mousePos.x;
|
||||
g_mousePos.y = mousePos.y;
|
||||
|
||||
aiMatrix4x4 matRotation;
|
||||
aiMatrix4x4 matRotation;
|
||||
|
||||
if (g_bMousePressed)
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
if (g_bMousePressed)
|
||||
{
|
||||
int nXDiff = -(g_mousePos.x - g_LastmousePos.x);
|
||||
int nYDiff = -(g_mousePos.y - g_LastmousePos.y);
|
||||
|
||||
aiMatrix4x4 matWorld;
|
||||
if (g_eClick != EClickPos_Outside)
|
||||
{
|
||||
if( 0 != nYDiff && g_eClick != EClickPos_CircleHor)
|
||||
{
|
||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||
}
|
||||
aiMatrix4x4 matWorld;
|
||||
if (g_eClick != EClickPos_Outside)
|
||||
{
|
||||
if( 0 != nYDiff && g_eClick != EClickPos_CircleHor)
|
||||
{
|
||||
aiVector3D v = aiVector3D(1.0f,0.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*) &matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nYDiff / 2.0f));
|
||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||
}
|
||||
|
||||
if( 0 != nXDiff && g_eClick != EClickPos_CircleVert)
|
||||
{
|
||||
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 != nYDiff || 0 != nXDiff)
|
||||
{
|
||||
// rotate around the z-axis
|
||||
RECT sRect;
|
||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
||||
sRect.right -= sRect.left;
|
||||
sRect.bottom -= sRect.top;
|
||||
if( 0 != nXDiff && g_eClick != EClickPos_CircleVert)
|
||||
{
|
||||
aiVector3D v = aiVector3D(0.0f,1.0f,0.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, D3DXToRadian((float)nXDiff / 2.0f) );
|
||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(0 != nYDiff || 0 != nXDiff)
|
||||
{
|
||||
// rotate around the z-axis
|
||||
RECT sRect;
|
||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sRect);
|
||||
sRect.right -= sRect.left;
|
||||
sRect.bottom -= sRect.top;
|
||||
|
||||
int xPos = g_mousePos.x - sRect.right/2;
|
||||
int yPos = g_mousePos.y - sRect.bottom/2;
|
||||
float fXDist = (float)xPos;
|
||||
float fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
||||
int xPos = g_mousePos.x - sRect.right/2;
|
||||
int yPos = g_mousePos.y - sRect.bottom/2;
|
||||
float fXDist = (float)xPos;
|
||||
float fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
||||
|
||||
bool bSign1;
|
||||
if (fXDist < 0.0f)bSign1 = false;
|
||||
else bSign1 = true;
|
||||
float fAngle = asin(fYDist);
|
||||
bool bSign1;
|
||||
if (fXDist < 0.0f)bSign1 = false;
|
||||
else bSign1 = true;
|
||||
float fAngle = asin(fYDist);
|
||||
|
||||
xPos = g_LastmousePos.x - sRect.right/2;
|
||||
yPos = g_LastmousePos.y - sRect.bottom/2;
|
||||
xPos = g_LastmousePos.x - sRect.right/2;
|
||||
yPos = g_LastmousePos.y - sRect.bottom/2;
|
||||
|
||||
fXDist = (float)xPos;
|
||||
fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
||||
fXDist = (float)xPos;
|
||||
fYDist = (float)yPos / sqrtf((float)(yPos * yPos + xPos * xPos));
|
||||
|
||||
bool bSign2;
|
||||
if (fXDist < 0.0f)bSign2 = false;
|
||||
else bSign2 = true;
|
||||
float fAngle2 = asin(fYDist);
|
||||
fAngle -= fAngle2;
|
||||
bool bSign2;
|
||||
if (fXDist < 0.0f)bSign2 = false;
|
||||
else bSign2 = true;
|
||||
float fAngle2 = asin(fYDist);
|
||||
fAngle -= fAngle2;
|
||||
|
||||
if (bSign1 != bSign2)
|
||||
{
|
||||
g_bInvert = !g_bInvert;
|
||||
}
|
||||
if (g_bInvert)fAngle *= -1.0f;
|
||||
if (bSign1 != bSign2)
|
||||
{
|
||||
g_bInvert = !g_bInvert;
|
||||
}
|
||||
if (g_bInvert)fAngle *= -1.0f;
|
||||
|
||||
aiVector3D v = aiVector3D(0.0f,0.0f,1.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, (float) (fAngle * 1.2) );
|
||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||
}
|
||||
}
|
||||
}
|
||||
aiVector3D v = aiVector3D(0.0f,0.0f,1.0f);
|
||||
D3DXMatrixRotationAxis( (D3DXMATRIX*)&matWorld, (D3DXVECTOR3*)&v, (float) (fAngle * 1.2) );
|
||||
g_mWorldRotate = g_mWorldRotate * matWorld;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_LastmousePos.x = g_mousePos.x;
|
||||
g_LastmousePos.y = g_mousePos.y;
|
||||
}
|
||||
g_LastmousePos.x = g_mousePos.x;
|
||||
g_LastmousePos.y = g_mousePos.y;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleKeyboardInputFPS( void )
|
||||
{
|
||||
unsigned char keys[256];
|
||||
GetKeyboardState( keys );
|
||||
{
|
||||
unsigned char keys[256];
|
||||
GetKeyboardState( keys );
|
||||
|
||||
aiVector3D tmpLook = g_sCamera.vLookAt;
|
||||
aiVector3D tmpRight = g_sCamera.vRight;
|
||||
aiVector3D tmpLook = g_sCamera.vLookAt;
|
||||
aiVector3D tmpRight = g_sCamera.vRight;
|
||||
|
||||
aiVector3D vOldPos = g_sCamera.vPos;
|
||||
aiVector3D vOldPos = g_sCamera.vPos;
|
||||
|
||||
// Up Arrow Key - View moves forward
|
||||
if( keys[VK_UP] & 0x80 )
|
||||
g_sCamera.vPos -= (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
||||
// Up Arrow Key - View moves forward
|
||||
if( keys[VK_UP] & 0x80 )
|
||||
g_sCamera.vPos -= (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
||||
|
||||
// Down Arrow Key - View moves backward
|
||||
if( keys[VK_DOWN] & 0x80 )
|
||||
g_sCamera.vPos += (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
||||
// Down Arrow Key - View moves backward
|
||||
if( keys[VK_DOWN] & 0x80 )
|
||||
g_sCamera.vPos += (tmpLook*-MOVE_SPEED)*g_fElpasedTime;
|
||||
|
||||
// Left Arrow Key - View side-steps or strafes to the left
|
||||
if( keys[VK_LEFT] & 0x80 )
|
||||
g_sCamera.vPos -= (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
||||
// Left Arrow Key - View side-steps or strafes to the left
|
||||
if( keys[VK_LEFT] & 0x80 )
|
||||
g_sCamera.vPos -= (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
||||
|
||||
// Right Arrow Key - View side-steps or strafes to the right
|
||||
if( keys[VK_RIGHT] & 0x80 )
|
||||
g_sCamera.vPos += (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
||||
// Right Arrow Key - View side-steps or strafes to the right
|
||||
if( keys[VK_RIGHT] & 0x80 )
|
||||
g_sCamera.vPos += (tmpRight*MOVE_SPEED)*g_fElpasedTime;
|
||||
|
||||
// Home Key - View elevates up
|
||||
if( keys[VK_HOME] & 0x80 )
|
||||
g_sCamera.vPos .y += MOVE_SPEED*g_fElpasedTime;
|
||||
// Home Key - View elevates up
|
||||
if( keys[VK_HOME] & 0x80 )
|
||||
g_sCamera.vPos .y += MOVE_SPEED*g_fElpasedTime;
|
||||
|
||||
// End Key - View elevates down
|
||||
if( keys[VK_END] & 0x80 )
|
||||
g_sCamera.vPos.y -= MOVE_SPEED*g_fElpasedTime;
|
||||
}
|
||||
// End Key - View elevates down
|
||||
if( keys[VK_END] & 0x80 )
|
||||
g_sCamera.vPos.y -= MOVE_SPEED*g_fElpasedTime;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
void HandleKeyboardInputTextureView( void )
|
||||
{
|
||||
unsigned char keys[256];
|
||||
GetKeyboardState( keys );
|
||||
{
|
||||
unsigned char keys[256];
|
||||
GetKeyboardState( keys );
|
||||
|
||||
// Up Arrow Key
|
||||
if( keys[VK_UP] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetY ( g_fElpasedTime * 150.0f );
|
||||
// Up Arrow Key
|
||||
if( keys[VK_UP] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetY ( g_fElpasedTime * 150.0f );
|
||||
|
||||
// Down Arrow Key
|
||||
if( keys[VK_DOWN] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetY ( -g_fElpasedTime * 150.0f );
|
||||
// Down Arrow Key
|
||||
if( keys[VK_DOWN] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetY ( -g_fElpasedTime * 150.0f );
|
||||
|
||||
// Left Arrow Key
|
||||
if( keys[VK_LEFT] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetX ( g_fElpasedTime * 150.0f );
|
||||
// Left Arrow Key
|
||||
if( keys[VK_LEFT] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetX ( g_fElpasedTime * 150.0f );
|
||||
|
||||
// Right Arrow Key
|
||||
if( keys[VK_RIGHT] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetX ( -g_fElpasedTime * 150.0f );
|
||||
}
|
||||
// Right Arrow Key
|
||||
if( keys[VK_RIGHT] & 0x80 )
|
||||
CDisplay::Instance().SetTextureViewOffsetX ( -g_fElpasedTime * 150.0f );
|
||||
}
|
||||
};
|
|
@ -47,187 +47,187 @@ CLogDisplay CLogDisplay::s_cInstance;
|
|||
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogDisplay::AddEntry(const std::string& szText,
|
||||
const D3DCOLOR clrColor)
|
||||
{
|
||||
SEntry sNew;
|
||||
sNew.clrColor = clrColor;
|
||||
sNew.szText = szText;
|
||||
sNew.dwStartTicks = (DWORD)GetTickCount();
|
||||
const D3DCOLOR clrColor)
|
||||
{
|
||||
SEntry sNew;
|
||||
sNew.clrColor = clrColor;
|
||||
sNew.szText = szText;
|
||||
sNew.dwStartTicks = (DWORD)GetTickCount();
|
||||
|
||||
this->asEntries.push_back(sNew);
|
||||
}
|
||||
this->asEntries.push_back(sNew);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogDisplay::ReleaseNativeResource()
|
||||
{
|
||||
if (this->piFont)
|
||||
{
|
||||
this->piFont->Release();
|
||||
this->piFont = NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (this->piFont)
|
||||
{
|
||||
this->piFont->Release();
|
||||
this->piFont = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogDisplay::RecreateNativeResource()
|
||||
{
|
||||
if (!this->piFont)
|
||||
{
|
||||
if (FAILED(D3DXCreateFont(g_piDevice,
|
||||
16, //Font height
|
||||
0, //Font width
|
||||
FW_BOLD, //Font Weight
|
||||
1, //MipLevels
|
||||
false, //Italic
|
||||
DEFAULT_CHARSET, //CharSet
|
||||
OUT_DEFAULT_PRECIS, //OutputPrecision
|
||||
//CLEARTYPE_QUALITY, //Quality
|
||||
5, //Quality
|
||||
DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily
|
||||
"Verdana", //pFacename,
|
||||
&this->piFont)))
|
||||
{
|
||||
CLogDisplay::Instance().AddEntry("Unable to load font",D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
{
|
||||
if (!this->piFont)
|
||||
{
|
||||
if (FAILED(D3DXCreateFont(g_piDevice,
|
||||
16, //Font height
|
||||
0, //Font width
|
||||
FW_BOLD, //Font Weight
|
||||
1, //MipLevels
|
||||
false, //Italic
|
||||
DEFAULT_CHARSET, //CharSet
|
||||
OUT_DEFAULT_PRECIS, //OutputPrecision
|
||||
//CLEARTYPE_QUALITY, //Quality
|
||||
5, //Quality
|
||||
DEFAULT_PITCH|FF_DONTCARE, //PitchAndFamily
|
||||
"Verdana", //pFacename,
|
||||
&this->piFont)))
|
||||
{
|
||||
CLogDisplay::Instance().AddEntry("Unable to load font",D3DCOLOR_ARGB(0xFF,0xFF,0,0));
|
||||
|
||||
this->piFont = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
this->piFont = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogDisplay::OnRender()
|
||||
{
|
||||
DWORD dwTick = (DWORD) GetTickCount();
|
||||
DWORD dwLimit = dwTick - 8000;
|
||||
DWORD dwLimit2 = dwLimit + 3000;
|
||||
{
|
||||
DWORD dwTick = (DWORD) GetTickCount();
|
||||
DWORD dwLimit = dwTick - 8000;
|
||||
DWORD dwLimit2 = dwLimit + 3000;
|
||||
|
||||
unsigned int iCnt = 0;
|
||||
RECT sRect;
|
||||
sRect.left = 10;
|
||||
sRect.top = 10;
|
||||
unsigned int iCnt = 0;
|
||||
RECT sRect;
|
||||
sRect.left = 10;
|
||||
sRect.top = 10;
|
||||
|
||||
RECT sWndRect;
|
||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sWndRect);
|
||||
sWndRect.right -= sWndRect.left;
|
||||
sWndRect.bottom -= sWndRect.top;
|
||||
sWndRect.left = sWndRect.top = 0;
|
||||
RECT sWndRect;
|
||||
GetWindowRect(GetDlgItem(g_hDlg,IDC_RT),&sWndRect);
|
||||
sWndRect.right -= sWndRect.left;
|
||||
sWndRect.bottom -= sWndRect.top;
|
||||
sWndRect.left = sWndRect.top = 0;
|
||||
|
||||
sRect.right = sWndRect.right - 30;
|
||||
sRect.bottom = sWndRect.bottom;
|
||||
sRect.right = sWndRect.right - 30;
|
||||
sRect.bottom = sWndRect.bottom;
|
||||
|
||||
// if no asset is loaded draw a "no asset loaded" text in the center
|
||||
if (!g_pcAsset)
|
||||
{
|
||||
const char* szText = "Nothing to display ... \r\nTry [Viewer | Open asset] to load an asset";
|
||||
// if no asset is loaded draw a "no asset loaded" text in the center
|
||||
if (!g_pcAsset)
|
||||
{
|
||||
const char* szText = "Nothing to display ... \r\nTry [Viewer | Open asset] to load an asset";
|
||||
|
||||
// shadow
|
||||
RECT sCopy;
|
||||
sCopy.left = sWndRect.left+1;
|
||||
sCopy.top = sWndRect.top+1;
|
||||
sCopy.bottom = sWndRect.bottom+1;
|
||||
sCopy.right = sWndRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
sCopy.left = sWndRect.left+1;
|
||||
sCopy.top = sWndRect.top+1;
|
||||
sCopy.bottom = sWndRect.bottom-1;
|
||||
sCopy.right = sWndRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
sCopy.left = sWndRect.left-1;
|
||||
sCopy.top = sWndRect.top-1;
|
||||
sCopy.bottom = sWndRect.bottom+1;
|
||||
sCopy.right = sWndRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
sCopy.left = sWndRect.left-1;
|
||||
sCopy.top = sWndRect.top-1;
|
||||
sCopy.bottom = sWndRect.bottom-1;
|
||||
sCopy.right = sWndRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
// shadow
|
||||
RECT sCopy;
|
||||
sCopy.left = sWndRect.left+1;
|
||||
sCopy.top = sWndRect.top+1;
|
||||
sCopy.bottom = sWndRect.bottom+1;
|
||||
sCopy.right = sWndRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
sCopy.left = sWndRect.left+1;
|
||||
sCopy.top = sWndRect.top+1;
|
||||
sCopy.bottom = sWndRect.bottom-1;
|
||||
sCopy.right = sWndRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
sCopy.left = sWndRect.left-1;
|
||||
sCopy.top = sWndRect.top-1;
|
||||
sCopy.bottom = sWndRect.bottom+1;
|
||||
sCopy.right = sWndRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
sCopy.left = sWndRect.left-1;
|
||||
sCopy.top = sWndRect.top-1;
|
||||
sCopy.bottom = sWndRect.bottom-1;
|
||||
sCopy.right = sWndRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sCopy,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(100,0x0,0x0,0x0));
|
||||
|
||||
// text
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sWndRect,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||
}
|
||||
// text
|
||||
this->piFont->DrawText(NULL,szText ,
|
||||
-1,&sWndRect,DT_CENTER | DT_VCENTER,D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0xFF));
|
||||
}
|
||||
|
||||
// update all elements in the queue and render them
|
||||
for (std::list<SEntry>::iterator
|
||||
i = this->asEntries.begin();
|
||||
i != this->asEntries.end();++i,++iCnt)
|
||||
{
|
||||
if ((*i).dwStartTicks < dwLimit)
|
||||
{
|
||||
i = this->asEntries.erase(i);
|
||||
// update all elements in the queue and render them
|
||||
for (std::list<SEntry>::iterator
|
||||
i = this->asEntries.begin();
|
||||
i != this->asEntries.end();++i,++iCnt)
|
||||
{
|
||||
if ((*i).dwStartTicks < dwLimit)
|
||||
{
|
||||
i = this->asEntries.erase(i);
|
||||
|
||||
if(i == this->asEntries.end())break;
|
||||
}
|
||||
else if (NULL != this->piFont)
|
||||
{
|
||||
float fAlpha = 1.0f;
|
||||
if ((*i).dwStartTicks <= dwLimit2)
|
||||
{
|
||||
// linearly interpolate to create the fade out effect
|
||||
fAlpha = 1.0f - (float)(dwLimit2 - (*i).dwStartTicks) / 3000.0f;
|
||||
}
|
||||
D3DCOLOR& clrColor = (*i).clrColor;
|
||||
clrColor &= ~(0xFFu << 24);
|
||||
clrColor |= (((unsigned char)(fAlpha * 255.0f)) & 0xFFu) << 24;
|
||||
if(i == this->asEntries.end())break;
|
||||
}
|
||||
else if (NULL != this->piFont)
|
||||
{
|
||||
float fAlpha = 1.0f;
|
||||
if ((*i).dwStartTicks <= dwLimit2)
|
||||
{
|
||||
// linearly interpolate to create the fade out effect
|
||||
fAlpha = 1.0f - (float)(dwLimit2 - (*i).dwStartTicks) / 3000.0f;
|
||||
}
|
||||
D3DCOLOR& clrColor = (*i).clrColor;
|
||||
clrColor &= ~(0xFFu << 24);
|
||||
clrColor |= (((unsigned char)(fAlpha * 255.0f)) & 0xFFu) << 24;
|
||||
|
||||
const char* szText = (*i).szText.c_str();
|
||||
if (sRect.top + 30 > sWndRect.bottom)
|
||||
{
|
||||
// end of window. send a special message
|
||||
szText = "... too many errors";
|
||||
clrColor = D3DCOLOR_ARGB(0xFF,0xFF,100,0x0);
|
||||
}
|
||||
const char* szText = (*i).szText.c_str();
|
||||
if (sRect.top + 30 > sWndRect.bottom)
|
||||
{
|
||||
// end of window. send a special message
|
||||
szText = "... too many errors";
|
||||
clrColor = D3DCOLOR_ARGB(0xFF,0xFF,100,0x0);
|
||||
}
|
||||
|
||||
// draw the black shadow
|
||||
RECT sCopy;
|
||||
sCopy.left = sRect.left+1;
|
||||
sCopy.top = sRect.top+1;
|
||||
sCopy.bottom = sRect.bottom+1;
|
||||
sCopy.right = sRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
// draw the black shadow
|
||||
RECT sCopy;
|
||||
sCopy.left = sRect.left+1;
|
||||
sCopy.top = sRect.top+1;
|
||||
sCopy.bottom = sRect.bottom+1;
|
||||
sCopy.right = sRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
|
||||
sCopy.left = sRect.left-1;
|
||||
sCopy.top = sRect.top-1;
|
||||
sCopy.bottom = sRect.bottom-1;
|
||||
sCopy.right = sRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
sCopy.left = sRect.left-1;
|
||||
sCopy.top = sRect.top-1;
|
||||
sCopy.bottom = sRect.bottom-1;
|
||||
sCopy.right = sRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
|
||||
sCopy.left = sRect.left-1;
|
||||
sCopy.top = sRect.top-1;
|
||||
sCopy.bottom = sRect.bottom+1;
|
||||
sCopy.right = sRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
sCopy.left = sRect.left-1;
|
||||
sCopy.top = sRect.top-1;
|
||||
sCopy.bottom = sRect.bottom+1;
|
||||
sCopy.right = sRect.right+1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
|
||||
sCopy.left = sRect.left+1;
|
||||
sCopy.top = sRect.top+1;
|
||||
sCopy.bottom = sRect.bottom-1;
|
||||
sCopy.right = sRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
sCopy.left = sRect.left+1;
|
||||
sCopy.top = sRect.top+1;
|
||||
sCopy.bottom = sRect.bottom-1;
|
||||
sCopy.right = sRect.right-1;
|
||||
this->piFont->DrawText(NULL,szText,
|
||||
-1,&sCopy,DT_RIGHT | DT_TOP,D3DCOLOR_ARGB(
|
||||
(unsigned char)(fAlpha * 100.0f),0x0,0x0,0x0));
|
||||
|
||||
// draw the text itself
|
||||
int iPX = this->piFont->DrawText(NULL,szText,
|
||||
-1,&sRect,DT_RIGHT | DT_TOP,clrColor);
|
||||
// draw the text itself
|
||||
int iPX = this->piFont->DrawText(NULL,szText,
|
||||
-1,&sRect,DT_RIGHT | DT_TOP,clrColor);
|
||||
|
||||
sRect.top += iPX;
|
||||
sRect.bottom += iPX;
|
||||
sRect.top += iPX;
|
||||
sRect.bottom += iPX;
|
||||
|
||||
if (szText != (*i).szText.c_str())break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (szText != (*i).szText.c_str())break;
|
||||
}
|
||||
}
|
||||
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
|
||||
|
|
|
@ -50,206 +50,206 @@ extern HKEY g_hRegistry;
|
|||
|
||||
// header for the RTF log file
|
||||
static const char* AI_VIEW_RTF_LOG_HEADER =
|
||||
"{\\rtf1"
|
||||
"\\ansi"
|
||||
"\\deff0"
|
||||
"{"
|
||||
"\\fonttbl{\\f0 Courier New;}"
|
||||
"}"
|
||||
"{\\colortbl;"
|
||||
"\\red255\\green0\\blue0;" // red for errors
|
||||
"\\red255\\green120\\blue0;" // orange for warnings
|
||||
"\\red0\\green150\\blue0;" // green for infos
|
||||
"\\red0\\green0\\blue180;" // blue for debug messages
|
||||
"\\red0\\green0\\blue0;" // black for everything else
|
||||
"}}";
|
||||
"{\\rtf1"
|
||||
"\\ansi"
|
||||
"\\deff0"
|
||||
"{"
|
||||
"\\fonttbl{\\f0 Courier New;}"
|
||||
"}"
|
||||
"{\\colortbl;"
|
||||
"\\red255\\green0\\blue0;" // red for errors
|
||||
"\\red255\\green120\\blue0;" // orange for warnings
|
||||
"\\red0\\green150\\blue0;" // green for infos
|
||||
"\\red0\\green0\\blue180;" // blue for debug messages
|
||||
"\\red0\\green0\\blue0;" // black for everything else
|
||||
"}}";
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Message procedure for the log window
|
||||
//-------------------------------------------------------------------------------
|
||||
INT_PTR CALLBACK LogDialogProc(HWND hwndDlg,UINT uMsg,
|
||||
WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
(void)lParam;
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
WPARAM wParam,LPARAM lParam)
|
||||
{
|
||||
(void)lParam;
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
int x = LOWORD(lParam);
|
||||
int y = HIWORD(lParam);
|
||||
case WM_SIZE:
|
||||
{
|
||||
int x = LOWORD(lParam);
|
||||
int y = HIWORD(lParam);
|
||||
|
||||
SetWindowPos(GetDlgItem(hwndDlg,IDC_EDIT1),NULL,0,0,
|
||||
x-10,y-12,SWP_NOMOVE|SWP_NOZORDER);
|
||||
SetWindowPos(GetDlgItem(hwndDlg,IDC_EDIT1),NULL,0,0,
|
||||
x-10,y-12,SWP_NOMOVE|SWP_NOZORDER);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
EndDialog(hwndDlg,0);
|
||||
return TRUE;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
EndDialog(hwndDlg,0);
|
||||
|
||||
CLogWindow::Instance().bIsVisible = false;
|
||||
return TRUE;
|
||||
};
|
||||
return FALSE;
|
||||
}
|
||||
CLogWindow::Instance().bIsVisible = false;
|
||||
return TRUE;
|
||||
};
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogWindow::Init ()
|
||||
{
|
||||
this->hwnd = ::CreateDialog(g_hInstance,MAKEINTRESOURCE(IDD_LOGVIEW),
|
||||
NULL,&LogDialogProc);
|
||||
this->hwnd = ::CreateDialog(g_hInstance,MAKEINTRESOURCE(IDD_LOGVIEW),
|
||||
NULL,&LogDialogProc);
|
||||
|
||||
if (!this->hwnd)
|
||||
{
|
||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create logger window",
|
||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||
}
|
||||
if (!this->hwnd)
|
||||
{
|
||||
CLogDisplay::Instance().AddEntry("[ERROR] Unable to create logger window",
|
||||
D3DCOLOR_ARGB(0xFF,0,0xFF,0));
|
||||
}
|
||||
|
||||
// setup the log text
|
||||
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
||||
this->szPlainText = "";
|
||||
// setup the log text
|
||||
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
||||
this->szPlainText = "";
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogWindow::Show()
|
||||
{
|
||||
if (this->hwnd)
|
||||
{
|
||||
ShowWindow(this->hwnd,SW_SHOW);
|
||||
this->bIsVisible = true;
|
||||
if (this->hwnd)
|
||||
{
|
||||
ShowWindow(this->hwnd,SW_SHOW);
|
||||
this->bIsVisible = true;
|
||||
|
||||
// contents aren't updated while the logger isn't displayed
|
||||
this->Update();
|
||||
}
|
||||
// contents aren't updated while the logger isn't displayed
|
||||
this->Update();
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CMyLogStream::write(const char* message)
|
||||
{
|
||||
CLogWindow::Instance().WriteLine(message);
|
||||
CLogWindow::Instance().WriteLine(message);
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogWindow::Clear()
|
||||
{
|
||||
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
||||
this->szPlainText = "";
|
||||
this->szText = AI_VIEW_RTF_LOG_HEADER;;
|
||||
this->szPlainText = "";
|
||||
|
||||
this->Update();
|
||||
this->Update();
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogWindow::Update()
|
||||
{
|
||||
if (this->bIsVisible)
|
||||
{
|
||||
SETTEXTEX sInfo;
|
||||
sInfo.flags = ST_DEFAULT;
|
||||
sInfo.codepage = CP_ACP;
|
||||
if (this->bIsVisible)
|
||||
{
|
||||
SETTEXTEX sInfo;
|
||||
sInfo.flags = ST_DEFAULT;
|
||||
sInfo.codepage = CP_ACP;
|
||||
|
||||
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
||||
}
|
||||
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogWindow::Save()
|
||||
{
|
||||
char szFileName[MAX_PATH];
|
||||
char szFileName[MAX_PATH];
|
||||
|
||||
DWORD dwTemp = MAX_PATH;
|
||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LogDestination",NULL,NULL,
|
||||
(BYTE*)szFileName,&dwTemp))
|
||||
{
|
||||
// Key was not found. Use C:
|
||||
strcpy(szFileName,"");
|
||||
}
|
||||
else
|
||||
{
|
||||
// need to remove the file name
|
||||
char* sz = strrchr(szFileName,'\\');
|
||||
if (!sz)sz = strrchr(szFileName,'/');
|
||||
if (!sz)*sz = 0;
|
||||
}
|
||||
OPENFILENAME sFilename1 = {
|
||||
sizeof(OPENFILENAME),
|
||||
g_hDlg,GetModuleHandle(NULL),
|
||||
"Log files\0*.txt", NULL, 0, 1,
|
||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
||||
"Save log to file",
|
||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||
0, 1, ".txt", 0, NULL, NULL
|
||||
};
|
||||
if(GetSaveFileName(&sFilename1) == 0) return;
|
||||
DWORD dwTemp = MAX_PATH;
|
||||
if(ERROR_SUCCESS != RegQueryValueEx(g_hRegistry,"LogDestination",NULL,NULL,
|
||||
(BYTE*)szFileName,&dwTemp))
|
||||
{
|
||||
// Key was not found. Use C:
|
||||
strcpy(szFileName,"");
|
||||
}
|
||||
else
|
||||
{
|
||||
// need to remove the file name
|
||||
char* sz = strrchr(szFileName,'\\');
|
||||
if (!sz)sz = strrchr(szFileName,'/');
|
||||
if (!sz)*sz = 0;
|
||||
}
|
||||
OPENFILENAME sFilename1 = {
|
||||
sizeof(OPENFILENAME),
|
||||
g_hDlg,GetModuleHandle(NULL),
|
||||
"Log files\0*.txt", NULL, 0, 1,
|
||||
szFileName, MAX_PATH, NULL, 0, NULL,
|
||||
"Save log to file",
|
||||
OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_NOCHANGEDIR,
|
||||
0, 1, ".txt", 0, NULL, NULL
|
||||
};
|
||||
if(GetSaveFileName(&sFilename1) == 0) return;
|
||||
|
||||
// Now store the file in the registry
|
||||
RegSetValueExA(g_hRegistry,"LogDestination",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH);
|
||||
// Now store the file in the registry
|
||||
RegSetValueExA(g_hRegistry,"LogDestination",0,REG_SZ,(const BYTE*)szFileName,MAX_PATH);
|
||||
|
||||
FILE* pFile = fopen(szFileName,"wt");
|
||||
fprintf(pFile,this->szPlainText.c_str());
|
||||
fclose(pFile);
|
||||
FILE* pFile = fopen(szFileName,"wt");
|
||||
fprintf(pFile,this->szPlainText.c_str());
|
||||
fclose(pFile);
|
||||
|
||||
CLogDisplay::Instance().AddEntry("[INFO] The log file has been saved",
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0));
|
||||
CLogDisplay::Instance().AddEntry("[INFO] The log file has been saved",
|
||||
D3DCOLOR_ARGB(0xFF,0xFF,0xFF,0));
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
void CLogWindow::WriteLine(const char* message)
|
||||
{
|
||||
this->szPlainText.append(message);
|
||||
this->szPlainText.append("\r\n");
|
||||
this->szPlainText.append(message);
|
||||
this->szPlainText.append("\r\n");
|
||||
|
||||
if (0 != this->szText.length())
|
||||
{
|
||||
this->szText.resize(this->szText.length()-1);
|
||||
}
|
||||
if (0 != this->szText.length())
|
||||
{
|
||||
this->szText.resize(this->szText.length()-1);
|
||||
}
|
||||
|
||||
switch (message[0])
|
||||
{
|
||||
case 'e':
|
||||
case 'E':
|
||||
this->szText.append("{\\pard \\cf1 \\b \\fs18 ");
|
||||
break;
|
||||
case 'w':
|
||||
case 'W':
|
||||
this->szText.append("{\\pard \\cf2 \\b \\fs18 ");
|
||||
break;
|
||||
case 'i':
|
||||
case 'I':
|
||||
this->szText.append("{\\pard \\cf3 \\b \\fs18 ");
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
this->szText.append("{\\pard \\cf4 \\b \\fs18 ");
|
||||
break;
|
||||
default:
|
||||
this->szText.append("{\\pard \\cf5 \\b \\fs18 ");
|
||||
break;
|
||||
}
|
||||
switch (message[0])
|
||||
{
|
||||
case 'e':
|
||||
case 'E':
|
||||
this->szText.append("{\\pard \\cf1 \\b \\fs18 ");
|
||||
break;
|
||||
case 'w':
|
||||
case 'W':
|
||||
this->szText.append("{\\pard \\cf2 \\b \\fs18 ");
|
||||
break;
|
||||
case 'i':
|
||||
case 'I':
|
||||
this->szText.append("{\\pard \\cf3 \\b \\fs18 ");
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
this->szText.append("{\\pard \\cf4 \\b \\fs18 ");
|
||||
break;
|
||||
default:
|
||||
this->szText.append("{\\pard \\cf5 \\b \\fs18 ");
|
||||
break;
|
||||
}
|
||||
|
||||
std::string _message = message;
|
||||
for (unsigned int i = 0; i < _message.length();++i)
|
||||
{
|
||||
if ('\\' == _message[i] ||
|
||||
'}' == _message[i] ||
|
||||
'{' == _message[i])
|
||||
{
|
||||
_message.insert(i++,"\\");
|
||||
}
|
||||
}
|
||||
std::string _message = message;
|
||||
for (unsigned int i = 0; i < _message.length();++i)
|
||||
{
|
||||
if ('\\' == _message[i] ||
|
||||
'}' == _message[i] ||
|
||||
'{' == _message[i])
|
||||
{
|
||||
_message.insert(i++,"\\");
|
||||
}
|
||||
}
|
||||
|
||||
this->szText.append(_message);
|
||||
this->szText.append("\\par}}");
|
||||
this->szText.append(_message);
|
||||
this->szText.append("\\par}}");
|
||||
|
||||
if (this->bIsVisible && this->bUpdate)
|
||||
{
|
||||
SETTEXTEX sInfo;
|
||||
sInfo.flags = ST_DEFAULT;
|
||||
sInfo.codepage = CP_ACP;
|
||||
if (this->bIsVisible && this->bUpdate)
|
||||
{
|
||||
SETTEXTEX sInfo;
|
||||
sInfo.flags = ST_DEFAULT;
|
||||
sInfo.codepage = CP_ACP;
|
||||
|
||||
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
||||
}
|
||||
return;
|
||||
SendDlgItemMessage(this->hwnd,IDC_EDIT1,
|
||||
EM_SETTEXTEX,(WPARAM)&sInfo,( LPARAM)this->szText.c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}; //! 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.
|
||||
*/
|
||||
//-------------------------------------------------------------------------------
|
||||
class CMyLogStream : public Assimp::LogStream
|
||||
{
|
||||
public:
|
||||
/** @brief Implementation of the abstract method */
|
||||
/** @brief Implementation of the abstract method */
|
||||
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
|
||||
|
|
|
@ -63,56 +63,56 @@ namespace AssimpView {
|
|||
using namespace Assimp;
|
||||
|
||||
extern std::string g_szMaterialShader;
|
||||
extern HINSTANCE g_hInstance /*= NULL*/;
|
||||
extern HWND g_hDlg /*= NULL*/;
|
||||
extern IDirect3D9* g_piD3D /*= NULL*/;
|
||||
extern IDirect3DDevice9* g_piDevice /*= NULL*/;
|
||||
extern HINSTANCE g_hInstance /*= NULL*/;
|
||||
extern HWND g_hDlg /*= NULL*/;
|
||||
extern IDirect3D9* g_piD3D /*= NULL*/;
|
||||
extern IDirect3DDevice9* g_piDevice /*= NULL*/;
|
||||
extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/;
|
||||
extern double g_fFPS /*= 0.0f*/;
|
||||
extern double g_fFPS /*= 0.0f*/;
|
||||
extern char g_szFileName[ MAX_PATH ];
|
||||
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPatternEffect /*= NULL*/;
|
||||
extern bool g_bMousePressed /*= false*/;
|
||||
extern bool g_bMousePressedR /*= false*/;
|
||||
extern bool g_bMousePressedM /*= false*/;
|
||||
extern bool g_bMousePressedBoth /*= false*/;
|
||||
extern float g_fElpasedTime /*= 0.0f*/;
|
||||
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPatternEffect /*= NULL*/;
|
||||
extern bool g_bMousePressed /*= false*/;
|
||||
extern bool g_bMousePressedR /*= false*/;
|
||||
extern bool g_bMousePressedM /*= false*/;
|
||||
extern bool g_bMousePressedBoth /*= false*/;
|
||||
extern float g_fElpasedTime /*= 0.0f*/;
|
||||
extern D3DCAPS9 g_sCaps;
|
||||
extern bool g_bLoadingFinished /*= false*/;
|
||||
extern HANDLE g_hThreadHandle /*= NULL*/;
|
||||
extern float g_fWheelPos /*= -10.0f*/;
|
||||
extern bool g_bLoadingCanceled /*= false*/;
|
||||
extern IDirect3DTexture9* g_pcTexture /*= NULL*/;
|
||||
extern bool g_bLoadingFinished /*= false*/;
|
||||
extern HANDLE g_hThreadHandle /*= NULL*/;
|
||||
extern float g_fWheelPos /*= -10.0f*/;
|
||||
extern bool g_bLoadingCanceled /*= false*/;
|
||||
extern IDirect3DTexture9* g_pcTexture /*= NULL*/;
|
||||
|
||||
extern aiMatrix4x4 g_mWorld;
|
||||
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 ] /* =
|
||||
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
||||
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
||||
aiVector3D(-0.5f,0.5f,0.5f)} */;
|
||||
|
||||
|
||||
extern POINT g_mousePos /*= {0,0};*/;
|
||||
extern POINT g_LastmousePos /*= {0,0}*/;
|
||||
extern bool g_bFPSView /*= false*/;
|
||||
extern bool g_bInvert /*= false*/;
|
||||
extern POINT g_mousePos /*= {0,0};*/;
|
||||
extern POINT g_LastmousePos /*= {0,0}*/;
|
||||
extern bool g_bFPSView /*= false*/;
|
||||
extern bool g_bInvert /*= false*/;
|
||||
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
|
||||
// directly be manipulated using the middle mouse button.
|
||||
// When the user chooses a color from the palette the intensity
|
||||
// is reset to 1.0
|
||||
// index[2] is the ambient color
|
||||
extern float g_fLightIntensity /*=0.0f*/;
|
||||
extern float g_fLightIntensity /*=0.0f*/;
|
||||
extern D3DCOLOR g_avLightColors[ 3 ];
|
||||
|
||||
extern RenderOptions g_sOptions;
|
||||
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
|
||||
// HUD texture
|
||||
//
|
||||
extern unsigned char* g_szImageMask /*= NULL*/;
|
||||
extern unsigned char* g_szImageMask /*= NULL*/;
|
||||
|
||||
|
||||
extern float g_fACMR /*= 3.0f*/;
|
||||
extern IDirect3DQuery9* g_piQuery;
|
||||
|
||||
extern bool g_bPlay /*= false*/;
|
||||
extern bool g_bPlay /*= false*/;
|
||||
|
||||
extern double g_dCurrent;
|
||||
extern float g_smoothAngle /*= 80.f*/;
|
||||
|
@ -319,7 +319,7 @@ int CMaterialManager::FindValidPath(aiString* p_szString)
|
|||
{
|
||||
ai_assert(NULL != p_szString);
|
||||
aiString pcpy = *p_szString;
|
||||
if ('*' == p_szString->data[0]) {
|
||||
if ('*' == p_szString->data[0]) {
|
||||
// '*' as first character indicates an embedded file
|
||||
return 5;
|
||||
}
|
||||
|
@ -1161,7 +1161,7 @@ int CMaterialManager::CreateMaterial(
|
|||
++iCurrent;
|
||||
|
||||
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].Definition = "1";
|
||||
++iCurrent;
|
||||
|
@ -1360,9 +1360,9 @@ int CMaterialManager::SetupMaterial (
|
|||
D3DXVec4Normalize(&apcVec[1],&apcVec[1]);
|
||||
piEnd->SetVectorArray("afLightDir",apcVec,5);
|
||||
|
||||
apcVec[0].x = ((g_avLightColors[0] >> 16) & 0xFF) / 255.0f;
|
||||
apcVec[0].y = ((g_avLightColors[0] >> 8) & 0xFF) / 255.0f;
|
||||
apcVec[0].z = ((g_avLightColors[0]) & 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].z = ((g_avLightColors[0]) & 0xFF) / 255.0f;
|
||||
apcVec[0].w = 1.0f;
|
||||
|
||||
if( g_sOptions.b3Lights)
|
||||
|
@ -1383,14 +1383,14 @@ int CMaterialManager::SetupMaterial (
|
|||
apcVec[1] *= g_fLightIntensity;
|
||||
piEnd->SetVectorArray("afLightColor",apcVec,5);
|
||||
|
||||
apcVec[0].x = ((g_avLightColors[2] >> 16) & 0xFF) / 255.0f;
|
||||
apcVec[0].y = ((g_avLightColors[2] >> 8) & 0xFF) / 255.0f;
|
||||
apcVec[0].z = ((g_avLightColors[2]) & 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].z = ((g_avLightColors[2]) & 0xFF) / 255.0f;
|
||||
apcVec[0].w = 1.0f;
|
||||
|
||||
apcVec[1].x = ((g_avLightColors[2] >> 16) & 0xFF) / 255.0f;
|
||||
apcVec[1].y = ((g_avLightColors[2] >> 8) & 0xFF) / 255.0f;
|
||||
apcVec[1].z = ((g_avLightColors[2]) & 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].z = ((g_avLightColors[2]) & 0xFF) / 255.0f;
|
||||
apcVec[1].w = 0.0f;
|
||||
|
||||
// FIX: light intensity doesn't apply to ambient color
|
||||
|
|
|
@ -51,116 +51,116 @@ CMeshRenderer CMeshRenderer::s_cInstance;
|
|||
//-------------------------------------------------------------------------------
|
||||
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
|
||||
g_piDevice->SetStreamSource(0,g_pcAsset->apcMeshes[iIndex]->piVB,0,
|
||||
sizeof(AssetHelper::Vertex));
|
||||
// set vertex and index buffer
|
||||
g_piDevice->SetStreamSource(0,g_pcAsset->apcMeshes[iIndex]->piVB,0,
|
||||
sizeof(AssetHelper::Vertex));
|
||||
|
||||
g_piDevice->SetIndices(g_pcAsset->apcMeshes[iIndex]->piIB);
|
||||
g_piDevice->SetIndices(g_pcAsset->apcMeshes[iIndex]->piIB);
|
||||
|
||||
D3DPRIMITIVETYPE type = D3DPT_POINTLIST;
|
||||
switch (g_pcAsset->pcScene->mMeshes[iIndex]->mPrimitiveTypes) {
|
||||
case aiPrimitiveType_POINT:
|
||||
type = D3DPT_POINTLIST;break;
|
||||
case aiPrimitiveType_LINE:
|
||||
type = D3DPT_LINELIST;break;
|
||||
case aiPrimitiveType_TRIANGLE:
|
||||
type = D3DPT_TRIANGLELIST;break;
|
||||
}
|
||||
// and draw the mesh
|
||||
g_piDevice->DrawIndexedPrimitive(type,
|
||||
0,0,
|
||||
g_pcAsset->pcScene->mMeshes[iIndex]->mNumVertices,0,
|
||||
g_pcAsset->pcScene->mMeshes[iIndex]->mNumFaces);
|
||||
D3DPRIMITIVETYPE type = D3DPT_POINTLIST;
|
||||
switch (g_pcAsset->pcScene->mMeshes[iIndex]->mPrimitiveTypes) {
|
||||
case aiPrimitiveType_POINT:
|
||||
type = D3DPT_POINTLIST;break;
|
||||
case aiPrimitiveType_LINE:
|
||||
type = D3DPT_LINELIST;break;
|
||||
case aiPrimitiveType_TRIANGLE:
|
||||
type = D3DPT_TRIANGLELIST;break;
|
||||
}
|
||||
// and draw the mesh
|
||||
g_piDevice->DrawIndexedPrimitive(type,
|
||||
0,0,
|
||||
g_pcAsset->pcScene->mMeshes[iIndex]->mNumVertices,0,
|
||||
g_pcAsset->pcScene->mMeshes[iIndex]->mNumFaces);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
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];
|
||||
const aiMesh* pcMesh = g_pcAsset->pcScene->mMeshes[iIndex];
|
||||
AssetHelper::MeshHelper* pcHelper = g_pcAsset->apcMeshes[iIndex];
|
||||
const aiMesh* pcMesh = g_pcAsset->pcScene->mMeshes[iIndex];
|
||||
|
||||
if (!pcHelper || !pcMesh || !pcHelper->piIB)
|
||||
return -5;
|
||||
if (!pcHelper || !pcMesh || !pcHelper->piIB)
|
||||
return -5;
|
||||
|
||||
if (pcMesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE || pcMesh->HasBones() || g_sOptions.bNoAlphaBlending)
|
||||
return DrawUnsorted(iIndex);
|
||||
if (pcMesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE || pcMesh->HasBones() || g_sOptions.bNoAlphaBlending)
|
||||
return DrawUnsorted(iIndex);
|
||||
|
||||
|
||||
// compute the position of the camera in worldspace
|
||||
aiMatrix4x4 mWorldInverse = mWorld;
|
||||
mWorldInverse.Inverse();
|
||||
mWorldInverse.Transpose();
|
||||
const aiVector3D vLocalCamera = mWorldInverse * g_sCamera.vPos;
|
||||
// compute the position of the camera in worldspace
|
||||
aiMatrix4x4 mWorldInverse = mWorld;
|
||||
mWorldInverse.Inverse();
|
||||
mWorldInverse.Transpose();
|
||||
const aiVector3D vLocalCamera = mWorldInverse * g_sCamera.vPos;
|
||||
|
||||
// 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
|
||||
// to a map which sorts it
|
||||
std::map<float,unsigned int, std::greater<float> > smap;
|
||||
// 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
|
||||
// to a map which sorts it
|
||||
std::map<float,unsigned int, std::greater<float> > smap;
|
||||
|
||||
for (unsigned int iFace = 0; iFace < pcMesh->mNumFaces;++iFace)
|
||||
{
|
||||
const aiFace* pcFace = &pcMesh->mFaces[iFace];
|
||||
float fDist = 0.0f;
|
||||
for (unsigned int c = 0; c < 3;++c)
|
||||
{
|
||||
aiVector3D vPos = pcMesh->mVertices[pcFace->mIndices[c]];
|
||||
vPos -= vLocalCamera;
|
||||
fDist += vPos.SquareLength();
|
||||
}
|
||||
smap.insert(std::pair<float, unsigned int>(fDist,iFace));
|
||||
}
|
||||
for (unsigned int iFace = 0; iFace < pcMesh->mNumFaces;++iFace)
|
||||
{
|
||||
const aiFace* pcFace = &pcMesh->mFaces[iFace];
|
||||
float fDist = 0.0f;
|
||||
for (unsigned int c = 0; c < 3;++c)
|
||||
{
|
||||
aiVector3D vPos = pcMesh->mVertices[pcFace->mIndices[c]];
|
||||
vPos -= vLocalCamera;
|
||||
fDist += vPos.SquareLength();
|
||||
}
|
||||
smap.insert(std::pair<float, unsigned int>(fDist,iFace));
|
||||
}
|
||||
|
||||
// now we can lock the index buffer and rebuild it
|
||||
D3DINDEXBUFFER_DESC sDesc;
|
||||
pcHelper->piIB->GetDesc(&sDesc);
|
||||
// now we can lock the index buffer and rebuild it
|
||||
D3DINDEXBUFFER_DESC sDesc;
|
||||
pcHelper->piIB->GetDesc(&sDesc);
|
||||
|
||||
if (D3DFMT_INDEX16 == sDesc.Format)
|
||||
{
|
||||
uint16_t* aiIndices;
|
||||
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
||||
if (D3DFMT_INDEX16 == sDesc.Format)
|
||||
{
|
||||
uint16_t* aiIndices;
|
||||
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
||||
|
||||
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
||||
i = smap.begin();
|
||||
i != smap.end();++i)
|
||||
{
|
||||
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
||||
*aiIndices++ = (uint16_t)pcFace->mIndices[0];
|
||||
*aiIndices++ = (uint16_t)pcFace->mIndices[1];
|
||||
*aiIndices++ = (uint16_t)pcFace->mIndices[2];
|
||||
}
|
||||
}
|
||||
else if (D3DFMT_INDEX32 == sDesc.Format)
|
||||
{
|
||||
uint32_t* aiIndices;
|
||||
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
||||
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
||||
i = smap.begin();
|
||||
i != smap.end();++i)
|
||||
{
|
||||
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
||||
*aiIndices++ = (uint16_t)pcFace->mIndices[0];
|
||||
*aiIndices++ = (uint16_t)pcFace->mIndices[1];
|
||||
*aiIndices++ = (uint16_t)pcFace->mIndices[2];
|
||||
}
|
||||
}
|
||||
else if (D3DFMT_INDEX32 == sDesc.Format)
|
||||
{
|
||||
uint32_t* aiIndices;
|
||||
pcHelper->piIB->Lock(0,0,(void**)&aiIndices,D3DLOCK_DISCARD);
|
||||
|
||||
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
||||
i = smap.begin();
|
||||
i != smap.end();++i)
|
||||
{
|
||||
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
||||
*aiIndices++ = (uint32_t)pcFace->mIndices[0];
|
||||
*aiIndices++ = (uint32_t)pcFace->mIndices[1];
|
||||
*aiIndices++ = (uint32_t)pcFace->mIndices[2];
|
||||
}
|
||||
}
|
||||
pcHelper->piIB->Unlock();
|
||||
for (std::map<float,unsigned int, std::greater<float> >::const_iterator
|
||||
i = smap.begin();
|
||||
i != smap.end();++i)
|
||||
{
|
||||
const aiFace* pcFace = &pcMesh->mFaces[(*i).second];
|
||||
*aiIndices++ = (uint32_t)pcFace->mIndices[0];
|
||||
*aiIndices++ = (uint32_t)pcFace->mIndices[1];
|
||||
*aiIndices++ = (uint32_t)pcFace->mIndices[2];
|
||||
}
|
||||
}
|
||||
pcHelper->piIB->Unlock();
|
||||
|
||||
// set vertex and index buffer
|
||||
g_piDevice->SetStreamSource(0,pcHelper->piVB,0,sizeof(AssetHelper::Vertex));
|
||||
// set vertex and index buffer
|
||||
g_piDevice->SetStreamSource(0,pcHelper->piVB,0,sizeof(AssetHelper::Vertex));
|
||||
|
||||
// and draw the mesh
|
||||
g_piDevice->SetIndices(pcHelper->piIB);
|
||||
g_piDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
|
||||
0,0,
|
||||
pcMesh->mNumVertices,0,
|
||||
pcMesh->mNumFaces);
|
||||
// and draw the mesh
|
||||
g_piDevice->SetIndices(pcHelper->piIB);
|
||||
g_piDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
|
||||
0,0,
|
||||
pcMesh->mNumVertices,0,
|
||||
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()
|
||||
{
|
||||
// invert all normal vectors
|
||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
aiMesh* pcMesh = this->pcScene->mMeshes[i];
|
||||
// invert all normal vectors
|
||||
for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
aiMesh* pcMesh = this->pcScene->mMeshes[i];
|
||||
|
||||
if (!pcMesh->mNormals)
|
||||
continue;
|
||||
if (!pcMesh->mNormals)
|
||||
continue;
|
||||
|
||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a){
|
||||
pcMesh->mNormals[a] *= -1.0f;
|
||||
}
|
||||
}
|
||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a){
|
||||
pcMesh->mNormals[a] *= -1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
void AssetHelper::FlipNormals()
|
||||
{
|
||||
FlipNormalsInt();
|
||||
FlipNormalsInt();
|
||||
|
||||
// recreate native data
|
||||
DeleteAssetData(true);
|
||||
CreateAssetData();
|
||||
g_bWasFlipped = ! g_bWasFlipped;
|
||||
// recreate native data
|
||||
DeleteAssetData(true);
|
||||
CreateAssetData();
|
||||
g_bWasFlipped = ! g_bWasFlipped;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
@ -92,84 +92,84 @@ void AssetHelper::FlipNormals()
|
|||
//-------------------------------------------------------------------------------
|
||||
void AssetHelper::SetNormalSet(unsigned int iSet)
|
||||
{
|
||||
// we need to build an unique set of vertices for this ...
|
||||
{
|
||||
MakeVerboseFormatProcess* pcProcess = new MakeVerboseFormatProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
delete pcProcess;
|
||||
// we need to build an unique set of vertices for this ...
|
||||
{
|
||||
MakeVerboseFormatProcess* pcProcess = new MakeVerboseFormatProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
delete pcProcess;
|
||||
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (!apcMeshes[i]->pvOriginalNormals)
|
||||
{
|
||||
apcMeshes[i]->pvOriginalNormals = new aiVector3D[pcScene->mMeshes[i]->mNumVertices];
|
||||
memcpy( apcMeshes[i]->pvOriginalNormals,pcScene->mMeshes[i]->mNormals,
|
||||
pcScene->mMeshes[i]->mNumVertices * sizeof(aiVector3D));
|
||||
}
|
||||
delete[] pcScene->mMeshes[i]->mNormals;
|
||||
pcScene->mMeshes[i]->mNormals = NULL;
|
||||
}
|
||||
}
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (!apcMeshes[i]->pvOriginalNormals)
|
||||
{
|
||||
apcMeshes[i]->pvOriginalNormals = new aiVector3D[pcScene->mMeshes[i]->mNumVertices];
|
||||
memcpy( apcMeshes[i]->pvOriginalNormals,pcScene->mMeshes[i]->mNormals,
|
||||
pcScene->mMeshes[i]->mNumVertices * sizeof(aiVector3D));
|
||||
}
|
||||
delete[] pcScene->mMeshes[i]->mNormals;
|
||||
pcScene->mMeshes[i]->mNormals = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// now we can start to calculate a new set of normals
|
||||
if (HARD == iSet)
|
||||
{
|
||||
GenFaceNormalsProcess* pcProcess = new GenFaceNormalsProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
FlipNormalsInt();
|
||||
delete pcProcess;
|
||||
}
|
||||
else if (SMOOTH == iSet)
|
||||
{
|
||||
GenVertexNormalsProcess* pcProcess = new GenVertexNormalsProcess();
|
||||
pcProcess->SetMaxSmoothAngle((float)AI_DEG_TO_RAD(g_smoothAngle));
|
||||
pcProcess->Execute(pcScene);
|
||||
FlipNormalsInt();
|
||||
delete pcProcess;
|
||||
}
|
||||
else if (ORIGINAL == iSet)
|
||||
{
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (apcMeshes[i]->pvOriginalNormals)
|
||||
{
|
||||
delete[] pcScene->mMeshes[i]->mNormals;
|
||||
pcScene->mMeshes[i]->mNormals = apcMeshes[i]->pvOriginalNormals;
|
||||
apcMeshes[i]->pvOriginalNormals = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
// now we can start to calculate a new set of normals
|
||||
if (HARD == iSet)
|
||||
{
|
||||
GenFaceNormalsProcess* pcProcess = new GenFaceNormalsProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
FlipNormalsInt();
|
||||
delete pcProcess;
|
||||
}
|
||||
else if (SMOOTH == iSet)
|
||||
{
|
||||
GenVertexNormalsProcess* pcProcess = new GenVertexNormalsProcess();
|
||||
pcProcess->SetMaxSmoothAngle((float)AI_DEG_TO_RAD(g_smoothAngle));
|
||||
pcProcess->Execute(pcScene);
|
||||
FlipNormalsInt();
|
||||
delete pcProcess;
|
||||
}
|
||||
else if (ORIGINAL == iSet)
|
||||
{
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (apcMeshes[i]->pvOriginalNormals)
|
||||
{
|
||||
delete[] pcScene->mMeshes[i]->mNormals;
|
||||
pcScene->mMeshes[i]->mNormals = apcMeshes[i]->pvOriginalNormals;
|
||||
apcMeshes[i]->pvOriginalNormals = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// recalculate tangents and bitangents
|
||||
Assimp::BaseProcess* pcProcess = new CalcTangentsProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
delete pcProcess;
|
||||
// recalculate tangents and bitangents
|
||||
Assimp::BaseProcess* pcProcess = new CalcTangentsProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
delete pcProcess;
|
||||
|
||||
// join the mesh vertices again
|
||||
pcProcess = new JoinVerticesProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
delete pcProcess;
|
||||
// join the mesh vertices again
|
||||
pcProcess = new JoinVerticesProcess();
|
||||
pcProcess->Execute(pcScene);
|
||||
delete pcProcess;
|
||||
|
||||
iNormalSet = iSet;
|
||||
iNormalSet = iSet;
|
||||
|
||||
if (g_bWasFlipped)
|
||||
{
|
||||
// invert all normal vectors
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||
{
|
||||
aiMesh* pcMesh = pcScene->mMeshes[i];
|
||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a)
|
||||
{
|
||||
pcMesh->mNormals[a] *= -1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (g_bWasFlipped)
|
||||
{
|
||||
// invert all normal vectors
|
||||
for (unsigned int i = 0; i < pcScene->mNumMeshes;++i)
|
||||
{
|
||||
aiMesh* pcMesh = pcScene->mMeshes[i];
|
||||
for (unsigned int a = 0; a < pcMesh->mNumVertices;++a)
|
||||
{
|
||||
pcMesh->mNormals[a] *= -1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// recreate native data
|
||||
DeleteAssetData(true);
|
||||
CreateAssetData();
|
||||
return;
|
||||
// recreate native data
|
||||
DeleteAssetData(true);
|
||||
CreateAssetData();
|
||||
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
|
||||
{
|
||||
public:
|
||||
{
|
||||
public:
|
||||
|
||||
// enumerates different drawing modi. POINT is currently
|
||||
// not supported and probably will never be.
|
||||
enum DrawMode {NORMAL, WIREFRAME, POINT};
|
||||
// enumerates different drawing modi. POINT is currently
|
||||
// not supported and probably will never be.
|
||||
enum DrawMode {NORMAL, WIREFRAME, POINT};
|
||||
|
||||
inline RenderOptions (void) :
|
||||
bMultiSample (true),
|
||||
bSuperSample (false),
|
||||
bRenderMats (true),
|
||||
bRenderNormals (false),
|
||||
b3Lights (false),
|
||||
bLightRotate (false),
|
||||
bRotate (true),
|
||||
bLowQuality (false),
|
||||
bNoSpecular (false),
|
||||
bStereoView (false),
|
||||
bNoAlphaBlending(false),
|
||||
eDrawMode (NORMAL),
|
||||
bCulling (false),
|
||||
bSkeleton (false)
|
||||
inline RenderOptions (void) :
|
||||
bMultiSample (true),
|
||||
bSuperSample (false),
|
||||
bRenderMats (true),
|
||||
bRenderNormals (false),
|
||||
b3Lights (false),
|
||||
bLightRotate (false),
|
||||
bRotate (true),
|
||||
bLowQuality (false),
|
||||
bNoSpecular (false),
|
||||
bStereoView (false),
|
||||
bNoAlphaBlending(false),
|
||||
eDrawMode (NORMAL),
|
||||
bCulling (false),
|
||||
bSkeleton (false)
|
||||
|
||||
{}
|
||||
{}
|
||||
|
||||
bool bMultiSample;
|
||||
bool bMultiSample;
|
||||
|
||||
// SuperSampling has not yet been implemented
|
||||
bool bSuperSample;
|
||||
// SuperSampling has not yet been implemented
|
||||
bool bSuperSample;
|
||||
|
||||
// Display the real material of the object
|
||||
bool bRenderMats;
|
||||
// Display the real material of the object
|
||||
bool bRenderMats;
|
||||
|
||||
// Render the normals
|
||||
bool bRenderNormals;
|
||||
// Render the normals
|
||||
bool bRenderNormals;
|
||||
|
||||
// Use 2 directional light sources
|
||||
bool b3Lights;
|
||||
// Use 2 directional light sources
|
||||
bool b3Lights;
|
||||
|
||||
// Automatically rotate the light source(s)
|
||||
bool bLightRotate;
|
||||
// Automatically rotate the light source(s)
|
||||
bool bLightRotate;
|
||||
|
||||
// Automatically rotate the asset around its origin
|
||||
bool bRotate;
|
||||
// Automatically rotate the asset around its origin
|
||||
bool bRotate;
|
||||
|
||||
// use standard lambertian lighting
|
||||
bool bLowQuality;
|
||||
// use standard lambertian lighting
|
||||
bool bLowQuality;
|
||||
|
||||
// disable specular lighting got all elements in the scene
|
||||
bool bNoSpecular;
|
||||
// disable specular lighting got all elements in the scene
|
||||
bool bNoSpecular;
|
||||
|
||||
// enable stereo view
|
||||
bool bStereoView;
|
||||
// enable stereo view
|
||||
bool bStereoView;
|
||||
|
||||
bool bNoAlphaBlending;
|
||||
bool bNoAlphaBlending;
|
||||
|
||||
// wireframe or solid rendering?
|
||||
DrawMode eDrawMode;
|
||||
// wireframe or solid rendering?
|
||||
DrawMode eDrawMode;
|
||||
|
||||
bool bCulling,bSkeleton;
|
||||
};
|
||||
bool bCulling,bSkeleton;
|
||||
};
|
||||
|
||||
#endif // !! IG
|
|
@ -51,195 +51,195 @@ using namespace AssimpView;
|
|||
// Constructor for a given scene.
|
||||
SceneAnimator::SceneAnimator( const aiScene* pScene, size_t pAnimIndex)
|
||||
{
|
||||
mScene = pScene;
|
||||
mCurrentAnimIndex = -1;
|
||||
mAnimEvaluator = NULL;
|
||||
mRootNode = NULL;
|
||||
mScene = pScene;
|
||||
mCurrentAnimIndex = -1;
|
||||
mAnimEvaluator = NULL;
|
||||
mRootNode = NULL;
|
||||
|
||||
// build the nodes-for-bones table
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
{
|
||||
const aiMesh* mesh = pScene->mMeshes[i];
|
||||
for (unsigned int n = 0; n < mesh->mNumBones;++n)
|
||||
{
|
||||
const aiBone* bone = mesh->mBones[n];
|
||||
// build the nodes-for-bones table
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes;++i)
|
||||
{
|
||||
const aiMesh* mesh = pScene->mMeshes[i];
|
||||
for (unsigned int n = 0; n < mesh->mNumBones;++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
|
||||
SetAnimIndex( pAnimIndex);
|
||||
// changing the current animation also creates the node tree for this animation
|
||||
SetAnimIndex( pAnimIndex);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor
|
||||
SceneAnimator::~SceneAnimator()
|
||||
{
|
||||
delete mRootNode;
|
||||
delete mAnimEvaluator;
|
||||
delete mRootNode;
|
||||
delete mAnimEvaluator;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Sets the animation to use for playback.
|
||||
void SceneAnimator::SetAnimIndex( size_t pAnimIndex)
|
||||
{
|
||||
// no change
|
||||
if( pAnimIndex == mCurrentAnimIndex)
|
||||
return;
|
||||
// no change
|
||||
if( pAnimIndex == mCurrentAnimIndex)
|
||||
return;
|
||||
|
||||
// kill data of the previous anim
|
||||
delete mRootNode; mRootNode = NULL;
|
||||
delete mAnimEvaluator; mAnimEvaluator = NULL;
|
||||
mNodesByName.clear();
|
||||
// kill data of the previous anim
|
||||
delete mRootNode; mRootNode = NULL;
|
||||
delete mAnimEvaluator; mAnimEvaluator = NULL;
|
||||
mNodesByName.clear();
|
||||
|
||||
mCurrentAnimIndex = pAnimIndex;
|
||||
mCurrentAnimIndex = pAnimIndex;
|
||||
|
||||
// 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
|
||||
mRootNode = CreateNodeTree( mScene->mRootNode, NULL);
|
||||
// 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
|
||||
mRootNode = CreateNodeTree( mScene->mRootNode, NULL);
|
||||
|
||||
// invalid anim index
|
||||
if( mCurrentAnimIndex >= mScene->mNumAnimations)
|
||||
return;
|
||||
// invalid anim index
|
||||
if( mCurrentAnimIndex >= mScene->mNumAnimations)
|
||||
return;
|
||||
|
||||
// create an evaluator for this animation
|
||||
mAnimEvaluator = new AnimEvaluator( mScene->mAnimations[mCurrentAnimIndex]);
|
||||
// create an evaluator for this animation
|
||||
mAnimEvaluator = new AnimEvaluator( mScene->mAnimations[mCurrentAnimIndex]);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Calculates the node transformations for the scene.
|
||||
void SceneAnimator::Calculate( double pTime)
|
||||
{
|
||||
// invalid anim
|
||||
if( !mAnimEvaluator)
|
||||
return;
|
||||
// invalid anim
|
||||
if( !mAnimEvaluator)
|
||||
return;
|
||||
|
||||
// calculate current local transformations
|
||||
mAnimEvaluator->Evaluate( pTime);
|
||||
// calculate current local transformations
|
||||
mAnimEvaluator->Evaluate( pTime);
|
||||
|
||||
// and update all node transformations with the results
|
||||
UpdateTransforms( mRootNode, mAnimEvaluator->GetTransformations());
|
||||
// and update all node transformations with the results
|
||||
UpdateTransforms( mRootNode, mAnimEvaluator->GetTransformations());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Retrieves the most recent local transformation matrix for the given node.
|
||||
const aiMatrix4x4& SceneAnimator::GetLocalTransform( const aiNode* node) const
|
||||
{
|
||||
NodeMap::const_iterator it = mNodesByName.find( node);
|
||||
if( it == mNodesByName.end())
|
||||
return mIdentityMatrix;
|
||||
NodeMap::const_iterator it = mNodesByName.find( node);
|
||||
if( it == mNodesByName.end())
|
||||
return mIdentityMatrix;
|
||||
|
||||
return it->second->mLocalTransform;
|
||||
return it->second->mLocalTransform;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Retrieves the most recent global transformation matrix for the given node.
|
||||
const aiMatrix4x4& SceneAnimator::GetGlobalTransform( const aiNode* node) const
|
||||
{
|
||||
NodeMap::const_iterator it = mNodesByName.find( node);
|
||||
if( it == mNodesByName.end())
|
||||
return mIdentityMatrix;
|
||||
NodeMap::const_iterator it = mNodesByName.find( node);
|
||||
if( it == mNodesByName.end())
|
||||
return mIdentityMatrix;
|
||||
|
||||
return it->second->mGlobalTransform;
|
||||
return it->second->mGlobalTransform;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Calculates the bone matrices for the given mesh.
|
||||
const std::vector<aiMatrix4x4>& SceneAnimator::GetBoneMatrices( const aiNode* pNode, size_t pMeshIndex /* = 0 */)
|
||||
{
|
||||
ai_assert( pMeshIndex < pNode->mNumMeshes);
|
||||
size_t meshIndex = pNode->mMeshes[pMeshIndex];
|
||||
ai_assert( meshIndex < mScene->mNumMeshes);
|
||||
const aiMesh* mesh = mScene->mMeshes[meshIndex];
|
||||
ai_assert( pMeshIndex < pNode->mNumMeshes);
|
||||
size_t meshIndex = pNode->mMeshes[pMeshIndex];
|
||||
ai_assert( meshIndex < mScene->mNumMeshes);
|
||||
const aiMesh* mesh = mScene->mMeshes[meshIndex];
|
||||
|
||||
// resize array and initialise it with identity matrices
|
||||
mTransforms.resize( mesh->mNumBones, aiMatrix4x4());
|
||||
// resize array and initialise it with identity matrices
|
||||
mTransforms.resize( mesh->mNumBones, aiMatrix4x4());
|
||||
|
||||
// calculate the mesh's inverse global transform
|
||||
aiMatrix4x4 globalInverseMeshTransform = GetGlobalTransform( pNode);
|
||||
globalInverseMeshTransform.Inverse();
|
||||
// calculate the mesh's inverse global transform
|
||||
aiMatrix4x4 globalInverseMeshTransform = GetGlobalTransform( pNode);
|
||||
globalInverseMeshTransform.Inverse();
|
||||
|
||||
// Bone matrices transform from mesh coordinates in bind pose to mesh coordinates in skinned pose
|
||||
// Therefore the formula is offsetMatrix * currentGlobalTransform * inverseCurrentMeshTransform
|
||||
for( size_t a = 0; a < mesh->mNumBones; ++a)
|
||||
{
|
||||
const aiBone* bone = mesh->mBones[a];
|
||||
const aiMatrix4x4& currentGlobalTransform = GetGlobalTransform( mBoneNodesByName[ bone->mName.data ]);
|
||||
mTransforms[a] = globalInverseMeshTransform * currentGlobalTransform * bone->mOffsetMatrix;
|
||||
}
|
||||
// Bone matrices transform from mesh coordinates in bind pose to mesh coordinates in skinned pose
|
||||
// Therefore the formula is offsetMatrix * currentGlobalTransform * inverseCurrentMeshTransform
|
||||
for( size_t a = 0; a < mesh->mNumBones; ++a)
|
||||
{
|
||||
const aiBone* bone = mesh->mBones[a];
|
||||
const aiMatrix4x4& currentGlobalTransform = GetGlobalTransform( mBoneNodesByName[ bone->mName.data ]);
|
||||
mTransforms[a] = globalInverseMeshTransform * currentGlobalTransform * bone->mOffsetMatrix;
|
||||
}
|
||||
|
||||
// and return the result
|
||||
return mTransforms;
|
||||
// and return the result
|
||||
return mTransforms;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Recursively creates an internal node structure matching the current scene and animation.
|
||||
SceneAnimNode* SceneAnimator::CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent)
|
||||
{
|
||||
// create a node
|
||||
SceneAnimNode* internalNode = new SceneAnimNode( pNode->mName.data);
|
||||
internalNode->mParent = pParent;
|
||||
mNodesByName[pNode] = internalNode;
|
||||
// create a node
|
||||
SceneAnimNode* internalNode = new SceneAnimNode( pNode->mName.data);
|
||||
internalNode->mParent = pParent;
|
||||
mNodesByName[pNode] = internalNode;
|
||||
|
||||
// copy its transformation
|
||||
internalNode->mLocalTransform = pNode->mTransformation;
|
||||
CalculateGlobalTransform( internalNode);
|
||||
// copy its transformation
|
||||
internalNode->mLocalTransform = pNode->mTransformation;
|
||||
CalculateGlobalTransform( internalNode);
|
||||
|
||||
// find the index of the animation track affecting this node, if any
|
||||
if( mCurrentAnimIndex < mScene->mNumAnimations)
|
||||
{
|
||||
internalNode->mChannelIndex = -1;
|
||||
const aiAnimation* currentAnim = mScene->mAnimations[mCurrentAnimIndex];
|
||||
for( unsigned int a = 0; a < currentAnim->mNumChannels; a++)
|
||||
{
|
||||
if( currentAnim->mChannels[a]->mNodeName.data == internalNode->mName)
|
||||
{
|
||||
internalNode->mChannelIndex = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// find the index of the animation track affecting this node, if any
|
||||
if( mCurrentAnimIndex < mScene->mNumAnimations)
|
||||
{
|
||||
internalNode->mChannelIndex = -1;
|
||||
const aiAnimation* currentAnim = mScene->mAnimations[mCurrentAnimIndex];
|
||||
for( unsigned int a = 0; a < currentAnim->mNumChannels; a++)
|
||||
{
|
||||
if( currentAnim->mChannels[a]->mNodeName.data == internalNode->mName)
|
||||
{
|
||||
internalNode->mChannelIndex = a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// continue for all child nodes and assign the created internal nodes as our children
|
||||
for( unsigned int a = 0; a < pNode->mNumChildren; a++)
|
||||
{
|
||||
SceneAnimNode* childNode = CreateNodeTree( pNode->mChildren[a], internalNode);
|
||||
internalNode->mChildren.push_back( childNode);
|
||||
}
|
||||
// continue for all child nodes and assign the created internal nodes as our children
|
||||
for( unsigned int a = 0; a < pNode->mNumChildren; a++)
|
||||
{
|
||||
SceneAnimNode* childNode = CreateNodeTree( pNode->mChildren[a], internalNode);
|
||||
internalNode->mChildren.push_back( childNode);
|
||||
}
|
||||
|
||||
return internalNode;
|
||||
return internalNode;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Recursively updates the internal node transformations from the given matrix array
|
||||
void SceneAnimator::UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms)
|
||||
{
|
||||
// update node local transform
|
||||
if( pNode->mChannelIndex != -1)
|
||||
{
|
||||
ai_assert( pNode->mChannelIndex < pTransforms.size());
|
||||
pNode->mLocalTransform = pTransforms[pNode->mChannelIndex];
|
||||
}
|
||||
// update node local transform
|
||||
if( pNode->mChannelIndex != -1)
|
||||
{
|
||||
ai_assert( pNode->mChannelIndex < pTransforms.size());
|
||||
pNode->mLocalTransform = pTransforms[pNode->mChannelIndex];
|
||||
}
|
||||
|
||||
// update global transform as well
|
||||
CalculateGlobalTransform( pNode);
|
||||
// update global transform as well
|
||||
CalculateGlobalTransform( pNode);
|
||||
|
||||
// continue for all children
|
||||
for( std::vector<SceneAnimNode*>::iterator it = pNode->mChildren.begin(); it != pNode->mChildren.end(); ++it)
|
||||
UpdateTransforms( *it, pTransforms);
|
||||
// continue for all children
|
||||
for( std::vector<SceneAnimNode*>::iterator it = pNode->mChildren.begin(); it != pNode->mChildren.end(); ++it)
|
||||
UpdateTransforms( *it, pTransforms);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Calculates the global transformation matrix for the given internal node
|
||||
void SceneAnimator::CalculateGlobalTransform( SceneAnimNode* pInternalNode)
|
||||
{
|
||||
// concatenate all parent transforms to get the global transform for this node
|
||||
pInternalNode->mGlobalTransform = pInternalNode->mLocalTransform;
|
||||
SceneAnimNode* node = pInternalNode->mParent;
|
||||
while( node)
|
||||
{
|
||||
pInternalNode->mGlobalTransform = node->mLocalTransform * pInternalNode->mGlobalTransform;
|
||||
node = node->mParent;
|
||||
}
|
||||
// concatenate all parent transforms to get the global transform for this node
|
||||
pInternalNode->mGlobalTransform = pInternalNode->mLocalTransform;
|
||||
SceneAnimNode* node = pInternalNode->mParent;
|
||||
while( node)
|
||||
{
|
||||
pInternalNode->mGlobalTransform = node->mLocalTransform * pInternalNode->mGlobalTransform;
|
||||
node = node->mParent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <map>
|
||||
|
||||
namespace AssimpView {
|
||||
namespace AssimpView {
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
/** A little tree structure to match the scene's node structure, but holding
|
||||
|
@ -58,35 +58,35 @@ namespace AssimpView {
|
|||
*/
|
||||
struct SceneAnimNode
|
||||
{
|
||||
std::string mName;
|
||||
SceneAnimNode* mParent;
|
||||
std::vector<SceneAnimNode*> mChildren;
|
||||
std::string mName;
|
||||
SceneAnimNode* mParent;
|
||||
std::vector<SceneAnimNode*> mChildren;
|
||||
|
||||
//! most recently calculated local transform
|
||||
aiMatrix4x4 mLocalTransform;
|
||||
//! most recently calculated local transform
|
||||
aiMatrix4x4 mLocalTransform;
|
||||
|
||||
//! same, but in world space
|
||||
aiMatrix4x4 mGlobalTransform;
|
||||
//! same, but in world space
|
||||
aiMatrix4x4 mGlobalTransform;
|
||||
|
||||
//! index in the current animation's channel array. -1 if not animated.
|
||||
size_t mChannelIndex;
|
||||
//! index in the current animation's channel array. -1 if not animated.
|
||||
size_t mChannelIndex;
|
||||
|
||||
//! Default construction
|
||||
SceneAnimNode() {
|
||||
mChannelIndex = -1; mParent = NULL;
|
||||
}
|
||||
//! Default construction
|
||||
SceneAnimNode() {
|
||||
mChannelIndex = -1; mParent = NULL;
|
||||
}
|
||||
|
||||
//! Construction from a given name
|
||||
SceneAnimNode( const std::string& pName)
|
||||
: mName( pName) {
|
||||
mChannelIndex = -1; mParent = NULL;
|
||||
}
|
||||
//! Construction from a given name
|
||||
SceneAnimNode( const std::string& pName)
|
||||
: mName( pName) {
|
||||
mChannelIndex = -1; mParent = NULL;
|
||||
}
|
||||
|
||||
//! Destruct all children recursively
|
||||
~SceneAnimNode() {
|
||||
for( std::vector<SceneAnimNode*>::iterator it = mChildren.begin(); it != mChildren.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
//! Destruct all children recursively
|
||||
~SceneAnimNode() {
|
||||
for( std::vector<SceneAnimNode*>::iterator it = mChildren.begin(); it != mChildren.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
@ -103,139 +103,139 @@ class SceneAnimator
|
|||
{
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Constructor for a given scene.
|
||||
*
|
||||
* The object keeps a reference to the scene during its lifetime, but
|
||||
* ownership stays at the caller.
|
||||
* @param pScene The scene to animate.
|
||||
* @param pAnimIndex [optional] Index of the animation to play. Assumed to
|
||||
* be 0 if not given.
|
||||
*/
|
||||
SceneAnimator( const aiScene* pScene, size_t pAnimIndex = 0);
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Constructor for a given scene.
|
||||
*
|
||||
* The object keeps a reference to the scene during its lifetime, but
|
||||
* ownership stays at the caller.
|
||||
* @param pScene The scene to animate.
|
||||
* @param pAnimIndex [optional] Index of the animation to play. Assumed to
|
||||
* be 0 if not given.
|
||||
*/
|
||||
SceneAnimator( const aiScene* pScene, size_t pAnimIndex = 0);
|
||||
|
||||
/** Destructor */
|
||||
~SceneAnimator();
|
||||
/** Destructor */
|
||||
~SceneAnimator();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets the animation to use for playback. This also recreates the internal
|
||||
* mapping structures, which might take a few cycles.
|
||||
* @param pAnimIndex Index of the animation in the scene's animation array
|
||||
*/
|
||||
void SetAnimIndex( size_t pAnimIndex);
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets the animation to use for playback. This also recreates the internal
|
||||
* mapping structures, which might take a few cycles.
|
||||
* @param pAnimIndex Index of the animation in the scene's animation array
|
||||
*/
|
||||
void SetAnimIndex( size_t pAnimIndex);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Calculates the node transformations for the scene. Call this to get
|
||||
* uptodate results before calling one of the getters.
|
||||
* @param pTime Current time. Can be an arbitrary range.
|
||||
*/
|
||||
void Calculate( double pTime);
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Calculates the node transformations for the scene. Call this to get
|
||||
* uptodate results before calling one of the getters.
|
||||
* @param pTime Current time. Can be an arbitrary range.
|
||||
*/
|
||||
void Calculate( double pTime);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** 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
|
||||
* 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
|
||||
* 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
|
||||
* Calculate() is called.
|
||||
* @param pNodeName Name of the node
|
||||
* @return A reference to the node's most recently calculated local
|
||||
* transformation matrix.
|
||||
*/
|
||||
const aiMatrix4x4& GetLocalTransform( const aiNode* node) const;
|
||||
// ----------------------------------------------------------------------------
|
||||
/** 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
|
||||
* 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
|
||||
* 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
|
||||
* Calculate() is called.
|
||||
* @param pNodeName Name of the node
|
||||
* @return A reference to the node's most recently calculated local
|
||||
* transformation matrix.
|
||||
*/
|
||||
const aiMatrix4x4& GetLocalTransform( const aiNode* node) const;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Retrieves the most recent global transformation matrix for the given node.
|
||||
*
|
||||
* 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,
|
||||
* 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
|
||||
* identity matrix is returned. All transformations are updated whenever
|
||||
* Calculate() is called.
|
||||
* @param pNodeName Name of the node
|
||||
* @return A reference to the node's most recently calculated global
|
||||
* transformation matrix.
|
||||
*/
|
||||
const aiMatrix4x4& GetGlobalTransform( const aiNode* node) const;
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Retrieves the most recent global transformation matrix for the given node.
|
||||
*
|
||||
* 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,
|
||||
* 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
|
||||
* identity matrix is returned. All transformations are updated whenever
|
||||
* Calculate() is called.
|
||||
* @param pNodeName Name of the node
|
||||
* @return A reference to the node's most recently calculated global
|
||||
* transformation matrix.
|
||||
*/
|
||||
const aiMatrix4x4& GetGlobalTransform( const aiNode* node) const;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Calculates the bone matrices for the given mesh.
|
||||
*
|
||||
* 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
|
||||
* matrix chain for using in the vertex shader is
|
||||
* @code
|
||||
* boneMatrix * worldMatrix * viewMatrix * projMatrix
|
||||
* @endcode
|
||||
* @param pNode The node carrying the mesh.
|
||||
* @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
|
||||
* of the node, which is usually also the only one.
|
||||
* @return A reference to a vector of bone matrices. Stays stable till the
|
||||
* next call to GetBoneMatrices();
|
||||
*/
|
||||
const std::vector<aiMatrix4x4>& GetBoneMatrices( const aiNode* pNode,
|
||||
size_t pMeshIndex = 0);
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Calculates the bone matrices for the given mesh.
|
||||
*
|
||||
* 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
|
||||
* matrix chain for using in the vertex shader is
|
||||
* @code
|
||||
* boneMatrix * worldMatrix * viewMatrix * projMatrix
|
||||
* @endcode
|
||||
* @param pNode The node carrying the mesh.
|
||||
* @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
|
||||
* of the node, which is usually also the only one.
|
||||
* @return A reference to a vector of bone matrices. Stays stable till the
|
||||
* next call to GetBoneMatrices();
|
||||
*/
|
||||
const std::vector<aiMatrix4x4>& GetBoneMatrices( const aiNode* pNode,
|
||||
size_t pMeshIndex = 0);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** @brief Get the current animation index
|
||||
*/
|
||||
size_t CurrentAnimIndex() const {
|
||||
return mCurrentAnimIndex;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
/** @brief Get the current animation index
|
||||
*/
|
||||
size_t CurrentAnimIndex() const {
|
||||
return mCurrentAnimIndex;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** @brief Get the current animation or NULL
|
||||
*/
|
||||
aiAnimation* CurrentAnim() const {
|
||||
return mCurrentAnimIndex < mScene->mNumAnimations ? mScene->mAnimations[ mCurrentAnimIndex ] : NULL;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
/** @brief Get the current animation or NULL
|
||||
*/
|
||||
aiAnimation* CurrentAnim() const {
|
||||
return mCurrentAnimIndex < mScene->mNumAnimations ? mScene->mAnimations[ mCurrentAnimIndex ] : NULL;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/** Recursively creates an internal node structure matching the
|
||||
* current scene and animation.
|
||||
*/
|
||||
SceneAnimNode* CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent);
|
||||
/** Recursively creates an internal node structure matching the
|
||||
* current scene and animation.
|
||||
*/
|
||||
SceneAnimNode* CreateNodeTree( aiNode* pNode, SceneAnimNode* pParent);
|
||||
|
||||
/** Recursively updates the internal node transformations from the
|
||||
* given matrix array
|
||||
*/
|
||||
void UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms);
|
||||
/** Recursively updates the internal node transformations from the
|
||||
* given matrix array
|
||||
*/
|
||||
void UpdateTransforms( SceneAnimNode* pNode, const std::vector<aiMatrix4x4>& pTransforms);
|
||||
|
||||
/** Calculates the global transformation matrix for the given internal node */
|
||||
void CalculateGlobalTransform( SceneAnimNode* pInternalNode);
|
||||
/** Calculates the global transformation matrix for the given internal node */
|
||||
void CalculateGlobalTransform( SceneAnimNode* pInternalNode);
|
||||
|
||||
protected:
|
||||
/** The scene we're operating on */
|
||||
const aiScene* mScene;
|
||||
/** The scene we're operating on */
|
||||
const aiScene* mScene;
|
||||
|
||||
/** Current animation index */
|
||||
size_t mCurrentAnimIndex;
|
||||
/** Current animation index */
|
||||
size_t mCurrentAnimIndex;
|
||||
|
||||
/** The AnimEvaluator we use to calculate the current pose for the current animation */
|
||||
AnimEvaluator* mAnimEvaluator;
|
||||
/** The AnimEvaluator we use to calculate the current pose for the current animation */
|
||||
AnimEvaluator* mAnimEvaluator;
|
||||
|
||||
/** Root node of the internal scene structure */
|
||||
SceneAnimNode* mRootNode;
|
||||
/** Root node of the internal scene structure */
|
||||
SceneAnimNode* mRootNode;
|
||||
|
||||
/** Name to node map to quickly find nodes by their name */
|
||||
typedef std::map<const aiNode*, SceneAnimNode*> NodeMap;
|
||||
NodeMap mNodesByName;
|
||||
/** Name to node map to quickly find nodes by their name */
|
||||
typedef std::map<const aiNode*, SceneAnimNode*> NodeMap;
|
||||
NodeMap mNodesByName;
|
||||
|
||||
/** Name to node map to quickly find nodes for given bones by their name */
|
||||
typedef std::map<const char*, const aiNode*> BoneMap;
|
||||
BoneMap mBoneNodesByName;
|
||||
/** Name to node map to quickly find nodes for given bones by their name */
|
||||
typedef std::map<const char*, const aiNode*> BoneMap;
|
||||
BoneMap mBoneNodesByName;
|
||||
|
||||
/** Array to return transformations results inside. */
|
||||
std::vector<aiMatrix4x4> mTransforms;
|
||||
/** Array to return transformations results inside. */
|
||||
std::vector<aiMatrix4x4> mTransforms;
|
||||
|
||||
/** Identity matrix to return a reference to in case of error */
|
||||
aiMatrix4x4 mIdentityMatrix;
|
||||
/** Identity matrix to return a reference to in case of error */
|
||||
aiMatrix4x4 mIdentityMatrix;
|
||||
};
|
||||
|
||||
} // end of namespace AssimpView
|
||||
|
|
|
@ -138,7 +138,7 @@ void HandleMouseInputTextureView( void );
|
|||
//
|
||||
//-------------------------------------------------------------------------------
|
||||
INT_PTR CALLBACK ProgressMessageProc(HWND hwndDlg,UINT uMsg,
|
||||
WPARAM wParam,LPARAM lParam);
|
||||
WPARAM wParam,LPARAM lParam);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// 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
|
||||
//-------------------------------------------------------------------------------
|
||||
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,
|
||||
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,
|
||||
WPARAM wParam,LPARAM lParam);
|
||||
WPARAM wParam,LPARAM lParam);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
@ -181,9 +181,9 @@ void HandleCommandLine(char* p_szCommand);
|
|||
template <class type, class intype>
|
||||
type clamp(intype in)
|
||||
{
|
||||
// for unsigned types only ...
|
||||
intype mask = (0x1u << (sizeof(type)*8))-1;
|
||||
return (type)max((intype)0,min(in,mask));
|
||||
// for unsigned types only ...
|
||||
intype mask = (0x1u << (sizeof(type)*8))-1;
|
||||
return (type)max((intype)0,min(in,mask));
|
||||
}
|
||||
|
||||
|
||||
|
@ -192,95 +192,95 @@ type clamp(intype in)
|
|||
//-------------------------------------------------------------------------------
|
||||
enum EClickPos
|
||||
{
|
||||
// The click was inside the inner circle (x,y axis)
|
||||
EClickPos_Circle,
|
||||
// The click was inside one of tghe vertical snap-ins
|
||||
EClickPos_CircleVert,
|
||||
// The click was inside onf of the horizontal snap-ins
|
||||
EClickPos_CircleHor,
|
||||
// the cklick was outside the circle (z-axis)
|
||||
EClickPos_Outside
|
||||
// The click was inside the inner circle (x,y axis)
|
||||
EClickPos_Circle,
|
||||
// The click was inside one of tghe vertical snap-ins
|
||||
EClickPos_CircleVert,
|
||||
// The click was inside onf of the horizontal snap-ins
|
||||
EClickPos_CircleHor,
|
||||
// the cklick was outside the circle (z-axis)
|
||||
EClickPos_Outside
|
||||
};
|
||||
|
||||
#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
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Evil globals
|
||||
//-------------------------------------------------------------------------------
|
||||
extern HINSTANCE g_hInstance /*= NULL*/;
|
||||
extern HWND g_hDlg /*= NULL*/;
|
||||
extern IDirect3D9* g_piD3D /*= NULL*/;
|
||||
extern IDirect3DDevice9* g_piDevice /*= NULL*/;
|
||||
extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/;
|
||||
extern double g_fFPS /*= 0.0f*/;
|
||||
extern char g_szFileName[MAX_PATH];
|
||||
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPatternEffect /*= NULL*/;
|
||||
extern bool g_bMousePressed /*= false*/;
|
||||
extern bool g_bMousePressedR /*= false*/;
|
||||
extern bool g_bMousePressedM /*= false*/;
|
||||
extern bool g_bMousePressedBoth /*= false*/;
|
||||
extern float g_fElpasedTime /*= 0.0f*/;
|
||||
extern D3DCAPS9 g_sCaps;
|
||||
extern bool g_bLoadingFinished /*= false*/;
|
||||
extern HANDLE g_hThreadHandle /*= NULL*/;
|
||||
extern float g_fWheelPos /*= -10.0f*/;
|
||||
extern bool g_bLoadingCanceled /*= false*/;
|
||||
extern IDirect3DTexture9* g_pcTexture /*= NULL*/;
|
||||
extern HINSTANCE g_hInstance /*= NULL*/;
|
||||
extern HWND g_hDlg /*= NULL*/;
|
||||
extern IDirect3D9* g_piD3D /*= NULL*/;
|
||||
extern IDirect3DDevice9* g_piDevice /*= NULL*/;
|
||||
extern IDirect3DVertexDeclaration9* gDefaultVertexDecl /*= NULL*/;
|
||||
extern double g_fFPS /*= 0.0f*/;
|
||||
extern char g_szFileName[MAX_PATH];
|
||||
extern ID3DXEffect* g_piDefaultEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piNormalsEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPassThroughEffect /*= NULL*/;
|
||||
extern ID3DXEffect* g_piPatternEffect /*= NULL*/;
|
||||
extern bool g_bMousePressed /*= false*/;
|
||||
extern bool g_bMousePressedR /*= false*/;
|
||||
extern bool g_bMousePressedM /*= false*/;
|
||||
extern bool g_bMousePressedBoth /*= false*/;
|
||||
extern float g_fElpasedTime /*= 0.0f*/;
|
||||
extern D3DCAPS9 g_sCaps;
|
||||
extern bool g_bLoadingFinished /*= false*/;
|
||||
extern HANDLE g_hThreadHandle /*= NULL*/;
|
||||
extern float g_fWheelPos /*= -10.0f*/;
|
||||
extern bool g_bLoadingCanceled /*= false*/;
|
||||
extern IDirect3DTexture9* g_pcTexture /*= NULL*/;
|
||||
|
||||
extern aiMatrix4x4 g_mWorld;
|
||||
extern aiMatrix4x4 g_mWorldRotate;
|
||||
extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/;
|
||||
extern aiMatrix4x4 g_mWorld;
|
||||
extern aiMatrix4x4 g_mWorldRotate;
|
||||
extern aiVector3D g_vRotateSpeed /*= aiVector3D(0.5f,0.5f,0.5f)*/;
|
||||
|
||||
extern aiVector3D g_avLightDirs[1] /* =
|
||||
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
||||
aiVector3D(-0.5f,0.5f,0.5f)} */;
|
||||
extern aiVector3D g_avLightDirs[1] /* =
|
||||
{ aiVector3D(-0.5f,0.6f,0.2f) ,
|
||||
aiVector3D(-0.5f,0.5f,0.5f)} */;
|
||||
|
||||
|
||||
extern POINT g_mousePos /*= {0,0};*/;
|
||||
extern POINT g_LastmousePos /*= {0,0}*/;
|
||||
extern bool g_bFPSView /*= false*/;
|
||||
extern bool g_bInvert /*= false*/;
|
||||
extern EClickPos g_eClick;
|
||||
extern unsigned int g_iCurrentColor /*= 0*/;
|
||||
extern POINT g_mousePos /*= {0,0};*/;
|
||||
extern POINT g_LastmousePos /*= {0,0}*/;
|
||||
extern bool g_bFPSView /*= false*/;
|
||||
extern bool g_bInvert /*= false*/;
|
||||
extern EClickPos g_eClick;
|
||||
extern unsigned int g_iCurrentColor /*= 0*/;
|
||||
|
||||
// NOTE: The light intensity is separated from the color, it can
|
||||
// directly be manipulated using the middle mouse button.
|
||||
// When the user chooses a color from the palette the intensity
|
||||
// is reset to 1.0
|
||||
// index[2] is the ambient color
|
||||
extern float g_fLightIntensity /*=0.0f*/;
|
||||
extern D3DCOLOR g_avLightColors[3];
|
||||
// NOTE: The light intensity is separated from the color, it can
|
||||
// directly be manipulated using the middle mouse button.
|
||||
// When the user chooses a color from the palette the intensity
|
||||
// is reset to 1.0
|
||||
// index[2] is the ambient color
|
||||
extern float g_fLightIntensity /*=0.0f*/;
|
||||
extern D3DCOLOR g_avLightColors[3];
|
||||
|
||||
extern RenderOptions g_sOptions;
|
||||
extern Camera g_sCamera;
|
||||
extern AssetHelper *g_pcAsset /*= NULL*/;
|
||||
extern RenderOptions g_sOptions;
|
||||
extern Camera g_sCamera;
|
||||
extern AssetHelper *g_pcAsset /*= NULL*/;
|
||||
|
||||
|
||||
//
|
||||
// Contains the mask image for the HUD
|
||||
// (used to determine the position of a click)
|
||||
//
|
||||
// The size of the image is identical to the size of the main
|
||||
// HUD texture
|
||||
//
|
||||
extern unsigned char* g_szImageMask /*= NULL*/;
|
||||
//
|
||||
// Contains the mask image for the HUD
|
||||
// (used to determine the position of a click)
|
||||
//
|
||||
// The size of the image is identical to the size of the main
|
||||
// HUD texture
|
||||
//
|
||||
extern unsigned char* g_szImageMask /*= NULL*/;
|
||||
|
||||
|
||||
extern float g_fACMR /*= 3.0f*/;
|
||||
extern IDirect3DQuery9* g_piQuery;
|
||||
extern float g_fACMR /*= 3.0f*/;
|
||||
extern IDirect3DQuery9* g_piQuery;
|
||||
|
||||
extern bool g_bPlay /*= false*/;
|
||||
extern bool g_bPlay /*= false*/;
|
||||
|
||||
extern double g_dCurrent;
|
||||
extern float g_smoothAngle /*= 80.f*/;
|
||||
extern double g_dCurrent;
|
||||
extern float g_smoothAngle /*= 80.f*/;
|
||||
|
||||
extern unsigned int ppsteps,ppstepsdefault;
|
||||
extern bool nopointslines;
|
||||
}
|
||||
extern unsigned int ppsteps,ppstepsdefault;
|
||||
extern bool nopointslines;
|
||||
}
|
||||
|
||||
#endif // !! AV_MAIN_H_INCLUDED
|
|
@ -7,23 +7,23 @@
|
|||
|
||||
// Ä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.
|
||||
#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.
|
||||
#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.
|
||||
#endif
|
||||
|
||||
#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.
|
||||
#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.
|
||||
#endif
|
||||
|
||||
#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.
|
||||
#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.
|
||||
#endif
|
||||
|
||||
#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.
|
||||
#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.
|
||||
#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:
|
||||
#include <windows.h>
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
|||
// D3D9 includes
|
||||
|
||||
#if (defined _DEBUG)
|
||||
# define D3D_DEBUG_INFO
|
||||
# define D3D_DEBUG_INFO
|
||||
#endif
|
||||
|
||||
#include <d3d9.h>
|
||||
|
@ -63,12 +63,12 @@
|
|||
#if defined _MSC_VER
|
||||
// Windows CommonControls 6.0 Manifest Extensions
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
|
|
Loading…
Reference in New Issue