1 registered members (TipmyPip),
18,449
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: A6LOD: LOD(Levels Of Detail) Plugin!
[Re: Josh_Arldt]
#55493
10/01/05 04:47
10/01/05 04:47
|
Joined: Nov 2004
Posts: 113 canada EH!?
zammmm
Member
|
Member
Joined: Nov 2004
Posts: 113
canada EH!?
|
Ya, C++ tends to be faster then c script  , also this way gives you more options and power. Nice job Josh, Its nice that it supports unlimited ammount of levels.
-- Send me a shout at zammmm@gmail.com, also got MSN messenger, Xbox Live, "random FIRE", Xfire, "zammmm" and Steam, "zammmm".
--------------------
|
|
|
Re: A6LOD: LOD(Levels Of Detail) Plugin!
[Re: zammmm]
#55494
10/02/05 17:59
10/02/05 17:59
|
Joined: Apr 2003
Posts: 1,044 Deutschland
Iron Chancellor
Senior Developer
|
Senior Developer
Joined: Apr 2003
Posts: 1,044
Deutschland
|
Hi, Some years ago I wrote a little script to add LOD to standard: Code:
/////////////////////////////////////////////////////////////////////////////////////////////// /////// LOD for A6 Standard ///////////////////////////////////////////////////////////////////////////////////////////////
// Strings
string lod1; string lod1_b; string lod1_1 = "_1";
string lod2; string lod2_b; string lod2_3 = "_2";
string lod3; string lod3_b; string lod3_3 = "_3";
function generate_filename_lod1() { var lod1_lenght; var lod1_cut; str_for_entfile(lod1, me); str_cpy(lod1_b, lod1); // Erzeuge eine Sicherheitskopie des strings lod1 lod1_lenght = str_len(lod1); lod1_cut = lod1_lenght - 6; str_clip(lod1, lod1_cut); // Jetzt haben wir die Dateiendung im string lod1 str_trunc(lod1_b, 6); // Jetzt haben wir den Dateinamen ohne Endung und ohne _0 im string lod1_b str_cat(lod1_b, lod1_1); // Füge "_1" am Ende des Dateinamens hinzu str_cat(lod1_b, lod1); // Füge die Dateiendung hinzu
function generate_filename_lod2() { var lod2_lenght; var lod2_cut; str_for_entfile(lod2, me); str_cpy(lod2_b, lod2); // Erzeuge eine Sicherheitskopie des strings lod2 lod2_lenght = str_len(lod2); lod2_cut = lod2_lenght - 6; str_clip(lod2, lod1_cut); // Jetzt haben wir die Dateiendung im string lod2 str_trunc(lod2_b, 6); // Jetzt haben wir den Dateinamen ohne Endung und ohne _1 im string lod2_b str_cat(lod2_b, lod2_2); // Füge "_2" am Ende des Dateinamens hinzu str_cat(lod2_b, lod2); // Füge die Dateiendung hinzu
function generate_filename_lod3() { var lod3_lenght; var lod3_cut; str_for_entfile(lod3, me); str_cpy(lod3_b, lod3); // Erzeuge eine Sicherheitskopie des strings lod3 lod3_lenght = str_len(lod3); lod3_cut = lod1_lenght - 6; str_clip(lod3, lod3_cut); // Jetzt haben wir die Dateiendung im string lod3 str_trunc(lod3_b, 6); // Jetzt haben wir den Dateinamen ohne Endung und ohne _2 im string lod3_b str_cat(lod3_b, lod3_b); // Füge "_3" am Ende des Dateinamens hinzu str_cat(lod3_b, lod3); // Füge die Dateiendung hinzu
function lod() { while(1) { if(vec_dist(player.x, my.x) >= clip_range/8 && < clip_range/4 && clip_range) { generate_filename_lod1(); ent_morph(me, lod1_b); } if(vec_dist(player.x, my.x) >= clip_range/4 && clip_range) { generate_filename_lod2(); ent_morph(me, lod2_b); } if(vec_dist(player.x, my.x) >= clip_range) { generate_filename_lod3(); ent_morph(me, lod3_b); } wait(1); } } If I remember right, you have to add lod() to each action which is assigned to a model that should use LOD. There are certainly better ways to do it, but I think it should work.
|
|
|
Re: A6LOD: LOD(Levels Of Detail) Plugin!
[Re: Iron Chancellor]
#55498
10/03/05 06:55
10/03/05 06:55
|
Joined: Oct 2003
Posts: 4,131
Matt_Aufderheide
Expert
|
Expert
Joined: Oct 2003
Posts: 4,131
|
There is absolutely no reason you couldnt do a few simple optimizations to make it much faster.. for instance.. change this: wait(1); to something like this: wait(5+random(10)); there are some otehr things to improve too.. but in general, the key is to spread out complex operations over time.. this is how you speed up all functions...so you only check every so often, with a random interval so all the loops dont run on the same frame.. as for other improvments..you would want to find out, whether a model is the wrong LOD for its distance...therefore, you have a skill set to 1,2,3 or something, and if its distance is in LOD range 3 ands its skill is set to 2, you need to morph it then and only then... so it doesnt do it every frame. for instance: Code:
define _LOD,skill1; var LOD_dist_1=100; var LOD_dist_2=300; var LOD_dist_3=800;
function lod() { while(me) { temp=vec_dist(my.x,camera.x); //call vec_dist once per loop and store
if temp<LOD_dist_1 && my._LOD!=1 { //morph to lod 1 my._LOD=1; //update the skill wait(5+random(10); //make sure it doesnt run the loop for all entities on the same frame continue; //end the loop early for speed reasons }
if temp>LOD_dist_1 && temp<LOD_dist_2 && my._LOD!=2 { //morph to lod 2 my._LOD=2; //update the skill wait(5+random(10); //make sure it doesnt run the loop for all entities on the same frame continue; //end the loop early for speed reasons }
if temp>LOD_dist_2 && my._LOD!=3 { //morph to lod 3 my._LOD=3; //update the skill wait(5+random(10); //make sure it doesnt run the loop for all entities on the same frame continue; //break the loop early for speed reasons } wait(5+random(10); //make sure it doesnt run the loop for all entities on the same frame
}
} [/ code]
|
|
|
Re: A6LOD: LOD(Levels Of Detail) Plugin!
[Re: Matt_Aufderheide]
#55499
10/03/05 06:59
10/03/05 06:59
|
Joined: Sep 2004
Posts: 1,214 Austin, Texas
Josh_Arldt
OP
Senior Developer
|
OP
Senior Developer
Joined: Sep 2004
Posts: 1,214
Austin, Texas
|
Quote:
there are some otehr things to improve too.. but in general, the key is to spread out complex operations over time..
These are the sort of things that I did for my plugin.  I had it spread out complex operations over time. Also my source-code is very small and I optimized it my best. 
The exact same thing that my plugin does is easy to do in c-script. Although I would rather have people using my plugin than some c-script version. 
|
|
|
|