Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Ayumi, 7th_zorro, 1 invisible), 1,060 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
LOD Script #255374
03/09/09 23:07
03/09/09 23:07
Joined: Mar 2006
Posts: 237
Deutschland, NRW, Recklinghaus...
TSG_Christof Offline OP
Member
TSG_Christof  Offline OP
Member

Joined: Mar 2006
Posts: 237
Deutschland, NRW, Recklinghaus...
Ich weis nicht ob es möglich ist, wenn ja kann mir jemand vielleicht dabei helfen ein LOD system zu Programmieren. Und zwar soll dabei ein Modell ersetzt werden, durch ein anderes was weniger performence frist laugh.

Re: LOD Script [Re: TSG_Christof] #255376
03/09/09 23:19
03/09/09 23:19
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Hier mal nen schmutziges Skript:
Code:
#define LOD_MIN 800

var lod_dist[4];

function set_lod_startup()
{
	lod_dist[1] = LOD_MIN;
	lod_dist[2] = LOD_MIN * 2;
	lod_dist[3] = LOD_MIN * 3;
	lod_dist[4] = LOD_MIN * 4;
}


function register_lod(ENTITY* ent, lods)
{
	STRING* temp_str = "#32";
	STRING* Model_file = "#32";
	var i = lods;
	var myvar;
	
	if(lods <= 0)
	{
		i = 1;
	}
	if(lods > 4)
	{
		i = 4;
	}
	
	STRING* LOD_model_file[4];
	
	
	str_for_entfile(Model_file,ent);
	
	for(myvar = 0; myvar < i; myvar++)
	{
		str_for_num(temp_str,myvar);
		LOD_model_file[myvar] = str_create(Model_file);
		str_trunc(LOD_model_file[myvar] ,4);
		str_cat(LOD_model_file[myvar] ,"_lod");
		str_cat(LOD_model_file[myvar] ,temp_str);
		str_cat(LOD_model_file[myvar] ,".mdl");
	}

	while(ent != NULL)
	{
		wait(10);
		switch(ent.skill99)
		{
			case 1:
			ent.skill99 = 0;
			return(1);
			
			case 2:
			ent.skill99 = 0;
			for(myvar = 0; myvar < i; myvar++)
			{
				str_for_num(temp_str,myvar);
				LOD_model_file[myvar] = str_create(Model_file);
				str_trunc(LOD_model_file[myvar] ,4);
				str_cat(LOD_model_file[myvar] ,"_lod");
				str_cat(LOD_model_file[myvar] ,temp_str);
				str_cat(LOD_model_file[myvar] ,".mdl");
			}
			
		}
		
		if ((ent.eflags&CLIPPED)) { continue; }
		
		str_for_entfile(temp_str,ent);
		
		if(vec_dist(ent.x,camera.x) <= lod_dist[1])
		{
			if(str_cmpi(Model_file,temp_str) == 1)
			{
				continue;
			}
			ent_morph(ent,Model_file);
			continue;
		}
		
		if(vec_dist(ent.x,camera.x) <= lod_dist[2])
		{
			if(str_cmpi(LOD_model_file[0],temp_str) == 1)
			{
				continue;
			}
			ent_morph(ent,LOD_model_file[0]);
			continue;
		}
		
		if(vec_dist(ent.x,camera.x) <= lod_dist[3] && lods >= 2)
		{
			if(str_cmpi(LOD_model_file[1],temp_str) == 1)
			{
				continue;
			}
			ent_morph(ent,LOD_model_file[1]);
			continue;
		}
		if(vec_dist(ent.x,camera.x) <= lod_dist[4] && lods >= 3)
		{
			if(str_cmpi(LOD_model_file[2],temp_str) == 1)
			{
				continue;
			}
			ent_morph(ent,LOD_model_file[2]);
			continue;
		}
		if(vec_dist(ent.x,camera.x) > lod_dist[4] && lods >= 4)
		{
			if(str_cmpi(LOD_model_file[3],temp_str) == 1)
			{
				continue;
			}
			ent_morph(ent,LOD_model_file[3]);
			continue;
		}
	}
}

Einfach die Entity über die gewünschte Funktion registrieren. Die Variable gibt die Anzahl der LOD Modelle vor. Die Entitys müssen die Endung N_lod.mdl haben, wobei n eine Zahl zwischen 0 und 3 ist.
Wenn du Skill99 der Entity auf 1 setzt, wird die Entity nicht mehr gemorpht, bleibt aber in ihrem aktuellen Zustand und Skill99 = 2 erzwingt ein update der Entity.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: LOD Script [Re: WretchedSid] #255377
03/09/09 23:31
03/09/09 23:31
Joined: Mar 2006
Posts: 237
Deutschland, NRW, Recklinghaus...
TSG_Christof Offline OP
Member
TSG_Christof  Offline OP
Member

Joined: Mar 2006
Posts: 237
Deutschland, NRW, Recklinghaus...
Noch unübersichtlicher gehts nicht laugh wink
dachte irgendwie an so was wie.
Distanz größer als 1000 model 1 löschen erstelle model 2, Distanz kleiner als 1000 lösche Model 2 erstelle Model 1 laugh.

wenn ich wüsste wie mann da nur noch in die tat umsetzt laugh

Re: LOD Script [Re: TSG_Christof] #255498
03/10/09 21:44
03/10/09 21:44
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Code:
if(vec_dist(ent.x,camera.x) >= 1000)
{
  ent = you;
  ent = ent_create("Model.mdl",you.x,NULL);
  ent_remove(you);
}

Ist jetzt relativ dirty. Ich würde dir aber raten ent_moprh zu nutzen. Und da ent_morph zu langsam für jeden Frame ist, kannst du mit str_for_entfile voher überprüfen ob das Modell nicht schon bereits dieses Modell nutzt.
guck dir mal vec_dist an, dass wird dir helfen.

Last edited by Sylar; 03/10/09 21:46.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com

Moderated by  HeelX, rvL_eXile 

Gamestudio download | chip programmers | 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