Moderators: Sascha Willems, walaber
rvangaal wrote:For the explode effect, see http://www.racer.nl/temp/evo6_explode.wmv (600Kb). The guardrail (I've checked) is 2 polygons at exactly the same spot; the normals are pointed to either side (which is why Newton becomes confused as it hits both at the same time). I don't think this is really nicely fixable, although I did try once to converse momentum - after a collision the momentum should not exceed the summed momentum of both objects colliding (in this case, the static world has momentum 0).
if (hitParam > 1.0e-3f) {
int isFuturePosiInRamp;
dVector floorNormal (info[0].m_normalOnHitPoint[0], info[0].m_normalOnHitPoint[1], info[0].m_normalOnHitPoint[2], 0.0f);
isFuturePosiInRamp = (floorNormal % upDir) < m_maxSlope;
if (isFuturePosiInRamp) {
// apply free fall gravity force to the body along the ramp
dFloat hitParam1;
NewtonWorldConvexCastReturnInfo info1;
bodyMatrix.m_posit = posit + upDir.Scale (m_stairHeight - m_kinematicCushion);
target = bodyMatrix.m_posit - upDir.Scale(m_stairHeight * 2.0f);
NewtonWorldConvexCast (m_world, &bodyMatrix[0][0], &target[0], m_bodyFloorSensorShape, &hitParam1, &castFilterData, ConvexAllBodyCastPrefilter, &info1, 1, threadIndex);
if (hitParam < hitParam1) {
int iterations;
int contactCount = 1;
// the player hit the edge of a forbidden ramp
dVector savedVeloc (velocity);
for (iterations = 0; contactCount && (iterations < MAX_COLLISIONS_ITERATION); iterations ++) {
dFloat projectVel;
floorNormal -= upDir.Scale (floorNormal % upDir);
_ASSERTE ((floorNormal % floorNormal) > 1.0e-3f);
floorNormal = floorNormal.Scale (1.0f / dSqrt (floorNormal % floorNormal));
projectVel = velocity % floorNormal;
velocity -= floorNormal.Scale (projectVel);
step = velocity.Scale (timestep);
bodyMatrix.m_posit = posit + step + upDir.Scale (m_stairHeight - m_kinematicCushion);
target = bodyMatrix.m_posit - upDir.Scale(m_stairHeight * 2.0f);
castFilterData.m_count = 1;
contactCount = NewtonWorldConvexCast (m_world, &bodyMatrix[0][0], &target[0], m_bodyFloorSensorShape, &hitParam, &castFilterData, ConvexAllBodyCastPrefilter, info, 1, threadIndex);
//
//
//
// here the hitParam can be 1.02 or so, if contactCount is 0
//
//
//
if (contactCount) {
floorNormal = dVector (info[0].m_normalOnHitPoint[0], info[0].m_normalOnHitPoint[1], info[0].m_normalOnHitPoint[2], 0.0f);
//floorNormal = dVector (info[0].m_normal[0], info[0].m_normal[1], info[0].m_normal[2], 0.0f);
contactCount = (floorNormal % upDir) < m_maxSlope;
}
}
if (iterations >= MAX_COLLISIONS_ITERATION) {
dVector veloc1 (CalculateVelocity (savedVeloc, timestep, upDir, 0.0f, threadIndex));
dVector err (veloc1 - velocity);
if ((err % err) < 1.0e-6f) {
m_playerState = m_onIlligalRamp;
} else {
velocity = veloc1;
hitParam = 0.0f;
step = dVector (0.0f, 0.0f, 0.0f, 0.0f);
bodyMatrix.m_posit = posit - upDir.Scale (m_kinematicCushion);
}
}
} else {
m_playerState = m_onIlligalRamp;
}
}
//
//
//
// then if iterations was < MAX_COLLISION_ITERATION it is used here to set the position
//
//
//
bodyMatrix.m_posit = bodyMatrix.m_posit + (target - bodyMatrix.m_posit).Scale (hitParam) + upDir.Scale (m_kinematicCushion);
bodyMatrix.m_posit -= step;
NewtonBodySetMatrix (m_body0, &bodyMatrix[0][0]);
}
melven wrote:Hi, I'm trying to implement a player-controller in OgreNewt (based on the CustomPlayerController-joint).
First of all, the player controller seems to work nice.
At the moment I just "copied" the code from the CustomPlayerController-class ( with modifications, so it uses Ogre's vectors etc).
It seems to work now, but I still have a few questions:
- If you move the player in the middle of two "illegal" ramps ( like a 'V' ), it gets stuck ( I did test this only with my version of the player-controller ). This happened when moving on some small boxes... If you have an idea how to solve this, I would be happy...
- In the following code from the CustomPlayerController::PlayerOnLand function, the hitParam can be 1.02, when the convex-cast in the for-loop doesn't hit anything, is this the intented behavior? (the hitParam is used to set the position later on... it seems to work though)
winstrol wrote:I deleted the movie, here is the test project:
http://www.insurgents.net/~winstrol/iPh ... rials2.zip
set active target to tutorial102 and move the wheel by pressing up and down arrows on the screen
under tutorial101 is the very simple car, you can also see the problem there, because car is jumping
Oh Cool, you are making the car for the iphone, I will chek it out tomorrrow morning, maybe I will add it as next tutorial.
struct dQuaternion InitFromMatrix (struct dMatrix* matrix)
Also had you getten the laste SDK, there are soem optimization an dsome change sonc eteh last Mac version
Users browsing this forum: No registered users and 3 guests