This tut is about how to make controlable water waves For this tut we have to modify three files, that would be : "gl_warp.c, gl_local.h and gl_main.c" First open up "gl_local.h", go to the line that says : extern cvar_t *r_lightlevel; And paste this below: extern cvar_t *r_wave; // Water waves Ok, in this file we are done. Now open "gl_main.c" Go to the line that looks like this : cvar_t *r_lightlevel; Paste this below it : cvar_t *r_wave; // Water waves And now go to the function caled : void R_Register( void ) Find this line : r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0); And paste this below it : r_wave = ri.Cvar_Get ("r_wave", "2", 0); // Water waves
Ok, this file is done ! vec3_t nv; // Water waves Now in the same function go to line : "qglTexCoord2f (s, t);" And at the botom of this line paste the water wave code : //=============== Water waves ============ if (!(fa->texinfo->flags & SURF_FLOWING)) { nv[0] =v[0]; nv[1] =v[1]; #if !id386 nv[2] =v[2] + r_wave->value *sin(v[0]*0.025+r_newrefdef.time)*sin(v[2]*0.05+r_newrefdef.time) + r_wave->value *sin(v[1]*0.025+r_newrefdef.time*2)*sin(v[2]*0.05+r_newrefdef.time); #else nv[2] =v[2] + r_wave->value *sin(v[0]*0.025+rdt)*sin(v[2]*0.05+r_newrefdef.time) + r_wave->value *sin(v[1]*0.025+rdt*2)*sin(v[2]*0.05+rdt); #endif qglVertex3fv (nv); } else //============= Water waves end. ============== qglVertex3fv (v); } qglEnd (); } } Thats all ! Enjoy the water waves. |