Optimize mesh creation/loading

Hello, first of all thanks to all the developers of this engine for the work done here :slight_smile: Next, I’ve been “playing” with jmonkey for a pair of weeks and I’ve created a very primitive hexagonal board for my board game. I didn’t see anywhere any “guide of style” or something similiar so I’ve made the things in a way I think that is not the best.

I will try to explain myself:

  • I’ve created an hexagon mesh in blender and exported to jmonkeyengine (I know that can be done directly from jmonkey but I wasn’t able to do it :frowning: )
  • In blender created a low poly forest and a mountain and exported to jmonkey.
  • Created a boardNode and added it to the rootNode.
  • Make a double loop for creating tiles and in every pass clone the original hexagon, create a new node and add this to the boardNode.
  • In every created tile look if is necessary an “forest” or a “mountain” clone the forest or the mountain and add it to the tile.

The result of the process is “acceptable” but take some time and I’m beginning to think that I’m abusing of the clone of meshes and maybe there is a better way to do this.

Thanks in advance for any clue and sorry for my poor english :frowning:

Try clicking the documentation menu item right onthis page to get a “guide of style”.

1 Like

Just now seeing that there was a whole page of documentation on optimization and another in which it is explained that clone is the same as making a loadAsset for the same Mesh. I am ashamed of my question: (

I apologize for the inconvenience: (

Abusing your trust I would ask if it’s right or make a DeepClone of a model or is better load a model with “loadModel” and apply the appropriate material evey time.

One more time thanks in advance.

@david.delamo said: Just now seeing that there was a whole page of documentation on optimization and another in which it is explained that clone is the same as making a loadAsset for the same Mesh. I am ashamed of my question: (

I apologize for the inconvenience: (

Abusing your trust I would ask if it’s right or make a DeepClone of a model or is better load a model with “loadModel” and apply the appropriate material evey time.

One more time thanks in advance.

as far as i know is that it makes a shallow copy, means that the mesh is shared and if you want to do not clone the material you can

can use clone(false);. This is useful If you do not alter the material of each spatial

1 Like

Sorry, I haven’t explained well the problem, I want to know if is better to load a mesh and apply a material or to deepClone a mesh with a material already applied.

My english is bad and feel I can’t explain correctly. Later I will try both options and will see by myself which one is faster.

Thanks for the answer anyway

All of that isn’t really “optimization”, theres no need to clone or share anything, it won’t improve performance. Meshes that can be shared will be shared anyway so you don’t get any memory benefits either. The performance mainly depends on how many single geometries you have, independent of how you created them.

1 Like

Ok, so the problem is that I got confused on my own :frowning: thank you for your patience and answers :slight_smile: