# PhysX 2.8.4 Cooking problem

Hello, I have recently started using the PhysX 2.8.4 engine, and I have a problem regarding cooking a material. I have taken the example given in the documentation, but I am having trouble with the “MemoryWriteBuffer” and “MemoryReadBuffer”. The application simply does not recognise them, although I included everything that the examples contained. After searching a while on the internet, I found that these are contained in the Stream file, but I’‘ve looked there and they are not mentioned anywhere. Could you please help me? I really don’'t know how to solve this.

I managed to find the correct file to the problem above, but I get another one.

Hello, I have recently started using the PhysX 2.8.4 engine, and I have a problem regarding cooking a material. I have taken the example given in the documentation, but I get an error.

The code is as follows:

/*
** Generate a uniform cloth patch, w and h are the width and height, d is the distance between vertices.
*/
NxClothMeshDesc desc;

NxReal w = 0.8f;
NxReal h = 0.7f;
NxReal d = 0.15f;

int numX = (int)(w / d) + 1;
int numY = (int)(h / d) + 1;
desc.numVertices                = (numX+1) * (numY+1);
desc.numTriangles               = numX*numY*2;
desc.pointStrideBytes           = sizeof(NxVec3);
desc.triangleStrideBytes        = 3*sizeof(NxU32);
desc.points                     = (NxVec3*)malloc(sizeof(NxVec3)*desc.numVertices);
desc.triangles                  = (NxU32*)malloc(sizeof(NxU32)*desc.numTriangles*3);
desc.flags                      = 0;

int i,j;
NxVec3 *p = (NxVec3*)desc.points;

for (i = 0; i <= numY; i++) {
for (j = 0; j <= numX; j++) {
p->set(d*j, 0.0f, d*i);
p++;
}
}

NxU32 *id = (NxU32*)desc.triangles;
for (i = 0; i < numY; i++) {
for (j = 0; j < numX; j++) {
NxU32 i0 = i * (numX+1) + j;
NxU32 i1 = i0 + 1;
NxU32 i2 = i0 + (numX+1);
NxU32 i3 = i2 + 1;

if ((j+i)%2) {
*id++ = i0;
*id++ = i2;
*id++ = i1;
*id++ = i1;
*id++ = i2;
*id++ = i3;
}
else {
*id++ = i0;
*id++ = i2;
*id++ = i3;
*id++ = i0;
*id++ = i3;
*id++ = i1;
}
}
}

//cooking
NxClothMesh *mClothMesh;
static NxCookingInterface *gCooking = NxGetCookingLib(NX_PHYSICS_SDK_VERSION);
gCooking->NxInitCooking();
NxClothMeshDesc mdesc;    //...
//Cook the mesh on the fly through a memory stream.    //A file stream could also be used to pre-cook the mesh.
MemoryWriteBuffer wb;
if (!gCooking->NxCookClothMesh(mdesc, wb))
printf("Cooking failed!");
try{
mClothMesh = gScene->getPhysicsSDK().createClothMesh(rb);}
catch (char *str)
{
printf(str);
}

//create cloth
NxClothDesc ndesc;
NxCloth *mCloth;