Exemplo n.º 1
0
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();
}
Exemplo n.º 2
0
void PlaceCamera(camera_t *cam)
{
    RtPoint direction;
    RiRotate(-cam->roll, 0.0, 0.0, 1.0);
    direction[0] = cam->look_at[0]-cam->location[0];
    direction[1] = cam->look_at[1]-cam->location[1];
    direction[2] = cam->look_at[2]-cam->location[2];
    AimZ(direction);
    RiTranslate(-cam->location[0], -cam->location[1], -cam->location[2]);
}
Exemplo n.º 3
0
/**
 * Display the scene in current window
 */
void display(void)
{
	const char *screenAction[2] = {"clear", "finish"};

	const char *matrixName[] = {"pre-camera"};
	RiIdentity();
	RiTranslate(0.0F,0.0F,sdepth); // Move back and forth
	RiTranslate(0, 0, 2.75);       // Move back to previous position
			
	// Rotation
	RiRotate(stheta, 1.0, 0.0, 0.0); // Rotate x
	RiRotate(-sphi, 0.0, 1.0, 0.0);  // Rotate y
			
	RiTranslate(0, 0, -2.75); // Move to a pivot
	RiCPPControl("state", "string store-transform", matrixName, RI_NULL); // Candidate for RiResource
	RiIdentity();

	// RiCPPControl("rib", "cache-file-archives", &noYes[1], RI_NULL);
	RiOption("glrenderer", RI_DISPXRES, &width, RI_DISPYRES, &height, RI_NULL);
	RiCPPControl("glrenderer", "screen", &screenAction[0], RI_NULL);
	RiAttribute("glrenderer", "draw-normals", &drawNormals, RI_NULL);
	    
	RiFormat(width, height, 1.0F);

	if ( storedArgc == 1 ) {
		RtFloat fov = 45.0;
		RiProjection(RI_PERSPECTIVE, RI_FOV, &fov, RI_NULL);
	}
	
	RiReadArchive("RIBARCHIVE", 0, RI_NULL);
	
	RiCPPControl("glrenderer", "screen", &screenAction[1], RI_NULL);
	// RiIdentity(); // done by restart

	// If double buffer
	glutSwapBuffers();

	RiSynchronize("restart");
}
Exemplo n.º 4
0
/*
 * AimZ(): rotate the world so the direction vector points in
 *  positive z by rotating about the y axis, then x. The cosine
 *  of each rotation is given by components of the normalized
 *  direction vector. Before the y rotation the direction vector
 *  might be in negative z, but not afterward.
 */
void AimZ(RtPoint direction)
{
    double xzlen, yzlen, yrot, xrot;

    if (direction[0]==0 && direction[1]==0 && direction[2]==0)
        return;

    /*
     * The initial rotation about the y axis is given by the projection of
     * the direction vector onto the x,z plane: the x and z components
     * of the direction.
     */
    xzlen = sqrt(direction[0]*direction[0]+direction[2]*direction[2]);
    if (xzlen == 0)
        yrot = (direction[1] < 0) ? 180.0 : 0.0;
    else
        yrot = 180.0*acos(direction[2]/xzlen)/PI;

    /*
     * The second rotation, about the x axis, is given by the projection on
     * the y,z plane of the y-rotated direction vector: the original y
     * component, and the rotated x,z vector from above.
     */
    yzlen = sqrt(direction[1]*direction[1]+xzlen*xzlen);
    xrot = 180*acos(xzlen/yzlen)/PI; /* yzlen should never be 0 */

    if (direction[1] > 0)
        RiRotate(xrot, 1.0, 0.0, 0.0);
    else
        RiRotate(-xrot, 1.0, 0.0, 0.0);

    /* The last rotation declared gets performed first */
    if (direction[0] > 0)
        RiRotate(-yrot, 0.0, 1.0, 0.0);
    else
        RiRotate(yrot, 0.0, 1.0, 0.0);
}
Exemplo n.º 5
0
void drawLamp(RtPoint position, RtFloat height) {
	/* Draw the base of the lamp */
	RiTransformBegin();
		RiTranslate(position[0], position[1] + 1, position[2]);
		RiRotate(90.0, 1.0, 0.0, 0.0);
		RiDisk(0.0, 4.0, 360.0, RI_NULL);
		RiCylinder(4.0, 0.0, 1.0, 360.0, RI_NULL);
	RiTransformEnd();

	/* Draw the stem of the lamp */
	RiTransformBegin();
		RiTranslate(position[0], position[1] + height + 1, position[2]);
		RiRotate(90.0, 1.0, 0.0, 0.0);
		RiCylinder(0.5, 0.0, height, 360.0, RI_NULL);
	RiTransformEnd();

	/* Draw the bell shaped part of the lamp */
	RiTransformBegin();
		RiTranslate(position[0], position[1] + height + 3, position[2]);
		RiRotate(100, 1.0, 0, 0);
		RiRotate(45, 0, 1.0, 0);
		RiParaboloid(4, 0, 6, 360, RI_NULL);
	RiTransformEnd();
}
Exemplo n.º 6
0
/**
 * Simple cone geometry
 */
void testCone()
{
	const RtFloat rad = 0.6F;
	const RtFloat height = 1.6F;
	RiAttributeBegin(); {
		RiSides(2);
		RiOrientation(RI_OUTSIDE);
		RiColor(blueish);
		RiTransformBegin(); {
			RiTranslate(0, -height/4.0F, 3);
			RiScale(1.0, 1.0, 1.0);
			RiRotate(-45, 1, 0, 0);
			RiCone(height, rad, 360, RI_NULL);
		} RiTransformEnd();
	} RiAttributeEnd();
}
Exemplo n.º 7
0
void PlaceCamera(camera_t *cam)
{
    RtPoint direction;
    /* RiIdentity(); */
    RiRotate(-cam->roll, 0.0, 0.0, 1.0);
    direction[0] = cam->look_at[0]-cam->location[0];
    direction[1] = cam->look_at[1]-cam->location[1];
    direction[2] = cam->look_at[2]-cam->location[2];
    double len = direction[0]*direction[0] + direction[1]*direction[1] + direction[2]*direction[2];
    len = sqrt(len);
    direction[0] *= 1.0/len;
    direction[1] *= 1.0/len;
    direction[2] *= 1.0/len;
    AimZ(direction);
    RiTranslate(-cam->location[0], -cam->location[1], -cam->location[2]);
}
Exemplo n.º 8
0
/**
 * Utah teapot, build-in geometry
 */
void testTeapot()
{
	RtObjectHandle handle = RiObjectBegin(); {
		RiGeometry(RI_TEAPOT, RI_NULL);
	} RiObjectEnd();

	RiAttributeBegin(); {
		RtFloat Cs[] = {0.33F, 0.33F, 1.0F};
		RiColor(Cs);
		RiTranslate(0, -.25, 2.75);
		RiScale(0.25F, 0.25F, 0.25F);
		RiRotate(-90, 1, 0, 0);
		RiSides(2);
		RiGeometricApproximation(RI_TESSELATION, 32);
		RiObjectInstance(handle);
	} RiAttributeEnd();
}
Exemplo n.º 9
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 );
  }
	}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
/**
 * Various polygon geometry interface calls
 */
void testPoly10()
{
	RtFloat p[] = {
		// outer
		-.5, -.5, 1, //  1
		-.5,  .5, 1, //  2
		.5,  .5, 1, //  3
		.5, -.5, 1, //  4
		0
	};
	RtInt nloops[] = {
		1
	};
	RtInt nverts[] = {
		4
	};
	RtInt verts[] = {
		0, 1, 2, 3
	};

	// Disable warnings (variable not used)
	opacity_25[0] = opacity_25[0]+0;
	opacity_50[0] = opacity_50[0]+0;
	opacity_75[0] = opacity_75[0]+0;

	RiAttributeBegin(); {
		RiTranslate(0, 0, 1.5);
		RiAttributeBegin(); {
			RiRotate(15.0, 0, 0, 1);
			RiOpacity(opacity_50);
			RiColor(greenish);

			// RiGeneralPolygon(nloops[0], nverts, RI_P, &p, RI_NULL);
			RiPolygon(4, RI_P, &p, RI_NULL);
			// RiPointsPolygons(1, nverts, verts, RI_P, &p, RI_NULL);
			// RiPointsGeneralPolygons(1, nloops, nverts, verts, RI_P, &p, RI_NULL);
	
#			if defined ( _TRACE )
			{
				RtInt i;
				RiTransformPoints(RI_CURRENT, RI_RASTER, sizeof(p)/sizeof(RtPoint), (RtPoint *)p);
				for ( i = 0; i < 4; ++i ) {
					printf("x %f, y %f, z %f\n", p[i*3+0], p[i*3+1], p[i*3+2]);
				}
				printf("Inverse\n");
				RiTransformPoints(RI_RASTER, RI_CURRENT, sizeof(p)/sizeof(RtPoint), (RtPoint *)p);
				for ( i = 0; i < 4; ++i ) {
					printf("x %f, y %f, z %f\n", p[i*3+0], p[i*3+1], p[i*3+2]);
				}
			}
#			endif
		} RiAttributeEnd();
	
		RiAttributeBegin(); {
			RiTranslate(0, 0, 0.2F);
			// RiOpacity(opacity_50);
			RiColor(redish);

			// RiGeneralPolygon(nloops[0], nverts, RI_P, &p, RI_NULL);
			// RiPolygon(4, RI_P, &p, RI_NULL);
			RiPointsPolygons(1, nverts, verts, RI_P, &p, RI_NULL);
			// RiPointsGeneralPolygons(1, nloops, nverts, verts, RI_P, &p, RI_NULL);
			
		} RiAttributeEnd();

		RiAttributeBegin(); {
			RiRotate(-15.0F, 0, 0, 1);
			RiTranslate(0, 0, 0.3F);
			RiOpacity(opacity_75);
			RiColor(blueish);

			// RiGeneralPolygon(nloops[0], nverts, RI_P, &p, RI_NULL);
			// RiPolygon(4, RI_P, &p, RI_NULL);
			// RiPointsPolygons(1, nverts, verts, RI_P, &p, RI_NULL);
			RiPointsGeneralPolygons(1, nloops, nverts, verts, RI_P, &p, RI_NULL);
			
		} RiAttributeEnd();

	} RiAttributeEnd();
}
Exemplo n.º 12
0
//-*****************************************************************************
void ProcessXform( IXform &xform, ProcArgs &args )
{
    IXformSchema &xs = xform.getSchema();

    TimeSamplingPtr ts = xs.getTimeSampling();

    size_t xformSamps = xs.getNumSamples();

    SampleTimeSet sampleTimes;
    GetRelevantSampleTimes( args, ts, xformSamps, sampleTimes );

    bool multiSample = sampleTimes.size() > 1;

    std::vector<XformSample> sampleVectors;
    sampleVectors.resize( sampleTimes.size() );

    //fetch all operators at each sample time first
    size_t sampleTimeIndex = 0;
    for ( SampleTimeSet::iterator I = sampleTimes.begin();
          I != sampleTimes.end(); ++I, ++sampleTimeIndex )
    {
        ISampleSelector sampleSelector( *I );

        xs.get( sampleVectors[sampleTimeIndex], sampleSelector );
    }

    if (xs.getInheritsXforms () == false)
    {
        RiIdentity ();
    }

    //loop through the operators individually since a MotionBegin block
    //can enclose only homogenous statements
    for ( size_t i = 0, e = xs.getNumOps(); i < e; ++i )
    {
        if ( multiSample ) { WriteMotionBegin(args, sampleTimes); }

        for ( size_t j = 0; j < sampleVectors.size(); ++j )
        {
            XformOp &op = sampleVectors[j][i];

            switch ( op.getType() )
            {
            case kScaleOperation:
            {
                V3d value = op.getScale();
                RiScale( value.x, value.y, value.z );
                break;
            }
            case kTranslateOperation:
            {
                V3d value = op.getTranslate();
                RiTranslate( value.x, value.y, value.z );
                break;
            }
            case kRotateOperation:
            case kRotateXOperation:
            case kRotateYOperation:
            case kRotateZOperation:
            {
                V3d axis = op.getAxis();
                float degrees = op.getAngle();
                RiRotate( degrees, axis.x, axis.y, axis.z );
                break;
            }
            case kMatrixOperation:
            {
                WriteConcatTransform( op.getMatrix() );
                break;
            }
            }
        }

        if ( multiSample ) { RiMotionEnd(); }
    }
}
Exemplo n.º 13
0
/**
 * NURBS vase from Larry Gritz BMRT
 */
void testVase()
{
    static RtFloat vaseMesh[] = { // Data copied from BMRT
        0.0F, 0.0F, 0.0F, 0.869825F, 0.0F, 0.0F, 0.0F, 0.902369F, 0.0F, 0.0F, 0.0F, 1.0F,
		0.0F, 0.0F, 0.0F, 0.707107F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.707107F,
		0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.707107F, 0.0F, 0.0F, 0.0F, 1.0F,
		0.0F, 0.0F, 0.0F, 0.804738F, 0.0F, 0.0F, 0.0F, 0.869825F,
        2.1269F, 3.79357F, 0.0F, 0.869825F, 1.17851F, 4.51184F, 0.0F, 0.902369F, 0.0F, 5.0F, 0.0F, 1.0F, -3.53553F, 3.53553F, 0.0F, 0.707107F, -5.0F, 3.06152e-016F, 0.0F, 1.0F, -3.53553F, -3.53553F, 0.0F,
        0.707107F, -6.12303e-016F, -5.0F, 0.0F, 1.0F, 3.53553F, -3.53553F, 0.0F, 0.707107F, 5.0F, -9.18455e-016F, 0.0F, 1.0F, 4.02369F, 2.35702F, 0.0F, 0.804738F, 2.1269F, 3.79357F, 0.0F, 0.869825F,
        12.1872F, 21.7372F, 0.0F, 4.9841F, 6.75287F, 25.8529F, 0.0F, 5.17057F, 0.0F, 28.65F, 0.0F, 5.73F, -20.2586F, 20.2586F, 0.0F, 4.05172F, -28.65F, 1.75425e-015F, 0.0F, 5.73F, -20.2586F,
        -20.2586F, 0.0F, 4.05172F, -3.5085e-015F, -28.65F, 0.0F, 5.73F, 20.2586F, -20.2586F, 0.0F, 4.05172F, 28.65F, -5.26275e-015F, 0.0F, 5.73F, 23.0557F, 13.5057F, 0.0F, 4.61115F, 12.1872F,
        21.7372F, 0.0F, 4.9841F, 2.1269F, 3.79357F, 0.260948F, 0.869825F, 1.17851F, 4.51184F, 0.270711F, 0.902369F, 0.0F, 5.0F, 0.3F, 1.0F, -3.53553F, 3.53553F, 0.212132F, 0.707107F, -5.0F,
        3.06152e-016F, 0.3F, 1.0F, -3.53553F, -3.53553F, 0.212132F, 0.707107F, -6.12303e-016F, -5.0F, 0.3F, 1.0F, 3.53553F, -3.53553F, 0.212132F, 0.707107F, 5.0F, -9.18455e-016F, 0.3F, 1.0F,
        4.02369F, 2.35702F, 0.241421F, 0.804738F, 2.1269F, 3.79357F, 0.260948F, 0.869825F, 6.38071F, 11.3807F, 0.782843F, 2.60948F, 3.53553F, 13.5355F, 0.812132F, 2.70711F, 0.0F,
        15.0F, 0.9F, 3.0F, -10.6066F, 10.6066F, 0.636396F, 2.12132F, -15.0F, 9.18455e-016F, 0.9F, 3.0F, -10.6066F, -10.6066F, 0.636396F, 2.12132F, -1.83691e-015F, -15.0F, 0.9F, 3.0F, 10.6066F,
        -10.6066F, 0.636396F, 2.12132F, 15.0F, -2.75536e-015F, 0.9F, 3.0F, 12.0711F, 7.07107F, 0.724264F, 2.41421F, 6.38071F, 11.3807F, 0.782843F, 2.60948F, 2.72244F, 4.85577F,
        2.0006F, 0.869825F, 1.50849F, 5.77516F, 2.07545F, 0.902369F, 0.0F, 6.4F, 2.3F, 1.0F, -4.52548F, 4.52548F, 1.62635F, 0.707107F, -6.4F, 3.91874e-016F, 2.3F, 1.0F, -4.52548F, -4.52548F,
        1.62635F, 0.707107F, -7.83748e-016F, -6.4F, 2.3F, 1.0F, 4.52548F, -4.52548F, 1.62635F, 0.707107F, 6.4F, -1.17562e-015F, 2.3F, 1.0F, 5.15032F, 3.01699F, 1.8509F, 0.804738F,
        2.72244F, 4.85577F, 2.0006F, 0.869825F, 2.97767F, 5.311F, 4.34913F, 0.869825F, 1.64992F, 6.31658F, 4.51184F, 0.902369F, 0.0F, 7.0F, 5.0F, 1.0F, -4.94975F, 4.94975F, 3.53553F,
        0.707107F, -7.0F, 4.28612e-016F, 5.0F, 1.0F, -4.94975F, -4.94975F, 3.53553F, 0.707107F, -8.57224e-016F, -7.0F, 5.0F, 1.0F, 4.94975F, -4.94975F, 3.53553F, 0.707107F, 7.0F, -1.28584e-015F, 5.0F,
        1.0F, 5.63316F, 3.29983F, 4.02369F, 0.804738F, 2.97767F, 5.311F, 4.34913F, 0.869825F, 2.55228F, 4.55228F, 6.9586F, 0.869825F, 1.41421F, 5.41421F, 7.21895F, 0.902369F, 0.0F, 6.0F, 8.0F,
        1.0F, -4.24264F, 4.24264F, 5.65685F, 0.707107F, -6.0F, 3.67382e-016F, 8.0F, 1.0F, -4.24264F, -4.24264F, 5.65685F, 0.707107F, -7.34764e-016F, -6.0F, 8.0F, 1.0F, 4.24264F, -4.24264F, 5.65685F,
        0.707107F, 6.0F, -1.10215e-015F, 8.0F, 1.0F, 4.82843F, 2.82843F, 6.4379F, 0.804738F, 2.55228F, 4.55228F, 6.9586F, 0.869825F, 1.27614F, 2.27614F, 8.69825F, 0.869825F, 0.707107F,
        2.70711F, 9.02369F, 0.902369F, 0.0F, 3.0F, 10.0F, 1.0F, -2.12132F, 2.12132F, 7.07107F, 0.707107F, -3.0F, 1.83691e-016F, 10.0F, 1.0F, -2.12132F, -2.12132F, 7.07107F, 0.707107F,
        -3.67382e-016F, -3.0F, 10.0F, 1.0F, 2.12132F, -2.12132F, 7.07107F, 0.707107F, 3.0F, -5.51073e-016F, 10.0F, 1.0F, 2.41421F, 1.41421F, 8.04738F, 0.804738F, 1.27614F, 2.27614F, 8.69825F,
        0.869825F, 1.27614F, 2.27614F, 10.4379F, 0.869825F, 0.707107F, 2.70711F, 10.8284F, 0.902369F, 0.0F, 3.0F, 12.0F, 1.0F, -2.12132F, 2.12132F, 8.48528F, 0.707107F, -3.0F, 1.83691e-016F,
        12.0F, 1.0F, -2.12132F, -2.12132F, 8.48528F, 0.707107F, -3.67382e-016F, -3.0F, 12.0F, 1.0F, 2.12132F, -2.12132F, 8.48528F, 0.707107F, 3.0F, -5.51073e-016F, 12.0F, 1.0F, 2.41421F, 1.41421F,
        9.65685F, 0.804738F, 1.27614F, 2.27614F, 10.4379F, 0.869825F, 1.44629F, 2.57963F, 10.4379F, 0.869825F, 0.801388F, 3.06805F, 10.8284F, 0.902369F, 0.0F, 3.4F, 12.0F, 1.0F, -2.40416F,
        2.40416F, 8.48528F, 0.707107F, -3.4F, 2.08183e-016F, 12.0F, 1.0F, -2.40416F, -2.40416F, 8.48528F, 0.707107F, -4.16366e-016F, -3.4F, 12.0F, 1.0F, 2.40416F, -2.40416F, 8.48528F,
        0.707107F, 3.4F, -6.24549e-016F, 12.0F, 1.0F, 2.73611F, 1.60278F, 9.65685F, 0.804738F, 1.44629F, 2.57963F, 10.4379F, 0.869825F, 1.44629F, 2.57963F, 11.3077F, 0.869825F,
        0.801388F, 3.06805F, 11.7308F, 0.902369F, 0.0F, 3.4F, 13.0F, 1.0F, -2.40416F, 2.40416F, 9.19239F, 0.707107F, -3.4F, 2.08183e-016F, 13.0F, 1.0F, -2.40416F, -2.40416F, 9.19239F, 0.707107F,
        -4.16366e-016F, -3.4F, 13.0F, 1.0F, 2.40416F, -2.40416F, 9.19239F, 0.707107F, 3.4F, -6.24549e-016F, 13.0F, 1.0F, 2.73611F, 1.60278F, 10.4616F, 0.804738F, 1.44629F, 2.57963F,
        11.3077F, 0.869825F, 1.19107F, 2.1244F, 11.3077F, 0.869825F, 0.659966F, 2.52663F, 11.7308F, 0.902369F, 0.0F, 2.8F, 13.0F, 1.0F, -1.9799F, 1.9799F, 9.19239F, 0.707107F, -2.8F,
        1.71445e-016F, 13.0F, 1.0F, -1.9799F, -1.9799F, 9.19239F, 0.707107F, -3.4289e-016F, -2.8F, 13.0F, 1.0F, 1.9799F, -1.9799F, 9.19239F, 0.707107F, 2.8F, -5.14335e-016F, 13.0F, 1.0F, 2.25327F,
        1.31993F, 10.4616F, 0.804738F, 1.19107F, 2.1244F, 11.3077F, 0.869825F, 1.19107F, 2.1244F, 10.4379F, 0.869825F, 0.659966F, 2.52663F, 10.8284F, 0.902369F, 0.0F, 2.8F, 12.0F, 1.0F,
        -1.9799F, 1.9799F, 8.48528F, 0.707107F, -2.8F, 1.71445e-016F, 12.0F, 1.0F, -1.9799F, -1.9799F, 8.48528F, 0.707107F, -3.4289e-016F, -2.8F, 12.0F, 1.0F, 1.9799F, -1.9799F, 8.48528F,
        0.707107F, 2.8F, -5.14335e-016F, 12.0F, 1.0F, 2.25327F, 1.31993F, 9.65685F, 0.804738F, 1.19107F, 2.1244F, 10.4379F, 0.869825F, 1.14853F, 2.04853F, 8.78523F, 0.869825F,
        0.636396F, 2.4364F, 9.11393F, 0.902369F, 0.0F, 2.7F, 10.1F, 1.0F, -1.90919F, 1.90919F, 7.14178F, 0.707107F, -2.7F, 1.65322e-016F, 10.1F, 1.0F, -1.90919F, -1.90919F, 7.14178F,
        0.707107F, -3.30644e-016F, -2.7F, 10.1F, 1.0F, 1.90919F, -1.90919F, 7.14178F, 0.707107F, 2.7F, -4.95966e-016F, 10.1F, 1.0F, 2.17279F, 1.27279F, 8.12785F, 0.804738F, 1.14853F,
        2.04853F, 8.78523F, 0.869825F, 2.38213F, 4.2488F, 6.9586F, 0.869825F, 1.31993F, 5.05327F, 7.21895F, 0.902369F, 0.0F, 5.6F, 8.0F, 1.0F, -3.9598F, 3.9598F, 5.65685F, 0.707107F, -5.6F,
        3.4289e-016F, 8.0F, 1.0F, -3.9598F, -3.9598F, 5.65685F, 0.707107F, -6.8578e-016F, -5.6F, 8.0F, 1.0F, 3.9598F, -3.9598F, 5.65685F, 0.707107F, 5.6F, -1.02867e-015F, 8.0F, 1.0F, 4.50653F,
        2.63987F, 6.4379F, 0.804738F, 2.38213F, 4.2488F, 6.9586F, 0.869825F, 2.80751F, 5.00751F, 4.34913F, 0.869825F, 1.55563F, 5.95564F, 4.51184F, 0.902369F, 0.0F, 6.6F, 5.0F, 1.0F,
        -4.6669F, 4.6669F, 3.53553F, 0.707107F, -6.6F, 4.0412e-016F, 5.0F, 1.0F, -4.6669F, -4.6669F, 3.53553F, 0.707107F, -8.0824e-016F, -6.6F, 5.0F, 1.0F, 4.6669F, -4.6669F, 3.53553F,
        0.707107F, 6.6F, -1.21236e-015F, 5.0F, 1.0F, 5.31127F, 3.11127F, 4.02369F, 0.804738F, 2.80751F, 5.00751F, 4.34913F, 0.869825F, 2.59482F, 4.62816F, 2.43551F, 0.869825F,
        1.43778F, 5.50445F, 2.52663F, 0.902369F, 0.0F, 6.1F, 2.8F, 1.0F, -4.31335F, 4.31335F, 1.9799F, 0.707107F, -6.1F, 3.73505e-016F, 2.8F, 1.0F, -4.31335F, -4.31335F, 1.9799F, 0.707107F,
        -7.4701e-016F, -6.1F, 2.8F, 1.0F, 4.31335F, -4.31335F, 1.9799F, 0.707107F, 6.1F, -1.12051e-015F, 2.8F, 1.0F, 4.9089F, 2.87557F, 2.25327F, 0.804738F, 2.59482F, 4.62816F, 2.43551F,
        0.869825F, 1.99929F, 3.56596F, 0.34793F, 0.869825F, 1.1078F, 4.24113F, 0.360948F, 0.902369F, 0.0F, 4.7F, 0.4F, 1.0F, -3.3234F, 3.3234F, 0.282843F, 0.707107F, -4.7F,
        2.87782e-016F, 0.4F, 1.0F, -3.3234F, -3.3234F, 0.282843F, 0.707107F, -5.75565e-016F, -4.7F, 0.4F, 1.0F, 3.3234F, -3.3234F, 0.282843F, 0.707107F, 4.7F, -8.63347e-016F, 0.4F, 1.0F,
        3.78227F, 2.2156F, 0.321895F, 0.804738F, 1.99929F, 3.56596F, 0.34793F, 0.869825F, 0.0F, 0.0F, 0.173965F, 0.869825F, 0.0F, 0.0F, 0.180474F, 0.902369F, 0.0F, 0.0F, 0.2F, 1.0F, 0.0F, 0.0F, 0.141421F,
        0.707107F, 0.0F, 0.0F, 0.2F, 1.0F, 0.0F, 0.0F, 0.141421F, 0.707107F, 0.0F, 0.0F, 0.2F, 1.0F, 0.0F, 0.0F, 0.141421F, 0.707107F, 0.0F, 0.0F, 0.2F, 1.0F, 0.0F, 0.0F, 0.160948F, 0.804738F, 0.0F, 0.0F, 0.173965F, 0.869825F
    };
	
    RtFloat uknot[] = {0.0F, 0.0F, 0.0F, 0.0833333F, 0.0833333F, 0.333333F, 0.333333F, 0.583333F, 0.583333F, 0.833333F, 0.833333F, 1.0F, 1.0F, 1.0F};
    RtFloat vknot[] = {0.0F, 0.0F, 0.0F, 0.0555556F, 0.111111F, 0.166667F, 0.222222F, 0.277778F, 0.333333F, 0.388889F, 0.444444F, 0.5F, 0.555556F, 0.611111F, 0.666667F, 0.722222F, 0.777778F, 0.833333F, 0.888889F, 0.944444F, 1.0F, 1.0F, 1.0F};
	
	RiAttributeBegin(); {
		RiColor(redish);
		RiSides(1);
		RiTranslate(0, -.3F, 2.75F);
		RiRotate(-90, 1, 0, 0);
		RiScale(.1F, .1F, .1F);
		RiNuPatch(11, 3, uknot, 0.0F, 1.0F, 20, 3, vknot, 0.0F, 1.0F, RI_PW, vaseMesh, RI_NULL);
	} RiAttributeEnd();
}
	static void _write(liqRibParticleData* pData, const structJob &currentJob__)
	{
		CM_TRACE_FUNC("rm_writeParticleData.cpp::write("<<pData->getFullPathName().asChar()<<","<<currentJob__.name.asChar()<<",...)");

		LIQDEBUGPRINTF( "-> writing particles\n");

#ifdef DEBUG
		RiArchiveRecord( RI_COMMENT, "Number of Valid Particles: %d", pData->m_numValidParticles );
		RiArchiveRecord( RI_COMMENT, "Number of Discarded Particles: %d", pData->m_numParticles - pData->m_numValidParticles );
#endif
		MString notes("Make sure the particle is generated(e.g. sometimes particle is not generated, drag the time slider from frame0 to generate particles.)");
		if(pData->m_numValidParticles <= 0 ){
			RiArchiveRecord( RI_COMMENT, "Number of Valid Particles: %d. %s", pData->m_numValidParticles, notes.asChar() );
			liquidMessage2(messageError, "%s. [%s]", notes.asChar(), pData->getFullPathName().asChar());
			return;
		}

		unsigned numTokens( pData->tokenPointerArray.size() );
		boost::scoped_array< RtToken > tokenArray( new RtToken[ numTokens ] );
		boost::scoped_array< RtPointer > pointerArray( new RtPointer[ numTokens ] );
		assignTokenArraysV( pData->tokenPointerArray, tokenArray.get(), pointerArray.get() );

		switch( pData->particleType ) 
		{
		case liqRibParticleData::MPTBlobbies: 
			{
				// Build an array that can be given to RiBlobby
				std::vector< RtString > stringArray;
				for( int i(0); i < pData->m_stringArray.size(); i++ ) 
				{
					stringArray.push_back( const_cast<char *>( pData->m_stringArray[i].c_str()) );
				}
				RiBlobbyV( pData->m_numValidParticles,
					pData->m_codeArray.size(), const_cast< RtInt* >( &pData->m_codeArray[0] ),
					pData->m_floatArray.size(), const_cast< RtFloat* >( &pData->m_floatArray[0] ),
					stringArray.size(), const_cast< RtString* >( &stringArray[0] ),
					numTokens,
					tokenArray.get(),
					const_cast< RtPointer* >( pointerArray.get() ) );
				pData->grain = 0;
			}
			break;

		case liqRibParticleData::MPTMultiPoint:
		case liqRibParticleData::MPTPoints:
			RiArchiveRecord( RI_COMMENT, "normal has to be reversed to show the MultiPoint/Points particles. //  [10/9/2012 yaoyansi]" );
			RiReverseOrientation();
#ifdef DELIGHT
		case liqRibParticleData::MPTSpheres:
		case liqRibParticleData::MPTSprites:
#endif
			{
				RiPointsV( pData->m_numValidParticles * pData->m_multiCount, numTokens, tokenArray.get(), pointerArray.get() );
			}
			break;

		case liqRibParticleData::MPTMultiStreak:
		case liqRibParticleData::MPTStreak: 
			{
				unsigned nStreaks( pData->m_numValidParticles * pData->m_multiCount / 2 );
				std::vector< RtInt > verts( nStreaks, 2 );
				// Alternatively:
				//   scoped_array< RtInt >verts( new RtInt[ nStreaks ] );
				//   fill( verts.get(), verts.get() + nStreaks, ( RtInt )2 );
				// Both ways are way faster than the frickin for() lop that was here before -- Moritz

				RiCurvesV( "linear", nStreaks, &verts[ 0 ], "nonperiodic", numTokens, tokenArray.get(), pointerArray.get() );
			}
			break;
#ifndef DELIGHT
		case liqRibParticleData::MPTSpheres: 
			{
				int posAttr  = -1,
					radAttr  = -1,
					colAttr  = -1,
					opacAttr = -1;

				for ( unsigned i = 0; i < pData->tokenPointerArray.size(); i++ )
				{
					const std::string tokenName( pData->tokenPointerArray[i].getTokenName() );
					if ( "P" == tokenName )
					{
						posAttr = i;
					}
					else if ( "radius" == tokenName )
					{
						radAttr = i;
					}
					else if ( "Cs" == tokenName )
					{
						colAttr = i;
					}
					else if ( "Os" == tokenName )
					{
						opacAttr = i;
					}
				}

				for ( unsigned i = 0; i < pData->m_numValidParticles; i++)
				{
					RiAttributeBegin();
					if ( colAttr != -1 )
					{
						RiColor( &((RtFloat*)pointerArray[colAttr])[i*3] );
					}
					if ( opacAttr != -1 )
					{
						RiOpacity( &((RtFloat*)pointerArray[opacAttr])[i*3] );
					}
					RiTransformBegin();
					RiTranslate(((RtFloat*)pointerArray[posAttr])[i*3+0],
						((RtFloat*)pointerArray[posAttr])[i*3+1],
						((RtFloat*)pointerArray[posAttr])[i*3+2]);

					RtFloat radius = ((RtFloat*)pointerArray[radAttr])[i];
					RiSphere(radius, -radius, radius, 360, RI_NULL);
					RiTransformEnd();
					RiAttributeEnd();
				}
			}
			break;

		case liqRibParticleData::MPTSprites: 
			{
				int posAttr   = -1,
					numAttr    = -1,
					twistAttr  = -1,
					scaleXAttr = -1,
					scaleYAttr = -1,
					colAttr    = -1,
					opacAttr   = -1;

				for ( unsigned i( 0 ); i < pData->tokenPointerArray.size(); i++ )
				{
					const std::string tokenName( pData->tokenPointerArray[i].getTokenName() );
					if ( "P" == tokenName )
					{
						posAttr = i;
					}
					else if ( "spriteNum" == tokenName )
					{
						numAttr = i;
					}
					else if ( "spriteTwist" == tokenName )
					{
						twistAttr = i;
					}
					else if ( "spriteScaleX" == tokenName )
					{
						scaleXAttr = i;
					}
					else if ( "spriteScaleY" == tokenName )
					{
						scaleYAttr = i;
					}
					else if ( "Cs" == tokenName )
					{
						colAttr = i;
					}
					else if ( "Os" == tokenName )
					{
						opacAttr = i;
					}
				}

				MVector camUp( 0, 1, 0 );
				MVector camRight( 1, 0, 0 );
				MVector camEye( 0, 0, 1 );

				camUp    *= currentJob__.camera[0].mat.inverse();
				camRight *= currentJob__.camera[0].mat.inverse();
				camEye   *= currentJob__.camera[0].mat.inverse();

				for( unsigned ui( 0 ); ui < pData->m_numValidParticles; ui++ ) 
				{
					MVector up( camUp );
					MVector right( camRight );

					float spriteRadiusX( 0.5 );
					float spriteRadiusY( 0.5 );
					RiAttributeBegin();

					RiArchiveRecord( RI_COMMENT, "normal has to be reversed to show the Sprite particles. //  [10/9/2012 yaoyansi]" );
					RiReverseOrientation();

					if ( -1 != colAttr ) 
						RiColor( &( ( RtFloat* )pointerArray[ colAttr ] )[ ui * 3 ] );

					if ( -1 != opacAttr ) 
						RiOpacity( &( ( RtFloat* )pointerArray[ opacAttr ] )[ ui * 3 ] );

					if ( -1 != twistAttr ) 
					{
						float twist( -( ( RtFloat* )pointerArray[ twistAttr ] )[ ui ] * M_PI / 180 );
						MQuaternion twistQ( twist, camEye );
						right = camRight.rotateBy( twistQ );
						up    = camUp.rotateBy( twistQ );
					}

					if ( scaleXAttr != -1 ) 
						spriteRadiusX *= ( ( RtFloat* )pointerArray[ scaleXAttr ] )[ ui ];

					if ( scaleYAttr != -1 ) 
						spriteRadiusY *= ( ( RtFloat* )pointerArray[ scaleYAttr ] )[ ui ];

					if ( posAttr != -1 ) 
					{
						float *P( &( ( RtFloat* ) pointerArray[ posAttr ] )[ ui * 3 ] );
						float spriteNumPP = 0;
						if ( numAttr != -1 ) 
							spriteNumPP = ( ( RtFloat* )pointerArray[ numAttr ] )[ ui ];

						float x0 = P[ 0 ] - spriteRadiusX * right[ 0 ] + spriteRadiusY * up[ 0 ];
						float y0 = P[ 1 ] - spriteRadiusX * right[ 1 ] + spriteRadiusY * up[ 1 ];
						float z0 = P[ 2 ] - spriteRadiusX * right[ 2 ] + spriteRadiusY * up[ 2 ];
						float x1 = P[ 0 ] + spriteRadiusX * right[ 0 ] + spriteRadiusY * up[ 0 ];
						float y1 = P[ 1 ] + spriteRadiusX * right[ 1 ] + spriteRadiusY * up[ 1 ];
						float z1 = P[ 2 ] + spriteRadiusX * right[ 2 ] + spriteRadiusY * up[ 2 ];
						float x2 = P[ 0 ] - spriteRadiusX * right[ 0 ] - spriteRadiusY * up[ 0 ];
						float y2 = P[ 1 ] - spriteRadiusX * right[ 1 ] - spriteRadiusY * up[ 1 ];
						float z2 = P[ 2 ] - spriteRadiusX * right[ 2 ] - spriteRadiusY * up[ 2 ];
						float x3 = P[ 0 ] + spriteRadiusX * right[ 0 ] - spriteRadiusY * up[ 0 ];
						float y3 = P[ 1 ] + spriteRadiusX * right[ 1 ] - spriteRadiusY * up[ 1 ];
						float z3 = P[ 2 ] + spriteRadiusX * right[ 2 ] - spriteRadiusY * up[ 2 ];

						float patch[ 12 ] = { x0, y0, z0,
							x1, y1, z1,
							x2, y2, z2,
							x3, y3, z3 };
						// !!! if not GENERIC_RIBLIB use RiPatch( "bilinear", "P", &patch, "float spriteNum", &spriteNum, RI_NULL );                                  
						// RiPatch( "bilinear", "P", &patch, "float spriteNum", (RtFloat*)&spriteNumPP, RI_NULL );
						// Patch "bilinear"  "P" [0.446265 0.316269 -0.647637 1.27725 0.316269 -1.20393 0.615752 -0.636188 -0.39446 1.44674 -0.636188 -0.950756 ]  "float spriteNum" [2 0 0 0 ]
						RiArchiveRecord( RI_VERBATIM, "Patch \"bilinear\" \"P\" [%f %f %f %f %f %f %f %f %f %f %f %f] \"float spriteNum\" [%f]", 
							x0, y0, z0,x1, y1, z1, x2, y2, z2,x3, y3, z3,
							spriteNumPP ); 
					} 
					else {
						RiIdentity();
					}
					RiAttributeEnd();
				}//for
			}
			break;

#endif // #ifndef DELIGHT


		case liqRibParticleData::MPTCloudy:
			{
				int posAttr  = -1,
					radAttr  = -1,
					colAttr  = -1,
					opacAttr = -1,
					rotAttr  = -1;

				for ( unsigned i = 0; i < pData->tokenPointerArray.size(); i++ )
				{
					const std::string tokenName( pData->tokenPointerArray[i].getTokenName() );
					if ( "P" == tokenName )
					{
						posAttr = i;
					}
					else if ( "radius" == tokenName )
					{
						radAttr = i;
					}
					else if ( "Cs" == tokenName )
					{
						colAttr = i;
					}
					else if ( "Os" == tokenName )
					{
						opacAttr = i;
					}
					else if ( "rotation" == tokenName )
					{
						rotAttr = i;
					}
				}
				// Build an array that can be given to RiBlobby
				std::vector< RtString > stringArray;
				for( unsigned int i(0); i < pData->m_stringArray.size(); i++ ) {
					stringArray.push_back( const_cast<char *>( pData->m_stringArray[i].c_str()) );
				}
				if(stringArray.size()==0)//added by yaoyansi, or it leads a crash on windows
					stringArray.push_back( "" );

				boost::scoped_array< RtToken > ithTokenArray( new RtToken[ numTokens ] );
				boost::scoped_array< RtPointer > ithPointerArray( new RtPointer[ numTokens ] );

				for ( unsigned i = 0; i < pData->m_numValidParticles; i++)
				{
					assignIthTokenArraysV( pData->tokenPointerArray, ithTokenArray.get(), ithPointerArray.get(), i );
					RiAttributeBegin();
					if ( colAttr != -1 )
					{
						RiColor( &((RtFloat*)pointerArray[colAttr])[i*3] );
					}
					if ( opacAttr != -1 )
					{
						RiOpacity( &((RtFloat*)pointerArray[opacAttr])[i*3] );
					}
					RiTransformBegin();
					RiTranslate(((RtFloat*)pointerArray[posAttr])[i*3+0],
						((RtFloat*)pointerArray[posAttr])[i*3+1],
						((RtFloat*)pointerArray[posAttr])[i*3+2]);

					if ( rotAttr != -1 )
					{
						RiRotate( (( RtFloat *) pointerArray[rotAttr])[i*3] * 360.0, 1.0, 0.0, 0.0 );
						RiRotate( (( RtFloat *) pointerArray[rotAttr])[i*3+1] * 360.0, 0.0, 1.0, 0.0 );
						RiRotate( (( RtFloat *) pointerArray[rotAttr])[i*3+2] * 360.0, 0.0, 0.0, 1.0 );
					}

					RtFloat radius = ((RtFloat*)pointerArray[radAttr])[i];
					RiScale( radius, radius, radius );
					//RiSphere(radius, -radius, radius, 360, RI_NULL);
					float dummy[] = { 0.0, 0.0, 0.0 }; // Worst case : three floats are needed
					RiBlobbyV( 1,
						pData->m_codeArray.size(), const_cast< RtInt* >( &pData->m_codeArray[0] ),
						pData->m_floatArray.size(), const_cast< RtFloat* >( &pData->m_floatArray[0] ),
						stringArray.size(), const_cast< RtString* >( &stringArray[0] ),
						numTokens, ithTokenArray.get(), ithPointerArray.get() );
//						"vertex color incandescence", (RtPointer *)( dummy ),
//						"vertex color Cs", (RtPointer *)( dummy ),
//						"vertex float selfshadow", (RtPointer *)( dummy ),
//						RI_NULL );
					RiTransformEnd();
					RiAttributeEnd();

				}
				break;
			}
		case liqRibParticleData::MPTNumeric:
			RiArchiveRecord( RI_COMMENT, "Numeric Particles are not supported" );
			break;
		case liqRibParticleData::MPTTube:
			RiArchiveRecord( RI_COMMENT, "Tube Particles are not supported" );
			break;

			break;
		}
	}
Exemplo n.º 15
0
void drawPencil() {
	RtColor pink = {1.0, 0.5, 0.5};
	RtColor silver = {0.7, 0.7, 0.7};
	RtColor yellow = {1.0, 0.7, 0.0};
	RtColor tan = {0.9, 0.8, 0.5};
	RtColor black = {0.1, 0.1, 0.1};

	RtPoint pencilSide[4] = {{-4.0, 0.1, -0.1}, {-4.0, 0.1, 0.1}, {4.0, 0.1, 0.1}, {4.0, 0.1, -0.1}};

	RiColor(yellow);
	RiSurface("paintedmatte", RI_NULL);

	/* Draw all six sides of a pencil, each 8.0"x0.2" in size */
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	
	/* Draw the eraser */
	RiTransformBegin();
		RiTranslate(4.2, 0.0, 0.0);

		/* Draw the metal part around the eraser */
		RiTransformBegin();
			RiTranslate(-0.2, 0.0, 0.0);
			RiRotate(-90.0, 0.0, 1.0, 0.0);

			RiColor(silver);
			RiSurface("metal", RI_NULL);
			RiCylinder(0.15, 0.0, 0.3, 360.0, RI_NULL);
		RiTransformEnd();

		RiRotate(-90.0, 0.0, 1.0, 0.0);

		RiColor(pink);
		RiSurface("matte", RI_NULL);

		RiDisk(0.0, 0.15, 360, RI_NULL);
		RiCylinder(0.15, 0.0, 0.2, 360, RI_NULL);
	RiTransformEnd();

	RiColor(tan);
	RiSurface("matte", RI_NULL);

	/* Draw the exposed wood part at the bottom of the pencil */
	RiTranslate(-4.0, 0.0, 0.0);
	RiTransformBegin();
		RiRotate(-90.0, 0.0, 1.0, 0.0);
		RiCone(1.0, 0.15, 360, RI_NULL);
	RiTransformEnd();

	/* Draw the lead of the pencil */
	RiTranslate(-0.7, 0.0, 0.0);
	RiRotate(-90.0, 0.0, 1.0, 0.0);

	RiColor(black);
	RiCone(0.3, 0.05, 360, RI_NULL);
}
Exemplo n.º 16
0
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();
}
Exemplo n.º 17
0
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();
}