Click to See Complete Forum and Search --> : [OpenGL] Movement on a football net


Syriana
April 22nd, 2006, 07:47 PM
Hi!
I need to make a football stadium. And there will be 2, I don't know what's their name in english... I think it's "nets"? The place where the ball goes in to make a goal LoL... (this is so lame... :()
Anyway, the drawing part is easy. I thought of drawing a box, to make the iron support and then some lines to draw the net.
What I really needed help with, is in how to make the effect caused by the ball when a goal happens... The net being thrown back by the impact of the ball. I have absolutely no idea of how to do that!! I don't know if it's possible with opengl, but I've seen opengl make a flag wave like if it was in the wind, so I thougt that maybe I could do the net effect on my project.
Does anybody know or have any idea how 2 do this...?
Thanks :D

surfdabbler
April 23rd, 2006, 06:16 AM
Hmm, yes, that sounds ambitious. Unfortunately, you aren't going to get an easy method of doing this in OpenGL. Waving a flag is probably done with a simple sin-wave calculation for the z dimension, and wrapping the flag over this (not in OpenGL, just in the application.

Moving a soccer net realistically would be a big task, based on physics calculations, etc. There's an article on the net somewhere called "Advanced Character Physics" (google this) that explains the theory behind it, based on particles, mass, velocity, constraints, boundary conditions, etc, and how it is often applied to the animation of game characters and environments. But don't expect to be easy. :)

Cheers,

Dave Aberdeen

nolxev
April 24th, 2006, 08:33 AM
I think you should go with a precalculate net, animate it with sin function and random the ball position on it (without exaggerate with random). Modeling a realistic ball to animated net collision is hard to figure out, especially when you have not a lot of experience with these things. Quake III Arena uses precalcuate bezier with its level curves, and if you look them attentively you'll notice that the collision rocket-curves are not very amazing, so keep thing simple.

Hnefi
April 26th, 2006, 09:33 AM
There are several different approaches.

The first, and most ambitious one, is to use vertex displacement techniques with the help of a vertex shader on the net, which should be represented by a series of quads or quad strips compiled into a display list. This is not as hard as it sounds, but it requires that you check for shader support and read some articles on Cg or GLSL.

The second approach can give just as good results but far worse performance. Do something like this: represent the net with a two-dimensional array of vertices. When you draw the net, simply use GL_QUAD_STRIP and loop through the vertice array. When the ball hits the net, loop through the array and calculate the distance of each vertex from the ball. Use this value to displace each vertex along its normal according to an appropriate formula (probably something roughly like 1/(0.001 + dist).

These two approaches are very similar, but the first performs the calculations on the GPU while the second does them on the CPU. The first approach is obviously better but requires some extra work with extensions and shaders. For a basic application with a net consisting of only maybe 15x15 vertices, the second approach will do just fine.