Esempio n. 1
0
int main(int argc, char** argv) {
	if (argc < 2 || argc > 3) {
		printf(
				"USAGE: URDFtoRob robot_file.urdf [optional filename for .rob]\n");
		return 0;
	}

	string filename;
	const char* fname;
	if(argc == 2)
		filename.assign(argv[1]);
	else if(argc == 3)
		filename.assign(argv[2]);
	StripExtension(filename);
	filename.append(".rob");
	const char* ext = FileExtension(argv[1]);
	string path = GetFilePath(argv[1]);
	if (0 == strcmp(ext, "urdf")) {
		Robot robot;

		robot.LoadURDF(argv[1]);
		robot.Save(filename.c_str(), path.c_str());
		robot.SaveGeometry(path.c_str(),"tri");
	} else {
		printf("Unknown file extension %s on file %s!\nOnly converts URDF to Rob", ext, argv[1]);
		return 1;
	}
	cout<<"Converted "<<argv[1]<<" to "<< filename<<endl;
	cout << "Done!" << endl;
}
Esempio n. 2
0
image_t *ImageFind( const char *filename )
{
	int			i;
	char		name[ 1024 ];
	
	
	/* init */
	ImageInit();
	
	/* dummy check */
	if( filename == NULL || filename[ 0 ] == '\0' )
		return NULL;
	
	/* strip file extension off name */
	strcpy( name, filename );
	StripExtension( name );
	
	/* search list */
	for( i = 0; i < MAX_IMAGES; i++ )
	{
		if( images[ i ].name != NULL && !strcmp( name, images[ i ].name ) )
			return &images[ i ];
	}
	
	/* no matching image found */
	return NULL;
}
Esempio n. 3
0
/*
 * @brief
 */
s_sample_t *S_LoadSample(const char *name) {
	char key[MAX_QPATH];
	s_sample_t *sample;

	if (!s_env.initialized)
		return NULL;

	if (!name || !name[0]) {
		Com_Error(ERR_DROP, "NULL name\n");
	}

	StripExtension(name, key);

	if (!(sample = (s_sample_t *) S_FindMedia(key))) {
		sample = (s_sample_t *) S_AllocMedia(key, sizeof(s_sample_t));

		sample->media.Free = S_FreeSample;

		S_LoadSampleChunk(sample);

		S_RegisterMedia((s_media_t *) sample);
	}

	return sample;
}
Esempio n. 4
0
void MakeLITFile (const char *filename)
{
	char	litname[1024];
	FILE	*litfile;
	litheader_t	litheader;

	strcpy (litname, filename);
	StripExtension (litname);
	DefaultExtension (litname, ".lit", sizeof(litname));
	litfile = fopen (litname, "wb");

	if (!litfile)
	{
		printf ("Unable to create %s\n", litname);
		return;
	}

	litheader.ident[0] = 'Q';
	litheader.ident[1] = 'L';
	litheader.ident[2] = 'I';
	litheader.ident[3] = 'T';
	litheader.version = LittleLong(LIT_VERSION);

	fwrite (&litheader, sizeof(litheader), 1, litfile);
	fwrite (&newdlightdata, newlightdatasize, 1, litfile);

	fclose (litfile);
	printf ("Wrote litfile: %s\n", litname);
}
Esempio n. 5
0
void be_root::Generate (be_ClientImplementation & source)
{
   ostream & os = source.Stream ();
   TList<be_CodeGenerator*>::iterator iit;
   TList<be_Type*>::iterator bit;

   for (iit = implementations.begin(); iit != implementations.end(); iit++)
   {
      (*iit)->Generate(source);
   }

   os << nl;

   be_CodeGenerator::Generate (source);

   os << nl;

   if (BE_Globals::lite)
   {
       DDS_StdString BaseFilename;
       BaseFilename = StripExtension(source.Filename());

       os << "#include \"" << BaseFilename << "-lite.c" << "\"" << nl;
   }
   os << nl;
   source.Close();
}
Esempio n. 6
0
int CBlockStream::Create( char *filename )
{
	char	newName[MAX_FILENAME_LENGTH], *id_header = IBI_HEADER_ID;
	float	version = IBI_VERSION;
	
	//Clear the temp string
	memset(newName, 0, sizeof(newName));

	//Strip the extension and add the BLOCK_EXT extension
	strcpy((char *) m_fileName, filename);
	StripExtension( (char *) m_fileName, (char *) &newName );
	strcat((char *) newName, IBI_EXT);

	//Recover that as the active filename
	strcpy(m_fileName, newName);

	if ( (m_fileHandle = fopen(m_fileName, "wb")) == NULL )
	{
		return false;
	}

	fwrite( id_header, IBI_HEADER_ID_LENGTH, 1, m_fileHandle );
	fwrite( &version, sizeof(version), 1, m_fileHandle );

	return true;
}
Esempio n. 7
0
void Pointfile_Delete( void ) {
	char	name[1024];
	strcpy( name, currentmap );
	StripExtension( name );
	strcat( name, ".lin" );
	remove( name );
}
Esempio n. 8
0
/*
 * @brief
 */
void WriteAASFile(void) {
	char path[MAX_QPATH];
	file_t *f;

	StripExtension(bsp_name, path);
	g_strlcat(path, ".aas", sizeof(path));

	if (!(f = Fs_OpenWrite(path))) {
		Com_Error(ERR_FATAL, "Couldn't open %s for writing\n", path);
	}

	Com_Print("Writing %d AAS nodes..\n", d_aas.num_nodes);

	SwapAASFile();

	d_bsp_header_t header;
	memset(&header, 0, sizeof(header));

	header.ident = LittleLong(AAS_IDENT);
	header.version = LittleLong(AAS_VERSION);

	Fs_Write(f, &header, 1, sizeof(header));

	d_bsp_lump_t *lump = &header.lumps[AAS_LUMP_NODES];
	WriteLump(f, lump, d_aas.nodes, sizeof(d_aas_node_t) * d_aas.num_nodes);

	// rewrite the header with the populated lumps

	Fs_Seek(f, 0);
	Fs_Write(f, &header, 1, sizeof(header));

	Fs_Close(f);
}
Esempio n. 9
0
/*
 * @brief Loads the music by the specified name.
 */
s_music_t *S_LoadMusic(const char *name) {
	char key[MAX_QPATH];
	s_music_t *music;

	StripExtension(name, key);

	if (!(music = (s_music_t *) S_FindMedia(key))) {

		void *buffer;
		SDL_RWops *rw;
		Mix_Music *mus;
		if (S_LoadMusicFile(key, &buffer, &rw, &mus)) {

			music = (s_music_t *) S_AllocMedia(key, sizeof(s_music_t));

			music->media.Retain = S_RetainMusic;
			music->media.Free = S_FreeMusic;

			music->buffer = buffer;
			music->rw = rw;
			music->music = mus;

			S_RegisterMedia((s_media_t *) music);
		} else {
			Com_Debug("S_LoadMusic: Couldn't load %s\n", key);
			music = NULL;
		}
	}

	if (music) {
		s_music_state.playlist = g_list_append(s_music_state.playlist, music);
	}

	return music;
}
Esempio n. 10
0
/**
 * @brief Handles the actual loading of .ogg music files.
 */
static _Bool S_LoadMusicFile(const char *name, void **buffer, SDL_RWops **rw, Mix_Music **music) {
	char path[MAX_QPATH];

	*music = NULL;

	StripExtension(name, path);
	g_snprintf(path, sizeof(path), "music/%s.ogg", name);

	int64_t len;
	if ((len = Fs_Load(path, buffer)) != -1) {

		if ((*rw = SDL_RWFromMem(*buffer, (int32_t) len))) {

			if ((*music = Mix_LoadMUS_RW(*rw, false))) {
				Com_Debug(DEBUG_SOUND, "Loaded %s\n", name);
			} else {
				Com_Warn("Failed to load %s: %s\n", name, Mix_GetError());
				SDL_FreeRW(*rw);
			}
		} else {
			Com_Warn("Failed to create SDL_RWops for %s\n", name);
			Fs_Free(*buffer);
		}
	} else {
		Com_Debug(DEBUG_SOUND, "Failed to load %s\n", name);
	}

	return *music != NULL;
}
Esempio n. 11
0
void ExportEntities( void ){
        char filename[ 1024 ];
        FILE *file;

        /* note it */
        Sys_FPrintf( SYS_VRB, "--- ExportEntities ---\n" );

        /* do some path mangling */
        strcpy( filename, source );
        StripExtension( filename );
        strcat( filename, ".ent" );

        /* sanity check */
        if ( bspEntData == NULL || bspEntDataSize == 0 ) {
                Sys_Warning( "No BSP entity data. aborting...\n" );
                return;
        }

        /* write it */
        Sys_Printf( "Writing %s\n", filename );
        Sys_FPrintf( SYS_VRB, "(%d bytes)\n", bspEntDataSize );
        file = fopen( filename, "w" );

        if ( file == NULL ) {
                Error( "Unable to open %s for writing", filename );
        }

        fprintf( file, "%s\n", bspEntData );
        fclose( file );
}
void RadCreateDiffuseLights( void ){
	/* startup */
	Sys_FPrintf( SYS_VRB, "--- RadCreateDiffuseLights ---\n" );
	numDiffuseSurfaces = 0;
	numDiffuseLights = 0;
	numBrushDiffuseLights = 0;
	numTriangleDiffuseLights = 0;
	numPatchDiffuseLights = 0;
	numAreaLights = 0;

	/* hit every surface (threaded) */
	RunThreadsOnIndividual( numBSPDrawSurfaces, qtrue, RadLight );

	/* dump the lights generated to a file */
	if ( dump ) {
		char dumpName[ 1024 ], ext[ 64 ];
		FILE    *file;
		light_t *light;

		strcpy( dumpName, source );
		StripExtension( dumpName );
		sprintf( ext, "_bounce_%03d.map", iterations );
		strcat( dumpName, ext );
		file = fopen( dumpName, "wb" );
		Sys_Printf( "Writing %s...\n", dumpName );
		if ( file ) {
			for ( light = lights; light; light = light->next )
			{
				fprintf( file,
						 "{\n"
						 "\"classname\" \"light\"\n"
						 "\"light\" \"%d\"\n"
						 "\"origin\" \"%.0f %.0f %.0f\"\n"
						 "\"_color\" \"%.3f %.3f %.3f\"\n"
						 "}\n",

						 (int) light->add,

						 light->origin[ 0 ],
						 light->origin[ 1 ],
						 light->origin[ 2 ],

						 light->color[ 0 ],
						 light->color[ 1 ],
						 light->color[ 2 ] );
			}
			fclose( file );
		}
	}

	/* increment */
	iterations++;

	/* print counts */
	Sys_Printf( "%8d diffuse surfaces\n", numDiffuseSurfaces );
	Sys_FPrintf( SYS_VRB, "%8d total diffuse lights\n", numDiffuseLights );
	Sys_FPrintf( SYS_VRB, "%8d brush diffuse lights\n", numBrushDiffuseLights );
	Sys_FPrintf( SYS_VRB, "%8d patch diffuse lights\n", numPatchDiffuseLights );
	Sys_FPrintf( SYS_VRB, "%8d triangle diffuse lights\n", numTriangleDiffuseLights );
}
Esempio n. 13
0
void MakeAllScales (void)
{
	strcpy(transferfile, source);
	StripExtension( transferfile );
	DefaultExtension( transferfile, ".r2" );

	if ( !incremental
	  || !IsIncremental(incrementfile)
	  || (unsigned)readtransfers(transferfile, num_patches) != num_patches )
	{
		// determine visibility between patches
		BuildVisMatrix ();

		RunThreadsOn (num_patches, true, MakeScales);
		if ( incremental )
			writetransfers(transferfile, num_patches);
		else
			unlink(transferfile);

		// release visibility matrix
		FreeVisMatrix ();
	}

	qprintf ("transfer lists: %5.1f megs\n"
		, (float)total_transfer * sizeof(transfer_t) / (1024*1024));
}
Esempio n. 14
0
/**
 * @brief
 */
static cm_material_t *Cm_LoadBspMaterials(const char *name) {

    char base[MAX_QPATH];
    StripExtension(Basename(name), base);

    return Cm_LoadMaterials(va("materials/%s.mat", base), NULL);
}
/**
Helper function to find and kill the specified process
*/
TInt CGsaFlexiMergeManyFilesTest::FindAndKill(const TDesC& aProcessName)
	{
	TFullName searchTerm(aProcessName);
	StripExtension(searchTerm);
	searchTerm += _L("*");
	TFindProcess find(searchTerm);
	TFullName name;
	TInt instancesFound = 0;
	while(find.Next(name) == KErrNone)
		{
		RProcess process;
		const TInt err = process.Open(find);

		if (KErrNone == err)
			{
			if (process.ExitType() == EExitPending)
				{
				instancesFound++;
				process.Kill(KErrCancel);
				process.Close();
				INFO_PRINTF2(_L("Process %S found and killed"), &aProcessName);
				}
			process.Close();
			}
		}
	return instancesFound;
	}
Esempio n. 16
0
// package creation tool main function ----------------------------------------
//
void MAKEPACK_main( int argc, char **argv )
{
	// clear options of main app
	OPT_ClearOptions();

	// register local options
	OPT_RegisterStringOption( "p", "pack", Tm_SetPackageName );
	OPT_RegisterStringOption( "f", "list", Tm_SetListName );

	// exec all registered command line options
	if ( !OPT_ExecRegisteredOptions( argc, argv ) ) {
		Err_Printf( options_invalid );
		Exit( EXIT_FAILURE );
	}

	// package name is mandatory
	if ( arg_package_name[ 0 ] == 0 ) {
		Err_Printf( pack_name_missing );
		Exit( EXIT_FAILURE );
	}

	// list name is optional (use package with different extension by default)
	if ( arg_list_name[ 0 ] == 0 ) {
		strcpy( arg_list_name, arg_package_name );
		StripExtension( arg_list_name );
		strcat( arg_list_name, ".lst" );
	}

	// create package
	CreatePackage( arg_package_name, arg_list_name );

	// end of sub-application
	Exit( EXIT_SUCCESS );
}
Esempio n. 17
0
/*
===============
Curve_WriteFile
===============
*/
void Curve_WriteFile (char *name) {
	char	curveName[1024];
	brush_t	*b;
	curveBlock_t	*cb;
	time_t	ltime;

	strcpy(curveName, name);
	StripExtension (curveName);
	strcat (curveName, ".bnd");
	curveFile = fopen(curveName, "w");
	if (!curveFile) {
		return;
	}

	time(&ltime);
	fprintf (curveFile, "// %s saved on %s\n", name, ctime(&ltime) );

	for (b=world_entity->brushes.onext ; b != &world_entity->brushes 
		; b=b->onext) {
		if (!b->curveBrush) {
			continue;		// only write curve brushes
		}

		cb = BrushToCurveBlock(b);
		SubdivideCurveBlock (cb);

	}
	fclose (curveFile);

	curveFile = NULL;
}
Esempio n. 18
0
void LoadTriangleList(const char *fileName, triangle_t **triList, int *triangleCount)
{
	FILE	*input;

	q_strlcpy(InputFileName, fileName, sizeof(InputFileName));

	StripExtension(InputFileName);
	q_strlcat(InputFileName, ".asc", sizeof(InputFileName));
	if ((input = fopen(InputFileName, "rb")) != NULL)
	{
		fclose(input);
		LoadASC(InputFileName, triList, triangleCount);
		return;
	}

	StripExtension(InputFileName);
	q_strlcat(InputFileName, ".hrc", sizeof(InputFileName));
	if ((input = fopen(InputFileName, "rb")) != NULL)
	{
		fclose(input);
		LoadHRC(InputFileName, triList, triangleCount);
		return;
	}

	StripExtension(InputFileName);
	q_strlcat(InputFileName, ".htr", sizeof(InputFileName));
	if ((input = fopen(InputFileName, "rb")) != NULL)
	{
		fclose(input);
		LoadHTR(InputFileName, triList, triangleCount);
		return;
	}

	StripExtension(InputFileName);
	q_strlcat(InputFileName, ".tri", sizeof(InputFileName));
	if ((input = fopen(InputFileName, "rb")) != NULL)
	{
		LoadTRI(input, triList, triangleCount);
		fclose(input);
		return;
	}

	COM_Error("Could not open file '%s':\n"
		"No ASC, HRC, HTR, or TRI match.\n", fileName);
}
Esempio n. 19
0
/*
 * @brief
 */
static void S_LoadSampleChunk(s_sample_t *sample) {
	char path[MAX_QPATH];
	void *buf;
	int32_t i, len;
	SDL_RWops *rw;

	if (sample->media.name[0] == '*') // place holder
		return;

	if (sample->media.name[0] == '#') { // global path
		g_strlcpy(path, (sample->media.name + 1), sizeof(path));
	} else { // or relative
		g_snprintf(path, sizeof(path), "sounds/%s", sample->media.name);
	}

	buf = NULL;
	rw = NULL;

	i = 0;
	while (SAMPLE_TYPES[i]) {

		StripExtension(path, path);
		g_strlcat(path, SAMPLE_TYPES[i++], sizeof(path));

		if ((len = Fs_Load(path, &buf)) == -1)
			continue;

		if (!(rw = SDL_RWFromMem(buf, len))) {
			Fs_Free(buf);
			continue;
		}

		if (!(sample->chunk = Mix_LoadWAV_RW(rw, false)))
			Com_Warn("%s\n", Mix_GetError());

		Fs_Free(buf);

		SDL_FreeRW(rw);

		if (sample->chunk) { // success
			break;
		}
	}

	if (sample->chunk) {
		Mix_VolumeChunk(sample->chunk, s_volume->value * MIX_MAX_VOLUME);
		Com_Debug("Loaded %s\n", path);
	} else {
		if (g_str_has_prefix(sample->media.name, "#players")) {
			Com_Debug("Failed to load player sample %s\n", sample->media.name);
		} else {
			Com_Warn("Failed to load %s\n", sample->media.name);
		}
	}
}
Esempio n. 20
0
int BSPInfo( int count, char **fileNames )
{
	int			i;
	char		source[ 1024 ], ext[ 64 ];
	int			size;
	FILE		*f;
	
	
	/* dummy check */
	if( count < 1 )
	{
		Sys_Printf( "No files to dump info for.\n");
		return -1;
	}
	
	/* enable info mode */
	infoMode = qtrue;
	
	/* walk file list */
	for( i = 0; i < count; i++ )
	{
		Sys_Printf( "---------------------------------\n" );
		
		/* mangle filename and get size */
		strcpy( source, fileNames[ i ] );
		ExtractFileExtension( source, ext );
		if( !Q_stricmp( ext, "map" ) )
			StripExtension( source );
		DefaultExtension( source, ".bsp" );
		f = fopen( source, "rb" );
		if( f )
		{
			size = Q_filelength (f);
			fclose( f );
		}
		else
			size = 0;
		
		/* load the bsp file and print lump sizes */
		Sys_Printf( "%s\n", source );
		LoadBSPFile( source );		
		PrintBSPFileSizes();
		
		/* print sizes */
		Sys_Printf( "\n" );
		Sys_Printf( "          total         %9d\n", size );
		Sys_Printf( "                        %9d KB\n", size / 1024 );
		Sys_Printf( "                        %9d MB\n", size / (1024 * 1024) );
		
		Sys_Printf( "---------------------------------\n" );
	}
	
	/* return count */
	return i;
}
Esempio n. 21
0
/*
 * BSP_Main
 */
int BSP_Main(void){
	time_t start, end;
	char base[MAX_OSPATH];
	int total_bsp_time;

	#ifdef _WIN32
		char title[MAX_OSPATH];
		sprintf(title, "Q2WMap [Compiling BSP]");
		SetConsoleTitle(title);
	#endif

	Com_Print("\n----- BSP -----\n\n");

	start = time(NULL);

	StripExtension(map_name, base);

	// clear the whole bsp structure
	memset(&d_bsp, 0, sizeof(d_bsp));

	// delete portal and line files
	remove(va("%s.prt", base));
	remove(va("%s.lin", base));

	// if onlyents, just grab the entities and re-save
	if(onlyents){

		LoadBSPFile(bsp_name);
		num_entities = 0;

		LoadMapFile(map_name);
		SetModelNumbers();

		UnparseEntities();

		WriteBSPFile(bsp_name);
	} else {
		// start from scratch
		LoadMapFile(map_name);
		SetModelNumbers();

		ProcessModels();
	}

	end = time(NULL);
	total_bsp_time = (int)(end - start);
	Com_Print("\nBSP Time: ");
	if(total_bsp_time > 59)
		Com_Print("%d Minutes ", total_bsp_time / 60);
	Com_Print("%d Seconds\n", total_bsp_time % 60);

	return 0;
}
Esempio n. 22
0
/*
   ===========
   Map_SaveFile
   \todo FIXME remove the use_region, this is broken .. work with a global flag to set region mode or not
   ===========
 */
void Map_SaveFile( const char *filename, qboolean use_region ){
	clock_t start, finish;
	double elapsed_time;
	start = clock();
	Sys_Printf( "Saving map to %s\n",filename );

	Pointfile_Clear();

	if ( !use_region ) {
		char backup[1024];

		// rename current to .bak
		strcpy( backup, filename );
		StripExtension( backup );
		strcat( backup, ".bak" );
		unlink( backup );
		rename( filename, backup );
	}

	Sys_Printf( "Map_SaveFile: %s\n", filename );

	// build the out data stream
	FileStream file;
	if ( !file.Open( filename,"w" ) ) {
		Sys_FPrintf( SYS_ERR, "ERROR: couldn't open %s for write\n", filename );
		return;
	}

	// extract filetype
	Map_Export( &file, filename_get_extension( filename ), use_region );

	file.Close();

	finish = clock();
	elapsed_time = (double)( finish - start ) / CLOCKS_PER_SEC;

	Sys_Printf( "Saved in %-.2f second(s).\n",elapsed_time );
	modified = false;

	if ( !strstr( filename, "autosave" ) ) {
		Sys_SetTitle( filename );
	}

	if ( !use_region ) {
		time_t timer;

		time( &timer );

		Sys_Beep();

		Sys_Status( "Saved.", 0 );
	}
}
void AddMissionsToTree(char *path, GtkWidget *tree, int is_parent) {
	glob_t *search;
	unsigned int length;
	int count, max;
	char *file, *filename;
	GtkWidget *subtree, *item;

	// First we check for sub directories. stick them at the top
	// For some reason, glob(,,GLOB_ONLYDIR,) doesn't seem to only match directories,
	// so FindDirs() currently returns everything. Check the last char for a /
	// That will be the directory.

	search = FindDirs(path);
	max = search->gl_pathc - 1;	// search->gl_pathc is a uint. If there's no files, it's 0.
	for (count = 0; count <= max; count++) {
		file = search->gl_pathv[count];
		length = strlen(file);
		if (file[length-1] != SEPERATOR) { continue; }	// Verify it's a directory and not a file

		filename = strdup(file);
		filename = StripPath(filename);
		if (strcmp("CVS", filename) == 0) { continue; }	// Don't need to display this directory

		item = AddItem(tree, filename, "dir");

		subtree = gtk_tree_new();
		gtk_signal_connect(GTK_OBJECT(subtree), "select_child", GTK_SIGNAL_FUNC(cb_select_child), subtree);
		gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child", GTK_SIGNAL_FUNC(cb_unselect_child), subtree);

		gtk_tree_set_selection_mode(GTK_TREE(subtree), GTK_SELECTION_SINGLE);
		gtk_tree_set_view_mode(GTK_TREE(subtree), GTK_TREE_VIEW_ITEM);
		gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);		

		AddMissionsToTree(file, subtree, 0);

	}

	search = FindFiles(path, EXT_MISSION);
	max = search->gl_pathc - 1;
	for (count = 0; count <= max; count++) {
		file = search->gl_pathv[count];
		length = strlen(file);
		if (file[length-1] == SEPERATOR) { continue; }

		filename = strdup(file);
		filename = StripPath(filename);
		StripExtension(filename);

		AddItem(tree, filename, file);
	}
	return;
}
Esempio n. 24
0
bool SHGToMap(wxChar *filename, wxChar *defaultFile)
{
  // Test the SHG parser
  HotSpot *hotspots = NULL;
  int n = ParseSHG(filename, &hotspots);
  if (n == 0)
    return false;

  wxChar buf[100];
  wxSnprintf(buf, sizeof(buf), _T("Converting .SHG file to HTML map file: there are %d hotspots in %s."), n, filename);
  OnInform(buf);

  wxChar outBuf[256];
  wxStrcpy(outBuf, filename);
  StripExtension(outBuf);
  wxStrcat(outBuf, _T(".map"));

  FILE *fd = wxFopen(outBuf, _T("w"));
  if (!fd)
  {
    OnError(_T("Could not open .map file for writing."));
    delete[] hotspots;
    return false;
  }

  wxFprintf(fd, _T("default %s\n"), defaultFile);
  for (int i = 0; i < n; i++)
  {
    wxChar *refFilename = _T("??");
    
    TexRef *texRef = FindReference(hotspots[i].szHlpTopic_Macro);
    if (texRef)
      refFilename = texRef->refFile;
    else
    {
      wxChar buf[300];
      wxSnprintf(buf, sizeof(buf), _T("Warning: could not find hotspot reference %s"), hotspots[i].szHlpTopic_Macro);
      OnInform(buf);
    }
    wxFprintf(fd, _T("rect %s %d %d %d %d\n"), refFilename, (int)hotspots[i].left, (int)hotspots[i].top,
      (int)hotspots[i].right, (int)hotspots[i].bottom);
  }
  wxFprintf(fd, _T("\n"));

  fclose(fd);

  delete[] hotspots;
  return true;
}
Esempio n. 25
0
int RobotWorld::LoadTerrain(const string& fn)
{
  Environment* t = new Environment;
  if(!t->Load(fn.c_str())) {
    delete t;
    return -1;
  }
  const char* justfn = GetFileName(fn.c_str());
  char* buf = new char[strlen(justfn)+1];
  strcpy(buf,justfn);
  StripExtension(buf);
  string name=buf;
  delete [] buf;
  int i = AddTerrain(name,t);
  return i;
}
Esempio n. 26
0
int RobotWorld::LoadRigidObject(const string& fn)
{
  RigidObject* t = new RigidObject;
  if(!t->Load(fn.c_str())) {
    delete t;
    return -1;
  }
  const char* justfn = GetFileName(fn.c_str());
  char* buf = new char[strlen(justfn)+1];
  strcpy(buf,justfn);
  StripExtension(buf);
  string name=buf;
  delete [] buf;
  int i = AddRigidObject(name,t);
  return i;
}
IFaceposerModels::CFacePoserModel::CFacePoserModel( char const *modelfile, StudioModel *model )
{
	m_pModel = model;
	m_szActorName[ 0 ] = 0;
	m_szShortName[ 0 ] = 0;
	strcpy( m_szModelFileName, modelfile );

	studiohdr_t *hdr = model->getStudioHeader();
	if ( hdr )
	{	
		strcpy( m_szShortName, hdr->name );
		StripExtension( m_szShortName );
	}

	m_bVisibileIn3DView = false;
}
Esempio n. 28
0
void WINAPI Pointfile_Check (void)
{
    char	name[1024];
    FILE	*f;
    idVec3	v;

    strcpy (name, currentmap);
    StripExtension (name);
    strcat (name, ".lin");

    f = fopen (name, "r");
    if (!f)
        return;

    common->Printf ("Reading pointfile %s\n", name);

    if (!g_qeglobals.d_pointfile_display_list)
        g_qeglobals.d_pointfile_display_list = qglGenLists(1);

    s_num_points = 0;
    qglNewList (g_qeglobals.d_pointfile_display_list,  GL_COMPILE);
    qglColor3f (1, 0, 0);
    qglDisable(GL_TEXTURE_2D);
    qglDisable(GL_TEXTURE_1D);
    qglLineWidth (2);
    qglBegin(GL_LINE_STRIP);
    do
    {
        if (fscanf (f, "%f %f %f\n", &v[0], &v[1], &v[2]) != 3)
            break;
        if (s_num_points < MAX_POINTFILE)
        {
            VectorCopy (v, s_pointvecs[s_num_points]);
            s_num_points++;
        }
        qglVertex3fv( v.ToFloatPtr() );
    }
    while (1);
    qglEnd();
    qglLineWidth (0.5);
    qglEndList ();

    s_check_point = 0;
    fclose (f);
    //Pointfile_Next ();
}
Esempio n. 29
0
/*
=============
WriteBSPFile
=============
*/
void
WriteBSPFile(void)
{
    FILE *f;
    size_t ret;

    header = AllocMem(OTHER, sizeof(dheader_t), true);
    header->version = options.BSPVersion;

    StripExtension(options.szBSPName);
    strcat(options.szBSPName, ".bsp");

    f = fopen(options.szBSPName, "wb");
    if (!f)
        Error("Failed to open %s: %s", options.szBSPName, strerror(errno));

    /* write placeholder, header is overwritten later */
    ret = fwrite(header, sizeof(dheader_t), 1, f);
    if (ret != 1)
        Error("Failure writing to file");

    AddLump(f, LUMP_PLANES);
    AddLump(f, LUMP_LEAFS);
    AddLump(f, LUMP_VERTEXES);
    AddLump(f, LUMP_NODES);
    AddLump(f, LUMP_TEXINFO);
    AddLump(f, LUMP_FACES);
    AddLump(f, LUMP_CLIPNODES);
    AddLump(f, LUMP_MARKSURFACES);
    AddLump(f, LUMP_SURFEDGES);
    AddLump(f, LUMP_EDGES);
    AddLump(f, LUMP_MODELS);

    AddLump(f, LUMP_LIGHTING);
    AddLump(f, LUMP_VISIBILITY);
    AddLump(f, LUMP_ENTITIES);
    AddLump(f, LUMP_TEXTURES);

    fseek(f, 0, SEEK_SET);
    ret = fwrite(header, sizeof(dheader_t), 1, f);
    if (ret != 1)
        Error("Failure writing to file");

    fclose(f);
    FreeMem(header, OTHER, sizeof(dheader_t));
}
Esempio n. 30
0
/*
 * @brief
 */
int32_t BSP_Main(void) {
	char base[MAX_OSPATH];

	Com_Print("\n----- BSP -----\n\n");

	const time_t start = time(NULL);

	StripExtension(map_name, base);

	// clear the whole bsp structure
	memset(&d_bsp, 0, sizeof(d_bsp));

	// delete portal and line files
	remove(va("%s.prt", base));
	remove(va("%s.lin", base));

	// if onlyents, just grab the entities and re-save
	if (onlyents) {

		LoadBSPFile(bsp_name);
		num_entities = 0;

		LoadMapFile(map_name);
		SetModelNumbers();

		UnparseEntities();

		WriteBSPFile(bsp_name);
	} else {
		// start from scratch
		LoadMapFile(map_name);
		SetModelNumbers();

		ProcessModels();
	}

	const time_t end = time(NULL);
	const time_t duration = end - start;
	Com_Print("\nBSP Time: ");
	if (duration > 59)
		Com_Print("%d Minutes ", (int32_t) (duration / 60));
	Com_Print("%d Seconds\n", (int32_t) (duration % 60));

	return 0;
}