BMAP* waterbump = "waves.jpg";
BMAP* envspec = "sky.jpg";
BMAP* bmap_mirrortarget;
VIEW view_mirror = { bmap = bmap_mirrortarget; } // render mirror view before camera view
function mtl_ffpwater_event();
MATERIAL* mtl_ffpwater =
{
skin1=waterbump;
skin2=envspec;
flags=TRANSLUCENT;
event = mtl_ffpwater_event;
effect = "Normalmap.fx";
}
function mtl_ffpwater_event()
{
while(1)
{
//Lets make it scroll in some direction
mtl_ffpwater.skill1 += 3*time_step; //Move the water along the x axis with the given speed
mtl_ffpwater.skill2 += 3*time_step; //Move the water along the y axis with the given speed
mtl_ffpwater.matrix31 = floatd(sin(mtl_ffpwater.skill1)*100000,40000);
mtl_ffpwater.matrix32 = floatd(cos(mtl_ffpwater.skill2)*100000,40000);
wait(1);
}
}
//BMAP* bmap_mirrortarget;
//panel rtt{flags = visible;}
function fx_mirror()
{
// do nothing if mirror is already running
if (bmap_mirrortarget) { return; }
bmap_mirrortarget = bmap_createblack(512,512,888);
mtl_ffpwater.skin2 = bmap_mirrortarget;
// view_mirror.bmap = bmap_mirrortarget;
// view_mirror.size_x = bmap_width(bmap_mirrortarget);
// view_mirror.size_y = bmap_height(bmap_mirrortarget);
// rtt.bmap = bmap_mirrortarget;
//
// vec_set(view_mirror.portal_x,my.x);
// vec_add(view_mirror.portal_x,vector(0,0,0));
// vec_set(view_mirror.pnormal_x,vector(0,0,1.0)); // reflect upwards
// set(view_mirror,PORTALCLIP);// = on; // clip at portal plane
//
// set(view_mirror,NOCULL); // view through walls
//
// set(view_mirror,VISIBLE);
while (bmap_mirrortarget)
{
//proc_late(); // camera must be moved and mtlfx_mirrorvisible set before
// view_mirror.aspect = 1;//1024/768; // screen aspect, independent of render target
// view_mirror.arc = camera.arc;
// view_mirror.fog_start = camera.fog_start;
// view_mirror.fog_end = camera.fog_end;
// view_mirror.clip_far = camera.clip_far;
// view_mirror.clip_near = camera.clip_near;
// view_mirror.x = camera.x;
// view_mirror.y = camera.y;
// view_mirror.z = 2*my.z-camera.z;//view_mirror.portal_z-camera.z; // move the camera at its mirror position
// view_mirror.pan = camera.pan;
// view_mirror.tilt = -camera.tilt; // flip the vertical camera angle
// view_mirror.roll = -camera.roll;
wait(1);
}
}
action Water()
{
mtl_ffpwater.matrix11 = floatv(100); //Tilefactor of the Bumpmap in x direction
mtl_ffpwater.matrix22 = floatv(100); //Tilefactor of the Bumpmap in y direction
bmap_to_mipmap(mtl_ffpwater.skin1);
bmap_to_mipmap(mtl_ffpwater.skin2);
my.material = mtl_ffpwater;
//fx_mirror();
}