In your code, you should do the cast AFTER you verified the class type : that is, instead of : Cone conex=(Cone)geom; if (conex instanceof Cone) { Cone conex=(Cone)someCone; ...
you should: if (geom instanceof Cone) { Cone conex=(Cone)geom; ... This is not going to take a crap on you, but then, it is never going to work either, just because Cone is derived from Primitive, NOT from Geometry. A Cone, however, is build from Shape3Ds, which in turn are built from Geometries. A single look at the JavaDoc of Cone would have revealed to you what was wrong with your cast! Therefore I strongly recommend, that you, on occasion, read some JavaDoc first!!!! H. ----- Original Message ----- From: "Brobbey,Isaac (neuron)" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 31, 2003 9:39 AM Subject: [JAVA3D] cone retrieval / Important > hi all: > > given the code below: > > sceneGraphPath = branchGroup.pickAny(pickRay); > System.out.println("scene graph="+" > "+sceneGraphPath.toString()); > Shape3D shape3d = (Shape3D)sceneGraphPath.getObject(); > Geometry geom = shape3d.getGeometry(); > Cone conex=(Cone)geom; > if( conex instanceof Cone) > { > Cone conex=(Cone)someCone; > float Ht=conex.getHeight(); > System.out.println("cone height="+" "+Ht); > } > > i have a problem on line " Cone conex=(Cone)geom; " > > what is the best way to get a cone from the scenegraph path ? > this is the path; > > scene graph= javax.media.j3d.Locale@dfcb47 : > com.sun.j3d.utils.geometry.Cone, Protein@9abc69 : > javax.media.j3d.Shape3Djavax.media.j3d.TriangleFanArray@c792d4 > > LocalToVworld Transform: > 0.0375749076740305, -0.005965948985267853, -0.012350453208999744, > 0.020183997378 > 483642 > > thanks, > > > > Isaac > > =========================================================================== > 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".