Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

collisionevent.cc

Go to the documentation of this file.
00001 #include "collisionevent.hh"
00002 #include "color.hh"
00003 #include "element.hh"
00004 #include "vector.hh"
00005 #include <iostream>
00006 #include "collisionmessage.hh"
00007 
00008 using namespace anoid::simple;
00009 using namespace anoid::base;
00010 
00011 void CollisionEvent::fire() {
00012     if (datacount == 3) {
00013         Vector *n = (Vector *)(data[0]);
00014         Vector *p1 = (Vector *)(data[1]);
00015         Vector *p2 = (Vector *)(data[2]);
00016         if (n) {
00017             n->setNorm(1);
00018             Element *e1 = dynamic_cast<Element *>(argv[0]);
00019             Element *e2 = dynamic_cast<Element *>(argv[1]);
00020             if (e1 && e2) {
00021                 CollisionMessage *m = new CollisionMessage();
00022                 m->setNormal(n);
00023                 m->setOther(e2);
00024                 m->setP1(p1);
00025                 m->setP2(p2);
00026                 e1->receive(m);
00027 
00028                 m->setOther(e1);
00029                 m->setP1(p2);
00030                 m->setP2(p1);
00031                 e2->receive(m);
00032 
00033                 delete m;
00034             }
00035             delete n;
00036         }
00037     }
00038 }

Anoid NG © Michael Westergaard, Martin Stig Stissing, Ronni Michael Laursen, and Kristian Bisgaard Lassen