Written by Jacques Krige (Korax)
Lets add some cool waterripple to the engine.
In actual fact I've hacked this tutorial off the code from disabling the waterwarp.
Actually I'm warping the water surface instead of the walls and stuff :) cvar_t gl_reporttjunctions ="gl_reporttjunctions","0"};Then right below it add the following: //jkrige - cvars cvar_t gl_waterripple ="gl_waterripple", "2"}; //jkrige - cvarsNow open the file called "glquake.h" and find the following line: extern cvar_t gl_playermip;Below that add the following: //jkrige extern cvar_t gl_waterripple; //jkrigeNow, lets go register our new CVAR: Open the file called "gl_rmisc.c" and find the function called "R_Init". In that function find the line: Cvar_RegisterVariable (&gl_reporttjunctions);Below that line, add the following: //jkrige - cvars Cvar_RegisterVariable (&gl_waterripple); //jkrige - cvarsNow for the fun-part. Open up the file called gl_warp.c and find the function called "EmitWaterPolys". When you did, replace it with this function I've already modified for you: void EmitWaterPolys (msurface_t *fa) { glpoly_t *p; float *v; int i; float s, t, os, ot; vec3_t nv; //jkrige - clamp waterripple values if(gl_waterripple.value>10) gl_waterripple.value=10; if(gl_waterripple.value<0) gl_waterripple.value=0 //jkrige - clamp waterripple values for (p=fa->polys ; p ; p=p->next) { glBegin (GL_POLYGON); for (i=0,v=p->verts[0] ; iThere! What I did is clamp the size of the warp or ripple effect you can have. Does it get any easier? :) Enjoy the tutorial and rock-on! Jacques Krige. |