[ODE] Using rays to generate a light/shadow map

Shamyl Zakariya shamyl at zakariya.net
Wed Nov 3 13:24:50 MST 2004


A peculiar turn of events:

I did some deeper investigation and was able to determine that my code 
was at fault, in one way at least. It was generating incorrect x,y 
positions on the map for use in casting the rays. So, fine, I fixed it. 
Now, things get weird.

The *first* time the level is loaded, there's no shadowing at all. None 
of the ray castings report collision.

The *second* and subsequent times the level is loaded, shadowing is 
correct ( woohoo! )

So, I tried putting in a dummy pumping of ODE after the geometry is 
uploaded to a trimesh, just to see if there's some black magic needed:

	dSpaceCollide( GameWorld::instance()->space(), 0L, &nearCallbackDummy 
);
	dWorldStep( GameWorld::instance()->world(), 0.01f );
	dJointGroupEmpty( GameWorld::instance()->contactGroup() );

But, no effect.

The good news is that I'm not seeing any noticeable floating point 
errors at the endpoints of my environment ( which is about -5k to +5k 
square )

Any ideas as to why the manual ray collisions would fail first time 
through, but succeed later?

Shamyl Zakariya
   "this is, after all, one of those movies where people spend a great
   deal of time looking at things and pointing."
	From a review of _Fantastic Voyage_

On Nov 3, 2004, at 11:54 AM, Jon Watte wrote:

>
>> surface( 791.01, 4990.24, 0.57 )  <-- ray origin
>
> Are you using floats or doubles? Values of magnitude 5000
> don't have all that much useable precision in floats -- only
> about 1e-3 at that point.
>
>> Anyway, I know there's nothing for the ray to collide with. Also, I'm
>> projecting the ray's origin away from the triangle center along the
>
> There's the actual triangle surface. It's quite possible that
> the ray collides with the base surface because of numerical
> imprecision problems.
>
>> So, I'm thinking that even though I'm manually calling dCollide with 
>> my
>> ray and with the terrain geom, perhaps there's some magic that needs
>> doing by calling dWorldStep at least once?
>
> That seems unlikely.
>
> I would pick a single, representative spot, and run the collision
> from there (possibly using "manual code" right before the automated
> ray cast). Then examine what you're actually colliding with inside
> the collision callback. Maybe use the ability to extract the collided
> triangle from the mesh, too.
>
> Cheers,
>
> 			/ h+
>
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>



More information about the ODE mailing list