Jump to content

GU_SDF


Recommended Posts

Hi,

Im using GU_SDF to build SDF's from files. Whenever i try, i get a box as a result.

screenshot20130225at659.png

screenshot20130225at658.png

[/img]


// 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[ 0 ] = 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();

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...