Is this possible, making an added object's mesh datablock unique per-instance (2.57)?

I ask this because I had the idea of using the vertex proxy module to move verticies a random amount if there’s a certain amount of color in a vertex, there’s two problems I’ve run into.

To start, I got this script to work for one mesh object and one material, now do note while reading the rest of the thread that this is my first time using the vertex proxy module for something other than simple tests.


import GameLogic

con = GameLogic.getCurrentController()
ob = con.owner

mesh = ob.meshes[0]

mats = mesh.numMaterials

length = mesh.getVertexArrayLength(0)
for array in range(0, length):
    
    vert = mesh.getVertex(0,array)
    col = vert.color
    
    if col[0] > 0.5:
        float = GameLogic.getRandomFloat()
        vert.z += float-0.25
    else:
        float = 0
        vert.z += float

    if array >= length-1:
        ob.reinstancePhysicsMesh(ob, mesh)
        ob.state = 2

The first problem is that I’ve tried for most of the afternoon to get this working with verticies that have more than one material, however, getting it to work as-per the script above was the easy part, it was a lot trickier than I anticipated to get it to loop through all the verticies in all the materials and then stop the script’s execution by changing the object’s state (and to note, I did look at the blender.org documentation where there was an example, but didn’t help much). So how would I change this script to work with more than one material channel?

The other problem mentioned in the thread title I’m not sure how I will go about starting to solve this, heck I don’t know if it’s even possible in the BGE. The issue is that I was wanting to use the script on added objects to give them a variation in appearance when created, but they all have the same mesh data and a change in a newly added object repeats it across all of the other objects. So the other question is, is there even a way to make the mesh of each added object unique so the changes to vertex position will only be seen on that object?

The main thing I was trying to do is use a vertex color to ‘map’ verticies I wanted to move in the Z direction a random amount, and then have it be different and stay different when more of the same object is added, is it possible to do in the BGE, and if it is, is there is a better way of doing the same thing compared to what I tried to do?

Thanks :slight_smile:

the problem is, whenever you change something on this mesh, all other instances of the mesh would be changed aswell.
The only way i found is to create for every object you add a unique mesh and change it afterwards. So changes will only work for the mesh itself.

I have a script somewhere, but i cant access my computer at the moment, because the powersupply seeems to be kaput.

Sevi’s right - since each mesh is just a duplicate, changing mesh data will follow to all duplicated objects. There’s not really any way to do this outside of Sevi’s method of preparing the meshes beforehand. Since they have to be made beforehand, you might just use the meshes as unique.

With 2.5 you can use the dynamic loading to create new meshes. Look for LibNew.

I haven’t done anything with it, so I can’t help.