Upload
src0108
View
216
Download
0
Embed Size (px)
Citation preview
7/28/2019 16- More on 3D Modeling in OpenGL
1/9
Basic 3D ShapesMore on perspective projectionLeft- vs. Ri ht-handed coordinate
systems.
7/28/2019 16- More on 3D Modeling in OpenGL
2/9
Glut has many different preset 3d shapes foruse in OpenGL.
Both solid and wireframe versions for eachshape.
For a cube: glutSolidCube(GLdouble size); glutWireCube(GLdouble size);
Render a solid or wireframe cube respectively. Thecube is centered at the modeling coordinates origin
with sides of length size. Next we will show only the solid version functions,
remember wireframe versions are available too.
7/28/2019 16- More on 3D Modeling in OpenGL
3/9
Sphere:
glutSolidSphere(GLdouble radius, GLintslices, GLint stacks);
radius: The radius of the sphere.
slices: The number of subdivisions around the Z
axis (similar to lines of longitude). stacks: The number of subdivisions along the Z axis
(similar to lines of latitude).
Cone:
glutSolidCone(GLdouble base, GLdouble
height, GLint slices, GLint stacks);
7/28/2019 16- More on 3D Modeling in OpenGL
4/9
Torus (doughnut) glutSolidTorus(GLdouble innerRadius,
GLdouble outerRadius, GLint nsides, GLint
rings);
innerRadius: Inner radius of the torus..
nsides: Number of sides for each radial section. rings Number of radial divisions for the torus.
TeapotglutSolidTeapot(GLdouble size);
size: Relative size of the teapot.
& some other shapes as well
7/28/2019 16- More on 3D Modeling in OpenGL
5/9
glFrustum( GLdouble left, GLdouble right,
GLdouble bottom, GLdouble top, GLdouble
near, GLdouble far);
7/28/2019 16- More on 3D Modeling in OpenGL
6/9
gluPerspective( GLdouble fovy, GLdouble
aspect, GLdouble near, GLdouble far);
7/28/2019 16- More on 3D Modeling in OpenGL
7/9
gluPerspectivegluPerspectivegluPerspectivegluPerspective()()()() requires only 4 parameters.
Can produce a symmetrical viewing volume only.
you have to use glFrustumglFrustumglFrustumglFrustum()()()() directly if you need tocreate a non-symmetrical viewing volume.
if ou want to render a wide scene into 2 ad oinin
screens, you can break down the frustum into 2asymmetric frustums (left and right). Then, renderthe scene with each frustum.
7/28/2019 16- More on 3D Modeling in OpenGL
8/9
It is very important to remember thatgluPerspectivegluPerspectivegluPerspectivegluPerspective,,,, glOrthoglOrthoglOrthoglOrtho andandandand glFrustumglFrustumglFrustumglFrustum are lefthanded.
It is easier if you think ofzNearzNearzNearzNearand zFarzFarzFarzFarasdistances from view oint ( oint where the camera
is placed, using the glulookAt function). Everything else is right handed, including the
vertices to be rendered.
7/28/2019 16- More on 3D Modeling in OpenGL
9/9
Refer to the attached code. Notice the difference between orthographic
and perspective projections. Try changing the parameters of the
ro ection functions calls, and the luLookAt
function call. Two OpenGL programs (with their source
code) are attached as well, they will help youbetter understand how to adjust theparameters passed to the projection andtransformation functions.