/** \brief Destructor. \author dcofer \date 6/30/2011 **/ VsFluidPlane::~VsFluidPlane() { try { DeleteGraphics(); DeletePhysics(); } catch(...) {Std_TraceMsg(0, "Caught Error in desctructor of VsFluidPlane/\r\n", "", -1, false, true);} }
/** \brief Destructor. \author dcofer \date 4/15/2011 **/ VsDistanceJoint::~VsDistanceJoint() { try { DeleteGraphics(); DeletePhysics(); } catch(...) {Std_TraceMsg(0, "Caught Error in desctructor of VsDistanceJoint/\r\n", "", -1, false, true);} }
BlBox::~BlBox() { try { DeleteGraphics(); DeletePhysics(false); } catch(...) {Std_TraceMsg(0, "Caught Error in desctructor of BlBox\r\n", "", -1, false, true);} }
VsOdorSensor::~VsOdorSensor() { try { DeleteGraphics(); DeletePhysics(); } catch(...) {Std_TraceMsg(0, "Caught Error in desctructor of VsOdorSensor/\r\n", "", -1, false, true);} }
VsEllipsoid::~VsEllipsoid() { try { DeleteGraphics(); DeletePhysics(); } catch(...) {Std_TraceMsg(0, "Caught Error in desctructor of VsEllipsoid/\r\n", "", -1, false, true);} }
OsgAttachment::~OsgAttachment() { try { DeleteGraphics(); DeletePhysics(false); } catch(...) {Std_TraceMsg(0, "Caught Error in desctructor of OsgAttachment\r\n", "", -1, false, true);} }
void Test_1::Input(SDL_Event E) { int i,j; Float x,y,z; palBodyBase *pb= NULL; palCompoundBodyBase *pcb = NULL; switch(E.type) { case SDL_KEYDOWN: switch (E.key.keysym.sym) { case SDLK_1: pb = CreateBody("palBox",sfrand()*3,sfrand()*2+5.0f,sfrand()*3,ufrand()+0.1f,ufrand()+0.1f,ufrand()+0.1f,1); if (pb == NULL) { printf("Error: Could not create a box\n"); } break; case SDLK_q: pb = CreateBody("palStaticBox",sfrand()*3,sfrand()*2+3.0f,sfrand()*3,ufrand()+0.1f,ufrand()+0.1f,ufrand()+0.1f,1); if (pb == NULL) { printf("Error: Could not create a static box\n"); } break; case SDLK_2: palSphere *ps; ps = NULL; ps=dynamic_cast<palSphere *>(PF->CreateObject("palSphere")); if (ps) { ps->Init(sfrand()*3,sfrand()*2+5.0f,sfrand()*3,0.5f*ufrand()+0.05f,1); BuildGraphics(ps); } else { printf("Error: Could not create a sphere\n"); } pb = ps; break; case SDLK_w: pb = CreateBody("palStaticSphere",sfrand()*3,sfrand()*2+3.0f,sfrand()*3,0.5*ufrand()+0.05f,0,0,1); if (pb == NULL) { printf("Error: Could not create a static sphere\n"); } break; case SDLK_3: palCapsule *pc; pc = NULL; pc=dynamic_cast<palCapsule *>(PF->CreateObject("palCapsule")); if (pc) { float radius=0.5f*ufrand()+0.05f; pc->Init(sfrand()*3,sfrand()*2+5.0f,sfrand()*3,radius,radius+ufrand()+0.1f,1); BuildGraphics(pc); } else { printf("Error: Could not create a cylinder\n"); } pb = pc; break; case SDLK_4: { int dist; dist = 3; float mult; mult = 1.0f; for (j=-dist;j<dist;j++) for (i=-dist;i<dist;i++) { pb = CreateBody("palBox",i*mult,5.0f,j*mult,0.25,0.25,0.25,1.0f); } pb = 0; } break; case SDLK_r: { int dist; dist = 3; float mult; mult = 1.0f; for (j=-dist;j<dist;j++) for (i=-dist;i<dist;i++) { pb = CreateBody("palStaticBox",i*mult,1.0f,j*mult,0.25,0.25,0.25,1.0f); } pb = 0; } break; case SDLK_5: x = sfrand()*3; y = sfrand()*2+3.0f; z = sfrand()*3; pcb = dynamic_cast<palCompoundBodyBase *>(PF->CreateObject("palCompoundBody")); if (!pcb) return; dynamic_cast<palCompoundBody *>(pcb)->Init(x,y,z); case SDLK_t: if (!pcb) { x = sfrand()*3; y = sfrand()*2+3.0f; z = sfrand()*3; pcb = dynamic_cast<palCompoundBodyBase *>(PF->CreateObject("palStaticCompoundBody")); if (!pcb) return; dynamic_cast<palStaticCompoundBody *>(pcb)->Init(x,y,z); } if (pcb) { palBoxGeometry *pbg; pbg = pcb->AddBox(); if (pbg) { palMatrix4x4 m; mat_identity(&m); mat_translate(&m,1+x,y,z); pbg->Init(m,1,1,1,1); } pbg = pcb->AddBox(); if (pbg) { palMatrix4x4 m; mat_identity(&m); mat_translate(&m,-1+x,y,z); pbg->Init(m,1,1,1,1); } pcb->Finalize(); BuildGraphics(pcb); } else { printf("Error: Could not create a compound body\n"); } pb = pcb; break; case SDLK_6: palConvex *pcv; pcv = NULL; pcv=dynamic_cast<palConvex *>(PF->CreateObject("palConvex")); if (pcv) { Float pVerts[(36+36+1)*3]; int nVerts = (36+36+1); MakeConvexCone(pVerts); pcv->Init(sfrand()*3,sfrand()*2+5.0f,sfrand()*3,pVerts,nVerts,1); // float radius=0.5f*ufrand()+0.05f; // pc->Init(sfrand()*3,sfrand()*2+5.0f,sfrand()*3,radius,radius+ufrand()+0.1f,1); BuildGraphics(pcv); } else { printf("Error: Could not create a convex object\n"); } pb = pcv; break; case SDLK_y: { palStaticConvex *pcv; pcv = NULL; pcv=dynamic_cast<palStaticConvex *>(PF->CreateObject("palStaticConvex")); if (pcv) { Float pVerts[(36+36+1)*3]; int nVerts = (36+36+1); MakeConvexCone(pVerts); pcv->Init(sfrand()*3,sfrand()*2+3.0f,sfrand()*3,pVerts,nVerts); // float radius=0.5f*ufrand()+0.05f; // pc->Init(sfrand()*3,sfrand()*2+5.0f,sfrand()*3,radius,radius+ufrand()+0.1f,1); BuildGraphics(pcv); } else { printf("Error: Could not create a static convex object\n"); } pb = pcv; } break; case SDLK_7: // palCompoundBody *pcb; pcb = NULL; pcb = dynamic_cast<palCompoundBody *>(PF->CreateObject("palCompoundBody")); if (pcb) { Float x = sfrand()*3; Float y = sfrand()*2+5.0f; Float z = sfrand()*3; dynamic_cast<palCompoundBody *>(pcb)->Init(x,y,z); Float pVerts[(36+36+1)*3]; int nVerts = (36+36+1); MakeConvexCone(pVerts); palConvexGeometry *pcg = 0; pcg = pcb->AddConvex(); if (pcg) { palMatrix4x4 m; mat_identity(&m); mat_translate(&m,1+x,y,z); pcg->Init(m,pVerts,nVerts,1); } pcg = pcb->AddConvex(); if (pcg) { palMatrix4x4 m; mat_identity(&m); mat_translate(&m,-1+x,y,z); pcg->Init(m,pVerts,nVerts,1); } pcb->Finalize(); BuildGraphics(pcb); } else { printf("Error: Could not create a convex object\n"); } pb = pcb; break; case SDLK_8: { if (bodies.size()>0) { int r= rand() % bodies.size(); palBody *body = dynamic_cast<palBody*>(bodies[r]); if (body) { body->SetPosition(sfrand()*3,sfrand()*2+5.0f,sfrand()*3,ufrand()*M_PI,ufrand()*M_PI,ufrand()*M_PI); body->SetActive(true); } } } break; case SDLK_9: if (bodies.size()>0) { DeleteGraphics(bodies[0]); delete bodies[0]; bodies.erase(bodies.begin()); } break; } if (pb) { bodies.push_back(pb); } break; } }