How to draw Schwarz P-surface in opengl?

here is the link:

please help,i have no clue at all

Do you have an equation (either implicit or parametric) for the surface? If you have an implicit equation (i.e. f(x,y,z)=0), then you can generate a mesh with the correct topology and approximate vertex positions then use Newton’s method to move the initial vertex position onto the surface.

The Wikipedia article gives the approximation cos(x)+cos(y)+cos(z)=0. For that, the gradient is just [-sin(x),-sin(y),-sin(z)]. Or you could just solve for one coordinate in terms of the other two, e.g. z=acos(-cos(x)-cos(y)).

1 Like

thank you very much, i used marching cubes to make it,but the result not right,only half showed,how to fix it?1_(HE327@`)OA4~ZKWPM6

I’m not certain, but it looks like front faces are being culled; try glDisable(GL_CULL_FACE).

If that isn’t the issue, try glPolygonMode(GL_FRONT_AND_BACK, GL_LINE) to draw a wireframe version to see whether the issue is with the geometry or its rasterisation.

1 Like

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.