Advertisement

Collision detection on a bezier curved surface?

Started by February 25, 2005 10:14 AM
5 comments, last by Intamin AG 19 years, 11 months ago
I have created a bezier surface and i now need to detect and respond to a sphere colliding along it. Can anyone help???? Do i need to use ray tracing? Or Bound box? And how would i use them to for the detection and responce? I have looked at a few tutorials on Collision detection, but none of descride collision along a curved surface. I am very new to OpenGL programming and have been learning most of my stuff from the Red Book. My bezier surface is created using the following code: GLfloat xpoint = 15.0; GLfloat xcurve = 9.0; GLfloat ymiddle = 0.6; GLfloat ytopbot = 1.5; GLfloat zpoint = 30.0; GLfloat zcurve = 48.0; //Create Points for bezier surface GLfloat ctrlpoints[4][4][3] = { { {-xpoint, -ytopbot, -zpoint}, {-xcurve, -ytopbot, -zcurve}, {xcurve, -ytopbot, -zcurve}, {xpoint, -ytopbot, -zpoint}}, { {-xpoint, -ymiddle, -zpoint}, {-xcurve, -ymiddle, -zcurve}, {xcurve, -ymiddle, -zcurve}, {xpoint, -ymiddle, -zpoint}}, { {-xpoint, ymiddle, -zpoint}, {-xcurve, ymiddle, -zcurve}, {xcurve, ymiddle, -zcurve}, {xpoint, ymiddle, -zpoint}}, { {-xpoint, ytopbot, -zpoint}, {-xcurve, ytopbot, -zcurve}, {xcurve, ytopbot, -zcurve}, {xpoint, ytopbot, -zpoint}} }; GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}}, {{1.0, 0.0}, {1.0, 1.0}}}; drawCurve() { glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlpoints[0][0][0]); glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, &texpts[0][0][0]); glEnable(GL_MAP2_TEXTURE_COORD_2); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_AUTO_NORMAL); glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0); glEvalMesh2(GL_FILL, 0, 20, 0, 20); }
I think it would be the easiest (and most accurate - but my knowledge in higher mathematics is limited) if you would build your own mesh out of the bezier surface (relatively easy, see NeHe tuts), and then do a bound -> tri&tri test for the triangles on the sphere and on the surface. I can help if needed.
The world isn't unpredictable. It's CHAOTIC.
Advertisement
Cool, thanks for your help.

I am going to implement a mesh this week and see if i can get the collision detection working.
if ur curve goes inward like say ur making a ice hocket game then u can simple create the entire bounding walls, u know the egg shape out of planes and do plane collision detection!

if u understand
----------------------------

http://djoubert.co.uk
or if you like official definitions...

A POINT ON A BÉZIER CURVE (read CURVED SURFACE) ALWAYS LIES WITHIN THE CONVEX HULL OF THE CONTROL POINTS
The world isn't unpredictable. It's CHAOTIC.
Quote:
Original post by Intamin AG
or if you like official definitions...

A POINT ON A BÉZIER CURVE (read CURVED SURFACE) ALWAYS LIES WITHIN THE CONVEX HULL OF THE CONTROL POINTS

Which doesn't help at all with poly-level collision detection [wink].

Advertisement
yeah (if you'd read my first post you would have seen i already proposed meshing and bound & tritri testing... but i was replying to the guy apove my previous post about the hockey thing)
The world isn't unpredictable. It's CHAOTIC.

This topic is closed to new replies.

Advertisement