610 likes | 1.01k Views
Exploring JavaFX 3D. Jim Weaver Java Technology Ambassador Oracle Corporation @ JavaFXpert james.weaver@oracle.com. Introduction to JavaFX 3D Nuts and Bolts of JavaFX 3D More Fun with JavaFX 3D. Program Agenda. Please note.
E N D
Exploring JavaFX 3D Jim Weaver Java Technology Ambassador Oracle Corporation @JavaFXpert james.weaver@oracle.com
Introduction to JavaFX 3D • Nuts and Bolts of JavaFX 3D • More Fun with JavaFX3D ProgramAgenda
Please note The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 3
Visit the 3D Features for JavaFX 8 Wiki https://wikis.oracle.com/display/OpenJDK/3D+Features 7
Visit Here: http://fxexperience.com Tip: This site is authored by Oracle JavaFX Engineers 8
“JavaFX 3D gives you the ability to use 3D geometry, cameras, and lights in JavaFX.” Jasper Potts JavaFX Engineer, Oracle Corporation
JavaFX 3D Application Example http://fxexperience.com/2013/02/javafx-3d-early-access-available/ 10
JavaFX 3D Use Cases Inventory and Process Visualization Scientific and Engineering Visualization 3D Charting Mechanical CAD and CAE Medical Imaging 11
More JavaFX 3D Use Cases Product Marketing Architectural Design and Walkthroughs Advanced User Experience Mission Planning Training Entertainment 12
Nuts and Bolts of JavaFX 3D(Shapes, Materials, Textures, Lights, Cameras)
Mesh Geometry (3D Shapes) Predefined shapes Box Cylinder Sphere User-defined shapes Using TriangleMesh/ MeshView https://wikis.oracle.com/display/OpenJDK/SphereAndBox.java 14
Rotating the 3D Shapes Tip: Use lambda expressions as shown here to simplify event handling 16
3D Materials and Textures PhongMaterial has these properties Ambient color Diffuse color, diffuse map Specular color, specular map Specular power Bump map Self-illumination map https://wikis.oracle.com/display/OpenJDK/3D+Features 17
UV Mapping Textures to Shapes Tip: A texture is a 2D image to be mapped on a 3D surface Source: http://en.wikipedia.org/wiki/File:UVMapping.png 18
Placing a Texture on a Cylinder Note that the texture is mapped three times to the cylinder radius height 21
Specifying Divisions on a Cylinder radius divisions height 22
Placing an Image on a Box Note that the texture is mapped six times to the box Tip: A Box doesn’t have to be a cube. It may have different width, height and depth args 23
Using TriangleMesh / MeshView If the same texture on all sides of the cube isn’t desired, a user-defined shape may be created using TriangleMesh and MeshView 24
Understanding TriangleMesh 8 points 0, 0 1, 0 14 texCoords Image 12 faces Tip: Best practice for texture map dimensions is powers of two (e.g. 1024x512) 12 faces 0, 1 1, 1 26
Using TriangleMeshPoints Tip: The API for points, texCoords, and faces is currently being modified, primarily to hold this data in different structures. (For example) 27
Using TriangleMeshTexture Coords (For example) 28
Using TriangleMeshFaces 0, 2, 1 are points[] indices 10, 5, 9 are texCoords[] indices 29
Using TriangleMeshSmoothing Groups (and putting all the pieces together of our user-defined shape) These are faces[] indices 30
3D Lights Lights are nodes in the scene graph PointLight AmbientLight Default light provided if no active lights https://wikis.oracle.com/display/OpenJDK/3D+Features 32
Lights, Camera, Action! Tip: The camera is also a node in the scene graph, so it is moveable 33
Using a SubScene • SubScene is a special node for scene separation • Renders part of the scene with a different camera • Some use cases are: • Overlay for UI controls • Underlay for background • "Heads-up" display 35
3D Node Picking • Some events (e.g. MouseEvent and TouchEvent) have a getPickResult() method • PickResult contains info such as • Node picked • 3D point picked on node • Distance of point from camera • Face # of node picked 38
Platonic Solids Tip: Sample code for loading a 3D format will be made available. Third-party loaders are available as well. 40
Switching Modes (TouchPoint#belongsTo) GuitarString3D instance 45