I went through my code and commented out the line where I set the sector for the camera. The end result was that there was no error, but the screen is black. I'm going to try to post some screenies of what the end result is with that code in and with in commented out. Does this shed any light on the problem I'm having? I'll post my Initialize and LoadMap function below.
/////////////////////////////////////////////////////////////////////
//
// Initialize the g_environment application
//
/////////////////////////////////////////////////////////////////////
bool G_Environment::Initialize()
{
// Set up the Configuration Manager
if(!csInitializer::SetupConfigManager(object_reg,
"/config/g_environment.cfg",
"CrystalSpace.G_Environment"))
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"Can't initialize configuration manager!");
return false;
}
const char* cdType = "crystalspace.collisiondetection.opcode";
// Set up the plug-ins to be used
if(!csInitializer::RequestPlugins(object_reg,
CS_REQUEST_VFS,
CS_REQUEST_OPENGL3D,
CS_REQUEST_ENGINE,
CS_REQUEST_FONTSERVER,
CS_REQUEST_IMAGELOADER,
CS_REQUEST_LEVELLOADER,
CS_REQUEST_PLUGIN(cdType, iCollideSystem),
CS_REQUEST_REPORTER,
CS_REQUEST_REPORTERLISTENER,
CS_REQUEST_END))
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"Can't initialize plugins!");
return false;
}
// Get the pointer to the command line parser (shortcut way)
csRef<iCommandLineParser> clp(CS_QUERY_REGISTRY(object_reg,
iCommandLineParser));
const char* cfgVal;
if(!(cfgVal = clp->GetName()))
// Check for commandline help.
if(csCommandLineHelper::CheckHelp(object_reg))
{
csCommandLineHelper::Help(object_reg);
csInitializer::DestroyApplication(object_reg);
exit (0);
}
// Set up the event handler
if(!csInitializer::SetupEventHandler(object_reg, EventHandler))
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"Can't initialize event handler!");
return false;
}
// Open the main system. This will open all the previously
// loaded plug-ins.
if(!csInitializer::OpenApplication(object_reg))
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"Error opening system!");
return false;
}
// Get the pointer to engine plug-in
engine = CS_QUERY_REGISTRY(object_reg, iEngine);
if(engine == 0)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"No iEngine plugin!");
return false;
}
// Get the pointer to the map loader plug-in
loader = CS_QUERY_REGISTRY(object_reg, iLoader);
if(loader == 0)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"No iLoader plugin!");
return false;
}
// Get the pointer to the 3D renderer plug-in
g3d = CS_QUERY_REGISTRY(object_reg, iGraphics3D);
if(g3d == 0)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"No iGraphics3D plugin!");
return false;
}
// Get the pointer to the Collision detection system
cdsys = CS_QUERY_REGISTRY(object_reg, iCollideSystem);
if(cdsys == 0)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"No iCollideSystem plugin!");
return false;
}
// Get the pointer to the 3D renderer plug-in
vc = CS_QUERY_REGISTRY(object_reg, iVirtualClock);
if(vc == 0)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"No iVirtualClock plugin!");
return false;
}
// Get the pointer to the command line parser
//if(clp == 0)
//{
// csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
// "crystalspace.application.g_environment",
// "No iCommandLineParser plugin!");
// return false;
//}
// Initialize the view to the environment and set the size of
// the view
view = csPtr<iView> (new csView(engine, g3d));
iGraphics2D* g2d = g3d->GetDriver2D();
view->SetRectangle(0, 0, g2d->GetWidth(), g2d->GetHeight() / 2);
// Load the environment level
if(!LoadMap())
{
return false;
}
// Pass necessary info. to the player.
player.SetCamera(view->GetCamera());
player.SetCollideSystem(cdsys);
player.SetEngine(engine);
player.SetView(view);
player.SetDesiredLocation(view->GetCamera()->GetTransform().GetOrigin());
player.SetDesiredLookAt(csVector3(0, 0, 1));
player.SetStartLocation(view->GetCamera()->GetTransform().GetOrigin());
player.SetStartLookAt(csVector3(0, 0, 1));
// Load a SpriteCal3D Mesh Object
csRef<iVFS> VFS(CS_QUERY_REGISTRY(object_reg, iVFS));
VFS->ChDir("/this/");
csRef<iMeshFactoryWrapper>
imeshfact(loader->LoadMeshObjectFactory("/this/test.cal3d"));
if(imeshfact == 0)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"Error loading mesh object factory!");
return false;
}
csRef<iMeshWrapper>
sprite = engine->CreateMeshWrapper(imeshfact,
"varge_wb1_gunner_pod",
engine->GetSectors()->FindByName("room"),
csVector3(0, 2, 5));
// Animate the model
csRef<iSpriteCal3DFactoryState> factState
(SCF_QUERY_INTERFACE(imeshfact->GetMeshObjectFactory(),
iSpriteCal3DFactoryState));
csRef<iSpriteCal3DState> cal3dState
(SCF_QUERY_INTERFACE(sprite->GetMeshObject(),
iSpriteCal3DState));
//cal3dState->SetAnimCycle("standing_idle", 1.0f);
cal3dState->SetAnimCycle("left_engine_rot_45deg", 1.0f);
cal3dState->SetAnimationTime(0.05f);
cal3dState->SetAnimCycle("dual_cannon_rotation_45deg_down", 1.0f);
// Initialize the collision detection
if(!InitCollisionDetection())
return false;
return true;
}
/////////////////////////////////////////////////////////////////////
//
// Load the map
//
/////////////////////////////////////////////////////////////////////
bool G_Environment::LoadMap()
{
// set VFS current directory to the level we want to load
csRef<iVFS> VFS(csQueryRegistry<iVFS>(object_reg));
VFS->ChDir("/lev/room01");
// load the level file which is called 'world'
if(!loader->LoadMapFile("world"))
{
// Create the default room for this application
if(!g_environment->CreateDefaultRoom())
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"Error generating environment!");
return false;
}
}
engine->Prepare();
// Find the starting position in this level
csVector3 pos(0.0f, 0.0f, 0.0f);
if(engine->GetCameraPositions()->GetCount() > 0)
{
// There is a valid starting position defined in the level file
iCameraPosition* campos = engine->GetCameraPositions()->Get(0);
room = engine->GetSectors()->FindByName(campos->GetSector());
pos = campos->GetPosition();
} else {
// Didn't find a valid starting position. The default
// room and start position is used
room = engine->GetSectors()->FindByName("room");
pos.Set(csVector3(0.0f, 3.0f, -3.0f));
}
if(!room)
{
csReport(object_reg, CS_REPORTER_SEVERITY_ERROR,
"crystalspace.application.g_environment",
"Can't find a valid starting position!");
return false;
}
// This is the offending line
view->GetCamera()->SetSector(room);
view->GetCamera()->GetTransform().SetOrigin(pos);
return true;
}