Jump to content

Procedural geometry based on Unigine::Mesh


photo

Recommended Posts

Posted

Hello,

I'm trying to use Unigine::Mesh and Unigine::ObjectMeshDynamic for generating procedural geometry which is supposed to be modified by the user by setting some parameters from UI.

So I add surfaces and modify vertices/indices via Mesh class but seems that the drawback of this approach is that every time I do the geometry updates I need to transfer the mesh to ObjectMeshDynamic. The second approach, as I can see, is to submit geometry directly using ObjectMeshDynamic methods (addVertex, addIndex etc) that seem to be using/updating some internal mesh and the geometry update is triggered via flushVertex/Indices calls.

My question is, assuming that I'm always building a geometry from scratch during each update, would there be a difference (performance wise) between:

a) Modifying Unigine::Mesh and copying it to ObjectMeshDynamic using setMesh method and

b) Modyfing mesh directly in ObjectMeshDynamic and triggering updates using flushVertices/Indices call?

The only drawback I see so far is that I'm forced to reassign the material and intersection mask to ObjectMeshDynamic when I use the first approach. Material seems to get lost after setMesh call.

Thanks in advance

Posted

scopic

The only difference between a) and b) is that steMesh is doing always a CPU copy of the mesh. If you don't need it, you can stick with the second approach. Both of them are totally fine for your use-case.

Thanks!

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Thanks for your response. What about re-assigning materials after setMesh call? Seems materials are always lost and needs to be assigned again but I guess it is not an expensive operation at all?

Posted

scopic

Materials are usually assigned to the mesh surfaces, so when you doing a setMesh you are rewriting the whole mesh data (including the surfaces information). So you need to save the required information and restore (if needed) later.

Thanks!

  • Like 1

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...