*** empty log message ***

This commit is contained in:
David Rose 2000-12-13 01:21:49 +00:00
parent d2fafbffad
commit c514d3c9ac
3 changed files with 60 additions and 0 deletions

View File

@ -1118,6 +1118,10 @@ int framework_main(int argc, char *argv[]) {
// And start looping any animations we successfully bound.
anim_controls.loop_all(true);
// Now prepare all the textures with the GSG.
NodePath render_path(render);
render_path.prepare_scene(main_win->get_gsg());
}
// Set up keyboard events.

View File

@ -19,10 +19,34 @@
#include <boundingSphere.h>
#include <sceneGraphAnalyzer.h>
#include <sceneGraphReducer.h>
#include <nodeTransitionWrapper.h>
#include <nodeAttributeWrapper.h>
#include <nullLevelState.h>
#include <traverserVisitor.h>
#include <dftraverser.h>
#include <bamFile.h>
#include <list>
// This class is used in prepare_scene() to traverse the scene graph
// and register textures with the gsg.
class ScenePrepareVisitor : public TraverserVisitor<NodeTransitionWrapper, NullLevelState> {
public:
bool forward_arc(NodeRelation *, NodeTransitionWrapper &trans,
NodeAttributeWrapper &, NodeAttributeWrapper &,
NullLevelState &) {
TextureTransition *tt;
if (get_transition_into(tt, trans)) {
if (tt->is_on()) {
tt->get_texture()->prepare(_gsg);
}
}
return true;
}
GraphicsStateGuardianBase *_gsg;
};
////////////////////////////////////////////////////////////////////
// Function: NodePath::extend_by
// Access: Public
@ -2166,6 +2190,33 @@ get_hidden_ancestor() const {
return next.get_hidden_ancestor();
}
////////////////////////////////////////////////////////////////////
// Function: NodePath::prepare_scene
// Access: Public
// Description: Walks through the scene graph beginning at the bottom
// node, and does whatever initialization is required to
// render the scene properly with the indicated GSG. It
// is not strictly necessary to call this, since the GSG
// will initialize itself when the scene is rendered,
// but this may take some of the overhead away from that
// process.
////////////////////////////////////////////////////////////////////
void NodePath::
prepare_scene(GraphicsStateGuardianBase *gsg) {
nassertv(!is_empty());
// Use the ScenePrepareVisitor and fire off a traversal of the scene
// beginning at the bottom node. The ScenePrepareVisitor (defined
// above) will call prepare() on each texture it finds in the scene
// graph at this point at below.
ScenePrepareVisitor visitor;
visitor._gsg = gsg;
NodeAttributeWrapper initial(TextureTransition::get_class_type());
df_traverse(node(), visitor, initial, NullLevelState(),
RenderRelation::get_class_type());
}
////////////////////////////////////////////////////////////////////
// Function: NodePath::show_bounds
// Access: Public

View File

@ -24,6 +24,7 @@ class Texture;
class Fog;
class Camera;
class AllTransitionsWrapper;
class GraphicsStateGuardianBase;
//
// A NodePath is the fundamental unit of high-level interaction with
@ -419,6 +420,8 @@ PUBLISHED:
bool is_hidden() const;
NodePath get_hidden_ancestor() const;
void prepare_scene(GraphicsStateGuardianBase *gsg);
void show_bounds();
void hide_bounds();
PT(BoundingVolume) get_bounds() const;
@ -457,6 +460,8 @@ private:
const FindApproxLevel &level,
int max_matches, int num_levels_remaining) const;
void r_prepare_scene(Node *node);
void r_list_descendants(ostream &out, int indent_level) const;
void r_list_transitions(ostream &out, int indent_level) const;