15 #include "physxClothMeshDesc.h"
16 #include "physxManager.h"
18 #include "nodePathCollection.h"
20 #include "geomVertexReader.h"
40 _points =
new NxVec3[numVertices];
42 _desc.numVertices = numVertices;
43 _desc.points = _points;
50 _texcoords =
new LPoint2f[numVertices];
62 nassertv(_desc.numVertices > idx);
65 _texcoords[idx] = texcoord;
80 if (_desc.triangles) {
84 _triangles =
new NxU32[3 * numTriangles];
86 _desc.numTriangles = numTriangles;
87 _desc.triangles = _triangles;
98 unsigned int i1,
unsigned int i2,
unsigned int i3) {
100 nassertv(_desc.numTriangles > idx);
103 _triangles[idx] = i1;
104 _triangles[idx + 1] = i2;
105 _triangles[idx + 2] = i3;
137 CPT(
Geom) geom = gnode->get_geom(j);
154 for (
int k=0; k<geom->get_num_primitives(); k++) {
157 prim = prim->decompose();
159 for (
int l=0; l<prim->get_num_primitives(); l++) {
161 int s = prim->get_primitive_start(l);
162 int e = prim->get_primitive_end(l);
164 for (
int l=s; l<e; l++) {
165 dataIndices.push_back(prim->get_vertex(l));
175 NxU32 numVertices = dataVertices.size();
176 NxU32 numTriangles = dataIndices.size() / 3;
178 _points =
new NxVec3[numVertices];
179 _triangles =
new NxU32[3 * numTriangles];
180 _texcoords =
new LPoint2f[numVertices];
184 for (vit=dataVertices.begin(); vit!=dataVertices.end(); vit++) {
193 for (tcit=dataTexcoords.begin(); tcit!=dataTexcoords.end(); tcit++) {
202 for(iit=dataIndices.begin(); iit!=dataIndices.end(); iit++) {
209 _desc.numVertices = numVertices;
210 _desc.points = _points;
211 _desc.numTriangles = numTriangles;
212 _desc.triangles = _triangles;
void set_from_node_path(const NodePath &np)
A convenience method to set the mesh data from a NodePath in a single call.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
NodePath get_path(int index) const
Returns the nth NodePath in the collection.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
PandaNode * node() const
Returns the referenced node of the path.
const LVecBase3f & get_data3f()
Returns the data associated with the read row, expressed as a 3-component value, and advances the rea...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
bool is_at_end() const
Returns true if the reader is currently at the end of the list of vertices, false otherwise...
int get_num_paths() const
Returns the number of NodePaths in the collection.
This is our own Panda specialization on the default STL vector.
void set_vertex(unsigned int idx, const LPoint3f &vert, const LPoint2f &texcoord)
Sets a single vertex.
void set_num_triangles(unsigned int n)
Sets the number of triangles to be stored in this triangle mesh.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
void set_triangle(unsigned int idx, unsigned int i1, unsigned int i2, unsigned int i3)
Sets a single triangle, by providing the three indices i1, i2, i3.
A container for geometry primitives.
const LVecBase2f & get_data2f()
Returns the data associated with the read row, expressed as a 2-component value, and advances the rea...
void set_num_vertices(unsigned int n)
Sets the number of vertices to be stored within this triangle mesh.
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
NodePathCollection find_all_matches(const string &path) const
Returns the complete set of all NodePaths that begin with this NodePath and can be extended by path...
This is a two-component point in space.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
A node that holds Geom objects, renderable pieces of geometry.
int get_num_geoms() const
Returns the number of geoms in the node.
This is a set of zero or more NodePaths.