30GeomTriangles(GeomTriangles::UsageHint usage_hint) :
56 return new GeomTriangles(*
this);
83 GeomPrimitivePipelineReader from(
this, current_thread);
84 int num_vertices = from.get_num_vertices();
87 new_vertices->set_num_rows(num_vertices * 2);
90 map<std::pair<int, int>,
int> edge_map;
91 for (
int i = 0; i < num_vertices; i += 3) {
95 edge_map[make_pair(v0, v1)] = v2;
96 edge_map[make_pair(v1, v2)] = v0;
97 edge_map[make_pair(v2, v0)] = v1;
104 for (
int i = 0; i < num_vertices; i += 3) {
111 auto it = edge_map.find(make_pair(v1, v0));
112 if (it != edge_map.end()) {
121 it = edge_map.find(make_pair(v2, v1));
122 if (it != edge_map.end()) {
129 it = edge_map.find(make_pair(v0, v2));
130 if (it != edge_map.end()) {
140 adj->set_vertices(std::move(new_vertices));
162 return gsg->draw_triangles(reader, force);
169doubleside_impl()
const {
180 bool needs_rotate =
false;
181 switch (from.get_shade_model()) {
182 case SM_flat_first_vertex:
183 case SM_flat_last_vertex:
192 for (
int i = from.get_num_vertices() - 1; i >= 0; --i) {
193 reversed->add_vertex(from.get_vertex(i));
199 reversed = (GeomTriangles *)DCAST(GeomTriangles, reversed->rotate());
209reverse_impl()
const {
211 PT(GeomTriangles) reversed =
new GeomTriangles(*
this);
213 GeomPrimitivePipelineReader from(
this, current_thread);
214 reversed->clear_vertices();
216 for (
int i = from.get_num_vertices() - 1; i >= 0; --i) {
217 reversed->add_vertex(from.get_vertex(i));
220 switch (from.get_shade_model()) {
221 case SM_flat_first_vertex:
222 reversed->set_shade_model(SM_flat_last_vertex);
223 reversed = (GeomTriangles *)DCAST(GeomTriangles, reversed->rotate());
226 case SM_flat_last_vertex:
227 reversed->set_shade_model(SM_flat_first_vertex);
228 reversed = (GeomTriangles *)DCAST(GeomTriangles, reversed->rotate());
248 PT(GeomVertexArrayData) new_vertices = make_index_data();
249 new_vertices->set_num_rows(num_vertices);
252 CPT(GeomVertexArrayData) vertices = get_vertices();
253 GeomVertexReader from(vertices, 0);
254 GeomVertexWriter to(new_vertices, 0);
256 switch (shade_model) {
257 case SM_flat_first_vertex:
260 for (
int begin = 0; begin < num_vertices; begin += 3) {
261 from.set_row_unsafe(begin + 1);
262 to.set_data1i(from.get_data1i());
263 to.set_data1i(from.get_data1i());
264 from.set_row_unsafe(begin);
265 to.set_data1i(from.get_data1i());
270 case SM_flat_last_vertex:
273 for (
int begin = 0; begin < num_vertices; begin += 3) {
274 from.set_row_unsafe(begin + 2);
275 to.set_data1i(from.get_data1i());
276 from.set_row_unsafe(begin);
277 to.set_data1i(from.get_data1i());
278 to.set_data1i(from.get_data1i());
285 nassertr(
false, vertices);
288 nassertr(to.is_at_end(),
nullptr);
293 GeomVertexWriter to(new_vertices, 0);
295 switch (shade_model) {
296 case SM_flat_first_vertex:
299 for (
int begin = 0; begin < num_vertices; begin += 3) {
300 to.set_data1i(begin + 1 + first_vertex);
301 to.set_data1i(begin + 2 + first_vertex);
302 to.set_data1i(begin + first_vertex);
307 case SM_flat_last_vertex:
310 for (
int begin = 0; begin < num_vertices; begin += 3) {
311 to.set_data1i(begin + 2 + first_vertex);
312 to.set_data1i(begin + first_vertex);
313 to.set_data1i(begin + 1 + first_vertex);
320 nassertr(
false,
nullptr);
323 nassertr(to.is_at_end(),
nullptr);
349 object->fillin(scan, manager);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
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...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A class to retrieve the individual data elements previously stored in a Datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
int get_vertex(int i) const
Returns the ith vertex index in the table.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
ConstPointerTo< GeomPrimitive > rotate() const
Returns a new primitive with the shade_model reversed (if it is flat shaded), if possible.
get_usage_hint
Returns the usage hint for this primitive.
get_num_vertices
Returns the number of indices used by all the primitives in this object.
int get_first_vertex() const
Returns the first vertex number referenced by the primitive.
get_shade_model
Returns the ShadeModel hint for this primitive.
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
Defines a series of disconnected triangles, with adjacency information.
Defines a series of disconnected triangles.
virtual PrimitiveType get_primitive_type() const
Returns the fundamental rendering type of this primitive: whether it is points, lines,...
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,...
ConstPointerTo< GeomPrimitive > make_adjacency() const
Adds adjacency information to this primitive.
virtual bool draw(GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const
Calls the appropriate method on the GSG to draw the primitive.
static void register_with_read_factory()
Tells the BamReader how to create objects of type Geom.
This is the data for one array of a GeomVertexData structure.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
void set_data1i(int data)
Sets the write row to a particular 1-component value, and advances the write row.
bool is_at_end() const
Returns true if the writer is currently at the end of the list of vertices, false otherwise.
void set_data1(PN_stdfloat data)
Sets the write row to a particular 1-component value, and advances the write row.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
get_current_thread
Returns a pointer to the currently-executing Thread object.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.