15 #include "geomTristrips.h"
16 #include "geomTriangles.h"
17 #include "geomVertexRewriter.h"
18 #include "pStatTimer.h"
19 #include "bamReader.h"
20 #include "bamWriter.h"
21 #include "graphicsStateGuardianBase.h"
31 GeomTristrips(GeomTristrips::UsageHint usage_hint) :
77 GeomPrimitive::PrimitiveType GeomTristrips::
78 get_primitive_type()
const {
92 return GR_triangle_strip | GR_indexed_other;
94 return GR_triangle_strip;
132 return gsg->draw_tristrips(reader, force);
150 decompose_impl()
const {
155 int num_vertices = get_num_vertices();
156 int num_unused = get_num_unused_vertices_per_primitive();
162 if (get_shade_model() == SM_flat_first_vertex) {
165 int vi = -num_unused;
167 while (li < (
int)ends.size()) {
171 nassertr(vi + 2 <= end, NULL);
172 int v0 = get_vertex(vi);
174 int v1 = get_vertex(vi);
176 bool reversed =
false;
178 int v2 = get_vertex(vi);
181 if (v0 != v1 && v0 != v2 && v1 != v2) {
182 triangles->add_vertex(v0);
183 triangles->add_vertex(v2);
184 triangles->add_vertex(v1);
185 triangles->close_primitive();
189 if (v0 != v1 && v0 != v2 && v1 != v2) {
190 triangles->add_vertex(v0);
191 triangles->add_vertex(v1);
192 triangles->add_vertex(v2);
193 triangles->close_primitive();
202 nassertr(vi == num_vertices, NULL);
207 int vi = -num_unused;
209 while (li < (
int)ends.size()) {
213 nassertr(vi + 2 <= end, NULL);
214 int v0 = get_vertex(vi);
216 int v1 = get_vertex(vi);
218 bool reversed =
false;
220 int v2 = get_vertex(vi);
222 if (v0 != v1 && v0 != v2 && v1 != v2) {
223 triangles->add_vertex(v1);
224 triangles->add_vertex(v0);
225 triangles->add_vertex(v2);
226 triangles->close_primitive();
230 if (v0 != v1 && v0 != v2 && v1 != v2) {
231 triangles->add_vertex(v0);
232 triangles->add_vertex(v1);
233 triangles->add_vertex(v2);
234 triangles->close_primitive();
244 nassertr(vi == num_vertices, NULL);
247 return triangles.p();
256 doubleside_impl()
const {
259 return decompose_impl()->doubleside();
268 reverse_impl()
const {
271 return decompose_impl()->reverse();
280 rotate_impl()
const {
289 new_vertices->set_num_rows(get_num_vertices());
299 for (ei = ends.begin(); ei != ends.end(); ++ei) {
301 int num_vertices = end - begin;
306 from.set_row_unsafe(end - 1);
313 nassertr((num_vertices & 1) == 0, NULL);
314 for (
int vi = end - 1; vi >= begin; --vi) {
315 from.set_row_unsafe(vi);
316 last_added = from.get_data1i();
327 int first_vertex = get_first_vertex();
332 CPTA_int::const_iterator ei;
333 for (ei = ends.begin(); ei != ends.end(); ++ei) {
335 int num_vertices = end - begin;
346 nassertr((num_vertices & 1) == 0, NULL);
347 for (
int vi = end - 1; vi >= begin; --vi) {
348 last_added = vi + first_vertex;
367 requires_unused_vertices()
const {
384 int prev = from.get_data1i();
418 parse_params(params, scan, manager);
419 object->fillin(scan, manager);
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
virtual int get_num_unused_vertices_per_primitive() const
Returns the number of vertices that are added between primitives that aren't, strictly speaking...
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
int get_num_rows() const
Returns the number of rows stored in the array, based on the number of bytes and the stride...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void add_data1i(int data)
Sets the write row to a particular 1-component value, and advances the write row. ...
virtual int get_geom_rendering() const
Returns the set of GeomRendering bits that represent the rendering properties required to properly re...
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...
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...
void set_data1i(int data)
Sets the write row to a particular 1-component value, and advances the write row. ...
Defines a series of triangle strips.
virtual bool draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const
Calls the appropriate method on the GSG to draw the primitive.
ShadeModel get_shade_model() const
Returns the shade model common to all of the individual GeomPrimitives that have been added to the ge...
UsageHint get_usage_hint() const
Returns the minimum (i.e.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual Geom * make_copy() const
Returns a newly-allocated Geom that is a shallow copy of this one.
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
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.
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
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.
Similar to PointerToArray, except that its contents may not be modified.
This is the data for one array of a GeomVertexData structure.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
bool is_at_end() const
Returns true if the writer is currently at the end of the list of vertices, false otherwise...