-
Notifications
You must be signed in to change notification settings - Fork 0
Home
sglab edited this page Jun 7, 2015
·
6 revisions
The archive contains all the libraries (except for opengl and glut) and include files needed to build applications using OpenCCD. The following is a description of what each folder contains:
- Src: source code for the OpenCCD library
- Doc: documentation for the OpenCCD library
- Demo1: one example demonstrating usage of the OpenCCD library
- include: header files that should be included to an application
Basic APIs are explained in below. Please see the full CCD_API documentation for details. [ Click Here ]
- Supported compiler: MS Visual Studio 2005 or later version
- Visual studio project files for VS2005 and VS2008 are included in the distribution.
- For other compilers, add all source files into a project and try to compile it.
Setting up the library for use in your application is simple.
- Build the OpenCCD library
- Make sure you link to OpennCCD.lib
- The include folder included with the distribution should be in your include path
- Once the above two things have been done, all you need to do is "#include <OpenCCD.h>" in your application
obj1.beginObject( # of frames , # of vertices, # of triangles, object type );
// set vertices' info. of each frame
obj.setVtx( 0, 0, Vec3f( 0, 0, 0 ) );
...
// set triangles' info. of each frame
obj.setTri( 0, 0, 1, 2 );
obj.endObject( );
CCD ccd;
CCD_Output output;
CCD_Object obj1, obj2;
ccd.setOutput( &output );
...
// Set Info. of objects
...
obj1.setID( ccd.addObject( &obj1 ) );
obj2.setID( ccd.addObject( &obj2 ) );
ccd.readyCCD( 0, 10, 0 );
while( ) {
ccd.performCCD( );
// move to next frame or update model Info.
}
CCD ccd;
CCD_Output output;
CCD_Object obj1, obj2;
// Assign output instance to CCD
ccd.setOutput( &output );
// set object 1
obj1.beginObject( 2, 3, 1, CCD_OBJECT_TYPE_STATIC );
// frame 1
obj1.setVtx( 0, 0, Vec3f( 0, 0, 0 ) );
obj1.setVtx( 0, 1, Vec3f( 0, 0, 1 ) );
obj1.setVtx( 0, 2, Vec3f( 0, 1, 1 ) );
// frame 2
obj1.setVtx( 1, 0, Vec3f( 0, 0, -1 ) );
obj1.setVtx( 1, 1, Vec3f( 0, 0, 0 ) );
obj1.setVtx( 1, 2, Vec3f( 0, 1, 0 ) );
obj1.setTri( 0, 0, 1, 2 );
obj1.endObject();
// set object 2
obj2.beginObject( 2, 3, 1, CCD_OBJECT_TYPE_STATIC );
// frame 1
obj2.setVtx( 0, 0, Vec3f( -10, 0, -0.5 ) );
obj2.setVtx( 0, 1, Vec3f( 0, 10, -0.5 ) );
obj2.setVtx( 0, 2, Vec3f( 10, 0, -0.5 ) );
// frame 2
obj2.setVtx( 1, 0, Vec3f( -10, 0, -0.5 ) );
obj2.setVtx( 1, 1, Vec3f( 0, 10, -0.5 ) );
obj2.setVtx( 1, 2, Vec3f( 10, 0, -0.5 ) );
obj2.setTri( 0, 0, 1, 2 );
obj2.endObject( );
// Add objects to CCD
obj1.setID ( ccd.addObject( &obj1 ) );
obj2.setID ( ccd.addObject( &obj2 ) );
// Ready to perform CCD
ccd.readyCCD( 0, 2, 0 );
// Perform CCD
for ( int i = 0 ; i < 3 ; i++ ) {
ccd.performCCD( );
ccd.nextFrame( );
}
// Print results
output.printSummary();
CCD ccd;
CCD_Output output;
CCD_Object obj1, obj2;
// Assign output instance to CCD
ccd.setOutput( &output ) ;
// set object 1
obj1.beginObject( 1, 3, 1, CCD_OBJECT_TYPE_STATIC );
obj1.setVtx( 0, 0, Vec3f( 0, 0, 0 ) );
obj1.setVtx( 0, 1, Vec3f( 0, 0, 1 ) );
obj1.setVtx( 0, 2, Vec3f( 0, 1, 1 ) );
obj1.setTri( 0, 0, 1, 2 );
obj1.endObject( );
// set object 2
obj2.beginObject( 1, 3, 1, CCD_OBJECT_TYPE_STATIC );
obj2.setVtx( 0, 0, Vec3f( -10, 0, -0.5 ) );
obj2.setVtx( 0, 1, Vec3f( 0, 10, -0.5 ) );
obj2.setVtx( 0, 2, Vec3f( 10, 0, -0.5 ) );
obj2.setTri( 0, 0, 1, 2 ) ;
obj2.endObject( );
// Add objects to CCD
obj1.setID( ccd.addObject( &obj1 ) );
obj2.setID( ccd.addObject( &obj2 ) );
// Ready to perform CCD
ccd.readyCCD( 0, 1, 0 );
// Apply model changes
obj1.swapVtxs_Cur_Prev( );
obj1.setCurVtx( 0, Vec3f( 0, 0, -1 ) );
obj1.setCurVtx( 1, Vec3f( 0, 0, 0 ) );
obj1.setCurVtx( 2, Vec3f( 0, 1, 0 ) );
obj2.swapVtxs_Cur_Prev( );
obj2.setCurVtx( 0, Vec3f( -10, 0, -0.5 ) );
obj2.setCurVtx( 1, Vec3f( 0, 10, -0.5 ) );
obj2.setCurVtx( 2, Vec3f( 10, 0, -0.5 ) );
// perform CCD
ccd.performCCD( );
// Print results
output.printSummary( );