Esempio n. 1
0
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;
}
	static void _write(liqRibMeshData* pData, const structJob &currentJob)
	{
		CM_TRACE_FUNC("rm_writeMeshData.cpp::_write("<<pData->getFullPathName().asChar()<<","<<currentJob.name.asChar()<<")");

		if( pData->isEmpty() )
		{
			liquidMessage( "Could not export degenerate mesh", messageError );
			return;
		}
		//
		//RiArchiveRecord( RI_COMMENT, "Sometimes the polygon cant be rendered correctly, so I try to reverse the normal. //- yaoyansi" );
		//RiReverseOrientation();

		if(pData->isAreaLight())
		{
			RtLightHandle handle = INVALID_LIGHT_INDEX;

			{ // What happens if we're inside a motion block????? This whole approach of Liquid is flawed...
				LIQDEBUGPRINTF( "-> mesh is area light\n" );
				//	RiAttributeBegin();
				RtString ribname = const_cast< char* >( pData->getFullPathName().asChar() );
				RiAttribute( "identifier", "name", &ribname, RI_NULL );
				RtMatrix tmp;
				memcpy( tmp, pData->getTransformationMatrixPtr(), sizeof( RtMatrix ) );
				RiTransform( tmp );
				float areaIntensity = pData->getAreaIntensity();
				handle = RiAreaLightSource( "arealight", "intensity", &areaIntensity, RI_NULL );
			}
			//
			//mesh data begin
			//
			// Each loop has one polygon, so we just want an array of 1's of
			// the correct size. Stack version.
			//vector< RtInt > nloops( numFaces, 1 );
			// Alternatively (heap version):
			boost::scoped_array< RtInt > nloops( new RtInt[ pData->getNumFaces() ] );
			std::fill( nloops.get(), nloops.get() + pData->getNumFaces(), ( RtInt )1 );

			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() );

			RiPointsGeneralPolygonsV( pData->getNumFaces(),
				&nloops[ 0 ],
				pData->getNverts().get(),
				pData->getVerts().get(),
				numTokens,
				tokenArray.get(),
				pointerArray.get() );
			//mesh data end

			{
				// RiAttributeEnd();
				RiIlluminate( handle, 1 );
			}
		}else{
			//mesh data begin
			//
			// Each loop has one polygon, so we just want an array of 1's of
			// the correct size. Stack version.
			//vector< RtInt > nloops( numFaces, 1 );
			// Alternatively (heap version):
			boost::scoped_array< RtInt > nloops( new RtInt[ pData->getNumFaces() ] );
			std::fill( nloops.get(), nloops.get() + pData->getNumFaces(), ( RtInt )1 );

			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() );

			RiPointsGeneralPolygonsV( pData->getNumFaces(),
				&nloops[ 0 ],
				pData->getNverts().get(),
				pData->getVerts().get(),
				numTokens,
				tokenArray.get(),
				pointerArray.get() );
			//mesh data end//	
		}
	}