Triangles separated within the same mesh?

Blitz3D Forums/Blitz3D Programming/Triangles separated within the same mesh?

_PJ_(Posted 2010) [#1]
Sorry if the title isn't very specific...

If I wanted to have a mesh that was comprised of separate 'pieces', would I need to use separate surfaces?


Yasha(Posted 2010) [#2]
Depends what you want to do with it.

If you want a segmented animation, like a tank, robot, or whatever, you can use a single-surface boned mesh easily enough - just design it in segments and assign each one to its own bone with no blending. It'll look the same as real segments but without the disadvantages of actually using separate surfaces.

If you want to be able to create characters or whatnot dynamically out of prefabricated "parts", then you would most likely need separate surfaces for them.

Finally, if you want a fully dynamic editable mesh where the user can choose to mutate individual triangles... you probably need to let them actually edit the mesh data.


D4NM4N(Posted 2010) [#3]
If you mean do the vertices have to be connected then the answer is no. You can have a static mesh with independent 'bodies'.
Afaik these can be of the same surface (although there is a vertex per surface toplimit in b3d).

Last edited 2010


Matty(Posted 2010) [#4]
As D4NM4N says - vertices/triangles do not need to be connected.

mesh=createmesh() ;creates a handle to an entity, which is a mesh currently with no surfaces
surface=createsurface(mesh) ;creates a surface which is attached to the mesh/entity. You can have, if you want, more than 1 surface per mesh entity

You can then add vertices, create triangles wherever in space you want which are attached to the specified surface.  Most good particle systems in blitz3d use a single surface and attach the particles as individual triangles/quads to that surface.  They are then moved through world space by adjusting vertex positions - note however that even if only one vertex is altered the entire set of vertices/triangles have to be recalculated internally by blitz on the cpu.

Also, a surface can have a brush and/or textures applied.  You can apply multiple textures to a surface, specifying the blend mode with each one beneath. One use of this is with lightmapping - diffuse texture multiplied with lightmap texture, using the second UV set for the lightmap texture. Blitz surfaces have  a maximum of 2 UV sets , but can have up to 8 textures applied to a surface.  Hope that is of some help. 


Oh..and there is an upper limit to the number of vertices you can have per surface, usually around the 32k number of vertices although it can be higher sometimes.  



_PJ_(Posted 2010) [#5]
Okay, that makes sense, and yeah, I shoulda kknown because I've done some aprticle stuff with single-surface mesh :)

What I want to do, is be able to separate the triangles within a mesh (or use a copy of the mesh with the triangles separated?) so that the mesh can be 'exploded'. Although of course, standard manipulation of the verts leads to all tri's attached to the verts being distorted as the vert is moved.

Supposedly, I would need to add extra verts to give each tri their own 3 individual corners?


Yasha(Posted 2010) [#6]
Have you seen this?

http://www.blitzbasic.com/codearcs/codearcs.php?code=680

This also looks helpful:

http://www.blitzbasic.com/codearcs/codearcs.php?code=422

"Unwelding" seems to be the term people use for this. The absolute simplest way to achieve it is to create a second mesh, and loop through the original's triangles, creating three new vertices matching the old positions and UVs, then applying to triangle to them. This creates a clone, with any vertices that were shared between triangles now duplicated. Obviously needs a little more work if there are multiple surfaces involved or other complications.