this is MY code For "Real" Cube map DX8

:


var cuberesolution=128; // set up the resolution of the cube here
//var cubeposition[3]=0,0,200; // set up the position of the cube here (you could also set cubeposition to the camera position)
var cubeposition=player.pos; // set up the position of the cube here (you could also set cubeposition to the camera position)
var west[3]=180,0,0;
var north[3]=90,0,0;
var east[3]=0,0,0;
var south[3]=-90,0,0;
var down[3]=90,-90,0;
var up[3]=90,90,0;




bmap cube_panel =<cube.tga>;

panel cube_map{

layer=1;
bmap = cube_panel;
flags = visible, overlay;
pos_x=0;
pos_y=0;


}
view Cv_w
{
layer = 2;


pos_y = 0;
size_x = 128;
size_y = 128;
arc = 90;
aspect = 1;
flags= visible;

}


view Cv_n
{
layer = 2;

pos_y = 0;
size_x = 128;
size_y = 128;
arc = 90;
aspect = 1;
flags= visible;

}
view Cv_e
{
layer = 2;

pos_y = 0;
size_x = 128;
size_y = 128;
arc = 90;
aspect = 1;
flags= visible;

}
view Cv_s
{
layer = 2;

pos_y = 0;
size_x = 128;
size_y = 128;
arc = 90;
aspect = 1;
flags= visible;

}
view Cv_d
{
layer = 2;

pos_y = 0;
size_x = 128;
size_y = 128;
arc = 90;
aspect = 1;
flags= visible;

}
view Cv_u
{
layer = 2;

pos_y = 0;
size_x = 128;
size_y = 128;
arc = 90;
aspect = 1;
flags= visible;

}



var n=0;
var v=0;
var r=0;
var cubeposition1;
function CUbereal {





while(1){


cubeposition=player.pos;


vec_set(cv_w.x,cubeposition1);
vec_set(cv_w.pan,west);
cv_w.x=player.x;
cv_w.y=player.y;

v=-128;
n=1;
cv_w.pos_x=v+128*n;
n=2;
cv_n.pos_x=v+128*n;
n=3;
cv_e.pos_x=v+128*n;
n=4;
cv_s.pos_x=v+128*n;
n=5;
cv_d.pos_x=v+128*n;
n=6;
cv_u.pos_x=v+128*n;


vec_set(cv_n.x,cubeposition1);
vec_set(cv_n.pan,north);
cv_n.x=player.x;
cv_n.y=player.y;

vec_set(cv_e.x,cubeposition1);
vec_set(cv_e.pan,east);
cv_e.x=player.x;
cv_e.y=player.y;

vec_set(cv_s.x,cubeposition1);
vec_set(cv_s.pan,south);
cv_s.x=player.x;
cv_s.y=player.y;

vec_set(cv_d.x,cubeposition1);
vec_set(cv_d.pan,down);
cv_d.x=player.x;
cv_d.y=player.y;


vec_set(cv_u.x,cubeposition1);
vec_set(cv_u.pan,up);
cv_u.x=player.x;
cv_u.y=player.y;








wait(1);

}


}

bmap bcube=<shot_0.bmp>;
bmap bcube1=<shot_1.bmp>;



function take_cube {
player.invisible=on;
CUbereal();
player.invisible=on;
video_set(768,128,32,2);wait(2);
screenshot("shot_",_shot_no);
wait(2);
//video_switch(800,650,32,1);
video_switch(7,32,1);



}
//on_c CUbereal;
on_t take_cube;


}



function mtl_envmap_view()
{
mat_set(mtl.matrix,matViewInv);
mtl.matrix41=0;
mtl.matrix42=0;
mtl.matrix43=0;
}




function mtl_envmap_init()
{


player.invisible=on;
take_cube();
player.invisible=on;
//bmap_purge(bcube); // Get rid of what is in tex memory
// read from disk // as Skin1, else it will accumulate and
bmap_load(bcube, "shot_0.bmp",0);



//...maybe you should copy the mat_model properties here...

mtl.skin1=bcube;

bmap_to_cubemap(mtl.skin1);
mtl.event=mtl_envmap_view;
mtl.enable_view=on;
mtl.enable_render=on;
player.invisible=off;



}


material mtl_envmap
{

event=mtl_envmap_init;

effect=
"
texture entSkin1;
texture mtlSkin1;
matrix matMtl;
technique envmap
{
pass p0
{
texture[0]=<entSkin1>;
texture[1]=<mtlSkin1>;

zWriteEnable=true;
alphaBlendEnable=false;

colorArg1[0]=Texture;
colorOp[0]=Modulate2x;
colorArg2[0]=Diffuse;

colorArg1[1]=Texture;
colorOp[1]=blendCurrentAlpha;
addressU[1]=Clamp;
addressV[1]=Clamp;
texCoordIndex[1]=cameraSpaceReflectionVector;
textureTransformFlags[1]=Count3;
textureTransform[1]=<matMtl>; // transform camera space back to world space
}
}
";
}

//starter lol
//{mtl_envmap.skin1=bcube;
//wait(1);

//}


action Reflections {

//VLight_orange();
//physics_lamp();

// my.pan+=8*time;
// my.roll+=8*time;


my.material=mtl_envmap;
}


function mem {

//player.invisible=on;
player.invisible=on;


bmap_purge(mtl_envmap.skin1);
mtl_envmap.skin1=mtl_envmap.skin1;
mtl_envmap_init();


}

on_t mem;







action player1
{my.material=mtl_envmap;
player = my;
//my.invisible = on;
my.passable=on;
while (1)
{
camera.x=player.x;
camera.y=player.y;

//vec_set (camera.x, my.x);
//vec_set (camera.y, my.y);
//vec_set (camera.pos, my.pos);
//vec_set (camera.pos, my.pos);

camera.pan = my.pan;
camera.tilt += 10 * mouse_force.y * time;
my.pan -= 10 * mouse_force.x * time;
temp.x = 25 * (key_w - key_s) * time;
temp.y = 25 * (key_a - key_d) * time;
//temp.z = 0;

ent_move (temp, nullvector);
wait (1);
}

}






you need a bmap called.. go check it above lazy "shot_0.bmp"

Oh and [T] to save the cube map to a file ... then all you need to do is A env shader, where the file you use as cube map is that one.. so its refreshed.. the shader name I have is reflections, but you assig it to the player or something like that .. action player1 then you must use orbital cam , to check the effect..

Last edited by Unknot; 01/02/05 00:34.