Skip to main content

Collision between moving objects

1 reply [Last post]
AlvaroPFC
Offline
Joined: 2011-10-12
Points: 0

Hi All,
I'm doing my FPC with Java3d and I'm having big problems with the detection of a collision between two objects in movement. This is the first time I post, and I don't know what can I do.

Please, anybody can helps me??

The first code is for the collision detector:

public class Colision extends Behavior {

protected WakeupCriterion[] Criteria;
protected WakeupOr oredCriteria;
protected Node collidingNode;
protected TransformGroup trChange;
protected JTextArea area;

public Colision(TransformGroup tr, JTextArea areaCol) {
this.collidingNode = tr;
this.trChange = tr;
this.area = areaCol;
setSchedulingBounds(new BoundingSphere(new Point3d(0.0, 0.0,
0.0), 3.0));
}

// public Colision(Primitive plane, JTextArea areaCol) {
// this.collidingNode = plane;
// this.area = areaCol;
// setSchedulingBounds(new BoundingSphere(new Point3d(0.0, 0.0,
// 0.0), 3.0));
// }

public void initialize() {

// inicializar colisiones
Criteria = new WakeupCriterion[3];
Criteria[0] = new WakeupOnCollisionEntry(collidingNode);
Criteria[1] = new WakeupOnCollisionExit(collidingNode);
Criteria[2] = new WakeupOnMovement(collidingNode);
oredCriteria = new WakeupOr(Criteria);
wakeupOn(oredCriteria);

}

public void processStimulus(Enumeration criteria) {
while (criteria.hasMoreElements()) {
WakeupCriterion wakeup = (WakeupCriterion) criteria.nextElement();
//ENTRA COLISION
if (wakeup instanceof WakeupOnCollisionEntry)
{
Node theLeaf = ((WakeupOnCollisionEntry) wakeup).getTriggeringPath().getObject().getParent( );
System.out.println("inicio a colisionar con: "+ this.collidingNode.getUserData());
area.append("Colision entry ->" + System.currentTimeMillis() + " " +this.collidingNode.getUserData()+ "\n");
}
//DEJA COLISION
} else if (wakeup instanceof WakeupOnCollisionExit) {
Node theLeaf = ((WakeupOnCollisionExit) wakeup).getTriggeringPath().getObject().getParent( );
System.out.println("dejo de colisionar con:" + theLeaf);
area.append("Colision exit <-\n");
//COLISION
} else
if (wakeup instanceof WakeupOnCollisionMovement) {
Node theLeaf = ((WakeupOnCollisionMovement) wakeup).getTriggeringPath().getObject().getParent( );
area.append("Se mueve...\n");
}
wakeupOn(oredCriteria);
}
}
}

This code is the scenegraph where the objects are:

public class Interaction_1 extends MouseAdapter
{

private int animVel = 9000;
private JPanel pan;
private float planeRadius;
private float distView;

private FlightsArray m_oFlightArr = null;
private JTextArea areaColision;
private BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0,
0.0), 3.0);
private Canvas3D m_oCanvas;
private PickCanvas m_oPickCanvas;
private JTextArea txtArea_RealInfo;
private JTextArea txtArea_SolutionInfo;
// private Colision co;
private String m_sTrack;

public Interaction_1(JPanel panel, float rad, float dView, FlightsArray fA, JTextArea areaCol, Canvas3D canvas, JTextArea areaRealInfo, JTextArea areaSolInfo, String track)
{
this.pan = panel;
this.planeRadius = rad;
this.distView = dView;
this.m_oFlightArr = fA;
this.areaColision = areaCol;
this.m_oCanvas = canvas;
this.txtArea_RealInfo = areaRealInfo;
this.txtArea_SolutionInfo = areaSolInfo;
this.m_sTrack = track;
}

private TransformGroup createPlane(int id, JPanel pan, float planeRadius)
{
//establecemos la apariencia del cilindro
Appearance ap = new Appearance();
TransparencyAttributes ta = new TransparencyAttributes(TransparencyAttributes.FAST EST, 0.0f); // 5.0f
ap.setTransparencyAttributes(ta);
TextureLoader tex = new TextureLoader("images/plane.gif", pan);
ImageComponent2D im = tex.getImage();
//vamos a dar el color al cilindro
Color3f col = new Color3f(Color.RED);
ColoringAttributes ca = new ColoringAttributes(col, ColoringAttributes.FASTEST);
ap.setColoringAttributes(ca);
//creamos el cilindro con la apariencia dada
Cylinder cy = new Cylinder(planeRadius, 0f, Primitive.GENERATE_TEXTURE_COORDS, ap);
cy.setName("Plane_"+this.m_oFlightArr.getFlightVec ()[id].getnFlight());
//rotamos el objeto para que pase de vertical a horizontal
Transform3D rot0 = new Transform3D();
rot0.rotX(Math.PI/2.0d);
rot0.setScale(5.0f);
TransformGroup tf0 = new TransformGroup(rot0);
tf0.addChild(cy);

Colision co = new Colision(tf0, areaColision); //getShape(1) te devuelve el TOP del cilindro
co.setSchedulingBounds(bounds);
tf0.addChild(co);

return tf0;
}

private TransformGroup drawMovPlane(String track, int f, ArrayList fList, Transform3D axisOfPos)
{
int tam = this.m_oFlightArr.getLeng();
float[] knotsArray = new float[tam];
TransformGroup tf = new TransformGroup();
int i = 0;
float paso;

Alpha m_alpha = new Alpha(1, Alpha.INCREASING_ENABLE, 0, 0, animVel, 0, 0, 0, 0, 0);

//los knots son los intervalos de tiempo en los que se va a producir el movimiento
knotsArray = new float[fList.size()];
knotsArray[0] = 0.0f;
paso = 1.0f/(fList.size()-1);
//calculamos los knots sabiendo que el primero empieza en 0 y el ultimo acaba en 1
for(int iter = 1; iter< fList.size()-1; iter++)
{
knotsArray[iter] = paso + knotsArray[iter-1];
}
knotsArray[fList.size()-1] = 1.0f;

//los TransformGroup para cada avion sobre el que se generara los ptos del movimiento

//para guardar los ptos del movimiento -o knots- hay que marcarle esta opcion
tf.setCapability(TransformGroup.ALLOW_TRANSFORM_WR ITE);

Point3f[] positionsArray = new Point3f[fList.size()];
i=0;
Iterator it = fList.iterator();
while(it.hasNext())
{
Point2f p2 = new Point2f();
p2 = (Point2f)it.next();
positionsArray[i] = new Point3f(p2.x, p2.y, distView);
i++;
}

PositionPathInterpolator rotPosPath1 =
new PositionPathInterpolator(m_alpha, tf, axisOfPos, knotsArray, positionsArray);
rotPosPath1.setSchedulingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0), 2000.0));
/* PositionPathInterpolator parameters:
alpha - the alpha object for this interpolator
target - the TransformGroup node affected by this translator
axisOfTransform - the transform that defines the local coordinate system in which this interpolator operates
knots - an array of knot values that specify interpolation points.
positions - an array of position values at the knots.
*/

tf.addChild(rotPosPath1);

tf.addChild(createPlane(f, this.pan, this.planeRadius));

// PointArray point_geom1 = new PointArray(fList.size(), GeometryArray.COORDINATES);

return tf;
}

public void drawTracks(BranchGroup objRoot, String track)
{

ArrayList fList = null;

BranchGroup bgMovement = new BranchGroup();

// TransformGroup tgMov = new TransformGroup();
// tgMov.setUserData("aeropuerto_tgMov");
// tgMov.setCapability(TransformGroup.ENABLE_COLLISIO N_REPORTING);
// Colision co = new Colision(tgMov, areaColision); //getShape(1) te devuelve el TOP del cilindro
// co.setSchedulingBounds(bounds);
// tgMov.addChild(co);

//AxisAngle4f axis = the transform that defines the local coordinate system in which this interpolator operates
Transform3D axisOfPos = new Transform3D();
AxisAngle4f axis = new AxisAngle4f(1.0f,0.0f,0.0f,0.0f);
axisOfPos.set(axis);
TransformGroup tGroup = new TransformGroup();

for(int f = 0; f < m_oFlightArr.getLeng(); f++)
{
if(track.equals("inicial"))
fList = m_oFlightArr.getFlightVec()[f].getPositionsIniList();
else // (track.equals("solucion"))
fList = m_oFlightArr.getFlightVec()[f].getPositionsSolList();

tGroup.addChild(drawMovPlane(track, f, fList, axisOfPos));

}
bgMovement.addChild(tGroup);

bgMovement.compile();

objRoot.addChild(bgMovement);
objRoot.compile();

}
}

Thanks a lot, and sorry for my english.
I wait for your responses,
Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
AlvaroPFC
Offline
Joined: 2011-10-12
Points: 0

Now, I do others class but it still does not detect collisions while the cylinder moves



What I'm doing wrong??

Java3d Code:
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-style: inherit; "><span style="color: rgb(0, 0, 0); "><span style="color: rgb(0, 119, 0); ">public class </span><span style="color: rgb(0, 0, 187); ">AircraftMov </span><span style="color: rgb(0, 119, 0); ">{ <br />
     <br />
    private </span><span style="color: rgb(0, 0, 187); ">BranchGroup branchGroup</span><span style="color: rgb(0, 119, 0); ">; <br />
<br />
    </span><span style="color: rgb(0, 0, 187); ">Cylinder cy</span><span style="color: rgb(0, 119, 0); ">; <br />
     <br />
    public </span><span style="color: rgb(0, 0, 187); ">AircraftMov</span><span style="color: rgb(0, 119, 0); ">() { <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">branchGroup </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">BranchGroup</span><span style="color: rgb(0, 119, 0); ">(); <br />
        </span><span style="color: rgb(0, 0, 187); ">Appearance app </span><span style="color: rgb(0, 119, 0); ">= new  </span><span style="color: rgb(0, 0, 187); ">Appearance</span><span style="color: rgb(0, 119, 0); ">(); <br />
        </span><span style="color: rgb(0, 0, 187); ">app</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">setMaterial</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">getMaterial</span><span style="color: rgb(0, 119, 0); ">()); <br />
        </span><span style="color: rgb(0, 0, 187); ">cy </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">Cylinder</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">0.3f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.3f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">Cylinder</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">GENERATE_NORMALS</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">app</span><span style="color: rgb(0, 119, 0); ">); <br />
<br />
        </span><span style="color: rgb(0, 0, 187); ">Transform3D rot0 </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">Transform3D</span><span style="color: rgb(0, 119, 0); ">(); <br />
        </span><span style="color: rgb(0, 0, 187); ">rot0</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">setScale</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">0.5f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">TransformGroup tf0 </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">TransformGroup</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">rot0</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">TransformGroup tfMov </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">TransformGroup</span><span style="color: rgb(0, 119, 0); ">(); <br />
        </span><span style="color: rgb(0, 0, 187); ">tfMov </span><span style="color: rgb(0, 119, 0); ">= </span><span style="color: rgb(0, 0, 187); ">movementAircraft</span><span style="color: rgb(0, 119, 0); ">(); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">tfMov</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">addChild</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">cy</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">CollisionBehavior colision </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">CollisionBehavior</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">cy</span><span style="color: rgb(0, 119, 0); ">, new </span><span style="color: rgb(0, 0, 187); ">BoundingSphere</span><span style="color: rgb(0, 119, 0); ">(new </span><span style="color: rgb(0, 0, 187); ">Point3d</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">0.0</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0</span><span style="color: rgb(0, 119, 0); ">, <br />
      </span><span style="color: rgb(0, 0, 187); ">0.0</span><span style="color: rgb(0, 119, 0); ">), </span><span style="color: rgb(0, 0, 187); ">3.0</span><span style="color: rgb(0, 119, 0); ">), </span><span style="color: rgb(0, 0, 187); ">null</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">branchGroup</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">addChild</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">colision</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">tf0</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">addChild</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">tfMov</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">branchGroup</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">addChild</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">tf0</span><span style="color: rgb(0, 119, 0); ">);  <br />
    } <br />
<br />
    public </span><span style="color: rgb(0, 0, 187); ">BranchGroup getBranchGroup</span><span style="color: rgb(0, 119, 0); ">(){ <br />
        return </span><span style="color: rgb(0, 0, 187); ">branchGroup</span><span style="color: rgb(0, 119, 0); ">; <br />
    } <br />
<br />
    public </span><span style="color: rgb(0, 0, 187); ">Primitive getCylinder</span><span style="color: rgb(0, 119, 0); ">() <br />
    { <br />
        return </span><span style="color: rgb(0, 0, 187); ">this</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">cy</span><span style="color: rgb(0, 119, 0); ">; <br />
    } <br />
     <br />
    private </span><span style="color: rgb(0, 0, 187); ">Material getMaterial</span><span style="color: rgb(0, 119, 0); ">(){ <br />
        </span><span style="color: rgb(0, 0, 187); ">Material mat </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">Material</span><span style="color: rgb(0, 119, 0); ">(); <br />
        </span><span style="color: rgb(0, 0, 187); ">mat</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">setAmbientColor</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">0.6f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.3f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.6f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">mat</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">setDiffuseColor</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">0.7f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.8f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.9f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">mat</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">setLightingEnable</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">true</span><span style="color: rgb(0, 119, 0); ">); <br />
        return </span><span style="color: rgb(0, 0, 187); ">mat</span><span style="color: rgb(0, 119, 0); ">; <br />
    } <br />
     <br />
    private </span><span style="color: rgb(0, 0, 187); ">TransformGroup movementAircraft</span><span style="color: rgb(0, 119, 0); ">() <br />
    { <br />
        </span><span style="color: rgb(0, 0, 187); ">TransformGroup tf </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">TransformGroup</span><span style="color: rgb(0, 119, 0); ">(); <br />
        </span><span style="color: rgb(0, 0, 187); ">tf</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">setCapability</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">TransformGroup</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">ALLOW_TRANSFORM_WRITE</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">Alpha alpha </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">Alpha</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">1</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">Alpha</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">INCREASING_ENABLE</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">9000</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">float</span><span style="color: rgb(0, 119, 0); ">[] </span><span style="color: rgb(0, 0, 187); ">knots </span><span style="color: rgb(0, 119, 0); ">= {</span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.125f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.25f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.375f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.5f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.625f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.75f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.875f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">1.0f</span><span style="color: rgb(0, 119, 0); ">}; <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">[] </span><span style="color: rgb(0, 0, 187); ">positions </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">9</span><span style="color: rgb(0, 119, 0); ">]; <br />
        </span><span style="color: rgb(255, 128, 0); ">//Movimiento de izda a dcha <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  -</span><span style="color: rgb(0, 0, 187); ">2.0f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">1</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  -</span><span style="color: rgb(0, 0, 187); ">1.5f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">2</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  -</span><span style="color: rgb(0, 0, 187); ">1.0f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">3</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  -</span><span style="color: rgb(0, 0, 187); ">0.5f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">4</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">5</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  </span><span style="color: rgb(0, 0, 187); ">0.5f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">6</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  </span><span style="color: rgb(0, 0, 187); ">1.0f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">7</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  </span><span style="color: rgb(0, 0, 187); ">1.5f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">8</span><span style="color: rgb(0, 119, 0); ">]= new </span><span style="color: rgb(0, 0, 187); ">Point3f</span><span style="color: rgb(0, 119, 0); ">(  </span><span style="color: rgb(0, 0, 187); ">2.0f</span><span style="color: rgb(0, 119, 0); ">,  </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">Transform3D axisOfPos </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">Transform3D</span><span style="color: rgb(0, 119, 0); ">(); <br />
        </span><span style="color: rgb(0, 0, 187); ">AxisAngle4f axis </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">AxisAngle4f</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">1.0f</span><span style="color: rgb(0, 119, 0); ">,</span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">,</span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">,</span><span style="color: rgb(0, 0, 187); ">0.0f</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">axisOfPos</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">set</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">axis</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">PositionPathInterpolator posPath </span><span style="color: rgb(0, 119, 0); ">=  <br />
                new </span><span style="color: rgb(0, 0, 187); ">PositionPathInterpolator</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">alpha</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">tf</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">axisOfPos</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">knots</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">positions</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">posPath</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">setSchedulingBounds</span><span style="color: rgb(0, 119, 0); ">(new </span><span style="color: rgb(0, 0, 187); ">BoundingSphere</span><span style="color: rgb(0, 119, 0); ">(new </span><span style="color: rgb(0, 0, 187); ">Point3d</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">0.0</span><span style="color: rgb(0, 119, 0); ">,</span><span style="color: rgb(0, 0, 187); ">0.0</span><span style="color: rgb(0, 119, 0); ">,</span><span style="color: rgb(0, 0, 187); ">0.0</span><span style="color: rgb(0, 119, 0); ">), </span><span style="color: rgb(0, 0, 187); ">1000.0</span><span style="color: rgb(0, 119, 0); ">)); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">tf</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">addChild</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">posPath</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
        return </span><span style="color: rgb(0, 0, 187); ">tf</span><span style="color: rgb(0, 119, 0); ">; <br />
    } <br />
}  <br />
</span></span>

Class Collision:

Java3d Code:
<code style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-style: inherit; "><span style="color: rgb(0, 0, 0); "><span style="color: rgb(0, 119, 0); ">class </span><span style="color: rgb(0, 0, 187); ">CollisionBehavior </span><span style="color: rgb(0, 119, 0); ">extends </span><span style="color: rgb(0, 0, 187); ">Behavior <br />
</span><span style="color: rgb(0, 119, 0); ">{ <br />
    </span><span style="color: rgb(255, 128, 0); ">//the wake up condition for the behavior <br />
    </span><span style="color: rgb(0, 119, 0); ">protected </span><span style="color: rgb(0, 0, 187); ">WakeupCriterion</span><span style="color: rgb(0, 119, 0); ">[] </span><span style="color: rgb(0, 0, 187); ">theCriteria</span><span style="color: rgb(0, 119, 0); ">; <br />
     <br />
    protected </span><span style="color: rgb(0, 0, 187); ">WakeupOr m_oredCriteria</span><span style="color: rgb(0, 119, 0); ">; <br />
      <br />
    protected </span><span style="color: rgb(0, 0, 187); ">Primitive cilindro</span><span style="color: rgb(0, 119, 0); ">; <br />
     <br />
    public </span><span style="color: rgb(0, 0, 187); ">CollisionBehavior</span><span style="color: rgb(0, 119, 0); ">( </span><span style="color: rgb(0, 0, 187); ">Primitive aircraft</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">Bounds theBounds</span><span style="color: rgb(0, 119, 0); ">) <br />
    { <br />
        </span><span style="color: rgb(0, 0, 187); ">cilindro </span><span style="color: rgb(0, 119, 0); ">= </span><span style="color: rgb(0, 0, 187); ">aircraft</span><span style="color: rgb(0, 119, 0); ">; <br />
        </span><span style="color: rgb(0, 0, 187); ">setBounds</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">theBounds</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
    } <br />
    public </span><span style="color: rgb(0, 0, 187); ">void initialize</span><span style="color: rgb(0, 119, 0); ">() <br />
    { <br />
        </span><span style="color: rgb(0, 0, 187); ">theCriteria </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">WakeupCriterion</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">2</span><span style="color: rgb(0, 119, 0); ">]; <br />
        </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionEntry startsCollision </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionEntry</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">cilindro</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionEntry</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">USE_GEOMETRY</span><span style="color: rgb(0, 119, 0); ">);<br />
        </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionExit endsCollision </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionExit</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">cilindro</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionEntry</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">USE_GEOMETRY</span><span style="color: rgb(0, 119, 0); ">); <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">theCriteria</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">0</span><span style="color: rgb(0, 119, 0); ">] = </span><span style="color: rgb(0, 0, 187); ">startsCollision</span><span style="color: rgb(0, 119, 0); ">; <br />
        </span><span style="color: rgb(0, 0, 187); ">theCriteria</span><span style="color: rgb(0, 119, 0); ">[</span><span style="color: rgb(0, 0, 187); ">1</span><span style="color: rgb(0, 119, 0); ">] = </span><span style="color: rgb(0, 0, 187); ">endsCollision</span><span style="color: rgb(0, 119, 0); ">; <br />
         <br />
        </span><span style="color: rgb(0, 0, 187); ">m_oredCriteria </span><span style="color: rgb(0, 119, 0); ">= new </span><span style="color: rgb(0, 0, 187); ">WakeupOr</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">theCriteria</span><span style="color: rgb(0, 119, 0); ">); <br />
        </span><span style="color: rgb(0, 0, 187); ">wakeupOn</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">m_oredCriteria</span><span style="color: rgb(0, 119, 0); ">); <br />
    } <br />
<br />
    public </span><span style="color: rgb(0, 0, 187); ">void processStimulus</span><span style="color: rgb(0, 119, 0); ">( </span><span style="color: rgb(0, 0, 187); ">java</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">util</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">Enumeration criteria </span><span style="color: rgb(0, 119, 0); ">) <br />
    { <br />
       while (</span><span style="color: rgb(0, 0, 187); ">criteria</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">hasMoreElements</span><span style="color: rgb(0, 119, 0); ">()) { <br />
            </span><span style="color: rgb(0, 0, 187); ">WakeupCriterion wakeup </span><span style="color: rgb(0, 119, 0); ">= (</span><span style="color: rgb(0, 0, 187); ">WakeupCriterion</span><span style="color: rgb(0, 119, 0); ">) </span><span style="color: rgb(0, 0, 187); ">criteria</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">nextElement</span><span style="color: rgb(0, 119, 0); ">(); <br />
</span><span style="color: rgb(255, 128, 0); ">//ENTRA COLISION <br />
            </span><span style="color: rgb(0, 119, 0); ">if (</span><span style="color: rgb(0, 0, 187); ">wakeup </span><span style="color: rgb(0, 119, 0); ">instanceof </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionEntry</span><span style="color: rgb(0, 119, 0); ">) { <br />
<br />
                </span><span style="color: rgb(0, 0, 187); ">System</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">out</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">println</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(221, 0, 0); ">&quot;inicio a colisionar con:&quot;</span><span style="color: rgb(0, 119, 0); ">); <br />
                </span><span style="color: rgb(0, 0, 187); ">JOptionPane</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">showMessageDialog</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">null</span><span style="color: rgb(0, 119, 0); ">, </span><span style="color: rgb(221, 0, 0); ">&quot;Entra en Colision!&quot;</span><span style="color: rgb(0, 119, 0); ">); <br />
<br />
</span><span style="color: rgb(255, 128, 0); ">//DEJA COLISION <br />
            </span><span style="color: rgb(0, 119, 0); ">} else if (</span><span style="color: rgb(0, 0, 187); ">wakeup </span><span style="color: rgb(0, 119, 0); ">instanceof </span><span style="color: rgb(0, 0, 187); ">WakeupOnCollisionExit</span><span style="color: rgb(0, 119, 0); ">) { <br />
<br />
                </span><span style="color: rgb(0, 0, 187); ">System</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">out</span><span style="color: rgb(0, 119, 0); ">.</span><span style="color: rgb(0, 0, 187); ">println</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(221, 0, 0); ">&quot;dejo de colisionar con:&quot;</span><span style="color: rgb(0, 119, 0); ">); <br />
</span><span style="color: rgb(255, 128, 0); ">//COLISION <br />
            </span><span style="color: rgb(0, 119, 0); ">}  <br />
        } <br />
        </span><span style="color: rgb(0, 0, 187); ">wakeupOn</span><span style="color: rgb(0, 119, 0); ">(</span><span style="color: rgb(0, 0, 187); ">m_oredCriteria</span><span style="color: rgb(0, 119, 0); ">); <br />
    } <br />
}  <br />
</span></span>

In the scenegraph there are one static cylinder and other moving cylinder.

But the moving cylinder does not collides with the other cylinder .