I've got a cube that flys around my with a splineinterpolator.  Now I'm trying to figure out what is the best way to implement a "trail" behind it.  So far, I've experimented with adding cubes after each processStimulus of the interpolator...that is, get the current position, move a cube (1 of 100 in an array) to the last position.  Do this every frame.  Then, for each frame, I iterate through each cube, and set the TransparencyAttributes for each cube, starting at fully visible, going to invisible by the last cube.  This works, but seems to be VERY inefficient.
 
For some reason, whenever I call this in the loop:
 
TransparencyAttributes.setTransparency(transpVal);
 
The garbage collector starts running VERY frequently...if I comment out that line, GC hardly ever runs.  Has anyone else noticed this behavior?
 
So far I have thought of the following techniques to leave a trail:
 
1) Like I'm doing it now...have an array of 100 cubes in TransformGroups.  At each processStimulus, get position of interpolator, move a cube from array (or wrap around and start taking from the back of the array if we're > 100).  Then iterate through all cubes, setting transparency on each.
 
2) similar to above, but pre-set the transparency on all the cubes, but then translate all 100 cubes for every processStimulus (using an array of past values from the interpolator).  This would avoid calling the costly setTransparency() method int the loop, but would require many transforms (which I believe are cheaper)
 
3) implement some kind of setup where there is no transparency...just cycle through different images...that is, have 100 images, the first being totally bright and visible, and the last totally invisible (transparent GIF's?)  Cycle through them somehow. (how to do this?)
 
4) some fancy voodoo with lines/lineattributes??
 
Anyone have any ideas on how to accomplish something like this efficiently in Java3D?  Will Java3D 1.3 help in this area because of NIO?
 
Thanks for any insight...
 
Michael P. McCutcheon
 

Reply via email to