3D Modeling 3D Modeling 1 Virtual enviroments can be populated with "models" as well as regular geometries (glut shapes, glu quadrics, gl primitives). Models are: collections of primitives often in a display list or file have colors, materials, or textures can have transforms ("bones") Hand (artist) generated models made with 3D software (Maya, 3D Studio, Lightwave, Blender, AC3D, Goggle sketchup,...) + wysiswug? easy to use, but opengl needs a loader utility - time intensive, needs artistic skill Procedurally generated (TerraGen,...) + parameterized, extendable - know grammars, programming
Using 3D Modelers 3D Modeling 2 When using a "hand" 3D modeler you need to know how the OpenGL model loader works before drawing your model. AC3D 6.1 installed in JD 1618 and GMC Lab Model surfaces not vertices : flat shading surface color material Set surface triangulation 3 orthographic views 1 3D view Use colors not textures for the assignment model.
AC3D 3D Modeler Placing your mouse over items presents a tooltip help. 1 3 3D Modeling 3 [1] shows the selection modes: group (many objects), object, surface, pixel. You probably want to [2] deselect select through. [3] shows where the mouse position and 2 selected objects dimension are shown There is a good tutorial off the AC3D site: http://www.inivis.com/ac3d/tutorials/
Spaceship should be facing towards -Z Surface 3D Modeling 4 Before exporting triangulate your surfaces (Menu Surface triangulate). Select all objects and optimize (Menu Object Optimize vertices and Optimize surfaces). Models for 465 project should have the origin at their center and fit within the boundaries of geometrical spaceship ( ± 100 on X, Y, Z)
trimodel465.hpp 3D Modeling 5 Export ac3d model as triangle file. *.tri (cube.tri) 9 vertices and hex color value (no texture) loadtrimodel(...) method will read a *.tri file and create vertex[], color[], and normal[] arrays. See the example project TriModelVierwer for an example on how to load a *.tri model and display it in OpenGL. Uses cube-1-1-1.tri You need to know the number of lines in the *.tri file (use text editor) If some of the surfaces appear black (and shouldn't be black) you have a normal going in the wrong direction. Return to AC3D (the *.ac) file, select the surface and correct the normal's direction (Menu Surface Flip normal). Export to *.tri and re-examine.
load many *.tri models w/ trimodel465.hpp 3D Modeling 6 cube.tri model has 12 lines, each has 3 vertices and a color (hex coded) 0.5 0.5-0.5-0.5-0.5-0.5-0.5 0.5-0.5 0xFFFFFF Each line is a triangular surface. There are 36 vertices in this model. The utility trimodel465.hpp has 2 methods float loadtrimodel(char * filename, int nvertices, glm::vec4 vertex[], glm::vec4 color[], glm::vec3 normal[]) float loadmodelbuffer(char modelfile[25], GLuint nvertices, GLuint vao, GLuint vbo, GLuint shaderprogram, GLuint vposition, GLuint vcolor, GLuint vnormal, char * shadervertex, char * shadercolor, char * shadernormal)
loadmodelbuffer(...) 3D Modeling 7 ManyModelsStatic.cpp uses loadmodelbuffer (...) method and scales its models based on the returned bounding sphere. for (int i = 0; i < nmodels; i++) { modelbr[i] = loadmodelbuffer(modelfile[i], nvertices[i], VAO[i], buffer[i], shaderprogram, vposition[i], vcolor[i], vnormal[i], "vposition", "vcolor", "vnormal"); // set scale for models given bounding radius scale[i] = glm::vec3( modelsize[i] * 1.0f/modelBR[i]); } Declared un-initialized arrays (VAO, buffer, vposition, vcolor, vnormal) are passed in and set by the utility. For each model a VerterArrayObject is created and bound to the buffers holding its vertices (vposition[i]), colors, and normal. These buffers are set to the shader programs in variables ("vposition"). loadtrimodel(...) is called first to read the vertices and colors and to compute normal for the surfaces (modelfile[i]).
Using other modelers 3D Modeling 8 You can use other 3D modelers I do not have experience with many... To use the trimodel465.hpp loader you should: model only with color materials. Do not use textures! export as *.3ds (3D Studio Max format). Use AC3D (in lab) to import your *.3ds model and export it as a triangle model (*.tri). You can use other 3D modelers w/o using trimodel465.hpp loader. You will have to write the equivalent functionality of trimodel 465.hpp Some OpenGL model loaders you might find on the internet are not "core" OpenGL compatible. Your models can't be drawn in C code, they must be stored on the GPU as vertices, normals, and colors. This way you can use the simplevertex.glsl and simplefragment.glsl shaders for the first 2 assignments.
3D Modeling 9 Free 3D modeler Blender high learning curve Free educational version for students, create an account, can install on 2 personal systems. 3D Studio Max a simpler 3D modeler, like AC3D Maya high learning cure Assimp-3.2 an open source asset importer can be used within C/C++ programs to load many model formats. Use is non-trivial.
pyramid example 3D Modeling 10 glm::vec4 const vertex_positions[5] = { glm::vec4( -5.0f, -8.0f, 5.0f, 1.0f ), // 0 front left bottom glm::vec4( 5.0f, -8.0f, 5.0f, 1.0f ), // 1 front right bottom glm::vec4( 5.0f, -8.0f, -5.0f, 1.0f ), // 2 back right bottom glm::vec4( -5.0f, -8.0f, -5.0f, 1.0f ), // 3 back left bottom glm::vec4( 0.0f, 8.0f, 0.0f, 1.0f ), // 4 apex }; // RGBA colors for each vertex glm::vec4 const vertex_color[5] = { glm::vec4( 1.0f, 0.0f, 0.0f, 1.0f ), // 0, red glm::vec4( 0.0f, 1.0f, 0.0f, 1.0f ), // 1, green glm::vec4( 0.0f, 0.0f, 1.0f, 1.0f ), // 2, blue glm::vec4( 0.8f, 0.8f, 0.8f, 1.0f ), // 3, light gray glm::vec4( 0.8f, 0.8f, 0.8f, 1.0f ) // 4, light gray views: front right top 3 2 4 0 1
Model in code 3D Modeling 11 The pyramid.cpp example demonstrates how to create a "model" in code not loaded from a model file. Similar to Angel & Shreiner's example. Each model consists of vertices that have a vec4 position and color. These vertices will be stored in the currently bound GL_ARRAY_BUFFER (buffer) on the GPU. The points are stored first followed by the colors. This pyramid has 18 vertices (point[numvertices]): 2 triangular surfaces on the bottom (6) and 4 triangular sides (12). Since vertices are shared by surfaces we define 5 vertices (4 at bottom, 1 at top) in vertex_position[]. (see previous page, colors also) The init() method calls pyramid() that calls triangle(a, b, c) 6 times to set the point[] of vertices. Method triangle's 3 arguments are "indexes" into vertex_position[]. The indexes references vertices define edges in a counter-clockwise direction from looking at the outside of the pyramid at the surface.
3D Point Cloud A point cloud is a set of vertices that represent an object's surface. Point clouds are most often created by 3D scanners. Often converted to 3D surface geometry. 3D Modeling 12 Point_cloud_torus.gif "laser image", LA SIGGRAPH 2012 image captured by 3D3 solutions, http://www.3d3solutions.com/ display program: CloudCompare V2 http://www.danielgm.net/cc License: GNU GPL (General Public Licence) Version: 2.4.Qt/MSVC - 09/22/2012