Thank you very much Justin Couch. I appreciate your immediate answer. And I changed my code as your advice. (It had the reference table of Material, and specified the color directly without array). But, there was hardly a change in the result. I was doing such coding in the beginning. But I was changed to the general-purpose code. If the cash reference of 5-6 times only has a loop 10000 times and takes several seconds, Java is too slow, and it can't be used. I think that Java is not so slow, isn't it? Incidentally, $B!! (Jthat color change process was less than 0.5 seconds by GL4Java. (Of course, I can't be compared it is the same. but ....) > The basic problem is not java 3D, but the way you are doing the code. > There is some very simple performance optimisations that you can do to > speed it up. Namely this line: > > shape[i].getAppearance().getMaterial().setDiffuseColor(color[0 > ],color[1],color[2]); > > which is in the method changeColor_actionPerformed(). > > For 10,000 interactions you are going to cop a *huge* amount > of overhead > in just method calls. For every call here you have 3 method calls plus > all the pointer dereferencing of the arrays. > > To start with, don't use arrays for the colour values. You > seem to have > fixed items there that use either one or other colour value. > Leave those > as constants and put them into single variables rather than arrays. > > The reason the method calls are killing you is that you've lost cache > coherency. Every method call there is going to bump you out to main > memory. So, for a single line of code you will have at least 5 fetches > from main memory - which roughly costs you 10 times the amount of time > that a chache hit will take. > > Instead, think of something a little quicker to access the > information. > Use a proper data structure such as a tree map to access the material. > The Shape3Ds act as a the key and the material as the value. > To then set > the values do this > > for(int i = 0; i < shape_count; i++) > { > Material m = (Material)material_map.get(shape[i]); > m.setDiffuseColor(red, green, blue); > } > > That alone should get you a 4-5 times performance increase and quite > possibly more. The reason for this is that the material map and the > shape array will hopefully get bulk loaded into cache rather than > hitting main memory a number of times with every single object. > > The lesson here is first think about what you are doing in your code > before blaming third party libraries. Often it is your fault and not > theirs. =========================================================================== 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