Hi,
I am not sure this really is a bug or not, but I couldn't explain the
behavior of Java3D when I used wakeupOnCollisionDetection() to detect
collision between two objects.
The situation is as following:
I have a object which moves through a set of coordinates contained in an
array. I have attached one WakeupOnBehaviorPost object to the scenegraph.
The role of the WakeupOnBehaviorPost object is to move the object to a new
location based on the information contained in the array of coordinates.
Once the object has moved to its new position, a WakeupOnCollisionEntry
object is attached to the scenegraph during rum-time to perform collision
detection at the new position. Once the wakeupOnCollisionEntry() is
completed, the WakeupOnCollisionEntry object is detached from the
scenegraph.
This particular program structure is working perfectly at its first
iteration (when the object moves to its first location). But upon the
completion of the first iteration, when the object is moved to the second
location, the WakeupOnCollisionEntry object still reporting the collision
condition in the previous location.
Following is the code structure which I used:
/**
* Behavior which moves object to a new location and attach
WakeupOnCollisionEntry object to a live * scenegraph.
*/
public class CDMonitorAuto extends Behavior {
private WakeupCriterion myEvent;
private static int capCounter =1;
public static final int ID_CD_Completed = 9;
public void initialize() {
myEvent = new WakeupOnBehaviorPost(null, ID_CD_Completed);
wakeupOn(myEvent);
}
public void processStimulus (Enumeration criteria) {
/*Moves the object to a new location and attach
WakeupOnCollisionDetection to scenegraph*/
moveObjectToNewLocation_AND_attachedWakupOnCollisionEntryBehavior();
wakeupOn(myEvent);
}
}
/**
* WakeupOnCollisionEntry() behavior which performs collision detection for
an object.
*/
public class CollisionDetector extends Behavior {
private WakeupOnCollisionEntry wEnter_GEOMETRY;
public void initialize() {
wEnter_GEOMETRY = new WakeupOnCollisionEntry(shape3D,
wEnter_GEOMETRY.USE_GEOMETRY);
wakeupOn(wEnter_GEOMETRY);
}
public void processStimulus(Enumeration criteria) {
System.out.println("Collision detected");
/* activate CDMonitorAuto WakeupOnBehaviorPost object */
postId(9);
/* detach current WakeupOnCollisionEntry object from the
live scenegraph */
detachWakeupOnCollisionEntry();
}
}
Thanks,
Best regards,
Sunny Leung
email: [EMAIL PROTECTED]
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".