Time Taken to create Shape3D Object: For some reason creating Shape3D objects that contain non-default Materials (using the setMaterial method) or colouring attributes (using the setColoringAttributes method) is much slower than creating Shape3D objects that use the default attributes. This has nothing to do with adding the Shape3D object to the SceneGraph or displaying it, but is purely object creation time! Additionally, the more Shape3D objects that are created the slower things become... much, much, much (i.e. exponentially) slower. I have graphed the results of some tests and included them on our web-site: http://www.tornadolabs.com/java/java3ddocs.html ** Note that you are talking about 5 minutes (!) to create 4,000 objects with a Material and ColoringAttributes on my PII 266 MHz PC running Windows NT SP3. ** If someone can explain this to me or come up with a workaround I would love to hear from them... Daniel Selman Tornado Labs Ltd. Email: [EMAIL PROTECTED] Web: www.tornadolabs.com Phone: +44 (0131) 343 2513 Fax: +44 07070 800 483 == The Code used to run the tests is included below == /* //************************************************************************** *** /* * @(#) CVoxel.java * * Project: (none) * Client: (none) Freely distributable * * Copyright (c) 1999 Tornado Labs, Ltd. * All Rights Reserved. * * http://www.tornadolabs.com * * @author Daniel Selman ([EMAIL PROTECTED]) */ //************************************************************************** *** import java.util.*; import java.awt.*; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.geometry.*; public class CVoxel { // private data private Shape3D m_Shape3D = null; private static PointArray m_PointArray = null; private static PointAttributes m_PointAttributes = null; private static Appearance m_Appearance = null; private static Material m_Material = null; private static Point3f m_Point = null; public CVoxel() if( m_PointArray == null ) { m_PointArray = new PointArray( 1, GeometryArray.COORDINATES | GeometryArray.NORMALS ); m_Appearance = new Appearance(); m_Material = new Material(); m_Point = new Point3f(); } m_PointArray.setCoordinate( 0, m_Point ); // ************************************************************ // including either of the next two lines will mean that it // takes several minutes to create 4,000 Shape3D objects... // // m_Appearance.setMaterial( m_Material ); // m_Appearance.setColoringAttributes( new ColoringAttributes( 1.0f, 1.0f, 1.0f, ColoringAttributes.FASTEST ) ); // // ************************************************************ m_Shape3D = new Shape3D( m_PointArray, m_Appearance ); } public static void main( String[] args ) { final int nSize = 4000; Vector vector = new Vector( nSize ); long startTime = java.lang.System.currentTimeMillis(); for( int n = 0; n < nSize; n++ ) { vector.add( new CVoxel() ); if( n % 100 == 0 ) System.out.println( n + "\t" + (java.lang.System.currentTimeMillis() - startTime) ); } System.out.println( "Total Time:\t" + (java.lang.System.currentTimeMillis() - startTime) ); } } ===================================================================== To subscribe/unsubscribe, send mail to [EMAIL PROTECTED] Java 3D Home Page: http://java.sun.com/products/java-media/3D/
