Hello George,
I need some help with your lod booster. I use the code for a forest. From time to time, the different lod-models are not replaeced correctly. Sometimes when I get near to the model (under the lod-limit) there has to be the "normal" model without lod, but there isn't. But it sometimes it works... Do I have to change the code to use it with a lot of models?
here is the code. My models names are "tan_0.mdl" "tan_2.mdl" "tan_3.mdl"
Code:
define lod_dist_1, skill1;
define lod_dist_2, skill2;
string entname_str[30];
string templod_str[30];
// uses lod_dist_1, lod_dist_2
action lod_booster
{
var lod_step = 0;
if (my.skill1 == 0 || my.skill2 == 0) // if the player forgets to set the lod steps in Wed
{
my.skill1 = 1000; // set the default lod steps
my.skill2 = 3000;
}
my.material = mtl_vegetation;
my.obj_amb_fac = 0.3;
my.ambient = (-100+sun_angle.tilt*(my.obj_amb_fac*1))+(lightning/3);
while (1)
{
str_for_entfile (entname_str, my); // get the file name of the entity
str_cpy (templod_str, entname_str); // copy the name to templod_str
str_clip (templod_str, str_len(entname_str) - 6); // get rid of the first part of the name
str_trunc (templod_str, 5); // as well as of the last part of the name
str_cpy (templod_str, entname_str); // copy the name of the entity in templod_str again
str_clip (templod_str, str_len(entname_str) - 4); // we've got the extension name here (ex: .mdl)
temp = vec_dist (my.x, camera.x); // measure the distance between the camera and the entity
if (temp >= my.skill1) // the distance is bigger than the first lod step?
{
if (temp < my.skill2) // if it is smaller than the 2nd lod step, so we will use the 2nd model
{
if (lod_step != 2)
{
str_trunc (entname_str, 5);
str_cat (entname_str, "2");
str_cat (entname_str, templod_str);
ent_morph(my, entname_str);
}
}
else // the distance is bigger than the 2nd lod step as well, so we will use the 3rd model
{
if (lod_step != 3)
{
lod_step = 3;
str_trunc (entname_str, 5);
str_cat (entname_str, "3");
str_cat (entname_str, templod_str);
ent_morph(my, entname_str);
}
}
}
else // the entity is close to the camera, so we will use the 1st model
{
if (lod_step != 1)
{
lod_step = 1;
str_trunc (entname_str, 5);
str_cat (entname_str, "0");
str_cat (entname_str, templod_str);
ent_morph(my, entname_str);
}
}
// wait a random number of frames; this instruction splits the load over several frames, useful if we have many lod entities
wait (3 + random(20));
}
}