Hi,
Im using GU_SDF to build SDF's from files. Whenever i try, i get a box as a result.
[imageshack.us]
[imageshack.us]
// Class to pass volume created via SDF
class VRAY_VolumeBuilder: public VRAY_Volume
{
public:
VRAY_VolumeBuilder( GU_SDF_REF sdfRef_, UT_BoundingBox bbox_ );
~VRAY_VolumeBuilder();
public:
virtual void getBoxes( UT_RefArray<UT_BoundingBox> &boxes, float radius, float dbound, float zerothreshold ) const;
virtual void getAttributeBinding( UT_StringArray &names, UT_IntArray &sizes ) const;
virtual void evaluate( const UT_Vector3 &pos, const UT_Filter &filter, float radius, float time, int idx, float *data ) const;
virtual UT_Vector3 gradient( const UT_Vector3 &pos, const UT_Filter &filter, float radius, float time, int idx ) const;
protected:
GU_SDF_REF sdfRef;
UT_BoundingBox bbox;
};
VRAY_VolumeBuilder::VRAY_VolumeBuilder( GU_SDF_REF sdfRef_, UT_BoundingBox bbox_ )
:sdfRef( sdfRef_ )
,bbox( bbox_ )
{}
VRAY_VolumeBuilder::~VRAY_VolumeBuilder()
{}
void VRAY_VolumeBuilder::getBoxes( UT_RefArray<UT_BoundingBox> &boxes, float radius, float dbound, float zerothreshold ) const
{
boxes.append( bbox );
}
void VRAY_VolumeBuilder::getAttributeBinding( UT_StringArray &names, UT_IntArray &sizes ) const
{
names.append( “density” );
}
void VRAY_VolumeBuilder::evaluate( const UT_Vector3 &pos, const UT_Filter &filter, float radius, float time, int idx, float *data ) const
{
data = sdfRef->getFunction()->evaluate( pos, filter, radius );
}
UT_Vector3 VRAY_VolumeBuilder::gradient( const UT_Vector3 &pos, const UT_Filter &filter, float radius, float time, int idx ) const
{
return sdfRef->getGradient( pos );
}
// Inside VRAY Procedural Render Method
GU_SDF_REF sdfRef( new GU_SDF() );
GU_SDFParms sdfParameters;
sdfParameters.setMode( GU_SDFParms::RAY_INTERSECT );
sdfParameters.setLaserScan( true );
sdfParameters.setFixSigns( true );
sdfParameters.setSweepCount( 3 );
sdfParameters.setSweepThreshold( 2.0f );
sdfParameters.setDivisions( 100, 100, 100 );
sdfParameters.setBBox( bbox );
sdfRef->build( gu, sdfParameters );
openVolumeObject();
addVolume( new VRAY_VolumeBuilder( sdfRef, bbox ), cameraShutter );
closeObject();