Code // PRTRENDER#ifdef WINDOWS #define PRTRENDER extern "C" __declspec( dllexport ) #pragma comment(lib,"prman.lib") #pragma comment(lib,"libgsl.lib")#else #define PRTRENDER extern "C"#endif#include <stdlib.h>#include <stdio.h>#include <string.h>#include <math.h>#include <time.h>#include <ri.h>#include <gsl/gsl_qrng.h>PRTRENDER RtPointer ConvertParameters(RtString ParamStr){ // RtString FilePath = strdup(ParamStr); // fprintf(stdout,"PRTRENDER DSO INFO : Import PRT @ [%s]\n",FilePath); // return (RtPointer)FilePath;}PRTRENDERRtVoid Subdivide(RtPointer Data, RtFloat Detail){ RtInt N = 1024; RtToken VarP = { "P"}; RtToken VarCWidth = { "constantwidth"}; gsl_qrng* QRNG = gsl_qrng_alloc(gsl_qrng_sobol,3); RtFloat* P = (RtFloat*)malloc( sizeof(float)*N*3 ); for( int i=0; i<N; ++i ) { double SingleSobol[3]; gsl_qrng_get(QRNG,SingleSobol); int j = i*3; P[j+0] = SingleSobol[0] * 2.0 - 1.0; P[j+1] = SingleSobol[1] * 2.0 - 1.0; P[j+2] = SingleSobol[2] * 2.0 - 1.0; } RtFloat CWidth = 0.01f; RtToken DataVar[2] = {VarP,VarCWidth}; RtPointer DataPointers[2] = {P,&CWidth}; RiPointsV(N,2,DataVar,DataPointers); free(P); gsl_qrng_free(QRNG);}PRTRENDERRtVoid Free(RtPointer Data){ // free(Data);}
这是在Maya中建模的粒子模型,导出为PRT格式的文件,而后使用DSO读取后直接渲染之。