PDA

View Full Version : Marching Cubes demo for FPC



Ingemar
24-09-2011, 06:27 AM
I just grabbed the Marching Cubes demo code from here:

http://paulbourke.net/geometry/polygonise/

More specifically, the "marchingsource.cpp" code. It is C++, but really plain C, using GLUT. That means a very simple program structure, and very portable indeed. I could easily make it run perfectly on my Mac. Then I decided to port it to FPC.

http://www.ragnemalm.se/lightweight/bilder/mc.png

Source: http://www.ragnemalm.se/lightweight/marchingsource.pas

This is converted and tested under OSX, but the code should be easy to port anywhere.

Seriously, this is not the most modern code around. In particular, it uses OpenGL immediate mode, which should be replaced by arrays for better performance. To make it really good, computations should be performed on the GPU as far as possible.

This might have been ported before, but I couldn't find anything like that in the forum so maybe it can be of some interest, not least considering its potential usage for water simulations.

chronozphere
24-09-2011, 08:40 AM
Great work! I was pretty shocked to see SO MANY numbers in that file! OMG :p

User137
24-09-2011, 10:43 AM
Modified a little to adjust to nxPascal. I don't use glut at all so those are commented out or removed. Didn't make replacement for wireframe code and some keys are propably not working, or maybe do but i don't see their effect. Most importantly blue orbs are bubbling around :)
Here is source code and executable:

Andru
24-09-2011, 01:49 PM
This demo was ported (http://www.sulaco.co.za/opengl_project_metaballs.htm) long time ago by Jan Horn... :)

Ingemar
25-09-2011, 12:42 PM
This demo was ported (http://www.sulaco.co.za/opengl_project_metaballs.htm) long time ago by Jan Horn... :)

I suspected there could be something like that. But that code doesn't look like a port, and isn't presented as such either. Based on the other though.

And as a bonus, it is about time for a thread about Marching Cubes here. :)