Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (290)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Storing state info along with geometry in Scene?  (Read 889 times)
0 Members and 1 Guest are viewing this topic.
Offline Kevdog

Junior Member





« Posted 2003-01-16 13:59:04 »

I thought I could store info about my object (a ship in this case) in with the geometry in the scene graph.

I basically did:
public class Ship extends Cone {
    public TransformGroup tg = null;

    // more code
}

When I pick the shape using a mouse behavior (WakeupOnAWTEvent) and do a node instanceof Ship, it returns false.  It is a Shape3D, but it doesn't associate with Ship, and a cast throws a ClassCastException.

I'm assuming that the scenegraph only retains the geometry info?  (I'm obviously doing something wrong!)  Should this work?  Or is there a better way to associate state info with the scene graph objects?


There are only 10 types of people, those who understand binary and those who don't!
Offline pepe

Junior Member




Nothing unreal exists


« Reply #1 - Posted 2003-01-16 14:23:04 »

its simply because Cone is not a Shape3D.
For your test to succeed, use
Shape3D pickedShape = ((Cone) node).getShape();

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Offline pepe

Junior Member




Nothing unreal exists


« Reply #2 - Posted 2003-01-16 14:25:06 »

Oh, by the way, is there a problem using mouse listeners directly on Canvas3D, instead of AWTEvent behaviors?

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #3 - Posted 2003-01-16 14:58:07 »

We published a 'userdata' object deep into a subgraph to indentify game-related objects from a node.

And I have MouseListeners on the Canvas3D. Works as expected.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline pepe

Junior Member




Nothing unreal exists


« Reply #4 - Posted 2003-01-16 15:11:21 »

Quote
And I have MouseListeners on the Canvas3D. Works as expected.
That's what i do, also and did notice no problems. Wondering why they crated those behaviors, then... Bah...

Home page: http://frederic.barachant.com
------------------------------------------------------
GoSub: java2D gamechmark http://frederic.barachant.com/GoSub/GoSub.jnlp
Offline Kevdog

Junior Member





« Reply #5 - Posted 2003-01-16 16:04:14 »

Thanks for the hint about the Cone.  But the strange thing is I removed everything else from my scenegraph except the Ship, and I was still picking a Shape3D.  

Doing a System.out.println of the sceneGraphPath I get back the following:
SceneGraphPath=javax.media.j3d.Locale@cdb06e : JavaMOO.Ship : javax.media.j3d.Shape3D

I thought I read somewhere that as of J3D vs 1.3 (or 1.3.1? or 1.3.1beta) that the Cone/Sphere/etc are now Shape3D's.  Of course now I can't find that anywhere.

Here's my whole definition of Ship:

public class Ship extends Cone {
   public TransformGroup tg = null;
   
   /** Creates new Ship */
   public Ship(TransformGroup tg) {
       super(0.2f, 0.5f);
       this.tg = tg;

       Appearance a = new Appearance();
       Material m = new Material();
       a.setMaterial(m);
       setAppearance(a);

   }
   
}

In the end, this returns the actual ship Node:
Node n0 = sceneGraphPath.getNode(0);

As for doing the AWT events myself, I'll probably end up doing that, but for now I'm playing with all the behaviors and "automagic" stuff.  Haven't used J3D in about a year now, so getting back up to speed Smiley

There are only 10 types of people, those who understand binary and those who don't!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (61 views)
2013-05-17 21:29:12

alaslipknot (70 views)
2013-05-16 21:24:48

gouessej (100 views)
2013-05-16 00:53:38

gouessej (98 views)
2013-05-16 00:17:58

theagentd (107 views)
2013-05-15 15:01:13

theagentd (98 views)
2013-05-15 15:00:54

StreetDoggy (144 views)
2013-05-14 15:56:26

kutucuk (167 views)
2013-05-12 17:10:36

kutucuk (166 views)
2013-05-12 15:36:09

UnluckyDevil (175 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.081 seconds with 21 queries.