Bonjour,
Le programme ci-dessous fait défiler un cube de gauche à droite
Je voudrai savoir comment faire pour faire défiler la caméra de gauche à droite de la même manière
Merci de bien vouloir m'aider
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j 3d .utils.geometry.*;
public class AlphaTest extends Applet3D
{ public BranchGroup createSceneTree ()
{ // Racine de l'arbre des objets représentés dans la scène 3D
BranchGroup root = new BranchGroup ();
// Création d'un opérateur en fonction des paramètres
Alpha alpha = getAlphaFromParameters ();
// Création de l'animation de translation
TransformGroup position = new TransformGroup ();
position.setCapability (TransformGroup.ALLOW_TRANSFORM_WRITE);
PositionInterpolator animation = new PositionInterpolator (alpha, position);
animation.setStartPosition (-0.8f);
animation.setEndPosition (0.8f);
animation.setSchedulingBounds (new BoundingSphere (new Point 3d (), 10.0));
// Construction de l'arbre
root.addChild (position);
position.addChild (animation);
position.addChild (createScene ());
return root;
}
public Alpha getAlphaFromParameters ()
{ // Création d'un opérateur alpha par défaut. Toutes les propriétés sont à 0 sauf
// loopCount = -1, mode = INCREASING_ENABLE, increasingAlphaDuration = 1000
Alpha alpha = new Alpha ();
String parameter;
// Modification des propriétés de l'opérateur alpha en fonction des paramètres
if ((parameter = getParameter ("loopCount")) != null) alpha.setLoopCount (Integer.parseInt (parameter));
if ((parameter = getParameter ("mode")) != null) { // Décodage des constantes INCREASING_ENABLE et DECREASING_ENABLE
int parameterValue = 0;
if (parameter.indexOf ("INCREASING_ENABLE") >= 0) parameterValue |= Alpha.INCREASING_ENABLE;
if (parameter.indexOf ("DECREASING_ENABLE") >= 0) parameterValue |= Alpha.DECREASING_ENABLE;
alpha.setMode (parameterValue);
}
if ((parameter = getParameter ("triggerTime")) != null) alpha.setTriggerTime (Long.parseLong (parameter));
if ((parameter = getParameter ("phaseDelayDuration")) != null) alpha.setPhaseDelayDuration (Long.parseLong (parameter));
if ((parameter = getParameter ("increasingAlphaDuration")) != null) alpha.setIncreasingAlphaDuration (Long.parseLong (parameter));
if ((parameter = getParameter ("increasingAlphaRampDuration")) != null) alpha.setIncreasingAlphaRampDuration (Long.parseLong (parameter));
if ((parameter = getParameter ("alphaAtOneDuration")) != null) alpha.setAlphaAtOneDuration (Long.parseLong (parameter));
if ((parameter = getParameter ("decreasingAlphaDuration")) != null) alpha.setDecreasingAlphaDuration (Long.parseLong (parameter));
if ((parameter = getParameter ("decreasingAlphaRampDuration")) != null) alpha.setDecreasingAlphaRampDuration (Long.parseLong (parameter));
if ((parameter = getParameter ("alphaAtZeroDuration")) != null) alpha.setAlphaAtZeroDuration (Long.parseLong (parameter));
return alpha;
}
public Node createScene ()
{ return new ColorCube (0.1);
}
// Méthode main () pour permettre d'utiliser cette classe
// comme applet ou comme application
public static void main (String [] args)
{ new MainFrame (new AlphaTest (), args, 300, 85);
}
}
Vince