|
Easy3D 3.0.0
|
Opening the default Easy3D Viewer to interactively inspect a 3D model.
Overview
This is the first interactive tutorial: it loads a model from disk and hands it to the built-in Viewer, which opens a window with a complete navigation interface (rotate, pan, zoom, picking, snapshots, ...). Almost every graphical Easy3D example builds on this same skeleton — initialize the library, create a Viewer, add one or more models, then call run(). The later tutorials (202-206) extend this viewer with custom GUI, multiple views, offscreen rendering, and camera control.
The technique
An interactive 3D viewer is driven by a render loop: the windowing system delivers input events (mouse drags, key presses, resize), the viewer updates the camera and scene state in response, and then redraws the framebuffer. Viewer::run() enters this loop and only returns when the user closes the window. The Camera is the piece that maps the 3D scene onto the 2D image: it holds a position and orientation (its Frame), a field of view, and near/far clipping planes, and from these it builds the view and projection matrices used by the GPU. Here we orient the camera before loading the model so the scene is presented from a known direction: looking down the -Z axis with +Y up, i.e. a standard "front" view.
Easy3D API
Running it
A window opens showing the "easy3d" logo model. Drag with the left mouse button to rotate, the right button (or wheel) to pan/zoom, and use the built-in shortcuts for snapshots and display options. Close the window to exit; run() then returns and the program ends.