home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 8090 / ModelEdit.7z / ModelInfoDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2006-03-08  |  5.8 KB  |  207 lines

  1. // ModelInfoDlg.cpp : implementation file
  2. //
  3.  
  4. #include "precompile.h"
  5. #include "modeledit.h"
  6. #include "modelinfodlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CModelInfoDlg dialog
  16.  
  17.  
  18. CModelInfoDlg::CModelInfoDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CModelInfoDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CModelInfoDlg)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26.  
  27. void CModelInfoDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CModelInfoDlg)
  31.         // NOTE: the ClassWizard will add DDX and DDV calls here
  32.     //}}AFX_DATA_MAP
  33. }
  34.  
  35.  
  36. BEGIN_MESSAGE_MAP(CModelInfoDlg, CDialog)
  37.     //{{AFX_MSG_MAP(CModelInfoDlg)
  38.     //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CModelInfoDlg message handlers
  43.  
  44.  
  45. void CModelInfoDlg::DrawToTextThing(char *pStr, ...)
  46. {
  47.     CWnd *pWnd = GetDlgItem(IDC_MODELINFOTEXT);
  48.     va_list marker;
  49.     char msg[256];
  50.     int nLen;
  51.  
  52.     if(pWnd)
  53.     {
  54.         va_start(marker, pStr);
  55.         vsprintf(msg, pStr, marker);
  56.         va_end(marker);
  57.  
  58.         strcat(msg, "\r\n");
  59.         nLen = pWnd->SendMessage(EM_GETLIMITTEXT, 0, 0);
  60.         pWnd->SendMessage(EM_SETSEL, nLen, nLen);
  61.         pWnd->SendMessage(EM_REPLACESEL, FALSE, (LPARAM)msg);
  62.     }
  63. }
  64.  
  65.  
  66. DWORD CModelInfoDlg::ShowPieceMem(DWORD iLOD)
  67. {
  68.     uint32 i, memPieces, memVerts, memTris;
  69.     PieceLOD *pLOD;
  70.  
  71.  
  72.     memPieces = m_pModel->NumPieces() * sizeof(ModelPiece);
  73.     
  74.     memTris = 0;
  75.     memVerts = 0;
  76.     for(i=0; i < m_pModel->NumPieces(); i++)
  77.     {
  78.         pLOD = m_pModel->GetPiece(i)->GetLOD((uint32)iLOD);
  79.         
  80.         memTris += pLOD->m_Tris.GetSize() * sizeof(ModelTri);
  81.         memVerts += pLOD->m_Verts.GetSize() * sizeof(ModelVert);
  82.     }
  83.     
  84.     DrawToTextThing("Pieces: %d", memPieces);
  85.     DrawToTextThing("Verts: %d", memVerts);
  86.     DrawToTextThing("Tris: %d", memTris);
  87.     
  88.     return memPieces+memVerts+memTris;
  89. }
  90.  
  91. void DrawToTextThingTabs( CModelInfoDlg *dlg, int depth )
  92. {
  93.     static char space_buffer[60];
  94.     CWnd *pWnd = dlg->GetDlgItem(IDC_MODELINFOTEXT);
  95.     if(!pWnd) return ;
  96.     for( int i = 0 , cnt=0; i < depth ; i++,cnt+=2 ){
  97.         space_buffer[cnt] = ' ';
  98.         space_buffer[cnt+1] = ' ';
  99.     }
  100.     space_buffer[cnt] = '\0';
  101.     int nLen = pWnd->SendMessage(EM_GETLIMITTEXT, 0, 0);
  102.     pWnd->SendMessage(EM_SETSEL, nLen, nLen);
  103.     pWnd->SendMessage(EM_REPLACESEL, FALSE, (LPARAM)space_buffer);
  104. }
  105.  
  106. void recur_print_nodes( CModelInfoDlg *dlg, ModelNode *root, int depth )
  107. {
  108.  
  109.     DrawToTextThingTabs(dlg,depth);
  110.     dlg->DrawToTextThing("%s", root->GetName());
  111.     for( uint32 i = 0 ;i < root->NumChildren() ; i++ )
  112.     {
  113.         recur_print_nodes(dlg,root->GetChild(i),depth+1);
  114.     }
  115. }
  116.  
  117. BOOL CModelInfoDlg::OnInitDialog() 
  118. {
  119.     DWORD i, total;
  120.     ModelPiece *pPiece;
  121.     DWORD totalMem, memWeights;
  122.  
  123.  
  124.     CDialog::OnInitDialog();
  125.  
  126.     DrawToTextThing("File Version : %d" , m_pModel->GetFileVersion() );
  127.     DrawToTextThing(" ");
  128.     DrawToTextThing("Number of animations: %d", m_pModel->m_Anims.GetSize());
  129.     DrawToTextThing("------------------------------");
  130.     total = 0;
  131.     for(i=0; i < m_pModel->m_Anims; i++)
  132.     {
  133.         DrawToTextThing("   %s", m_pModel->GetAnim(i)->GetName());
  134.         total += m_pModel->GetAnim(i)->m_KeyFrames.GetSize();
  135.     }
  136.     DrawToTextThing("------------------------------");
  137.     DrawToTextThing("Average keyframes per animation: %d", total / m_pModel->m_Anims.GetSize());
  138.  
  139.     DrawToTextThing("Number of triangles: %d", m_pModel->CalcNumTris());
  140.     DrawToTextThing("Number of vertices: %d", m_pModel->CalcNumVerts());
  141.     DrawToTextThing("Number of nodes: %d", m_pModel->m_Transforms.GetSize());
  142.     DrawToTextThing("Number of vertex weights: %d", m_pModel->CalcNumVertexWeights());
  143.     DrawToTextThing("Average weights per vertex: %.3f", (float)m_pModel->CalcNumVertexWeights() / m_pModel->CalcNumVerts());
  144.  
  145.     DrawToTextThing("");
  146.     DrawToTextThing("Nodes ----------------");
  147.     
  148.     DrawToTextThing("Number of Nodes : %d ", m_pModel->m_FlatNodeList.GetSize());
  149.     DrawToTextThing(" ");
  150.     if( m_pModel->m_FlatNodeList )
  151.     {
  152.         recur_print_nodes(this,m_pModel->m_FlatNodeList[0],0);
  153.     }
  154.  
  155.     
  156.     DrawToTextThing("");
  157.     DrawToTextThing("Pieces ----------------");
  158.     for(i=0; i < m_pModel->NumPieces(); i++)
  159.     {
  160.         pPiece = m_pModel->GetPiece(i);
  161.  
  162.         // T.F ModelPiece ;
  163.         for( uint32 per_lod = 0 ; per_lod < pPiece->NumLODs() ; per_lod++ )
  164.         {
  165.             DrawToTextThing("%s, %d textures, texture[0] %d", pPiece->GetName(), 
  166.                     pPiece->GetLOD(per_lod)->m_nNumTextures, pPiece->GetLOD(per_lod)->m_iTextures[0]);
  167.         }
  168.     }
  169.  
  170.  
  171.     DrawToTextThing("");
  172.     DrawToTextThing("Geometry Memory ----------------");
  173.  
  174.     totalMem = 0 ;
  175.     for( i = 0 ; i < m_pModel->NumPieces() ; i++ )
  176.     {
  177.         uint32 memPiece, memVerts, memTris;
  178.         memPiece= memVerts= memTris=0;
  179.  
  180.         DrawToTextThing("piece %s", m_pModel->GetPiece(i)->GetName() );
  181.         ModelPiece *pPiece = m_pModel->GetPiece(i);
  182.         memPiece += sizeof(ModelPiece);
  183.         for( uint32 j = 0 ; j < pPiece->NumLODs() ; j++ )
  184.         {
  185.             
  186.             DrawToTextThing("-------- LOD %d dist :%f -------",j, pPiece->m_LODDists[j]);        
  187.             DrawToTextThing(" n verts : %d  n tris %d ", pPiece->GetLOD(j)->m_Verts.GetSize(),pPiece->GetLOD(j)->m_Tris.GetSize());
  188.             memPiece     += sizeof(PieceLOD);
  189.             memVerts += pPiece->GetLOD(j)->m_Verts;
  190.             memTris  += pPiece->GetLOD(j)->m_Tris;
  191.         }
  192.         DrawToTextThing("Pieces: %d", memPiece);
  193.         DrawToTextThing("Verts: %d", memVerts);
  194.         DrawToTextThing("Tris: %d", memTris);
  195.         totalMem += memPiece + memVerts + memTris ;
  196.     }
  197.  
  198.     DrawToTextThing("");
  199.     memWeights = m_pModel->m_VertexWeights.GetSize() * sizeof(NewVertexWeight);
  200.     DrawToTextThing("Weights: %d", memWeights);
  201.     DrawToTextThing("TOTAL: %d", totalMem);
  202.     return TRUE;  // return TRUE unless you set the focus to a control
  203.                   // EXCEPTION: OCX Property Pages should return FALSE
  204. }
  205.  
  206.  
  207.