Jump to content

LoD System


Haydenmango
 Share

Recommended Posts

Hey everyone I have been trying to make a LoD (Level of Detail) system lately but I am running into one big issue.

Using world:ForEachEntityInAABB() or world:ForEachVisibleEntityDo() works to hide the entity but then I run into my issue. These functions will not return a Hidden entity. So how would I go about 'finding' a Hidden entity?

 

I know I could give each entity a script and make them check for my player when they are hidden but that doesn't seem like the best way to go about doing this.

 

Any other ideas are welcome.

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Link to comment
Share on other sites

i'm so new here to properly answer, but i would do a list of all the entities and handle them not depending on if they are seen by those functions.

 

are you using c++ or lua?

 

from a c++ tut i took the following:

 

you may define a function (called when the map is loaded) which keeps track of each entity included on the map, and store references to them in a vector (defined as: vector<Entity*> entities;)

 

//Store all entities when map is loaded

void StoreWorldObjects(Entity* entity, Object* extra)

{

System::Print("Loaded an entity and stored it: " + entity->GetKeyValue("name"));

entities.push_back(entity);

 

}

 

you have to call Load this way:

 

Map::Load("Maps/start.map", StoreWorldObjects);

 

then you can scan the vector:

 

for( iter; iter != entities.end(); iter++)

{

Entity* entity = *iter;

}

 

and do whatever you have to do whit them

 

(no idea if this work in lua)

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

I personally would go with attached scripts. It seems the easiest. The main issue is that you have to know what LoD's to load and generally you do that by the same model name with some numbers after them for the LoD and by just looping over the loaded entities you don't know the model name (afaik). It would be nice if Leadwerks set a key/value with the model filepath and name so we could get this. With attached scripts you could expose variables for you to assign these in with the editor.

 

I'm not sure why you are anti-script attaching but with using prefabs it shouldn't be bad at all.

 

 

Big long thread about this with different thoughts

 

http://www.leadwerks.com/werkspace/topic/8643-lod-system-questions/page__hl__lod

Link to comment
Share on other sites

Thanks for your thoughts guys.

@Charrua I hadn't thought of gathering my entities info at the inital map load I may give it a try although I am using Lua.

@Rick I am trying to do a slightly different LoD system; it's actually more like a view range system. I don't have different LoD models for everything in my map (I may eventually) but for now I was just trying to make entities a certain distance from me Hidden and then the entities within the distance Shown.

I guess I could give all my entites scripts but my worry is they all would be constantly calculating their distance from me instead of me just calculating my distance to them.

 

Am I going about this in the wrong direction? Should I use a collision box or something similar for my "View Area" or would calculating distance to/from each entity better? I will give that thread another read through, there are some helpful tips in there.

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Link to comment
Share on other sites

You know what, if you just want to hide/show at a range look into this function which should let you define this for each entity. So you can loop through every entity at startup and set this for each one:

 

http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetviewrange-r151

 

 

I used this before with a top/down game I was doing with heavy forest areas and I recall it speeding things up a ton. With a top/down game it works great because you can't see outward. With a first person perspective I would think this would be strange unless you have some fog at the same range to cover up the popping in and out as you move.

  • Upvote 1
Link to comment
Share on other sites

Sadly all of my entites view ranges are already set to near (in the editor). Does setting view range for entites in the editor also set it in game or would I have to use the function in a script?

 

I can still see all of my entites with a near view range from 300 units away. My Cameras View Range is set to 300 (instead of 1000) and I can see my trees all the way up to where the camera range cuts off.

I would probably like the range to be about 100-150 if I could figure it out.

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Link to comment
Share on other sites

FYI, I plan to implement LOD built into the model file. It will work by loading an LOD model into another model, and saving the result. This means you will have LOD switches without different entities for the different levels. This is much more convenient for scripting and things like that, since you don't have to worry about which is visible.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

That sounds extremely convenient/useful Josh. I may wait for that before making a LoD system.

 

For now what do you think would be the best way to do a more specific View Range system? By specific I mean I could set the view range for each object to a set number instead of Near,Medium,Far,Max, or Infinite.

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Link to comment
Share on other sites

There's a good reason the view range is set that way. The octree sorts objects by their view range, so if a chunk is further than a certain range, and contains no entities above that range, the entire chunk gets skipped, and the renderer doesn't have to iterate through the list of entities.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Not sure if this is intended but Near View Range gives my entites No Shadows even though I have turned their shadows to static ( even through scripts). The only way I can see their shadows is by setting the entites View Range to Max. My directional lights view range is set to infinite. I have tried using all different lighting settings (static,dynamic,static+dynamic,etc.) and also have tried turning changing my worlds light quality by throwing self.world:SetLightQuality(0-2) into my App.lua scripts Start() function.

 

I also can say that turning my entites view range to near (in the editor) only works on entites that don't have a parent. If they have a parent it won't work in game(but it will show in editor) even if I set the parents/parents children view range to near.

 

 

--edit both of these issues have been fixed! hurrah!

Check out my game Rogue Snowboarding- 

https://haydenmango.itch.io/roguesnowboarding

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...