David Rose 18 роки тому
батько
коміт
8ce0e1070d

+ 3 - 0
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 \

+ 5 - 0
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<LODNodeType> 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

+ 3 - 0
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<LODNodeType> default_lod_type;
+
 extern EXPCL_PANDA void init_libpgraph();
 
 #endif

+ 24 - 0
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 &params) {
   LODNode *node = new LODNode("");
+  
   DatagramIterator scan;
   BamReader *manager;
 

+ 2 - 0
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 &copy);
 public:

+ 52 - 0
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
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#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;
+}

+ 38 - 0
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
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#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
+
+

+ 1 - 0
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"