Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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 1138 times)
0 Members and 1 Guest are viewing this topic.
Offline Kevdog

Junior Duke





« Posted 2003-01-16 12: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 Duke




Nothing unreal exists


« Reply #1 - Posted 2003-01-16 13: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 Duke




Nothing unreal exists


« Reply #2 - Posted 2003-01-16 13: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!
Legends of Yore - The Casual Retro Roguelike
Offline Herkules

Senior Duke




Friendly fire isn't friendly!


« Reply #3 - Posted 2003-01-16 13: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 Duke




Nothing unreal exists


« Reply #4 - Posted 2003-01-16 14: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 Duke





« Reply #5 - Posted 2003-01-16 15: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.

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (42 views)
2014-10-16 15:22:06

Norakomi (32 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!