vtlib: Importing 3D Models

Currently Model Functionality

The method vtLoadModel uses OSG to import 3D geometry from a file, and returns it as a node which can be added to the scene, and optionally placed on the terrain.

The most commonly useful formats include the following, depending on which extensions DLLs have been built with the library:

These five formats have been tested and known to work reasonably well, within the limitations of each format.  OSG supports a long list of less-common formats as well.

Another option is to export directly to an OSG-specific format:

If you are using Blender, see How to use Blender with OSG/VTP.

Working with loaded models

First, you will almost certainly want to add your model to the scene graph, by using addChild to add it to some existing node:

vtGroup *root = vtGetScene().GetRoot();

If you are writing your code in a vtTerrain subclass method (your own terrain), you can alternately use vtTerrain::AddNode to add the node to the terrain's scene graph:

void MyTerrain::CreateCustomCulture()
    NodePtr node = vtLoadModel(...);

To move/scale your model, you can attach it to a transform node:

vtTransform *trans = new vtTransform;

To control placement of your model on the terrain, you can use the vtTerrain methods provided:

void vtTerrain::PlantModel(vtTransform *model);
void vtTerrain::PlantModelAtPoint(vtTransform *model, const DPoint2 &pos);

The PlantModel method moves your object vertically such that it lies on the terrain surface, PlantModelAtPoint first places the object a specific earth coordinate before planting it down.

Long-term issues with the Art Path into vtlib


There is a 3D modeling package that is popular, and as Free as the VTP - Blender
Tested this possibility in August 2006: Blender to OSG