Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ContactInfo.cpp

Go to the documentation of this file.
00001 #include "ContactInfo.h" 
00002 #include "PhysicalObject.h"
00003 
00004 
00005 ContactInfo::ContactInfo(PhysicalObject* iniObject, int iniSigma) :
00006    sigma(iniSigma),
00007    type(contactTypeTorque),
00008    object(iniObject),
00009    force(0.0){
00010       parentObject=object;
00011 }
00012 
00013 ContactInfo::ContactInfo(PhysicalObject* iniObject, int iniSigma, 
00014                          const Vector2& iniP, const Vector2& iniN, int iSensor) :
00015    object(iniObject),    
00016    sigma(iniSigma),
00017    p(iniP),
00018    n(iniN),
00019    iSensor(iSensor),
00020    type(contactTypeForce),
00021    force(0.0){ 
00022    setupObject();
00023 }
00024 
00025 
00026 ContactInfo::ContactInfo(PhysicalObject* iniObject, int iniSigma, 
00027                          const Vector2& iniP, const Vector2& iniN, 
00028                    int iSensor, int iSensor2) :
00029    object(iniObject),
00030    sigma(iniSigma),
00031    p(iniP),
00032    n(iniN),
00033    iSensor(iSensor),
00034    iSensor2(iSensor2),
00035    type(contactTypeForceParallel),
00036    force(0.0){    
00037    setupObject(); 
00038 }
00039 
00040 void ContactInfo::setupObject(){
00041    if(object->parent){
00042       /*for composed objects, modify the relative position, 
00043           to be relative to the origin of the
00044           composed object, rather than the object itself */
00045       Vector2  rt=object->r;
00046       rt -= object->parent->r;
00047       p += rt;
00048       /*for composed objects, the contact is registered 
00049           at the level of the composed object, 
00050           not at the level of the simple objects */
00051       parentObject = object->parent;
00052    } else {
00053       parentObject = object;
00054    }
00055    pxn = p ^ n;
00056    parentObject->addContact(this);
00057 }
00058 
00059 ContactInfo::~ContactInfo() {
00060 }

Thyrix homepageUsers' guide

(C) Arxia 2004-2005