Panda3D

geomPoints.cxx

00001 // Filename: geomPoints.cxx
00002 // Created by:  drose (22Mar05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "geomPoints.h"
00016 #include "pStatTimer.h"
00017 #include "bamReader.h"
00018 #include "bamWriter.h"
00019 #include "graphicsStateGuardianBase.h"
00020 
00021 TypeHandle GeomPoints::_type_handle;
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: GeomPoints::Constructor
00025 //       Access: Published
00026 //  Description: 
00027 ////////////////////////////////////////////////////////////////////
00028 GeomPoints::
00029 GeomPoints(GeomPoints::UsageHint usage_hint) :
00030   GeomPrimitive(usage_hint)
00031 {
00032 }
00033  
00034 ////////////////////////////////////////////////////////////////////
00035 //     Function: GeomPoints::Copy Constructor
00036 //       Access: Published
00037 //  Description: 
00038 ////////////////////////////////////////////////////////////////////
00039 GeomPoints::
00040 GeomPoints(const GeomPoints &copy) :
00041   GeomPrimitive(copy)
00042 {
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: GeomPoints::Destructor
00047 //       Access: Published, Virtual
00048 //  Description: 
00049 ////////////////////////////////////////////////////////////////////
00050 GeomPoints::
00051 ~GeomPoints() {
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: GeomPoints::make_copy
00056 //       Access: Public, Virtual
00057 //  Description: 
00058 ////////////////////////////////////////////////////////////////////
00059 PT(GeomPrimitive) GeomPoints::
00060 make_copy() const {
00061   return new GeomPoints(*this);
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: GeomPoints::get_primitive_type
00066 //       Access: Public, Virtual
00067 //  Description: Returns the fundamental rendering type of this
00068 //               primitive: whether it is points, lines, or polygons.
00069 //
00070 //               This is used to set up the appropriate antialiasing
00071 //               settings when AntialiasAttrib::M_auto is in effect;
00072 //               it also implies the type of primitive that will be
00073 //               produced when decompose() is called.
00074 ////////////////////////////////////////////////////////////////////
00075 GeomPrimitive::PrimitiveType GeomPoints::
00076 get_primitive_type() const {
00077   return PT_points;
00078 }
00079 
00080 ////////////////////////////////////////////////////////////////////
00081 //     Function: GeomPoints::get_geom_rendering
00082 //       Access: Published, Virtual
00083 //  Description: Returns the set of GeomRendering bits that represent
00084 //               the rendering properties required to properly render
00085 //               this primitive.
00086 ////////////////////////////////////////////////////////////////////
00087 int GeomPoints::
00088 get_geom_rendering() const {
00089   // Fancy point attributes, if any, are based on whether the
00090   // appropriate columns are defined in the associated GeomVertexData;
00091   // these bits will be added by Geom::get_geom_rendering().
00092   if (is_indexed()) {
00093     return GR_point | GR_indexed_point;
00094   } else {
00095     return GR_point;
00096   }
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: GeomPoints::get_num_vertices_per_primitive
00101 //       Access: Public, Virtual
00102 //  Description: If the primitive type is a simple type in which all
00103 //               primitives have the same number of vertices, like
00104 //               points, returns the number of vertices per
00105 //               primitive.  If the primitive type is a more complex
00106 //               type in which different primitives might have
00107 //               different numbers of vertices, for instance a
00108 //               point strip, returns 0.
00109 ////////////////////////////////////////////////////////////////////
00110 int GeomPoints::
00111 get_num_vertices_per_primitive() const {
00112   return 1;
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: GeomPoints::get_min_num_vertices_per_primitive
00117 //       Access: Public, Virtual
00118 //  Description: Returns the minimum number of vertices that must be
00119 //               added before close_primitive() may legally be called.
00120 ////////////////////////////////////////////////////////////////////
00121 int GeomPoints::
00122 get_min_num_vertices_per_primitive() const {
00123   return 1;
00124 }
00125 
00126 ////////////////////////////////////////////////////////////////////
00127 //     Function: GeomPoints::draw
00128 //       Access: Public, Virtual
00129 //  Description: Calls the appropriate method on the GSG to draw the
00130 //               primitive.
00131 ////////////////////////////////////////////////////////////////////
00132 bool GeomPoints::
00133 draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader,
00134      bool force) const {
00135   return gsg->draw_points(reader, force);
00136 }
00137 
00138 ////////////////////////////////////////////////////////////////////
00139 //     Function: GeomPoints::register_with_read_factory
00140 //       Access: Public, Static
00141 //  Description: Tells the BamReader how to create objects of type
00142 //               Geom.
00143 ////////////////////////////////////////////////////////////////////
00144 void GeomPoints::
00145 register_with_read_factory() {
00146   BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
00147 }
00148 
00149 ////////////////////////////////////////////////////////////////////
00150 //     Function: GeomPoints::make_from_bam
00151 //       Access: Protected, Static
00152 //  Description: This function is called by the BamReader's factory
00153 //               when a new object of type Geom is encountered
00154 //               in the Bam file.  It should create the Geom
00155 //               and extract its information from the file.
00156 ////////////////////////////////////////////////////////////////////
00157 TypedWritable *GeomPoints::
00158 make_from_bam(const FactoryParams &params) {
00159   GeomPoints *object = new GeomPoints(UH_unspecified);
00160   DatagramIterator scan;
00161   BamReader *manager;
00162 
00163   parse_params(params, scan, manager);
00164   object->fillin(scan, manager);
00165 
00166   return object;
00167 }
 All Classes Functions Variables Enumerations