|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
gestion of collisions : discussion on some improvements...hi,
don't know on what you're working on but for collision what I need is : 1) which part on the entity collide, (front, back (of a car) etc...) 2) where (and who!) on the other entity, (a bush, a truck (rip) ) 3) which force/velocity (1Km/h 100km/h ??? not the same result) 4) must be done as fast as possible !! the current implementation doesn't fit really well. You have to cross ref others entity/shape - which is time consuming - even many informations are missing. So here some changes I made (would make) and I would like to know what you all think about ; a) The ode callback in physics::Level will call : physics::Shape::onCollide( Shape* remote, vector& velocity ) : added the velocity information and "remote" is the other entity's shape it collided with. b) The shape will call (from onCollide) : physics::entity::onCollide( Shape* local, Shape* remote, vector& velocity ); : from the entity you directly know where, with who, how. c) I change the entity collided array (GetCollidedShapes). It will store a struct holding : struct collision { Shape* local // shape on this entity Shape* remote // shape on the collided entity vector3 velocity // velocity of the collision } d) new xml optional token for shape object : "shapeid" (int) By distributing the value between all shapes on your game - like and ip address - it's allow you to identify the shape without having to look at the composite : cheap, fast. (and allow switch/case algorithm structures) here an example of implementation : xml for a car : <Composite type="standard" numBodies="5" numJoints="4" numMeshes="0"> <RigidBody name="body" pos="0.000000 0.682949 0.000000" rot="0.0000 0.0000 0.0000 1.0000" model="body" numShapes="1"> <BoxShape shapeid="100" pos="0.0 0.296 0.0" rot="0.0000 0.0000 0.0000 1.0000" size="2 0.692 1" mat="EmptyWood" /> </RigidBody> <RigidBody name="wheel_front_l" pos="0.822664 0.682949 -0.596252" rot="0.0000 0.0000 0.0000 1.0000" model="wheel_front_l" numShapes="1"> <SphereShape shapeid="10" pos="0.000 0.000 0.000" radius="0.3" mat="Tire" /> </RigidBody> ............. xml for a pylon (static obj) <Composite type="standard" numBodies="0" numJoints="0" numMeshes="1"> <MeshShape name="pylone" shapeid="1000" file="home:/export/meshes/testcar/pylone.n3d2" mat="Soil"/> </Composite> most of collision check must be done into an derived physics::entity but here how to implement those into an property::OnMoveAfter .............. // init some variables etc.... ............... i = phyentity->GetNumCollisions() -1; while( i >= 0 ) { struct Physics::Entity::collision data = phyentity->GetCollidedShapes().At( i ); switch( data.local->GetShapeId() ) { // left front wheel case 10 : .......... // right front wheel case 11 : switch( data.remote->GetShapeId() ) { // wheel collide with ground ; don't care case 0 : break; // it a "tiny" tree, no consequences, the tree entity // will care about destroying it case 500 : break; // hit a pylon, may "break the joint case 1000 : // check force... if( (data.velocity.x * data.velocity.x) + (data.velocity.y * data.velocity.y) + (data.velocity.z * data.velocity.z) > 0.1 ) { // too fast, break the joint between wheel and body dJointAttach( joint_g->GetJointId(), 0, 0 ); ....... etc } break; .................etc default : break; } .............etc } In my point of view those changes make collision based decision fast and cheap, I tried it and working with collision is now an easy part; So WHAT do you THINK about IT ????????? -- for my 3d work it's over there --> http://j.a.l.free.fr/3dsmax update 26 Aug 2006 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV *** NOTE: To reply to the list use "reply to all", *** *** to reply direct to the sender use "reply" *** _______________________________________________ Nebuladevice-discuss mailing list Nebuladevice-discuss@... https://lists.sourceforge.net/lists/listinfo/nebuladevice-discuss |
| Free embeddable forum powered by Nabble | Forum Help |