|
![](/i/fill.gif) |
Doh! I double declared my Rock object. Once removed, though, it still
doesn't work right.
Mike wrote:
>I have been working on this for hours and have gotten close, but no cigar.
>
>What I want is for a sphere to follow the curves of something below it as it
>is animated (the ultimate goal is to have a tire [torus] roll across a
>height field). I will post the code that I got so far...
>
>=======================================================
>===== CODE TO FOLLOW ==================================
>=======================================================
>#version 3.5;
<----Snip---->
>#declare Ground =
> plane { y, -1 }
>
>#declare Wheel=
> sphere {<0,-.75,0>,.25}
>
>#declare Rock=
> union
> {
> sphere {<-1,-1,0>,.5}
> sphere {<0,-1,0>,.7}
> sphere {<1,-1,0>,.5}
> }
>
>#macro MoveWheel()
> #declare initLoc=-2+clock*4;
>
> #declare height=0;
>
> #declare Norm=<0,0,0>;
> #declare intersect=trace(Rock,<initLoc,height,0>, <0,-1,0>, Norm);
> #debug concat("intersect: <",vstr(3,intersect,",",4,3))
> #debug concat("> norm:<",vstr(3,Norm,",",4,3),"> "," initLoc = ")
> #debug concat(str(initLoc,3,1),"\n")
>
> #declare height=height+(Norm.y/2);
> translate<initLoc,height,0>
>#end
>
>
>#declare Rock=
> union
> {
> sphere {<-1,-1,0>,.5}
> sphere {<0,-1,0>,.7}
> sphere {<1,-1,0>,.5}
> texture{pigment{color rgb<1,0,0>}}
> }
>
>object {Ground pigment { color rgb <0.7,0.5,0.3> }}
>object {Rock pigment{color rgb<1,0,0>}}
>
>object
> {
> Wheel
> MoveWheel()
> pigment{color rgb<0,0,1>}
> }
>
>=======================================================
>===== END CODE ========================================
>=======================================================
>
>If you animate the above code, you will see my wheel go over the first and
>third spheres more or less correctly, but it definitatly goes *inside* the
>middle one. Can anyone give me any idea why this is happening.
>
>Thanks,
>Mike
>
>PS. If there is a better way to do this, I'm VERY open to suggestions.
>
Post a reply to this message
|
![](/i/fill.gif) |