Panda3D
geomLinesAdjacency.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 geomLinesAdjacency.cxx
10  * @author rdb
11  * @date 2018-03-01
12  */
13 
14 #include "geomLinesAdjacency.h"
15 #include "pStatTimer.h"
16 #include "bamReader.h"
17 #include "bamWriter.h"
19 #include "geomVertexReader.h"
20 #include "geomVertexWriter.h"
21 
22 TypeHandle GeomLinesAdjacency::_type_handle;
23 
24 /**
25  *
26  */
27 GeomLinesAdjacency::
28 GeomLinesAdjacency(GeomEnums::UsageHint usage_hint) :
29  GeomPrimitive(usage_hint)
30 {
31 }
32 
33 /**
34  *
35  */
36 GeomLinesAdjacency::
37 GeomLinesAdjacency(const GeomLinesAdjacency &copy) :
38  GeomPrimitive(copy)
39 {
40 }
41 
42 /**
43  *
44  */
45 GeomLinesAdjacency::
46 ~GeomLinesAdjacency() {
47 }
48 
49 /**
50  *
51  */
52 PT(GeomPrimitive) GeomLinesAdjacency::
53 make_copy() const {
54  return new GeomLinesAdjacency(*this);
55 }
56 
57 /**
58  * Returns the fundamental rendering type of this primitive: whether it is
59  * points, lines, or polygons.
60  *
61  * This is used to set up the appropriate antialiasing settings when
62  * AntialiasAttrib::M_auto is in effect; it also implies the type of primitive
63  * that will be produced when decompose() is called.
64  */
65 GeomPrimitive::PrimitiveType GeomLinesAdjacency::
66 get_primitive_type() const {
67  return PT_lines;
68 }
69 
70 /**
71  * Returns the set of GeomRendering bits that represent the rendering
72  * properties required to properly render this primitive.
73  */
74 int GeomLinesAdjacency::
75 get_geom_rendering() const {
76  return GeomPrimitive::get_geom_rendering() | GR_adjacency;
77 }
78 
79 /**
80  * If the primitive type is a simple type in which all primitives have the
81  * same number of vertices, like lines, returns the number of vertices per
82  * primitive. If the primitive type is a more complex type in which different
83  * primitives might have different numbers of vertices, for instance a line
84  * strip, returns 0.
85  */
86 int GeomLinesAdjacency::
87 get_num_vertices_per_primitive() const {
88  return 4;
89 }
90 
91 /**
92  * Returns the minimum number of vertices that must be added before
93  * close_primitive() may legally be called.
94  */
95 int GeomLinesAdjacency::
96 get_min_num_vertices_per_primitive() const {
97  return 4;
98 }
99 
100 /**
101  * Calls the appropriate method on the GSG to draw the primitive.
102  */
103 bool GeomLinesAdjacency::
105  bool force) const {
106  return gsg->draw_lines_adj(reader, force);
107 }
108 
109 /**
110  * Tells the BamReader how to create objects of type Geom.
111  */
112 void GeomLinesAdjacency::
113 register_with_read_factory() {
114  BamReader::get_factory()->register_factory(get_class_type(), make_from_bam);
115 }
116 
117 /**
118  * This function is called by the BamReader's factory when a new object of
119  * type Geom is encountered in the Bam file. It should create the Geom and
120  * extract its information from the file.
121  */
122 TypedWritable *GeomLinesAdjacency::
123 make_from_bam(const FactoryParams &params) {
124  GeomLinesAdjacency *object = new GeomLinesAdjacency(UH_unspecified);
125  DatagramIterator scan;
126  BamReader *manager;
127 
128  parse_params(params, scan, manager);
129  object->fillin(scan, manager);
130 
131  return object;
132 }
Defines a series of disconnected line segments with adjacency information, for use with geometry shad...
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
PT(GeomPrimitive) GeomLinesAdjacency
Returns the fundamental rendering type of this primitive: whether it is points, lines,...
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
get_geom_rendering
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
Definition: geomPrimitive.h:73
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.