|
Hello,
Yep just another collision detection problem. I just
started programming in java3d, read the sun tutorial and the rawj3d
tutorial.
Now the problem I'm facing is quite simple. When the
view collides with the colorcube it has to print "in" and when it exits
"out".
So I used the TickTockCollision detector, but it only give
"in" when the application start (which is normal).
But when I navigate through the world and go through the
colorbox it doesn't respond, no event is triggered.
(Code is included at the bottom)
Can someone tell me what my mistake is, or give me an example
of a view colliding prog or shut I consider using picking ?
Thanx in advance,
Koen Vanderloock
Code :
--------
//objRoot = BranchGroup
TransformGroup test = new
TransformGroup();
objRoot.addChild(test); ColorCube cb = new
ColorCube();
cb.setCapability(ColorCube.ENABLE_COLLISION_REPORTING); test.addChild(cb); CollisionDetector cd = new
CollisionDetector(cb);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 1.0); cd.setSchedulingBounds(bounds); objRoot.addChild(cd); public class CollisionDetector extends Behavior
{ private boolean inCollision = false; private Shape3D shape; private WakeupOnCollisionEntry wEnter; private WakeupOnCollisionExit wExit; public CollisionDetector(Shape3D s) { shape = s; inCollision = false; } public void initialize()
{ wEnter = new WakeupOnCollisionEntry(shape,WakeupOnCollisionEntry.USE_BOUNDS ); wExit = new WakeupOnCollisionExit(shape,WakeupOnCollisionExit.USE_BOUNDS ); wakeupOn(wEnter); } public void processStimulus(Enumeration
criteria)
{ inCollision = !inCollision; if (inCollision)
{ System.out.println("in"); wakeupOn(wExit); } else { System.out.println("out"); wakeupOn(wEnter); } } } |
