David Megginson wrote:
Yes - I apologise that this isn't documented - but it's vitallyPlib has callbacks for branches as well as leaves, but the branch callbacks are not documented, so I had to dig trough the plib source code (they're the same ones I used for the dynamic scenery objects). For a branch, you can set pre-traversal and post-traversal callbacks; if the pre-traversal callback return false, then the branch will be skipped. Here's a trivial (and not-so-efficient) example:static int cloaking_callback (ssgEntity * e, int mask) { return !fgGetBool("/controls/cloaking-device"); } ssgBranch * ship; // ... ship->setTravCallback(SSG_CALLBACK_PRETRAV, cloaking_callback); Now, the 'ship' branch will automatically vanish whenever the /controls/cloaking-device property is true and reappear when it's false.
important that you can do this -so it *should* be documented.
Bear in mind though that your callback is only called when the object's parent is inside the field of view. This is both an
advantage and a curse. It means that expensive callbacks are
only called when they are needed - but also that callbacks with
side-effects are a bit unpredictable!
For the dynamic objects, I use a much more complicated approach -- the branches are actually empty until ssg attempts to traverse them, then (at first traversal) FlightGear populates them with pseudo-randomly placed objects.
Wow!
That way, branches that never come into range or into the view direction are never populated. I also have a callback to depopulate the branches once they fall out of range. That turns out to be a fairly efficient way to add many objects (such as buildings or trees) to the scenery nearby without overwhelming the system.
Interesting. ---------------------------- Steve Baker ------------------------- HomeEmail: <[EMAIL PROTECTED]> WorkEmail: <[EMAIL PROTECTED]> HomePage : http://web2.airmail.net/sjbaker1 Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net _______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel