diff --git a/panda/src/pgraph/Sources.pp b/panda/src/pgraph/Sources.pp index b29f071624..95fe3c012d 100644 --- a/panda/src/pgraph/Sources.pp +++ b/panda/src/pgraph/Sources.pp @@ -67,6 +67,7 @@ loaderFileTypeRegistry.h \ loaderOptions.I loaderOptions.h \ lodNode.I lodNode.h \ + lodNodeType.h \ materialAttrib.I materialAttrib.h \ materialCollection.I materialCollection.h \ modelFlattenRequest.I modelFlattenRequest.h \ @@ -175,6 +176,7 @@ loaderFileTypeRegistry.cxx \ loaderOptions.cxx \ lodNode.cxx \ + lodNodeType.cxx \ materialAttrib.cxx \ materialCollection.cxx \ modelFlattenRequest.cxx \ @@ -278,6 +280,7 @@ loaderFileTypeRegistry.h \ loaderOptions.I loaderOptions.h \ lodNode.I lodNode.h \ + lodNodeType.h \ materialAttrib.I materialAttrib.h \ materialCollection.I materialCollection.h \ modelFlattenRequest.I modelFlattenRequest.h \ diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 5201fffa64..7dabe08def 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -328,6 +328,11 @@ ConfigVariableBool allow_incomplete_render "geometry is always paged in when needed, holding up the frame " "render if necessary.")); +ConfigVariableEnum default_lod_type +("default-lod-type", LNT_pop, + PRC_DESC("Set this to either 'pop' or 'fade' to determine the type of " + "LODNode that is created by LODNode::make_default_lod().")); + //////////////////////////////////////////////////////////////////// // Function: init_libpgraph // Description: Initializes the library. This must be called at diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 61b1e208b7..c628762806 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/panda/src/pgraph/config_pgraph.h @@ -26,6 +26,7 @@ #include "configVariableInt.h" #include "configVariableDouble.h" #include "configVariableList.h" +#include "lodNodeType.h" class DSearchPath; @@ -71,6 +72,8 @@ extern ConfigVariableList load_file_type; extern ConfigVariableString default_model_extension; extern EXPCL_PANDA ConfigVariableBool allow_incomplete_render; +extern ConfigVariableEnum default_lod_type; + extern EXPCL_PANDA void init_libpgraph(); #endif diff --git a/panda/src/pgraph/lodNode.cxx b/panda/src/pgraph/lodNode.cxx index 05675c5f2c..ad768279ab 100644 --- a/panda/src/pgraph/lodNode.cxx +++ b/panda/src/pgraph/lodNode.cxx @@ -17,6 +17,7 @@ //////////////////////////////////////////////////////////////////// #include "lodNode.h" +#include "fadeLodNode.h" #include "cullTraverserData.h" #include "cullTraverser.h" #include "config_pgraph.h" @@ -43,6 +44,28 @@ TypeHandle LODNode::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: LODNode::make_default_lod +// Access: Published, Static +// Description: Creates a new LODNode of the type specified by the +// default-lod-type config variable. +//////////////////////////////////////////////////////////////////// +PT(LODNode) LODNode:: +make_default_lod(const string &name) { + switch (default_lod_type) { + case LNT_pop: + return new LODNode(name); + + case LNT_fade: + return new FadeLODNode(name); + + default: + pgraph_cat.error() + << "Invalid LODNodeType value: " << (int)default_lod_type << "\n"; + return new LODNode(name); + } +} + //////////////////////////////////////////////////////////////////// // Function: LODNode::make_copy // Access: Public, Virtual @@ -763,6 +786,7 @@ write_datagram(BamWriter *manager, Datagram &dg) { TypedWritable *LODNode:: make_from_bam(const FactoryParams ¶ms) { LODNode *node = new LODNode(""); + DatagramIterator scan; BamReader *manager; diff --git a/panda/src/pgraph/lodNode.h b/panda/src/pgraph/lodNode.h index a49d7a736b..aa75fe37a1 100644 --- a/panda/src/pgraph/lodNode.h +++ b/panda/src/pgraph/lodNode.h @@ -36,6 +36,8 @@ class EXPCL_PANDA LODNode : public PandaNode { PUBLISHED: INLINE LODNode(const string &name); + static PT(LODNode) make_default_lod(const string &name); + protected: INLINE LODNode(const LODNode ©); public: diff --git a/panda/src/pgraph/lodNodeType.cxx b/panda/src/pgraph/lodNodeType.cxx new file mode 100644 index 0000000000..a285ba94e6 --- /dev/null +++ b/panda/src/pgraph/lodNodeType.cxx @@ -0,0 +1,52 @@ +// Filename: lodNodeType.cxx +// Created by: drose (08Jun07) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "lodNodeType.h" +#include "string_utils.h" + +ostream & +operator << (ostream &out, LODNodeType lnt) { + switch (lnt) { + case LNT_pop: + return out << "pop"; + + case LNT_fade: + return out << "fade"; + } + + pgraph_cat->error() + << "Invalid LODNodeType value: " << (int)lnt << "\n"; + nassertr(false, out); + return out; +} + +istream & +operator >> (istream &in, LODNodeType &lnt) { + string word; + in >> word; + if (cmp_nocase_uh(word, "pop") == 0) { + lnt = LNT_pop; + } else if (cmp_nocase_uh(word, "fade") == 0) { + lnt = LNT_fade; + } else { + pgraph_cat->error() + << "Invalid LODNodeType string: " << word << "\n"; + lnt = LNT_pop; + } + return in; +} diff --git a/panda/src/pgraph/lodNodeType.h b/panda/src/pgraph/lodNodeType.h new file mode 100644 index 0000000000..2ba8f2d203 --- /dev/null +++ b/panda/src/pgraph/lodNodeType.h @@ -0,0 +1,38 @@ +// Filename: lodNodeType.h +// Created by: drose (08Jun07) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef LODNODETYPE_H +#define LODNODETYPE_H + +#include "pandabase.h" + +BEGIN_PUBLISH + +enum LODNodeType { + LNT_pop, + LNT_fade, +}; + +END_PUBLISH + +EXPCL_PANDA ostream &operator << (ostream &out, LODNodeType lnt); +EXPCL_PANDA istream &operator >> (istream &in, LODNodeType &cs); + +#endif + + diff --git a/panda/src/pgraph/pgraph_composite3.cxx b/panda/src/pgraph/pgraph_composite3.cxx index 9b36d5ab1c..c713f1681a 100644 --- a/panda/src/pgraph/pgraph_composite3.cxx +++ b/panda/src/pgraph/pgraph_composite3.cxx @@ -10,6 +10,7 @@ #include "loaderFileTypeRegistry.cxx" #include "loaderOptions.cxx" #include "lodNode.cxx" +#include "lodNodeType.cxx" #include "materialAttrib.cxx" #include "materialCollection.cxx" #include "modelFlattenRequest.cxx"