32 NxClothMeshDesc meshDesc;
33 _cloth->ptr()->getClothMesh()->saveToDesc(meshDesc);
35 NxU32 numVertices = meshDesc.numVertices;
36 NxU32 numTriangles = meshDesc.numTriangles;
42 NxU32 maxVertices = factor * numVertices;
43 _mesh.verticesPosBegin = (NxVec3 *)malloc(
sizeof(NxVec3) * maxVertices);
44 _mesh.verticesNormalBegin = (NxVec3 *)malloc(
sizeof(NxVec3) * maxVertices);
45 _mesh.verticesPosByteStride =
sizeof(NxVec3);
46 _mesh.verticesNormalByteStride =
sizeof(NxVec3);
47 _mesh.maxVertices = maxVertices;
48 _mesh.numVerticesPtr = (NxU32 *)malloc(
sizeof(NxU32));
51 NxU32 maxIndices = 3 * numTriangles;
52 _mesh.indicesBegin = (NxU32 *)malloc(
sizeof(NxU32) * maxIndices);
53 _mesh.indicesByteStride =
sizeof(NxU32);
54 _mesh.maxIndices = maxIndices;
55 _mesh.numIndicesPtr = (NxU32 *)malloc(
sizeof(NxU32));
57 NxU32 maxParentIndices = maxVertices;
58 _mesh.parentIndicesBegin = (NxU32 *)malloc(
sizeof(NxU32)*maxParentIndices);
59 _mesh.parentIndicesByteStride =
sizeof(NxU32);
60 _mesh.maxParentIndices = maxParentIndices;
61 _mesh.numParentIndicesPtr = (NxU32 *)malloc(
sizeof(NxU32));
63 *(_mesh.numVerticesPtr) = 0;
64 *(_mesh.numIndicesPtr) = 0;
66 _cloth->ptr()->setMeshData(_mesh);
75 NxU32 numVertices = *(_mesh.numVerticesPtr);
77 if (numVertices == _numVertices) {
83 _numVertices = numVertices;
93 _prim->clear_vertices();
100 NxU32 numVertices = *(_mesh.numVerticesPtr);
101 NxVec3 *v = (NxVec3 *)_mesh.verticesPosBegin;
102 NxVec3 *n = (NxVec3 *)_mesh.verticesNormalBegin;
104 for (
unsigned int i=0; i < numVertices; i++) {
116 for (
unsigned int i=0; i < numVertices; i++) {
117 tex_u = _texcoords[2*i];
118 tex_v = _texcoords[2*i+1];
119 twriter.add_data2f(tex_u, tex_v);
124 NxU32 numIndices = *(_mesh.numIndicesPtr);
125 NxU32 *idx = (NxU32 *)_mesh.indicesBegin;
127 for (
unsigned int i=0; i < numIndices; i++) {
128 _prim->add_vertex(*idx);
132 _prim->close_primitive();
144 NxU32 numVertices = *(_mesh.numVerticesPtr);
145 NxVec3 *v = (NxVec3 *)_mesh.verticesPosBegin;
146 NxVec3 *n = (NxVec3 *)_mesh.verticesNormalBegin;
148 for (
unsigned int i=0; i < numVertices; i++) {
166 NxU32 numVertices = *(_mesh.numVerticesPtr);
167 NxU32 *parent = (NxU32 *)_mesh.parentIndicesBegin + _numTexcoords;
169 for (NxU32 i=_numTexcoords; i < numVertices; i++, parent++) {
170 _texcoords[2*i] = _texcoords[2*(*parent)];
171 _texcoords[2*i+1] = _texcoords[2*(*parent)+1];
174 _numTexcoords = numVertices;
181set_texcoords(
const Filename &filename) {
183 if (filename.empty()) {
188 fn.resolve_filename(get_model_path());
206 _numTexcoords = fs.readDword();
207 _texcoords =
new float[2 * _numTexcoords];
209 for (
unsigned int i=0; i<_numTexcoords; i++) {
210 _texcoords[2*i] = fs.readFloat();
211 _texcoords[2*i+1] = fs.readFloat();
The name of a file, such as a texture file or an Egg file.
bool exists() const
Returns true if the filename exists on the physical disk, false otherwise.
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
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 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.
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.