Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
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  
  Xith3D performance  (Read 1336 times)
0 Members and 1 Guest are viewing this topic.
Offline c_inconnu

Junior Newbie




Java games rock!


« Posted 2003-12-06 14:59:16 »

Hi !

First I'd like to say that I am a true beginner in the 3D world  Smiley I have coded a small terrain test. It's very basic ; it's loads a bitmap and creates for each pixel a square made of two triangles. Every cell shares its normal with the neighbours so the (gouraud) rendering looks smooth.
It looks fine but i got a 25fps for a 40*40 map, ie 40*40*2=3200 triangles... on a Athlon2000+, GeForce4200, 1Go RAM Cry I started from the cubetest and testutils classes.
So i'd like to know if i am really bad (probably) or if the performance of Xith are not so good Huh
Or maybe i miss some configuration point because the xith terrain demo is hanging the whole PC when launched...

Thanks
A pure beginner
Offline Jani Laakso

Junior Member




Do it with Java!


« Reply #1 - Posted 2003-12-06 15:01:23 »

Perhaps a source code of your test class could tell more of the possible bottlenecks?
Offline abies

Senior Member





« Reply #2 - Posted 2003-12-06 15:15:12 »

Please search your code for Thread.sleep(...) code. Quite a few of test classes use it and it will for sure kill your fps (it is acceptable in test classes, because they test features, not speed).

Artur Biesiadowski
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline c_inconnu

Junior Newbie




Java games rock!


« Reply #3 - Posted 2003-12-06 15:15:37 »

Thanks for quickly answering. I put some code below. It is very long and quite unoptimized for the triangles generation. But even if the generation is badly coded, does it impact the performance (since the data are created just once) Huh

And as i said, the XithTerrainDemo is hanging my PC (and another too which is a Athlon550,GeForce256,512Mo RAM)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
public class TerrainRenderer2
{
    Transform3D testRotateY = new Transform3D();
    TransformGroup testRotateYGroup = new TransformGroup();
    Material material = new Material();
    boolean play = true;
    boolean pause = false;
    TerrainData terrainMap = null;
    View view = new View();

    public static void main(String[] args)
    {
            <load image in map>
            final TerrainRenderer2 test = new TerrainRenderer2(map, panel);
            ...
            test.start();
    }

    public TerrainRenderer2(TerrainData terrainMap, Component ccc)
        throws Exception
    {
        this.terrainMap = terrainMap;

        // Prepare full-screen canvas adapted for current resolution
       Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

        VirtualUniverse universe = new VirtualUniverse();

        view.setBackClipDistance(100f);
        view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
        new Vector3f(0, 1, 0));
    view.getTransform().lookAt(
            new Vector3f(0, 3.5f, 3),
            new Vector3f(0, 0, 0),
       
        Locale locale = new Locale();
        universe.addLocale(locale);
        universe.addView(view);

        RenderPeer renderPeer = new RenderPeerImpl();
        CanvasPeer canvasPeer =
            renderPeer.makeCanvas(
                ccc,
                screenSize.width - 200,
                screenSize.height - 200,
                16,
                true);
        //canvasPeer.getWindow().setLocation(100, 100);
       Canvas3D canvas = new Canvas3D();
        canvas.set3DPeer(canvasPeer);
        view.addCanvas3D(canvas);

        BranchGroup scene = this.createSceneGraph();
        locale.addBranchGraph(scene);

        class KeyboardEventListener implements AWTEventListener{...}
        Toolkit.getDefaultToolkit().addAWTEventListener(
            new KeyboardEventListener(),
            AWTEvent.KEY_EVENT_MASK);
    }

    public void start()
    {
        <classical loop with view.renderOnce()>
    }

    public void stop()
    {
        play = false;
    }

    protected BranchGroup createSceneGraph() throws Exception
    {
        BranchGroup objRoot = new BranchGroup();

        AmbientLight light =
            new AmbientLight(true, new Color3f(0.25f, 0.25f, 0.25f));
        DirectionalLight dlight =
            new DirectionalLight(
                true,
                new Color3f(0.75f, 0.75f, 0.75f),
                new Vector3f(-1, -1, -1));
        objRoot.addChild(light);
        objRoot.addChild(dlight);

        // Add animation TransformGroup
       testRotateYGroup.setTransform(testRotateY);
        objRoot.addChild(testRotateYGroup);

        // Make extra transfrom we may want to play with (scale etc.)
       TransformGroup sceneRootTransform = new TransformGroup();
        Transform3D t = new Transform3D();
        t.setIdentity();
        t.setTranslation(new Vector3f(-2, 0, -2));
        sceneRootTransform.setTransform(t);
        testRotateYGroup.addChild(sceneRootTransform);

        material.setEmissiveColor(0.0f, 0f, 0f);
        material.setSpecularColor(0.5f, 0.5f, 0.5f);
        material.setAmbientColor(10.0f, 0.0f, 0.0f);
        material.setDiffuseColor(0.75f, 0.0f, 0.0f);
        material.setLightingEnable(true);

        int width = terrainMap.getSize().width;
        int height = terrainMap.getSize().height;
        int cellHeight = 0;

        //interpolatedHeightfield
       float[][] ihf = new float[width - 1][height - 1];

        for (int i = 0; i < ihf.length; i++)
        {
            for (int j = 0; j < ihf[0].length; j++)
            {
                <much much (too much ?) lines to generate the triangles >
                <looks like xith examples>
            }
        }

                int flags = GeometryArray.COORDINATES;
                flags |= GeometryArray.NORMALS;

                TriangleArray qa = new TriangleArray(coords.length, flags);
                qa.setCoordinates(0, coords);
                qa.setNormals(0, normals);

                Appearance a = new Appearance();
                a.setPolygonAttributes(
                    new PolygonAttributes(
                        PolygonAttributes.POLYGON_FILL,
                        PolygonAttributes.CULL_NONE,
                        0));
                a.setColoringAttributes(
                    new ColoringAttributes(
                        new Color3f(1, 0, 0),
                        ColoringAttributes.SHADE_GOURAUD));
                a.setMaterial(material);

                Shape3D shape = new Shape3D();
                shape.setAppearance(a);
                shape.setGeometry(qa);
                sceneRootTransform.addChild(shape);
            }
        }

        return objRoot;
    }
}
Offline Yuri Vl. Gushchin

Senior Member




Speak Java!


« Reply #4 - Posted 2003-12-06 16:02:22 »

Hi,

I just tested Xith3DTerrainTest on my PC and got 90-95 FPS.

The exact system configuration is:

WinXP Home
P4-1.8GHz, 512 Mb RAM
GeForce 440Go (32 Mb)
1600x1200 LCD, 32bpp color depth, 60 Hz refresh
Vertical Sync OFF
Drivers 2846 (Toshiba does not have newer drivers)
All windows except Xith3D window minimized, no other window overlap Xith3D window.

FPS measured using FRAPS 1.9D.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline Preston

Senior Member


Medals: 4



« Reply #5 - Posted 2003-12-06 18:03:02 »

Well, Xith3d is fast. David, Yuri and the other few maintainers say it's not fully optimized yet and there will be done more in the future, but it's already pretty fast and very usable IMHO.

Currently with a GF4 4200 I've got a scenery with about five moving/rotating objects with about 43000 polygons in total, @ 85 to 90 FPS on a 1024x768x32bpp screen. The (<2 GHz) CPU is idling at below 30% load, so actually it's just up to the graphics card.

Of course, fewer (geometry static) objects with many polygons render better than many objects with fewer polygons, but still it gives a hint.
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 (51 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (209 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!