Creating unique meshes with LibNew

How to use LibNew to create unique meshes?

I can’t seem to find out how it works. And by searching the API or the forum I didn’t find any clues, examples.

Thanks to whoever wants to give a small example.

LibNew is just used to create a new library of data. You cant create meshes with it. All you can do is load in new information.
I don’t have an example for LibNew, someone else can help you with that.

You may add an object with relatively unique mesh using LibNew.
idx = 0
New_mesh = bge.logic.LibNew(‘Model’+str(idx),‘Mesh’, [‘Mesh_Name_here’][0]
OldObject.replaceMesh(New_mesh)
idx+=1

You need to add an object first and then replace its mesh using LibNew. The reference Mesh needs to be in a hidden layer.
The Library name needs to be unique, that’s why I use the idx variable to alter a static name!

I agree with torakunsama, you create a copy of a mesh rather than to build a mesh.

Thanks, guys. I got it now. I will post some example later.

So, here’s an example.

But I get a message in the System Console for every time the mesh is copied: Mesh has a user “Cube”

Is this normal?

Attachments

LibNew_00.blend (86.4 KB)

Unfortunately, yes, printing that statement is a big problem form me, since I use the LibNew too many times. The printing freezes the game even more, since some times, hundreds of lines need to be printed. If someone knows of a way to remove the printing, I’ll appreciate the help!