you can try different scale values, this change the behavior
Yes it's normal the object pass trough the hole, I put the object here to make it easier to see.
The issue is when you grab it on the collision mesh (not in the hole)
Moderators: Sascha Willems, Thomas
DemoMesh* const visualMesh = new DemoMesh(NewtonMeshCreateFromCollision(seatcol));
NewtonMesh* const newtonMesh = NewtonMeshCreateFromCollision(seatcol);
DemoMesh* const visualMesh = new DemoMesh(newtonMesh);
NewtonMeshDestroy(newtonMesh);
// load the skybox
scene->CreateSkyBox();
NewtonBody* const body = CreateLevelMesh (scene, "flatPlane.ngd", true);
dMatrix originMatrix;
NewtonBodyGetMatrix(body, &originMatrix[0][0]);
dMatrix camMatrix (dRollMatrix(-20.0f * 3.1416f /180.0f) * dYawMatrix(180.0f * 3.1416f /180.0f));
dQuaternion rot (camMatrix);
dVector origin (originMatrix.m_posit);
dFloat hight = 1000.0f;
origin = FindFloor (scene->GetNewton(), dVector (origin.m_x, hight, origin .m_z, 0.0f), hight * 2);
dVector location (origin);
location.m_x -= 0.0f;
location.m_z -= 0.0f;
location.m_y += 1.0f;
int defaultMaterialID = NewtonMaterialGetDefaultGroupID (scene->GetNewton());
dMatrix matrix (dGetIdentityMatrix());
matrix.m_posit = location;
matrix.m_posit.m_x = 0.0f;
matrix.m_posit.m_y = 0.8f;
matrix.m_posit.m_z = 0.0f;
matrix.m_posit.m_w = 1.0f;
NewtonCollision* seatcol = 0;
char pathName[2048];
GetWorkingFileName ("seat.col", pathName);
float scale = 0.001f;
FILE* file = fopen(pathName, "rb");
seatcol = NewtonCreateCollisionFromSerialization (scene->GetNewton(), DemoEntityManager::DeserializeFile, file);
fclose (file);
if (seatcol)
{
NewtonMesh* nmesh = NewtonMeshCreateFromCollision(seatcol);
DemoMesh* const visualMesh = new DemoMesh(nmesh);
for (int i = 0 ; i < visualMesh->m_vertexCount; i ++) {
visualMesh->m_vertex[i * 3 + 0] *= scale;
visualMesh->m_vertex[i * 3 + 1] *= scale;
visualMesh->m_vertex[i * 3 + 2] *= scale;
}
// re-optimize for render
visualMesh->OptimizeForRender();
NewtonBodySetCollisionScale(CreateSimpleSolid(scene, visualMesh, 10.0f, matrix, seatcol, 0), scale, scale, scale);
visualMesh->Release();
NewtonMeshDestroy(nmesh);
NewtonDestroyCollision(seatcol);
}
NewtonCollision* groundcol = 0;
matrix.m_posit.m_y = 1.0f;
GetWorkingFileName ("support.col", pathName);
file = fopen(pathName, "rb");
groundcol = NewtonCreateCollisionFromSerialization (scene->GetNewton(), DemoEntityManager::DeserializeFile, file);
fclose (file);
scale = 0.5f;
if (groundcol)
{
NewtonMesh* nmesh = NewtonMeshCreateFromCollision(groundcol);
DemoMesh* const visualMesh = new DemoMesh(nmesh);
for (int i = 0 ; i < visualMesh->m_vertexCount; i ++) {
visualMesh->m_vertex[i * 3 + 0] *= scale;
visualMesh->m_vertex[i * 3 + 1] *= scale;
visualMesh->m_vertex[i * 3 + 2] *= scale;
}
// re-optimize for render
visualMesh->OptimizeForRender();
NewtonBody* body = CreateSimpleSolid(scene, visualMesh, 0.0f, matrix, groundcol, 0);
NewtonBodySetCollisionScale(body, scale, scale, scale);
NewtonBodySetContinuousCollisionMode(body, 1);
visualMesh->Release();
NewtonMeshDestroy(nmesh);
NewtonDestroyCollision(groundcol);
}
origin.m_x += 1.0f;
origin.m_y += 1.0f;
scene->SetCameraMatrix(rot, origin);
Users browsing this forum: No registered users and 10 guests