• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Stop wasting time looking for files and revisions. Connect your Gmail, DriveDropbox, and Slack accounts and in less than 2 minutes, Dokkio will automatically organize all your file attachments. Learn more and claim your free account.


Articles DCECollision

Page history last edited by PBworks 15 years ago

GLScene has a dynamic collision engine (DCE) which provides automatic collision detection with objects in a scene. It is useful when creating a Quake like game where a player walks around a town and it is necessary to stop the player from crashing into walls and objects placed on the scene. DCE Collision detection works by adding behaviours to a scene object. The behaviour can either be static (TGLDCEStatic) or dynamic (TGLDCEDynamic). Static behaviour means that the object is stationary and is an object you collide with (eg a Quake 3 map) while dynamic behaviour is for objects that will collide with the static objects (eg a dummycube with a TGLCamera child). Typically a dynamic object is a camera. Since a camera has no behaviour property a dummycube can be created as the cameras parent and the dynamic behaviour is added to the dummycube.

The following are some steps for using DCE collision:

1. Add a TGLDCEManager to the application. If you want gravity in your scene set it to a negative number such as -30. This will mean that objects added to the scene will automatically move down until they collide with something.

2. For static objects in your scene click on the behaviour property and click on 'DCE Static Collider'. Set the manager of 'DCE Static Collider' to the DCEManager added in step 1. Set the shape property of the behaviour. If the static object is a freeform set it to cdFreeForm.

3. For dynamic objects add a 'DCE Dynamic Collider' behaviour to the object and also set the manager to the one in step 1.

In a GLScene application it will then be possible to move the dynamic objects around and they will slide or bounce off objects they collide with. Objects can be moved by applying force to the object or specifying the position you want to move the object to. The procedure GetOrCreateDCEDynamic provides a reference the objects TGLDCEDynamic behaviour class. The TGLDCEDynamic class has procedures that can move an object. In the following example the dummycube gldummycube2 has force applied in the z direction:



It will move the dummycube in the z direction. Objects in the path of the dummycube will effect how far it moves. For example if there is a cube in front of the object in the z direction it will bounce or slide off the cube when it hits it.

It is also possible to move an object to a certain position. The following example tries to move the dummycube to position 2,3,4



There is also a jump method that allows an object to leap up with a certain amount of force:


For a demonstration of DCE refer to the demo in CVS at:



Comments (0)

You don't have permission to comment on this page.