Dashboard > NeL > ... > NeLDocumentation > CachingTimeCriticalData
CachingTimeCriticalData
Added by Matt Raykowski, last edited by Matt Raykowski on Sep 21, 2007  (view change)
Labels: 
(None)


This is a writing in progress. This is how Project Talaus uses the shape bank to cache time critical data.

3DTask.h

NL3D::UDriver &driver() const
{
  nlassert(driver_instance);
  return *driver_instance;
}
NL3D::UShapeBank &shapeBank() const
{
  nlassert(shape_bank_instance);
  return *shape_bank_instance;
}

3DTask.cpp

if(driver_name == "DirectX")
{
  driver_instance = NL3D::UDriver::createDriver(icon, true);
}
else if (driver_name == "OpenGL")
{
  driver_instance = NL3D::UDriver::createDriver(icon, false);
}
else
{
  nlerror("%s is an unknown driver name please use DirectX or OpenGL.", driver_name);
}
shape_bank_instance = driver_instance->getShapeBank();

loadingtask somewhere

try
{
  progressBarAlter(0.95f, 0.96f, "Caching Shapes...");
  C3DTask::instance().shapeBank().addShapeCache("shapes");
  C3DTask::instance().shapeBank().setShapeCacheSize("shapes", 1048576);
  C3DTask::instance().shapeBank().preLoadShapesFromDirectory("shapes", "", "*.shape", true, smallprogress, true);
  nlinfo("Cached shapes sucessfully");
}
catch(...)
{
  nlerror("Could not cache shapes");
  CTalausTaskManager::instance().exit();
}

try
{
  progressBarAlter(0.96f, 0.97f, "Caching Skeletons...");
  C3DTask::instance().shapeBank().addShapeCache("skeletons");
  C3DTask::instance().shapeBank().setShapeCacheSize("skeletons", 1048576);
  C3DTask::instance().shapeBank().preLoadShapesFromDirectory("skeletons", "", "*.skel", true, smallprogress, true);
  nlinfo("Cached skeletons sucessfully");
}
catch(...)
{
  nlerror("Could not cache skeletons");
  CTalausTaskManager::instance().exit();
}

try
{
  progressBarAlter(0.97f, 0.98f, "Caching Particle Effects...");
  C3DTask::instance().shapeBank().addShapeCache("fx");
  C3DTask::instance().shapeBank().setShapeCacheSize("fx", 1048576);
  C3DTask::instance().shapeBank().preLoadShapesFromDirectory("fx", "", "*.ps", true, smallprogress, true);
  nlinfo("Cached particle effects sucessfully");
}
catch(...)
{
  nlerror("Could not cache particle effects");
  CTalausTaskManager::instance().exit();
}

Site running on a free Atlassian Confluence Open Source Project License granted to Open NeL (Open Nevrax Library, community branch of NeL). Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators