rmitton / rjm

Various single-file C libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't make marching cubes work

slapin opened this issue · comments

I'm really sorry for disturbance, but could you please provide some small working example
to run rjm_mc.h?

I tried to use it but got mess of points. It looks like vertices are not correctly generated.

What I get:

http://ossfans.org/pic.png

isofn:

                static float isofn(const float *pos, float *extra, void *userparam)
                {
                        Vector3 position(pos);
                        extra[0] = position.x_;
                        extra[1] = position.z_;
                        if (position.y_ > 4.0f)
                                return 1.0f;
                        if (position.y_ < 1.0f)
                                return 1.0f;
                        float center = 1.0f + (5.0f - 1.0f) / 2.0f;
                        if (position.y_ < center)
                                return position.y_ - center;
                        else
                                return center - position.y_;

I've updated the header to include a complete working example, which should get you going :-)