problem with WakeupOnCollisionEntry
i am willing to write a simple code with 2 Shape3D objects ( 2 Text3D signs in my case), added 2 Behavior classes, each one connected with one Text3D object respectively. One moves the text on mouse click and i want the other to react when moving text collides with it.
significant pieces of code :
1st Behavior class
publicclass SimpleBehaviorextends Behavior (the one that moves obj1)
{
private TransformGroup targetTG;
private WakeupCriterion wakeupNextFrame;
private Transform3D rotation =new Transform3D();
privatedouble angle = 0.0, x = 0.2, angle2;
SimpleBehavior(TransformGroup targetTG)
{
this.targetTG = targetTG;
wakeupNextFrame =new WakeupOnElapsedFrames(1);
}
publicvoid initialize()
{
//this.wakeupOn(new WakeupOnCollisionEntry(getBounds()));
this.wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED));
angle = 0.0f;
angle2 = 10;
x = 0.2;
}
publicvoid processStimulus(Enumeration criteria)
{
if (angle < angle2)
{
x = x + 0.01;
angle += x;
rotation.setTranslation(new Vector3d(-angle, 0, 0));
targetTG.setTransform(rotation);
this.wakeupOn(wakeupNextFrame);
}
else
{
//angle = 0;
angle2 = angle2 + 10;
x = 0.2;
this.wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED));
}
}
}
2nd Behavior class that would use wakeUpOnCollisionEntry criteria
publicclass SimpleBehavior2extends Behavior
{
private TransformGroup targetTG;
private WakeupCriterion wakeupNextFrame;
private Transform3D rotation =new Transform3D();
privatedouble angle = 0.0, x = 0.2, angle2;
SimpleBehavior2(TransformGroup targetTG)
{
this.targetTG = targetTG;
wakeupNextFrame =new WakeupOnElapsedFrames(5);
}
publicvoid initialize()
{
this.wakeupOn(new WakeupOnCollisionEntry(new BoundingSphere()));
angle = 0.0f;
angle2 = 10;
x = 0.2;
}
publicvoid processStimulus(Enumeration criteria)
{
if (angle < angle2)
{
x = x + 0.01;
angle += x;
rotation.setTranslation(new Vector3d(-angle, 0, 0));
targetTG.setTransform(rotation);
this.wakeupOn(wakeupNextFrame);
}
else
{
angle2 = angle2 + 10;
x = 0.2;
this.wakeupOn(new WakeupOnCollisionEntry(new BoundingSphere()));
}
}
}
how can i rewrite the second class to react the way i want to ?
really appreciate any help, can throw more code in if neccesary
Best regards, Lukasz

