5 Replies - 4361 Views - Last Post: 14 December 2011 - 04:37 PM Rate Topic: -----

#1 philliph1986   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-December 11

explanation of how basic opengl water generating code is working

Posted 14 December 2011 - 03:24 PM

I am trying to get my head around how this water generating code is working, it's fairly basic. I don't quite understand it and it's an effect I would like to use. Could anyone give me a basic overview of what is happening here. I know an array of 2d points is being made, and I understand about normalisation and lighting. but any other explanation would be appreciate.

Code at this link

http://mirtchovski.c...opengl/watlit.c

Is This A Good Question/Topic? 0
  • +

Replies To: explanation of how basic opengl water generating code is working

#2 anonymous26   User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: explanation of how basic opengl water generating code is working

Posted 14 December 2011 - 03:53 PM

We can't be sure we are properly explaining it to you because we have no idea of what you are capable of understanding. How are you with C and OpenGL? Are you comfortable coding with them to some level?
Was This Post Helpful? 0
  • +
  • -

#3 philliph1986   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-December 11

Re: explanation of how basic opengl water generating code is working

Posted 14 December 2011 - 04:02 PM

View PostButchDean, on 14 December 2011 - 03:53 PM, said:

We can't be sure we are properly explaining it to you because we have no idea of what you are capable of understanding. How are you with C and OpenGL? Are you comfortable coding with them to some level?



thanks for replying. yes i'm fairly comfortable, alot more comfortable with C though . just confused with how this has been setup. I just want to get a general idea of what's going on, it doesn't have to be massively in depth. For example, i understand this is an array of points creating a mesh, but i dont understand why the array of points is three dimensional as only the x and y coordinates are stored. I want to know how making this a three dimensional array aids the affect why the calcwater method is called every scene and to what degree this aids the ripple affect. Just some pointers in the right direction will help me get my head around it
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26   User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: explanation of how basic opengl water generating code is working

Posted 14 December 2011 - 04:16 PM

View Postphilliph1986, on 14 December 2011 - 11:02 PM, said:

it doesn't have to be massively in depth. For example, i understand this is an array of points creating a mesh, but i dont understand why the array of points is three dimensional as only the x and y coordinates are stored.

If you look at the declaration for the 3D array

float water[2][WATERSIZE][WATERSIZE];

Two surfaces are being declared that are 2x 2D square arrays of which x and y have WATERSIZE number of points. The function void idle(void) randomizes the fluid points in that array. The function void calcwater() is responsible for calculating the points on the x-y plane for each point of the two surfaces. The void display(void) renders the values in the water by passing those values to the OpenGL pipeline.

View Postphilliph1986, on 14 December 2011 - 11:02 PM, said:

I want to know how making this a three dimensional array aids the affect why the calcwater method is called every scene and to what degree this aids the ripple affect. Just some pointers in the right direction will help me get my head around it

Having two surfaces improves the effect, otherwise it might look closer to a waving flag.
Was This Post Helpful? 0
  • +
  • -

#5 philliph1986   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-December 11

Re: explanation of how basic opengl water generating code is working

Posted 14 December 2011 - 04:29 PM

thank you mate, that is really helpful. So am i right in thinking random ripples are generated in the idle function and this being in two arrays makes the affect more ripple like. Can I just ask what you mean by fluid points. Thank you so much!
Was This Post Helpful? 0
  • +
  • -

#6 anonymous26   User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: explanation of how basic opengl water generating code is working

Posted 14 December 2011 - 04:37 PM

View Postphilliph1986, on 14 December 2011 - 11:29 PM, said:

thank you mate, that is really helpful. So am i right in thinking random ripples are generated in the idle function and this being in two arrays makes the affect more ripple like.

Yes. Investigate glutIdleFunc(idle); and see the purpose of glutIdleFunc(). See what's going on there?

View Postphilliph1986, on 14 December 2011 - 11:29 PM, said:

Can I just ask what you mean by fluid points. Thank you so much!

The 'fluid points' is every point on the x- and y-planes/axes indexed from 0 to WATERSIZE-1. This is clearly shown in calcwater().
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1