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

panda/src/collide/test_collide.cxx

Go to the documentation of this file.
00001 // Filename: test_collide.cxx
00002 // Created by:  drose (24Apr00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "collisionTraverser.h"
00020 #include "collisionNode.h"
00021 #include "collisionSphere.h"
00022 #include "collisionPlane.h"
00023 #include "collisionHandlerPusher.h"
00024 
00025 #include <namedNode.h>
00026 #include <pt_NamedNode.h>
00027 #include <pointerTo.h>
00028 #include <transformTransition.h>
00029 #include <luse.h>
00030 #include <get_rel_pos.h>
00031 #include <renderRelation.h>
00032 
00033 int
00034 main(int argc, char *argv[]) {
00035   PT_NamedNode r = new NamedNode("r");
00036 
00037   PT_NamedNode a = new NamedNode("a");
00038   PT_NamedNode b = new NamedNode("b");
00039 
00040   PT(CollisionNode) aa = new CollisionNode("aa");
00041   PT(CollisionNode) ab = new CollisionNode("ab");
00042   PT(CollisionNode) ba = new CollisionNode("ba");
00043 
00044   RenderRelation *r_a = new RenderRelation(r, a);
00045   RenderRelation *r_b = new RenderRelation(r, b);
00046 
00047   RenderRelation *a_aa = new RenderRelation(a, aa);
00048   RenderRelation *a_ab = new RenderRelation(a, ab);
00049   RenderRelation *b_ba = new RenderRelation(b, ba);
00050 
00051 
00052   CollisionSphere *aa1 = new CollisionSphere(LPoint3f(0, 0, 0), 1);
00053   aa->add_solid(aa1);
00054   a_aa->set_transition(new TransformTransition(LMatrix4f::translate_mat(0, -5, 0)));
00055 
00056   CollisionSphere *ab1 = new CollisionSphere(LPoint3f(0, 2, 0), 1.5);
00057   ab->add_solid(ab1);
00058 
00059   Planef plane(LVector3f(0, 1, 0), LPoint3f(0, 0, 0));
00060   CollisionPlane *ba1 = new CollisionPlane(plane);
00061   ba->add_solid(ba1);
00062 
00063   CollisionTraverser ct;
00064   PT(CollisionHandlerPusher) chp = new CollisionHandlerPusher;
00065   chp->add_collider(aa, a_aa);
00066   ct.add_collider(aa, chp);
00067 
00068   ct.traverse(r);
00069 
00070   nout << "\nFrame 2:\n\n";
00071 
00072   ct.traverse(r);
00073 
00074   return (0);
00075 }
00076 

Generated on Fri May 2 00:35:49 2003 for Panda by doxygen1.3