0

Please bear with me in this rather long question.

I am currently building a voxel engine (nothing like Minecraft, don't worry). I want the engine to be modular. For example, I want the voxel 'engine' to be a seperate component to the 'renderer'.

The engine currently builds up a database of voxel objects that are each composed of a 3-dimensional array. However, the renderer makes use of meshes extracted from this data using the marching cubes algorithm. I need to store both the voxel data and the mesh data for each voxel object. However, since both components are modular they cannot be stored in the same place.

My current solution has been to build a secondary data structure inside the renderer that attempts to mirror the engine. It does this by duplicating the objects in the engine structure, giving each object a pointer to the object they mirror. However, this quickly becomes complex, since modifications to the original data structure have to be updated by the mirrored version.

As you can see, the problem is more theoretical than technical. Could anyone help me in suggesting an OOP structure that my program may take to solve this issue better? I'm open to all suggestions, however radical.

Thanks.

Barry Smith
  • 281
  • 1
  • 4
  • 16
  • Possibly something for [SE: programmers](http://programmers.stackexchange.com). – Pixelchemist Jul 15 '15 at 20:33
  • Your question is too broad for Stack Overflow. – Captain Obvlious Jul 15 '15 at 20:33
  • i solved this same problem by keeping the data structures separate, and then building functions that will convert from voxel data to mesh data. But I use functional programming, so no modifications to the data structure are happening. see http://sivut.koti.soon.fi/~terop/GameApi.html – tp1 Jul 15 '15 at 20:53
  • @tp1 I would do that, but the problem is this voxel data can't be converted to mesh data in real-time so I need a method by which I can store it in a data structure. – Barry Smith Jul 15 '15 at 20:57
  • there's thing called "flyweight pattern" which is used to draw fonts etc, but also suitable for voxel-like things. – tp1 Jul 15 '15 at 21:11
  • @tp1 I looked up the flyweight pattern. Very useful, but I'm not sure it would help me with my problem. Thanks for the suggestion though. – Barry Smith Jul 15 '15 at 21:29
  • @Pixelchemist when referring other sites, it is often helpful to point that [cross-posting is frowned upon](http://meta.stackexchange.com/tags/cross-posting/info) – gnat Jul 15 '15 at 21:38

0 Answers0