Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing complex surfaces in OpenGL

I want to know the techniques used to render complex surfaces that can't be represented by a mathematical equation (like a car, ) in OpenGL. Do we create it by combining so many basic elements (sphere, cone, ...)? Or there are some other methods? I am about to start creating an app that will render a 3D car and want to know where to start.

like image 545
yassin Avatar asked Jan 23 '14 00:01

yassin


3 Answers

You can use a third-party tool, such as Blender to create models that can be exported and then rendered in OpenGL. These models are usually composed of triangles, but drawn with 3D tools analogous to 2D's pen and paper.

Here is a tutorial on the subject: OpenGL Model Tutorial

like image 166
Steven Hansen Avatar answered Nov 10 '22 05:11

Steven Hansen


Yes, OpenGL produces images by drawing many basic elements (known as "primitives").

The most commonly used primitives are triangles and quadrilaterals (or "quads", which are commonly implemented as two triangles). (There are also provisions for drawing line and point primitives, but these are not typically used for drawing photorealistic surfaces.)

Complex surfaces are approximated with a mesh of triangles or quads. Hidden surface removal is typically done by using a depth map: primitives drawn closer to the camera inhibit and override more distant primitives on a per-pixel basis.

In order to reduce the tessellation level necessary to produce a good image, OpenGL supports interpolation of a (fictitious) tangent plane between triangle (and quad) corners. This cheap approximation, called a "shading normal", practically eliminates the faceted appearance that would otherwise mar a continuous surface approximated with a modest number of primitives.

like image 21
comingstorm Avatar answered Nov 10 '22 04:11

comingstorm


It is very hard to design you object from scratch. OpenGL is polygon rendering machine. Usualy objects are represented by verteces for their 3D position and indices for how they conect obj file. You can find some obj files that represent a car for example or anything else and to render it. Also there is a alternative method for designing complex models using patches. Patches are used in CAD programs for better control over the model patches. To make more complex model you conect many patches together.

like image 21
crow Avatar answered Nov 10 '22 05:11

crow