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

IunctusSimulator.cpp

Go to the documentation of this file.
00001 #include "IunctusSimulator.h"
00002 #include "Border.h"
00003 #include "Circle.h"
00004 
00005 
00006 
00007 
00008 IunctusSimulator::IunctusSimulator() {
00009 
00010    real width=6, height=4;
00011    //set the borders of the simulator space
00012    registerObject(new Border(0, height/2, 1, 0, "left border"));
00013    registerObject(new Border(width, height/2, -1, 0, "right border"));
00014    registerObject(new Border(width/2, 0,  0, 1, "bottom border"));
00015    registerObject(new Border(width/2, height, 0,  -1, "upper border"));
00016 
00018    float circles[6][3] = {
00019       {0.1f, 5.0f, 3.0f},
00020       {0.2f, 0.4f, 0.6f},
00021       {0.1f, 0.8f, 0.9f},
00022       {0.2f, 1.7f, 2.8f},
00023       {0.25f, 4.7f, 2.5f},
00024       {0.1f, 3.5f, 1.0f}
00025    };
00026    
00027    //add the agent
00028    registerObject(agent=new Iunctus(2.0, 0.8, "Iunctus"));
00029 
00030    //add balls
00031 
00032    char s[10];
00033 
00034    
00035    for (unsigned i = 0; i < 6; ++i) {
00036       sprintf(s,"ball %d",i+1);
00037       registerObject(new Circle(circles[i][0], circles[i][1], circles[i][2], s));
00038    }
00039    
00040 
00041    
00042    registerObject(new CappedRectangle(0.3f,  0.1f, 3.0f, 2.2f, 10*degrees, "capsule 1"));
00043    registerObject(new CappedRectangle(0.6f, 0.05f, 1.0f, 3.2f, 60*degrees, "capsule 2"));
00044    registerObject(new CappedRectangle(0.5f, 0.12f, 5.0f, 1.2f, 80*degrees, "capsule 3"));
00045    registerObject(new CappedRectangle(0.4f, 0.08f, 2.3f, 3.3f, 160*degrees, "capsule 4"));
00046    ComposedPhysicalObject* c=new ComposedPhysicalObject(2.0f, 2.5f, 0, "double ball");
00047    c->addObject(new Circle(0.1),-0.1,0,0);
00048    c->addObject(new Circle(0.1),0.1,0,0);
00049    registerObject(c);
00050 }
00051 
00052 IunctusSimulator::~IunctusSimulator(){
00053 }
00054 
00055 void IunctusSimulator::detectContacts(){
00056    Simulator::detectContacts();
00057    /*
00058    The eye is not involved into contact detection by its parent, the agent.
00059    We can do this by either:
00060    1. Changing the bounding box of the agent to include the bounding box of the eye, thus becoming infinite,
00061    and including eye contact detection with agent contact detection (as for Spherus).
00062    This is innefficient because we will then need to verify in detail the contact of all agent links
00063    with all objects.
00064    2. Changing the method of contact detection in Simulator::detectContacts by performing culling with 
00065    bounding boxes at the level of primitives. Thus, the eye will be treated separately of the agent.
00066    Then, we will have to ensure that there is no contact checking between successive articulated links.
00067    This is best but requires distancing slightly the links and coding global changes in the implementation 
00068    of contact detection (to do...).
00069    3. The method implemented below: we call here 'manually' contact detection for the eye with all objects.
00070    */
00071    PhysicalObjectPVector::iterator objectsI, objectsEnd=objects.end();
00072    for(objectsI=objects.begin(); objectsI!=objectsEnd; ++objectsI){
00073          agent->eye->detectContacts(*objectsI, &contacts);
00074    }
00075 
00076 }

Thyrix homepageUsers' guide

(C) Arxia 2004-2005