Example #1
0
void WriteImageTexture(FILE *fph,const StringRef &name,
					   VFormatOptions &options,bool lightmap, bool clamp= false)
{

  // texture node already defined ?
	  TextureDefMap::iterator found;
	  found = options.textureDefMap.find(name);
	  if ( found != options.textureDefMap.end()) { // simply use it 
		  fprintf(fph,"USE %s\n",(const char *)(*found).second );
	  } 
	  else 
	  { // need to define new imageTexture node 

		  char buf[60];
		  sprintf(buf,"_T%d",options.textureCount);
		  options.textureCount++;

		  fprintf(fph,"DEF %s ImageTexture {\n",(const char *)buf);

		  if (clamp) fprintf(fph,"\trepeatS FALSE repeatT FALSE\n");		  
		  const char *ext="bmp";
		  
		  if (options.usePng) 
			  ext = "png";
		  
		  if (!lightmap) {
				String textureFileName;
				// check and return jpg, png ..
				CheckTexture(name, textureFileName);
				fprintf(fph,"  url %c%s%c\n",0x22,textureFileName.c_str(),0x22);
		  } else
			  fprintf(fph,"  url %c%s.%s%c\n",0x22,name.Get(),ext,0x22);
		  
		  fprintf(fph,"}\n");
		  
		  // insert new node into map 
		  options.textureDefMap.insert(TextureDefMap::value_type(name,buf));
		  
	  }
}
Example #2
0
//==================================================================================
int CommandParser::CommandLine(int argc,const char **argv,bool fallbackok)
{
	int ret = 0;

	if ( argc )
	{
		TokenMap::iterator found;
		StringRef ref = SGET(argv[0]);
		found = mTokens.find( ref );

		if ( found == mTokens.end() )
		{
			// do case - insenstive search
			for (found=mTokens.begin(); found!=mTokens.end(); ++found)
			{
				if ( stricmp( (*found).first.Get(), ref.Get() ) == 0 ) break;
			}
		}

		if ( found != mTokens.end() )
		{
			TokenTag ttype = (*found).second;

			if ( 0 )
			{
				for (int i=0; i<argc; i++)
				{
					gAllGlobals.gLog.ref()->Display("%s ", argv[i] );
				}
				gAllGlobals.gLog.ref()->Display("\n");
			}

			CommandParserInterface *cmd = ttype.GetService();

			int v = cmd->CommandCallback( ttype.GetLocalToken(), argc, argv );

			if ( v ) 
				ret = v;
		}
		else
		{
			if ( mFallbacks.empty() || !fallbackok )
			{
				#if LOG_ERROR
				if ( gAllGlobals.gLog.ref() )
				{
//          gAllGlobals.gLog.ref()->Display("CPARSER(%s)???\n", argv[0] );
				}
				#endif
			}
			else
			{
				CommandParserInterfaceVector::iterator i;

				for (i=mFallbacks.begin(); i!=mFallbacks.end(); ++i)
				{
					CommandParserInterface *iface = (*i);
					int v = iface->CommandFallback(argc,argv);
					if ( v ) ret = v;
				}
			}
		}
	}

	return ret;
}