Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
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  
  Newbie has troubles with xith's Ase source exemple  (Read 869 times)
0 Members and 1 Guest are viewing this topic.
Offline Psyko

Junior Newbie




Java games rock!


« Posted 2003-12-21 15:59:33 »

Hi everybody,
could you please have a look to my #~@@@ problem ?

i'm new with Xith3d and i try to run xith's Ase source exemple from Eclipse.
http://www.xith.org/tutes/GettingStarted/html/the_ase_geometry_loader.html

This is the piece of code wich throws me an exception error:

     private void loadGeom() {
           try {

                 
                 /*
                  * Loads the ASE file
                  */
                 AseFile af = new AseFile();
                 BufferedReader br = null;
                 
                 try {
                       // Attempts to read the file normally
                       br = new BufferedReader(new FileReader("crudetank_mod.ASE"));
                 
                 } catch (IOException e) {
                       // Attemts to read file from JAR
                       URL url = this.getClass().getClassLoader().getResource("crudetank_mod.ASE");
                       br = new BufferedReader(new InputStreamReader(url.openStream()));
                 }
                 AseReader r = new AseReader(br, af);
                 af.parse(r);
                 
                 torso = new BranchGroup ();
                 tankbody = new BranchGroup ();
                 turret = new BranchGroup ();

                 // Extracts list of named nodes
                 java.util.Hashtable views = af.getNamedNodes();

                 // Iterates though nodes, adding them to relevent base branch groups
                 for (Enumeration e = views.keys() ; e.hasMoreElements() ;) {
                       String current = (String)  e.nextElement();
                       
                       if (current.equals("Torso")) {
                             torso.addChild((BranchGroup) views.get((Object)current));
                             
                       } else if (current.equals("Body") ) {
                             tankbody.addChild((BranchGroup) views.get((Object)current));
                             
                       } else if (current.equals("Turret")) {
//HERE IS THE PROBLEM WICH THROWS THE EXCEPTION
                             turret.addChild(((BranchGroup) views.get((Object)current));
                       }
blablabla

The excpetion is :
java.lang.ClassCastException
     at Ase.CrudeTank.loadGeom(CrudeTank.java:107)
     at Ase.CrudeTank.<init>(CrudeTank.java:63)
     at Ase.AseTest.<init>(AseTest.java:94)
     at Ase.AseTest.main(AseTest.java:78)

I would like to debugs it.
But before getting started i was wondering; why is there screenshots of this exmple, if it has never worked before.

i know that the .ase file has been read, and that te enumerator is full of stuff, it seems to be a casting problem between BranchGroup and the Node object.
So why does this probem occurs on my pc if this piece of code is supposed to be working ?

Thanks for your help

Psyko The Newbie
Offline Psyko

Junior Newbie




Java games rock!


« Reply #1 - Posted 2003-12-21 17:40:57 »

Konik and i found the reason.

The casting of (BranchGroup) is responsable of the exception it works fine with (TransformGroup).

We have now a nice tank rotating Wink

Have fun

Psyko
Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #2 - Posted 2003-12-21 21:00:09 »

My bad Sad

Problem was caused because I changed getNamedNodes to return TG's rather than BG's.  I've patched the souce but it may take a few days to sync with the server.

Thanks for pointing out the bug.

If you liked that tute, I strongly suggest checking out this one: http://xith.org/tutes/GettingStarted/html/transformgroup_trees_with_t.html

getTransformGroupTree is quite a lot more useful than getNamedNodes for many situations Smiley

Cheers,

Will.

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 (35 views)
2014-10-17 03:59:02

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

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

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

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

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

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

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

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

BurntPizza (75 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!