|
|
Re: Footsteps from AUM 8
[Re: 3run]
#328425
06/13/10 06:00
06/13/10 06:00
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Can you show me the lite-c please?
I'll see what I can do...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Footsteps from AUM 8
[Re: EvilSOB]
#328426
06/13/10 06:29
06/13/10 06:29
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
Here you go:
// don't forget to include this in the main script
// call texture_scan(); in your player script just before the while loop
SOUND* grass_snd = "grass.wav";
SOUND* stone_snd = "stone.wav";
#define grass 1 // to have some decent names as function arguments
#define stone 2
var step_length = 0;
VECTOR player_pos1;
VECTOR player_pos2;
function texture_sound(sound_type)
{
// you can have step_length % 3 to double the steps and so on
// I choose 6 to make sure that it will divide 1 and 3 (step_length += ...)
// 6 / 4 = 1.5 seconds between steps
if ((sound_type == grass) && (step_length % 6 == 0)) // 0, 6
{
snd_play (grass_snd, 60, 0);
}
if ((sound_type == stone) && (step_length % 6 == 0)) // 0, 6
{
snd_play (stone_snd, 50, 0);
}
if (step_length >= 6) {step_length = 0;}
}
function texture_scan()
{
while (player == NULL) {wait (1);}
while (1)
{
vec_set (player_pos1.x, player.x);
wait(1);
vec_set (player_pos2.x, player.x);
c_trace(my.x, vector(my.x, my.y, my.z - 100), IGNORE_ME + IGNORE_MODELS + IGNORE_PASSABLE + SCAN_TEXTURE);
if(vec_dist (player_pos1.x, player_pos2.x) != 0)
{
if (str_cmpi (tex_name,"grass1"))
{
texture_sound(grass);
}
else
{
texture_sound(stone);
}
}
step_length += 1 + 2 * key_shift; // add 4 (12 if shift is pressed) to step_length every second
wait (-1.5); // play with this
}
}
Not tested, but should work  Do not mind IGNORE_MODELS, it will work with models if you delet it, but not with multi terrain...
|
|
|
Re: Footsteps from AUM 8
[Re: 3run]
#328429
06/13/10 06:59
06/13/10 06:59
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I havent tested your function at all, but may do later when I have more time...
But I can see this whole detection revolves around the detected skin names. So it shouldnt be too hard to re-work for multi-texture at least.
BUT, after taking more of a look. It is much more involved with multi-tex surfaces. Referencing all three multi-texturing skins and extracting pixels at the contacted UV co-ord, and then getting its alpha... AND THEN doing the same for the other two skins, AND THEN picking the highest alpha of all three, and passing 1,2 or 3 to the sound-player is a lot of work...
So Im hoping you can figure out code for what Ive just said,
or better yet...
Someone else has a better idea!! Mine is hard work...
Sorry dude...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Footsteps from AUM 8
[Re: Roel]
#330141
06/25/10 22:05
06/25/10 22:05
|
Joined: Jul 2007
Posts: 620 Turkey, Izmir
Emre
User
|
User
Joined: Jul 2007
Posts: 620
Turkey, Izmir
|
and sample;
BMAP* color_bmap="color.bmp"; //colormap of the terrain
function color_scan()
{
var format,pixel;
COLOR pixel_color;
while(1)
{
c_trace(camera.x,vector(camera.x,camera.y,camera.z-5000),SCAN_TEXTURE);
if(HIT_TARGET)
{
draw_point3d(hit.x,vector(0,0,255),100,5);
format = bmap_lock (color_bmap,0);
pixel = pixel_for_bmap(color_bmap, hit.u1, hit.v1);
pixel_to_vec (pixel_color, NULL, format, pixel);
if(pixel_color.red>100)
{
draw_text("RED!",100,10,vector(100,100,255));
}
if(pixel_color.green>100)
{
draw_text("GREEN!",100,10,vector(100,100,255));
}
if(pixel_color.blue>100)
{
draw_text("BLUE!",100,10,vector(100,100,255));
}
bmap_unlock(color_bmap);
}
wait(1);
}
}
|
|
|
|