From f13329602f9a0ff963196871460b3043d73095b9 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 10 Nov 2000 04:47:22 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/egg2sg/eggLoader.cxx | 14 ++++++- panda/src/sgraph/Sources.pp | 7 +++- panda/src/sgraph/config_sgraph.cxx | 6 +++ panda/src/sgraph/modelNode.I | 36 ++++++++++++++++++ panda/src/sgraph/modelNode.cxx | 54 ++++++++++++++++++++++++++ panda/src/sgraph/modelNode.h | 61 ++++++++++++++++++++++++++++++ panda/src/sgraph/modelRoot.I | 36 ++++++++++++++++++ panda/src/sgraph/modelRoot.cxx | 50 ++++++++++++++++++++++++ panda/src/sgraph/modelRoot.h | 58 ++++++++++++++++++++++++++++ 9 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 panda/src/sgraph/modelNode.I create mode 100644 panda/src/sgraph/modelNode.cxx create mode 100644 panda/src/sgraph/modelNode.h create mode 100644 panda/src/sgraph/modelRoot.I create mode 100644 panda/src/sgraph/modelRoot.cxx create mode 100644 panda/src/sgraph/modelRoot.h diff --git a/panda/src/egg2sg/eggLoader.cxx b/panda/src/egg2sg/eggLoader.cxx index 3a6caf3624..19439fac35 100644 --- a/panda/src/egg2sg/eggLoader.cxx +++ b/panda/src/egg2sg/eggLoader.cxx @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -121,7 +123,7 @@ build_graph() { load_textures(); // Now build up the scene graph. - _root = new NamedNode; + _root = new ModelRoot; _root->set_name(_data.get_egg_filename().get_basename()); make_node(&_data, _root); _builder.build(); @@ -1158,6 +1160,16 @@ make_node(EggGroup *egg_group, NamedNode *parent) { make_node(*ci, node); } + } else if (egg_group->get_model_flag()) { + // A model flag; create a model node. + node = new ModelNode; + node->set_name(egg_group->get_name()); + + EggGroup::const_iterator ci; + for (ci = egg_group->begin(); ci != egg_group->end(); ++ci) { + make_node(*ci, node); + } + } else { // A normal group; just create a normal node, and traverse. node = new NamedNode; diff --git a/panda/src/sgraph/Sources.pp b/panda/src/sgraph/Sources.pp index 2eef807050..548e636cb7 100644 --- a/panda/src/sgraph/Sources.pp +++ b/panda/src/sgraph/Sources.pp @@ -8,13 +8,16 @@ #define SOURCES \ camera.I camera.cxx camera.h config_sgraph.cxx config_sgraph.h \ geomNode.I geomNode.cxx geomNode.h geomTransformer.I \ - geomTransformer.cxx geomTransformer.h planeNode.I planeNode.cxx \ + geomTransformer.cxx geomTransformer.h modelNode.I modelNode.cxx \ + modelNode.h modelRoot.I modelRoot.cxx modelRoot.h \ + planeNode.I planeNode.cxx \ planeNode.h projectionNode.I projectionNode.cxx projectionNode.h \ renderTraverser.I renderTraverser.cxx renderTraverser.h #define INSTALL_HEADERS \ camera.I camera.h geomNode.I geomNode.h geomTransformer.I \ - geomTransformer.h planeNode.I planeNode.h projectionNode.I \ + geomTransformer.h modelNode.I modelNode.h modelRoot.I \ + modelRoot.h planeNode.I planeNode.h projectionNode.I \ projectionNode.h renderTraverser.I renderTraverser.h #define IGATESCAN all diff --git a/panda/src/sgraph/config_sgraph.cxx b/panda/src/sgraph/config_sgraph.cxx index f561b6d52e..d81d30c6f8 100644 --- a/panda/src/sgraph/config_sgraph.cxx +++ b/panda/src/sgraph/config_sgraph.cxx @@ -8,6 +8,8 @@ #include "geomNode.h" #include "camera.h" #include "planeNode.h" +#include "modelNode.h" +#include "modelRoot.h" #include "projectionNode.h" #include @@ -20,9 +22,13 @@ ConfigureFn(config_sgraph) { GeomNode::init_type(); Camera::init_type(); PlaneNode::init_type(); + ModelNode::init_type(); + ModelRoot::init_type(); ProjectionNode::init_type(); //Registration of writeable object's creation //functions with BamReader's factory GeomNode::register_with_read_factory(); + ModelNode::register_with_read_factory(); + ModelRoot::register_with_read_factory(); } diff --git a/panda/src/sgraph/modelNode.I b/panda/src/sgraph/modelNode.I new file mode 100644 index 0000000000..1cedb66e6b --- /dev/null +++ b/panda/src/sgraph/modelNode.I @@ -0,0 +1,36 @@ +// Filename: modelNode.I +// Created by: drose (09Nov00) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: ModelNode::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ModelNode:: +ModelNode(const string &name) : + NamedNode(name) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelNode::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ModelNode:: +ModelNode(const ModelNode ©) : + NamedNode(copy) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelNode::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void ModelNode:: +operator = (const ModelNode ©) { + NamedNode::operator = (copy); +} diff --git a/panda/src/sgraph/modelNode.cxx b/panda/src/sgraph/modelNode.cxx new file mode 100644 index 0000000000..7d26499a75 --- /dev/null +++ b/panda/src/sgraph/modelNode.cxx @@ -0,0 +1,54 @@ +// Filename: modelNode.cxx +// Created by: drose (09Nov00) +// +//////////////////////////////////////////////////////////////////// + +#include "modelNode.h" + +#include +#include +#include + +TypeHandle ModelNode::_type_handle; + + +//////////////////////////////////////////////////////////////////// +// Function: ModelNode::make_copy +// Access: Public, Virtual +// Description: Returns a newly-allocated Node that is a shallow copy +// of this one. It will be a different Node pointer, +// but its internal data may or may not be shared with +// that of the original Node. +//////////////////////////////////////////////////////////////////// +Node *ModelNode:: +make_copy() const { + return new ModelNode(*this); +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelNode::register_with_factory +// Access: Public, Static +// Description: Factory method to generate a node object +//////////////////////////////////////////////////////////////////// +void ModelNode:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_ModelNode); +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelNode::make_ModelNode +// Access: Protected, Static +// Description: Factory method to generate a node object +//////////////////////////////////////////////////////////////////// +TypedWriteable* ModelNode:: +make_ModelNode(const FactoryParams ¶ms) { + ModelNode *me = new ModelNode; + BamReader *manager; + Datagram packet; + + parse_params(params, manager, packet); + DatagramIterator scan(packet); + + me->fillin(scan, manager); + return me; +} diff --git a/panda/src/sgraph/modelNode.h b/panda/src/sgraph/modelNode.h new file mode 100644 index 0000000000..50c5eda909 --- /dev/null +++ b/panda/src/sgraph/modelNode.h @@ -0,0 +1,61 @@ +// Filename: modelNode.h +// Created by: drose (09Nov00) +// +//////////////////////////////////////////////////////////////////// + +#ifndef MODELNODE_H +#define MODELNODE_H + +#include + +#include + +//////////////////////////////////////////////////////////////////// +// Class : ModelNode +// Description : This node is placed at key points within the scene +// graph to indicate the roots of "models": subtrees +// that are conceptually to be treated as a single unit, +// like a car or a room, for instance. It doesn't +// affect rendering or any other operations; it's +// primarily useful as a high-level model indication. +// +// ModelNodes are created in response to a { 1 } +// flag within an egg file. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA ModelNode : public NamedNode { +public: + INLINE ModelNode(const string &name = ""); + INLINE ModelNode(const ModelNode ©); + INLINE void operator = (const ModelNode ©); + + virtual Node *make_copy() const; + +public: + static void register_with_read_factory(void); + +protected: + static TypedWriteable *make_ModelNode(const FactoryParams ¶ms); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + NamedNode::init_type(); + register_type(_type_handle, "ModelNode", + NamedNode::get_class_type()); + } + virtual TypeHandle get_type(void) const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "modelNode.I" + +#endif + + diff --git a/panda/src/sgraph/modelRoot.I b/panda/src/sgraph/modelRoot.I new file mode 100644 index 0000000000..e947e8b90e --- /dev/null +++ b/panda/src/sgraph/modelRoot.I @@ -0,0 +1,36 @@ +// Filename: modelRoot.I +// Created by: drose (09Nov00) +// +//////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////// +// Function: ModelRoot::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ModelRoot:: +ModelRoot(const string &name) : + ModelNode(name) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelRoot::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE ModelRoot:: +ModelRoot(const ModelRoot ©) : + ModelNode(copy) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelRoot::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void ModelRoot:: +operator = (const ModelRoot ©) { + ModelNode::operator = (copy); +} diff --git a/panda/src/sgraph/modelRoot.cxx b/panda/src/sgraph/modelRoot.cxx new file mode 100644 index 0000000000..2cbf28a08e --- /dev/null +++ b/panda/src/sgraph/modelRoot.cxx @@ -0,0 +1,50 @@ +// Filename: modelRoot.cxx +// Created by: drose (09Nov00) +// +//////////////////////////////////////////////////////////////////// + +#include "modelRoot.h" + +TypeHandle ModelRoot::_type_handle; + + +//////////////////////////////////////////////////////////////////// +// Function: ModelRoot::make_copy +// Access: Public, Virtual +// Description: Returns a newly-allocated Node that is a shallow copy +// of this one. It will be a different Node pointer, +// but its internal data may or may not be shared with +// that of the original Node. +//////////////////////////////////////////////////////////////////// +Node *ModelRoot:: +make_copy() const { + return new ModelRoot(*this); +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelRoot::register_with_factory +// Access: Public, Static +// Description: Factory method to generate a node object +//////////////////////////////////////////////////////////////////// +void ModelRoot:: +register_with_read_factory() { + BamReader::get_factory()->register_factory(get_class_type(), make_ModelRoot); +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelRoot::make_ModelRoot +// Access: Protected, Static +// Description: Factory method to generate a node object +//////////////////////////////////////////////////////////////////// +TypedWriteable* ModelRoot:: +make_ModelRoot(const FactoryParams ¶ms) { + ModelRoot *me = new ModelRoot; + BamReader *manager; + Datagram packet; + + parse_params(params, manager, packet); + DatagramIterator scan(packet); + + me->fillin(scan, manager); + return me; +} diff --git a/panda/src/sgraph/modelRoot.h b/panda/src/sgraph/modelRoot.h new file mode 100644 index 0000000000..ca31a5b45c --- /dev/null +++ b/panda/src/sgraph/modelRoot.h @@ -0,0 +1,58 @@ +// Filename: modelRoot.h +// Created by: drose (09Nov00) +// +//////////////////////////////////////////////////////////////////// + +#ifndef MODELROOT_H +#define MODELROOT_H + +#include + +#include "modelNode.h" + +//////////////////////////////////////////////////////////////////// +// Class : ModelRoot +// Description : A node of this type is created automatically at the +// root of each model file that is loaded. It may +// eventually contain some information about the +// contents of the model; at the moment, it contains no +// special information, but can be used as a flag to +// indicate the presence of a loaded model file. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA ModelRoot : public ModelNode { +public: + INLINE ModelRoot(const string &name = ""); + INLINE ModelRoot(const ModelRoot ©); + INLINE void operator = (const ModelRoot ©); + + virtual Node *make_copy() const; + +public: + static void register_with_read_factory(void); + +protected: + static TypedWriteable *make_ModelRoot(const FactoryParams ¶ms); + +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + ModelNode::init_type(); + register_type(_type_handle, "ModelRoot", + ModelNode::get_class_type()); + } + virtual TypeHandle get_type(void) const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "modelRoot.I" + +#endif + +