Panda3D
Public Member Functions | Protected Member Functions

GeomVertexWriter Class Reference

This object provides a high-level interface for quickly writing a sequence of numeric values from a vertex table. More...

#include "geomVertexWriter.h"

Inheritance diagram for GeomVertexWriter:
GeomEnums GeomVertexRewriter

List of all members.

Public Member Functions

 GeomVertexWriter (Thread *current_thread=Thread::get_current_thread())
 Constructs an invalid GeomVertexWriter.
 GeomVertexWriter (GeomVertexData *vertex_data, Thread *current_thread=Thread::get_current_thread())
 Constructs a new writer to process the vertices of the indicated data object.
 GeomVertexWriter (GeomVertexData *vertex_data, const InternalName *name, Thread *current_thread=Thread::get_current_thread())
 Constructs a new writer to process the vertices of the indicated data object.
 GeomVertexWriter (const GeomVertexWriter &copy)
 GeomVertexWriter (GeomVertexArrayData *array_data, Thread *current_thread=Thread::get_current_thread())
 Constructs a new writer to process the vertices of the indicated array only.
 GeomVertexWriter (GeomVertexData *vertex_data, const string &name, Thread *current_thread=Thread::get_current_thread())
 Constructs a new writer to process the vertices of the indicated data object.
 GeomVertexWriter (GeomVertexArrayData *array_data, int column, Thread *current_thread=Thread::get_current_thread())
 Constructs a new writer to process the vertices of the indicated array only.
 GeomVertexWriter (GeomVertexDataPipelineWriter *data_writer, const InternalName *name)
 Constructs a new writer to process the vertices of the indicated data object.
void add_data1f (float data)
 Sets the write row to a particular 1-component value, and advances the write row.
void add_data1i (int data)
 Sets the write row to a particular 1-component value, and advances the write row.
void add_data2f (float x, float y)
 Sets the write row to a particular 2-component value, and advances the write row.
void add_data2f (const LVecBase2f &data)
 Sets the write row to a particular 2-component value, and advances the write row.
void add_data2i (int a, int b)
 Sets the write row to a particular 2-component value, and advances the write row.
void add_data2i (const int data[2])
 Sets the write row to a particular 2-component value, and advances the write row.
void add_data3f (float x, float y, float z)
 Sets the write row to a particular 3-component value, and advances the write row.
void add_data3f (const LVecBase3f &data)
 Sets the write row to a particular 3-component value, and advances the write row.
void add_data3i (const int data[3])
 Sets the write row to a particular 3-component value, and advances the write row.
void add_data3i (int a, int b, int c)
 Sets the write row to a particular 3-component value, and advances the write row.
void add_data4f (float x, float y, float z, float w)
 Sets the write row to a particular 4-component value, and advances the write row.
void add_data4f (const LVecBase4f &data)
 Sets the write row to a particular 4-component value, and advances the write row.
void add_data4i (int a, int b, int c, int d)
 Sets the write row to a particular 4-component value, and advances the write row.
void add_data4i (const int data[4])
 Sets the write row to a particular 4-component value, and advances the write row.
void clear ()
 Resets the GeomVertexWriter to the initial state.
int get_array () const
 Returns the array index containing the data type that the writer is working on.
GeomVertexArrayDataget_array_data () const
 Returns the particular array object that the writer is currently processing.
const GeomVertexColumnget_column () const
 Returns the description of the data type that the writer is working on.
Threadget_current_thread () const
 Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this object.
int get_start_row () const
 Returns the row index at which the writer started.
GeomVertexDataget_vertex_data () const
 Returns the vertex data object that the writer is processing.
int get_write_row () const
 Returns the row index to which the data will be written at the next call to set_data*() or add_data*().
bool has_column () const
 Returns true if a valid data type has been successfully set, or false if the data type does not exist.
bool is_at_end () const
 Returns true if the writer is currently at the end of the list of vertices, false otherwise.
void operator= (const GeomVertexWriter &copy)
void output (ostream &out) const
bool set_column (const InternalName *name)
 Sets up the writer to use the data type with the indicated name.
bool set_column (int array, const GeomVertexColumn *column)
 Sets up the writer to use the indicated column description on the given array.
bool set_column (int column)
 Sets up the writer to use the nth data type of the GeomVertexFormat, numbering from 0.
bool set_column (const string &name)
 Sets up the writer to use the data type with the indicated name.
void set_data1f (float data)
 Sets the write row to a particular 1-component value, and advances the write row.
void set_data1i (int data)
 Sets the write row to a particular 1-component value, and advances the write row.
void set_data2f (const LVecBase2f &data)
 Sets the write row to a particular 2-component value, and advances the write row.
void set_data2f (float x, float y)
 Sets the write row to a particular 2-component value, and advances the write row.
void set_data2i (int a, int b)
 Sets the write row to a particular 2-component value, and advances the write row.
void set_data2i (const int data[2])
 Sets the write row to a particular 2-component value, and advances the write row.
void set_data3f (const LVecBase3f &data)
 Sets the write row to a particular 3-component value, and advances the write row.
void set_data3f (float x, float y, float z)
 Sets the write row to a particular 3-component value, and advances the write row.
void set_data3i (const int data[3])
 Sets the write row to a particular 3-component value, and advances the write row.
void set_data3i (int a, int b, int c)
 Sets the write row to a particular 3-component value, and advances the write row.
void set_data4f (const LVecBase4f &data)
 Sets the write row to a particular 4-component value, and advances the write row.
void set_data4f (float x, float y, float z, float w)
 Sets the write row to a particular 4-component value, and advances the write row.
void set_data4i (const int data[4])
 Sets the write row to a particular 4-component value, and advances the write row.
void set_data4i (int a, int b, int c, int d)
 Sets the write row to a particular 4-component value, and advances the write row.
void set_row (int row)
 Sets the start row to the indicated value.

Protected Member Functions

GeomVertexColumn::Packer * get_packer () const
 Returns the writer's Packer object.

Detailed Description

This object provides a high-level interface for quickly writing a sequence of numeric values from a vertex table.

This object can be used both to replace existing vertices in the table, or to extend the table with new vertices. The set_data*() family of methods can only be used to replace existing data; it is an error to allow these to run past the end of the data. The add_data*() family of methods, on the other hand, can be used to replace existing data or add new data; if you call set_row() into the middle of existing data the add_data*() methods will behave like the corresponding set_data*(), but if they run past the end of existing data they will quietly add new vertices.

Like GeomVertexReader, the writer is particularly optimized for writing a single column of data values for a series of vertices, without changing columns between each number. Although you can also use one GeomVertexWriter to write across the columns if it is convenient, by calling set_column() repeatedly at each vertex, it is faster to write down the columns, and to use a different GeomVertexWriter for each column.

Note that, like a GeomVertexReader, a GeomVertexWriter does not keep a reference count to the actual vertex data buffer. This means that it is important not to keep a GeomVertexWriter object around over a long period of time in which the data buffer is likely to be deallocated; it is intended for making a quick pass over the data in one session.

It also means that you should create any GeomVertexWriters *before* creating GeomVertexReaders on the same data, since the writer itself might cause the vertex buffer to be deallocated. Better yet, use a GeomVertexRewriter if you are going to create both of them anyway.

Definition at line 69 of file geomVertexWriter.h.


Constructor & Destructor Documentation

GeomVertexWriter::GeomVertexWriter ( Thread current_thread = Thread::get_current_thread()) [inline]

Constructs an invalid GeomVertexWriter.

You must use the assignment operator to assign a valid GeomVertexWriter to this object before you can use it.

Definition at line 25 of file geomVertexWriter.I.

Referenced by clear().

GeomVertexWriter::GeomVertexWriter ( GeomVertexData vertex_data,
Thread current_thread = Thread::get_current_thread() 
) [inline]

Constructs a new writer to process the vertices of the indicated data object.

Definition at line 39 of file geomVertexWriter.I.

GeomVertexWriter::GeomVertexWriter ( GeomVertexData vertex_data,
const string &  name,
Thread current_thread = Thread::get_current_thread() 
) [inline]

Constructs a new writer to process the vertices of the indicated data object.

This flavor creates the writer specifically to process the named data type.

Definition at line 54 of file geomVertexWriter.I.

References set_column().

GeomVertexWriter::GeomVertexWriter ( GeomVertexData vertex_data,
const InternalName name,
Thread current_thread = Thread::get_current_thread() 
) [inline]

Constructs a new writer to process the vertices of the indicated data object.

This flavor creates the writer specifically to process the named data type.

Definition at line 71 of file geomVertexWriter.I.

References set_column().

GeomVertexWriter::GeomVertexWriter ( GeomVertexArrayData array_data,
Thread current_thread = Thread::get_current_thread() 
) [inline]

Constructs a new writer to process the vertices of the indicated array only.

Definition at line 87 of file geomVertexWriter.I.

GeomVertexWriter::GeomVertexWriter ( GeomVertexArrayData array_data,
int  column,
Thread current_thread = Thread::get_current_thread() 
) [inline]

Constructs a new writer to process the vertices of the indicated array only.

Definition at line 102 of file geomVertexWriter.I.

References set_column().

GeomVertexWriter::GeomVertexWriter ( GeomVertexDataPipelineWriter data_writer,
const InternalName name 
) [inline]

Constructs a new writer to process the vertices of the indicated data object.

This flavor creates the writer specifically to process the named data type.

Definition at line 119 of file geomVertexWriter.I.

References GeomVertexFormat::get_array_with(), and GeomVertexFormat::get_column().


Member Function Documentation

void GeomVertexWriter::add_data1f ( float  data) [inline]

Sets the write row to a particular 1-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 607 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::add_data1i ( int  data) [inline]

Sets the write row to a particular 1-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 709 of file geomVertexWriter.I.

References has_column().

Referenced by GeomPrimitive::add_consecutive_vertices(), GeomPrimitive::add_vertex(), GeomTristrips::append_unused_vertices(), and GeomPrimitive::pack_vertices().

void GeomVertexWriter::add_data2f ( float  x,
float  y 
) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 622 of file geomVertexWriter.I.

Referenced by CMotionTrail::add_geometry_quad(), WindowFramework::load_default_model(), MeshDrawer2D::quad_raw(), PhysxSoftBodyNode::set_from_geom(), and MeshDrawer::tri().

void GeomVertexWriter::add_data2f ( const LVecBase2f data) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 636 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::add_data2i ( int  a,
int  b 
) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 724 of file geomVertexWriter.I.

References has_column().

Referenced by add_data2i().

void GeomVertexWriter::add_data2i ( const int  data[2]) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 739 of file geomVertexWriter.I.

References add_data2i().

void GeomVertexWriter::add_data3f ( float  x,
float  y,
float  z 
) [inline]
void GeomVertexWriter::add_data3f ( const LVecBase3f data) [inline]

Sets the write row to a particular 3-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 665 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::add_data3i ( int  a,
int  b,
int  c 
) [inline]

Sets the write row to a particular 3-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 753 of file geomVertexWriter.I.

References has_column().

Referenced by add_data3i().

void GeomVertexWriter::add_data3i ( const int  data[3]) [inline]

Sets the write row to a particular 3-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 768 of file geomVertexWriter.I.

References add_data3i().

void GeomVertexWriter::add_data4f ( const LVecBase4f data) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 694 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::add_data4f ( float  x,
float  y,
float  z,
float  w 
) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 680 of file geomVertexWriter.I.

Referenced by CMotionTrail::add_geometry_quad(), LineSegs::create(), PortalClipper::draw_lines(), CollisionRay::fill_viz_geom(), CollisionParabola::fill_viz_geom(), CollisionLine::fill_viz_geom(), MeshDrawer2D::quad_raw(), and MeshDrawer::tri().

void GeomVertexWriter::add_data4i ( int  a,
int  b,
int  c,
int  d 
) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 782 of file geomVertexWriter.I.

References has_column().

Referenced by add_data4i().

void GeomVertexWriter::add_data4i ( const int  data[4]) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

If the write row advances past the end of data, implicitly adds a new row to the data.

Definition at line 797 of file geomVertexWriter.I.

References add_data4i().

void GeomVertexWriter::clear ( ) [inline]

Resets the GeomVertexWriter to the initial state.

Reimplemented in GeomVertexRewriter.

Definition at line 297 of file geomVertexWriter.I.

References GeomVertexWriter().

int GeomVertexWriter::get_array ( ) const [inline]

Returns the array index containing the data type that the writer is working on.

Reimplemented in GeomVertexRewriter.

Definition at line 320 of file geomVertexWriter.I.

Referenced by GeomVertexData::copy_from(), GeomVertexData::describe_vertex(), and GeomVertexRewriter::get_array().

GeomVertexArrayData * GeomVertexWriter::get_array_data ( ) const [inline]

Returns the particular array object that the writer is currently processing.

Reimplemented in GeomVertexRewriter.

Definition at line 200 of file geomVertexWriter.I.

Referenced by GeomVertexRewriter::get_array_data().

const GeomVertexColumn * GeomVertexWriter::get_column ( ) const [inline]

Returns the description of the data type that the writer is working on.

Reimplemented in GeomVertexRewriter.

Definition at line 331 of file geomVertexWriter.I.

Referenced by GeomVertexRewriter::get_column(), and GeomVertexRewriter::has_column().

Thread * GeomVertexWriter::get_current_thread ( ) const [inline]

Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this object.

Definition at line 211 of file geomVertexWriter.I.

Referenced by GeomVertexData::clear_rows(), GeomVertexData::set_format(), and GeomVertexData::set_transform_table().

GeomVertexColumn::Packer * GeomVertexWriter::get_packer ( ) const [inline, protected]

Returns the writer's Packer object.

Definition at line 807 of file geomVertexWriter.I.

int GeomVertexWriter::get_start_row ( ) const [inline]

Returns the row index at which the writer started.

It will return to this row if you reset the current column.

Reimplemented in GeomVertexRewriter.

Definition at line 363 of file geomVertexWriter.I.

Referenced by GeomVertexRewriter::get_start_row().

GeomVertexData * GeomVertexWriter::get_vertex_data ( ) const [inline]

Returns the vertex data object that the writer is processing.

This may return NULL if the writer was constructed with just an array pointer.

Reimplemented in GeomVertexRewriter.

Definition at line 189 of file geomVertexWriter.I.

Referenced by GeomVertexRewriter::get_vertex_data().

int GeomVertexWriter::get_write_row ( ) const [inline]

Returns the row index to which the data will be written at the next call to set_data*() or add_data*().

Definition at line 375 of file geomVertexWriter.I.

bool GeomVertexWriter::has_column ( ) const [inline]

Returns true if a valid data type has been successfully set, or false if the data type does not exist.

Reimplemented in GeomVertexRewriter.

Definition at line 309 of file geomVertexWriter.I.

Referenced by add_data1f(), add_data1i(), add_data2f(), add_data2i(), add_data3f(), add_data3i(), add_data4f(), add_data4i(), GeomVertexData::copy_from(), set_data1f(), set_data1i(), set_data2f(), set_data2i(), set_data3f(), set_data3i(), set_data4f(), set_data4i(), and set_row().

bool GeomVertexWriter::is_at_end ( ) const [inline]

Returns true if the writer is currently at the end of the list of vertices, false otherwise.

If this is true, another call to set_data*() will result in a crash, but another call to add_data*() will add a new row.

Reimplemented in GeomVertexRewriter.

Definition at line 389 of file geomVertexWriter.I.

bool GeomVertexWriter::set_column ( int  array,
const GeomVertexColumn column 
)

Sets up the writer to use the indicated column description on the given array.

This also resets the current write row number to the start row (the same value passed to a previous call to set_row(), or 0 if set_row() was never called.)

The return value is true if the data type is valid, false otherwise.

Reimplemented in GeomVertexRewriter.

Definition at line 38 of file geomVertexWriter.cxx.

bool GeomVertexWriter::set_column ( int  column) [inline]

Sets up the writer to use the nth data type of the GeomVertexFormat, numbering from 0.

This also resets the write row number to the start row (the same value passed to a previous call to set_row(), or 0 if set_row() was never called.)

The return value is true if the data type is valid, false otherwise.

Reimplemented in GeomVertexRewriter.

Definition at line 229 of file geomVertexWriter.I.

References GeomVertexFormat::get_array_with(), and GeomVertexFormat::get_column().

Referenced by GeomVertexData::copy_from(), GeomVertexWriter(), and set_column().

bool GeomVertexWriter::set_column ( const string &  name) [inline]

Sets up the writer to use the data type with the indicated name.

This also resets the write row number to the start row (the same value passed to a previous call to set_row(), or 0 if set_row() was never called.)

The return value is true if the data type is valid, false otherwise.

Reimplemented in GeomVertexRewriter.

Definition at line 258 of file geomVertexWriter.I.

References set_column().

bool GeomVertexWriter::set_column ( const InternalName name) [inline]

Sets up the writer to use the data type with the indicated name.

This also resets the write number to the start row (the same value passed to a previous call to set_row(), or 0 if set_row() was never called.)

The return value is true if the data type is valid, false otherwise.

Reimplemented in GeomVertexRewriter.

Definition at line 276 of file geomVertexWriter.I.

References GeomVertexFormat::get_array_with(), and GeomVertexFormat::get_column().

void GeomVertexWriter::set_data1f ( float  data) [inline]

Sets the write row to a particular 1-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 403 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::set_data1i ( int  data) [inline]

Sets the write row to a particular 1-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 505 of file geomVertexWriter.I.

References has_column().

Referenced by GeomPrimitive::offset_vertices().

void GeomVertexWriter::set_data2f ( const LVecBase2f data) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 432 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::set_data2f ( float  x,
float  y 
) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 418 of file geomVertexWriter.I.

void GeomVertexWriter::set_data2i ( int  a,
int  b 
) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 520 of file geomVertexWriter.I.

References has_column().

Referenced by set_data2i().

void GeomVertexWriter::set_data2i ( const int  data[2]) [inline]

Sets the write row to a particular 2-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 535 of file geomVertexWriter.I.

References set_data2i().

void GeomVertexWriter::set_data3f ( float  x,
float  y,
float  z 
) [inline]

Sets the write row to a particular 3-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 447 of file geomVertexWriter.I.

Referenced by LineSegs::set_vertex().

void GeomVertexWriter::set_data3f ( const LVecBase3f data) [inline]

Sets the write row to a particular 3-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 461 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::set_data3i ( int  a,
int  b,
int  c 
) [inline]

Sets the write row to a particular 3-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 549 of file geomVertexWriter.I.

References has_column().

Referenced by set_data3i().

void GeomVertexWriter::set_data3i ( const int  data[3]) [inline]

Sets the write row to a particular 3-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 564 of file geomVertexWriter.I.

References set_data3i().

void GeomVertexWriter::set_data4f ( const LVecBase4f data) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 490 of file geomVertexWriter.I.

References has_column().

void GeomVertexWriter::set_data4f ( float  x,
float  y,
float  z,
float  w 
) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 476 of file geomVertexWriter.I.

Referenced by GeomVertexData::copy_from(), LineSegs::set_vertex_color(), and GeomTransformer::transform_texcoords().

void GeomVertexWriter::set_data4i ( const int  data[4]) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 593 of file geomVertexWriter.I.

References set_data4i().

void GeomVertexWriter::set_data4i ( int  a,
int  b,
int  c,
int  d 
) [inline]

Sets the write row to a particular 4-component value, and advances the write row.

It is an error for the write row to advance past the end of data.

Definition at line 578 of file geomVertexWriter.I.

References has_column().

Referenced by GeomVertexData::copy_from(), and set_data4i().

void GeomVertexWriter::set_row ( int  row) [inline]

Sets the start row to the indicated value.

The writer will begin writing to the indicated row; each subsequent set_data*() call will store the data into the subsequent row. If set_column() is called, the writer will return to this row.

Reimplemented in GeomVertexRewriter.

Definition at line 348 of file geomVertexWriter.I.

References has_column().

Referenced by GeomPrimitive::add_consecutive_vertices(), GeomPrimitive::add_vertex(), GeomTristrips::append_unused_vertices(), LineSegs::set_vertex(), and LineSegs::set_vertex_color().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations