31 GeomTristrips(GeomTristrips::UsageHint usage_hint) :
68 GeomPrimitive::PrimitiveType GeomTristrips::
69 get_primitive_type()
const {
78 get_geom_rendering()
const {
80 return GR_triangle_strip | GR_indexed_other;
82 return GR_triangle_strip;
91 make_adjacency()
const {
99 int num_vertices = from.get_num_vertices();
100 const int num_unused = 2;
103 map<std::pair<int, int>,
int> edge_map;
105 int vi = -num_unused;
107 while (li < (
int)ends.size()) {
111 nassertr(vi + 2 <= end,
nullptr);
113 int v0 = from.get_vertex(vi++);
114 int v1 = from.get_vertex(vi++);
115 int v2 = from.get_vertex(vi);
116 edge_map[make_pair(v0, v1)] = v2;
119 v2 = from.get_vertex(vi++);
120 edge_map[make_pair(v2, v0)] = v1;
124 edge_map[make_pair(v1, v2)] = v0;
130 v2 = from.get_vertex(vi++);
131 edge_map[make_pair(v0, v2)] = v1;
135 edge_map[make_pair(v2, v1)] = v0;
144 nassertr(vi == num_vertices,
nullptr);
150 while (li < (
int)ends.size()) {
154 nassertr(vi + 2 <= end,
nullptr);
156 int v0 = from.get_vertex(vi++);
157 int v1 = from.get_vertex(vi++);
162 auto it = edge_map.find(make_pair(v1, v0));
163 if (it != edge_map.end()) {
164 adj->add_vertex(it->second);
172 v2 = from.get_vertex(vi++);
173 it = edge_map.find(make_pair(v0, v2));
174 if (it != edge_map.end()) {
175 adj->add_vertex(it->second);
183 it = edge_map.find(make_pair(v2, v1));
184 if (it != edge_map.end()) {
185 adj->add_vertex(it->second);
194 v2 = from.get_vertex(vi++);
195 it = edge_map.find(make_pair(v2, v0));
196 if (it != edge_map.end()) {
197 adj->add_vertex(it->second);
205 it = edge_map.find(make_pair(v1, v2));
206 if (it != edge_map.end()) {
207 adj->add_vertex(it->second);
217 adj->close_primitive();
220 nassertr(vi == num_vertices,
nullptr);
230 get_min_num_vertices_per_primitive()
const {
241 get_num_unused_vertices_per_primitive()
const {
251 return gsg->draw_tristrips(reader, force);
265 decompose_impl()
const {
271 int num_unused = get_num_unused_vertices_per_primitive();
279 int vi = -num_unused;
281 while (li < (
int)ends.size()) {
285 nassertr(vi + 2 <= end,
nullptr);
290 bool reversed =
false;
295 if (v0 != v1 && v0 != v2 && v1 != v2) {
296 triangles->add_vertex(v0);
297 triangles->add_vertex(v2);
298 triangles->add_vertex(v1);
299 triangles->close_primitive();
303 if (v0 != v1 && v0 != v2 && v1 != v2) {
304 triangles->add_vertex(v0);
305 triangles->add_vertex(v1);
306 triangles->add_vertex(v2);
307 triangles->close_primitive();
316 nassertr(vi == num_vertices,
nullptr);
321 int vi = -num_unused;
323 while (li < (
int)ends.size()) {
327 nassertr(vi + 2 <= end,
nullptr);
332 bool reversed =
false;
336 if (v0 != v1 && v0 != v2 && v1 != v2) {
337 triangles->add_vertex(v1);
338 triangles->add_vertex(v0);
339 triangles->add_vertex(v2);
340 triangles->close_primitive();
344 if (v0 != v1 && v0 != v2 && v1 != v2) {
345 triangles->add_vertex(v0);
346 triangles->add_vertex(v1);
347 triangles->add_vertex(v2);
348 triangles->close_primitive();
358 nassertr(vi == num_vertices,
nullptr);
368 doubleside_impl()
const {
371 return decompose_impl()->doubleside();
378 reverse_impl()
const {
381 return decompose_impl()->reverse();
388 rotate_impl()
const {
406 CPTA_int::const_iterator ei;
407 for (ei = ends.begin(); ei != ends.end(); ++ei) {
409 int num_vertices = end - begin;
413 to.set_data1i(last_added);
414 from.set_row_unsafe(end - 1);
415 to.set_data1i(from.get_data1i());
421 nassertr((num_vertices & 1) == 0,
nullptr);
422 for (
int vi = end - 1; vi >= begin; --vi) {
423 from.set_row_unsafe(vi);
424 last_added = from.get_data1i();
425 to.set_data1i(last_added);
431 nassertr(to.is_at_end(),
nullptr);
440 CPTA_int::const_iterator ei;
441 for (ei = ends.begin(); ei != ends.end(); ++ei) {
443 int num_vertices = end - begin;
447 to.set_data1i(last_added);
448 to.set_data1i(end - 1 + first_vertex);
454 nassertr((num_vertices & 1) == 0,
nullptr);
455 for (
int vi = end - 1; vi >= begin; --vi) {
456 last_added = vi + first_vertex;
457 to.set_data1i(last_added);
463 nassertr(to.is_at_end(),
nullptr);
473 requires_unused_vertices()
const {
487 int prev = from.get_data1i();
493 to.add_data1i(vertex);
516 object->fillin(scan, manager);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
get_vertex
Returns the ith vertex index in the table.
UsageHint get_usage_hint() const
Returns the minimum (i.e.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
get_num_vertices
Returns the number of indices used by all the primitives in this object.
Defines a series of triangle strips.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT(GeomPrimitive) GeomTristrips
Returns the fundamental rendering type of this primitive: whether it is points, lines,...
int get_first_vertex() const
Returns the first vertex number referenced by the primitive.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
get_current_thread
Returns a pointer to the currently-executing Thread object.
Defines a series of triangle strips with adjacency information.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
CPTA_int get_ends() const
Returns a const pointer to the primitive ends array so application code can read it directly.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
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...
int get_num_rows() const
Returns the number of rows stored in the array, based on the number of bytes and the stride.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A thread; that is, a lightweight process.
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
get_shade_model
Returns the ShadeModel hint for this primitive.
Defines a series of disconnected triangles.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Geom.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to PointerToArray, except that its contents may not be modified.
This is the data for one array of a GeomVertexData structure.