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

JavaFX Discussion :

Premiers tests 3D


Sujet :

JavaFX

  1. #1
    Membre averti

    Profil pro
    Inscrit en
    Février 2009
    Messages
    284
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2009
    Messages : 284
    Points : 409
    Points
    409
    Par défaut Premiers tests 3D
    Je propose ce post pour les questions sur la 3D.
    J'ai essayé de faire un cube mais les faces ne s'affichent pas bien



    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
     
    public class Cube extends CustomNode {
        public var origin: Point3D = Point3D{}
        public-init var size: Number = 150;
        init {
            children = [
                for(n in [0..1]) [
                    Rectangle {
                        fill: Color.LIGHTGRAY
                        stroke: Color.BLACK
                        strokeWidth: 2
                        translateZ: size*n
                        width: size height: size
                    }
                    Rectangle {
                        rotationAxis: Point3D {
                            x:0 y:10 z:0
                        }
                        rotate: 90
                        fill: Color.LIGHTGREEN
                        stroke: Color.BLACK
                        strokeWidth: 2
                        translateX: (size*(n-.5))
                        translateZ: size/2
                        width: size height: size
                    }
                    Rectangle {
                        rotationAxis: Point3D {
                            x:1 y:0 z:0
                        }
                        rotate: 90
                        fill: Color.LIGHTSKYBLUE
                        stroke: Color.BLACK
                        strokeWidth: 2
                        translateY: size*(n-.5)
                        translateZ: size/2
                        width: size height: size
                    }
                ]
            ]
        }
    }
    function run() {
        def feats = ConditionalFeature.values();
        for(f in feats) {
            println("feature {f}=>{Platform.isSupported(f)}");
        }
        def cube = Cube {
            size: 100
            opacity: 1
            rotationAxis: Point3D{z: 1}
        }
         def grp = Group {
     
            rotationAxis: Point3D{x: 1 y: 1}
            rotate: 60
            translateZ: 100
            translateX: 100
            translateY: 100
            content: cube
        }
        Timeline {
            repeatCount: Timeline.INDEFINITE
            keyFrames: [at(2s){ cube.rotate => 360}]
        }.playFromStart();
     
        Stage {
    	title : "3D Cube"
    	onClose: function () {  }
    	scene: Scene {
                width: 300
                height: 300
                fill: Color.TRANSPARENT
                camera: PerspectiveCamera {
                    fieldOfView: 200
                }
                content: [
                    grp
                ]
           }
       }
    }

  2. #2
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut
    Vu la manière dont les faces sont orientées dans la boucle de création, je me demandais tout simplement si ce n'était pas un problème de normale mal orientée (les faces arrières du cube font face à son volume interne au lieu de faire face à l'extérieur).
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

  3. #3
    Membre averti

    Profil pro
    Inscrit en
    Février 2009
    Messages
    284
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2009
    Messages : 284
    Points : 409
    Points
    409
    Par défaut
    Tu as raison bouye, je l'ai un peu fait à l'arrache ce cube. Je vais essayé comme tu l'as suggéré.

  4. #4
    Membre averti

    Profil pro
    Inscrit en
    Février 2009
    Messages
    284
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2009
    Messages : 284
    Points : 409
    Points
    409
    Par défaut
    Ma science en 3D se résume à la règle du tir-bouchon mais j'ai retenté un truc et me voilà perplexe, J'ai l'impression que les deux rectangles se chevauchent toujours de la même façon.



    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
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
     
    public class Cube extends CustomNode {
        public var top = true;
        public var back = true;
        public var origin: Point3D = Point3D{}
        public-init var size: Number = 150;
        def repereSize = 30;
        function getFace(text: String): Node[] {
            [
                Rectangle {
                    fill: Color.LIGHTGRAY
                    stroke: Color.BLACK
                    strokeWidth: 2
                    width: size height: size
                }
                Label {
                    text: text
                }
            ]
        }
     
        init {
            def repere = Group {
                content: [
                    Line {
                        strokeWidth: 2
                        stroke: Color.BLUE
                        endX: repereSize
                    }
                    Line {
                        strokeWidth: 2
                        endY: repereSize
                        stroke: Color.RED
                    }
                    Line {
                        transforms: [Rotate{axis: Rotate.Y_AXIS angle: 270}]
                        strokeWidth: 2
                        endX: repereSize
                        stroke: Color.GREEN
                    }
                ]
            }
            def backFace: Group = Group {
                visible: bind back
                content: getFace("BACK");
            }
            def topFace: Group = Group {
                translateZ: 100
                visible: bind top
                content: getFace("TOP");
     
            }
            children = [
                repere, backFace,topFace
            ]
        }
    }
    function run() {
        def feats = ConditionalFeature.values();
        for(f in feats) {
            println("feature {f}=>{Platform.isSupported(f)}");
        }
        def cube = Cube {
            size: 100
            opacity: 1
        }
        var tz: Number = 150;
        var tx: Number = 150;
        var ty: Number = 150;
        var rot: Number = 0;
         def grp = Group {
            rotationAxis: Point3D{x: 1y: 1}
            translateZ: bind tz
            translateX: bind tx
            translateY: bind ty
            content: cube
            rotate: bind rot
        }
        def tm = Timeline {
            repeatCount: Timeline.INDEFINITE
            keyFrames: [at(6s){ rot => 360}]
        }
        var play = true on replace {
            if(play)tm.playFromStart() else tm.stop();
        }
     
        var field: Number = 45;
        Stage {
    	title : "3D Cube"
    	onClose: function () {  }
    	scene: Scene {
                width: 450
                height: 450
                content: [
                    VBox {
                        layoutX: 20
                        layoutY: 20
                        spacing: 20
                        content: [
                            CheckBox {
                                text: "Animation" selected: bind play with inverse
                            }
                            Grid {
                                hgap: 10 vgap: 10
                                rows: [
                                    GridRow {
                                        maxWidth: 200
                                        cells: [
                                            Label{text: "Afficher:"}
                                            HBox {
                                                spacing: 10
                                                content: [
                                                    CheckBox {
                                                        text: "Back"
                                                        selected: bind cube.back with inverse
                                                    }
                                                    CheckBox {
                                                        text: "Top"
                                                        selected: bind cube.top with inverse
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                    GridRow {
                                        cells: [
                                            Label{text: "Rotation:"}
                                            Slider {
                                                disable: bind play
                                                min: 0 max: 360 showTickMarks: true showTickLabels:true
                                                value: bind rot with inverse
                                            }
                                        ]
                                    }
                                    GridRow {
                                        cells: [
                                            Label{text: "TX"}
                                            Slider {
                                                min: 0 max: 300 showTickMarks: true showTickLabels:true
                                                value: bind tx with inverse
                                            }
                                        ]
                                    }
                                    GridRow {
                                        cells: [
                                            Label{text: "TY"}
                                            Slider {
                                                min: 0 max: 300 showTickMarks: true showTickLabels:true
                                                value: bind ty with inverse
                                            }
                                        ]
                                    }
                                    GridRow {
                                        cells: [
                                            Label{text: "TZ"}
                                            Slider {
                                                min: 0 max: 300 showTickMarks: true showTickLabels:true
                                                value: bind tz with inverse
                                            }
                                        ]
                                    }
                                ]
                            }
                            grp
                        ]
                    }
                ]
           }
       }
    }

  5. #5
    Membre averti

    Profil pro
    Inscrit en
    Février 2009
    Messages
    284
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2009
    Messages : 284
    Points : 409
    Points
    409
    Par défaut
    La réponse au problème est donnée par un gars de InteractiveMesh
    As of my experiences with the new 'SCENE3D' conditional (optional) feature my conclusion is:

    The cube faces (Rectangle) are drawn in order of their position in the children sequence: if face (j) overlaps face (i; i < j) it is drawn on top. Their z-/depth-values are ignored! So, if a face is rotated away from the camera's position and its z-values are increased it is drawn still not before the predecessors in the sequence are drawn.

    In case of a simple model like a cube or box this dilemma can be solved by hiding (visible = false) all covered faces. A cube's face is covered when its frontside 'Normal' is directed away from the camera.

    Doing more complex 3D modelling and animation based on these features would be a nice way to torture students by a (sadistic) professor.

    Elsewhere it is said that the new 'prism' renderer is only "... available in the 1.3 development environment, but not in a deployed applet or JWS." and "... used on TV, it is not supported in 1.3 on desktop. Turning it on manually is for development purposes and kicks and giggles. Actually deploying an app with it turned on may or may not work in this release".

    August

  6. #6
    Rédacteur/Modérateur

    Avatar de bouye
    Homme Profil pro
    Information Technologies Specialist (Scientific Computing)
    Inscrit en
    Août 2005
    Messages
    6 840
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : Nouvelle-Calédonie

    Informations professionnelles :
    Activité : Information Technologies Specialist (Scientific Computing)
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Août 2005
    Messages : 6 840
    Points : 22 851
    Points
    22 851
    Billets dans le blog
    51
    Par défaut

    et c'est reparti pour 10 mois d'attente avant d'avoir une version utilisable...

    Et pis franchement cela fait plus d'1 an que le blog de Chris Oliver nous montre des objets en 3D (pas juste des cubes) http://blogs.sun.com/chrisoliver/, sans parler de celui d'Anthony Rogers qui lui montre carrément une surface déformée et autres objets complexes http://blogs.sun.com/ant/ (qu'on ne viennet pas me dire qu'ils ont fait le tank ou la porsche à grand coup de noeuds 2D).

    C'est donc qu'ils ont en interne des filtres d'import 3DS ou des classes permettant de définir des volumes...

    Bon après c'est vrai que perso je n'ai pas vraiment usage de la 3D mais bon...

    Tssss y a des jours où je me demande si ça ne vaudrait pas plus le coup de sortir ma carte de crédit pour acheter Expression Studio ou Flex Builder (vu que j'ai déjà Visual Studio 2008 et CS 4 au boulot).
    Merci de penser au tag quand une réponse a été apportée à votre question. Aucune réponse ne sera donnée à des messages privés portant sur des questions d'ordre technique. Les forums sont là pour que vous y postiez publiquement vos problèmes.

    suivez mon blog sur Développez.

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning. ~ Rich Cook

Discussions similaires

  1. premier test de Javascript
    Par laurentSc dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 08/05/2008, 19h32
  2. Config TexNicCenter et premier test de page
    Par JeanMi66 dans le forum Editeurs / Outils
    Réponses: 7
    Dernier message: 03/08/2007, 11h45
  3. [J2ME Polish] Premiers tests du sample "menu" proposé
    Par white-rabbit dans le forum Java ME
    Réponses: 2
    Dernier message: 02/08/2007, 18h26
  4. [AJAX] Mon premier test avec Ajax : échec
    Par Nasky dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 28/05/2007, 01h24

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