Hi Joerg,

    There are 1000 ColorCube in the scene, under OGL
display list is used which is invoked 1000 times to draw
individual cube. (Using display list is faster
than D3D DrawPrimitive)

    This example define the Cube as QuadArray, using
OGL which support GL_QUADS directly so we can have
only one function call to draw the whole cube.

    But D3D don't support QUADS, so we break the
primitive into to draw two triangles at a time

using
  DrawPrimitiveStrided(D3DPT_TRIANGLEFAN,
                       vertexFormat, &strideData, 4, 0);

So for ColorCube there are 6000 DrawPrimitives call.
That's why it hurts performance as Philip Taylor
from Microsoft mention in his email.

Several optimization is consider in our next release.
For D3D we may use VertexBuffer. Also we may combine
shape node together.

There are several things that you can do right now to
improve performance.

(1) Use TriangleArray instead of QuadArray to define Cube
    (Only if D3D version is used)
(2) In you scene graph there is a TransformGroup above every Cube.
    You can eliminate the 1000 TransformGroup by per-transforming
    the coordinate in your Cube definition. This can significantly
    increase performance under v1.2 (compare with v1.1.3).


Thanks for your test program.

- Kelvin

----------
Java 3D Team
Sun Microsystems Inc.








>X-Unix-From: [EMAIL PROTECTED]  Sun Jul  9 03:41:58 2000
>MIME-Version: 1.0
>Content-Transfer-Encoding: 7bit
>X-Priority: 3 (Normal)
>X-MSMail-Priority: Normal
>Importance: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
>Date: Sun, 9 Jul 2000 12:26:45 +0200
>From: "Joerg 'Herkules' Plewe" <[EMAIL PROTECTED]>
>Subject: Re: [JAVA3D] DirectX Beta1
>Comments: To: Kelvin Chung <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>
>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".

===========================================================================
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