Skip to content

Commit

Permalink
Adding a zoom camera API to BowlerStudio static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Apr 14, 2024
1 parent ad6a41c commit 3ae0bb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -890,4 +890,9 @@ public static void setCamera(TransformNR tf) {
CreatureLab3dController.getEngine().moveCamera(tfupde);
});
}
public static void zoomCamera(double increment) {
runLater(()->{
CreatureLab3dController.getEngine().zoomIncrement(increment);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1184,20 +1184,25 @@ public void handle(MouseEvent me) {
scene.addEventHandler(ScrollEvent.ANY, t -> {
if (ScrollEvent.SCROLL == t.getEventType()) {

double zoomFactor = -(t.getDeltaY()) * getVirtualcam().getZoomDepth() / 500;
//
// double z = camera.getTranslateY();
// double newZ = z + zoomFactor;
// camera.setTranslateY(newZ);
// System.out.println("Z = "+zoomFactor);

getVirtualcam().setZoomDepth(getVirtualcam().getZoomDepth() + zoomFactor);
double deltaY = t.getDeltaY();
zoomIncrement(deltaY);
}
t.consume();
});

}

public void zoomIncrement(double deltaY) {
double zoomFactor = -deltaY * getVirtualcam().getZoomDepth() / 500;
//
// double z = camera.getTranslateY();
// double newZ = z + zoomFactor;
// camera.setTranslateY(newZ);
// System.out.println("Z = "+zoomFactor);

getVirtualcam().setZoomDepth(getVirtualcam().getZoomDepth() + zoomFactor);
}

public void moveCamera(TransformNR newPose) {
getFlyingCamera().DriveArc(newPose);
}
Expand Down

0 comments on commit 3ae0bb9

Please sign in to comment.