Attached is a program that illustrate a better approach to setup a scene with 5000 identical spheres. On my machine, I've a 4X speedup in setup time.
Using Link and SharedGroup is a intuitive way of sharing similar shape node in a scene graph API. It's pretty effective if the sharing is limited and small. There do come with some cost in both memory and setup time, but almost no cost in pure rendering performance (once it is setup). This setup cost might not be linear, depending on scene arrangement. For your program, all you need is to share geometry and there isn't a need to use SharedGroup. I only need to change a few lines of code. BTW, I also replaced MouseRotate with OrbitBehavior for better interaction. - Chien Yang Java 3D Team. > Date: Tue, 02 Apr 2002 19:22:05 +0200 > From: Artur Biesiadowski <[EMAIL PROTECTED]> > Subject: Re: [JAVA3D] A basic doubt > To: [EMAIL PROTECTED] > MIME-version: 1.0 > Content-transfer-encoding: 7bit > X-Accept-Language: en-us, en > Delivered-to: [EMAIL PROTECTED] > User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.9) Gecko/20020311 > > Nitin.Jain wrote: > > > > I saw the Sphere code in the repository but it seems this sphere doesn't > > share the geometry, in that case it will eat up huge amount of memory for > > each instance. Anyway I'll try this. > > Even if it is a case, you can take out geometry by hand. It can be done > currently I think, in case of problems, modify it a bit. > > > Could you give me some pointers on optimization. I'm creating only one > > Shape3D and using them with Link. The Tranform3D which is assigend is also > > created only once. > > I was thinking that you were doing certain mistake, but after looking at > code again it is not there. So only part now is to not use standard > Sphere with quite costly GeometryData - but I don't know if it will > create noticeable difference. > > > >> percent live alloc'ed stack class > >> rank self accum bytes objs bytes objs trace name > >> > >> 94 0.11% 87.51% 20016 1 50080000 5000 10593 > >>javax.media.j3d.CachedTargets > >> 95 0.11% 87.62% 20016 1 50079984 4999 10601 > > > > > > I never got this "CachedTargets" object in my profiler, can you tell me > > which profiler are you using? > > -Xrunhprof:heap=sites,depth=20 > > :) > > > > I couldn't quite get it...what do you mean by non-array object. > > int[] i = new int[100000]; > takes up 400kb. No problem. But if you want to create normal (non-array > object) which will take up so much memory, you would have to add 100000 > fields by hand... So if any object takes up 20kb, I'm suspecting some > mistake in profiler (either plain error or Hotspot inlines some array > data at end of object - is this possible ?) > > Artur > > =========================================================================== > 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".
TestApp2.java
Description: TestApp2.java