Surface Normal

Started by AO, May 14, 2013, 08:20:21 PM

Previous topic - Next topic

AO

Hey there. I gotta do some ball bouncing over a cube, which is obviously an even surface. When I detect the collision I'm trying to get the corresponding surface normal. Since it is a cube, which is no rotated nor moved or anything, I expect to get a normal with only one axis component (i.e.:[0.0, -1.0, 0.0]), but I get different values for different collision events, even though the ball is bouncing all the time over the same side on the mentioned cube. The normals I get are close to the one I expect, but are not exactly the ones I'm expecting, thus creating some funny behaviour on some bounces (as if the surfave was kind of rugged). Please if someone can help me out, I'd appreciate it. Cheers!

EgonOlsen

How do you get these normals and how much do they differ (some example values might help)?

AO

All I have is a sphere and a cube (or a plane), both from Primitives. When a collision occurs, I get the polygon normal from "CollisionEvent". An example of the values is (0.0032, -0.9936, 0.0032)

EgonOlsen

...and that's the reason for my question: There is no method to get the surface normal in CollisionEvent. I'm confused... ???

AO

Yes, you're right, you can't do retrieve it directly, so I get the polygons id's
CollisionEvent.getPolygonIds()
and given that I get the normal out of
PolygonManager.getTransformedNormal(int polyID)

EgonOlsen

I had a look at that method...the differences in the values that you experience are simply caused by numerical inaccuracies that add up in the process. That's normal behaviour and usually not a problem, because the differences are so tiny that they are neglectable in most cases.
However, looking at the method, it seems to be rather inefficient anyway. I've uploaded a new beta version here: http://jpct.de/download/beta/jpct_ae.jar that implements this in a more efficient way with the additional effect, that numerical accuracy should have been improved. Please give it a try.

AO

All right, thanks a lot. I'll give it a try and get back to you feedback. Keep up the good work!

AO

Problem solved mate, thanks.