Importing geometriesnew

This tutorial extends the previous Loading a simple landscape tutorial. After loading the landscape, we'll setup a full house model over it for a real-time review. Please note that this tutorial does not cover the making of the house, which is covered by other related tutorials.

Overview of the imported house

For those who are in 3D for a long time, you should recognize this model quite easily ;) The model itself is quite small (so that it's not too heavy as a tutorial) and features:

From this, we use ART to setup:

Finally, the model is packaged as a single .red file ready to use in any application.

Loading a "ready to view" geometry

The needed code to load a geometry is quite straightforward. Compared to the previous landscape tutorial, we add the geometry loading using the RPL::IAssetManager::LoadGeometry call and we do the placement of the geometry on the landscape using the RPL::IPlanet::AddGeometry method:

// Loading our geometry:
RED::Object* geometry;
RC_TEST( iassetmgr->LoadGeometry( geometry, "../Resources/House.red", REDartProgressCB, NULL ) );

// Load our landscape:
RED::Object* atlas;
RED::Vector< RED::Object* > cameras;
RC_TEST( iassetmgr->LoadAtlas( atlas, cameras, "../Resources/atlas_Desert.red", REDartProgressCB, (void*)0x1 ) );
iearth->SetAtlas( atlas );

// We need two cameras here: one is looking at the other that'll be used to place the house:
if( cameras.size() < 2 )
  RC_TEST( RED_FAIL );

// Setup the geometry positioning matrix.
RED::Matrix matx;
const RED::Matrix& cmatx = cameras[ 1 ]->As< RPL::ICamera >()->GetMatrix();
RED::Vector3 cpos = cmatx.GetTranslation();
RC_TEST( iearth->GetTangentAxisSystem( matx, &( cpos._x ) ) );

// Apply some rotation:
RED::Matrix mrot;
mrot.RotationAxisMatrix( RED::Vector3::ZERO, RED::Vector3::ZAXIS, 1.57 );
matx *= mrot;

RC_TEST( iearth->AddGeometry( geometry, matx ) );

// Set the view using the first camera:
RC_TEST( iobserver->SetParentCelestialBody( earth ) );
RC_TEST( iobserver->SetFromCamera( cameras[ 0 ] ) );

The landscape was saved with several camera positions, providing us coordinate informations to position entities over it. We use the camera position to get a tangent space coordinate system to setup our geometry on a horizontal ground plane at that camera position. Geometries have an automatic ground landing mode that can be triggered using RPL::IGeometry::SetAutomaticSetOnGround. When activated a geometry's origin is automatically adjusted to the landscape altitude at the geometry position. That way, a model can be dropped anywhere and still keep a clean interaction with its surrounding environment. We can see the effect of this feature below:

Well, anywhere means anywhere...

Key graphic features

Let's review some details of the graphic features loaded with the imported geometry. For each feature, we have a dedicated tutorial that'll show how to build the corresponding graphical asset usable by ART:

Some graphical features of the loaded geometry.

In addition to the listed features above, we'd like to pinpoint the importance of the contextual integration of a loaded geometry: the geometry can be seen from the inside, looking through windows and see something that "makes sense" because it's in a complete 3D environment. Similarly, it can be looked at from the outside toward the inside and remain coherent, still because it's fully integrated in a 3D environment.

Day & night cycles work due to the dynamic caches and probes that have been setup and the calibration of the tonemapping provide the necessary adjustment to control the visual feedback we get from the scene.