Ejemplo n.º 1
0
main (int argc, char *argv[])
{
	int i;
	CommandLine()->CreateCmdLine( argc, argv );
	SpewOutputFunc( HLFacePoserSpewFunc );
	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
	CoInitialize(NULL);

	// make sure, we start in the right directory
	char szName[256];
	strcpy (szName, mx::getApplicationPath() );

	mx::init (argc, argv);

	sound->Init();

	FileSystem_Init( true );
	filesystem = (IFileSystem *)(FileSystem_GetFactory()( FILESYSTEM_INTERFACE_VERSION, NULL ));
	if ( !filesystem )
	{
		AssertMsg( 0, "Failed to create/get IFileSystem" );
		return 1;
	}

	char workingdir[ 256 ];
	workingdir[0] = 0;
	Q_getwd( workingdir );

	// If they didn't specify -game on the command line, use VPROJECT.
	CmdLib_InitFileSystem( workingdir, true );

	IFacePoserToolWindow::EnableToolRedraw( false );

	new MDLViewer ();

	g_MDLViewer->setMenuBar (g_MDLViewer->getMenuBar ());
	
	g_pStudioModel->Init();

	bool modelloaded = false;
	for ( i = 1; i < CommandLine()->ParmCount(); i++ )
	{
		if ( Q_stristr (CommandLine()->GetParm( i ), ".mdl") )
		{
			modelloaded = true;
			g_MDLViewer->LoadModelFile( CommandLine()->GetParm( i ) );
			break;
		}
	}

	models->LoadModelList();

	if ( models->Count() == 0 )
	{
		g_pFlexPanel->initFlexes( );
	}

	// Load expressions from last time
	int files = workspacefiles->GetNumStoredFiles( IWorkspaceFiles::EXPRESSION );
	for ( i = 0; i < files; i++ )
	{
		expressions->LoadClass( workspacefiles->GetStoredFile( IWorkspaceFiles::EXPRESSION, i ) );
	}

	IFacePoserToolWindow::EnableToolRedraw( true );

	int retval = mx::run();

	soundemitter->BaseShutdown();

	if (g_pStudioModel)
	{
		g_pStudioModel->Shutdown();
		g_pStudioModel = NULL;
	}

	if (g_pMaterialSystem)
	{
		g_pMaterialSystem->Shutdown();
		g_pMaterialSystem = NULL;
	}

	FileSystem_Term();

	CoUninitialize();

	return retval;
}
Ejemplo n.º 2
0
CreateInterfaceFn CmdLib_GetFileSystemFactory()
{
	return FileSystem_GetFactory();
}
Ejemplo n.º 3
0
MatSysWindow::MatSysWindow (mxWindow *parent, int x, int y, int w, int h, const char *label, int style)
: IFacePoserToolWindow( "3D View", "3D View" ), mxMatSysWindow ( parent, x, y, w, h, label, style )
{
	SetAutoProcess( true );

	setLabel( MATSYSWIN_NAME );

	m_bSuppressSwap = false;

	m_hWnd = (HWND)getHandle();


	const char *pPath = basegamedir;

	Con_Printf( "Directory:  %s\n", basegamedir );
	
	Con_Printf( "Loading materialsystem.dll\n" );

	// Load the material system DLL and get its interface.
	m_hMaterialSystemInst = LoadLibrary( "MaterialSystem.dll" );
	if( !m_hMaterialSystemInst )
	{
		Error( "Can't load MaterialSystem.dll\n" );
	}

	Con_Printf( "Getting materialsystem factory\n" );

	g_MaterialSystemFactory = Sys_GetFactory( "MaterialSystem.dll" );
	if ( g_MaterialSystemFactory )
	{
		g_pMaterialSystem = (IMaterialSystem *)g_MaterialSystemFactory( MATERIAL_SYSTEM_INTERFACE_VERSION, NULL );
		if ( !g_pMaterialSystem )
		{
			Error( "Could not get the material system interface from materialsystem.dll" );
		}
	}
	else
	{
		Error( "Could not find factory interface in library MaterialSystem.dll" );
	}

	const char *pShaderDLL = CommandLine()->ParmValue("-shaderdll");
	if(!pShaderDLL)
	{
		pShaderDLL = "shaderapidx9.dll";
	}

	if ( CommandLine()->FindParm( "-noshaderapi" ) )
	{
		pShaderDLL = "shaderapiempty.dll";
	}

	Con_Printf( "Initializing materialsystem\n" );

	if(!( g_MaterialSystemClientFactory = g_pMaterialSystem->Init(pShaderDLL, &g_DummyMaterialProxyFactory, FileSystem_GetFactory() )) )
		Error("IMaterialSystem::Init failed");
	
	g_pMaterialSystemHardwareConfig = (IMaterialSystemHardwareConfig*)
		g_MaterialSystemClientFactory( MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, 0 );
	if ( !g_pMaterialSystemHardwareConfig )
		return;

	Con_Printf( "Setting material system video mode\n" );

	MaterialVideoMode_t mode;
	int modeFlags = MATERIAL_VIDEO_MODE_WINDOWED | MATERIAL_VIDEO_MODE_RESIZING;
	mode.m_Width = mode.m_Height = 0;
	if (!g_pMaterialSystem->SetMode( (void*)m_hWnd, mode, modeFlags ))
		return;

	g_pMaterialSystem->AddReleaseFunc( ReleaseMaterialSystemObjects );
	g_pMaterialSystem->AddRestoreFunc( RestoreMaterialSystemObjects );

	Con_Printf( "Calling UpdateConfig\n" );

	MaterialSystem_Config_t config;
	InitMaterialSystemConfig(&config);
	g_pMaterialSystem->UpdateConfig(&config, false);
	
	Con_Printf( "Loading debug materials\n" );

	ITexture *pCubemapTexture = g_pMaterialSystem->FindTexture( "hlmv/cubemap", NULL, true );
	pCubemapTexture->IncrementReferenceCount();
	g_pMaterialSystem->BindLocalCubemap( pCubemapTexture );

	g_materialBackground	= g_pMaterialSystem->FindMaterial("particle/particleapp_background", NULL, true);
	g_materialWireframe		= g_pMaterialSystem->FindMaterial("debug/debugmrmwireframe", NULL, true);
	g_materialFlatshaded	= g_pMaterialSystem->FindMaterial("debug/debugdrawflatpolygons", NULL, true);
	g_materialSmoothshaded	= g_pMaterialSystem->FindMaterial("debug/debugmrmfullbright2", NULL, true);
	g_materialBones			= g_pMaterialSystem->FindMaterial("debug/debugmrmwireframe", NULL, true);
	g_materialLines			= g_pMaterialSystem->FindMaterial("debug/debugwireframevertexcolor", NULL, true);
	g_materialFloor			= g_pMaterialSystem->FindMaterial("hlmv/floor", NULL, true);

	if (!parent)
		setVisible (true);
	else
		mx::setIdleWindow (this);

	m_bSuppressResize = false;
}
Ejemplo n.º 4
0
int main(int argc, char* argv[])
{
    SpewOutputFunc( SceneManagerSpewFunc );

    //
    // make sure, we start in the right directory
    //
    char szName[256];

    strcpy (szName, mx::getApplicationPath ());

    if (argc > 1)
    {
        strcpy (cmdline, argv[1]);
        for (int i = 2; i < argc; i++)
        {
            strcat (cmdline, " ");
            strcat (cmdline, argv[i]);
        }
    }

    mx::init (argc, argv);

    FileSystem_Init( true );
    filesystem = (IFileSystem *)(FileSystem_GetFactory()( FILESYSTEM_INTERFACE_VERSION, NULL ));
    if ( !filesystem )
    {
        AssertMsg( 0, "Failed to create/get IFileSystem" );
        return 1;
    }

    char workingdir[ 256 ];
    workingdir[0] = 0;
    Q_getwd( workingdir );

    char *vproject = getenv("VPROJECT");
    if ( !vproject )
    {
        mxMessageBox( NULL, "You must set VPROJECT to run scenemanager.exe", "SceneManager", MB_OK );
        return -1;
    }

    // If they didn't specify -game on the command line, use VPROJECT.
    CmdLib_InitFileSystem( workingdir, true );

    sound->Init();

    CWorkspaceManager *sm = new CWorkspaceManager();

    bool workspace_loaded = false;
    for ( int i = 1; i < argc; i++ )
    {
        if ( !workspace_loaded && strstr (argv[i], ".vsw") )
        {
            workspace_loaded = true;

            // Strip game directory and slash
            char workspace_name[ 512 ];
            filesystem->FullPathToRelativePath( argv[ i ], workspace_name );

            sm->AutoLoad( workspace_name );
        }
    }

    if ( !workspace_loaded )
    {
        sm->AutoLoad( NULL );
    }

    int retval = mx::run ();

    sound->Shutdown();

    soundemitter->BaseShutdown();

    FileSystem_Term();

    return retval;
}
//-----------------------------------------------------------------------------
// Purpose:
// Input  : argc -
//			argv[] -
// Output : int
//-----------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
    SpewOutputFunc( SpewFunc );
    SpewActivate( "vcd_sound_check", 2 );

    int i=1;
    for ( i ; i<argc ; i++)
    {
        if ( argv[ i ][ 0 ] == '-' )
        {
            switch( argv[ i ][ 1 ] )
            {
            case 'l':
                uselogfile = true;
                break;
            case 'v':
                verbose = true;
                break;
            case 'm':
                spewmoveto = true;
                break;
            case 'o':
                vcdonly = true;
                break;
            default:
                printusage();
                break;
            }
        }
    }

    if ( argc < 3 || ( i != argc ) )
    {
        PrintHeader();
        printusage();
    }

    CheckLogFile();

    PrintHeader();

    vprint( 0, "    Looking for .wav files not referenced in .vcd files...\n" );

    char sounddir[ 256 ];
    char vcddir[ 256 ];
    strcpy( sounddir, argv[ i - 2 ] );
    strcpy( vcddir, argv[ i - 1 ] );
    if ( !strstr( sounddir, "sound" ) )
    {
        vprint( 0, "Sound dir %s looks invalid (format:  u:/tf2/hl2/sound/vo)\n", sounddir );
        return 0;
    }
    if ( !strstr( vcddir, "scenes" ) )
    {
        vprint( 0, ".vcd dir %s looks invalid (format:  u:/tf2/hl2/scenes)\n", vcddir );
        return 0;
    }

    char workingdir[ 256 ];
    workingdir[0] = 0;
    Q_getwd( workingdir, sizeof( workingdir ) );

    // If they didn't specify -game on the command line, use VPROJECT.
    CmdLib_InitFileSystem( workingdir );

    CSysModule *pSoundEmitterModule = g_pFullFileSystem->LoadModule( "soundemittersystem.dll" );
    if ( !pSoundEmitterModule )
    {
        vprint( 0, "Sys_LoadModule( soundemittersystem.dll ) failed!\n" );
        return 0;
    }

    CreateInterfaceFn hSoundEmitterFactory = Sys_GetFactory( pSoundEmitterModule );
    if ( !hSoundEmitterFactory )
    {
        vprint( 0, "Sys_GetFactory on soundemittersystem.dll failed!\n" );
        return 0;
    }

    soundemitter = ( ISoundEmitterSystemBase * )hSoundEmitterFactory( SOUNDEMITTERSYSTEM_INTERFACE_VERSION, NULL );
    if ( !soundemitter )
    {
        vprint( 0, "Couldn't get interface %s from soundemittersystem.dll!\n", SOUNDEMITTERSYSTEM_INTERFACE_VERSION );
        return 0;
    }

    filesystem = (IFileSystem *)(CmdLib_GetFileSystemFactory()( FILESYSTEM_INTERFACE_VERSION, NULL ));
    if ( !filesystem )
    {
        AssertMsg( 0, "Failed to create/get IFileSystem" );
        return 1;
    }

    Q_FixSlashes( gamedir );
    Q_strlower( gamedir );

    vprint( 0, "game dir %s\nsounds dir %s\nvcd dir %s\n\n",
            gamedir,
            sounddir,
            vcddir );

    Q_StripTrailingSlash( sounddir );
    Q_StripTrailingSlash( vcddir );


    filesystem->RemoveFile( "moveto.txt", "GAME" );
    //
    //ProcessMaterialsDirectory( vmtdir );

    vprint( 0, "Initializing sound emitter system\n" );
    soundemitter->Connect( FileSystem_GetFactory() );
    soundemitter->Init();

    vprint( 0, "Loaded %i sounds\n", soundemitter->GetSoundCount() );

    vprint( 0, "Building list of .vcd files\n" );
    CUtlVector< CUtlSymbol > vcdfiles;
    BuildFileList( vcdfiles, vcddir, ".vcd" );
    vprint( 0, "found %i .vcd files\n\n", vcdfiles.Count() );

    vprint( 0, "Building list of known .wav files\n" );
    CUtlVector< CUtlSymbol > wavfiles;
    BuildFileList( wavfiles, sounddir, ".wav" );
    vprint( 0, "found %i .wav files\n\n", wavfiles.Count() );

    CorrelateWavsAndVCDs( vcdfiles, wavfiles );

    soundemitter->Shutdown();
    soundemitter = 0;
    g_pFullFileSystem->UnloadModule( pSoundEmitterModule );

    FileSystem_Term();

    return 0;
}