PDA

View Full Version : Transform a quadric in another one

Greencoco
03-05-2017, 05:36 AM
Hey !

So I started to do some stuff with OpenGL few days ago and I have a homework but I don't really understand how to do it

I have to make a quadric like a sphere and I have to turn it into another quadric like a cylinder with an animation.
But yeah I searched on the internet, i couldn't find anything and I have no clue how to do that...

So can someone explain to me how can I do that or just show me an example for me to understand ?

Thanks !

GClements
03-05-2017, 07:55 AM
To make things simple, both quadrics need to have the same topology. So the difference between the sphere and the cylinder will be that the cylinder's radius is constant whereas the sphere's radius changes (reaching zero at the poles).

So first figure out how to draw a cylinder as an MxN grid of quads. Then draw a sphere using the same arrangement of quads, but with the vertex coordinates changed so the radius varies along the axis. Then it's just a matter of making the radius a function of both distance along the axis and time.

Greencoco
03-05-2017, 01:07 PM
Ok thanks for your explanation i will try !

But if I use per example, gluCylinder to make a Cylinder, can i simply change its parameters and make an animation to transform the cylinder into a cone ?

GClements
03-05-2017, 04:12 PM
But if I use per example, gluCylinder to make a Cylinder, can i simply change its parameters and make an animation to transform the cylinder into a cone ?
You can' transform it into a cone by animating one of the radii (base or top parameters) so that it goes to zero. But you can't make gluCylinder() produce a sphere or gluSphere() produce a cylinder. There are ways to capture the generated vertices, but it would almost certainly be simpler to just generate the data yourself rather than using those functions (also, GLU is deprecated, because much of its functionality depends upon deprecated features and won't work in an OpenGL 3+ core profile).