Posted By: txesmi
#include <acknex.h>
#include <default.c>
ANGLE atemp;
VECTOR vtemp;
FONT *standard_font = "Arial#14b";
BMAP *projectiontex = "Spotlight.tga";
function evnProjMain ();
function evnProjSecond ();
function evnProjThird ();
function evnProjFourth ();
function evnShadMain ();
function evnShadSecond ();
function evnShadThird ();
function evnShadFourth ();
float ProjMatMain[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float ShadMatMain[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float ProjMatSecond[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float ShadMatSecond[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float ProjMatThird[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float ShadMatThird[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float ProjMatFourth[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
float ShadMatFourth[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
BMAP *bmpShadMain;
BMAP *bmpShadSecond;
BMAP *bmpShadThird;
BMAP *bmpShadFourth;
var F1Pos[3];
var F1Ang[3];
var F1Ran;
var F1Int;
var F2Pos[3];
var F2Ang[3];
var F2Ran;
var F2Int;
var F3Pos[3];
var F3Ang[3];
var F3Ran;
var F3Int;
var F4Pos[3];
var F4Ang[3];
var F4Ran;
var F4Int;
MATERIAL *mtlSpotlit =
{
flags = TANGENT | ENABLE_RENDER | AUTORELOAD;
effect = "focos2.fx";
}
function init_mat_startup()
{
mat_identity(ShadMatMain);
mat_effect1 = ShadMatMain;
mat_identity(ProjMatMain);
mat_effect2 = ProjMatMain;
mat_identity(ShadMatSecond);
mat_effect3 = ShadMatSecond;
mat_identity(ProjMatSecond);
mat_effect4 = ProjMatSecond;
mat_identity(ShadMatThird);
mat_effect5 = ShadMatThird;
mat_identity(ProjMatThird);
mat_effect6 = ProjMatThird;
mat_identity(ShadMatFourth);
mat_effect7 = ShadMatFourth;
mat_identity(ProjMatFourth);
mat_effect8 = ProjMatFourth;
}
MATERIAL *mtlProjMain =
{
effect = " technique DummyTechnique { pass p0{}}";
event = evnProjMain;
flags = ENABLE_VIEW;
}
MATERIAL *mtlProjSecond =
{
effect = " technique DummyTechnique { pass p0{}}";
event = evnProjSecond;
flags = ENABLE_VIEW;
}
MATERIAL *mtlProjThird =
{
effect = " technique DummyTechnique { pass p0{}}";
event = evnProjThird;
flags = ENABLE_VIEW;
}
MATERIAL *mtlProjFourth =
{
effect = " technique DummyTechnique { pass p0{}}";
event = evnProjFourth;
flags = ENABLE_VIEW;
}
VIEW *viewProjMain =
{
material = mtlProjMain;
flags = VISIBLE;
}
VIEW *viewProjSecond =
{
material = mtlProjSecond;
flags = VISIBLE;
}
VIEW *viewProjThird =
{
material = mtlProjThird;
flags = VISIBLE;
}
VIEW *viewProjFourth =
{
material = mtlProjFourth;
flags = VISIBLE;
}
function evnProjMain ()
{
float pTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
pTexAdj[12] = 0.5 + (0.5/(float)bmap_width(projectiontex));
pTexAdj[13] = 0.5 + (0.5/(float)bmap_height(projectiontex));
mat_set(ProjMatMain,matViewProj);
mat_multiply(ProjMatMain,pTexAdj);
}
function evnProjSecond ()
{
float pTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
pTexAdj[12] = 0.5 + (0.5/(float)bmap_width(projectiontex));
pTexAdj[13] = 0.5 + (0.5/(float)bmap_height(projectiontex));
mat_set(ProjMatSecond,matViewProj);
mat_multiply(ProjMatSecond,pTexAdj);
}
function evnProjThird ()
{
float pTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
pTexAdj[12] = 0.5 + (0.5/(float)bmap_width(projectiontex));
pTexAdj[13] = 0.5 + (0.5/(float)bmap_height(projectiontex));
mat_set(ProjMatThird,matViewProj);
mat_multiply(ProjMatThird,pTexAdj);
}
function evnProjFourth ()
{
float pTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
pTexAdj[12] = 0.5 + (0.5/(float)bmap_width(projectiontex));
pTexAdj[13] = 0.5 + (0.5/(float)bmap_height(projectiontex));
mat_set(ProjMatFourth,matViewProj);
mat_multiply(ProjMatFourth,pTexAdj);
}
MATERIAL *mtlShadMain =
{
effect = "Depth.fx";
event = evnShadMain;
flags = ENABLE_VIEW;
}
MATERIAL *mtlShadSecond =
{
effect = "Depth.fx";
event = evnShadSecond;
flags = ENABLE_VIEW;
}
MATERIAL *mtlShadThird =
{
effect = "Depth.fx";
event = evnShadThird;
flags = ENABLE_VIEW;
}
MATERIAL *mtlShadFourth =
{
effect = "Depth.fx";
event = evnShadFourth;
flags = ENABLE_VIEW;
}
VIEW *viewShadMain =
{
//bmap = bmpShadMain;
material = mtlShadMain;
flags = VISIBLE;
}
VIEW *viewShadSecond =
{
//bmap = bmpShadSecond;
material = mtlShadSecond;
flags = VISIBLE;
}
VIEW *viewShadThird =
{
//bmap = bmpShadThird;
material = mtlShadThird;
flags = VISIBLE;
}
VIEW *viewShadFourth =
{
//bmap = bmpShadFourth;
material = mtlShadFourth;
flags = VISIBLE;
}
function evnShadMain()
{
float sTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
if(viewShadMain.bmap)
{
sTexAdj[12] = 0.5 + (0.5/(float)viewShadMain.bmap.width);
sTexAdj[13] = 0.5 + (0.5/(float)viewShadMain.bmap.height);
}
mat_set(ShadMatMain,matViewProj);
mat_multiply(ShadMatMain,sTexAdj);
}
function evnShadSecond ()
{
float sTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
if(viewShadSecond.bmap)
{
sTexAdj[12] = 0.5 + (0.5/(float)viewShadSecond.bmap.width);
sTexAdj[13] = 0.5 + (0.5/(float)viewShadSecond.bmap.height);
}
mat_set(ShadMatSecond,matViewProj);
mat_multiply(ShadMatSecond,sTexAdj);
}
function evnShadThird ()
{
float sTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
if(viewShadThird.bmap)
{
sTexAdj[12] = 0.5 + (0.5/(float)viewShadThird.bmap.width);
sTexAdj[13] = 0.5 + (0.5/(float)viewShadThird.bmap.height);
}
mat_set(ShadMatThird,matViewProj);
mat_multiply(ShadMatThird,sTexAdj);
}
function evnShadFourth ()
{
float sTexAdj[16] = { 0.5, 0.0, 0.0, 0.0, 0.0,-0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
if(viewShadFourth.bmap)
{
sTexAdj[12] = 0.5 + (0.5/(float)viewShadFourth.bmap.width);
sTexAdj[13] = 0.5 + (0.5/(float)viewShadFourth.bmap.height);
}
mat_set(ShadMatFourth,matViewProj);
mat_multiply(ShadMatFourth,sTexAdj);
}
function Spotlight ()
{
set ( me, INVISIBLE );
c_setminmax (me);
while ( !my.parent ) wait(1);
set ( my.parent, PASSABLE );
while(me)
{
if ( mouse_middle )
camera.pan += mickey.x * 0.1;
vec_set ( vtemp, vector((key_w - key_s)*time_step*8,(key_a - key_d)*time_step*8,0));
vec_rotate ( vtemp, vector(camera.pan, 0, 0 ) );
c_move ( my, nullvector, vtemp, IGNORE_PASSABLE | GLIDE );
vec_for_angle ( vtemp, camera.pan );
vec_scale ( vtemp, -300 );
vec_add ( vtemp, my.x );
vec_set ( camera.x, vtemp );
vec_set ( vtemp, mouse_dir3d );
vec_scale ( vtemp, -camera.z/vtemp.z );
vec_add ( vtemp, camera.x );
//vtemp.z += 30;
vec_sub ( vtemp, my.x );
vec_to_angle ( atemp, vtemp );
atemp.tilt = maxv ( atemp.tilt, -45 );
c_rotate ( my, vector(ang(atemp.pan-my.pan)*time_step*0.4, ang(atemp.tilt-my.tilt)*time_step*0.4, 0 ), GLIDE | IGNORE_PASSABLE );
my.parent.x = my.x;
my.parent.y = my.y;
my.parent.pan = my.pan;
vec_for_angle ( vtemp.x, vector(my.pan+45,my.tilt,.0) );
vec_normalize ( vtemp, 30 );
vec_add ( vtemp, my.x );
vec_set(viewProjMain.x, vtemp);
vec_set(viewProjMain.pan, my.pan);
vec_set(viewShadMain.x, vtemp);
vec_set(viewShadMain.pan, my.pan);
F1Pos[0] = floatv(vtemp.x);
F1Pos[1] = floatv(vtemp.z); // z and y must be reversed!
F1Pos[2] = floatv(vtemp.y);
F1Ran = floatv(380); // spotlight range
vec_for_angle(vtemp.x, my.pan);
F1Ang[0] = floatv(vtemp.x);
F1Ang[1] = floatv(vtemp.z); // z and y must be reversed!
F1Ang[2] = floatv(vtemp.y);
F1Int = floatv(2); // light intensity
wait(1);
}
}
//=======================================================================================
// MAIN
//=======================================================================================
void main()
{
int i;
d3d_triplebuffer = 1;
d3d_lightres = 1;
fps_max = 5000;
preload_mode = 3;
video_mode = 10;
//video_set(sys_metrics(0),sys_metrics(1),32,1);
level_load("");
camera.layer = 10;
wait(3);
bmpShadMain = bmap_create ( "#1024x1024x14" );
bmpShadSecond = bmap_create ( "#1024x1024x14" );
bmpShadThird = bmap_create ( "#1024x1024x14" );
bmpShadFourth = bmap_create ( "#1024x1024x14" );
mouse_mode = 4;
camera.tilt = -70;
camera.arc = 90;
sun_light = 0;
you = ent_create ( "suelo.mdl", vector(0,0,0), NULL );
you.material = mtlSpotlit;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "columna01B.mdl", vector(88,88,0), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "columna01B.mdl", vector(-88,88,0), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "columna01B.mdl", vector(88,-88,0), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "columna01B.mdl", vector(-88,-88,0), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "caja01.mdl", vector(170,-70,0), NULL );
you.material = mtlSpotlit;
you.pan = 193;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "barril01b.mdl", vector(190,-30,0), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "palet02b.mdl", vector(-116,-83,35), NULL );
you.material = mtlSpotlit;
you.pan = 15;
you.tilt = 70;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "caja02b.mdl", vector(-176,-63,0), NULL );
you.material = mtlSpotlit;
you.pan = -7;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "caja02b.mdl", vector(-176,-103,0), NULL );
you.material = mtlSpotlit;
you.pan = -197;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "caja02b.mdl", vector(-166,-83,22), NULL );
you.material = mtlSpotlit;
you.pan = -92;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "palet01b.mdl", vector(159,73,0), NULL );
you.material = mtlSpotlit;
you.pan = -94;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "barril02b.mdl", vector(143,63,13.5), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "barril02b.mdl", vector(175,47,13.5), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "barril02b.mdl", vector(149,100,13.5), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "barril02b.mdl", vector(181,83,13.5), NULL );
you.material = mtlSpotlit;
you.pan = random(360);
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "caja01.mdl", vector(-150,190,0), NULL );
you.material = mtlSpotlit;
you.pan = -42;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "caja01.mdl", vector(-190,150,0), NULL );
you.material = mtlSpotlit;
you.pan = -44;
c_setminmax (you);
set(you,PASSABLE);
you = ent_create ( "cube.mdl", vector (0,0,64), Spotlight );
//you.lightrange = 450;
you.parent = ent_create ( "cyberdemon2.mdl", vector (128,128,32), NULL );
vec_fill ( you.parent.scale_x, 0.3 );
you.parent.material = mtlSpotlit;
ent_animate ( you.parent, "construct", 1, NULL );
set(you.parent,PASSABLE);
you = ent_createlayer ( "sky+6.tga", SKY | CUBE | SHOW, 1 );
viewProjMain.aspect = 0.7;
viewProjMain.arc = 60;
viewShadMain.arc = 60;
viewProjSecond.aspect = 0.7;
viewProjSecond.arc = 60;
viewShadSecond.arc = 60;
viewProjThird.aspect = 0.7;
viewProjThird.arc = 80;
viewShadThird.arc = 80;
viewProjFourth.aspect = 0.7;
viewProjFourth.arc = 70;
viewShadFourth.arc = 70;
viewShadMain.bmap = bmpShadMain;
viewShadSecond.bmap = bmpShadSecond;
viewShadThird.bmap = bmpShadThird;
viewShadFourth.bmap = bmpShadFourth;
mtlSpotlit.skin1 = bmpShadMain;
mtlSpotlit.skin2 = bmpShadSecond;
mtlSpotlit.skin3 = bmpShadThird;
mtlSpotlit.skin4 = bmpShadFourth;
vec_set ( vtemp, vector(-88,75,128) );
vec_set ( atemp, vector(240,-30,0) );
vec_set ( viewProjSecond.x, vtemp );
vec_set ( viewProjSecond.pan, atemp.pan );
vec_set ( viewShadSecond.x, vtemp );
vec_set ( viewShadSecond.pan, atemp.pan );
F2Pos[0] = floatv(vtemp.x);
F2Pos[1] = floatv(vtemp.z);
F2Pos[2] = floatv(vtemp.y);
F2Ran = floatv(650);
vec_for_angle ( vtemp.x, atemp.pan );
F2Ang[0] = floatv(vtemp.x);
F2Ang[1] = floatv(vtemp.z);
F2Ang[2] = floatv(vtemp.y);
F2Int = floatv(1);
vec_set ( vtemp, vector(110,88,148) );
vec_set ( atemp, vector(-15,-60,0) );
vec_set ( viewProjThird.x, vtemp );
vec_set ( viewProjThird.pan, atemp.pan );
vec_set ( viewShadThird.x, vtemp );
vec_set ( viewShadThird.pan, atemp.pan );
F3Pos[0] = floatv(vtemp.x);
F3Pos[1] = floatv(vtemp.z);
F3Pos[2] = floatv(vtemp.y);
F3Ran = floatv(650);
vec_for_angle ( vtemp.x, atemp.pan );
F3Ang[0] = floatv(vtemp.x);
F3Ang[1] = floatv(vtemp.z);
F3Ang[2] = floatv(vtemp.y);
F3Int = floatv(1);
vec_set ( vtemp, vector(0,0,230) );
vec_set ( atemp, vector(0,-90,0) );
vec_set ( viewProjFourth.x, vtemp );
vec_set ( viewProjFourth.pan, atemp.pan );
vec_set ( viewShadFourth.x, vtemp );
vec_set ( viewShadFourth.pan, atemp.pan );
F4Pos[0] = floatv(vtemp.x);
F4Pos[1] = floatv(vtemp.z);
F4Pos[2] = floatv(vtemp.y);
F4Ran = floatv(650);
vec_for_angle ( vtemp.x, atemp.pan );
F4Ang[0] = floatv(vtemp.x);
F4Ang[1] = floatv(vtemp.z);
F4Ang[2] = floatv(vtemp.y);
F4Int = floatv(0.5);
}
