Hi community, here it is....

Meanwhile I checked out the D3D stuff further and found out that my
performance problems are not with all apps. So condensed my own stuff to a
minimum and like to post it here now.
Maybe someone can figure out why this sample is SO EXTREMLY SLOW only with
Direct3D. OpenGL is way faster and even OGL software rendering can beat it
by a factor of two!!
I hope the sample may help Sun to fix a severe performance bottleneck where
I cannot see any reason for it. Additionally I'd like to invite everybody to
confirm my observation!


The sample creates a grid of 10x10x10 ColorCubes and uses a
KeyNavigateBehavior to move the camera around.
The problem get obvious when the camera moves outside the grid and sees a
lot of cubes. This does not harm OGL very much (neither hardware nor
software), but it REALLY HURTS D3D. It drops to a framerate <4 on my
machine. Even OGL/software stays at about 9fps.

The applet can by found at

        http://www.hardcode.de/D3DKiller/Index.html


Source is at

        http://www.hardcode.de/D3DKiller/D3DKiller.java

and added to this post.


This does not make any sense to me,

- J

Joerg 'Herkules' Plewe
HARDCODE Development
http://www.hardcode.de


>
>    It is because Java3D v1.2 OGL make use of Display List
> to improve performance but D3D beta version haven't take
> advantage of Vertex Buffer feature yet. We'll consider this in our
> final D3D release.
>




/*
 * D3DKiller.java
 *
 * Created on 9. Juli 2000, 11:29
 */

import java.awt.BorderLayout;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.keyboard.*;
import javax.media.j3d.*;
import javax.vecmath.*;


/**
 *
 * @author  Herkules
 * @version
 */
public class D3DKiller extends java.applet.Applet
{

        /**
        * @param args the command line arguments
        */
        public void init ()
        {
        }


    public D3DKiller()
        {
                setLayout(new BorderLayout());
                        GraphicsConfiguration config =
                           SimpleUniverse.getPreferredConfiguration();

                Canvas3D c = new Canvas3D(config);
                add("Center", c);

                // Create a simple scene and attach it to the virtual universe
                BranchGroup scene = createSceneGraph();
                SimpleUniverse u = new SimpleUniverse(c);

                // This will move the ViewPlatform back a bit so the
                // objects in the scene can be viewed.
                u.getViewingPlatform().setNominalViewingTransform();
                View view = u.getViewer().getView();
                view.setBackClipDistance(10000);

                setCameraByKeyboard( u, scene );

                u.addBranchGraph(scene);
    }


    public BranchGroup createSceneGraph() {

                // Create the root of the branch graph
                BranchGroup objRoot = new BranchGroup();
                objRoot.setCapability( Group.ALLOW_CHILDREN_EXTEND );

                // Create the TransformGroup node and initialize it to the
                // identity. Enable the TRANSFORM_WRITE capability so that
                // our behavior code can modify it at run time. Add it to
                // the root of the subgraph.
                TransformGroup objTrans = new TransformGroup();
                objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
                objRoot.addChild(objTrans);

                // Create a simple Shape3D node; add it to the scene graph.
                objTrans.addChild( createCubeGrid( 10, 10, 10, new Vector3d( 0.0, 0.0,
0.0), 2, 8 ) );


                // Have Java 3D perform optimizations on this scene graph.
                objRoot.compile();

                return objRoot;
    }



//-------------------------------------------------------------------------c
reateSimpleCube
        TransformGroup createSimpleCube( double size )
        {
                TransformGroup tg = new TransformGroup();
                ColorCube cube  = new ColorCube( size );

                tg.addChild( cube );

                return tg;
        }

//-------------------------------------------------------------------------c
reateSimpleCube



//-------------------------------------------------------------------------c
reateCubeGrid
        /** Creates new CubeGrid */
        BranchGroup createCubeGrid(int countX,int countY,int countZ,Vector3d
CenterPos,double CubeSize,double Distance)
        {
                Vector3d Pos = new Vector3d();
                Transform3D Translation = new Transform3D();
                BranchGroup bg = new BranchGroup();

                Pos.x = CenterPos.x - (double)countX / 2.0 * Distance;
                for( int i = 0; i < countX; ++i )
                {
                        Pos.y = CenterPos.y - (double)countY / 2.0 * Distance;
                        for( int j = 0; j < countY; ++j )
                        {
                                Pos.z = CenterPos.z - (double)countZ / 2.0 * Distance;
                                for( int k = 0; k < countZ; ++k )
                                {
                                        Translation.setTranslation( Pos );

                                        TransformGroup cube = createSimpleCube( 
CubeSize );
                                        cube.setTransform( Translation );
                                        bg.addChild( cube );
                                        Pos.z += Distance;
                                }
                                Pos.y += Distance;
                        }
                        Pos.x += Distance;
                }

                return bg;
        }

//-------------------------------------------------------------------------c
reateCubeGrid


        void setCameraByKeyboard( SimpleUniverse u, BranchGroup s )
        {
                TransformGroup tg =  u.getViewingPlatform().getViewPlatformTransform();

                KeyNavigatorBehavior keybehavior = new KeyNavigatorBehavior (tg);
                BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),
100000.0);
                keybehavior.setSchedulingBounds (bounds);

                BranchGroup bg = new BranchGroup();
                bg.addChild( keybehavior );
                s.addChild( bg );
        }




//-------------------------------------------------------------------------m
ain
    public static void main(String[] args)
        {
                new MainFrame(new D3DKiller(), 640, 480);

        }

//-------------------------------------------------------------------------m
ain

}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to