Jump to content

Adding LOD to the Model Class

JMichael

926 views

The Model class is being slightly restructured to add support for built-in LOD without the need for separate entities. Previously, a list of surfaces was included in the Model class itself:

class Model
{
	std::vector<shared_ptr<Surface> > surfaces;
};

This is being replaced with a new LOD class, which allows multiple lists of surfaces containing less detail to be stored in the same model:

class LOD
{
	std::vector<shared_ptr<Surface> > surfaces;
};

class Model
{
	std::vector<LOD> lods;
};

To iterate through all surfaces in the first LOD, you do this:

for (int i = 0; i < model->lods[0].surfaces.size(); ++i)
{
	auto surf = lods[0].surfaces[i];
}

To iterate through all LODs and all surfaces, you do this:

for (int n = 0; n < model->lods.size(); ++n)
{
	for (int i = 0; i < model->lods[n].surfaces.size(); ++i)
	{
		auto surf = lods[n].surfaces[i];
	}
}

In the future editor, I plan to add a feature to automatically reduce the detail of a mesh, adding the simplified mesh as an additional LOD level so you can automatically generate these.

How this will work with our super-efficient batching system, I am not sure of yet.

  • Like 1


4 Comments


Recommended Comments

How are LODs currently being handled in LE4? I remember seeing tutorials on this in previous Leadwerks releases but not sure if the system has changed.

Share this comment


Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Add a comment...

×   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.

×
×
  • Create New...