I have bump mapping working on my level geometry, but it won't react to flashlight code. the flashlight is working (some of my geometry is not bump mapped)
Any help would be appreciated.
Code:
bmap detail_floor1, <floorplate02_nmap.tga>;// this is your normalmap!(the blue-pink)
function init_detail_mapping
{
bmap_to_mipmap(mtl.skin1);
}
material floorplate02 // this is your wad texture in wed you use this for the block
{
event=init_detail_mapping;
skin1=detail_floor1;
effect=
"
matrix matWorldViewProj;
matrix matWorld;
texture mtlSkin1;
texture entSkin1;
texture entSkin2;
vector vecLight;
technique dot3map
{
pass p0
{
Texture[0] = <mtlSkin1>;
Texture[1] = <entSkin2>;
Texture[2] = <entSkin1>;
TextureFactor = 0xFFFFFFFF;
COLOROP[0] = DotProduct3;
COLORARG1[0] = Texture;
COLORARG2[0] = TFactor;
TexCoordIndex[0] = 1;
COLOROP[1] = Modulate;
COLORARG1[1] = Texture;
COLORARG2[1] = Current;
TexCoordIndex[1] = 0;
magFilter[2]=Linear;
minFilter[2]=Linear;
mipFilter[2]=Linear;
COLOROP[2] = AddSigned;
COLORARG1[2] = Texture;
COLORARG2[2] = Current;
TexCoordIndex[2] = 1;
}
}
";
}
Code:
var d3d_lightres = 1;
var flashlight_pos[3] = -100,0,0; //change to set the distance from the camera
var flash_light;
var temp_cdist[3] = -100,0,0; //beginning distance, same as flashlight_pos
var temp2[3]; //another temp varstring
entity* light_spot; //the one and only flashlight entity
action ent_flashlight
{
light_spot = my;
my.invisible = on;
my.passable = on;
move_flash_light();
}
function move_flash_light()
{
var flashlight_target[3];
while(1)
{
// orientate the flashlight
light_spot.pan += time * ang(camera.pan-light_spot.pan);
light_spot.tilt = camera.tilt; // tilt flashligth with camera
flashlight_pos.z = camera.z/2;
// set view target to player origin + eye_height offset
vec_set(flashlight_target.x,camera.x);
flashlight_target.z = camera.z;
// temp is now the target offset
vec_set(temp,flashlight_pos);
vec_scale(temp,-1); // negate direction (compatibility issues)
// Rotate the flashlight offset by the player's orientation
temp2 = camera.TILT; // save camera tilt
light_spot.TILT = camera.tilt; // use camera for tilt
vec_rotate(temp,light_spot.PAN); // temp = new target vector
light_spot.TILT = temp2; // restore camera tilt
// offset flashlight offset by player position
vec_add(temp,camera.x);
// move towards target position
temp2 = min(1,1 * TIME); // value of 1 places us at target
temp_cdist.X += temp2*(temp.x - temp_cdist.X);
temp_cdist.Y += temp2*(temp.y - temp_cdist.Y);
temp_cdist.Z += temp2*(temp.z - temp_cdist.Z);
// keep flashlight from penetrating walls
vec_diff(temp2.x,temp_cdist.x,flashlight_target.x);
vec_normalize(temp2.x,16);
vec_add(temp2.x,temp_cdist.x);// 16 units away from view target
me = player;
trace_mode = ignore_me + ignore_passable + ignore_models + ignore_sprites;
if( trace(flashlight_target.x,temp2.x) > 0) // trace hit something
{
// note: trace sets target vector to hit point
vec_diff(temp2.x,flashlight_target.x,target.x); // view target
vec_normalize(temp2.x,16); // back off 16 units from wall
// set flashlight = target - 16 units
vec_set(light_spot.x,target.x);
vec_add(light_spot.x,temp2.x);
}
else
{
vec_set(light_spot.x,temp_cdist.x); // set to original camera target
}
wait(1);
}
}
function flashlight_toggle()
{
if (flash_light == 0)
{
flash_light = 1;
light_spot.light=on;
light_spot.lightrange = 400;
wait(4);
}
else
{
flash_light = 0;
light_spot.light=off;
light_spot.lightrange = 0;
wait(1);
}
}
ON_F flashlight_toggle();