15 #include "physxTriangleMeshDesc.h" 16 #include "physxManager.h" 18 #include "nodePathCollection.h" 20 #include "geomVertexReader.h" 39 _vertices =
new NxVec3[numVertices];
41 _desc.numVertices = numVertices;
42 _desc.points = _vertices;
54 nassertv(_desc.numVertices > idx);
70 if (_desc.triangles) {
74 if (_desc.materialIndices) {
78 _triangles =
new NxU32[3 * numTriangles];
80 _desc.numTriangles = numTriangles;
81 _desc.triangles = _triangles;
83 if (use_material_indices ==
true) {
84 _materials =
new NxMaterialIndex[numTriangles];
85 _desc.materialIndices = _materials;
97 unsigned int i1,
unsigned int i2,
unsigned int i3,
98 unsigned int material_index) {
100 nassertv(_desc.numTriangles > idx);
102 if (_desc.materialIndices) {
103 _materials[idx] = (NxMaterialIndex) material_index;
107 _triangles[idx] = i1;
108 _triangles[idx + 1] = i2;
109 _triangles[idx + 2] = i3;
117 const NxTriangleMeshDesc &PhysxTriangleMeshDesc::
151 CPT(
Geom) geom = gnode->get_geom(j);
162 for (
int k=0; k<geom->get_num_primitives(); k++) {
165 prim = prim->decompose();
167 for (
int l=0; l<prim->get_num_primitives(); l++) {
169 int s = prim->get_primitive_start(l);
170 int e = prim->get_primitive_end(l);
172 for (
int l=s; l<e; l++) {
173 dataIndices.push_back(prim->get_vertex(l));
183 NxU32 numVertices = dataVertices.size();
184 NxU32 numTriangles = dataIndices.size() / 3;
186 _vertices =
new NxVec3[numVertices];
187 _triangles =
new NxU32[3 * numTriangles];
191 for (vit=dataVertices.begin(); vit!=dataVertices.end(); vit++) {
194 _vertices[i].x = v.get_x();
195 _vertices[i].y = v.get_y();
196 _vertices[i].z = v.get_z();
202 for(iit=dataIndices.begin(); iit!=dataIndices.end(); iit++) {
209 _desc.numVertices = numVertices;
210 _desc.points = _vertices;
211 _desc.numTriangles = numTriangles;
212 _desc.triangles = _triangles;
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
void set_num_vertices(unsigned int n)
Sets the number of vertices to be stored within this triangle mesh.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
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 ...
int get_num_geoms() const
Returns the number of geoms in the node.
This is our own Panda specialization on the default STL vector.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
void set_vertex(unsigned int idx, const LPoint3f &vert)
Sets a single vertex.
NodePath get_path(int index) const
Returns the nth NodePath in the collection.
int get_num_paths() const
Returns the number of NodePaths in the collection.
void set_num_triangles(unsigned int n, bool use_material_indices=false)
Sets the number of triangles to be stored in this triangle mesh.
PandaNode * node() const
Returns the referenced node of the path.
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
bool is_at_end() const
Returns true if the reader is currently at the end of the list of vertices, false otherwise...
void set_triangle(unsigned int idx, unsigned int i1, unsigned int i2, unsigned int i3, unsigned int material_index=1)
Sets a single triangle, by providing the three indices i1, i2, i3.
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...
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.
void set_from_node_path(const NodePath &np)
A convenience method to set the mesh data from a NodePath in a single call.
This is a set of zero or more NodePaths.