A couple of IAnimatedMesh/Node Questions

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
BobTheFish
Posts: 10
Joined: Mon Oct 13, 2008 6:21 am

A couple of IAnimatedMesh/Node Questions

Post by BobTheFish »

What's the easiest/best way to modify (add/remove/etc) the triangles in a mesh (e.g. IAnimatedMesh)?

Is it possible to force-feed animation to bones and joints to an IAnimatedMeshSceneNode, rather than relying on the animation data in the IAnimatedMesh? For example, how would I set the position and orientation of a joint manually?
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Removing triangles is not a very common task, for animated meshes you need to know the underlying structures and be really careful.
You can use the animation system to manually animate/force joints. Please check Irrlicht's Wiki, there's a really short introduction to this type of animation (If someone provides a tutorial we could add this to the engine :idea: )
BobTheFish
Posts: 10
Joined: Mon Oct 13, 2008 6:21 am

Post by BobTheFish »

I promise I'll be careful :)

So there is a way to modify the MeshBuffer?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Sure. You just modify the vertex or index buffer (depending on what you want to do).

Travis
BobTheFish
Posts: 10
Joined: Mon Oct 13, 2008 6:21 am

Post by BobTheFish »

Maybe I'm looking in the wrong place (I've spent much time searching the api, google, wiki and forum) but I can't find a way to do it - the only calls available to IMeshBuffer are "get", there are no "set".
There are "append" calls but I would also like to remove arbitrary pieces of mesh.

The addresses of the arrays of vertices and indices are available but they're in the form of void*.
If directly working with this data (I assume by first casting to the correct type e.g. S3DVertex) is the only way to modify the mesh, then I can see how I could directly modify the data already present, but how would I decrease or increase the number of vertices/indices? There doesn't seem to be a way to tell the mesh how many of each it has.

If you're wondering why I'm going to all this effort: I've successfully completed dynamic mesh LOD in plain OpenGL and would like to implement it in Irrlicht instead, taking advantage of features like model loading etc.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The void* has to be cast to a core::array<S3DVertex> or whatever vertex type is used. Once you have the array you can work with it as usual, also erasng vertices. Please note, though, that there is no automatic propagation of vertex removes to the indices, you have to adjust them manually.
It might be even better to just remove indices. Taking into account that hw buffers will remove the overhead of passing vertices each frame, the index manipulation is really simple and fast.
wITTus
Posts: 167
Joined: Tue Jun 24, 2008 7:41 pm
Location: Germany

Post by wITTus »

vitek wrote:Sure. You just modify the vertex or index buffer (depending on what you want to do).

Travis
I already asked myself what would be the best way to do this? As hybrid said, it's really a very tedious task. Some function call for IMeshBuffer like deleteVertex() would be nice. 8)

Something like:
- allocate new memory
- copy needed stuff (without the deleted vertex and without the indices which use that vertex :?: )
- free old memory
- change pointers

Don't know. That's what I would probably do.
Hm... a list<vertex> could be much faster too, to do dynamic stuff like that...
BobTheFish
Posts: 10
Joined: Mon Oct 13, 2008 6:21 am

Post by BobTheFish »

hybrid wrote:The void* has to be cast to a core::array<S3DVertex> or whatever vertex type is used.
Are you sure this sort of thing is possible? I tried for example to cast (for the indices) u16* to core::array<u16> and couldn't get a cast to compile. Perhaps my approach is wrong, what kind of cast should I be using?
wITTus wrote:Something like:
- allocate new memory
- copy needed stuff (without the deleted vertex and without the indices which use that vertex Question )
- free old memory
- change pointers
The difficulty arises on that very last step - I can see no way to inform the IMeshBuffer of the new addresses.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Why cast the u16* to an array? It's fine as it is ;)

it's the vertices you should be casting!
Image Image Image
BobTheFish
Posts: 10
Joined: Mon Oct 13, 2008 6:21 am

Post by BobTheFish »

JP wrote:Why cast the u16* to an array? It's fine as it is ;)
I guess I was just hoping that the array would handle resizing memory for me, so I didn't have to do the stuff wiTTus describes.
This is especially important to me since if I allocate any new memory as described I can't see a way of changing the pointer and count in the IMeshBuffer.
Post Reply