Norihito Hiruma wrote:
> I am developer of CAD-Application.
> Right now, I am trying Java3D but Java3D's attribute change performance is
> too bad.
> The color change of 2500 Attributes takes about six seconds.
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.
--
Justin Couch Author, Java Hacker
http://www.vlc.com.au/~justin/ Java 3D FAQ Maintainer
http://www.j3d.org/ J3D.org The Java 3D Community Site
-------------------------------------------------------------------
"Humanism is dead. Animals think, feel; so do machines now.
Neither man nor woman is the measure of all things. Every organism
process data according to its domain, its environment; you, with
all your brains, would be useless in a mouse's universe..."
- Greg Bear, Slant
-------------------------------------------------------------------
===========================================================================
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".