void doFrame(int fNum, size_t cur, int fft_size, fftw_complex *fft_data[], char *fName) { RiFrameBegin(fNum); char buffer[256]; sprintf(buffer, "images/%s%05d.tif", fName, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); RiTranslate(0.0,0.0,0.8*fft_size); RiRotate( -120.0, 1.0, 0.0, 0.0); RiRotate(90.0, 0.0,0.0, 1.0); RiWorldBegin(); RiSurface((char*)"matte", RI_NULL); RiTranslate(-fft_size/2.0, -fft_size/2.0+fft_size/4.0, 0); size_t real_i = cur; RtPoint *pts = malloc(sizeof(RtPoint)*(fft_size*fft_size/2)); RtColor *colors = malloc(sizeof(RtColor)*(fft_size*fft_size/2)); RtInt *numCurves = malloc(sizeof(RtInt)*fft_size); size_t cp = 0; for (int i=fft_size-1; i>=0; --i) { real_i += 1; if (real_i == fft_size) { real_i = 0; } numCurves[i] = fft_size/2; for (size_t j=0; j<fft_size/2; ++j) { colors[cp][0] = real_i/(double)(fft_size-1); colors[cp][1] = cabs(fft_data[real_i][j]); if (colors[cp][1]>1.0) { colors[cp][1] = 1.0; } colors[cp][2] = j/(double)(fft_size/2); pts[cp][0] = fft_size-i; pts[cp][2] = cabs(fft_data[real_i][j]); pts[cp][1] = j; cp += 1; } } RiCurves( "linear", fft_size, numCurves, "nonperiodic", "P", (RtPointer)pts, "Cs", (RtPointer)colors, RI_NULL ); free(numCurves); free(colors); free(pts); RiWorldEnd(); RiFrameEnd(); }
void SpotLight::prepare(Scene* scene) { #if 0 /* Attribute castShadows = attributeByName("Casts Shadows"); if (castShadows && castShadows->property("value").isValid()) { } */ //Attribute position = ; //position.property("value").toFloat(); QVector3D position = getBoundValue<QVector3D>(this, attributeByName("Position")); QVector3D lookat = position + lookDir(); float coneAngle = PI * attributeByName("Cone Angle")->property("value").value<float>() / 180.0f; RtFloat intensity = attributeByName("Intensity")->property("value").value<float>(); RtPoint from = { position.x(), position.y(), position.z() }; RtPoint to = { lookat.x(), lookat.y(), lookat.z() }; QColor color = attributeByName("Color")->property("value").value<QColor>(); RtColor c = { color.redF(), color.greenF(), color.blueF() }; bool castsShadow = attributeByName("Casts Shadows")->property("value").value<bool>(); if (castsShadow) { QString shadowPath = QString(getenv("AQSIS_TEXTURE_PATH")).split(":")[0] + "/" + scene->assetName(this) + ".shd"; char cShadowPath[1000]; strcpy(cShadowPath, shadowPath.toStdString().c_str()); char *shadowPaths[]= { cShadowPath, RI_NULL }; // float shadowBias = attributeByName("Shadow Bias")->property("value").value<float>(); //RiOption("shadow", "bias", (RtPointer)&shadowBias, RI_NULL); // std::cout << "shadow bias: " << shadowBias << std::endl; RiDeclare("shadowname", "uniform string"); RiLightSource("shadowspot", "from", from, "to", to, "intensity", &intensity, "coneangle", &coneAngle, "lightcolor", &c, "shadowname", shadowPaths, RI_NULL); } else RiLightSource("spotlight", "from", from, "to", to, "intensity", &intensity, "coneangle", &coneAngle, "lightcolor", &c, RI_NULL); //LightSource "shadowspot" 1 "intensity" 50 "from" [1 5 0] "to" [0 0 0] // "shadowname" ["spot1.tx"] #endif }
int main() { std::ostringstream output; // Test setting of options. const char* outputType = "Ascii"; RiOption((char*)"RI2RIB_Output", "Type", &outputType, "OStream", &output, RI_NULL); int indentSize = 2; const char* indentType = "Space"; RiOption((char*)"RI2RIB_Indentation", "Size", &indentSize, "Type", &indentType, RI_NULL); RtPointer badHandle = RtPointer(0xDEADBEEF); // Create RIB RiBegin(0); RiFrameBegin(0); RiBasis(RiCatmullRomBasis, 2, RiHermiteBasis, 3); RiFrameEnd(); RiArchiveRecord((char*)"comment", (char*)" Note that we expect a bad handle error " "regarding %p somewhere here!", badHandle); RiFrameBegin(1); RiDisplay((char*)"blah.tif", (char*)"framebuffer", (char*)"rgb", RI_NULL); RiBasis(RiBezierBasis, 3, RiCatmullRomBasis, 1); RiPixelFilter(RiGaussianFilter, 2, 2); RiProjection((char*)"perspective", RI_NULL); RiTranslate(0,0,5); RiWorldBegin(); RtLightHandle h = RiLightSource((char*)"pointlight", RI_NULL); RiIlluminate(h, RI_FALSE); RiIlluminate(badHandle, RI_TRUE); // Invalid handle! float Cs[] = {1,0,0, 0,1,0, 0,0,1, 2,2,2}; RiSphere(1, -1, 1, 360, "Cs", Cs, RI_NULL); float blah[] = {42}; RiSphere(2, -2, 2, 360, "float blah", blah, RI_NULL); int nvertices[] = {5}; float P[] = {-1,-1,0, 1,-1,0, 1,1,0, -1,1,0, -1,-1,2}; float width[] = {1, 2, 3}; RiCurves((char*)"cubic", 1, nvertices, (char*)"nonperiodic", "P", P, "width", width, RI_NULL); RiWorldEnd(); RiFrameEnd(); RiEnd(); // Stream the output buffer to stdout std::cout << output.str(); return 0; }
void AmbientLight::prepare(Scene* scene) { #if 0 RtFloat intensity = attributeByName("Intensity")->property("value").value<float>(); QColor color = attributeByName("Color")->property("value").value<QColor>(); //getBoundValue<QVector3D>(this, attributeByName("Color")); RtColor c = { color.redF(), color.greenF(), color.blueF() }; std::cout << color.redF() << " " << color.greenF() << " " << color.blueF() << std::endl; RiLightSource("ambientlight", "intensity", &intensity, "lightcolor", &c, RI_NULL); #endif }
void doFrame(size_t fNum, scene_info_t *scene, wave_object_t *obj) { RtInt on = 1; char buffer[256]; RtString on_string = "on"; RtInt samples = 2; RtPoint lightPos = {40,80,40}; RiFrameBegin(fNum); RtColor bgcolor = {0.2,0.8,0.2}; RiImager("background", "color background", bgcolor, RI_NULL); sprintf(buffer, "images/%s%05lu.tif", scene->fprefix, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiProjection((char*)"perspective",RI_NULL); PlaceCamera(&scene->cam); /* RiAttribute("visibility", "int trace", &on, RI_NULL); */ RiAttribute( "visibility", "int camera", (RtPointer)&on, "int transmission", (RtPointer)&on, "int diffuse", (RtPointer)&on, "int specular", (RtPointer)&on, "int photon", (RtPointer)&on, RI_NULL ); RiAttribute( "light", (RtToken)"shadows", (RtPointer)&on_string, (RtToken)"samples", (RtPointer)&samples, RI_NULL ); RiAttribute((RtToken)"light", "string shadow", (RtPointer)"on", RI_NULL); RiLightSource("distantlight", (RtToken)"from", (RtPointer)lightPos, RI_NULL); RiWorldBegin(); RiSurface((char*)"matte", RI_NULL); show_object(obj); RiWorldEnd(); RiFrameEnd(); }
int main(int argc, const char *argv[]) { RtPoint points[] = { { 0, 0, 0}, {-.5, .5, 0}, {.5, .5, 0} }; RtPoint points2[] = { { 0, 0, 0}, { 0, 1.0F, 0}, {1.33333F, -1.0F, 0}, {-1.33333F, -1.0F, 0} }; RtFloat color[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 }; RtFloat Cs1[] = {1, 1, 1}; RtFloat Cs2[] = {1, 1, 0}; RtFloat Cs3[] = {1, 0, 0}; RtBound bound = { -.5F, 0, 0, .5F, .5F, 0 }; RtInt renderer = 0; RtString myVal[2] = {"MyVal0", "MyVal1"}; RiOption("MyOption", "string MyVar", &myVal[0], RI_NULL); RiCPPControl("MyControl", "string MyVar2", &myVal[1], RI_NULL); switch(renderer) { case 1: RiBegin("|aqsis -progress"); break; case 2: RiBegin("|rndr -p"); break; default: RiBegin(RI_NULL); } /* RiMakeTexture("mytexture.tiff", "mytexture.tx", RI_PERIODIC, RI_PERIODIC, RiSincFilter, (RtFloat)3.0, (RtFloat)3.0, RI_NULL); */ /* Using gcc-4.0.1 I got a warning for Ri-functions that float is used instead of double due to prototype, * even if I pass explictely float. Due to a message in fr.comp.lang.c "Complexe avex fonction réelle" Jan 23, 2008 * this warning (gcc-4.2.3) is not issued in gcc-4.3.0 anymore, so I disabled the "Prototype conversion" option temporarily. */ RiPixelFilter(RiGaussianFilter, 3.0f, 3.0f), RiShutter(0.0F, 1.0F); RiClipping(0.5F, 20.0F); RiProjection(RI_PERSPECTIVE, RI_NULL); RiFrameBegin(1); RiDisplay("Polygon", RI_FRAMEBUFFER, RI_RGB, RI_NULL); RiTranslate(0.0F, 0.0F, 4.5F); RiLightSource("pointlight", RI_NULL); RiTranslate(0.0F, 0.0F, .5F); RiWorldBegin(); RiOrientation(RI_LH); RiSides(1); RiSurface("matte", RI_NULL); RiMotionBegin(3, 0.0F, 0.5F, 1.0F); RiColor(Cs1); RiColor(Cs2); RiColor(Cs3); RiMotionEnd(); RiMotionBegin(3, 0.0F, 0.5F, 1.0F); RiRotate(10.0F, 0.0F, 0.0F, 1.0F); RiRotate(20.0F, 0.0F, 0.0F, 1.0F); RiRotate(30.0F, 0.0F, 0.0F, 1.0F); RiMotionEnd(); RiDetail(bound); RiDetailRange(0.0F, 0.0F, 100.0F, 150.0F); RiPolygon(3, RI_P, points, RI_NULL); RiDetailRange(100.0F, 150.0F, RI_INFINITY, RI_INFINITY); RiPolygon(3, RI_P, points, RI_CS, color, RI_NULL); RiTransformPoints(RI_SCREEN, RI_RASTER, sizeof(points2)/sizeof(RtPoint), points2); RiWorldEnd(); RiFrameEnd(); RiEnd(); exit(0); return 0; }
int Renderer::preview( const std::string& fileName, const liqPreviewShaderOptions& options ) { CM_TRACE_FUNC("Renderer::preview("<<fileName<<","<<options.shaderNodeName<<")"); std::string shaderFileName; liqShader currentShader; MObject shaderObj; MString shader_type_TempForRefactoring;// [2/14/2012 yaoyansi] if ( options.fullShaderPath ) { // a full shader path was specified //cout <<"[liquid] got full path for preview !"<<endl; //shaderFileName = const_cast<char*>(options.shaderNodeName); std::string tmp( options.shaderNodeName ); currentShader.setShaderFileName(tmp.substr( 0, tmp.length() - 4 ) ); if ( options.type == "surface" ){ assert(0&&"we should use currentShader.shader_type_ex = \"surface\""); //currentShader.shader_type = SHADER_TYPE_SURFACE;// [2/14/2012 yaoyansi] shader_type_TempForRefactoring = "surface"; }else if ( options.type == "displacement" ){ assert(0&&"we should use currentShader.shader_type_ex = \"displacement\""); //currentShader.shader_type = SHADER_TYPE_DISPLACEMENT;// [2/14/2012 yaoyansi] shader_type_TempForRefactoring = "displacement"; } //cout <<"[liquid] options.shaderNodeName = " << options.shaderNodeName << endl; //cout <<"[liquid] options.type = "<<options.type<<endl; } else { // a shader node was specified MSelectionList shaderNameList; shaderNameList.add( options.shaderNodeName.c_str() ); shaderNameList.getDependNode( 0, shaderObj ); if( shaderObj == MObject::kNullObj ) { MGlobal::displayError( std::string( "Can't find node for " + options.shaderNodeName ).c_str() ); RiEnd(); return 0; } currentShader = liqShader( shaderObj ); shader_type_TempForRefactoring = currentShader.shader_type_ex; shaderFileName = currentShader.getShaderFileName(); } MFnDependencyNode assignedShader( shaderObj ); // Get the Pathes in globals node MObject globalObjNode; MString liquidShaderPath = "",liquidTexturePath = "",liquidProceduralPath = ""; MStatus status; MSelectionList globalList; // get the current project directory MString MELCommand = "workspace -q -rd"; MString MELReturn; MGlobal::executeCommand( MELCommand, MELReturn ); MString liquidProjectDir = MELReturn; status = globalList.add( "liquidGlobals" ); if ( globalList.length() > 0 ) { status.clear(); status = globalList.getDependNode( 0, globalObjNode ); MFnDependencyNode globalNode( globalObjNode ); liquidGetPlugValue( globalNode, "shaderPath", liquidShaderPath, status); liquidGetPlugValue( globalNode, "texturePath", liquidTexturePath, status); liquidGetPlugValue( globalNode, "proceduralPath", liquidProceduralPath, status); } if( fileName.empty() ) { RiBegin_liq( NULL ); #ifdef DELIGHT //RtPointer callBack( progressCallBack ); //RiOption( "statistics", "progresscallback", &callBack, RI_NULL ); #endif } else { liquidMessage2(messageInfo,"preview rib file: [%s]", fileName.c_str()); RiBegin_liq( (RtToken)fileName.c_str() ); } std::string liquidHomeDir = liquidSanitizeSearchPath( getEnvironment( "LIQUIDHOME" ) ); std::string shaderPath( "&:@:.:~:" + liquidHomeDir + "/lib/shaders" ); std::string texturePath( "&:@:.:~:" + liquidHomeDir + "/lib/textures" ); std::string proceduralPath( "&:@:.:~:" + liquidHomeDir + "/lib/shaders" ); std::string projectDir = std::string( liquidSanitizeSearchPath( liquidProjectDir ).asChar() ); if ( liquidProjectDir != "") { shaderPath += ":" + projectDir; texturePath += ":" + projectDir; proceduralPath += ":" + projectDir; } if ( liquidShaderPath != "" ) shaderPath += ":" + std::string( liquidSanitizeSearchPath( parseString( liquidShaderPath, false ) ).asChar()); if ( liquidTexturePath != "" ) texturePath += ":" + std::string( liquidSanitizeSearchPath( parseString( liquidTexturePath, false) ).asChar()); if ( liquidProceduralPath != "" ) proceduralPath += ":" + std::string( liquidSanitizeSearchPath( parseString( liquidProceduralPath, false) ).asChar()); RtString list( const_cast< RtString >( shaderPath.c_str() ) ); RiOption( "searchpath", "shader", &list, RI_NULL ); RtString texPath( const_cast< RtString >( texturePath.c_str() ) ); if( texPath[ 0 ] ) RiOption( "searchpath","texture", &texPath, RI_NULL ); RtString procPath( const_cast< RtString >( proceduralPath.c_str() ) ); if( procPath[ 0 ] ) RiOption( "searchpath","procedural", &procPath, RI_NULL ); RiShadingRate( ( RtFloat )options.shadingRate ); RiPixelSamples( options.pixelSamples, options.pixelSamples ); #ifdef PRMAN if ( MString( "PRMan" ) == liqglo.liquidRenderer.renderName ) RiPixelFilter( RiCatmullRomFilter, 4., 4. ); #elif defined( DELIGHT ) if ( MString( "3Delight" ) == liqglo.liquidRenderer.renderName ) RiPixelFilter( RiSeparableCatmullRomFilter, 4., 4. ); // RiPixelFilter( RiMitchellFilter, 4., 4.); #else RiPixelFilter( RiCatmullRomFilter, 4., 4. ); #endif RiFormat( ( RtInt )options.displaySize, ( RtInt )options.displaySize, 1.0 ); if( options.backPlane ) { RiDisplay( const_cast< RtString >( options.displayName.c_str() ), const_cast< RtString >( options.displayDriver.c_str() ), RI_RGB, RI_NULL ); } else { // Alpha might be useful RiDisplay( const_cast< RtString >( options.displayName.c_str() ), const_cast< RtString >( options.displayDriver.c_str() ), RI_RGBA, RI_NULL ); } RtFloat fov( 22.5 ); RiProjection( "perspective", "fov", &fov, RI_NULL ); RiTranslate( 0, 0, 2.75 ); RiExposure(1, currentShader.m_previewGamma); RtInt visible = 1; RtString transmission = "transparent"; RiAttribute( "visibility", ( RtToken ) "camera", &visible, RI_NULL ); RiAttribute( "visibility", ( RtToken ) "trace", &visible, RI_NULL ); // RiAttribute( "visibility", ( RtToken ) "transmission", ( RtPointer ) &transmission, RI_NULL ); RiWorldBegin(); RiReverseOrientation(); RiTransformBegin(); RiRotate( -90., 1., 0., 0. ); RiCoordinateSystem( "_environment" ); RiTransformEnd(); RtLightHandle ambientLightH, directionalLightH; RtFloat intensity; intensity = 0.05 * (RtFloat)options.previewIntensity; ambientLightH = RiLightSource( "ambientlight", "intensity", &intensity, RI_NULL ); intensity = 0.9 * (RtFloat)options.previewIntensity; RtPoint from; RtPoint to; from[0] = -1.; from[1] = 1.5; from[2] = -1.; to[0] = 0.; to[1] = 0.; to[2] = 0.; RiTransformBegin(); RiRotate( 55., 1, 0, 0 ); RiRotate( 30., 0, 1, 0 ); directionalLightH = RiLightSource( "liquiddistant", "intensity", &intensity, RI_NULL ); RiTransformEnd(); intensity = 0.2f * (RtFloat)options.previewIntensity; from[0] = 1.3f; from[1] = -1.2f; from[2] = -1.; RiTransformBegin(); RiRotate( -50., 1, 0, 0 ); RiRotate( -40., 0, 1, 0 ); directionalLightH = RiLightSource( "liquiddistant", "intensity", &intensity, RI_NULL ); RiTransformEnd(); RiAttributeBegin(); //ymesh omit this section, because liqShader::writeRibAttributes() do this work in that branch //I don't use liqShader::writeRibAttributes(), so I use this section. -yayansi float displacementBounds = 0.; liquidGetPlugValue( assignedShader, "displacementBound", displacementBounds, status); if ( displacementBounds > 0. ) { RtString coordsys = "shader"; RiArchiveRecord( RI_COMMENT, "ymesh omit this section, because liqShader::writeRibAttributes do this work in that branch" ); RiAttribute( "displacementbound", "coordinatesystem", &coordsys, RI_NULL ); RiAttribute( "displacementbound", "sphere", &displacementBounds, "coordinatesystem", &coordsys, RI_NULL ); } //LIQ_GET_SHADER_FILE_NAME( shaderFileName, options.shortShaderName, currentShader ); // output shader space MString shadingSpace; liquidGetPlugValue( assignedShader, "shaderSpace", shadingSpace, status); if ( shadingSpace != "" ) { RiTransformBegin(); RiCoordSysTransform( (char*) shadingSpace.asChar() ); } RiTransformBegin(); // Rotate shader space to make the preview more interesting RiRotate( 60., 1., 0., 0. ); RiRotate( 60., 0., 1., 0. ); RtFloat scale( 1.f / ( RtFloat )options.objectScale ); RiScale( scale, scale, scale ); if ( shader_type_TempForRefactoring=="surface" || shader_type_TempForRefactoring=="shader"/*currentShader.shader_type == SHADER_TYPE_SURFACE || currentShader.shader_type == SHADER_TYPE_SHADER */ ) // [2/14/2012 yaoyansi] { RiColor( currentShader.rmColor ); RiOpacity( currentShader.rmOpacity ); //cout << "Shader: " << shaderFileName << endl; if ( options.fullShaderPath ) RiSurface( (RtToken)shaderFileName.c_str(), RI_NULL ); else { liqShader liqAssignedShader( shaderObj ); liqAssignedShader.forceAs = SHADER_TYPE_SURFACE; liqAssignedShader.write(); } } else if ( shader_type_TempForRefactoring=="displacement"/*currentShader.shader_type == SHADER_TYPE_DISPLACEMENT*/ ) // [2/14/2012 yaoyansi] { RtToken Kd( "Kd" ); RtFloat KdValue( 1. ); #ifdef GENERIC_RIBLIB // !!! current ribLib has wrong interpretation of RiSurface parameters RiSurface( "plastic", Kd, &KdValue, RI_NULL ); #else RiSurface( "plastic", &Kd, &KdValue, RI_NULL ); #endif if ( options.fullShaderPath ) RiDisplacement( (RtToken)shaderFileName.c_str(), RI_NULL ); else { liqShader liqAssignedShader( shaderObj ); liqAssignedShader.forceAs = SHADER_TYPE_DISPLACEMENT; liqAssignedShader.write(); } } RiTransformEnd(); if ( shadingSpace != "" ) RiTransformEnd(); switch( options.primitiveType ) { case CYLINDER: { RiReverseOrientation(); RiScale( 0.95, 0.95, 0.95 ); RiRotate( 60., 1., 0., 0. ); RiTranslate( 0., 0., -0.05 ); RiCylinder( 0.5, -0.3, 0.3, 360., RI_NULL ); RiTranslate( 0., 0., 0.3f ); RiTorus( 0.485, 0.015, 0., 90., 360., RI_NULL ); RiDisk( 0.015, 0.485, 360., RI_NULL ); RiTranslate( 0., 0., -0.6 ); RiTorus( 0.485, 0.015, 270., 360., 360., RI_NULL ); RiReverseOrientation(); RiDisk( -0.015, 0.485, 360., RI_NULL ); break; } case TORUS: { RiRotate( 45., 1., 0., 0. ); RiTranslate( 0., 0., -0.05 ); RiReverseOrientation(); RiTorus( 0.3f, 0.2f, 0., 360., 360., RI_NULL ); break; } case PLANE: { RiScale( 0.5, 0.5, 0.5 ); RiReverseOrientation(); static RtPoint plane[4] = { { -1., 1., 0. }, { 1., 1., 0. }, { -1., -1., 0. }, { 1., -1., 0. } }; RiPatch( RI_BILINEAR, RI_P, (RtPointer) plane, RI_NULL ); break; } case TEAPOT: { RiTranslate( 0.06f, -0.18f, 0. ); RiRotate( -120., 1., 0., 0. ); RiRotate( 130., 0., 0., 1. ); RiScale( 0.2f, 0.2f, 0.2f ); RiArchiveRecord( RI_VERBATIM, "Geometry \"teapot\"" ); break; } case CUBE: { /* Lovely cube with rounded corners and edges */ RiScale( 0.35f, 0.35f, 0.35f ); RiRotate( 60., 1., 0., 0. ); RiRotate( 60., 0., 0., 1. ); RiTranslate( 0.11f, 0., -0.08f ); RiReverseOrientation(); static RtPoint top[ 4 ] = { { -0.95, 0.95, -1. }, { 0.95, 0.95, -1. }, { -0.95, -0.95, -1. }, { 0.95, -0.95, -1. } }; RiPatch( RI_BILINEAR, RI_P, ( RtPointer ) top, RI_NULL ); static RtPoint bottom[ 4 ] = { { 0.95, 0.95, 1. }, { -0.95, 0.95, 1. }, { 0.95, -0.95, 1. }, { -0.95, -0.95, 1. } }; RiPatch( RI_BILINEAR, RI_P, ( RtPointer ) bottom, RI_NULL ); static RtPoint right[ 4 ] = { { -0.95, -1., -0.95 }, { 0.95, -1., -0.95 }, { -0.95, -1., 0.95 }, { 0.95, -1., 0.95 } }; RiPatch( RI_BILINEAR, RI_P, ( RtPointer ) right, RI_NULL ); static RtPoint left[ 4 ] = { { 0.95, 1., -0.95 }, { -0.95, 1., -0.95 }, { 0.95, 1., 0.95 }, { -0.95, 1., 0.95 } }; RiPatch( RI_BILINEAR, RI_P, ( RtPointer ) left, RI_NULL ); static RtPoint front[ 4 ] = { {-1., 0.95, -0.95 }, { -1., -0.95, -0.95 }, { -1., 0.95, 0.95 }, { -1., -0.95, 0.95 } }; RiPatch( RI_BILINEAR, RI_P, ( RtPointer ) front, RI_NULL ); static RtPoint back[ 4 ] = { { 1., -0.95, -0.95 }, { 1., 0.95, -0.95 }, { 1., -0.95, 0.95 }, { 1., 0.95, 0.95 } }; RiPatch( RI_BILINEAR, RI_P, ( RtPointer ) back, RI_NULL ); RiTransformBegin(); RiTranslate( 0.95, 0.95, 0. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0.95, -0.95, 0. ); RiRotate( -90., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( -0.95, 0.95, 0. ); RiRotate( 90., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( -0.95, -0.95, 0. ); RiRotate( 180., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0., 0., 0.95 ); RiTransformBegin(); RiTransformBegin(); RiTranslate( 0.95, 0.95, 0. ); RiSphere( 0.05, 0., 0.05, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0.95, -0.95, 0. ); RiRotate( -90., 0., 0., 1. ); RiSphere( 0.05, 0., 0.05, 90., RI_NULL ); RiTransformEnd(); RiRotate( 180., 0., 0., 1. ); RiTransformBegin(); RiTranslate( 0.95, 0.95, 0. ); RiSphere( 0.05, 0., 0.05, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0.95, -0.95, 0. ); RiRotate( -90., 0., 0., 1. ); RiSphere( 0.05, 0., 0.05, 90., RI_NULL ); RiTransformEnd(); RiTransformEnd(); RiRotate( 90., 1., 0., 0. ); RiTransformBegin(); RiTranslate( 0.95, 0., 0. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( -0.95, 0., 0. ); RiRotate( 90., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiRotate( 90., 0., 1., 0. ); RiTransformBegin(); RiTranslate( 0.95, 0., 0. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( -0.95, 0., 0. ); RiRotate( 90., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0., 0., -0.95 ); RiTransformBegin(); RiTransformBegin(); RiTranslate( 0.95, 0.95, 0. ); RiSphere( 0.05, -0.05, 0., 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0.95, -0.95, 0. ); RiRotate( -90., 0., 0., 1. ); RiSphere( 0.05, -0.05, 0., 90., RI_NULL ); RiTransformEnd(); RiRotate( 180., 0., 0., 1. ); RiTransformBegin(); RiTranslate( 0.95, 0.95, 0. ); RiSphere( 0.05, -0.05, 0., 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0.95, -0.95, 0. ); RiRotate( -90., 0., 0., 1. ); RiSphere( 0.05, -0.05, 0., 90., RI_NULL ); RiTransformEnd(); RiTransformEnd(); RiRotate( 90., 1., 0., 0. ); RiTransformBegin(); RiTranslate( -0.95, 0., 0. ); RiRotate( 180., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( 0.95, 0., 0. ); RiRotate( -90., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiRotate( 90., 0., 1., 0. ); RiTransformBegin(); RiTranslate( 0.95, 0., 0. ); RiRotate( -90., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformBegin(); RiTranslate( -0.95, 0., 0. ); RiRotate( 180., 0., 0., 1. ); RiCylinder( 0.05, -0.95, 0.95, 90., RI_NULL ); RiTransformEnd(); RiTransformEnd(); break; } case CUSTOM: { //cout <<"custom : "<<options.customRibFile<<endl; if ( fileExists( options.customRibFile.c_str() ) ) { RiReadArchive( const_cast< RtToken >( options.customRibFile.c_str() ), NULL, RI_NULL ); } break; } case SPHERE: default: { RiRotate( 60., 1., 0., 0. ); RiReverseOrientation(); RiSphere( 0.5, -0.5, 0.5, 360., RI_NULL ); break; } } RiAttributeEnd(); /* * Backplane */ if( options.backPlane ) { if ( options.customBackplane.empty() ) { RiAttributeBegin(); RiScale( 0.91, 0.91, 0.91 ); if( MString("displacement")==shader_type_TempForRefactoring/*SHADER_TYPE_DISPLACEMENT == currentShader.shader_type*/ ) // [2/14/2012 yaoyansi] { RtColor bg = { 0.698, 0.698, 0. }; RiColor( bg ); } else RiSurface( const_cast< RtToken >( options.backPlaneShader.c_str() ), RI_NULL ); static RtPoint backplane[4] = { { -1., 1., 2. }, { 1., 1., 2. }, { -1., -1., 2. }, { 1., -1., 2. } }; RiPatch( RI_BILINEAR, RI_P, (RtPointer) backplane, RI_NULL ); RiAttributeEnd(); } else { if ( fileExists( options.customBackplane.c_str() ) ) { RiAttributeBegin(); RiScale( 1., 1., -1. ); RiReadArchive( const_cast< RtString >( options.customBackplane.c_str() ), NULL, RI_NULL ); RiAttributeEnd(); } } } RiWorldEnd(); /* this caused maya to hang up under windoof - Alf #ifdef _WIN32 // Wait until the renderer is done while( !fileFullyAccessible( options.displayName.c_str() ) ); #endif */ RiEnd(); if(liqglo.m_logMsgFlush) { fflush( NULL ); } }
int main(int argc, char *argv[]) { if (argc < 2) { printf("Not enough arguments given!\n"); return 1; } else if (argc > 2) { printf("Too many arguments given!\n"); return 1; } char *fprefix = argv[1]; srand(time(NULL)); const size_t NUM_FRAMES = 120; RtInt md = 4; scene_info_t scene; double rad = 55.0; double t = 0.0; const double tmin = 0.0; const double tmax = 2.0*PI; double dt = (tmax-tmin)/NUM_FRAMES; size_t fnum; RiBegin(RI_NULL); RiOption("trace", "maxdepth", &md, RI_NULL); RiSides(1); scene.cam.location[0] = rad; scene.cam.location[1] = rad; scene.cam.location[2] = rad; scene.cam.look_at[0]= 0.0; scene.cam.look_at[1]= 0.0; scene.cam.look_at[2]= 0.0; scene.cam.roll = 0.0; scene.fprefix = fprefix; const size_t NUM_POINTS = 100000000; RtPoint *pts = malloc(sizeof(RtPoint)* NUM_POINTS); randomPoint2D(pts[0]); /* pts[0][2] = 0.0; */ /* RtFloat mats[][3][3] = {{{0.0,0.0,0.0}, */ /* {0.0,0.16,0.0}, */ /* {0.0,0.0,1.0}}, */ /* {{0.85, 0.04, 0.0}, */ /* {-0.04, 0.85, 0.0}, */ /* {0.0,0.0,1.0}}, */ /* {{0.20,-0.26, 0.0}, */ /* {0.23, 0.22, 0.0}, */ /* {0.0,0.0,1.0}}, */ /* {{-0.15, 0.28,0.0}, */ /* {0.26, 0.24, 0.0}, */ /* {0.0,0.0,1.0}}, */ /* }; */ RtFloat mats[][3][3] = {{{0.34,0.0,0.0}, {0.0,0.34,0.0}, {0.0,0.0,0.34}}, {{0.34,0.0,0.0}, {0.0,0.34,0.0}, {0.0,0.0,0.34}}, {{0.34,0.0,0.0}, {0.0,0.34,0.0}, {0.0,0.0,0.34}}, {{0.34,0.0,0.0}, {0.0,0.34,0.0}, {0.0,0.0,0.34}}, {{0.34,0.0,0.0}, {0.0,0.34,0.0}, {0.0,0.0,0.34}}, {{0.34,0.0,0.0}, {0.0,0.34,0.0}, {0.0,0.0,0.34}}, {{0.34,0.0,0.0}, {0.0,0.34,0.0}, {0.0,0.0,0.34}}, }; RtPoint offsets[] = {{0.0,0.0,0.66}, {0.0,0.0,-0.66}, {0.0,0.0,0.0}, {0.66,0.0,0.0}, {-0.66,0.0,0.0}, {0.0,0.66, 0.0}, {0.0,-0.66, 0.0}, }; RtFloat probs[] = {0.14285714285714285, 0.14285714285714285, 0.14285714285714285, 0.14285714285714285, 0.14285714285714285, 0.14285714285714285, 0.14285714285714285, }; for (size_t i=0; i<NUM_POINTS-1; ++i) { ifs(7, mats, offsets, probs, pts[i], pts[i+1]); } for (fnum = 0; fnum < NUM_FRAMES; ++fnum) { scene.cam.location[0] = rad*sin(t); scene.cam.location[1] = rad; scene.cam.location[2] = rad*cos(t); /* scene.cam.look_at[1] = rad; */ t += dt; printf("Rendering frame %lu\n", (unsigned long)fnum); RtInt on = 1; char buffer[256]; RtString on_string = "on"; RtInt samples = 2; RtPoint light1Pos = {80,80,80}; RtPoint light2Pos = {0,120,0}; RtPoint light3Pos = {0,40,0}; /* RiImager("background", RI_NULL); */ RiFrameBegin(fnum); sprintf(buffer, "images/%s%05lu.jpg", scene.fprefix, (unsigned long)fnum); RiDisplay(buffer,(char*)"jpeg",(char*)"rgb",RI_NULL); RiFormat(1280, 720, 1.0); RiProjection((char*)"perspective",RI_NULL); PlaceCamera(&scene.cam); RiShadingRate(1.0); RiShadingInterpolation("smooth"); /* RtFloat bound = 0.125; */ /* char *space = "object"; */ /* RiAttribute ("displacementbound", "sphere", (RtPointer)&bound, "space", (RtPointer)&space, RI_NULL); */ /* RiAttribute("visibility", "int trace", &on, RI_NULL); */ /* RiAttribute( "visibility", */ /* "int camera", (RtPointer)&on, */ /* "int transmission", (RtPointer)&on, */ /* "int diffuse", (RtPointer)&on, */ /* "int specular", (RtPointer)&on, */ /* "int photon", (RtPointer)&on, */ /* RI_NULL ); */ /* RiAttribute( "light", (RtToken)"shadows", (RtPointer)&on_string, (RtToken)"samples", (RtPointer)&samples, RI_NULL ); */ RiAttribute((RtToken)"light", "string shadow", (RtPointer)&on_string, RI_NULL); RiLightSource("distantlight", "point from", (RtPointer)light1Pos, RI_NULL); RiLightSource("distantlight", "point from", (RtPointer)light2Pos, RI_NULL); /* RiLightSource("pointlight", "point from", (RtPointer)light3Pos, RI_NULL); */ RiWorldBegin(); RiAttributeBegin(); /* RtColor col = {((double)fnum)/NUM_FRAMES,1.0-((double)fnum)/NUM_FRAMES,0.0}; */ RtColor col = {0.0,1.0,0.0}; RiSurface((char*)"matte", RI_NULL); /* RtColor opa = {0.8,0.8,0.8}; */ /* RiOpacity(opa); */ /* RtFloat km = 0.125; */ /* RiDisplacement((char*)"stucco", (RtToken)"Km", (RtPointer)&km, RI_NULL); */ RiColor(col); /* RtColor opa = {0.75,0.75,0.75}; */ /* RiOpacity(opa); */ RiScale(50.0,50.0,50.0); RtFloat cw = 0.0005; RiPoints(NUM_POINTS, "type", "particles", "constantwidth", &cw, RI_P, pts, RI_NULL); /* RiSphere(0.2,-0.2,0.2,360.0, RI_NULL); */ RiAttributeEnd(); RiWorldEnd(); RiFrameEnd(); } RiEnd(); return 0; }
void doFrame(int fNum, scene_info_t *scene) { RiFrameBegin(fNum); char buffer[256]; sprintf(buffer, "images/%s%05d.tif", scene->fprefix, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); /* RiTranslate(scene->x_trans, scene->y_trans, scene->z_trans); */ /* RiRotate( scene->x_rotation, 1.0, 0.0, 0.0); */ /* RiRotate( scene->y_rotation, 0.0, 1.0, 0.0); */ /* RiRotate( scene->z_rotation, 0.0, 0.0, 1.0); */ PlaceCamera(&scene->cam); RiWorldBegin(); RiSurface((char*)"matte", RI_NULL); const size_t NUM_I = 256; const size_t NUM_J = 256; RtPoint *pts = malloc(sizeof(RtPoint)*NUM_I*NUM_J); RtColor *colors = malloc(sizeof(RtPoint)*NUM_I*NUM_J); double umin = -4*PI; double umax = 4*PI; double vmin = -4*PI; double vmax = 4*PI; double du = (umax - umin)/(NUM_J-1); double dv = (vmax - vmin)/(NUM_I-1); double u = umin; for (size_t i=0; i< NUM_I; ++i) { double v = vmin; for (size_t j=0; j < NUM_J; ++j) { pts[i*NUM_J + j][0] = x(u,v); pts[i*NUM_J + j][1] = z(u,v); pts[i*NUM_J + j][2] = y(u,v); colors[i*NUM_J + j][0] = r(u,v); colors[i*NUM_J + j][1] = g(u,v); colors[i*NUM_J + j][2] = b(u,v); /* RiTransformBegin(); */ /* RiTranslate(x(u,v), y(u,v), z(u,v)); */ /* RiSphere(du, -du, du, 360.0, RI_NULL); */ /* RiTransformEnd(); */ v += dv; } u += du; } RtInt npolys = 2*(NUM_J+1)*(NUM_I+1); RtInt *nvertices = malloc(sizeof(RtInt) * npolys); for (size_t i=0; i<npolys; ++i) { nvertices[i] = 3; } RtInt *vertices = malloc(sizeof(RtInt)*3*npolys); size_t curIdx = 0; for (size_t i = 0; i<(NUM_I-1); ++i) { for (size_t j=0; j<(NUM_J-1); ++j) { vertices[curIdx] = j*NUM_I + i; vertices[curIdx+1] = (j+1)*NUM_I + i; vertices[curIdx+2] = j*NUM_I + i+1; vertices[curIdx+3] = (j+1)*NUM_I + i; vertices[curIdx+4] = (j+1)*NUM_I + (i+1); vertices[curIdx+5] = j*NUM_I + (i+1); curIdx += 6; } } RiPointsPolygons(curIdx/3, nvertices, vertices, "P", pts, "Cs", colors, RI_NULL); /* RiSphere(10.0, -10.0, 10.0, 360.0); */ free(vertices); free(nvertices); free(colors); free(pts); RiWorldEnd(); RiFrameEnd(); }
void doFrame(int fNum, char *fName) { RiFrameBegin(fNum); static RtColor Color = {.2, .4, .6} ; char buffer[256]; sprintf(buffer, "images/%s%03d.tif", fName, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); RiTranslate(0.0,0.0,50); // RiRotate(-40.0, 1.0,0.0,0.0); // RiRotate(-20.0, 0.0,1.0,0.0); RiWorldBegin(); RiColor(Color); RiRotate(fNum, 0.0,1.0,0.0); RtFloat roughness = 0.03; int trace = 1; //RtFloat km = .3; //RtFloat maxKm = 1.0; RtFloat opac[] = {0.5, 0.9, 0.3}; // RiBasis(RiBezierBasis, 3, RiBezierBasis, 3); //km = abs(sin(2.0*PI*((double)fNum/100.0))); // RiSurface((char*)"funkyglass", "roughness", (RtPointer)&roughness, RI_NULL); // RiOpacity(opac); // RiAttribute((char*)"visibility", "int trace", &trace, RI_NULL); RiSurface((char*)"matte", RI_NULL); RiSolidBegin("difference"); // RiTranslate(15,0,0); // RiSolidBegin("primitive"); // RiSphere(10, -10, 10, 360, RI_NULL); // RiSolidEnd(); double t=-PI; int steps = 8; double dt = (2*PI)/steps; RiSolidBegin("primitive"); double rad=5.0; for (int ti=0; ti<steps; ++ti) { RiTransformBegin(); RiTranslate(xv(t),yv(t),0); // RiSolidBegin("primitive"); RiSphere(rad, -rad, rad, 360, RI_NULL); // RiSolidEnd(); RiTransformEnd(); t += dt; } for (int ti=0; ti<steps; ++ti) { RiTransformBegin(); RiTranslate(0,xv(t),yv(t)); // RiSolidBegin("primitive"); RiSphere(rad, -rad, rad, 360, RI_NULL); // RiSolidEnd(); RiTransformEnd(); t += dt; } RiSolidEnd(); RiSolidBegin("primitive"); RiSphere(15, -15, 15, 360, RI_NULL); RiSolidEnd(); // RiTranslate(-30.0,-30.0,0); // RiSolidBegin("primitive"); // RiSphere(10, -10, 10, 360, RI_NULL); // RiSolidEnd(); // RiTranslate(15.0,-15.0,0); // RiSolidBegin("primitive"); // RiSphere(15, -15, 15, 360, RI_NULL); // RiSolidEnd(); RiSolidEnd(); RiWorldEnd(); RiFrameEnd(); }
void doFrame(int fNum, char *fName) { RtPoint points[4] = {-0.5,0,-0.5, -0.5,0,0.5, 0.5,0,0.5, 0.5,0,-0.5}; RiFrameBegin(fNum); { static RtColor Color = {.2, .4, .6} ; RtFloat radius=1.0, zmin = -1.0, zmax = 1.0, thetamax=360; char buffer[256]; std::sprintf(buffer, "images/%s%03d.tif", fName, fNum); // std::cout << buffer << "\n"; RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.3); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); RiTranslate(0.0,0.0,8.5); RiRotate(-40.0, 1.0,0.0,0.0); RiRotate(-40.0, 0.0,1.0,0.0); RtColor bgcolor = {0.9,0.9,0.9}; RiImager((char*)"background", (char*)"color bgcolor", &bgcolor, RI_NULL); RiWorldBegin(); { RiColor(Color); RtFloat roughness = 0.03; int trace = 1; //RtFloat km = .3; //RtFloat maxKm = 1.0; // RtFloat opac[] = {0.4,0.4,0.4}; RtFloat color[] = {0.9,0.9,0.9}; const char *texName = "texture2.tx"; RiColor(color); RiSurface((char*)"paintedplastic", (char*)"texturename", &texName, RI_NULL); RiRotate(fNum, 0,1,0); RiAttributeBegin(); { RiTranslate(-5.0,2.5,0.0); RiSphere(2.0,-2.0,2.0,360.0,RI_NULL); } RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(0.0,2.5,0.0); RiCylinder(2.0,-2.0,2.0,360.0,RI_NULL); }RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(5.0,2.5,0.0); RiCone(4.0,2.0,360.0,RI_NULL); } RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(-5.0,-2.5,0.0); RiParaboloid(4.0,0.0,4.0,360.0,RI_NULL); } RiAttributeEnd(); RtPoint p1 = {-1,-1,-4}; RtPoint p2 = {4,2,4}; RiAttributeBegin(); { RiTranslate(0.0,-2.5,0.0); RiHyperboloid(p1, p2, 360.0,RI_NULL); } RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(5.0,-2.5,0.0); RiTorus(2.0,0.5,0,360,360,RI_NULL); } RiAttributeEnd(); } RiWorldEnd(); } RiFrameEnd(); }