Displaying Indoor Models

This tutorial showcases another approach compared to the Importing Geometries tutorial. Indeed, loading a complete landscape may be a burden, and this is a costly operation in terms of performances since REDart has to render the complete environment, including the landscape, vegetation, clouds and all decorative geometries.

As an alternative to using a full outdoor environment, we’ll use a HDR texture map generated from the outdoor environment:

../../../_images/wd_displaying_indoor_models_environment.png

The generated HDR environment map.

The Asset Editor can be used to produce environment maps: It’ll generate both a LDR, HDR and a suitable ART environment .red file that can be loaded as we’ll see below.

Loading an Environment Map

The loader is the ART::IAssetManager, and similarly to the loading of complete atlas, we load environment files instead:

// Load our environment:
RED::Object* environment;
RED::Matrix envaxis, planetaxissun;
RC_TEST( iassetmgr->LoadEnvironment( environment, envaxis, planetaxissun, "../Resources/atlas_Environment.red" ) );

// Setup the environment before starting the world:
RC_TEST( iearth->SetEnvironment( environment, 1.0, envaxis, 1000.0 ) );

// Start the world:
RC_TEST( iworld->Start( window, REDartProgressCB, NULL ) );

We see that the ART::IAssetManager::LoadEnvironment method returns two matrices:

  • The first matrix is the tangent space matrix containing the position and axis system of the environment used during its creation. It’s expressed in Planetary Coordinate System (PCS).

  • The second matrix is the World Coordinate System (WCS) matrix of the sun position used for the environment creation. It can be used to reposition the sun properly so that the lighting of the geometry matches the lighting of the surrounding environment. Therefore, it can be used “as is” for ART::IPlanet::OverrideAxisSystem.

Then, we call ART::IPlanet::SetEnvironment, instead of ART::IPlanet::SetAtlas that was used in the previous tutorial. Setting up an environment will remove an atlas and vice-versa. Note that the SetEnvironment method requires an altitude to be supplied. This is the maximal height of all geometries that are intended to be seen within the environment. This parameter is required noticeably for a proper setup of sun shadows.