Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (NewbieZorro, TipmyPip, 1 invisible), 19,045 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 2 of 2 1 2
Re: A6LOD: LOD(Levels Of Detail) Plugin! [Re: creature] #55492
09/18/05 20:40
09/18/05 20:40
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline OP
Senior Developer
Josh_Arldt  Offline OP
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
The c-script version seems to be 2x slower than the C++ version and drops the framerate instead of improving it. I recomend using the C++ version.
If anyone still really wants the c-script version I will post it anyways.

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 Offline
Member
zammmm  Offline
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 Offline
Senior Developer
Iron Chancellor  Offline
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] #55495
10/02/05 18:41
10/02/05 18:41
Joined: Sep 2004
Posts: 1,214
Austin, Texas
Josh_Arldt Offline OP
Senior Developer
Josh_Arldt  Offline OP
Senior Developer

Joined: Sep 2004
Posts: 1,214
Austin, Texas
@ Iron Chancellor nice script although by the looks of it you may as well not use your script as it will lower the framerate instead of improving it.

Re: A6LOD: LOD(Levels Of Detail) Plugin! [Re: Josh_Arldt] #55496
10/02/05 20:04
10/02/05 20:04
Joined: Apr 2003
Posts: 1,044
Deutschland
Iron Chancellor Offline
Senior Developer
Iron Chancellor  Offline
Senior Developer

Joined: Apr 2003
Posts: 1,044
Deutschland
Lol, I don't know I haven't test it a lot. It's really a while ago and it was more to see if it was theoreticaly possible to do the same in C-Script as the engine does

Re: A6LOD: LOD(Levels Of Detail) Plugin! [Re: Iron Chancellor] #55497
10/03/05 06:43
10/03/05 06:43
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

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 otehr ways to do it too.. but in general, the key is to spread out complex operations over time.. this is how you speed up all functions.

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
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

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]


Sphere Engine--the premier A6 graphics plugin.
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 Offline OP
Senior Developer
Josh_Arldt  Offline 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.

Page 2 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1