While it is convenient to use mesh files provided by external sources, we may want to make our own .obj files for objects to either create unique shapes, or to adjust size, orientation, and origin locations for basic geometric meshes. In this lab, we will see how to create a basic mesh shape in Blender and export it to an .obj file that our basic model loader can load into our application.

Getting Started

Download CS370_Lab12.zip, saving it into the CS370-Fall2022 directory.

Double-click on CS370_Lab12.zip and extract the contents of the archive into a subdirectory called CS370_Lab12

Open CLion, select CS370-Fall2022 from the main screen (you may need to close any open projects), and open the CMakeLists.txt file in this directory (not the one in the CS370_Lab12 subdirectory). Uncomment the line

	add_subdirectory("CS370_Lab12" "CS370_Lab12/bin")

Finally, select Reload changes which should build the project and add it to the dropdown menu at the top of the IDE window.

Solution

Download CS370_Lab12_Solution.zip, saving it into the CS370-Fall2022 directory.

Double-click on CS370_Lab12_Solution.zip and extract the contents of the archive into a subdirectory called CS370_Lab12_Solution

Open CLion, select CS370-Fall2022 from the main screen (you may need to close any open projects), and open the CMakeLists.txt file in this directory (not the one in the CS370_Lab12_Solution subdirectory). Uncomment the line

	add_subdirectory("CS370_Lab12_Solution" "CS370_Lab12_Solution/bin")

Finally, select Reload changes which should build the project and add it to the dropdown menu at the top of the IDE window.

For this lab you will also need to install Blender.

Adding a Mesh

When Blender is first opened, there is a default cube centered at the origin.

Blender Window

To delete this stock object, simply right-click and select Delete.

Blender Delete Window

Then to add a new mesh (at the origin) simply hit <Shift>-A which should pop up the add dialog and select Mesh which should pop out a list of mesh objects that are built in to Blender.

Blender Add Window

After the mesh has been added, there may be a dialog box in the lower left portion of the main window that will allow configuration of the added mesh typically including the default size, location, and orientation.

Some additional meshes can be obtained by selecting the drop down menu in the lower right window, choosing Data->Preferences->Add-ons->Add Mesh: Extra Objects.

Multiple Meshes

You can also combine several meshes together, which is necessary for our model loader to work properly, by

Tasks

Exporting a Mesh

To export the mesh, from the menu bar select File->Export->Wavefront (.obj)

Blender Export Window

Select the location where you want to export the file and the name for the file. In the lower right panel, expand the Geometry tab and make sure the selections match the figure below, i.e. only Apply Modifiers, Write Normals, Include UVs, and Triangulate Faces are checked. This will produce a file that can be imported by the basic model loader we are using.

Blender Settings Window

Tasks

This lab is only to create simple geometry meshes in Blender that can be loaded into our OpenGL applications using our simple model loader. For more information about using all the features of Blender to create more sophisticated models, one place to start is the Blender tutorials.

Compiling and running the program

You should be able to build and run the program by selecting blenderMonkey from the dropdown menu and clicking the small green arrow towards the right of the top toolbar.

At this point you should see a cube and Blender monkey with lighting.

Blender Monkey Window

To quit the program simply close the window.

Congratulations, you have now created a simple model in a modeling program and imported it into an application.

Next we will greatly enhance the visual appearance of our objects using texture mapping.