Click on the filename to display or download the file.
spherical_density.mi
declare shader
scalar "spherical_density" (
vector "center" default 0 0 0,
scalar "radius" default 1 )
version 1
apply volume
end declare
spherical_density.c
#include "shader.h"
#include "miaux.h"
DLLEXPORT
int spherical_density_version(void) { return 1; }
struct spherical_density {
miVector center;
miScalar radius;
};
DLLEXPORT
miBoolean spherical_density (
miScalar *result, miState *state, struct spherical_density *params )
{
miVector *center = mi_eval_vector(¶ms->center);
miScalar radius = *mi_eval_scalar(¶ms->radius);
miVector point;
mi_vector_to_world(state, &point, &state->point);
if (mi_vector_dist(center, &point) <= radius)
*result = 1.0;
else
*result = 0.0;
return miTRUE;
}
22 April 2008 23:40:54