|
|
On 4/8/2009 9:41 PM, MessyBlob wrote:
> "clipka"<nomail@nomail> wrote:
>> What good would that do? I mean, stuff that trace() and inside() cannot do for
>> you yet?
>
> The problem is that you can't do trace() or inside() on an object that has not
> yet been placed, but when it has been placed, it is a permanent placement.
That's actually not true.
When you call trace(), it's on an object that has been declared, but not
necessarily placed. You can do it like this:
#declare my_obj = object { ... }
#declare v_orig = <...>;
#declare v_dir = <...>;
#declare intersection = <0,0,0>;
#declare norm = <0,0,0>;
#declare intersection = trace(my_obj, v_orig, v_dir, norm)
#declare hit = false;
#if (intersection.x != 0) #declare hit = true; #end
#if (intersection.y != 0) #declare hit = true; #end
#if (intersection.z != 0) #declare hit = true; #end
#if (hit)
object { my_obj }
#end
The above code has the nice property of only parsing the object, and
thus tracing it, if your intended intersection actually occurs.
However, it highlights one of the needs in the SDL of proper object
support: mainly, the need to pass norm as an "out" parameter to the
trace function, rather than returning a vector pair of the intersection
point / normal. With proper class support, this could be remedied.
--
...Chambers
www.pacificwebguy.com
Post a reply to this message
|
|