CopyMesh and Copying Animation

BlitzMax Forums/MiniB3D Module/CopyMesh and Copying Animation

siread(Posted 2007) [#1]
I posted this in the Blitz3D forum because sometimes I don't know whether to post queries there or in here. I've tried code in both B3D and MiniB3D without success...

Basically, I don't want to LoadAnimMesh for 22 models as loading takes too long.

If I load the master mesh and use CopyEntity I am unable to change the surface colours or textures for each individual entity which is essential.

If I use CopyMesh I can change the colours/textures of the individual models but it doesn't copy the animation. I tried using LoadAnimSeq(player1, "originalmesh.b3d") but this gives the error "Entity has no animation" in B3D. It compiles ok in miniB3D but still doesn't animate.

What's the solution?


klepto2(Posted 2007) [#2]
The solution is to wait until I'm coming home ;)
To be serious, with standard b3d or minib3d it doesn't seem to be possible. But I have worked out a 'copyanimmesh' function which will copy the animations also. I only have to get it working with the new bone system. I will post it as soon as possible.


Dreamora(Posted 2007) [#3]
Although I already answered your question over there I will do it here as well: Mesh data is attached to an entity, as well as is animation data. The animation data is NOT part of the mesh.

So if you call CopyMesh, you only have the mesh data, which normally means Frame 0 of the animation.

The solution is simple: load the different "distinct" master models (if all 22 are the same it shouldn't be an issue if you have 2 versions of the model: 1 that is textured, one that is not. only load the textured one on the first step, get its brush, load the other 21 master meshes and apply the brush)


siread(Posted 2007) [#4]
Thanks Dreamora. I was afraid that this is the case.

Here's hoping Klepto can come to the rescue. :)


simonh(Posted 2007) [#5]
Ideally with animated meshes you will have just one surface, with a single texture for each mesh. This will improve speed greatly, and you would be able to use CopyEntity and EntityTexture to quickly and efficiently create lots of different textured entities.

This could be done for a football game, too - you would just need a single texture (512x256) with distinct skin and kit areas (left and right side of texture), then to change the skin or kit, dynamically copy from two textures (256x256 for skin, 256x256 for kit) to the left or right side of the single texture.


siread(Posted 2007) [#6]
Simon, this methods works perfectly. Thanks. :)


z4g0(Posted 2007) [#7]
Other problem: Loading some AnimatedMesh I get "Array out of bounds" in this row:

bo_bone.keys.flags[k_frame]=bo_bone.keys.flags[k_frame]+k_flags

on TModel.LoadAnimB3D() function.

the same models in blitz3D works good!


simonh(Posted 2007) [#8]
Can you send me the file please z4g0?


simonh(Posted 2007) [#9]
Thinking about it, does the file contain a non-boned anim? If so, MiniB3D doesn't support these yet.


jtfrench(Posted 2011) [#10]
Does anybody know if this issue (animating a CopyMesh'd entity) was ever addressed in regular MiniB3D? It sounds like there may be a patch in the MiniB3D extended from Klepto. Just curious if there was ever an accepted "best practice" for resolving this issue.

Thanks


Kryzon(Posted 2011) [#11]
I don't know the answer to your question, but if I had to solve this issue myself I would study CopyMesh() and CopyEntity() to see how they worked and come up with a new DuplicateEntity() function.

This function would take in optional boolean arguments as to which elements of the original entity to duplicate (True) and which elements to share (False) with the original. If every argument is kept as 'False' it should probably work as a CopyEntity().
It should take care of matrices, meshes, surfaces and anim_surfaces, brushes, textures and recursively duplicate the child hierarchy (such as child entities and bones).


AdamRedwoods(Posted 2011) [#12]
CopyEntity() should work. I see the animation info in the code.

Also, other issues may be fixed in the small fixes version:
http://www.blitzbasic.com/Community/posts.php?topic=94221


jtfrench(Posted 2011) [#13]
We got it working I think by using CopyMesh() and then individually copying over the boneslist or something like that.