Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  
  Real Time?  (Read 903 times)
0 Members and 1 Guest are viewing this topic.
Offline Jamison

Junior Member




We're all idiots in one way or another.


« Posted 2006-05-03 18:24:23 »

Hey all,

I'm having a bit of trouble getting started with Java 3D... I can get a BranchGroup to render and all, rotate a cube, etc. But after the scene is compiled (BranchGroup.compile()), I can't set the Transform3D object on my TransformGroup object. Here's my code:
Quote
import java.awt.*;
import javax.swing.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;

public class Test extends JFrame {
   TransformGroup cubeTG = new TransformGroup();

   public Test() {
      setSize(400, 300);
      setResizable(false);
      setDefaultCloseOperation(EXIT_ON_CLOSE);

      GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();
      Canvas3D c = new Canvas3D(gc);
      getContentPane().add(c);

      BranchGroup scene = new BranchGroup();

      scene.addChild(cubeTG);
      cubeTG.addChild(new ColorCube(0.4));

      scene.compile();

      SimpleUniverse su = new SimpleUniverse(c);
      su.getViewingPlatform().setNominalViewingTransform();
      su.addBranchGraph(scene);

      setVisible(true);

      while(true) {
         Transform3D t3d = new Transform3D();
         cubeTG.getTransform(t3d);

         t3d.rotY(Math.toRadians(1));

         cubeTG.setTransform(t3d);
      }
   }

   public static void main(String args[]) {
      new Test();
   }
}
I recieve the following exception:
Quote
Exception in thread "main" javax.media.j3d.CapabilityNotSetException: Group: no
capability to set transform
        at javax.media.j3d.TransformGroup.setTransform(TransformGroup.java:115)
        at Test.<init>(Test.java:38)
        at Test.main(Test.java:43)
If I can't set the transform on an object after the scene has been compiled, how can I render in real time (for 3D games...)?

I don't like you. Check out my site Smiley www.gamedevforums.com
Offline Breakfast

Senior Member




for great justice!


« Reply #1 - Posted 2006-05-03 22:36:54 »

You need to set ALLOW_TRANSFORM_WRITE as one of the attributes on your transformgroup before you compile it- basically compiling will allow Java3D to optimise your scene as much as possible, if it knows an object won't be moved it can perform some optimisations that it couldn't perform if the object will be moved, so you need to tell it ahead of time.

I wrote a tutorial on basic Java3D for games a few years back, I suspect it may be a little out of date by now but there will probably be some stuff there that is useful to you- you can find it here...
Offline Jamison

Junior Member




We're all idiots in one way or another.


« Reply #2 - Posted 2006-05-04 01:31:13 »

Alright! Thanks so much, Breakfast. It works just as I wanted it to. I'll have a look at your tutorial now too.

I don't like you. Check out my site Smiley www.gamedevforums.com
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.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (21 views)
2014-08-16 06:12:11

Rayexar (60 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!