Jennifer

Once the first object has collided with the second, it won't pick up any
further collisions until it's no longer in collision with the second anyway.
Unless you mean that after the collision, the first object is not allowed to
collide with another one, even after the collision is cleared, in which
case, just don't reset the collision wakeup.

Tony

-----Original Message-----
From: Jennifer Mc Gann [mailto:[EMAIL PROTECTED]]
Sent: 19 November 2002 16:51
To: [EMAIL PROTECTED]
Subject: [JAVA3D] Behaviours and loaded files


Hi there,
This is the first time I've used this support so here
goes....

I am creating a collision behaviour between two
objects which are both loaded into a file. The
behaviour is in a seperate file and goes along the
lines of the following:

import java.util.*;
import javax.media.j3d.*;
import java.awt.event.*;
import java.awt.*;
import javax.vecmath.*;

public class DropperBehaviourTest extends Behavior {
/** The shape that is being watched for collisions. */
protected Node collidingObject;
/** The separate criteria that trigger this behaviour
*/
protected WakeupCriterion[] theCriteria;
/** The result of the 'OR' of the separate criteria */
protected WakeupAnd andedCriteria;
/** The switch that is used to swap the dropper shapes
*/
protected Switch theSwitch;
/** The alpha generator that drives the animation */
//protected Alpha theTargetAlpha;
/** Defines whether the dropper is empty or full */
protected boolean full = false;


/**
* This sets up the data for the behaviour.
* @param theShape Node that is to be watched for
collisions.
* @param sw Switch that is used to swap shapes.
* @param a1 Alpha that drives the dropper's animation.
* @param theBounds Bounds that define the active
region for this behaviour.
*/
public DropperBehaviourTest(Node theObject, Switch sw,
Bounds theBounds ) {
collidingObject = theObject;
theSwitch = sw;


setSchedulingBounds(theBounds);


//Create the bounding leaf node
BoundingSphere thebounds =
new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
BoundingLeaf boundingLeaf = new
BoundingLeaf(thebounds);


}

/**
* This sets up the criteria for triggering the
behaviour.
* It creates an collision crtiterion and a mouse event
criterion, AND's these
* together and then sets the AND'ed criterion as the
wake up
* condition.
*/
public void initialize() {
theCriteria = new WakeupCriterion[2];
theCriteria[0] = new
WakeupOnCollisionEntry(collidingObject);
theCriteria[1] = new WakeupOnAWTEvent(
MouseEvent.MOUSE_RELEASED );


andedCriteria = new WakeupAnd(theCriteria);
wakeupOn(andedCriteria);
}

/**
* This is where the work is done.
* If there is a collision, then if the dropper is
* empty we switch to the full dropper. If the dropper
* was already full then we take no action.

* The other case we need to check for is when the
* alpha value is zero, when we need to set the duck
back
* to the live one for its next traversal of the
screen.

* Finally, the wake up condition is set
* to be the OR'ed criterion again.
*/
public void processStimulus(Enumeration criteria) {
while (criteria.hasMoreElements()) {
WakeupCriterion theCriterion = (WakeupCriterion)
criteria.nextElement();
if (theCriterion instanceof WakeupOnCollisionEntry) {
//If there's a collsion and the dropper is empty then
swap
//it to the full one
if (full == false) {
theSwitch.setWhichChild(1);
full = true;
}
}

}
wakeupOn(andedCriteria);
}
}


My problem is that I don't know to make the behaviour
aware that it is only supposed to work when the first
object collides with the second object and no other
one?
Can anyone help with this?
Thanks in advance,
Regards,
Jennifer.


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

===========================================================================
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".

===========================================================================
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".

Reply via email to