Example usage for javax.media.j3d Node ENABLE_COLLISION_REPORTING

List of usage examples for javax.media.j3d Node ENABLE_COLLISION_REPORTING

Introduction

In this page you can find the example usage for javax.media.j3d Node ENABLE_COLLISION_REPORTING.

Prototype

int ENABLE_COLLISION_REPORTING

To view the source code for javax.media.j3d Node ENABLE_COLLISION_REPORTING.

Click Source Link

Document

Specifies that this Node will be reported in the collision SceneGraphPath if a collision occurs.

Usage

From source file:KeyNavigateTest.java

public Group createObject(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile, String szCollisionSound) {
    m_TransformGroup = new TransformGroup();
    Transform3D t3d = new Transform3D();

    t3d.setScale(scale);//from  w  w w.j  av a2  s  . c  om
    t3d.setTranslation(position);

    m_TransformGroup.setTransform(t3d);

    m_BehaviorTransformGroup = new TransformGroup();

    if ((m_nFlags & GEOMETRY) == GEOMETRY)
        m_BehaviorTransformGroup
                .addChild(createGeometryGroup(app, position, scale, szTextureFile, szSoundFile));

    if ((m_nFlags & SOUND) == SOUND) {
        MediaContainer media = loadSoundFile(szSoundFile);
        PointSound pointSound = new PointSound(media, getSoundInitialGain(false), 0, 0, 0);
        setSoundAttributes(pointSound, false);
        m_BehaviorTransformGroup.addChild(pointSound);
    }

    if ((m_nFlags & COLLISION) == COLLISION) {
        m_BehaviorTransformGroup.setCapability(Node.ENABLE_COLLISION_REPORTING);
        m_BehaviorTransformGroup.setCollidable(true);
        m_BehaviorTransformGroup.setCollisionBounds(getGeometryBounds());

        if ((m_nFlags & COLLISION_SOUND) == COLLISION_SOUND) {
            MediaContainer collideMedia = loadSoundFile(szCollisionSound);

            m_CollideSound = new BackgroundSound(collideMedia, 1);
            setSoundAttributes(m_CollideSound, true);
            m_TransformGroup.addChild(m_CollideSound);
        }

        CollisionBehavior collision = new CollisionBehavior(m_BehaviorTransformGroup, this);
        collision.setSchedulingBounds(getGeometryBounds());

        m_BehaviorTransformGroup.addChild(collision);
    }

    m_TransformGroup.addChild(m_BehaviorTransformGroup);
    m_ParentGroup.addChild(m_TransformGroup);

    return m_BehaviorTransformGroup;
}