POV-Ray : Newsgroups : povray.advanced-users : Collision Detection Server Time
1 Nov 2024 13:21:01 EDT (-0400)
  Collision Detection (Message 1 to 4 of 4)  
From: Mike
Subject: Collision Detection
Date: 2 Aug 2002 23:40:02
Message: <web.3d4b4ff6fac903ee9d3dc080@news.povray.org>
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;

#include "colors.inc"

global_settings {
  assumed_gamma 1.0
}

camera {
  location  <0.0, 0.5, -4.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.7 rgb <0.0,0.1,0.8>]
    }
  }
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

// ----------------------------------------
#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

From: Mike
Subject: Re: Collision Detection
Date: 3 Aug 2002 09:35:06
Message: <web.3d4bdb3540941870e9d3dc080@news.povray.org>
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

From: hughes b
Subject: Re: Collision Detection
Date: 3 Aug 2002 10:33:32
Message: <3d4be9bc@news.povray.org>
Hey there, here is what I managed to do with it and maybe you'll see the
things different from your way. I think the main problem was to get the
trace all done in the positive y instead of dealing with negative. Just not
sure that was the real factor causing the trouble. I was only able to get it
set right using <0,0,0> to <X,+Y,0>.

Anyway, the incurable problem seems to be about the gaps between the
spheres. That isn't solvable by just tracing alone, my usual answer would be
to spline it together using only selected trace points to skip the gaps. Not
very ingenious, admittedly, but only way I know of.

Makes it impossible to just trace the surfaces everywhere along the path
when those gaps are obviously also a part of the surface. However, if you
check the changed script below you'll see that the wheel at least follows
along the tops of the spheres.

Maybe Rune or someone else with mastery of this kind of stuff will have some
tips.

#version 3.5;

#include "colors.inc"

global_settings {
  assumed_gamma 1.0
}

camera {
  location  <0.0, 1.5, -4.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.7 rgb <0.0,0.1,0.8>]
    }
  }
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

// ----------------------------------------
#declare Ground =
  plane { y, 0 } // everything is moved up 1*y from before

#declare Wheel=
  sphere {<0,.25,0>,.25}

#declare Rock=
  union
    {
    sphere {<-1,0,0>,.5}
    sphere {<0,0,0>,.7}
    sphere {<1,0,0>,.5}
    }

#macro MoveWheel()

  #declare height=1;

  #declare initLoc=<-2+clock*4,height,0>; // combined to vector

  #declare Norm=<0,0,0>;

  #declare intersect=trace(Rock,initLoc, <0,0,0>-initLoc, Norm);

  #debug concat("intersect: <",vstr(3,intersect,",",4,3))
  #debug concat("> norm:<",vstr(3,Norm,",",4,3),"> "," initLoc = ")
  #debug concat(str(initLoc.x,3,1),"\n")

  #if (vlength(Norm)!=0)

  #declare Direction=Norm;

  pigment{checker color rgb<0,0,1> color rgb<0,1,0>
         scale 0.25
         rotate 90*Direction // I have no idea what I did here :-)
          }

  translate intersect

  #end

#end


object {Ground pigment { color rgb <0.7,0.5,0.3> }}
object {Rock pigment{color rgbf<1,0,0,0>}}

object
  {
  Wheel
  MoveWheel()
  }


Post a reply to this message

From: Tim Nikias
Subject: Re: Collision Detection
Date: 3 Aug 2002 16:44:24
Message: <3d4c40a8$1@news.povray.org>
You don't need the "colors.inc", at least not in the
code posted... ;-)

Regards,

Tim

--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde
"Mike" <mla### [at] yahoocom> schrieb im Newsbeitrag
news:web.3d4b4ff6fac903ee9d3dc080@news.povray.org...
> 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;
>
> #include "colors.inc"
>
> global_settings {
>   assumed_gamma 1.0
> }
>
> camera {
>   location  <0.0, 0.5, -4.0>
>   direction 1.5*z
>   right     x*image_width/image_height
>   look_at   <0.0, 0.0,  0.0>
> }
>
> sky_sphere {
>   pigment {
>     gradient y
>     color_map {
>       [0.0 rgb <0.6,0.7,1.0>]
>       [0.7 rgb <0.0,0.1,0.8>]
>     }
>   }
> }
>
> light_source {
>   <0, 0, 0>            // light's position (translated below)
>   color rgb <1, 1, 1>  // light's color
>   translate <-30, 30, -30>
> }
>
> // ----------------------------------------
> #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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.