I'm in the same boat than Mathieu :-P
But to me, the testEntity isn't that simple ;-) Indeed, it relies upon external scene/map resources and makes use of Spawner the exact purpose is obscure to me.
If I want to create a scene/map really from scratch the dtEntity way, i.e. simply by loading an OSG-supported mesh without relying any external scene/map resources, is the code below supposed to work (I've followed the advice you gave to Mathieu at the time):
void cOSG::InitSceneGraph(void)
{
// Init the main Root Node/Group
mRoot = new osg::Group; // mRoot is an osg::ref_ptr<osg::Group> member variable
// mViewer is an osgViewer::Viewer member variable
// em is a dtEntity::EntityManager member variable
dtEntityOSG::SetupSceneGraph(*mViewer, em, mRoot.get());
dtEntity::StartSystemMessage msg;
em.EnqueueMessage(msg);
// Create new entity
dtEntity::Entity* entity = NULL;
VERIFY(em.CreateEntity(entity));
if (!entity) return;
// Load the Model from the model name
dtEntityOSG::StaticMeshComponent* meshcomp = NULL;
VERIFY(entity->CreateComponent(meshcomp));
if (!meshcomp) return;
meshcomp->SetMesh(m_ModelName); // m_ModelName is a std::string member variable
// Create camera component
dtEntityOSG::CameraComponent* camcomp = NULL;
VERIFY(entity->CreateComponent(camcomp));
if (!camcomp) return;
camcomp->SetContextId(0);
// Create map component
dtEntity::MapComponent* mapcomp = NULL;
VERIFY(entity->CreateComponent(mapcomp));
// Add the model to the scene
dtEntity::MapSystem* mapsys = NULL;
VERIFY(em.GetEntitySystem(dtEntity::MapComponent::TYPE, mapsys));
if (!mapsys) return;
VERIFY(mapsys->AddToScene(entity->GetId()));
}
I'm getting _nothing_ (i.e. no background color, no stats handler, nothing) in my application window with the above code.
If I remove the camera component, the viewer seems to be initialized correctly as I can see the classical dark blue OSG background in my application window. And the stats handler reports one camera with one view, but no PrimitiveSet, so I can't see my loaded mesh. And yes, I've checked that it loads fine in the SetMesh call.
What am I missing? Except for the dtEntityOSG::DoScreenSetup that I had to "override" in order to use an existing window on Windows (rather than creating a new one), I'm having the equivalent code sequence to dtEntityOSG::InitOSGViewer, so am getting the default dtEntityOSG::CameraSystem, dtEntityOSG::LayerSystem, dtEntity::MapSystem and dtEntityOSG::LayerAttachPointSystem at load.
Alternatively, isn't there a simpler example than testEntity that shows how to simply load a supported OSG mesh/image file the dtEntity way (without using external scene/map resources to make it simple at first)?
Thanks,
Emeric