Hi August,
John Yoon, Richard and I have a private discussion on the
possibility of avoiding "cloning" for your use case. We wonder do you
ever need to interact with the 3D scene via the various sub views? Or
these sub views are purely for viewing the 3d scene with different
cameras? If this is your use case scenario, have you thought of using
Node.snapshot()?
public WritableImage snapshot(SnapshotParameters params,
WritableImage image) {
Where you can call snapshot on the node with a specified camera (in the
snapshot params). It will then render the node from that camera's
viewpoint and put the result in an WritableImage. You can then add it
into the scenegraph using an ImageView. I have attached a very simple
example on how snapshot can be used with an ancillary camera. Please let
us know of your progress in this work. We would hope to learn from this
work so that we can evaluate it to see if there are any performance /
semantic problems. You will likely ended up with a one frame behind
rendering in those sub views, but do let us know for your finding.
Thanks,
- Chien
On 7/26/2013 10:53 AM, Chien Yang wrote:
Yes, that is still the approach. The challenge isn't just strictly on
rendering. Let's take picking a "shared" node as an example. Imagine
this node is in a scenegraph viewed by more than 1 camera. The
question is where do we hang the set picked information. There is some
level of "cloning" needed within JavaFX if we want to free application
developer from doing it.
- Chien
On 7/25/2013 7:31 PM, Richard Bair wrote:
I thought the approach was not to have multiple parents, but to
render into an image.
On Jul 25, 2013, at 5:26 PM, Chien Yang<chien.y...@oracle.com> wrote:
We don't support sharable Node. Some one will have to do the cloning
of the scenegraph, either the application or JavaFX. Now I may have
opened a can of worms. ;-)
- Chien
On 7/25/2013 5:20 PM, Richard Bair wrote:
Having to clone the nodes hardly seems like simultaneous viewing
from different points of view?
On Jul 25, 2013, at 5:17 PM, Chien Yang<chien.y...@oracle.com> wrote:
Hi August,
We did talk through some use cases such as PIP and rear view
mirror. You can do simultaneous viewing from different points of
view into a single 3D scene via the use of SubScenes. The key
point, as you have clearly stated, is the need to clone the scene
graph nodes per SubScene.
- Chien
On 7/25/2013 10:37 AM, Richard Bair wrote:
Hi August,
"I think we already do multiple active cameras?"
More precisely: simultaneous viewing from different points of
view into a single 3D scene graph was meant, i.e. several
cameras are attached to one scene graph.
A SubScene has exactly one camera attached which renders the
associated scene graph into the corresponding SubScene's
rectangle. Implementing simultaneous viewing requires a cloned
3D scene graph for the second, third, and so on
SubScene/Camera. Material, Mesh, and Image objects can be
re-used because they are shareable. Animations of Nodes'
Transforms seem to be shareable as well. But Transitions
(Rotate, Scale, Translate) have to be cloned because they
operate on a Node's methods directly. So, simultaneous viewing
seems practicable.
Jasper or Kevin will have to comment, but I know this scenario
was talked about extensively in the design for the renderToImage
and cameras, and I thought this was possible today.
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
*/
package helloworld;
import javafx.application.Application;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.PerspectiveCamera;
import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;
public class HelloSnapshotPerspective extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("HelloSnapshotPerspective");
Group g = new Group();
Rectangle rect = new Rectangle(300, 200);
rect.setTranslateX(25);
rect.setTranslateY(25);
rect.setRotate(-40);
rect.setRotationAxis(Rotate.Y_AXIS);
rect.setFill(Color.PALEGREEN);
g.getChildren().add(rect);
final Group root = new Group(g);
Scene scene = new Scene(root, 800, 300);
scene.setCamera(new PerspectiveCamera());
scene.setFill(Color.BROWN);
SnapshotParameters params = new SnapshotParameters();
params.setCamera(new PerspectiveCamera());
params.setFill(Color.DARKBLUE);
params.setViewport(new Rectangle2D(0, 0, 800, 300));
final Image image = rect.snapshot(params, null);
ImageView iv = new ImageView(image);
iv.setLayoutX(400);
root.getChildren().add(iv);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
javafx.application.Application.launch(args);
}
}