IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

3D Java Discussion :

java3D, ailes doiseaux!


Sujet :

3D Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    54
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Décembre 2006
    Messages : 54
    Par défaut java3D, ailes doiseaux!
    Bonjour!

    C'est simple je cherche a faire un pauvre "oiseau-like" en java 3D...
    un cube (corps) et deux cubes plats (ailes). Je veut donc animer l'aile droite pour quelle fasse un quart de rotation, comme si laile "battait"... Cela me semble super simple en concept mais je galere!
    Pour linstant "laile" tourne sur elle meme, infiniment!
    Je veut juste un quart de tour, puis quelle repart a zero et refasse un quart de tour, er repart, etc...

    Voila mon code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
     
     
     //----------------------début de la création de la rotation--------------------------------
     
        TransformGroup WinRSpin=new TransformGroup();
     
        // permet de modifier l'objet pendant l'execution
        WinRSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
     
        // on crée un fonction de rotation au cours du temps
        Alpha rotationAlphaWinRSpin=new Alpha(-1,4000);
     
         Transform3D rot = new Transform3D();
         rot.rotX((float)Math.PI/- 2.0f);
        // on crée un comportement qui va appliquer la rotation à l'objet voulu
        RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 0.50f,(float)(2.0*Math.PI));
     
        // on définit la zone sur laquelle va s'appliquer la rotation
        BoundingSphere boundsWinRSpin=new BoundingSphere();
        rotatorWinRSpin.setSchedulingBounds(boundsWinRSpin);
        WinRSpin.addChild(rotatorWinRSpin);
     
    //----------------------début de la création de la rotation--------------------------------

    Des idees?

    Merci!

  2. #2
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    54
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Décembre 2006
    Messages : 54
    Par défaut
    Je m'auto edite:
    rot.rotX((float)Math.PI/- 2.0f);

    cette ligne jarrive a la remplacer par rot.rotX(90);
    Je pense que ca veut dire un angle de rotation de 90 degres par rapport a laxe des X.
    Je peut donc faire:
    rot.rotY(45);
    et
    rot.rotZ(180);
    Ce sont deux examples!

    Le probleme est toujours la: meme en changeant cela:
    1) cela tourne toujours genre sur le centre de la boite
    2) l'angle est foireux...
    Genre meme en faisant une rotation sur X seulement il tourne "en diagonale"...

    Je confirme cela change dangle de rotation quand je change mais je trouve pas les bonnes valeurs!

    A savoir il me semble que jai une vue "orthogonale" genre ma scene nest pas vue de face mais en "diagonale de haut en bas"!!

    Je crois que c'est cela qui fait ke je suis en vue bizarre:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     private void setupViewPlatform()
      {
        viewPlatform = new ViewPlatform();
        setViewingDistance(zViewDistance);
        viewPlatformTransform.addChild(viewPlatform);
      }
      public void setViewingDistance(float viewDistance)
      {
        zViewDistance = viewDistance;
        Transform3D transform = new Transform3D();
        transform.set(new Vector3f(0.0f, 0.0f, zViewDistance));
        viewPlatformTransform.setTransform(transform);
      }
    c'est galere!!

    Il me reste plus que cela et jai finit!!!

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    54
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Décembre 2006
    Messages : 54
    Par défaut
    Je m'autorepond...
    a ce que pense maitnenant je pourrai changer le centre de la "bounding sphere" autour de laquelle rotate ma boite.

    Or je trouve cela dans la doc java:

    setCenter

    public void setCenter(Point3d center)

    Sets the position of this bounding sphere from a point.

    Parameters:
    center - a Point defining the new center of the bounding sphere


    Jai donc penser ecrire: maboundingpshere().setCenter(coordonnees);

    mais ca marche pas ca me dit cest pas une fonction publique!

    Raaah

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2008
    Messages : 7
    Par défaut
    J'ai resolu le probleme du centre (en apparence)
    Il fallait ecrire cela comme cela:
    BoundingSphere boundsWinRSpin=new BoundingSphere(new Point3d((Math.PI / 4.0), 0.0, 0.0), 0.5);
    boundsWinRSpin.setCenter(new Point3d(-10,0,0));



    Cela ne fait toujours pas ce que je veux...

    Je resume, on ma dit de faire tourner l'aile non plus sur son bounding sphere, mais a partir du bounding sphere du corps de l'oiseau!
    Mais meme en faisant cette excellente suggestion, l'objet tourne sur lui meme!
    Il y a donc une variable ou quelque chose que je ne comprends pas...
    Peut etre la place ou cela est situe dans le code je ne sais pas!!!


    Aussi il me semble que je dois faire rotater en fonction de l'axe Z?



    Voici mon code pour l'instant:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
     
     
    Previous bit: This part is only to show I had a bounding sphere to the bird body, and later on I tried to attach it to the wings, so it rotate from it and not from the wing itself bounding sphere.
     
    //beginning of Rotation for Bird
          TransformGroup Bird=new TransformGroup();
     
          //will allow to modify object while executing
          Bird.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
     
          //alpha rotation time related
          Alpha rotationAlphaBird=new Alpha(-1,400);
          Alpha transAlphaBird=new Alpha(-1,5990);
     
          //transform 3d trans for the interpolatipon
          Transform3D transBird=new Transform3D();
     
              //create transform 3d for the Bird
          transBird.set(new Vector3f(1.90f,-.45f,0.9f));
     
          //create the child tranform group for the Bird Box
          Bird.setTransform(transBird);
     
          //matrix for 2positions
          Point3f[] cheminBird=new Point3f[3];
          cheminBird[0]=new Point3f(1.95f,0.0f,-6.8f);
          cheminBird[1]=new Point3f(1.95f,0.90f,-0.8f);         
          cheminBird[2]=new Point3f(1.95f,0.0f,5.8f);
     
          //matrix of floats to make the dots match with timeline
          float[] timePositionBird={0.00f,0.50f,1.0f};
          PositionPathInterpolator interpolBird=new PositionPathInterpolator(transAlphaBird,Bird,transBird,timePosition,cheminBird);
          BoundingSphere bounds3Bird=new BoundingSphere();
          //BoundingSphere bounds3Bird= new BoundingSphere(new Point3d(0.0, 0.0, -50.0), 0.5);
          interpolBird.setSchedulingBounds(bounds3Bird);
          Bird.addChild(interpolBird);
     
          //behviour for our rotation
          RotationInterpolator rotatorBird= new RotationInterpolator(rotationAlphaBird,Bird);
     
           // area where rotation will be
          BoundingSphere boundsBird=new BoundingSphere();
          rotatorBird.setSchedulingBounds(boundsBird);
          Bird.addChild(rotatorBird);
     
            //end of rotation For Bird
     
     
     
    //----------------------début de la création de la rotation--------------------------------
     
        TransformGroup WinRSpin=new TransformGroup();
     
        // permet de modifier l'objet pendant l'execution
        WinRSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
     
        // on crée un fonction de rotation au cours du temps
        Alpha rotationAlphaWinRSpin=new Alpha(-1,2000);
     
         Transform3D rot = new Transform3D();
        // rot.rotX((float)Math.PI/- 2.0f);
        //rot.rotX(-45);
        //rot.rotX((-Math.PI / 4.0)+30); 
        rot.rotZ((-Math.PI / 4.0));
     
        //rot.rotX(-Math.PI / 4.0);
         //rot.rotY(-Math.PI / 4.0);
        // rot.rotZ(-Math.PI / 4.0);
        // rot.rotY(00);
         //rot.rotZ(45);
        // on crée un comportement qui va appliquer la rotation à l'objet voulu
         // on définit la zone sur laquelle va s'appliquer la rotation
     
     
        RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 0.50f,(float)(2.0*Math.PI));
     
        BoundingSphere boundsWinRSpin=new BoundingSphere(new Point3d((Math.PI / 4.0), 0.0, 0.0), 0.5);
       // boundsWinRSpin.setCenter(new Point3d((Math.PI / 4.0),0,0));
        boundsWinRSpin.setCenter(new Point3d(-10,0,0));
        //boundsWinRSpin.setCenter();
        //test put a t3d to a boundingsphere??
        //Transform3D T3Dbounding = new Transform3D();
       // T3Dbounding.set(new Vector3f(5.00f,0.0f,0.00f));
        //WinRSpin.setTransform(T3Dbounding);
        //end test put a t3d to a boundingsphere, not working
     
    rotatorWinRSpin.setSchedulingBounds(boundsWinRSpin);
       // test BoundingSphere of BODY BIRD rotatorWinRSpin.setSchedulingBounds(boundsBird);
        WinRSpin.addChild(rotatorWinRSpin);
     
    //----------------------End de la création de la rotation--------------------------------

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    7
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Avril 2008
    Messages : 7
    Par défaut [RESOLU! ]

    J'ai reussi tout seul!!!


    Je met quand meme la reponse pour les 0.000000000000000000002% de la population mondiale qui utilisent java3d

    ce que je devais faire:

    RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 25,26);



    Je m'etais embrouiller dans les variables, voici mon code avant:

    //RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 0.50f,(float)(2.0*Math.PI));


    c'etait pas beau!

    Je me suis aider de la documentation JAVADOC:

    RotationInterpolator

    public RotationInterpolator(Alpha alpha,
    TransformGroup target,
    Transform3D axisOfTransform,
    float minimumAngle,
    float maximumAngle)
    Constructs a new rotation interpolator that varies the target transform node's rotational component.
    Parameters:
    alpha - the alpha generator to use in the rotation computation
    target - the TransformGroup node affected by this interpolator
    axisOfTransform - the transform that defines the local coordinate system in which this interpolator operates. The rotation is done about the Y-axis of this local coordinate system.
    minimumAngle - the starting angle in radians
    maximumAngle - the ending angle in radians


    Donc pour constraindre une rotation avec un angle specifique (pas 360 degres= tour complet) il fallait changer cela (les 2 dernieres valeurs de rotationInterpolator)
    Oh opar defaut cest sur laxe des Y il faudra changer en fonction de l'axe voulu

    here my bit of code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
     
     
    //beginning of Rotating WINR
          //----------------------début de la création de la rotation--------------------------------
     
        TransformGroup WinRSpin=new TransformGroup();
     
        // permet de modifier l'objet pendant l'execution
        WinRSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
     
        // on crée un fonction de rotation au cours du temps
        Alpha rotationAlphaWinRSpin=new Alpha(-1,1000);
     
     
     
     
         Transform3D rot = new Transform3D();
        rot.rotX((float)Math.PI/- 2.0f);
        //rot.rotX(-45);
        //rot.rotX((-Math.PI / 4.0)+30); 
        //rot.rotZ((-Math.PI / 4.0));
     
        //rot.rotX(-Math.PI / 4.0);
         //rot.rotY(-Math.PI / 4.0);
        // rot.rotZ(-Math.PI / 4.0);
        // rot.rotY(00);
         //rot.rotZ(45);
        // on crée un comportement qui va appliquer la rotation à l'objet voulu
         // on définit la zone sur laquelle va s'appliquer la rotation
     
     
        //RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 0.50f,(float)(2.0*Math.PI));
    RotationInterpolator rotatorWinRSpin=new RotationInterpolator(rotationAlphaWinRSpin,WinRSpin, rot, 25,26);
     
        BoundingSphere boundsWinRSpin=new BoundingSphere(new Point3d((Math.PI / 4.0), 0.0, 0.0), 0.5);
       // boundsWinRSpin.setCenter(new Point3d((Math.PI / 4.0),0,0));
        boundsWinRSpin.setCenter(new Point3d(-10,0,0));
        //boundsWinRSpin.setCenter();
        //test put a t3d to a boundingsphere??
        //Transform3D T3Dbounding = new Transform3D();
       // T3Dbounding.set(new Vector3f(5.00f,0.0f,0.00f));
        //WinRSpin.setTransform(T3Dbounding);
        //end test put a t3d to a boundingsphere, not working
     
    rotatorWinRSpin.setSchedulingBounds(boundsWinRSpin);
       // test BoundingSphere of BODY BIRD rotatorWinRSpin.setSchedulingBounds(boundsBird);
        WinRSpin.addChild(rotatorWinRSpin);
     
    //----------------------End de la création de la rotation--------------------------------
     
    BirdWingR.addChild(WinRSpin);
    // on cree un cube qui hérite de la rotation
    //WinRSpin.addChild(new ColorCube(0.5));// de rayon 50 cm
     WinRSpin.addChild(new com.sun.j3d.utils.geometry.Box(.43f,.07f,.22f, primflagsx,apx));
     
          //End of Rotating WINR


    I hope it will help others as I really struggled to find help on the internet, on forums, etc...
    Merci a ceux qui m'ont aide, c'est a dire pas grand monde!
    XD

Discussions similaires

  1. [java3D][collision]
    Par geofun dans le forum 3D
    Réponses: 7
    Dernier message: 12/02/2007, 14h49
  2. [java] java3d vs Jogl
    Par mandale dans le forum OpenGL
    Réponses: 3
    Dernier message: 03/01/2005, 15h44
  3. [java3d] superposition des éléments
    Par moutse dans le forum 3D
    Réponses: 3
    Dernier message: 19/10/2004, 12h59
  4. Réponses: 3
    Dernier message: 07/10/2004, 17h02
  5. [Java3D]Construction de terrain
    Par zoulou1212 dans le forum 3D
    Réponses: 6
    Dernier message: 17/09/2004, 11h06

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo