DG Kernel (ActiveX) Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
What is new
Upgrading Native Apps
Licensing
Collapse ModelsModels
Collapse DG Kernel ControlsDG Kernel Controls
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
Collapse ModelModel
Collapse ViewView
Collapse General ComputingGeneral Computing
Collapse Samples and TutorialsSamples and Tutorials
Collapse GraphicsGraphics
Collapse Math ObjectsMath Objects
Collapse DeprecatedDeprecated
Redistribution
Model Viewer
Open Source
Support
Skip Navigation Links Go to DGKC docs Search Documentation


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.