Collision Delphi Sample
Source code for Collision sample is available in Samples\Delphi 
folder of the installation directory. The sample is a Delphi 7 project, which 
can be loaded by later versions of Borland environments. 
Description 
Implementation
All functionality is implemented in TForm1 module. InitModelInfo() procedure, 
called initially from TForm1.OnFormShow(),
accesses IMetrics
interfaces of the two objects in the model. OnButtonMove() handler starts 
animation, which moves one of the objects. The animation is controlled by the 
timer m_timer, enabled in the OnButtonMove(). 
OnTimer() handler of timer events modifies position of the moved object with 
SetOrigin method of the I3DObject
interface, implemented by the object and checks whether the object has become 
close than specified distance to the second object. If this is true the timer is 
disabled to stop animation and final distance is calculated and displayed by 
CalculateDist() procedure. CalculateDist() uses 
IMetrics.Dist to do the calculation. 
See also DG Kernel and Delphi, Delphi Samples, 
Visual C++ Samples,   
All samples. 
                 |