Panda3D
geomPoints.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file geomPoints.cxx
10  * @author drose
11  * @date 2005-03-22
12  */
13 
14 #include "geomPoints.h"
15 #include "pStatTimer.h"
16 #include "bamReader.h"
17 #include "bamWriter.h"
19 
20 TypeHandle GeomPoints::_type_handle;
21 
22 /**
23  *
24  */
25 GeomPoints::
26 GeomPoints(GeomPoints::UsageHint usage_hint) :
27  GeomPrimitive(usage_hint)
28 {
29 }
30 
31 /**
32  *
33  */
34 GeomPoints::
35 GeomPoints(const GeomPoints &copy) :
36  GeomPrimitive(copy)
37 {
38 }
39 
40 /**
41  *
42  */
43 GeomPoints::
44 ~GeomPoints() {
45 }
46 
47 /**
48  *
49  */
50 PT(GeomPrimitive) GeomPoints::
51 make_copy() const {
52  return new GeomPoints(*this);
53 }
54 
55 /**
56  * Returns the fundamental rendering type of this primitive: whether it is
57  * points, lines, or polygons.
58  *
59  * This is used to set up the appropriate antialiasing settings when
60  * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive
61  * that will be produced when decompose() is called.
62  */
63 GeomPrimitive::PrimitiveType GeomPoints::
64 get_primitive_type() const {
65  return PT_points;
66 }
67 
68 /**
69  * Returns the set of GeomRendering bits that represent the rendering
70  * properties required to properly render this primitive.
71  */
72 int GeomPoints::
73 get_geom_rendering() const {
74  // Fancy point attributes, if any, are based on whether the appropriate
75  // columns are defined in the associated GeomVertexData; these bits will be
76  // added by Geom::get_geom_rendering().
77  if (is_indexed()) {
78  return GR_point | GR_indexed_point;
79  } else {
80  return GR_point;
81  }
82 }
83 
84 /**
85  * If the primitive type is a simple type in which all primitives have the
86  * same number of vertices, like points, returns the number of vertices per
87  * primitive. If the primitive type is a more complex type in which different
88  * primitives might have different numbers of vertices, for instance a point
89  * strip, returns 0.
90  */
91 int GeomPoints::
92 get_num_vertices_per_primitive() const {
93  return 1;
94 }
95 
96 /**
97  * Returns the minimum number of vertices that must be added before
98  * close_primitive() may legally be called.
99  */
100 int GeomPoints::
101 get_min_num_vertices_per_primitive() const {
102  return 1;
103 }
104 
105 /**
106  * Calls the appropriate method on the GSG to draw the primitive.
107  */
108 bool GeomPoints::
110  bool force) const {
111  return gsg->draw_points(reader, force);
112 }
113 
114 /**
115  * Tells the BamReader how to create objects of type Geom.
116  */
117 void GeomPoints::
118 register_with_read_factory() {
119  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
120 }
121 
122 /**
123  * This function is called by the BamReader's factory when a new object of
124  * type Geom is encountered in the Bam file. It should create the Geom and
125  * extract its information from the file.
126  */
127 TypedWritable *GeomPoints::
128 make_from_bam(const FactoryParams &params) {
129  GeomPoints *object = new GeomPoints(UH_unspecified);
130  DatagramIterator scan;
131  BamReader *manager;
132 
133  parse_params(params, scan, manager);
134  object->fillin(scan, manager);
135 
136  return object;
137 }
Defines a series of disconnected points.
Definition: geomPoints.h:23
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:56
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams &params, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Definition: bamReader.I:275
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Definition: factory.I:73
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition: bamReader.I:177
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
Definition: geomPrimitive.I:86
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT(GeomPrimitive) GeomPoints
Returns the fundamental rendering type of this primitive: whether it is points, lines,...
Definition: geomPoints.cxx:50