15 #include "physxClothNode.h" 16 #include "physxCloth.h" 17 #include "physxFileStream.h" 19 #include "geomVertexFormat.h" 20 #include "geomVertexWriter.h" 35 NxClothMeshDesc meshDesc;
36 _cloth->ptr()->getClothMesh()->saveToDesc(meshDesc);
38 NxU32 numVertices = meshDesc.numVertices;
39 NxU32 numTriangles = meshDesc.numTriangles;
45 NxU32 maxVertices = factor * numVertices;
46 _mesh.verticesPosBegin = (NxVec3 *)malloc(
sizeof(NxVec3) * maxVertices);
47 _mesh.verticesNormalBegin = (NxVec3 *)malloc(
sizeof(NxVec3) * maxVertices);
48 _mesh.verticesPosByteStride =
sizeof(NxVec3);
49 _mesh.verticesNormalByteStride =
sizeof(NxVec3);
50 _mesh.maxVertices = maxVertices;
51 _mesh.numVerticesPtr = (NxU32 *)malloc(
sizeof(NxU32));
54 NxU32 maxIndices = 3 * numTriangles;
55 _mesh.indicesBegin = (NxU32 *)malloc(
sizeof(NxU32) * maxIndices);
56 _mesh.indicesByteStride =
sizeof(NxU32);
57 _mesh.maxIndices = maxIndices;
58 _mesh.numIndicesPtr = (NxU32 *)malloc(
sizeof(NxU32));
60 NxU32 maxParentIndices = maxVertices;
61 _mesh.parentIndicesBegin = (NxU32 *)malloc(
sizeof(NxU32)*maxParentIndices);
62 _mesh.parentIndicesByteStride =
sizeof(NxU32);
63 _mesh.maxParentIndices = maxParentIndices;
64 _mesh.numParentIndicesPtr = (NxU32 *)malloc(
sizeof(NxU32));
66 *(_mesh.numVerticesPtr) = 0;
67 *(_mesh.numIndicesPtr) = 0;
69 _cloth->ptr()->setMeshData(_mesh);
80 NxU32 numVertices = *(_mesh.numVerticesPtr);
82 if (numVertices == _numVertices) {
88 _numVertices = numVertices;
100 _prim->clear_vertices();
107 NxU32 numVertices = *(_mesh.numVerticesPtr);
108 NxVec3 *v = (NxVec3 *)_mesh.verticesPosBegin;
109 NxVec3 *n = (NxVec3 *)_mesh.verticesNormalBegin;
111 for (
unsigned int i=0; i < numVertices; i++) {
123 for (
unsigned int i=0; i < numVertices; i++) {
124 tex_u = _texcoords[2*i];
125 tex_v = _texcoords[2*i+1];
131 NxU32 numIndices = *(_mesh.numIndicesPtr);
132 NxU32 *idx = (NxU32 *)_mesh.indicesBegin;
134 for (
unsigned int i=0; i < numIndices; i++) {
135 _prim->add_vertex(*idx);
139 _prim->close_primitive();
147 void PhysxClothNode::
153 NxU32 numVertices = *(_mesh.numVerticesPtr);
154 NxVec3 *v = (NxVec3 *)_mesh.verticesPosBegin;
155 NxVec3 *n = (NxVec3 *)_mesh.verticesNormalBegin;
157 for (
unsigned int i=0; i < numVertices; i++) {
170 void PhysxClothNode::
177 NxU32 numVertices = *(_mesh.numVerticesPtr);
178 NxU32 *parent = (NxU32 *)_mesh.parentIndicesBegin + _numTexcoords;
180 for (NxU32 i=_numTexcoords; i < numVertices; i++, parent++) {
181 _texcoords[2*i] = _texcoords[2*(*parent)];
182 _texcoords[2*i+1] = _texcoords[2*(*parent)+1];
185 _numTexcoords = numVertices;
193 bool PhysxClothNode::
194 set_texcoords(
const Filename &filename) {
196 if (filename.empty()) {
201 fn.resolve_filename(get_model_path());
219 _numTexcoords = fs.readDword();
220 _texcoords =
new float[2 * _numTexcoords];
222 for (
unsigned int i=0; i<_numTexcoords; i++) {
223 _texcoords[2*i] = fs.readFloat();
224 _texcoords[2*i+1] = fs.readFloat();
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
void add_data2f(float x, float y)
Sets the write row to a particular 2-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. ...
The name of a file, such as a texture file or an Egg file.
void add_data3f(float x, float y, float z)
Sets the write row to a particular 3-component value, and advances the write row. ...
TypeHandle is the identifier used to differentiate C++ class types.
bool exists() const
Returns true if the filename exists on the disk, false otherwise.