UAV Simulator
Loading...
Searching...
No Matches
World Class Reference

Manages terrain, ground, and 3D grid elements within the simulation scene. More...

#include <world.h>

Public Member Functions

 World ()
 Constructs a World object with default parameters.
 
void createGround (easy3d::Viewer &viewer)
 Creates a flat ground surface and adds it to the viewer.
 
void createTerrain (easy3d::Viewer &viewer)
 Creates a basic 3D terrain surface without textures.
 
void createTerrainWithTexture (easy3d::Viewer &viewer)
 Creates a 3D terrain surface and applies a texture image.
 
void createGridDrawable (easy3d::Viewer &viewer)
 Generates and displays a 3D coordinate grid.
 

Private Attributes

const float size
 Actual grid size for this world instance.
 
const int numLines
 Number of grid lines for this world instance.
 
const float offset
 Grid offset to displace it from the origin.
 
easy3d::LinesDrawable * gridDrawable
 Pointer to Easy3D's LinesDrawable used to render the grid.
 
std::vector< easy3d::vec3grid_vertices
 Vertices defining the grid lines.
 
std::unique_ptr< easy3d::Texture > terrainTexture
 

Static Private Attributes

static constexpr float DEFAULT_GRID_SIZE = 6000.0f
 Total size of the grid (length of each axis), in world units.
 
static constexpr float DEFAULT_OFFSET = 3000.0f
 Vertical offset for the grid to visually separate it from objects like aircraft.
 
static constexpr int DEFAULT_NUM_LINES = 70
 Number of lines along each axis of the grid.
 

Detailed Description

Manages terrain, ground, and 3D grid elements within the simulation scene.

This class generates various visualization components such as:

  • A flat ground surface
  • A procedurally generated 3D terrain
  • Optional textured terrain
  • A 3D grid system for spatial orientation

Constructor & Destructor Documentation

◆ World()

World::World ( )

Constructs a World object with default parameters.

Constructs a World instance with default parameters.

Initializes size, offset, and resolution of the 3D grid.

Initializes grid size, line count, and offset for visualization.

Member Function Documentation

◆ createGridDrawable()

void World::createGridDrawable ( easy3d::Viewer &  viewer)

Generates and displays a 3D coordinate grid.

Creates and renders a 3D spatial grid on the three principal planes (XY, YZ, XZ).

Parameters
viewerThe Easy3D viewer to which the grid will be added.

The grid helps users orient themselves in the virtual space.

Parameters
viewerReference to the Easy3D viewer.

◆ createGround()

void World::createGround ( easy3d::Viewer &  viewer)

Creates a flat ground surface and adds it to the viewer.

Adds a flat rectangular ground plane to the scene.

Parameters
viewerThe Easy3D viewer to which the ground will be added.
viewerReference to the Easy3D viewer to which the ground is added.
Deprecated:
Use createTerrainWithTexture() for enhanced visual realism.

◆ createTerrain()

void World::createTerrain ( easy3d::Viewer &  viewer)

Creates a basic 3D terrain surface without textures.

Loads and displays 3D terrain from an STL mesh.

Parameters
viewerThe Easy3D viewer to which the terrain will be added.
viewerReference to the Easy3D viewer.
Deprecated:
Use createTerrainWithTexture() for textured terrain rendering.

◆ createTerrainWithTexture()

void World::createTerrainWithTexture ( easy3d::Viewer &  viewer)

Creates a 3D terrain surface and applies a texture image.

Loads an STL terrain mesh and applies a repeating texture.

Parameters
viewerThe Easy3D viewer to which the textured terrain will be added.

Automatically computes UV coordinates to ensure aspect-ratio-correct tiling.

Parameters
viewerReference to the Easy3D viewer.

Member Data Documentation

◆ DEFAULT_GRID_SIZE

constexpr float World::DEFAULT_GRID_SIZE = 6000.0f
staticconstexprprivate

Total size of the grid (length of each axis), in world units.

The grid spans from -size/2 to +size/2 in each direction.

◆ DEFAULT_NUM_LINES

constexpr int World::DEFAULT_NUM_LINES = 70
staticconstexprprivate

Number of lines along each axis of the grid.

Determines the grid's resolution (higher = denser grid).

◆ DEFAULT_OFFSET

constexpr float World::DEFAULT_OFFSET = 3000.0f
staticconstexprprivate

Vertical offset for the grid to visually separate it from objects like aircraft.

◆ grid_vertices

std::vector<easy3d::vec3> World::grid_vertices
private

Vertices defining the grid lines.

Stored as a flat list of 3D points, where each pair defines a line.

◆ gridDrawable

easy3d::LinesDrawable* World::gridDrawable
private

Pointer to Easy3D's LinesDrawable used to render the grid.

Managed by Easy3D and registered with the Viewer.

◆ numLines

const int World::numLines
private

Number of grid lines for this world instance.

Initialized from DEFAULT_NUM_LINES.

◆ offset

const float World::offset
private

Grid offset to displace it from the origin.

Initialized from DEFAULT_OFFSET.

◆ size

const float World::size
private

Actual grid size for this world instance.

Initialized from DEFAULT_GRID_SIZE.

◆ terrainTexture

std::unique_ptr<easy3d::Texture> World::terrainTexture
private

The documentation for this class was generated from the following files: