The 'behaviours' that I need are as follows (I include what I do to set them up and what I expect) [in the provided code, 'world', 'collision' and 'location' refer to a properly initialized NewtonWorld, a properly initialized NewtonCollision and the location matrix for that body]:
- Type A: triggers
+ Desired Behaviour: do not interact physically at all with other bodies, but generate contact joints for CustomTriggerManager (I even need to get NewtonContactJointGetClosestDistance() to control how the automatic cameras in the game are interpolated). These triggers may be static or move around controlled by entities or scripts.
+ Setup:
- Code: Select all
NewtonCollisionSetMode( collision, 0 );
body = NewtonCreateKinematicBody( world, collision, location );
- Type B: static geometry
+ Desired Behaviour: affect dynamic bodies in the solver, but are not affected by them (mostly scenario. I tried to put them all in the scene collision, but they have different setups for broadphase filtering and ended up being too cumbersome, so I keep them as separate bodies).
+ Setup:
- Code: Select all
body = NewtonCreateKinematicBody( world, collision, location );
NewtonBodySetCollidable( body, 1 );
- Type C: kinematic bodies (in the traditional sense)
+ Desired Behaviour: same behaviour as Type B (statics) but can be moved around by scripts (like moving platforms).
+ Setup:
- Code: Select all
body = NewtonCreateKinematicBody( world, collision, location );
NewtonBodySetMassProperties( body, 1.0f * NewtonConvexCollisionCalculateVolume( collision ), collision );
NewtonBodySetCollidable( body, 1 );
*Note that I have had to give them mass (it seems bizarre to me) otherwise they do not activate triggers.
- Type D: characters
+ Desired Behaviour: a 'mockup' for characters, as I am currently still working on the CustomCharacterController for our game (however, the mockup does the job for now). They should collide physically with Types B and C, and also activate triggers.
+ Setup:
- Code: Select all
body = NewtonCreateDynamicBody( world, collision, location );
NewtonBodySetMassProperties( body, 1.0f * NewtonConvexCollisionCalculateVolume( collision ), collision );
NewtonBodySetForceAndTorqueCallback( body, characterForceCallback );
NewtonConstraintCreateUpVector( world, Vector(0, 1, 0), body );
NewtonBodySetContinuousCollisionMode( body, 1 );
NewtonBodySetTransformCallback( body, setTransformCallback );
Type D has several tweaks of its velocity and acceleration in the respective callback. As I mentioned, I intend to improve its physical behaviour in a Custom Controller, but it does the job for now.
The main problem is that, even having tweaked the setup in weird ways to get it to work as much as possible (giving mass to Type C???), I cannot get moving triggers (Type A) to detect static geometry (Type B).
I have tried many possibilities for setup, this is simply the one that gets most stuff to work (but not all). Am I missing something or doing something wrong? What is the proper way to setup the bodies for the behaviour I described? Thanks