Jump to content

Recommended Posts

Posted

This is for Turbo Engine but can be adapted for Leadwerks. Resizes model without changing scale.

void Resize(shared_ptr<Entity> entity, const float scale)
{
	entity->SetPosition(entity->GetPosition() * scale);
	auto model = dynamic_pointer_cast<Model>(entity);
	if (model)
	{
		for (auto mesh : model->lods[0]->meshes)
		{
			for (int v = 0; v < mesh->vertices.size(); ++v)
			{
				mesh->vertices[v].position *= scale;
			}
			mesh->Finalize();
			mesh->UpdateBounds();
		}
		model->UpdateBounds(1 + 2 + 4);
	}
	for (auto child : entity->kids)
	{
		Resize(child, scale);
	}
}

 

  • Like 3

Let's build cool stuff and have fun. :)

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.

×
×
  • Create New...