//========= Copyright © 2008, Fire64, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include <stdio.h>
#include <string.h>
#include "studio.h"
void Usage( void )
{
fprintf( stderr, "Usage: modelinfo gman.mdl\n" );
exit( -1 );
}
void PrintBoneGraphRecursive( studiohdr_t *phdr, int boneIndex, int level )
{
int j;
printf( "%d \"%s\" ", boneIndex, phdr->pBone( boneIndex )->pszName() );
printf( "\n" );
for( j = 0; j < phdr->numbones; j++ )
{
mstudiobone_t *pBone = phdr->pBone( j );
if( pBone->parent == boneIndex )
{
PrintBoneGraphRecursive( phdr, j, level+1 );
}
}
}
void PrintAnimGraphRecursive( studiohdr_t *phdr, int animindex, int level )
{
int j;
printf( "%d \"%s\" ", animindex, phdr->pAnimdesc( animindex )->pszName() );
printf( "\n" );
for( j = 0; j < phdr->numanim; j++ )
{
mstudioanimdesc_t *pAnimdesc = phdr->pAnimdesc( j );
if( pAnimdesc->sznameindex == animindex )
{
PrintAnimGraphRecursive( phdr, j, level+1 );
}
}
}
int main( int argc, char **argv )
{
if( argc != 2 )
{
Usage();
}
FILE *fp;
fp = fopen( argv[1], "rb" );
if( !fp )
{
fprintf( stderr, "Can't open: %s\n", argv[1] );
Usage();
}
fseek( fp, 0, SEEK_END );
int len = ftell( fp );
rewind( fp );
studiohdr_t *pStudioHdr = ( studiohdr_t * )malloc( len );
fread( pStudioHdr, 1, len, fp );
// printf( "ID %d\n", pStudioHdr->id );
printf( "Versiya %d\n", pStudioHdr->version );
printf( "Kontrolnay summa %d\n", pStudioHdr->checksum );
// printf( "Name %d\n", pStudioHdr->name[64] );
// printf( "Length %d\n", pStudioHdr->length );
printf( "Eyeposition %d\n", pStudioHdr->eyeposition );
printf( "Illumposition %d\n", pStudioHdr->illumposition );
printf( "Hull_min %d\n", pStudioHdr->hull_min );
printf( "Hull_max %d\n", pStudioHdr->hull_max );
printf( "View_bbmin %d\n", pStudioHdr->view_bbmin );
printf( "View_bbmax %d\n", pStudioHdr->view_bbmax );
printf( "Flags %d\n", pStudioHdr->flags );
printf( "Kolichestvo kostey %d\n", pStudioHdr->numbones );
// printf( "Boneindex %d\n", pStudioHdr->boneindex );
printf( "Kolichestvo bonecontrollerov %d\n", pStudioHdr->numbonecontrollers );
// printf( "Bonecontrollerindex %d\n", pStudioHdr->bonecontrollerindex );
printf( "Kolichectvo hitboxsets %d\n", pStudioHdr->numhitboxsets );
// printf( "Hitboxsetindex %d\n", pStudioHdr->hitboxsetindex );
printf( "Kolichestvo animachiy %d\n", pStudioHdr->numanim );
// printf( "Animdescindex %d\n", pStudioHdr->animdescindex );
printf( "Kolichestvo sequence %d\n", pStudioHdr->numseq );
// printf( "Seqindex %d\n", pStudioHdr->seqindex );
// printf( "Sequencesindexed %d\n", pStudioHdr->sequencesindexed );
printf( "Kolichestvo sequence grup %d\n", pStudioHdr->numseqgroups );
// printf( "Seqgroupindex %d\n", pStudioHdr->seqgroupindex );
printf( "Kolichestvo textur %d\n", pStudioHdr->numtextures );
// printf( "Textureindex %d\n", pStudioHdr->textureindex );
printf( "Kolichestvo ispolzuemyh papok s teksturami %d\n", pStudioHdr->numcdtextures );
// printf( "Cdtextureindex %d\n", pStudioHdr->cdtextureindex );
printf( "Kolichestvo skin reference %d\n", pStudioHdr->numskinref );
printf( "Kolichestvo skin families %d\n", pStudioHdr->numskinfamilies );
// printf( "Skinindex %d\n", pStudioHdr->skinindex );
printf( "Kolichestvo body parts %d\n", pStudioHdr->numbodyparts );
// printf( "Bodypartindex %d\n", pStudioHdr->bodypartindex );
printf( "Kolichestvo attachmentov %d\n", pStudioHdr->numattachments );
// printf( "Attachmentindex %d\n", pStudioHdr->attachmentindex );
printf( "Kolichestvo transitions %d\n", pStudioHdr->numtransitions );
// printf( "Transitionindex %d\n", pStudioHdr->transitionindex );
printf( "Kolichestvo flexdesc %d\n", pStudioHdr->numflexdesc );
// printf( "Flexdescindex %d\n", pStudioHdr->flexdescindex );
printf( "Kolichestvo flex controllerov %d\n", pStudioHdr->numflexcontrollers );
// printf( "Flexcontrollerindex %d\n", pStudioHdr->flexcontrollerindex );
printf( "Kolichestvo flex rules %d\n", pStudioHdr->numflexrules );
// printf( "Flexruleindex %d\n", pStudioHdr->flexruleindex );
printf( "Kolichestvo ikchains %d\n", pStudioHdr->numikchains );
// printf( "Ikchainindex %d\n", pStudioHdr->ikchainindex );
printf( "Kolichestvo mouths %d\n", pStudioHdr->nummouths );
// printf( "Mouthindex %d\n", pStudioHdr->mouthindex );
printf( "Kolichestvo poseparameters %d\n", pStudioHdr->numposeparameters );
// printf( "Poseparamindex %d\n", pStudioHdr->poseparamindex );
// printf( "Surfacepropindex %d\n", pStudioHdr->surfacepropindex );
printf( "Kolichestvo transitions %d\n", pStudioHdr->numtransitions );
// printf( "Keyvalueindex %d\n", pStudioHdr->keyvalueindex );
// printf( "Keyvaluesize %d\n", pStudioHdr->keyvaluesize );
printf( "Kolichestvo ikautoplaylocks %d\n", pStudioHdr->numikautoplaylocks );
// printf( "Ikautoplaylockindex %d\n", pStudioHdr->ikautoplaylockindex );
// printf( "Contents %d\n", pStudioHdr->contents );
int i;
for( i = 0; i < pStudioHdr->numbones; i++ )
{
mstudiobone_t *pBone = pStudioHdr->pBone( i );
if( pBone->parent == -1 )
{
printf( "Imena kostey\n" );
PrintBoneGraphRecursive( pStudioHdr, i, 0 );
}
}
for( i = 0; i < pStudioHdr->numanim; i++ )
{
mstudioanimdesc_t *pAnimdesc = pStudioHdr->pAnimdesc( i );
PrintAnimGraphRecursive( pStudioHdr, i, 0 );
}
fclose( fp );
return 0;
}
консольное приложение => GUI
никто не даст какой-нибудь example исходник, с окном и оконной консолью в которую бы выводились сообщения через функцию printf ?
вот исходник моей программы
Код: