Пример #1
0
/** \brief Feed command line options to the renderer.
 *
 * This function sends all command line options to the renderer, except those
 * which are set directly before the world block.
 */
void setupOptions()
{
	if ( g_cl_echoapi )
		Aqsis::cxxRenderContext()->addFilter("echorib");

	std::string frameList = getFrameList();
	if(!frameList.empty())
		Aqsis::cxxRenderContext()->addFilter("framedrop",
				Aqsis::ParamListBuilder()("frames", frameList.c_str()) );

	// Allow any command line arguments to override system/env settings
	Aqsis::log() << Aqsis::info
		<< "Applying search paths provided at the command line\n";
	const char* popt[1];
	if(!g_cl_shader_path.empty())
	{
		popt[0] = g_cl_shader_path.c_str();
		RiOption( tokenCast("searchpath"), "shader", &popt, RI_NULL );
	}
	if(!g_cl_archive_path.empty())
	{
		popt[0] = g_cl_archive_path.c_str();
		RiOption( tokenCast("searchpath"), "archive", &popt, RI_NULL );
	}
	if(!g_cl_texture_path.empty())
	{
		popt[0] = g_cl_texture_path.c_str();
		RiOption( tokenCast("searchpath"), "texture", &popt, RI_NULL );
	}
	if(!g_cl_display_path.empty())
	{
		popt[0] = g_cl_display_path.c_str();
		RiOption( tokenCast("searchpath"), "display", &popt, RI_NULL );
	}
	if(!g_cl_procedural_path.empty())
	{
		popt[0] = g_cl_procedural_path.c_str();
		RiOption( tokenCast("searchpath"), "procedural", &popt, RI_NULL );
	}

	RiProgressHandler( &PrintProgress );
}
Пример #2
0
/** \brief Feed command line options to the renderer.
 *
 * This function sends all command line options to the renderer, except those
 * which are set directly before the world block.
 */
void setupOptions()
{
	if ( g_cl_echoapi )
	{
		RtInt echoapi = 1;
		RiOption( tokenCast("statistics"), "echoapi", &echoapi, RI_NULL );
	}
	
	// Allow any command line arguments to override system/env settings
	Aqsis::log() << Aqsis::info
		<< "Applying search paths provided at the command line\n";
	const char* popt[1];
	if(!g_cl_shader_path.empty())
	{
		popt[0] = g_cl_shader_path.c_str();
		RiOption( tokenCast("searchpath"), "shader", &popt, RI_NULL );
	}
	if(!g_cl_archive_path.empty())
	{
		popt[0] = g_cl_archive_path.c_str();
		RiOption( tokenCast("searchpath"), "archive", &popt, RI_NULL );
	}
	if(!g_cl_texture_path.empty())
	{
		popt[0] = g_cl_texture_path.c_str();
		RiOption( tokenCast("searchpath"), "texture", &popt, RI_NULL );
	}
	if(!g_cl_display_path.empty())
	{
		popt[0] = g_cl_display_path.c_str();
		RiOption( tokenCast("searchpath"), "display", &popt, RI_NULL );
	}
	if(!g_cl_procedural_path.empty())
	{
		popt[0] = g_cl_procedural_path.c_str();
		RiOption( tokenCast("searchpath"), "procedural", &popt, RI_NULL );
	}

	RiProgressHandler( &PrintProgress );
	RiPreWorldFunction( &PreWorld );
}
Пример #3
0
// Get list of frames, as a string
std::string getFrameList()
{
	std::string frameList;
	if(g_cl_frames.size() == 2)
	{
		std::ostringstream fmt;
		fmt << g_cl_frames[0] << "-" << g_cl_frames[1];
		frameList = fmt.str();
	}
	if(!g_cl_frameList.empty())
	{
		if(!frameList.empty())
			frameList += ',';
		frameList += g_cl_frameList;
	}
	return frameList;
}
Пример #4
0
RtVoid PreWorld()
#endif
{
	if ( g_cl_fb )
	{
		RiDisplay( tokenCast("aqsis"), tokenCast("framebuffer"), tokenCast("rgb"), NULL );
	}
	else if ( !g_cl_type.empty() )
	{
		RiDisplay( tokenCast("aqsis"), tokenCast(g_cl_type.c_str()),
				   tokenCast(g_cl_mode.c_str()), NULL );
	}
	else if ( !g_cl_addtype.empty() )
	{
		RiDisplay( tokenCast("+aqsis"), tokenCast(g_cl_addtype.c_str()),
				   tokenCast(g_cl_mode.c_str()), NULL );
	}

	// Pass the statistics option onto Aqsis.
	if ( g_cl_endofframe >= 0 )
	{
		RiOption( tokenCast("statistics"), "endofframe", &g_cl_endofframe, RI_NULL );
	}

	// Pass the crop window onto Aqsis.
	if( g_cl_cropWindow.size() == 4 )
	{
		RiCropWindow(g_cl_cropWindow[0], g_cl_cropWindow[1], g_cl_cropWindow[2], g_cl_cropWindow[3]);
	}

	// Pass in specified resolution.
	if(g_cl_res.size() == 2)
	{
		RiFormat(g_cl_res[0], g_cl_res[1], 1.0f);
	}

#	if ENABLE_MPDUMP
	// Pass the statistics option onto Aqsis.
	if ( g_cl_mpdump )
	{
		RtInt enabled = 1;
		RiOption( "mpdump", "enabled", &enabled, RI_NULL );
	}
#	endif

	// Parse all the command line options with the RIB parser.
	for(TqInt i = 0, end = g_cl_options.size(); i < end; ++i)
	{
		std::istringstream inStream(g_cl_options[i]);
		Aqsis::QGetRenderContextI()->parseRibStream(inStream, "command_line_option");
	}
	return;
}
Пример #5
0
int main( int argc, const char** argv )
{
	ArgParse ap;
	RtFilterFunc filterfunc;
	float bake;

	ap.usageHeader( ArgParse::apstring( "Usage: " ) + argv[ 0 ] + " [options] infile outfile" );
	ap.argFlag( "help", "\aPrint this help and exit", &g_help );
	ap.alias( "help" , "h" );
	ap.argFlag( "version", "\aPrint version information and exit", &g_version );
	ap.argInt( "verbose", "=integer\aSet log output level\n"
		"\a0 = errors\n"
		"\a1 = warnings (default)\n"
		"\a2 = information\n"
		"\a3 = debug", &g_cl_verbose );
	ap.alias( "verbose" , "v" );
	ap.argString( "compression", "=string\a[none|lzw|packbits|deflate] (default: %default)", &g_compress );
	ap.argFlag( "envcube", " px nx py ny pz nz\aproduce a cubeface environment map from 6 images.", &g_envcube );
	ap.argFlag( "envlatl", "\aproduce a latlong environment map from an image file.", &g_envlatl );
	ap.argFlag( "shadow", "\aproduce a shadow map from a z file.", &g_shadow );
	ap.argString( "swrap", "=string\as wrap [black|periodic|clamp] (default: %default)", &g_swrap );
	ap.argString( "smode", "=string\a(equivalent to swrap for BMRT compatibility)", &g_swrap );
	ap.argString( "twrap", "=string\at wrap [black|periodic|clamp] (default: %default)", &g_twrap );
	ap.argString( "tmode", "=string\a(equivalent to twrap for BMRT compatibility)", &g_swrap );
	ap.argString( "wrap", "=string\awrap s&t [black|periodic|clamp]", &g_wrap );
	ap.argString( "mode", "=string\as (equivalent to wrap for BMRT compatibility)", &g_wrap );
	ap.argString( "filter", "=string\a[box|bessel|catmull-rom|disk|gaussian|sinc|triangle|mitchell] (default: %default)", &g_filter );
	ap.argFloat( "fov(envcube)", "=float\a[>=0.0f] (default: %default)", &g_fov );
	ap.argFloat( "swidth", "=float\as width [>0.0f] (default: %default)", &g_swidth );
	ap.alias( "swidth", "sfilterwidth" );
	ap.argFloat( "twidth", "=float\at width [>0.0f] (default: %default)", &g_twidth );
	ap.alias( "twidth", "tfilterwidth" );
	ap.argFloat( "width", "=float\awidth [>0.0f] set both swidth and twidth (default: %default)", &g_width );
	ap.alias( "width", "filterwidth" );
	ap.argFloat( "quality", "=float\a[>=1.0f && <= 100.0f] (default: %default)", &g_quality );
	ap.argFloat( "bake", "=float\a[>=2.0f && <= 2048.0f] (default: %default)", &g_bake );
	ap.argString( "resize", "=string\a[up|down|round|up-|down-|round-] (default: %default)\n\aNot used, for BMRT compatibility only!", &g_resize );


	if ( argc > 1 && !ap.parse( argc - 1, argv + 1 ) )
	{
		Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg();
		exit( 1 );
	}

	if ( g_version )
	{
		version( std::cout );
		exit( 0 );
	}

	if ( g_help || ap.leftovers().size() <= 1 )
	{
		std::cout << ap.usagemsg();
		exit( 0 );
	}

	if ( g_envcube && g_shadow )
	{
		std::cout << "Specify only one of envcube or shadow" << std::endl;
		exit( 1 );
	}


	/* find the pixel's filter function */
	filterfunc = RiBoxFilter;
	if ( g_filter == "box" )
		filterfunc = RiBoxFilter;
	else if ( g_filter == "mitchell" )
		filterfunc = RiMitchellFilter;
	else if ( g_filter == "sinc" )
		filterfunc = RiSincFilter;
	else if ( g_filter == "catmull-rom" )
		filterfunc = RiCatmullRomFilter;
	else if ( g_filter == "disk" )
		filterfunc = RiDiskFilter;
	else if ( g_filter == "bessel" )
		filterfunc = RiBesselFilter;
	else if ( g_filter == "triangle" )
		filterfunc = RiTriangleFilter;
	else if ( g_filter == "gaussian" )
		filterfunc = RiGaussianFilter;



	/* protect the s,t width */
	if ( g_swidth < 1.0 )
	{
		Aqsis::log() << "g_swidth is smaller than 1.0." << " 1.0 will be used instead." << std::endl;
		g_swidth = 1.0;
	}
	if ( g_twidth < 1.0 )
	{
		Aqsis::log() << "g_twidth is smaller than 1.0." << " 1.0 will be used instead." << std::endl;
		g_twidth = 1.0;
	}

	/* protect the s,t wrap mode */
	if ( !( ( g_swrap == "black" ) || ( g_swrap == "periodic" ) || ( g_swrap == "clamp" ) ) )
	{
		Aqsis::log() << "Unknown s wrap mode: " << g_swrap << ". black will be used instead." << std::endl;
		g_swrap = "black";
	}
	if ( !( ( g_twrap == "black" ) || ( g_twrap == "periodic" ) || ( g_twrap == "clamp" ) ) )
	{
		Aqsis::log() << "Unknown t wrap mode: " << g_twrap << ". black will be used instead." << std::endl;
		g_twrap = "black";
	}
	if ( !( ( g_wrap == "" ) || ( g_wrap == "black" ) || ( g_wrap == "periodic" ) || ( g_wrap == "clamp" ) ) )
	{
		Aqsis::log() << "Unknown wrap mode: " << g_wrap << ". black will be used instead." << std::endl;
		g_wrap = "black";
	}

	/* If wrap is specified, it overrides both s and t */
	if( g_wrap != "" )
	{
		g_twrap = g_wrap;
		g_swrap = g_wrap;
	}

	/* Need to set both st width ? */
	if ( g_width > 0.0 )
	{
		g_twidth = g_swidth = g_width;
	}

	/* protect the compression mode */
	if ( !( ( g_compress == "deflate" ) ||
	        ( g_compress == "lzw" ) ||
	        ( g_compress == "none" ) ||
	        ( g_compress == "packbits" )
	      )
	   )
	{
		Aqsis::log() << "Unknown compression mode: " << g_compress << ". none." << std::endl;
		g_compress = "none";
	}

	/* protect the quality mode */
	if ( g_quality < 1.0f )
		g_quality = 1.0;
	if ( g_quality > 100.0f )
		g_quality = 100.0;

	/* protect the bake mode */
	if ( g_bake < 2.0f )
		g_bake = 2.0;
	if ( g_bake > 2048.0f )
		g_bake = 2048.0;

	char *compression = ( char * ) g_compress.c_str();
	float quality = ( float ) g_quality;


	std::auto_ptr<std::streambuf> show_level( new Aqsis::show_level_buf(Aqsis::log()) );
	Aqsis::log_level_t level = Aqsis::ERROR;
	if( g_cl_verbose > 0 )
		level = Aqsis::WARNING;
	if( g_cl_verbose > 1 )
		level = Aqsis::INFO;
	if( g_cl_verbose > 2 )
		level = Aqsis::DEBUG;
	std::auto_ptr<std::streambuf> filter_level( new Aqsis::filter_by_level_buf(level, Aqsis::log()) );

	RiBegin(RI_NULL);

	if ( g_envcube )
	{
		if ( ap.leftovers().size() != 7 )
		{
			Aqsis::log() << "Need 6 images for cubic environment map" << std::endl;
			return ( -1 );
		}

		printf( "CubeFace Environment %s %s %s %s %s %s ----> %s \n\t\"fov\"= %4.1f\n\t\"filter\"= %s \n\t\"swidth\"= %4.1f\n\t\"twidth\"= %4.1f\n\t\"compression\" = %s\n",
		        const_cast<char*>(ap.leftovers() [ 0 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 1 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 2 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 3 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 4 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 5 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 6 ].c_str()),
		        g_fov,
		        g_filter.c_str(),
		        g_swidth,
		        g_twidth,
		        ( char* ) g_compress.c_str()
		      );

		RiMakeCubeFaceEnvironment(
		    const_cast<char*>(ap.leftovers() [ 0 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 1 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 2 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 3 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 4 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 5 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 6 ].c_str()),
		    g_fov,
		    filterfunc,
		    ( float ) g_swidth,
		    ( float ) g_twidth,
		    "compression",
		    &compression,
		    "quality",
		    &quality,
		    RI_NULL );
	}
	else if ( g_shadow )
	{
		printf( "Shadow %s ----> %s \n\t\"compression\" = %s\n",
		        ( char* ) ap.leftovers() [ 0 ].c_str(),
		        ( char* ) ap.leftovers() [ 1 ].c_str(),
		        ( char* ) g_compress.c_str() );



		RiMakeShadow( ( char* ) ap.leftovers() [ 0 ].c_str(), ( char* ) ap.leftovers() [ 1 ].c_str(), ( float ) g_twidth, "compression", &compression, "quality", &quality, RI_NULL );
	}
	else if ( g_envlatl )
	{
		printf( "LatLong Environment %s ----> %s \n\t\"compression\" = %s \n",
		        ( char* ) ap.leftovers() [ 0 ].c_str(),
		        ( char* ) ap.leftovers() [ 1 ].c_str(),
		        ( char* ) g_compress.c_str() );

		RiMakeLatLongEnvironment( ( char* ) ap.leftovers() [ 0 ].c_str(), ( char* ) ap.leftovers() [ 1 ].c_str(), filterfunc,
		                          ( float ) g_swidth, ( float ) g_twidth, "compression", &compression, "quality", &quality, RI_NULL );
	}
	else
	{
		printf( "Texture %s ----> %s \n\t\"swrap\"= %s \n\t\"twrap\"= %s \n\t\"filter\"= %s \n\t\"swidth\"= %4.1f\n\t\"twidth\"= %4.1f\n\t\"compression\" = %s\n",
		        ( char* ) ap.leftovers() [ 0 ].c_str(),
		        ( char* ) ap.leftovers() [ 1 ].c_str(),
		        ( char* ) g_swrap.c_str(),
		        ( char* ) g_twrap.c_str(),
		        ( char* ) g_filter.c_str(),
		        g_swidth,
		        g_twidth,
		        compression
		      );

 		bake = g_bake;

		RiMakeTexture( ( char* ) ap.leftovers() [ 0 ].c_str(), ( char* ) ap.leftovers() [ 1 ].c_str(),
		               ( char* ) g_swrap.c_str(), ( char* ) g_twrap.c_str(), filterfunc,
		               ( float ) g_swidth, ( float ) g_twidth, "compression", &compression, "quality", &quality, "float bake", &bake, RI_NULL );
	}

	RiEnd();

	return ( 0 );
}
Пример #6
0
int main( int argc, const char** argv )
{

#ifdef	AQSIS_SYSTEM_WIN32
	char acPath[256];
	char rootPath[256];
	if( GetModuleFileName( NULL, acPath, 256 ) != 0)
	{
		// guaranteed file name of at least one character after path
		*( strrchr( acPath, '\\' ) + 1 ) = '\0';
		std::string	 stracPath(acPath);
		stracPath.append("..\\");
		_fullpath(rootPath,&stracPath[0],256);
	}
	g_shader_path = rootPath;
	g_shader_path.append( "shaders" );
#elif defined(AQSIS_SYSTEM_MACOSX)
#else

	g_shader_path = AQSIS_XSTR(DEFAULT_SHADER_PATH);
#endif

	/*Aqsis::QGetRenderContextI();*/
	ArgParse ap;
	ap.usageHeader( ArgParse::apstring( "Usage: " ) + argv[ 0 ] + " <shadername>" );
	ap.argFlag( "help", "\aPrint this help and exit", &g_cl_help );
	ap.alias( "help" , "h" );
	ap.argFlag( "version", "\aPrint version information and exit", &g_cl_version );
	ap.argString( "shaders", "=string\aOverride the default shader searchpath(s) [" + g_shader_path + "]", &g_cl_shader_path );

	if ( argc > 1 && !ap.parse( argc - 1, argv + 1 ) )
	{
		Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg();
		exit( 1 );
	}

	if ( g_cl_help )
	{
		std::cout << ap.usagemsg();
		exit( 0 );
	}

	if ( g_cl_version )
	{
		std::cout << "aqsltell version " << AQSIS_VERSION_STR_FULL << std::endl << "compiled " << __DATE__ << " " << __TIME__ << std::endl;
		exit( 0 );
	}

	// Apply environment-variable overrides to default paths ...
	if(getenv("AQSIS_SHADER_PATH"))
		g_shader_path = getenv("AQSIS_SHADER_PATH");

	// Apply command-line overrides to default paths ...
	if(!g_cl_shader_path.empty())
		g_shader_path = g_cl_shader_path;

	// Any leftovers are presumed to be shader names.
	if ( ap.leftovers().size() == 0 )     // If no files specified, take input from stdin.
	{
		Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg();
		exit( 1 );
	}
	else
	{
		for ( ArgParse::apstringvec::const_iterator e = ap.leftovers().begin(); e != ap.leftovers().end(); e++ )
		{
			SLX_SetPath( const_cast<char*>( g_shader_path.c_str() ) );
			SLX_SetDSOPath( const_cast<char*>( g_shader_path.c_str() ) );
			Slo_SetShader( ( char* ) e->c_str() );

			if ( SLX_SetShader( ( char* ) e->c_str() ) == 0 )
			{
				// SLX_SetShader successful
				int	nArgs;
				int i;
				SLX_VISSYMDEF * symPtr;

				std::cout << SLX_TypetoStr( SLX_GetType() ) << " \"" << Slo_GetName() << "\"" << std::endl;
				nArgs = SLX_GetNArgs();

				for ( i = 0; i < nArgs; i++ )
				{
					symPtr = SLX_GetArgById( i );
					if ( symPtr != NULL )
					{
						TqInt arrayLen = 1;
						if ( symPtr->svd_arraylen != 0 )
							arrayLen = symPtr->svd_arraylen;

						std::cout << "    \"" << symPtr->svd_name << "\" \"parameter " <<
						SLX_DetailtoStr( symPtr->svd_detail ) << " " <<
						SLX_TypetoStr( symPtr->svd_type );

						if ( symPtr->svd_arraylen != 0 )
							std::cout << "[" << arrayLen << "]";

						std::cout << "\"" << std::endl;

						TqInt arrayIndex;
						for ( arrayIndex = 0; arrayIndex < arrayLen; arrayIndex++ )
						{
							std::cout << "\t\tDefault value: ";

							if ( symPtr->svd_spacename != NULL )
							{
								if ( ( symPtr->svd_type == SLX_TYPE_POINT ) ||
								        ( symPtr->svd_type == SLX_TYPE_NORMAL ) ||
								        ( symPtr->svd_type == SLX_TYPE_VECTOR ) ||
								        ( symPtr->svd_type == SLX_TYPE_MATRIX ) ||
								        ( symPtr->svd_type == SLX_TYPE_COLOR ) )
									std::cout << "\"" << symPtr->svd_spacename << "\" ";
							}

							if ( symPtr->svd_default.stringval != NULL )
							{
								switch ( symPtr->svd_type )
								{
										case SLX_TYPE_UNKNOWN:
										std::cout << "unknown" << std::endl;
										break;
										case SLX_TYPE_POINT:
										case SLX_TYPE_NORMAL:
										case SLX_TYPE_VECTOR:
										std::cout << "[" << symPtr->svd_default.pointval[ arrayIndex ].xval << " " <<
										symPtr->svd_default.pointval[ arrayIndex ].yval << " " <<
										symPtr->svd_default.pointval[ arrayIndex ].zval <<
										"]" << std::endl;
										break;
										case SLX_TYPE_COLOR:
										std::cout << "[" << symPtr->svd_default.pointval[ arrayIndex ].xval << " " <<
										symPtr->svd_default.pointval[ arrayIndex ].yval << " " <<
										symPtr->svd_default.pointval[ arrayIndex ].zval <<
										"]" << std::endl;
										break;
										case SLX_TYPE_SCALAR:
										std::cout << symPtr->svd_default.scalarval[ arrayIndex ] << std::endl;
										break;
										case SLX_TYPE_STRING:
										std::cout << "\"" << symPtr->svd_default.stringval[ arrayIndex ] << "\"" << std::endl;
										break;
										case SLX_TYPE_MATRIX:
										std::cout << "[" <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[0][0] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[0][1] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[0][2] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[0][2] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[1][0] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[1][1] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[1][2] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[1][2] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[2][0] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[2][1] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[2][2] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[2][3] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[3][0] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[3][1] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[3][2] << " " <<
										symPtr->svd_default.matrixval[ arrayIndex ].val[3][3] <<
										"]" << std::endl;
										break;
										default:
										std::cout << "unknown" << std::endl;
										break;
								}
							}
						}
					}
					else
					{
						printf( "ERROR - null pointer to value\n" );
					}
					//std::cout << std::endl;
				}

				SLX_EndShader();
			}
			else
			{
				printf("ERROR - could not read shader file\n");
			}
		}
	}

	return ( 0 );
}