|
|
Haven't tested it with meshes but I don't expect it would work in all cases
as it requires the use of an inside(obj,vect) test. I think the POV docs
state that meshes can have an inside if they form a closed shape and you
specify the inside_vector, but I rarely use meshes where I can get away
with SDL, CSG or macros so haven't tried it out.
It basically works by sampling points within the bounding box of an object
with a user-set resolution, testing whether each point is inside the
object, and creating a union of cubes for the inside points. The same
method can be used with a merge instead of a union if you want to create a
well-behaved transparent version of the same. Render times are OK, as it's
just a collection of simple primitives, but for high resolution sampling the
parse time (and probably memory usage) can skyrocket.
As I mentioned the method is a but clunky and can no doubt be improved, but
it achieved what I wanted it to so I'm not going to pursue it any further.
Here's the SDL, since it sounds like a couple of people are interested:
#macro GRANULE(GrObj,Res,Text)
#local MinExt = 0;
#local MaxExt = 0;
Extents(GrObj,MinExt,MaxExt)
#local MinCxLim = Res*floor((MinExt.x)/Res);
#local MinCyLim = Res*floor((MinExt.y)/Res);
#local MinCzLim = Res*floor((MinExt.z)/Res);
#local MaxCxLim = Res*ceil((MaxExt.x)/Res);
#local MaxCyLim = Res*ceil((MaxExt.y)/Res);
#local MaxCzLim = Res*ceil((MaxExt.z)/Res);
#local Cz = MinCxLim;
union {
#while ( Cz < MaxCzLim )
#local Cy = MinCxLim;
#while ( Cy < MaxCyLim )
#local Cx = MinCxLim;
#while ( Cx < MaxCxLim )
#if ( inside(GrObj,<Cx+(Res/2),Cy+(Res/2),Cz+(Res/2)>) )
object {
box {
<Cx,Cy,Cz>-(Res/100),<Cx,Cy,Cz>+(Res*1.01)
}
}
#end
#local Cx = Cx + Res;
#end
#local Cy = Cy + Res;
#end
#local Cz = Cz + Res;
#end
texture {
Text
}
}
#end
Call it by using
GRANULE(Object,Resolution,Texture)
where Object and Texture are previously declared, and Resolution is a float
indicating the size of each cube.
L
-
Post a reply to this message
|
|