How can I create the following model:
by starting from the first drawing. Could it be programmed in OpenGL entirely or should I use other software like 3d Studio Max or Unity? Are there some specific algorithms that should be used?
How can I create the following model:
by starting from the first drawing. Could it be programmed in OpenGL entirely or should I use other software like 3d Studio Max or Unity? Are there some specific algorithms that should be used?
Yes this can be done in C++/OpenGL
create random curves emitting from center
simple 3D quadratic polynomial curve will fit the bill.
convert the curves to cones
simply interpolate points along each curve and use it as a center for the cone slice. The direction is set by the previous or next point along the curve. Interpolate the cone slices and add their points to some point list. See:
create faces
simply connect the computed points to form the cones using any primitive ... I would suggest
GL_QUAD
s...core
if you want to add also the core (nuclei?) it can be done a s a sphere with some noise added to its surface and probably some filtering to smooth it a bit...
Here simple curve generation C++ example:
Preview of the generated points:
[Edit1] When added the cones,normals and faces it looks like this:
Its far from perfect but I think is a good start point. Just tweak the radius
r
and the curve coefficientsa1[],a2[]
to achieve desired shape ... and may be add the core and or check for self intersections too, I am too lazy to do that...Here the updated C++/GL code:
If you do not know how to compute vector operations like cross/dot products or absolute value see:
vector_mul(a[3],b[3],c[3])
is cross producta = b x c
a = vector_mul(b[3],c[3])
is dot producta = (b.c)
vector_one(a[3],b[3])
is unit vectora = b/|b|
vector_copy(a[3],b[3])
is just copya = b
vector_add(a[3],b[3],c[3])
is addinga = b + c
vector_sub(a[3],b[3],c[3])
is substractinga = b - c
vector_neg(a[3],b[3])
is negationa = -b
vector_ld(a[3],x,y,z)
is just loadinga = (x,y,z)
Also some (if not all the) Vector math used can be found here:
I also use mine dynamic list template so:
List<double> xxx;
is the same asdouble xxx[];
xxx.add(5);
adds5
to end of the listxxx[7]
access array element (safe)xxx.dat[7]
access array element (unsafe but fast direct access)xxx.num
is the actual used size of the arrayxxx.reset()
clears the array and setxxx.num=0
xxx.allocate(100)
preallocate space for100
items