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?
A couple of IAnimatedMesh/Node Questions
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
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
)
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
-
BobTheFish
- Posts: 10
- Joined: Mon Oct 13, 2008 6:21 am
-
BobTheFish
- Posts: 10
- Joined: Mon Oct 13, 2008 6:21 am
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.
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:
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.
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.
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.vitek wrote:Sure. You just modify the vertex or index buffer (depending on what you want to do).
Travis
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
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?hybrid wrote:The void* has to be cast to a core::array<S3DVertex> or whatever vertex type is used.
The difficulty arises on that very last step - I can see no way to inform the IMeshBuffer of the new addresses.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
-
BobTheFish
- Posts: 10
- Joined: Mon Oct 13, 2008 6:21 am
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.JP wrote:Why cast the u16* to an array? It's fine as it is
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.
