Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

26. May 2012, 09:20:06 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)No visible nodes in scene....
Pages: [1] 2
Print
Author Topic: No visible nodes in scene....  (Read 3301 times)
rbivens
Just dropped in

Offline Offline

Posts: 11


View Profile Email
« on: 16. December 2006, 10:05:06 pm »

I'm obviously new to Xith, but have years of experience in Java, Java3d and some jME experience (a couple of months).

My probelm is this:

I'm working through the tutorial from Xith In A Nutshell - 1st Edition, and I'm unable to add anything to the scene graph. I've spent 2 days working on this, thinking that Xith would be a replacement for jME. At this point, I'm thinking NOT!

If anyone would like to look at my code, here it is. It's ugly because I've been trying nearly everything. Thanks.

    public EmptyScene()
    {
   super(120);
   env = new Xith3DEnvironment();
   canvas = Canvas3DWrapper.createStandalone(Resolution.RES_1024X768, "Mantis Framework Client");
   env.addCanvas(canvas);
   this.addEnvironment(env);
   canvas.getComponent().addMouseListener(this);
   canvas.getComponent().addMouseMotionListener(this);
   
   env.getLocale().addBranchGraph(this.createScene());
//   env.getRootBranchGroup().addChild(this.createScene());
//   canvas.getView().startView();
   this.begin();
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
   new EmptyScene();
    }
   
    private BranchGroup createScene()
    {
   GeoSphere sph = new GeoSphere( 8, GeometryArray.COLOR_3 | GeometryArray.NORMALS, .5f );
//   Texture tex = TextureLoader.getInstance().getTexture( "stone.jpg" );
//   Appearance app = new Appearance();
//   app.setTexture( tex );
//   sph.setAppearance( app );
   BranchGroup bg = new BranchGroup();
   bg.addChild( sph );
   sph.setLive(true);
   
   return( bg );
    }
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 16. December 2006, 11:51:24 pm »

Hi, rbivens

Welcome to Xith3D and this board Smiley.

I'm working through the tutorial from Xith In A Nutshell - 1st Edition, and I'm unable to add anything to the scene graph. I've spent 2 days working on this, thinking that Xith would be a replacement for jME. At this point, I'm thinking NOT!

Wow, hard judgement at this early point in gathering experince with Xith3D Shocked. Why didn't you ask earlier Huh.

When did you download the XIN.pdf? I guess it must be months ago. It has been updated several times and bugs have been eliminated. This addEnvironment() method doesn't exist anymore for very long (it only existed for some weeks). The new name is addRenderEngine(), but generally it is not needed, since it is already done by the Xith3DEnvirnment constructor, if you pass the RenderLoop instance (this) to the Xith3DEnvironment constructor like it is done in the example below.

I guess you're using the version 0.8.0 of Xith3D. One of the very first lines in XIN tells you do use a version greater than 0.8.0, since very much work has been done on Xith3D and not all features described in XIN are supported by 0.8.0. At the moment you have the choice to download the latest cooker version or checkout the latest SVN of xith3d and xith-tk. I strongly advise you to do the latter, since some bugs have been killed after the latest cooker release. The next cooker release will be available sunday or monday. The 1.0-beta1 will be released this year.

Code:
canvas.getComponent().addMouseListener(this);
canvas.getComponent().addMouseMotionListener(this);

We use an input abstraction layer called HIAL (thanks to William Denniss) for catching input events. It is integrated into and handled by the RenderLoop class. So you only need to call one of the register*Device() methods of the RenderLoop (like below).

Code:
env.getLocale().addBranchGraph(this.createScene());

Xith3DEnvironment provides several add*() methods to add nodes, groups or graphs. So you won't need to get the Locale or the root BranchGroup. The example below demonstrates one method.

This example is working:
Code:
public class EmptyScene extends ExtRenderLoop
{
    public void onKeyReleased(int key)
    {
        switch (key)
        {
            case KeyCode.VK_ESCAPE:
                System.exit( 0 );
                break;
        }
    }
   
    private BranchGroup createScene()
    {
        BranchGroup bg = new BranchGroup();
       
        //GeoSphere sph = new GeoSphere( 8, GeometryArray.COLOR_3 | GeometryArray.NORMALS, .5f );
        GeoSphere sph = new GeoSphere( 8, GeometryArray.TEXTURE_COORDINATE_2 | GeometryArray.NORMALS, .5f );
       
        // Tell the TextureLoader where to load Textures from...
        TextureLoader.getInstance().addTextureStreamLocator( new TextureStreamLocatorFile( "demo/textures/" ) );
       
        // Put a Texture on the sphere...
        Texture tex = TextureLoader.getInstance().getTexture( "stone.jpg" );
        Appearance app = new Appearance();
        app.setTexture( tex );
        sph.setAppearance( app );
       
        // add the sphere to the scenegraph
        bg.addChild( sph );
       
        return( bg );
    }
   
    public EmptyScene()
    {
        super( 120L );
       
        // Create a new Xith3DEnvironment and link it with the RenderLoop
        Xith3DEnvironment env = new Xith3DEnvironment( this );
       
        Canvas3D canvas = Canvas3DWrapper.createStandalone( Resolution.RES_1024X768, "Mantis Framework Client" );
        env.addCanvas( canvas );
       
        // Prepare the RenderLoop to catch input events...
        this.registerKeyboardAndMouse( canvas );
       
        // Initialize the scenegraph
        env.addBranchGraph( this.createScene() );
       
        // Start the RenderLoop
        this.begin();
    }
   
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        new EmptyScene();
    }
}

If you have any further questions, please do ask here to make us help you out. Xith3D certainly isn't that bad as you might have thought Wink.

I hope, I was able to help.

Marvin
Logged
rbivens
Just dropped in

Offline Offline

Posts: 11


View Profile Email
« Reply #2 on: 17. December 2006, 03:07:51 pm »

Marvin-

Thanks fro the informative reply. I will take your advice and get the latest source from SVN and give it another try.

Incidentally, I did get things to work by using the "Java3D-like" APIs instead of the examples. Is there an advantage to using one or the other?

Thanks,
rbivens
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 17. December 2006, 11:15:37 pm »

Incidentally, I did get things to work by using the "Java3D-like" APIs instead of the examples. Is there an advantage to using one or the other?

Well, you save a lot of code by using the wrapper classes, don't you? Functionally there shouldn't be any difference, since the wrapper classes make use of the Java3D-style classes (they wrap them Wink).

What's the problem with the example I posted?

Marvin
Logged
rbivens
Just dropped in

Offline Offline

Posts: 11


View Profile Email
« Reply #4 on: 18. December 2006, 12:24:48 am »

No problem--I'm just curious about the relationship between the different classes. Thanks for your help.

rbivens
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 18. December 2006, 12:57:11 am »

No problem--I'm just curious about the relationship between the different classes. Thanks for your help.

I just wondered, why you said: "I did get things to work by using the "Java3D-like" APIs instead of the examples.". So I thought, you didn't get the example working.

Do you find it easier/more convenient with the wrapper classes or with the Java3D-like ones? I'm always interested in things, that improve the wrapper classes Wink.

Marvin
Logged
rbivens
Just dropped in

Offline Offline

Posts: 11


View Profile Email
« Reply #6 on: 18. December 2006, 03:35:37 am »

Marvin-

Well, to be honest I've been struggling with getting the source to build properly. I actually do prefer to use the example-style code (the wrappers).

I'm working with the latest build now (12 Dec) instead. I know I may encounter some bugs until the next build comes (I've been reading your posts), but I think I know what to avoid for now.

Thanks again for you help.

-rbivens
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #7 on: 18. December 2006, 04:40:30 am »

Marvin-

Well, to be honest I've been struggling with getting the source to build properly. I actually do prefer to use the example-style code (the wrappers).

I'm working with the latest build now (12 Dec) instead. I know I may encounter some bugs until the next build comes (I've been reading your posts), but I think I know what to avoid for now.

Thanks again for you help.

-rbivens

Cool. Tomorrow (Monday) I will hopefully release the next cooker built. It will come with these bugfixes and some massive HUD fixes/enhancements I've worked on the last days Smiley.

Marvin
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #8 on: 18. December 2006, 04:11:02 pm »

Welcome rbivens !

Nice to see Marvin answered (again) too fast for me Smiley

Hope you got working what you wanted to do.

Don't hesitate to ask any questions.. it's always better than to fight with your computer for days (he may get angry in the end), and as you can see I think we're pretty reactive..
Logged
rbivens
Just dropped in

Offline Offline

Posts: 11


View Profile Email
« Reply #9 on: 19. December 2006, 02:42:45 am »

Marvin's been a great help.

I do have another question, now that I'm moving forward:

I've noticed that no matter what I do, I cannot get the FPS above ~50 or so. I've subclassed ExtRenderLoop and call super(500), but the FPS never changes. I have an NVIDIA GEFORCE GO 7600 with 128 megs of video ram.

Is there some sort of governing code that causes this?

Thanks,
rbivens
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #10 on: 19. December 2006, 03:10:45 am »

I've noticed that no matter what I do, I cannot get the FPS above ~50 or so. I've subclassed ExtRenderLoop and call super(500), but the FPS never changes. I have an NVIDIA GEFORCE GO 7600 with 128 megs of video ram.

Is there some sort of governing code that causes this?

Well 500 as the limit should be high enough Grin. If you use the empty super constructor the long-Constructor is automatically called with Long.MAX_VALUE.

The maximum reachable frame rate doesn't only depend on your machine. As you may know it also depends on the complexity of your scene and all the other stuff, which is done insode the render loop.

What does your scene look like. Try to call canvas.get3DPeer().getTriangles() after the first render loop iteration and tell us the number. (e.g. override the loopIteration() method and place a System.out there).

Are you doing other things insode the render loop? Do you have some game logic being done?

All this puts some load on the CPU/GPU and will make your FPS lower, as you may understand Wink.

Marvin
Logged
rbivens
Just dropped in

Offline Offline

Posts: 11


View Profile Email
« Reply #11 on: 19. December 2006, 04:39:16 am »

I tried your suggestion, but nothing changed. Here's what's wierd: I can change the max fps to something lower than 60 and it tries to conform to this. When I go higher than 60 it never gets higher. I currently have 80 triangles.

Even with no nodes added it stays the same. Also, I can add over 350,000 triangles before it starts to drop below 60 fps! Performance always seems good, and I can add a temendous amount of triangles before it starts to slow down, but there seems to be something holding it back at 60 fps.

rbivens
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Online Online

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #12 on: 19. December 2006, 11:24:58 am »

I tried your suggestion, but nothing changed. Here's what's wierd: I can change the max fps to something lower than 60 and it tries to conform to this. When I go higher than 60 it never gets higher. I currently have 80 triangles.

Even with no nodes added it stays the same. Also, I can add over 350,000 triangles before it starts to drop below 60 fps! Performance always seems good, and I can add a temendous amount of triangles before it starts to slow down, but there seems to be something holding it back at 60 fps.

Please try to run org.xith3d.test.loaders.BSPLoaderTest. In the starting view (close to the wall) the FPSCounter shows about 250 FPS (much less, if looking into a hall). Run org.xith3d.test.benchmark.Q3FlightBenchmark, press SPACE and wait about a minute. Then the intermediary FPS is dumped to stdout. It should be way over 100.

If you get FPS over 60 in the two tests, then it is something in your app. If not it's something in your driver, your system, etc. Don't know. But it's nothing in xith.

Marvin
Logged
'n ddrylliog
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #13 on: 19. December 2006, 05:35:26 pm »

Hi, rbivens.

Which OS are you running ?

I'm pretty inclined to think that your 60 FPS limit is due to the "Sync to VBlank" option enabled. If your screen has a 60Hz refresh rate, then your FPS can't go higher. If you disable this synchronization, your FPS can go at any rate.

I attached a screenshot of the nvidia config tool under linux. I don't know the trick for Windows but you can easily find it on the web.
Logged
rbivens
Just dropped in

Offline Offline

Posts: 11


View Profile Email
« Reply #14 on: 20. December 2006, 12:27:14 am »

Hmmmm. I went into my nvidia config tool and sure enough, it's locked at 60 Hz. I had no idea that fps could not exceed driver refresh rates, though. I have the option to change it, but only after the driver warned me that very bad things could happen to the hardware.

Based on this new info, I think I'll just leave it the way it is. 60 fps is plenty fast, and performance is excellent until I add hundreds of thousands of triangles.

Thanks Amos! (and Marvin, of course!). It's like you guys have a contest going on to see who can be the most helpful.

By the way, we've decided to switch from jME to Xith for our engine, based on ease of use and very similar performance.

Expect more questions  Smiley

Thanks again,
rbivens
Logged
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic