• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. OpenJFX
  4. 3D Features

Page History

Versions Compared

Old Version 30

changes.mady.by.user Brian Beck

Saved on Jan 18, 2013

compared with

New Version 31

changes.mady.by.user Brian Beck

Saved on Feb 21, 2013

  • Previous Change: Difference between versions 29 and 30
  • Next Change: Difference between versions 31 and 32
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Syncing content with existing wiki.

...

Three umbrella JIRA issues were created to capture most of the work: Movable Camera , 3D Geometry, and 3D Attributes

Here is a simple 1 page example of rendering a blue sphere and a red box with mouse control: SphereAndBox.java

Proposed API

Proposed Features

...

  • Camera is now a Node
  • Camera can be added to a scene graph
  • Camera's position and aim (or orientation) is set using standard Node transform properties and methods
  • For backward compatibility, fixed camera need not be added to the scene
  • Added new properties for near & far clipping plane
  • SubScene is a special Node for scene separation
  • It can be used to render part of the Scene with different camera
  • Possible use cases are:
    • Picture in picture
    • Overlay for UI controls (needs a static camera)
    • Underlay for background (static or updated less frequently)
    • "HeadsOverlay or "heads-up" display for UI controls in a scene with a moving camera
Camera Class Hierarchy
Panel
  • javafx.scene.Node
    • javafx.scene.Camera (abstract)
      • javafx.scene.ParallelCamera
      • javafx.scene.PerspectiveCamera
    • javafx.scene.SubScene

...

Specifying a fixed Camera (existing 2.2 API)

Code Block

// Create a camera and add it to the Scene
Camera camera = new PerspectiveCamera();
scene.setCamera(camera);

Specifying a movable Camera

Code Block

// Create a camera and add it to the Scene
Camera camera = new PerspectiveCamera();
scene.setCamera(camera);

// Add camera to scene graph (so it can move)
Group cameraGroup = new Group();
cameraGroup.getChildren().add(camera);
root.getChildren().add(cameraGroup);

// Rotate the camera
camera.rotate(45);

// Move the cameraGroup (camera moves with it)
cameraGroup.setTranslateZ(-75);

...

Panel
  • javafx.scene.Node
    • javafx.scene.shape3dshape.Shape3D (abstract)
      • javafx.scene.shape3dshape.MeshView
      • javafx.scene.shape3dshape.Box
      • javafx.scene.shape3dshape.Cylinder
      • javafx.scene.shape3dshape.Sphere
Mesh Class Hierarchy
Panel
  • java.lang.Object
    • javafx.scene.shape3dshape.Mesh (abstract)
      • javafx.scene.shape3dshape.TriangleMesh
Code Segment

Defining a MeshView

Code Block

// Create the arrays of positions, texCoords
float[] positions = createPositions();
float[] texCoords = createUVs();

// Create faces (indices into the positions, texCoord arrays)
int[] faces = createFaces();

// Create a mesh
TriangleMesh mesh = new TriangleMesh();
mesh.setPositions(positions);
mesh.setTexCoords(texCoords);
mesh.setFaces(faces);

// Create meshView
MeshView mv = new MeshView(mesh);

Using Predefined Shapes

Code Block

// Create a sphere with the given radius
Sphere sphere = new Sphere(10.0);

// Create a sphere with the given radius, number of divisions
Sphere sphere = new Sphere(10.0, 40);

// Create a cylinder with the given radius, and height
Cylinder cylinder = new Cylinder(10.0, 30.0);

// Create a box with the given width, height, and depth
Box box = new Box(1.0, 1.0, 1.0);

// NOTE: Predefined 3D shapes are centered at (0,0,0)

...

Panel
  • javafx.scene.Node
    • javafx.scene.light.LightBase (abstract)
      • javafx.scene.light.AmbientLight
      • javafx.scene.light.PointLight
Material Class Hierarchy
Panel
  • java.lang.Object
    • javafx.scene.materialpaint.Material (abstract)
      • javafx.scene.materialpaint.PhongMaterial
Code Segment

Defining Lights

Code Block

// Create point light and add it to the Scene
PointLight light = new PointLight();
light.setColor(Color.RED);
scene.getLights().add(light);

// Add light to scene graph (so it can move)
Group lightGroup = new Group();
lightGroup.getChildren().add(light);
root.getChildren().add(lightGroup);

// Rotate the light
light.rotate(45);

// Move the lightGroup (light moves with it)
lightGroup.setTranslateZ(-75);

Defining Materials

Code Block

// Create material
Material mat = new PhongMaterial();
Image diffuseMap = new Image("diffuseMap.png");
Image bumpMap = new Image("normalMap.png");

// Set material properties
mat.setDiffuseMap(diffuseMap);
mat.setBumpMap(normalMap);
mat.setSpecularColor(Color.WHITE);

// Use the material for a shape
shape3d.setMaterial(mat);

...

Proposed API to support 3D picking: Picking3dAPI

Methods added to Node

  • A LOD helper method that returns the area of the Node projected onto the physical screen in pixel units.
Code Block
public double computeAreaInScreen()
  • A set of 3D transform  methods
Code Block
public Point3D sceneToLocal(Point3D scenePoint)
public Point3D sceneToLocal(double sceneX, double sceneY, double sceneZ)
public Point3D localToScene(Point3D localPoint)
public Point3D localToScene(double x, double y, double z)
public Point3D parentToLocal(Point3D parentPoint)
public Point3D parentToLocal(double parentX, double parentY, double parentZ)
public Point3D localToParent(Point3D localPoint)
public Point3D localToParent(double x, double y, double z)

Loader support

  • Many 3D file formats exist, such as:
    •  Obj, Maya, 3D Studio Max, Collada, KRML
  • We will not provide a loader as part of the JavaFX runtime
  • We will make sample code available for one or two popular formats

 

Overview
Content Tools
ThemeBuilder

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.23
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 247, "requestCorrelationId": "d4befadc793c994c"}