Main Page   Namespace List   Alphabetical List   Compound List   File List   Compound Members   File Members  

CollisionSet Class Reference

class represents set of collisionable objects More...

#include <collisionset.h>

Collaboration diagram for CollisionSet:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CollisionSet ()
 empty constructor

bool insert (Model *model)
 insert object into collision set

bool contains (Model *model)
 check wether collision set contains given object

void setTranslation (double t[3])
 set translation matrix

void setOrientation (double o[3][3])
 set orientation matrix

 ~CollisionSet ()
 destructor


Static Public Member Functions

bool checkForCollision (CollisionSet *setA, CollisionSet *setB)
 check for collision


Public Attributes

double translation [3]
 translation matrix

double orientation [3][3]
 orientation matrix


Private Attributes

ModelListroot

Detailed Description

class represents set of collisionable objects

This class represents a data structure to store Model instances that are involved in the collision detection process.

Author:
Rene Mueller
Date:
June 16th, 2003


Constructor & Destructor Documentation

CollisionSet::CollisionSet  ) 
 

empty constructor

00012 {
00013    root = new ModelList;
00014    root->next = NULL;
00015    root->model = NULL;
00016 
00017    // set orientation to identity matrix
00018    orientation[0][0] = 1.0; orientation[0][1] = 0.0; orientation[0][2] = 0.0;
00019    orientation[1][0] = 0.0; orientation[1][1] = 1.0; orientation[1][2] = 0.0;
00020    orientation[2][0] = 0.0; orientation[2][1] = 0.0; orientation[2][2] = 1.0;
00021    
00022    // set translation to zero vector
00023    translation[0] = 0.0; 
00024    translation[1] = 0.0; 
00025    translation[2] = 0.0; 
00026 }

CollisionSet::~CollisionSet  ) 
 

destructor

00088 { }


Member Function Documentation

bool CollisionSet::checkForCollision CollisionSet *  setA,
CollisionSet *  setB
[static]
 

check for collision

check every model from each set against every model from the other set if there is a collision return true, otherwise false.

Parameters:
setA first collision set
setB second collision set
Returns:
true if there is a collision, false otherwise

00093 {
00094    bool collision = false;
00095    ModelList* modelA, *modelB;
00096    for (modelA = setA->root->next; modelA != NULL; modelA = modelA->next) {
00097       for (modelB = setB->root->next; modelB != NULL; modelB = modelB->next) {
00098          Model* A = modelA->model;
00099          Model* B = modelB->model;
00100          
00101          RAPID_Collide(setA->orientation, setA->translation, 
00102             A->rapidModel, setB->orientation, setB->translation, B->rapidModel,
00103             RAPID_FIRST_CONTACT);
00104          collision = (RAPID_num_contacts != 0);
00105          if (collision) {
00106              return true;
00107          }
00108       }
00109    }
00110 
00111    return collision;
00112 }

bool CollisionSet::contains Model *  model  ) 
 

check wether collision set contains given object

check whether given model is present in set

Parameters:
model model to check
Returns:
true if model is in set, false otherwise

00054 {
00055    ModelList* ptr = root;
00056    while ((ptr != NULL) && (ptr->model != model)) {
00057       ptr = ptr->next;
00058    }
00059    if (ptr == NULL) {
00060       return false;
00061    } else {
00062       return (ptr->model == model);
00063    }
00064 }

bool CollisionSet::insert Model *  model  ) 
 

insert object into collision set

insert Model into collision set if it does not already exist

Parameters:
model Model to be inserted
Returns:
true if model was successfully inserted and false if model is already in set

00032 {
00033    if (contains(model)) {
00034       // model is already in set 
00035       return false;
00036    }
00037 
00038    // find end of list
00039    ModelList* ptr = root;
00040    while (ptr->next != NULL) {
00041       ptr = ptr->next;
00042    }
00043    // ptr.next == NULL now 
00044    ptr->next = new ModelList;
00045    ptr->next->next = NULL;
00046    ptr->next->model = model;
00047    
00048    return true;
00049 }

void CollisionSet::setOrientation double  o[3][3]  ) 
 

set orientation matrix

Parameters:
o new orientation matrix (copied by value)

00078 {
00079    for (int i=0; i<3; i++) {
00080       for (int j=0; j<3; j++) {
00081          orientation[i][j] = o[i][j];
00082       }
00083    }
00084 }   

void CollisionSet::setTranslation double  t[3]  ) 
 

set translation matrix

Parameters:
t new translation matrix (copied by value)

00069 {
00070    for (int i=0; i<3; i++) {
00071       translation[i] = t[i];
00072    }
00073 }   


Member Data Documentation

double CollisionSet::orientation[3][3]
 

orientation matrix

ModelList* CollisionSet::root [private]
 

double CollisionSet::translation[3]
 

translation matrix


The documentation for this class was generated from the following files:
Generated on Tue Jul 8 13:23:02 2003 for ROM-Visualizer by doxygen 1.3.1