Ani3D - Introduction

Download code base

The code base is available on Github:
Notes on the requirements

Introductory scene

Information on the library (only general information, no exercise)

CGP library provides a set of functionalities to ease 3D graphics programming such as
Structures and functions of the library are accessible in the namespace cgp::

Use of the code library

First observe the files main.cpp and application.cpp. You should recognize the general organization of the program, in particular the setup stage (application_structure::initialize), and the animation loop stage (application_structure::animation_loop). Note where the two main methods scene().initialize() and s.display_frame() are called in application.cpp, and their implementation in the file scene.cpp.
In the following we consider the file scene.cpp (and scene.hpp).

Adding a sphere

In this first part we display a new sphere to the scene.
cgp::mesh_drawable sphere; 
mesh sphere_mesh = mesh_primitive_sphere(0.5f);
sphere.initialize_data_on_gpu(sphere_mesh);
  • (or variant: simply in one line without explicitly storing the mesh variable)
sphere.initialize_data_on_gpu(mesh_primitive_sphere(0.5f));
draw(sphere, environment);
sphere.material.color = vec3(1+std::cos(time), 1+std::sin(time), 2.0)/2.0f;

Checkbox interface

We will now add a GUI checkbox (button that can be checked) to activate/deactivate the wireframe display of the sphere.
bool display_wireframe = false;
ImGui::Checkbox("Wireframe", &gui.display_wireframe);
The last step consists in adapting the behavior of the display.
	if (gui.display_wireframe)
		draw_wireframe(sphere, environment, { 1,1,0 });