Game Development Community

LOD Callbacks

by Thomas Bang · in Torque Game Engine · 10/02/2009 (8:59 am) · 3 replies

Is it possible to execute a callback when the LOD-Stage of a model/interior has changed?

#1
10/02/2009 (11:52 am)
In short, yes. But I don't know how much work it would take. You've also got to keep in mind that LOD is done on clients, so your callback would be exclusively client-side (I guess you already know that). Have a look at the shape instance code - I believe I glanced at it a while ago, and it wasn't too indecipherable (I may be remembering something else, though ;P).
#2
10/03/2009 (6:52 am)
I did not found where the LODs are set. But i guess i can do it in a different way. It is possible to execute a callback when a special frame is rendered. So i can get the current LOD over animation trigger.
It's not the best solution but it should work.
#3
10/03/2009 (12:41 pm)
For TS models, you should find
void TSShapeInstance::setCurrentDetail
in ts/tsShapeInstance.cc

near the end of the function before changing mCurrentDetailLevel do
// If the detail level changes...
   if (dl != mCurrentDetailLevel)
   {
      // callback
   }

   mCurrentDetailLevel = dl;

As for Interiors, they do not seem to keep track of the last detail level used; they just select a detail level every on every render loop. So you'd want to add an mCurrentDetailLevel to InteriorInstance. Then find
void InteriorInstance::renderObject
in interior/interiorInstance.cc. Then after the line
InteriorRenderImage* interiorImage = static_cast<InteriorRenderImage*>(sceneImage);
add
if (mCurrentDetailLevel != interiorImage->mDetailLevel)
   {
      // do callback
   }
   mCurrentDetailLevel = interiorImage->mDetailLevel;