Surface cloned(?) problem with CopyEntity/CopyMesh

Blitz3D Forums/Blitz3D Programming/Surface cloned(?) problem with CopyEntity/CopyMesh

gameproducer(Posted 2007) [#1]
I have a mesh.b3d that contains 5 different surfaces. I can use paintSurface to apply textures to these surfaces, and it works fine - with ONE entity that I load using LoadAnimMesh.

After that I use copyEntity (also tried copyMesh) and it creates a mesh2 that has a different handle than mesh1.

Then I try to use getSurface(mesh2,1) and it returns the SAME HANDLE that mesh 1 returns with getSurface(mesh1,1). When I apply a texture to new surface... it also applies the texture to mesh1 surface...

What's wrong here? mesh1 and mesh2 are different handles, but somehow they seem to share surfaces (strange).

If I use LoadAnimMesh instead of CopyEntity/copySurface THEN also the surfaces are different for mesh1 and mesh2.

The problem with LoadAnimMesh is that it takes much more time, so I'd rather use something else.

Any ideas on how to make the surfaces under meshes independent?


b32(Posted 2007) [#2]
Basically, you should use CopyMesh instead. It will make a real copy of the mesh data. CopyEntity is intented to save memory, so you can use the same mesh data for several entities.
However, how CopyMesh behaves when copying animated/hierarchic meshes, I don't know.


H&K(Posted 2007) [#3]
The difference between CopyMesh and CopyEntity is that CopyMesh makes a copy of all the surfaces whereas the result of a CopyEntity shares any surfaces with its template.

I know you said you tried CopyMesh, but now that you can see that CopyEntity is doing exactly what its supposed to, could you just try again (The reason, being that when Im not sure which I should be using, I tend to messup my tests to see if its working)


big10p(Posted 2007) [#4]
CopyMesh attempts to combine surfaces. You may have to write your own function to make a deep copy of an entity. I thought there was one in the archives but I can't seem to find it.


gameproducer(Posted 2007) [#5]
Hmm... darn.

I re-test copyMesh once more... but I doubt it works :)


gameproducer(Posted 2007) [#6]
Ah... now I remember that I forgot to add something. CopyMesh does create right surfaces, but now I lost animations.

Is there no CopyAnimMesh? ;)


b32(Posted 2007) [#7]
You mean with or without bones ? With bones, I think, only LoadAnimMesh could be a solution. Else, you could write a Function that copies the animation as well. Or you could maybe use LoadAnimSeq to load the animation onto the copied object.


gameproducer(Posted 2007) [#8]
LoadAnimMesh and LoadAnimSeq work... but the problem is that they are slow (takes ages to load 10 characters with lots of animations... not to mention loading 50 characters :))

Basically I would need "CopyAnimMesh" that would be like a combination of copyMesh and copyEntity.

I


b32(Posted 2007) [#9]
But then again, 50 different animated characters could be quite much. And if they have the same shape, why use a different mesh ? I thought you could give CopyEntity-entities different skins.
Anyway, you can more or less make a copy of a characters animation. I wrote this quickly, it might need some tweaking to get it right:

I think the EntityScaleX/Y/Z routines are in the archives.


gameproducer(Posted 2007) [#10]
Well, 50 is quite much - but I have a a fast computer, so on slow computer 25 characters might take same time as 50 on my... and different meshes are so that I can use different textures on those child surfaces...

Anyway:

That copyanimation might actually be what I'm after (since it's the animation file that's so big)...

Big thanks! I'll test and see how this goes.


gameproducer(Posted 2007) [#11]
Yep, this seems to work (although still some problems with the positioning)... and I'm not sure if this is any faster than loadAnimMesh after all :)