Moderators: Sascha Willems, walaber
void ConvexCastPlacement (NewtonBody* body)
{
dFloat param;
dMatrix matrix;
NewtonWorld* world;
NewtonCollision* collision;
NewtonWorldConvexCastReturnInfo info[16];
NewtonBodyGetMatrix (body, &matrix[0][0]);
matrix.m_posit.m_y += 20.0f;
dVector p (matrix.m_posit);
p.m_y -= 40.0f;
world = NewtonBodyGetWorld(body);
collision = NewtonBodyGetCollision(body);
NewtonWorldConvexCast (world, &matrix[0][0], &p[0], collision, ¶m, body, ConvexCastCallback, info, 16);
_ASSERTE (param < 1.0f);
matrix.m_posit.m_y += (p.m_y - matrix.m_posit.m_y) * param;
NewtonBodySetMatrix(body, &matrix[0][0]);
}
KiwiCoder wrote:contacts = NewtonWorldConvexCast(world, &matrix[0], &matrix[0], sensorShape, ¶m, NULL, NULL, info, MAX_CONTACTS, 0);
why don't you use a simpler function, like for all object in AABB?
I would use sometion like this:
KiwiCoder wrote:BTW, what does the threadIndex parameter do..?
float worldbb[6];
NewtonWorld * nWorld;
worldbb[0] = -100;
worldbb[1] = -100;
worldbb[2] = -100;
worldbb[3] = 100;
worldbb[4] = 100;
worldbb[5] = 100;
// create world
nWorld = NewtonCreate(0, 0);
NewtonSetThreadsCount(nWorld, 1);
NewtonSetPlatformArchitecture(nWorld, 0);
NewtonSetMultiThreadSolverOnSingleIsland(nWorld, 0);
NewtonSetSolverModel(nWorld, 1);
NewtonSetFrictionModel(nWorld, 1);
NewtonSetWorldSize(nWorld, worldbb, worldbb + 3);
// create sphere
NewtonCollision * col = NewtonCreateSphere(nWorld, 5, 5, 5, 0, 0);
float p[16];
int i;
for (i = 0; i < 16; ++i)
{
p[i] = 0;
}
p[0] = 1;
p[5] = 1;
p[10] = 1;
p[15] = 1;
p[12] = 10;
p[13] = 10;
p[14] = 15;
NewtonBody * body = NewtonCreateBody(nWorld, col);
NewtonReleaseCollision(nWorld, col);
NewtonBodySetMatrix(body, p);
// collision
col = NewtonCreateSphere(nWorld, 2, 2, 2, 0, 0);
for (i = 0; i < 16; ++i)
{
p[i] = 0;
}
p[0] = 1;
p[5] = 1;
p[10] = 1;
p[15] = 1;
p[12] = 10;
p[13] = 10;
p[14] = 10;
float hitparam;
NewtonWorldConvexCastReturnInfo returninfo[128];
int returninfon = NewtonWorldConvexCast(nWorld, p, p, col, &hitparam, 0, 0, returninfo, 128, 0);
Users browsing this forum: No registered users and 2 guests