Raghav,

    It works fine as expected (run the attach program).
Try to debug your program to see if it is cause by others.

- Kelvin
-----------------
Java 3D Team
Sun Microsystems Inc.



Raghavendra R wrote:
> Hi Kelvin,
>
> I am calling  wakeupOn (mMouseCriterion) at the end of processStimulus
> function. The JDK and Java3D versions are JDK 1.4.0_01 and Java3D 1.3.1.
> respectively. Infact, i have tried on JDK 1.3.1, JDK 1.4.1 also with the
> same results. I have attached the behavior class in this mail for your
> reference.
>
> Thanks
> Raghav
>
> Kelvin Chung wrote:
>
>  > Raghavendra R wrote:
>  >
>  >> Hi,
>  >>
>  >> I have called the setSchedulingBounds as follows.
>  >>
>  >> setSchedulingBounds(new BoundingSphere(new Point3d(),
>  >> Double.MAX_VALUE)) ;
>  >>
>  >
>  > From your email it seems you get at least one mouse event but not
>  > others. Check to see if you invoke wakeupOn() after the mouse event
>  > is process in processStimulus(). If still not work please
>  > send us a test case and the JDK version you're using.
>  >
>  > - Kelvin
>  > ---------------
>  > Java 3D Team
>  > Sun Microsystems Inc.
>  >
>  >>
>  >>
>  >> Kelvin Chung wrote:
>  >>
>  >>>
>  >>>
>  >>> Raghavendra R wrote:
>  >>>
>  >>>> Hi,
>  >>>>
>  >>>> I have an application for selecting a set of entities using polygon
>  >>>> pick
>  >>>> by enclosing these entities in a polygon drawn on a Canvas3D. I have
>  >>>> attached WakeupOnAWTEvent for getting Mouse behaviors like Mouse
>  >>>> press /
>  >>>> click / drag etc. Till now, i was using Java3D 1.1.3 and it was
>  >>>> working
>  >>>> well.
>  >>>>
>  >>>> Recently i upgraded the Java3D from 1.1.3 to 1.3.1. Now, i am
>  >>>> unable to get more than one mouse press event in my processStimulus
>  >>>> callback.
>  >>>>
>  >>>> Are there any changes in Behavior / AWT event handling /
>  >>>> Wakeup etc from J3d 1.1.3 to 1.3.1 that may be causing my problem?
>  >>>>
>  >>>> Thanks
>  >>>> Raghav
>  >>>>
>  >>> Make sure either
>  >>>
>  >>> (i) setSchedulingBounds(Bounds region) is set and this
>  >>>     bound intersect the view platform activation region.
>  >>>
>  >>>     As an experiment set region to a very big bounds to
>  >>>     see what happen.
>  >>>
>  >>> OR
>  >>>
>  >>> (ii)  setSchedulingBoundingLeaf(BoundingLeaf region) is set
>  >>>      and this BoundingLeaf is ATTACH to the scene graph.
>  >>>
>  >>>      There is bug in previous version of Java3D that the
>  >>>      behavior is schedule even though bounding leaf is not
>  >>>      attach to scenegraph. This is fixed in current release.
>  >>>      This bug also appear in the old VRML97 class which you
>  >>>      will encounter behavior not function at all after update.
>  >>>
>  >>> - Kelvin
>  >>> -----------
>  >>> Java 3D Team
>  >>> Sun Microsystems Inc.
>  >>>
>  >>>
>  >>>
>  >>
>  >>
> ===========================================================================
>  >>
>  >> 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".
>  >
>  >
>
>

/*
 *      %Z%%M% %I% %E% %U%
 *
 * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * - Redistribution in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in
 *   the documentation and/or other materials provided with the
 *   distribution.
 *
 * Neither the name of Sun Microsystems, Inc. or the names of
 * contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * This software is provided "AS IS," without a warranty of any
 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
 * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
 * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
 * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
 * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *
 * You acknowledge that Software is not designed,licensed or intended
 * for use in the design, construction, operation or maintenance of
 * any nuclear facility.
 */

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class HelloUniverse extends Applet {

    private SimpleUniverse u = null;

    public BranchGroup createSceneGraph() {
        // Create the root of the branch graph
        BranchGroup objRoot = new BranchGroup();

        // Create the TransformGroup node and initialize it to the
        // identity. Enable the TRANSFORM_WRITE capability so that
        // our behavior code can modify it at run time. Add it to
        // the root of the subgraph.
        TransformGroup objTrans = new TransformGroup();
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objRoot.addChild(objTrans);

        // Create a simple Shape3D node; add it to the scene graph.
        objTrans.addChild(new ColorCube(0.4));

        // Create a new Behavior object that will perform the
        // desired operation on the specified transform and add
        // it into the scene graph.
        Transform3D yAxis = new Transform3D();
        Alpha rotationAlpha = new Alpha(-1, 4000);

        TestBehavior behavior = new TestBehavior();

        BoundingSphere bounds =
            new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);

        objRoot.addChild(behavior);

        // Have Java 3D perform optimizations on this scene graph.
        objRoot.compile();

        return objRoot;
    }

    public HelloUniverse() {
    }

    public void init() {
        setLayout(new BorderLayout());
        GraphicsConfiguration config =
           SimpleUniverse.getPreferredConfiguration();

        Canvas3D c = new Canvas3D(config);
        add("Center", c);

        // Create a simple scene and attach it to the virtual universe
        BranchGroup scene = createSceneGraph();
        u = new SimpleUniverse(c);

        // This will move the ViewPlatform back a bit so the
        // objects in the scene can be viewed.
        u.getViewingPlatform().setNominalViewingTransform();

        u.addBranchGraph(scene);
    }

    public void destroy() {
        u.removeAllLocales();
    }

    //
    // The following allows HelloUniverse to be run as an application
    // as well as an applet
    //
    public static void main(String[] args) {
        new MainFrame(new HelloUniverse(), 256, 256);
    }
}
import java.util.*;
import java.awt.event.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class TestBehavior extends Behavior {

    private WakeupOr mMouseCriterion;
    private boolean  mActiveFlag = false ;


    public void initialize() {
        WakeupCriterion[]   mouseEvents = new WakeupCriterion[5];
        mouseEvents[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
        mouseEvents[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
        mouseEvents[2] = new WakeupOnElapsedFrames(0) ;
        mouseEvents[3] = new WakeupOnAWTEvent(MouseEvent.MOUSE_RELEASED);
        mouseEvents[4] = new WakeupOnAWTEvent(MouseEvent.MOUSE_CLICKED);
        mMouseCriterion = new WakeupOr(mouseEvents);
        wakeupOn (mMouseCriterion);
        setSchedulingBounds(new BoundingSphere(new Point3d(),
                                               Double.MAX_VALUE)) ;
    }

    // Override Behavior's stimulus method to handle the event
    public void processStimulus(Enumeration inCriteria) {

        WakeupCriterion wakeup;

        System.out.println("Inside processStimulus");

        wakeupOn(mMouseCriterion);

        while (inCriteria.hasMoreElements()) {
            wakeup = (WakeupCriterion) inCriteria.nextElement();
            System.out.println(wakeup);
        }
    }

    public boolean isActive() {
        return mActiveFlag ;
    }

    public void setActive(boolean  inActiveFlag) {
        mActiveFlag = inActiveFlag ;
    }

}

Reply via email to