Panda3D

Loading...
Searching...
No Matches
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"
18#include "graphicsStateGuardianBase.h"
19#include "geomVertexReader.h"
20#include "geomVertexWriter.h"
21
22 TypeHandle GeomLinesAdjacency::_type_handle;
23
24/**
25 *
26 */
27GeomLinesAdjacency::
28GeomLinesAdjacency(GeomEnums::UsageHint usage_hint) :
29 GeomPrimitive(usage_hint)
30{
31}
32
33/**
34 *
35 */
36GeomLinesAdjacency::
37GeomLinesAdjacency(const GeomLinesAdjacency &copy) :
38 GeomPrimitive(copy)
39{
40}
41
42/**
43 *
44 */
45GeomLinesAdjacency::
46~GeomLinesAdjacency() {
47}
48
49/**
50 *
51 */
52PT(GeomPrimitive) GeomLinesAdjacency::
53make_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 */
65GeomPrimitive::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::
104 draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader,
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::
123make_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}
bamReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
parse_params
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
bamWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
BamReader::get_factory
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Definition bamReader.I:177
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
Factory::register_factory
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
GeomLinesAdjacency
Defines a series of disconnected line segments with adjacency information, for use with geometry shad...
Definition geomLinesAdjacency.h:26
GeomLinesAdjacency::get_primitive_type
virtual PrimitiveType get_primitive_type() const
Returns the fundamental rendering type of this primitive: whether it is points, lines,...
Definition geomLinesAdjacency.cxx:66
GeomLinesAdjacency::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type Geom.
Definition geomLinesAdjacency.cxx:113
GeomLinesAdjacency::draw
virtual bool draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const
Calls the appropriate method on the GSG to draw the primitive.
Definition geomLinesAdjacency.cxx:104
GeomLinesAdjacency::get_geom_rendering
virtual int get_geom_rendering() const
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
Definition geomLinesAdjacency.cxx:75
GeomLinesAdjacency::get_num_vertices_per_primitive
virtual int get_num_vertices_per_primitive() const
If the primitive type is a simple type in which all primitives have the same number of vertices,...
Definition geomLinesAdjacency.cxx:87
GeomLinesAdjacency::get_min_num_vertices_per_primitive
virtual int get_min_num_vertices_per_primitive() const
Returns the minimum number of vertices that must be added before close_primitive() may legally be cal...
Definition geomLinesAdjacency.cxx:96
GeomPrimitive
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition geomPrimitive.h:56
GeomPrimitive::get_geom_rendering
get_geom_rendering
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
Definition geomPrimitive.h:73
GraphicsStateGuardianBase
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
Definition graphicsStateGuardianBase.h:110
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable
Base class for objects that can be written to and read from Bam files.
Definition typedWritable.h:35
geomLinesAdjacency.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomVertexReader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
geomVertexWriter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
graphicsStateGuardianBase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pStatTimer.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.