示例#1
0
int main(int argc, char* argv[])
{
	if (argc == 3)
	{
		g_pd3dDevice = CreateNULLRefDevice();
		SprConverter spr;

		/* ½«argv[2]ת»»³ÉÊý×Ö */
		//
		printf("%d", aoti(argv[2]));
//		spr.Converter(argv[1], argv[2]);
		spr.CreateNewSprFile(argv[1], atoi(argv[2]));
		getchar();
	}
	return 0;
}
示例#2
0
int main(int argc, char* argv[])
{
	/**/
//	printf("Usage:\n");
	if (argc == 3)
	{
		g_pd3dDevice = CreateNULLRefDevice();
		if(g_pd3dDevice == NULL) printf("g_pd3dDevice is NULL.\n");
		SprConverter spr;
//		spr.Converter(argv[1]);
//		printf("%d", atoi(argv[2]));
		spr.CreateNewSprFile(argv[1], atoi(argv[2]));
		getchar();
	}
	else
	{
		printf(" 请输入合理的参数!\n");
	}
	return 0;
}
示例#3
-1
//-----------------------------------------------------------------------------
// Name: main()
// Desc: Entry point for the application.  We use just the console window
//-----------------------------------------------------------------------------
int main(int argc, char* argv[])
{
    // Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif

    int nRet = 0;
    IDirect3DDevice9* pd3dDevice = NULL;
    SETTINGS settings;
    ZeroMemory( &settings, sizeof(SETTINGS) );

    if( argc < 2 )
    {
        DisplayUsage();
        goto LCleanup;
    }

    if( !ParseCommandLine( &settings ) )
    {
        nRet = 0;
        goto LCleanup;
    }

    if( settings.bVerbose )
    {
        wprintf( L"Input file: %s\n", settings.strInputFile );   
        wprintf( L"Output file: %s\n", settings.strOutputFile );   
        wprintf( L"Overwrite: %d\n", settings.bOverwrite );   
        switch( settings.outputType )
        {
            case MESH_TYPE_X_TEXT: wprintf( L"Output format: .x text\n" ); break;
            case MESH_TYPE_X_BINARY: wprintf( L"Output format: .x binary\n" ); break;
            case MESH_TYPE_SDKMESH: wprintf( L"Output format: sdkmesh\n" ); break;
        }
    }

    // Create NULLREF device 
    pd3dDevice = CreateNULLRefDevice(); 
    if( pd3dDevice == NULL )
    {
        wprintf( L"Error: Can not create NULLREF Direct3D device\n" );
        nRet = 1;
        goto LCleanup;
    }
    else
    {
        if( settings.bVerbose )
        {
            wprintf( L"NULLREF Direct3D 9 device created\n" );   
        }

        // Load the mesh
        CLoader loader;
        if( FAILED(loader.Load( settings.strInputFile, FTT_RELATIVE )) )
        {
            wprintf( L"Cannot Load specified input file\n" );
            goto LCleanup;
            nRet = 1;
        }

        // Convert to Little Endian
        loader.GetMesh()->ConvertToLittleEndian();

        // Create a decl that reflects our inputs
        D3DVERTEXELEMENT9 decl[MAX_VERTEX_ELEMENTS];
        BuildVertexDecl( decl, &settings );

        // Convert the mesh to this decl
        loader.GetMesh()->ConvertVertexData( pd3dDevice, decl, MAX_VERTEX_ELEMENTS );

        // fix up the mesh
        loader.GetMesh()->FixMesh();

        // if we need tangents or binormals, generate them
        if( settings.bGenTangents || settings.bGenBinormals )
        {
            if( !loader.GetMesh()->GenerateTangents( pd3dDevice ) )
                wprintf( L"Warning:  Cannot generate tangent frame information for mesh\n" );
        }

        // Save it out
        if( FAILED( loader.Save( pd3dDevice, settings.strOutputFile, settings.outputType ) ) )
        {
            wprintf( L"Cannot Save specified output file\n" );
            goto LCleanup;
            nRet = 1;
        }

        if( settings.bRetainAnimation )
        {
            WCHAR szOutput[MAX_PATH];
            StringCchCopy( szOutput, MAX_PATH, settings.strOutputFile );
            StringCchCat( szOutput, MAX_PATH, L"_anim" );
            if( FAILED( loader.SaveAnimationData( szOutput ) ) )
            {
                wprintf( L"Cannot Save animation data\n" );
            }
        }
    }

LCleanup:
    wprintf( L"\n" );

#ifdef DEBUG_PRESSKEY
    wprintf( L"Press ENTER to continue.");
    _getch();
#endif 

    // Cleanup
    SAFE_RELEASE( pd3dDevice );

    return nRet;
}