{"id":37,"date":"2010-04-29T12:30:11","date_gmt":"2010-04-29T11:30:11","guid":{"rendered":"http:\/\/www.jroller.com\/peter_pilgrim\/entry\/3d_capabilities_in_javafx_1"},"modified":"2010-04-29T12:30:11","modified_gmt":"2010-04-29T11:30:11","slug":"3d-capabilities-in-javafx-1-3-release","status":"publish","type":"post","link":"https:\/\/www.xenonique.co.uk\/blog\/2010\/04\/29\/3d-capabilities-in-javafx-1-3-release\/","title":{"rendered":"3D Capabilities in JavaFX 1.3 Release"},"content":{"rendered":"<p>Hi All<\/p>\n<p>Last week on the 22nd April 2010, <a href=\"https:\/\/javafx.com\">JavaFX 1.3 Release<\/a> was released to the general public. I immediately scanned the <a href=\"\">release notes<\/a> and was intrigued by the <a href=\"https:\/\/javafx.com\/docs\/articles\/javafx1-3.jsp\">3D capabilities<\/a>.<\/p>\n<p>Congratulations to the SDK team for listening to criticism and improvements, mine included. I suggested in an <a href=\"https:\/\/audioboo.fm\/boos\/81294-javafx-is-alive-part-2-the-foundations-reengineering-underneath-the-tip-of-the-iceberg\">AudioBoo<\/a> that we needed a <a href=\"https:\/\/java.sun.com\/javafx\/1.3\/docs\/api\/javafx.runtime\/javafx.runtime.ConditionalFeature.html\">Capabilities API<\/a> for the platform. It is now included there. <\/p>\n<p>\nSo if you do have accelerated GPU chip as your graphic card and you run the follow application with the JVM argument <code>-Xtoolkit prism<\/prism> you will be surprised.\n<\/p>\n<pre>\nimport javafx.stage.Stage;\nimport javafx.scene.Scene;\nimport javafx.scene.text.Text;\nimport javafx.scene.text.Font;\nimport javafx.scene.control.Slider;\nimport javafx.scene.shape.Rectangle;\nimport javafx.scene.paint.Color;\nimport javafx.scene.layout.Tile;\nimport javafx.scene.control.Label;\nimport javafx.scene.layout.LayoutInfo;\nimport javafx.scene.PerspectiveCamera;\nimport javafx.scene.transform.*;\nimport javafx.scene.paint.LinearGradient;\nimport javafx.scene.paint.Stop;\n\n\nvar fieldOfView = 200.0 on replace {\n    println(\"fieldOfView={fieldOfView}\");\n};\n\nvar rotateX: Number on replace {\n    println(\"rotateX={%5.2f rotateX}\")\n};\nvar rotateY: Number on replace {\n    println(\"rotateY={%5.2f rotateY}\")\n};\nvar rotateZ: Number on replace {\n    println(\"rotateZ={%5.2f rotateZ}\")\n};\n\nvar scene: Scene;\nvar rect: Rectangle;\n\n\n\/**\n * Research JavaFX 3D with a basic 2D rectangle\n * www.xenonique.co.uk\n * 27th April 2010\n * @author Peter Pilgrim\n *\/\nStage {\n    title: \"Peter Pilgrim:: Research JavaFX 1.3 Release :: XeNoNiQUe :: London, UK\"\n    scene: scene =Scene {\n        camera: PerspectiveCamera {\n            fieldOfView: bind fieldOfView\n        }\n\n        fill: LinearGradient {\n            startX: 0.0 startY: 0.0\n            endX: 0.0  endY : 1.0\n            stops: [\n                Stop {\n                    color : Color.LIGHTGRAY\n                    offset: 0.0\n                },\n                Stop {\n                    color : Color.DARKGRAY\n                    offset: 0.25\n                },\n                Stop {\n                    color : Color.GRAY\n                    offset: 1.0\n                },\n            ]\n        }\n\n\n        width: 500\n        height: 500\n        content: [\n            Text {\n                layoutX: 50\n                layoutY: bind scene.height - 150\n                font : Font { size : 12 }\n                content: \n                \"Rectangle rotation in X,Y and Z manipulate with Slider\\n\"\n                \"No Graphics 3D Primitives in FX 1.3 release!\\n\"\n                \"You can translate 2D SG object in 3D space\\n\"\n                \"No yet ready for 3D graphic application then.\"\n            },\n            rect = Rectangle {\n                translateX: 200\n                translateY: 200\n                translateZ: 100\n                transforms: [\n                    Rotate {\n                        axis: Rotate.Y_AXIS\n                        angle: bind rotateX\n                    },\n                    Rotate {\n                        axis: Rotate.X_AXIS\n                        angle: bind rotateY\n                    },\n                    Rotate {\n                        axis: Rotate.Z_AXIS\n                        angle: bind rotateZ\n                    }\n                ]\n\n\n                x: -100, y: -100\n                width: 200, height: 200\n                arcWidth: 10 arcHeight: 10\n                fill: Color.web(\"#ff9900\")\n                strokeWidth: 2\n                stroke: Color.web(\"#FF0000\")\n            },\n            Tile {\n                layoutX: 10\n                layoutY: 10\n                columns: 2\n                hgap: 3\n                vgap: 6\n\n                content: [\n                    Label {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        text: \"Rotate X:\"\n                    },\n                    Slider {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        min: 0\n                        max: 360\n                        vertical: false\n                        value: bind rotateX with inverse\n                    },\n                    Label {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        text: \"Rotate Y:\"\n                    },\n                    Slider {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        min: 0\n                        max: 360\n                        vertical: false\n                        value: bind rotateY with inverse\n                    },\n                    Label {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        text: \"Rotate Z:\"\n                    },\n                    Slider {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        min: 0\n                        max: 360\n                        vertical: false\n                        value: bind rotateZ with inverse\n                    },\n                    Label {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        text: \"Field of View:\"\n                    },\n                    Slider {\n                        layoutInfo: LayoutInfo { width: 200 }\n                        min: 0\n                        max: 360\n                        vertical: false\n                        value: bind fieldOfView with inverse;\n                    },\n                ]\n            }\n\n\n        ]\n    }\n}\n\n<\/pre>\n<ul>\n<li> JavaFX 1.3 release has no 3D graphics primitives (yet). <\/li>\n<li> There is however javafx.geometry.Point3D and that seems to be defining rotation around an arbitary axis in 3D space<\/li>\n<li> There is no way to find out the world view transform or even the perspective transform through the API. (Pick up an educational computer graphics book, like <a href=\"https:\/\/www.amazon.co.uk\/Computer-Graphics-reissued-2nd-Ed\/dp\/0201848406\/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1272559873&#038;sr=1-1\">James D. Foley's<\/a> or <a href=\"https:\/\/www.amazon.co.uk\/3D-Computer-Graphics-Alan-Watt\/dp\/0201398559\/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1272559968&#038;sr=1-1\">Dr. Alan Watts<\/a> to understand these concepts 4 dimensional matrix transformations. )<\/li>\n<li> There is a way to translate 2D shapes into 3D cartesian space as the code above illustrates<\/li>\n<li> The rotation of objects in the 3D world of JavaFX is a little weird at the moment. (From the example of code above, I am unsure, if I got it completely correct)\n<\/li>\n<\/ul>\n<p>The new grahics stack is decent proof of concept and more importantly proof of delivery of the new architecture. So my worries aside of the Oracle acquisition of Sun, I know that my next great space 3D game will not be written with JavaFX 1.3, however the speed and the runtime performance are most welcome.<\/p>\n<p>\nPeter Pilgrim. Fast tracked blog entry. Out\n<\/p>\n<p>\nPS: I believe change the <em>field-of-view<\/em> dynamically does not work in the example. However I may have written it wrong? Have a pop yourself.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi All Last week on the 22nd April 2010, JavaFX 1.3 Release was released to the general public. I immediately scanned the release notes and was intrigued by the 3D capabilities. Congratulations to the SDK team for listening to criticism and improvements, mine included. I suggested in an AudioBoo that we needed a Capabilities API [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/37"}],"collection":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":0,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xenonique.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}