Try to reuse the old alpha. You should simply set the new duration and AFTER that you NEED to reset the start time, by calling alpha.setStartTime(System.currentTimeMillis()); Actually, you don't need the vector of interpolators, you only need the alpha objects to play with.
 
Cheers,
 
Florin
-----Urspr�ngliche Nachricht-----
Von: A. Murat Tanyer [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 29. Januar 2003 18:43
An: [EMAIL PROTECTED]
Betreff: [JAVA3D] help needed urgently

Dear all,

I don't know whether this problem is too difficult to resolve but I can't get rid of it. I send this email to the list but couldn't get proper reply.


I am trying to make an animation of my scene. Basically, the objects should go from transparent to opaque. The duration of animation for each object (the aplha value) should be assigned during the run time by the user. That means that the user selects objects during the run time and assigns a 't' duration to them. 't' could be different for each selection group. Within the assigned 't' duration, the objects should go from transparent to opaque. My scenegraph is attached.

During the construction of my scene, I created a default TransparencyInterpolator with a default Alpha f
or each object.
During the run time I create a new Alpha with the correct duration ('t' duration) and replace the previous alpha with this new one.

The problem is I can't get my objects animated. My questions are:

i) Is my logic for this animation correct?
ii) Is this possible to replace the alpha value of my default TransparencyInterpolator with a new one during the run time?
iii) Do I need to create a new
TransparencyInterpolator for each of my object and than change the alpha value?
iv) How can I start and stop the activity of a TransparencyInterpolator during the run time?

Thanks for any help



// MY CODE
Vector v_linked_elements = new Vector();

//LOOP FOR EACH ELEMENT
{

BranchGroup cT = new BranchGroup();

TransparencyAttributes objTransp = new TransparencyAttributes();
objTransp.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
objTransp.setTransparencyMode(TransparencyAttributes.BLENDED);
objTransp.setTransparency(1.0f);

Appearance app2 = part2.getAppearance();
app2.setTransparencyAttributes(objTransp);
part2.setAppearance(app2);
part2.setPickable(false);

//CREATE A DEFAULT ALPHA VALUE FOR THE TRANSPARENCYINTERPOLATOR
Alpha alpha = new Alpha();
//CREATE A
DEFAULT TRANSPARENCYINTERPOLATOR
TransparencyInterpolator traInt = new TransparencyInterpolator (alpha, objTransp);
traInt.setSchedulingBounds(Scenegraph.bounds);
//ADD TRANSPARENCYINTERPOLATOR TO THE SCENEGRAPH
cT.addChild(traInt);

//PUT EACH
TRANSPARENCYINTERPOLATOR INTO A VECTOR SO THAT I CAN ACCESS THEM LATER
v_linked_elements.add(traInt);
....
} //END LOOP FOR EACH ELEMENT


//DURING THE RUN TIME CREATE A NEW ALPHA AND ASSIGN TO THE SELECTED OBJECTS' TRANSPARENCYINTERPOL.
Alpha alp_dur = new Alpha();
alp_dur.setLoopCount(-1);
alp_dur.setMode(Alpha.DECREASING_ENABLE);
alp_dur.setTriggerTime(0);
alp_dur.setPhaseDelayDuration(delay*2000);
alp_dur.setIncreasingAlphaDuration(0);
alp_dur.setDecreasingAlphaDuration((long)duration * 5000); //correct 't' value for the duration
alp_dur.setAlphaAtZeroDuration(0);

//ASSIGN NEW ALPHA INSTEAD OF THE PREVIOUS ALPHAS THAT ARE IN THE VECTOR
for(int i=0; i < v_linked_elements.size(); i++)
((TransparencyInterpolator)(v_linked_elements_TI.get(i))).setAlpha(
alp_dur);

Reply via email to