Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, aliswee), 835 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
About auto hide invisible entitiesl #474014
09/07/18 16:11
09/07/18 16:11
Joined: Feb 2003
Posts: 146
RP China
2
20BN Offline OP
Member
20BN  Offline OP
Member
2

Joined: Feb 2003
Posts: 146
RP China
Hi, all.
If every game levels has 3000-5000 entities,
need to hide outside of camera sight.
Do you have any plans?

Re: About auto hide invisible entitiesl [Re: 20BN] #474161
09/26/18 03:19
09/26/18 03:19
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline
User
Dooley  Offline
User

Joined: May 2005
Posts: 868
Chicago, IL
camera.clip_near
camera.clip_far

Look these up in manual

Re: About auto hide invisible entitiesl [Re: 20BN] #474163
09/26/18 06:36
09/26/18 06:36
Joined: Nov 2005
Posts: 204
Bavaria
HellThunder Offline
Member
HellThunder  Offline
Member

Joined: Nov 2005
Posts: 204
Bavaria
You could use the part of this while loop for hiding entities. Related to the camera position and the culling_distance, it will hide your entities or show them again. This code snippet was a part of AUM - original was C-Script.
Code:
var culling_distance = 4000;
action NULL_() 
{
 while(me)
 {
	if (vec_dist (my.x, camera.x) < culling_distance) // the player has come close to this entity?
	{
		reset(my, INVISIBLE); // then show it!
		while (my.alpha < 100) // run this loop until the entity becomes opaque again
		{
			my.alpha = minv(100, my.alpha + 15 * time_step); // increase my.alpha (15 = speed) and limit it to 100
			wait (1);
		}
		reset(my, TRANSLUCENT); // get rid of some nasty artifacts when the entity is completely visible
	}
	else // the player has moved away from this entity?
	{
		set(my, TRANSLUCENT);  // then set the "transparent" flag again
		while (my.alpha > 0) // run this loop until the entity becomes practically invisible (alpha = 0)
		{
			my.alpha = maxv(0, my.alpha - 15 * time_step); // decrease my.alpha (15 = speed) and limit it to 0
			wait (1);
		}
		set(my, INVISIBLE); // now hide the entity in order to increase the frame rate

	}
        wait(1);
 }
}



Create your own JRPG and join our community: https://www.yrpgtoolkit.com
Re: About auto hide invisible entitiesl [Re: HellThunder] #474175
09/26/18 14:26
09/26/18 14:26
Joined: Feb 2003
Posts: 146
RP China
2
20BN Offline OP
Member
20BN  Offline OP
Member
2

Joined: Feb 2003
Posts: 146
RP China
In other words, 1000 entities, there will be 1000 processes?

Re: About auto hide invisible entitiesl [Re: 20BN] #474176
09/26/18 15:06
09/26/18 15:06
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I'm sorry but don't use that code quoted by HellThunder. Do not do this manually, esp. not with dedicated wait(1) loops per entity. This is an engine's task.

Entities not on screen in the sense of the camera's frustum are set to invisible/ CLIPPED automatically.


For distance based clipping camera.clip_far or LOD is the correct approach.
For special cases such as a building full of entities you can use region_set in A8 to hide all entities contained in that region manually.


If the entity count (and draw count) is a problem performance wise, you may want to think about combining multiple entities into one.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: About auto hide invisible entitiesl [Re: Superku] #474177
09/26/18 20:43
09/26/18 20:43
Joined: Nov 2005
Posts: 204
Bavaria
HellThunder Offline
Member
HellThunder  Offline
Member

Joined: Nov 2005
Posts: 204
Bavaria
Entity loops would result with additional tasks, true - But should this result in a bottleneck?

In order to validate the production quality of this method, I used the snippet within the main loop of a testlevel with over 600 Entities. Every entity got an action. Some models use normal maps. HDR + DOF and a screen resolution of 1920*1080.

Result:
Quote:
culling_distance: 10000 fps: about 80



Quote:
culling_distance: 3400 fps: 105-110



The fading works flawlessly, plus selection of entities which should be hidden and which should stay would be possible.
e.g. Would work fine for hiding vegetation or other environment entities, but could also be able to force mountains to stay visible.

Conclusion:
For grouping entities and hiding groups of entities, the snippet works very fine and results with a fps increase.
For just limiting the view I would suggest to use the approach of Superku, which is mentioned within the official manual for cases like this.


Re: About auto hide invisible entitiesl [Re: HellThunder] #474227
10/01/18 11:33
10/01/18 11:33
Joined: Feb 2003
Posts: 146
RP China
2
20BN Offline OP
Member
20BN  Offline OP
Member
2

Joined: Feb 2003
Posts: 146
RP China
@HellThunder

your fuc = 8.(600 entities loop = 8?)

Re: About auto hide invisible entitiesl [Re: 20BN] #474242
10/01/18 20:02
10/01/18 20:02
Joined: Nov 2005
Posts: 204
Bavaria
HellThunder Offline
Member
HellThunder  Offline
Member

Joined: Nov 2005
Posts: 204
Bavaria
I don't know, if I understand your question.
In my case it is just a single function, which will be started after the camera or player is moving. The function itself will be called within a mainloop, which runs all the time.


Create your own JRPG and join our community: https://www.yrpgtoolkit.com

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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