Be sure to call setSchedulingBounds( ... )
on your behavior after you create it. David Zwarg Instrumentation Engineer 510.291.6159 >-----Original Message----- >From: Brobbey,Isaac (neuron) [mailto:[EMAIL PROTECTED]] >Sent: Tuesday, January 28, 2003 10:20 AM >To: [EMAIL PROTECTED] >Subject: [JAVA3D] behavoir class > > > Dear all: > >i will be glad if any one can carefully check this code and >tell me what is >wrong with it. it work, or print out anything when i instatiates it. > > >thanks, > > >Isaac > > >class PickBehavia extends Behavior >{ > //WakeupCriterion mouseCriteria; > BranchGroup branchGroup; > Canvas3D canvas3D; > > WakeupOr mouseCriteria; > public PickBehavia(BranchGroup branchGroup, Canvas3D canvas3D) > { > this.branchGroup = branchGroup; > this.canvas3D = canvas3D; > > } > > public void initialize() > { > > WakeupCriterion [] mouseEvents = new WakeupCriterion[3]; > mouseEvents[0] = new WakeupOnAWTEvent( MouseEvent.MOUSE_DRAGGED ); > mouseEvents[1] = new WakeupOnAWTEvent( MouseEvent.MOUSE_PRESSED ); > mouseEvents[2] = new WakeupOnAWTEvent( MouseEvent.MOUSE_RELEASED ); > mouseCriteria = new WakeupOr( mouseEvents ); // member data > wakeupOn( mouseCriteria); > > //mouseCriterion = new >WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED); > System.out.println("event entered"); > System.out.println("Initialize"); > //wakeupOn (mouseCriterion); > } > > public void processStimulus (Enumeration criteria) > { > SceneGraphPath sceneGraphPath=null; > AWTEvent[] event = >((WakeupOnAWTEvent)criteria.nextElement()).getAWTEvent(); > for (int i=0; i<event.length; i++) > { > int x = ((MouseEvent)event[i]).getX(); > int y = ((MouseEvent)event[i]).getY(); > System.out.println("x="+" "+x); > PickRay pickRay = generatePickRay(x,y); > > sceneGraphPath = branchGroup.pickAny(pickRay); > Cone someCone = >(Cone)sceneGraphPath.getObject(); > > float Ht=someCone.getHeight(); > System.out.println("cone height="+" "+Ht); > //@@@ the formula for prop-retrieval. > //float calcx = (float)baseLine+Ht; > //float prop = calcx/yaxis; > > //for (int b=0;b<allProtein.size();b++) > //{ > //Protein tein >=(Protein)allProtein.elementAt(b); > >//if(isAproximatelyEqual(prop,tein.proportion,0.5f)) > //{ > //tellUser(tein.getName()); > //} > > //} > > > } > > > System.out.println("generate pickray"); > System.out.println(sceneGraphPath); > wakeupOn(mouseCriteria); > } > > public PickRay generatePickRay(int xpos, int ypos) > { > Transform3D motion=new Transform3D(); > Point3d eyePosn = new Point3d(); > Point3d mousePosn = new Point3d(); > Vector3d mouseVec=new Vector3d(); > canvas3D.getCenterEyeInImagePlate(eyePosn); > >canvas3D.getPixelLocationInImagePlate(xpos,ypos,mousePosn); > canvas3D.getImagePlateToVworld(motion); > > motion.transform(eyePosn); > motion.transform(mousePosn); > mouseVec.sub(mousePosn, eyePosn); > mouseVec.normalize(); > > return new PickRay(eyePosn, mouseVec); > } > > public boolean isAproximatelyEqual(float one,float >two,float three) > { > float four =(float)two-one; > if(Math.abs(four)<three) > return true; > else > return false; > } > private void tellUser(String message) > { > > JOptionPane.showMessageDialog(null, >message+"\n"+":..."); > } > > >} //class > >=============================================================== >============ >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".