mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-10 14:14:33 +00:00
update assimp lib
This commit is contained in:
parent
03a348deb7
commit
d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -106,6 +106,11 @@ int CDisplay::EnableAnimTools(BOOL hm) {
|
|||
EnableWindow(GetDlgItem(g_hDlg,IDC_PLAY),hm);
|
||||
EnableWindow(GetDlgItem(g_hDlg,IDC_SLIDERANIM),hm);
|
||||
|
||||
if (hm == FALSE) {
|
||||
g_dCurrent = 0.0;
|
||||
SendDlgItemMessage(g_hDlg, IDC_SLIDERANIM, TBM_SETPOS, TRUE, LPARAM(0));
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -115,9 +120,16 @@ int CDisplay::FillAnimList(void) {
|
|||
if (0 != g_pcAsset->pcScene->mNumAnimations)
|
||||
{
|
||||
// now fill in all animation names
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumAnimations;++i) {
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumAnimations; ++i)
|
||||
{
|
||||
std::string animationLabel(g_pcAsset->pcScene->mAnimations[i]->mName.data);
|
||||
if (animationLabel.empty())
|
||||
{
|
||||
animationLabel = std::string("Animation ") + std::to_string(i) + " (UNNAMED)";
|
||||
}
|
||||
|
||||
SendDlgItemMessage(g_hDlg,IDC_COMBO1,CB_ADDSTRING,0,
|
||||
( LPARAM ) g_pcAsset->pcScene->mAnimations[i]->mName.data);
|
||||
(LPARAM)animationLabel.c_str());
|
||||
}
|
||||
|
||||
// also add a dummy - 'none'
|
||||
|
|
@ -139,6 +151,7 @@ int CDisplay::ClearAnimList(void)
|
|||
{
|
||||
// clear the combo box
|
||||
SendDlgItemMessage(g_hDlg,IDC_COMBO1,CB_RESETCONTENT,0,0);
|
||||
EnableAnimTools(FALSE);
|
||||
return 1;
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
|
|
@ -161,7 +174,7 @@ int CDisplay::AddNodeToDisplayList(
|
|||
ai_assert(nullptr != pcNode);
|
||||
ai_assert(nullptr != hRoot);
|
||||
|
||||
char chTemp[MAXLEN];
|
||||
char chTemp[AI_MAXLEN];
|
||||
|
||||
if(0 == pcNode->mName.length) {
|
||||
if (iIndex >= 100) {
|
||||
|
|
@ -173,12 +186,12 @@ int CDisplay::AddNodeToDisplayList(
|
|||
}
|
||||
else
|
||||
iIndex += iDepth * 10;
|
||||
ai_snprintf(chTemp, MAXLEN,"Node %u",iIndex);
|
||||
ai_snprintf(chTemp,AI_MAXLEN,"Node %u",iIndex);
|
||||
}
|
||||
else {
|
||||
ai_snprintf(chTemp, MAXLEN,"%s",pcNode->mName.data);
|
||||
ai_snprintf(chTemp, AI_MAXLEN, "%s", pcNode->mName.data);
|
||||
}
|
||||
ai_snprintf(chTemp+strlen(chTemp), MAXLEN- strlen(chTemp), iIndex ? " (%i)" : " (%i meshes)",pcNode->mNumMeshes);
|
||||
ai_snprintf(chTemp + strlen(chTemp), AI_MAXLEN - strlen(chTemp), iIndex ? " (%i)" : " (%i meshes)", pcNode->mNumMeshes);
|
||||
|
||||
TVITEMEXW tvi;
|
||||
TVINSERTSTRUCTW sNew;
|
||||
|
|
@ -223,15 +236,15 @@ int CDisplay::AddMeshToDisplayList(unsigned int iIndex, HTREEITEM hRoot)
|
|||
{
|
||||
aiMesh* pcMesh = g_pcAsset->pcScene->mMeshes[iIndex];
|
||||
|
||||
char chTemp[MAXLEN];
|
||||
char chTemp[AI_MAXLEN];
|
||||
|
||||
if(0 == pcMesh->mName.length) {
|
||||
ai_snprintf(chTemp,MAXLEN,"Mesh %u",iIndex);
|
||||
ai_snprintf(chTemp, AI_MAXLEN, "Mesh %u", iIndex);
|
||||
}
|
||||
else {
|
||||
ai_snprintf(chTemp,MAXLEN,"%s",pcMesh->mName.data);
|
||||
ai_snprintf(chTemp, AI_MAXLEN, "%s", pcMesh->mName.data);
|
||||
}
|
||||
ai_snprintf(chTemp+strlen(chTemp),MAXLEN-strlen(chTemp), iIndex ? " (%i)" : " (%i faces)",pcMesh->mNumFaces);
|
||||
ai_snprintf(chTemp + strlen(chTemp), AI_MAXLEN - strlen(chTemp), iIndex ? " (%i)" : " (%i faces)", pcMesh->mNumFaces);
|
||||
|
||||
TVITEMEXW tvi;
|
||||
TVINSERTSTRUCTW sNew;
|
||||
|
|
@ -267,8 +280,7 @@ int CDisplay::AddMeshToDisplayList(unsigned int iIndex, HTREEITEM hRoot)
|
|||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Replace the currently selected texture by another one
|
||||
int CDisplay::ReplaceCurrentTexture(const char* szPath)
|
||||
{
|
||||
int CDisplay::ReplaceCurrentTexture(const char* szPath) {
|
||||
ai_assert(nullptr != szPath);
|
||||
|
||||
// well ... try to load it
|
||||
|
|
@ -518,20 +530,19 @@ int CDisplay::AddTextureToDisplayList(unsigned int iType,
|
|||
return 1;
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
||||
unsigned int iIndex)
|
||||
{
|
||||
int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot, unsigned int iIndex) {
|
||||
ai_assert(nullptr != hRoot);
|
||||
|
||||
aiMaterial* pcMat = g_pcAsset->pcScene->mMaterials[iIndex];
|
||||
|
||||
if (g_pcAsset->pcScene->mNumMeshes == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// find the first mesh using this material index
|
||||
unsigned int iMesh = 0;
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
{
|
||||
if (iIndex == g_pcAsset->pcScene->mMeshes[i]->mMaterialIndex)
|
||||
{
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) {
|
||||
if (iIndex == g_pcAsset->pcScene->mMeshes[i]->mMaterialIndex) {
|
||||
iMesh = i;
|
||||
break;
|
||||
}
|
||||
|
|
@ -540,12 +551,9 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
|||
// use the name of the material, if possible
|
||||
char chTemp[512];
|
||||
aiString szOut;
|
||||
if (AI_SUCCESS != aiGetMaterialString(pcMat,AI_MATKEY_NAME,&szOut))
|
||||
{
|
||||
if (AI_SUCCESS != aiGetMaterialString(pcMat,AI_MATKEY_NAME,&szOut)) {
|
||||
ai_snprintf(chTemp,512,"Material %i",iIndex+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ai_snprintf(chTemp,512,"%s (%i)",szOut.data,iIndex+1);
|
||||
}
|
||||
TVITEMEXW tvi;
|
||||
|
|
@ -577,17 +585,15 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
|||
aiTextureOp eOp;
|
||||
aiString szPath;
|
||||
bool bNoOpacity = true;
|
||||
for (unsigned int i = 0; i <= AI_TEXTURE_TYPE_MAX;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i <= AI_TEXTURE_TYPE_MAX;++i) {
|
||||
unsigned int iNum = 0;
|
||||
while (true)
|
||||
{
|
||||
if (AI_SUCCESS != aiGetMaterialTexture(pcMat,(aiTextureType)i,iNum,
|
||||
&szPath,nullptr, &iUV,&fBlend,&eOp))
|
||||
{
|
||||
while (true) {
|
||||
if (AI_SUCCESS != aiGetMaterialTexture(pcMat,(aiTextureType)i,iNum, &szPath,nullptr, &iUV,&fBlend,&eOp)) {
|
||||
break;
|
||||
}
|
||||
if (aiTextureType_OPACITY == i)bNoOpacity = false;
|
||||
if (aiTextureType_OPACITY == i) {
|
||||
bNoOpacity = false;
|
||||
}
|
||||
AddTextureToDisplayList(i,iNum,&szPath,hTexture,iUV,fBlend,eOp,iMesh);
|
||||
++iNum;
|
||||
}
|
||||
|
|
@ -595,8 +601,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
|||
|
||||
AssetHelper::MeshHelper* pcMesh = g_pcAsset->apcMeshes[iMesh];
|
||||
|
||||
if (pcMesh->piDiffuseTexture && pcMesh->piDiffuseTexture == pcMesh->piOpacityTexture && bNoOpacity)
|
||||
{
|
||||
if (pcMesh->piDiffuseTexture && pcMesh->piDiffuseTexture == pcMesh->piOpacityTexture && bNoOpacity) {
|
||||
// check whether the diffuse texture is not a default texture
|
||||
|
||||
// {9785DA94-1D96-426b-B3CB-BADC36347F5E}
|
||||
|
|
@ -606,9 +611,7 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
|||
|
||||
uint32_t iData = 0;
|
||||
DWORD dwSize = 4;
|
||||
if(FAILED( pcMesh->piDiffuseTexture->GetPrivateData(guidPrivateData,&iData,&dwSize) ||
|
||||
0xffffffff == iData))
|
||||
{
|
||||
if(FAILED( pcMesh->piDiffuseTexture->GetPrivateData(guidPrivateData,&iData,&dwSize) || 0xffffffff == iData)) {
|
||||
// seems the diffuse texture contains alpha, therefore it has been
|
||||
// added to the opacity channel, too. Add a special value ...
|
||||
AddTextureToDisplayList(aiTextureType_OPACITY | 0x40000000,
|
||||
|
|
@ -625,33 +628,26 @@ int CDisplay::AddMaterialToDisplayList(HTREEITEM hRoot,
|
|||
this->AddMaterial(info);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Expand all elements in the tree-view
|
||||
int CDisplay::ExpandTree()
|
||||
{
|
||||
int CDisplay::ExpandTree() {
|
||||
// expand all materials
|
||||
for (std::vector< MaterialInfo >::iterator
|
||||
i = m_asMaterials.begin();
|
||||
i != m_asMaterials.end();++i)
|
||||
{
|
||||
for (std::vector< MaterialInfo >::iterator i = m_asMaterials.begin(); i != m_asMaterials.end();++i) {
|
||||
TreeView_Expand(GetDlgItem(g_hDlg,IDC_TREE1),(*i).hTreeItem,TVE_EXPAND);
|
||||
}
|
||||
// expand all nodes
|
||||
for (std::vector< NodeInfo >::iterator
|
||||
i = m_asNodes.begin();
|
||||
i != m_asNodes.end();++i)
|
||||
{
|
||||
for (std::vector< NodeInfo >::iterator i = m_asNodes.begin(); i != m_asNodes.end();++i) {
|
||||
TreeView_Expand(GetDlgItem(g_hDlg,IDC_TREE1),(*i).hTreeItem,TVE_EXPAND);
|
||||
}
|
||||
TreeView_Expand(GetDlgItem(g_hDlg,IDC_TREE1),m_hRoot,TVE_EXPAND);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Get image list for tree view
|
||||
int CDisplay::LoadImageList(void)
|
||||
{
|
||||
if (!m_hImageList)
|
||||
{
|
||||
int CDisplay::LoadImageList() {
|
||||
if (!m_hImageList) {
|
||||
// First, create the image list we will need.
|
||||
// FIX: Need RGB888 color space to display all colors correctly
|
||||
HIMAGELIST hIml = ImageList_Create( 16,16,ILC_COLOR24, 5, 0 );
|
||||
|
|
@ -682,12 +678,13 @@ int CDisplay::LoadImageList(void)
|
|||
|
||||
m_hImageList = hIml;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Fill tree view
|
||||
int CDisplay::FillDisplayList(void)
|
||||
{
|
||||
int CDisplay::FillDisplayList(void) {
|
||||
LoadImageList();
|
||||
|
||||
// Initialize the tree view window.
|
||||
|
|
@ -713,11 +710,11 @@ int CDisplay::FillDisplayList(void)
|
|||
(LPARAM)(LPTVINSERTSTRUCT)&sNew);
|
||||
|
||||
// add each loaded material to the tree
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMaterials;++i)
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMaterials; ++i)
|
||||
AddMaterialToDisplayList(m_hRoot,i);
|
||||
|
||||
// add each mesh to the tree
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i)
|
||||
for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes; ++i)
|
||||
AddMeshToDisplayList(i,m_hRoot);
|
||||
|
||||
// now add all loaded nodes recursively
|
||||
|
|
@ -729,8 +726,10 @@ int CDisplay::FillDisplayList(void)
|
|||
// everything reacts a little bit slowly if D3D is rendering,
|
||||
// so give GDI a small hint to leave the couch and work ;-)
|
||||
UpdateWindow(g_hDlg);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Main render loop
|
||||
int CDisplay::OnRender()
|
||||
|
|
@ -738,23 +737,25 @@ int CDisplay::OnRender()
|
|||
// update possible animation
|
||||
if( g_pcAsset)
|
||||
{
|
||||
static double lastPlaying = 0.;
|
||||
static double lastRenderTime = 0.;
|
||||
|
||||
ai_assert( g_pcAsset->mAnimator);
|
||||
double currentTime = clock() / double(CLOCKS_PER_SEC);
|
||||
if (g_bPlay) {
|
||||
g_dCurrent += clock()/ double( CLOCKS_PER_SEC) -lastPlaying;
|
||||
g_dCurrent += currentTime - lastRenderTime;
|
||||
|
||||
double time = g_dCurrent;
|
||||
aiAnimation* mAnim = g_pcAsset->mAnimator->CurrentAnim();
|
||||
if( mAnim && mAnim->mDuration > 0.0) {
|
||||
double tps = mAnim->mTicksPerSecond ? mAnim->mTicksPerSecond : 25.f;
|
||||
time = fmod( time, mAnim->mDuration/tps);
|
||||
SendDlgItemMessage(g_hDlg,IDC_SLIDERANIM,TBM_SETPOS,TRUE,LPARAM(10000 * (time/(mAnim->mDuration/tps))));
|
||||
if (mAnim && mAnim->mDuration > 0.0) {
|
||||
double tps = mAnim->mTicksPerSecond ? mAnim->mTicksPerSecond : ANIM_DEFAULT_TICKS_PER_SECOND;
|
||||
time = fmod(time, mAnim->mDuration/tps);
|
||||
SendDlgItemMessage(g_hDlg, IDC_SLIDERANIM, TBM_SETPOS, TRUE, LPARAM(ANIM_SLIDER_MAX * (time / (mAnim->mDuration / tps))));
|
||||
}
|
||||
|
||||
g_pcAsset->mAnimator->Calculate( time );
|
||||
lastPlaying = g_dCurrent;
|
||||
}
|
||||
|
||||
lastRenderTime = currentTime;
|
||||
}
|
||||
// begin the frame
|
||||
g_piDevice->BeginScene();
|
||||
|
|
@ -806,8 +807,10 @@ int CDisplay::FillDefaultStatistics(void)
|
|||
SetDlgItemText(g_hDlg,IDC_EVERT,"0");
|
||||
SetDlgItemText(g_hDlg,IDC_EFACE,"0");
|
||||
SetDlgItemText(g_hDlg,IDC_EMAT,"0");
|
||||
SetDlgItemText(g_hDlg,IDC_ENODE,"0");
|
||||
SetDlgItemText(g_hDlg,IDC_EMESH,"0");
|
||||
SetDlgItemText(g_hDlg,IDC_ENODEWND,"0");
|
||||
SetDlgItemText(g_hDlg,IDC_ESHADER,"0");
|
||||
SetDlgItemText(g_hDlg,IDC_ELOAD,"");
|
||||
SetDlgItemText(g_hDlg,IDC_ETEX,"0");
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -890,7 +893,7 @@ int CDisplay::OnSetupNormalView()
|
|||
SetWindowText(GetDlgItem(g_hDlg,IDC_NUMSHADERS),"Shaders:");
|
||||
SetWindowText(GetDlgItem(g_hDlg,IDC_NUMMATS),"Materials:");
|
||||
SetWindowText(GetDlgItem(g_hDlg,IDC_NUMMESHES),"Meshes:");
|
||||
SetWindowText(GetDlgItem(g_hDlg,IDC_LOADTIME),"Time:");
|
||||
SetWindowText(GetDlgItem(g_hDlg,IDC_LOADTIME),"Loading Time:");
|
||||
|
||||
FillDefaultStatistics();
|
||||
SetViewMode(VIEWMODE_FULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue