*** empty log message ***

This commit is contained in:
David Rose 2001-01-11 23:10:48 +00:00
parent e78f3d06a9
commit 286a640ffe
24 changed files with 362 additions and 72 deletions

View File

@ -14,7 +14,7 @@
builderBucketNode.I builderBucketNode.cxx builderBucketNode.h \ builderBucketNode.I builderBucketNode.cxx builderBucketNode.h \
builderFuncs.I builderFuncs.h builderMisc.cxx builderMisc.h \ builderFuncs.I builderFuncs.h builderMisc.cxx builderMisc.h \
builderNormalVisualizer.I builderNormalVisualizer.cxx \ builderNormalVisualizer.I builderNormalVisualizer.cxx \
builderNormalVisualizer.h builderPrim.cxx builderPrim.h \ builderNormalVisualizer.h builderPrim.I builderPrim.cxx builderPrim.h \
builderPrimTempl.I builderPrimTempl.h builderProperties.cxx \ builderPrimTempl.I builderPrimTempl.h builderProperties.cxx \
builderProperties.h builderTypes.cxx builderTypes.h \ builderProperties.h builderTypes.cxx builderTypes.h \
builderVertex.I builderVertex.cxx builderVertex.h \ builderVertex.I builderVertex.cxx builderVertex.h \
@ -27,7 +27,8 @@
builder.I builder.h builderAttrib.I builderAttrib.h \ builder.I builder.h builderAttrib.I builderAttrib.h \
builderAttribTempl.I builderAttribTempl.h builderBucket.I \ builderAttribTempl.I builderAttribTempl.h builderBucket.I \
builderBucket.h builderBucketNode.I builderBucketNode.h \ builderBucket.h builderBucketNode.I builderBucketNode.h \
builderNormalVisualizer.I builderNormalVisualizer.h builderPrim.h \ builderNormalVisualizer.I builderNormalVisualizer.h \
builderPrim.I builderPrim.h \
builderPrimTempl.I builderPrimTempl.h builderProperties.h \ builderPrimTempl.I builderPrimTempl.h builderProperties.h \
builderTypes.h builderVertex.I builderVertex.h builderVertexTempl.I \ builderTypes.h builderVertex.I builderVertex.h builderVertexTempl.I \
builderVertexTempl.h config_builder.h builderVertexTempl.h config_builder.h

View File

@ -99,6 +99,18 @@ set_normal(const NType &n) {
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderAttribTempl::clear_normal
// Access: Public
// Description: Removes the attribute's normal.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
clear_normal() {
_flags &= ~BAF_normal;
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderAttribTempl::has_color // Function: BuilderAttribTempl::has_color
@ -140,6 +152,18 @@ set_color(const CType &c) {
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderAttribTempl::clear_color
// Access: Public
// Description: Removes the attribute's color.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
clear_color() {
_flags &= ~BAF_color;
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderAttribTempl::has_pixel_size // Function: BuilderAttribTempl::has_pixel_size
@ -181,6 +205,18 @@ set_pixel_size(float s) {
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderAttribTempl::clear_pixel_size
// Access: Public
// Description: Removes the attribute's pixel_size.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE BuilderAttribTempl<VT, NT, TT, CT> &BuilderAttribTempl<VT, NT, TT, CT>::
clear_pixel_size() {
_flags &= ~BAF_pixel_size;
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderAttribTempl::operator == // Function: BuilderAttribTempl::operator ==
// Access: Public // Access: Public

View File

@ -37,14 +37,17 @@ public:
INLINE bool has_normal() const; INLINE bool has_normal() const;
INLINE NType get_normal() const; INLINE NType get_normal() const;
INLINE BuilderAttribTempl &set_normal(const NType &n); INLINE BuilderAttribTempl &set_normal(const NType &n);
INLINE BuilderAttribTempl &clear_normal();
INLINE bool has_color() const; INLINE bool has_color() const;
INLINE CType get_color() const; INLINE CType get_color() const;
INLINE BuilderAttribTempl &set_color(const CType &c); INLINE BuilderAttribTempl &set_color(const CType &c);
INLINE BuilderAttribTempl &clear_color();
INLINE bool has_pixel_size() const; INLINE bool has_pixel_size() const;
INLINE float get_pixel_size() const; INLINE float get_pixel_size() const;
INLINE BuilderAttribTempl &set_pixel_size(float s); INLINE BuilderAttribTempl &set_pixel_size(float s);
INLINE BuilderAttribTempl &clear_pixel_size();
INLINE bool operator == (const BuilderAttribTempl &other) const; INLINE bool operator == (const BuilderAttribTempl &other) const;
INLINE bool operator != (const BuilderAttribTempl &other) const; INLINE bool operator != (const BuilderAttribTempl &other) const;

View File

@ -16,7 +16,8 @@
// Intended to be called from Builder::add_prim(). // Intended to be called from Builder::add_prim().
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool BuilderBucketNode:: bool BuilderBucketNode::
add_prim(const BuilderPrim &prim) { add_prim(BuilderPrim prim) {
prim.flatten_vertex_properties();
bool result = expand(prim, *_bucket, inserter(_prims, _prims.begin())); bool result = expand(prim, *_bucket, inserter(_prims, _prims.begin()));
return result; return result;
} }

View File

@ -33,7 +33,7 @@ public:
INLINE BuilderBucketNode(const BuilderBucketNode &copy); INLINE BuilderBucketNode(const BuilderBucketNode &copy);
INLINE void operator = (const BuilderBucketNode &copy); INLINE void operator = (const BuilderBucketNode &copy);
bool add_prim(const BuilderPrim &prim); bool add_prim(BuilderPrim prim);
bool add_prim(const BuilderPrimI &prim); bool add_prim(const BuilderPrimI &prim);
INLINE bool add_prim_nonindexed(const BuilderPrimI &prim); INLINE bool add_prim_nonindexed(const BuilderPrimI &prim);

View File

@ -6,6 +6,6 @@
INLINE BuilderNormalVisualizer:: INLINE BuilderNormalVisualizer::
BuilderNormalVisualizer(BuilderBucket &bucket) : _bucket(bucket) { BuilderNormalVisualizer(BuilderBucket &bucket) : _bucket(bucket) {
_num_vertices = 0; _num_vertices = 0;
_net_vertex._v.set(0.0, 0.0, 0.0); _net_vertex.set(0.0, 0.0, 0.0);
} }

View File

@ -3,22 +3,22 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifdef SUPPORT_SHOW_NORMALS
#include "builderNormalVisualizer.h" #include "builderNormalVisualizer.h"
#include "builderFuncs.h" #include "builderFuncs.h"
#ifdef SUPPORT_SHOW_NORMALS
void BuilderNormalVisualizer:: void BuilderNormalVisualizer::
add_prim(const BuilderPrim &prim) { add_prim(const BuilderPrim &prim) {
if (prim.has_overall_normal()) { if (prim.has_overall_normal()) {
// Average up all the vertex values to get the primitive center. // Average up all the vertex values to get the primitive center.
BuilderV net_vertex; BuilderV net_vertex;
net_vertex._v.set(0.0, 0.0, 0.0); net_vertex.set(0.0, 0.0, 0.0);
int num_verts = prim.get_num_verts(); int num_verts = prim.get_num_verts();
for (int i = 0; i < num_verts; i++) { for (int i = 0; i < num_verts; i++) {
net_vertex._v += prim.get_vertex(i).get_coord(); net_vertex += prim.get_vertex(i).get_coord();
} }
net_vertex._v /= num_verts; net_vertex /= num_verts;
add_normal(net_vertex, prim.get_normal()); add_normal(net_vertex, prim.get_normal());
} else if (prim.has_vertex_normal()) { } else if (prim.has_vertex_normal()) {
@ -50,7 +50,7 @@ show_normals(GeomNode *node) {
void BuilderNormalVisualizer:: void BuilderNormalVisualizer::
add_normal(const BuilderV &center, const BuilderN &normal) { add_normal(const BuilderV &center, const BuilderN &normal) {
BuilderV to = center._v + normal._v * _bucket._normal_scale; BuilderV to = center + normal * _bucket._normal_scale;
BuilderPrim line; BuilderPrim line;
line.set_type(BPT_line); line.set_type(BPT_line);

View File

@ -6,10 +6,12 @@
#ifndef BUILDERNORMALVISUALIZER_H #ifndef BUILDERNORMALVISUALIZER_H
#define BUILDERNORMALVISUALIZER_H #define BUILDERNORMALVISUALIZER_H
#ifdef SUPPORT_SHOW_NORMALS
#include <pandabase.h> #include <pandabase.h>
#include "mesherConfig.h"
#ifdef SUPPORT_SHOW_NORMALS
#include "builderBucket.h" #include "builderBucket.h"
#include "builderAttrib.h" #include "builderAttrib.h"
#include "builderVertex.h" #include "builderVertex.h"

View File

@ -0,0 +1,65 @@
// Filename: builderPrim.I
// Created by: drose (11Jan01)
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: BuilderPrim::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE BuilderPrim::
BuilderPrim() {
}
////////////////////////////////////////////////////////////////////
// Function: BuilderPrim::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE BuilderPrim::
BuilderPrim(const BuilderPrim &copy) :
BuilderPrimTempl<BuilderVertex>(copy) {
}
////////////////////////////////////////////////////////////////////
// Function: BuilderPrim::Copy Assignment
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE BuilderPrim &BuilderPrim::
operator = (const BuilderPrim &copy) {
BuilderPrimTempl<BuilderVertex>::operator = (copy);
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: BuilderPrimI::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE BuilderPrimI::
BuilderPrimI() {
}
////////////////////////////////////////////////////////////////////
// Function: BuilderPrimI::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE BuilderPrimI::
BuilderPrimI(const BuilderPrimI &copy) :
BuilderPrimTempl<BuilderVertexI>(copy) {
}
////////////////////////////////////////////////////////////////////
// Function: BuilderPrimI::Copy Assignment
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE BuilderPrimI &BuilderPrimI::
operator = (const BuilderPrimI &copy) {
BuilderPrimTempl<BuilderVertexI>::operator = (copy);
return *this;
}

View File

@ -70,6 +70,47 @@ nonindexed_copy(const BuilderPrimTempl<BuilderVertexI> &copy,
////////////////////////////////////////////////////////////////////
// Function: BuilderPrim::flatten_vertex_properties
// Access: Public
// Description: If all the vertices of the primitive have the same
// normal, color, etc., removes those properties from
// the vertices and assigns them to the primitive
// instead.
//
// This can provide better meshing by removing
// properties from otherwise shared vertices.
////////////////////////////////////////////////////////////////////
void BuilderPrim::
flatten_vertex_properties() {
int num_verts = get_num_verts();
int i;
if (has_overall_normal()) {
set_normal(get_normal());
for (i = 0; i < num_verts; i++) {
get_vertex(i).clear_normal();
}
}
if (has_overall_color()) {
set_color(get_color());
for (i = 0; i < num_verts; i++) {
get_vertex(i).clear_color();
}
}
if (has_overall_pixel_size()) {
set_pixel_size(get_pixel_size());
for (i = 0; i < num_verts; i++) {
get_vertex(i).clear_pixel_size();
}
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderPrim::fill_geom // Function: BuilderPrim::fill_geom
// Access: Public // Access: Public
@ -103,6 +144,21 @@ fill_geom(Geom *geom, const PTA_BuilderV &v_array,
} }
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderPrimI::flatten_vertex_properties
// Access: Public
// Description: If all the vertices of the primitive have the same
// normal, color, etc., removes those properties from
// the vertices and assigns them to the primitive
// instead.
//
// This can do nothing in the case of an indexed
// primitive, because we can't monkey with the vertex
// properties in this case.
////////////////////////////////////////////////////////////////////
void BuilderPrimI::
flatten_vertex_properties() {
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderPrimI::fill_geom // Function: BuilderPrimI::fill_geom

View File

@ -73,11 +73,15 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl<BuilderVe
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDAEGG BuilderPrim : public BuilderPrimTempl<BuilderVertex> { class EXPCL_PANDAEGG BuilderPrim : public BuilderPrimTempl<BuilderVertex> {
public: public:
BuilderPrim() {} INLINE BuilderPrim();
INLINE BuilderPrim(const BuilderPrim &copy);
INLINE BuilderPrim &operator = (const BuilderPrim &copy);
BuilderPrim &nonindexed_copy(const BuilderPrimTempl<BuilderVertexI> &copy, BuilderPrim &nonindexed_copy(const BuilderPrimTempl<BuilderVertexI> &copy,
const BuilderBucket &bucket); const BuilderBucket &bucket);
void flatten_vertex_properties();
static void fill_geom(Geom *geom, const PTA_BuilderV &v_array, static void fill_geom(Geom *geom, const PTA_BuilderV &v_array,
GeomBindType n_attr, const PTA_BuilderN &n_array, GeomBindType n_attr, const PTA_BuilderN &n_array,
GeomBindType t_attr, const PTA_BuilderTC &t_array, GeomBindType t_attr, const PTA_BuilderTC &t_array,
@ -97,7 +101,11 @@ public:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDAEGG BuilderPrimI : public BuilderPrimTempl<BuilderVertexI> { class EXPCL_PANDAEGG BuilderPrimI : public BuilderPrimTempl<BuilderVertexI> {
public: public:
BuilderPrimI() {} INLINE BuilderPrimI();
INLINE BuilderPrimI(const BuilderPrimI &copy);
INLINE BuilderPrimI &operator = (const BuilderPrimI &copy);
void flatten_vertex_properties();
static void fill_geom(Geom *geom, const PTA_ushort &v_array, static void fill_geom(Geom *geom, const PTA_ushort &v_array,
GeomBindType n_attr, PTA_ushort n_array, GeomBindType n_attr, PTA_ushort n_array,
@ -107,6 +115,8 @@ public:
int num_prims, int num_components, int num_verts); int num_prims, int num_components, int num_verts);
}; };
#include "builderPrim.I"
// Tell GCC that we'll take care of the instantiation explicitly here. // Tell GCC that we'll take care of the instantiation explicitly here.
#ifdef __GNUC__ #ifdef __GNUC__

View File

@ -138,6 +138,18 @@ set_normal(const NType &n) {
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::clear_normal
// Access: Public
// Description: Removes the vertex's normal.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
clear_normal() {
BuilderAttribTempl<VT, NT, TT, CT>::clear_normal();
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::has_texcoord // Function: BuilderVertexTempl::has_texcoord
@ -164,6 +176,18 @@ set_texcoord(const TType &t) {
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::clear_texcoord
// Access: Public
// Description: Removes the vertex's texcoord.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
clear_texcoord() {
_flags &= ~BAF_texcoord;
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::get_texcoord // Function: BuilderVertexTempl::get_texcoord
@ -196,6 +220,18 @@ set_color(const CType &c) {
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::clear_color
// Access: Public
// Description: Removes the vertex's color.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
clear_color() {
BuilderAttribTempl<VT, NT, TT, CT>::clear_color();
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::set_pixel_size // Function: BuilderVertexTempl::set_pixel_size
@ -213,6 +249,18 @@ set_pixel_size(float s) {
return *this; return *this;
} }
////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::clear_pixel_size
// Access: Public
// Description: Removes the vertex's pixel_size.
////////////////////////////////////////////////////////////////////
template <class VT, class NT, class TT, class CT>
INLINE BuilderVertexTempl<VT, NT, TT, CT> &BuilderVertexTempl<VT, NT, TT, CT>::
clear_pixel_size() {
BuilderAttribTempl<VT, NT, TT, CT>::clear_pixel_size();
return *this;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: BuilderVertexTempl::operator == // Function: BuilderVertexTempl::operator ==

View File

@ -42,14 +42,18 @@ public:
INLINE BuilderVertexTempl &set_coord(const VType &c); INLINE BuilderVertexTempl &set_coord(const VType &c);
INLINE BuilderVertexTempl &set_normal(const NType &c); INLINE BuilderVertexTempl &set_normal(const NType &c);
INLINE BuilderVertexTempl &clear_normal();
INLINE bool has_texcoord() const; INLINE bool has_texcoord() const;
INLINE TType get_texcoord() const; INLINE TType get_texcoord() const;
INLINE BuilderVertexTempl &set_texcoord(const TType &t); INLINE BuilderVertexTempl &set_texcoord(const TType &t);
INLINE BuilderVertexTempl &clear_texcoord();
INLINE BuilderVertexTempl &set_color(const CType &c); INLINE BuilderVertexTempl &set_color(const CType &c);
INLINE BuilderVertexTempl &clear_color();
INLINE BuilderVertexTempl &set_pixel_size(float s); INLINE BuilderVertexTempl &set_pixel_size(float s);
INLINE BuilderVertexTempl &clear_pixel_size();
bool operator == (const BuilderVertexTempl &other) const; bool operator == (const BuilderVertexTempl &other) const;
INLINE bool operator != (const BuilderVertexTempl &other) const; INLINE bool operator != (const BuilderVertexTempl &other) const;

View File

@ -16,4 +16,9 @@
// actually hurt, by bitching the heuristic). // actually hurt, by bitching the heuristic).
#define SUPPORT_FANS #define SUPPORT_FANS
// Define this to enable code to visualize the normals when generating
// primitives. This creates line segment geometry to show each normal
// as the primitives are created.
#define SUPPORT_SHOW_NORMALS
#endif #endif

View File

@ -109,3 +109,14 @@ INLINE float Fog::get_end(void) const {
INLINE float Fog::get_density(void) const { INLINE float Fog::get_density(void) const {
return _density; return _density;
} }
////////////////////////////////////////////////////////////////////
// Function: Fog::apply
// Access: Public
// Description: Called during rendering to enable fogging with the
// GSG.
////////////////////////////////////////////////////////////////////
INLINE void Fog::
apply(GraphicsStateGuardianBase *gsg) {
gsg->apply_fog(this);
}

View File

@ -36,10 +36,6 @@ PUBLISHED:
Fog(Mode mode = M_exponential, int hardware_bits = 8); Fog(Mode mode = M_exponential, int hardware_bits = 8);
~Fog(); ~Fog();
void apply(GraphicsStateGuardianBase *gsg) {
gsg->apply_fog(this);
}
INLINE Mode get_mode(void) const; INLINE Mode get_mode(void) const;
INLINE void set_mode(Mode mode); INLINE void set_mode(Mode mode);
@ -58,6 +54,9 @@ PUBLISHED:
void output(ostream &out) const; void output(ostream &out) const;
public:
INLINE void apply(GraphicsStateGuardianBase *gsg);
protected: protected:
void compute_density(void); void compute_density(void);

View File

@ -19,6 +19,7 @@
#include <ioPtaDatagramShort.h> #include <ioPtaDatagramShort.h>
#include <ioPtaDatagramInt.h> #include <ioPtaDatagramInt.h>
#include <ioPtaDatagramLinMath.h> #include <ioPtaDatagramLinMath.h>
#include <indent.h>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Static variables // Static variables
@ -412,8 +413,8 @@ config(void) {
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void Geom:: void Geom::
write(ostream &out) const { write(ostream &out, int indent_level) const {
out << *this << endl; indent(out, indent_level) << *this << endl;
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -582,7 +583,7 @@ template <class VecType>
static void static void
describe_attr(ostream &out, const Geom *geom, describe_attr(ostream &out, const Geom *geom,
GeomBindType bind, const PTA(VecType) &array, GeomBindType bind, const PTA(VecType) &array,
const char *pad) { bool newline, int indent_level) {
PTA_int lengths = geom->get_lengths(); PTA_int lengths = geom->get_lengths();
int num_prims = geom->get_num_prims(); int num_prims = geom->get_num_prims();
bool components = geom->uses_components(); bool components = geom->uses_components();
@ -590,7 +591,8 @@ describe_attr(ostream &out, const Geom *geom,
int i, j, vi; int i, j, vi;
switch (bind) { switch (bind) {
case G_PER_VERTEX: case G_PER_VERTEX:
out << "Per vertex:"; indent(out, indent_level)
<< "Per vertex:";
vi = 0; vi = 0;
int num_verts; int num_verts;
num_verts = geom->get_num_vertices_per_prim(); num_verts = geom->get_num_vertices_per_prim();
@ -598,11 +600,18 @@ describe_attr(ostream &out, const Geom *geom,
if (components) { if (components) {
num_verts = lengths[i]; num_verts = lengths[i];
} }
out << "\n [ "; out << "\n";
indent(out, indent_level) << "[ ";
if (num_verts > 0) { if (num_verts > 0) {
out << array[vi++]; out << array[vi++];
for (j = 1; j < num_verts; j++) { for (j = 1; j < num_verts; j++) {
out << pad << array[vi++]; if (newline) {
out << "\n";
indent(out, indent_level + 2);
} else {
out << " ";
}
out << array[vi++];
} }
} }
out << " ]"; out << " ]";
@ -611,17 +620,26 @@ describe_attr(ostream &out, const Geom *geom,
case G_PER_COMPONENT: case G_PER_COMPONENT:
if (!components) { if (!components) {
out << "Invalid per-component attribute specified!"; indent(out, indent_level)
<< "Invalid per-component attribute specified!";
} else { } else {
out << "Per component:"; indent(out, indent_level)
<< "Per component:";
vi = 0; vi = 0;
for (i = 0; i < num_prims; i++) { for (i = 0; i < num_prims; i++) {
num_verts = lengths[i] - geom->get_num_more_vertices_than_components(); num_verts = lengths[i] - geom->get_num_more_vertices_than_components();
out << "\n [ "; out << "\n";
indent(out, indent_level) << "[ ";
if (num_verts > 0) { if (num_verts > 0) {
out << array[vi++]; out << array[vi++];
for (j = 1; j < num_verts; j++) { for (j = 1; j < num_verts; j++) {
out << pad << array[vi++]; if (newline) {
out << "\n";
indent(out, indent_level + 2);
} else {
out << " ";
}
out << array[vi++];
} }
out << " ]"; out << " ]";
} }
@ -630,14 +648,29 @@ describe_attr(ostream &out, const Geom *geom,
break; break;
case G_PER_PRIM: case G_PER_PRIM:
out << "Per prim:"; indent(out, indent_level)
<< "Per prim:";
for (i = 0; i < num_prims; i++) { for (i = 0; i < num_prims; i++) {
out << pad << array[i]; if (newline) {
out << "\n";
indent(out, indent_level + 2);
} else {
out << " ";
}
out << array[i];
} }
break; break;
case G_OVERALL: case G_OVERALL:
out << "Overall:" << pad << array[0]; indent(out, indent_level)
<< "Overall:";
if (newline) {
out << "\n";
indent(out, indent_level + 2);
} else {
out << " ";
}
out << array[0];
case G_OFF: case G_OFF:
break; break;
@ -653,7 +686,7 @@ describe_attr(ostream &out, const Geom *geom,
// not too much detail. // not too much detail.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void Geom:: void Geom::
write_verbose(ostream &out) const { write_verbose(ostream &out, int indent_level) const {
GeomBindType bind_coords; GeomBindType bind_coords;
GeomBindType bind_normals; GeomBindType bind_normals;
GeomBindType bind_tcoords; GeomBindType bind_tcoords;
@ -674,51 +707,65 @@ write_verbose(ostream &out) const {
get_texcoords(g_tcoords, bind_tcoords, i_tcoords); get_texcoords(g_tcoords, bind_tcoords, i_tcoords);
get_colors(g_colors, bind_colors, i_colors); get_colors(g_colors, bind_colors, i_colors);
out << "\n" << get_type() << " contains " out << "\n";
indent(out, indent_level)
<< get_type() << " contains "
<< get_num_prims() << " primitives:\n"; << get_num_prims() << " primitives:\n";
if (bind_coords == G_OFF) { if (bind_coords == G_OFF) {
out << "No coords\n"; indent(out, indent_level)
<< "No coords\n";
} else if (i_coords!=(ushort*)0L) { } else if (i_coords!=(ushort*)0L) {
out << "Indexed coords = " << (void *)g_coords << ", length = " indent(out, indent_level)
<< "Indexed coords = " << (void *)g_coords << ", length = "
<< g_coords.size() << ":\n"; << g_coords.size() << ":\n";
describe_attr(out, this, bind_coords, i_coords, " "); describe_attr(out, this, bind_coords, i_coords, false, indent_level + 2);
} else { } else {
out << "Nonindexed coords:\n"; indent(out, indent_level)
describe_attr(out, this, bind_coords, g_coords, "\n "); << "Nonindexed coords:\n";
describe_attr(out, this, bind_coords, g_coords, true, indent_level + 2);
} }
if (bind_colors == G_OFF) { if (bind_colors == G_OFF) {
out << "No colors\n"; indent(out, indent_level)
<< "No colors\n";
} else if (i_colors!=(ushort*)0L) { } else if (i_colors!=(ushort*)0L) {
out << "Indexed colors = " << (void *)g_colors << ", length = " indent(out, indent_level)
<< "Indexed colors = " << (void *)g_colors << ", length = "
<< g_colors.size() << "\n"; << g_colors.size() << "\n";
describe_attr(out, this, bind_colors, i_colors, " "); describe_attr(out, this, bind_colors, i_colors, false, indent_level + 2);
} else { } else {
out << "Nonindexed colors:\n"; indent(out, indent_level)
describe_attr(out, this, bind_colors, g_colors, "\n "); << "Nonindexed colors:\n";
describe_attr(out, this, bind_colors, g_colors, true, indent_level + 2);
} }
if (bind_tcoords == G_OFF) { if (bind_tcoords == G_OFF) {
out << "No tcoords\n"; indent(out, indent_level)
<< "No tcoords\n";
} else if (i_tcoords!=(ushort*)0L) { } else if (i_tcoords!=(ushort*)0L) {
out << "Indexed tcoords = " << (void *)g_tcoords << ", length = " indent(out, indent_level)
<< "Indexed tcoords = " << (void *)g_tcoords << ", length = "
<< g_tcoords.size() << "\n"; << g_tcoords.size() << "\n";
describe_attr(out, this, bind_tcoords, i_tcoords, " "); describe_attr(out, this, bind_tcoords, i_tcoords, false, indent_level + 2);
} else { } else {
out << "Nonindexed tcoords:\n"; indent(out, indent_level)
describe_attr(out, this, bind_tcoords, g_tcoords, "\n "); << "Nonindexed tcoords:\n";
describe_attr(out, this, bind_tcoords, g_tcoords, true, indent_level + 2);
} }
if (bind_normals == G_OFF) { if (bind_normals == G_OFF) {
out << "No normals\n"; indent(out, indent_level)
<< "No normals\n";
} else if (i_normals!=(ushort*)0L) { } else if (i_normals!=(ushort*)0L) {
out << "Indexed normals = " << (void *)g_normals << ", length = " indent(out, indent_level)
<< "Indexed normals = " << (void *)g_normals << ", length = "
<< g_normals.size() << "\n"; << g_normals.size() << "\n";
describe_attr(out, this, bind_normals, i_normals, " "); describe_attr(out, this, bind_normals, i_normals, false, indent_level + 2);
} else { } else {
out << "Nonindexed normals:\n"; indent(out, indent_level)
describe_attr(out, this, bind_normals, g_normals, "\n "); << "Nonindexed normals:\n";
describe_attr(out, this, bind_normals, g_normals, true, indent_level + 2);
} }
} }

View File

@ -106,9 +106,9 @@ public:
virtual Geom *make_copy() const=0; virtual Geom *make_copy() const=0;
PUBLISHED: PUBLISHED:
void write(ostream &out) const; void write(ostream &out, int indent_level = 0) const;
virtual void output(ostream &out) const; virtual void output(ostream &out) const;
void write_verbose(ostream &out) const; void write_verbose(ostream &out, int indent_level) const;
public: public:
// From parent dDrawable // From parent dDrawable

View File

@ -31,7 +31,7 @@ set_on(Fog *fog) {
// is only valid to call this if is_on() has returned // is only valid to call this if is_on() has returned
// true. // true.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE PT(Fog) FogAttribute:: INLINE Fog *FogAttribute::
get_fog() const { get_fog() const {
nassertr(is_on(), NULL); nassertr(is_on(), NULL);
return _value; return _value;

View File

@ -20,8 +20,9 @@ public:
INLINE FogAttribute(); INLINE FogAttribute();
INLINE void set_on(Fog *fog); INLINE void set_on(Fog *fog);
INLINE PT(Fog) get_fog() const; INLINE Fog *get_fog() const;
public:
virtual TypeHandle get_handle() const; virtual TypeHandle get_handle() const;
virtual NodeAttribute *make_copy() const; virtual NodeAttribute *make_copy() const;
virtual NodeAttribute *make_initial() const; virtual NodeAttribute *make_initial() const;

View File

@ -57,7 +57,7 @@ set_on(Fog *fog) {
// It is only valid to call this if is_on() has returned // It is only valid to call this if is_on() has returned
// true. // true.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE PT(Fog) FogTransition:: INLINE Fog *FogTransition::
get_fog() const { get_fog() const {
nassertr(is_on(), NULL); nassertr(is_on(), NULL);
return _value; return _value;

View File

@ -24,8 +24,9 @@ public:
INLINE static FogTransition off(); INLINE static FogTransition off();
INLINE void set_on(Fog *fog); INLINE void set_on(Fog *fog);
INLINE PT(Fog) get_fog() const; INLINE Fog *get_fog() const;
public:
virtual NodeTransition *make_copy() const; virtual NodeTransition *make_copy() const;
virtual NodeAttribute *make_attrib() const; virtual NodeAttribute *make_attrib() const;

View File

@ -117,12 +117,12 @@ write(ostream &out, int indent_level) const {
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void GeomNode:: void GeomNode::
write_verbose(ostream &out) const { write_verbose(ostream &out, int indent_level) const {
Geoms::const_iterator gi; Geoms::const_iterator gi;
for (gi = _geoms.begin(); gi != _geoms.end(); ++gi) { for (gi = _geoms.begin(); gi != _geoms.end(); ++gi) {
dDrawable *drawable = (*gi); dDrawable *drawable = (*gi);
if (drawable->is_of_type(Geom::get_class_type())) { if (drawable->is_of_type(Geom::get_class_type())) {
DCAST(Geom, drawable)->write_verbose(out); DCAST(Geom, drawable)->write_verbose(out, indent_level);
} else { } else {
out << drawable->get_type() << "\n"; out << drawable->get_type() << "\n";
} }

View File

@ -38,7 +38,7 @@ public:
PUBLISHED: PUBLISHED:
void write(ostream &out, int indent_level = 0) const; void write(ostream &out, int indent_level = 0) const;
void write_verbose(ostream &out) const; void write_verbose(ostream &out, int indent_level) const;
public: public:
void draw(GraphicsStateGuardianBase *gsg); void draw(GraphicsStateGuardianBase *gsg);