Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  VRML and Capability bits  (Read 854 times)
0 Members and 1 Guest are viewing this topic.
Offline asimonk

Junior Newbie




Java games rock!


« Posted 2005-07-29 23:50:21 »

So I'm using XJ3D to load my vrmls into my project. Allegedly the VRML97Loader can mass set capability bits, but  any actual confirmation to this is dodgy at best.,  using loader.setCapabilityRequiredMap(Map, Map). Even tracking down an example of this was futile. The code I used to initialize the loader is

     VRML97Loader loader = new VRML97Loader();
    Map<Integer,Integer> capabilityBits = new LinkedHashMap<Integer,Integer>();
    capabilityBits.put(BranchGroup.ALLOW_CHILDREN_READ,BranchGroup.ALLOW_CHILDREN_READ);
    Map<Integer,Integer> freqBits = new LinkedHashMap<Integer,Integer>();
    freqBits.put(BranchGroup.ALLOW_CHILDREN_READ,BranchGroup.ALLOW_CHILDREN_READ);
    loader.setCapabilityRequiredMap(capabilityBits, freqBits);

My problem is thus, I'm trying to add an object to a light's scope list to essentially highlight the object. The Light.addScope(Group) function only takes adds the Group and not its children. So I wrote a little hack to traverse the sub-graph and add all of the group nodes. 

   private void Scope(Light light, Group group)
   {
      light.addScope(group);//group.getCapability(BranchGroup.ALLOW_CHILDREN_READ)
      Enumeration children = group.getAllChildren();
      while(children.hasMoreElements())
      {
         Object o = (Object)children.nextElement();
         if(o instanceof Group)
         {
         Scope(light, (Group)o);
         }
      }
     
   }

Then I ran into my capability bit problem. It seems that while I can set the BranchGroup containing the loaded VRML model's bits, the loader's setCapabilityRequiredMap function, does not work as anticipated. I get the following expection:
 
javax.media.j3d.CapabilityNotSetException: Group: no capability to read children

I tried to manually traverse the sub-graph of the loaded VRML with a similar hack as above

   private void setCapability(Group group)
   {
      group.setCapability(Group.ALLOW_CHILDREN_READ);
      Enumeration e = group.getAllChildren();
      System.out.println(this.id);
      while(e.hasMoreElements())
      {
         Object o = (Object)e.nextElement();
         if(o instanceof Group)
         {
         setCapability((Group)o);
         }
      }     
   }

Not to keep you all in suspense, but it didn't work. So I'm curious if anyone has any suggestions as to what i have done wrong, or even a different approach to solving my problem. Any help would be greatly appreciate, thanks in advance.
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2005-07-30 01:19:18 »

Well..  I have a suggestion but you may not like it...

Basically what a lot of people do is write recursive code they run after the loader laods the scene but before they make it live to traverse the tree and set the bits they need.

I know that Paul Byrne in the J3D group attempted to write a generic tree traverser to do things like this, but I dont know if its public and/or if it is where it lives.

I can ask him on Tuesday...

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline asimonk

Junior Newbie




Java games rock!


« Reply #2 - Posted 2005-08-03 18:25:57 »

A generic tree traverser would be a godsend. I'm a little curious why this sort of functionality doesn't exist in the form of a helper class or even on the loader itself. I'm running into similar capability bits (which I can only assume were devised to make life that much more irritating) with picking. It very well could be my complete misunderstanding of the nature of capability bits.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mithrandir

Senior Member




Cut from being on the bleeding edge too long


« Reply #3 - Posted 2005-08-08 18:16:45 »

We try to be pretty good about setting the right capability bits, but sometimes this just don't work out right. For example, if you set a Group node as the key to the map with ALLOW_CHILDREN_WRITE, and we're using a TransformGroup as the internal implementation, then we won't pick that up: our code uses TransformGroup.class as the key to the map. There's a lot of places where this comes into play due to all the derived classes that are part of the Java3D design.

If you have specific instances that are not being set correctly, please post a bug report at http://bugzilla.xj3d.org for us to look through. Sometimes these are just trivial errors in our handling and can be fixed in a minute or too. Doing a generic audit is something we currently don't have time to do, but if we know of specific cases, that makes our lives much, much easier and we can take the hour or two out of our schedule to go fix it.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
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.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!