1

I would like to create a 3-D shape that is defined on some mesh such that the shape can be defined in a Conway Polyhedron Notation and so that I can interact with each face as its own object.

The goal of this project is to take a 3-D shape of some kind, and experiment with cellular automata rules in 3-D. For example, if there is a cube defined and the top face is in a "on state" all adjacent faces enter the "on state". Next cycle, if a face is adjacent to more two "on state" faces, it sets itself to an "off state".

In an ideal world, I would like the faces to be their own instances of a Class so that they can hold multiple states at the same time. I don't know if they would each need to be held in a separate array or map to the shape, or if they should be defined directly by the shape.

I am not new to C++ but I have never tried anything graphical and not a flat Qt UI before. This is my first stack overflow question so please let me know if I am including too much or too little information. Maybe C++ is the totally wrong tool for this, or the project is bad in its conception, let me know!

EDIT: A clarification, I would like to work with just the surface of the sphere like an eggshell.

1 Answers1

0

The simple and obvious way to represent an arbitrary abstract polyhedron would be to represent each face of the polyhedron with an object that contains its state and a list of its neighboring faces.

You can also include additional properties in your Face objects. For example, if you want to update the states of all faces "simultaneously", you can implement that by having each face store both its current state and its future state after the next update. After you've looped through all the faces ones to calculate their future state, loop through them again and replace the current state with the future one.

Also, if you intend to draw the polyhedron for the user to see, you probably want your Face objects to include a list of the 3D coordinates of the face's corners.

And yes, you will probably also want to have a list of all the faces of your polyhedron stored somewhere so that you can easily iterate over it. You can wrap this in a Polyhedron class if you like, and also include any other "global" state that your algorithm might need (such as the number of cycles processed so far) in it. If you're using a language like C++ without automatic garbage collection, having a list of all the Face objects will also make it easier to free them once you no longer need them.

This will probably not be the fastest or most memory-efficient possible solution. But it's simple and flexible and should be more than adequate, at least unless your polygons have billions of faces.

Ilmari Karonen
  • 49,047
  • 9
  • 93
  • 153