Creating Submeshes with Surfaces

BlitzMax Forums/MiniB3D Module/Creating Submeshes with Surfaces

AdamRedwoods(Posted 2011) [#1]
For miniB3D.

What this technically does is it allows you to create a separate mesh ENTITY from an existing mesh surfaces. So if you have a few meshes you'd like to use, but don't want to load in a bunch of files, then you'd create a bunch of meshes and assign them different surfaces, and load in only one 3D mesh file.

This would be useful for ideas like debris, or foliage, or if you want to animate individual parts even.
The prep work is that you would create your 3d models in your 3d program of choice, and for each object you would assign it to a separate, unique surface.

This only creates entities, so therefore, if the original mesh is altered, then the entity will be changed too.

Then you can use this tiny function to create an instance after you've loaded your mesh in.

Code:


example of use:
''say i have a model of debris, assigned 3 surfaces to the meshes in one file
r.explosion.positionentity r.x,2.0,r.z
r.debris = CreateSubMesh(debrismain,rand(0,2) ) ''choose random debris
r.debris.positionentity r.x,2.0,r.z  ''only the selected surface will show up 


This works with Lightwave-> obj export, but you cannot use layers as LW's plugin acts poorly when exporting layers. Putting them all into one layer works.

Last edited 2011

Last edited 2011

Last edited 2011