Me again!
OK, OpenGL is all polygons and vertexes .. no nice smoothies. I have had a look at the docs on gluCylinder, gluDisk etc which seem to be based on a general quadric (3D quadratic equation) but the implementation of those is probably nasty and somewhere deep in GLUT.
Q1 (an aside). Why only those limited forms of quadric ?? The general form of ax**2+by**2+cZ**2 + eXY+fXZ+gYZ should be capable of producing interesting forms (ellipsoids??)
Q2. This is the general problem. Suppose I have a solid defined by a simple functional form.
For x in -3..+3,
yupper = 1+sin(x), Ylower = 1-cos(x),
z= sqrt(abs(x))
Well, maybe that is not well expressed, but the idea is for a wiggly tube parallel to the x axis, whose cross section in the z direction varies as x.
More generally, I have a function that will return a set of x,y and z values that lie on the surface of the solid. (If it was a sphere, then we would know that x**2+y**2+z**2=C, but let us not assume that knowledge .. suppose we simply have a set of points that we know lie on a surface).
How do I get OpenGL to render this solid?
Am I talking about triangulation here? I came across
http://www.schorsch.com/rayfront/manual/generators.html#triangulate
Is this what I need and want and does OpenGL do it?
Or maybe this has something to do with a mesh .. anyone care to explain exactly what that is and how OpenGL uses it?
The above relates to having a black box function that returns 3D points on the surface of a solid, and I want to know how to render that solid.
If you DO know the mathematics eg tubey at
http://astronomy.swin.edu.au/~pbourke/surfaces/tubey/
which uses
-3 x8 - 3 y8 - 2*z8
+ 5 x4 y2 z2 + 3 x2 y4 z2
- 4 (x3 + y3 + z3 + 1) + (x + y + z + 1)4 + 1 = 0
how then do we go about it?
(I guess knots .. eg
http://www.cecm.sfu.ca/~scharein/sepicts/ have mathematical descriptions too).
I had a look at
http://astronomy.swin.edu.au/~pbourke/opengl/superellipsoid/
and that seems to calculate the entire surface using triangle strips, but it is not clear to me that this is a generally applicable method.
Paul Bourke's BLOB
http://astronomy.swin.edu.au/~pbourke/surfaces/blob/blob.pov
has POVRAY code (below), which is short and sweet - is there an OpenGL "equivalent"
Thanks for any enlightenment
#include "metals.inc"
#declare RR = 4;
#switch (clock)
#case (0)
#declare VP = <-RR,0,0>;
#break
#case (1)
#declare VP = <0,-RR,0>;
#break
#case (2)
#declare VP = <0,0,-RR>;
#break
#case (3)
#declare VP = <-0.7*RR,-0.7*RR,0>;
#break
#case (4)
#declare VP = <0,-0.7*RR,-0.7*RR>;
#break
#case (5)
#declare VP = <-0.7*RR,0,-0.7*RR>;
#break
#case (6)
#declare VP = <-0.7*RR,-0.7*RR,-0.7*RR>;
#break
#end
camera {
location VP
up y
right x
angle 60
sky <0,0,1>
look_at <0,0,0>
}
light_source {
<-15,0,0>
color rgb <1,0.5,0.5>
}
light_source {
<0,-15,0>
color rgb <0.5,1.0,0.5>
light_source {
<0,0,-15>
color rgb <0.5,0.5,1.0>
}
isosurface {
function {
x*x + y*y + z*z + sin(4*x) + sin(4*y) + sin(4*z) - 1
}
contained_by {
sphere { <0,0,0>, 4 }
}
threshold 0
accuracy 0.01
max_gradient 25
open
texture { T_Silver_5C }
}