Skip to content

Commit 2f8c4cd

Browse files
committed
working camera controls and resetting
1 parent 4a1794a commit 2f8c4cd

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

src/main/java/com/commonwealthrobotics/MainController.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ void onExport(ActionEvent event) {
224224

225225
@FXML
226226
void onFitView(ActionEvent event) {
227-
227+
engine.focusOrentation(
228+
new TransformNR(0,0,0,new RotationNR(0,45,-45)),
229+
new TransformNR(),
230+
engine.getFlyingCamera().getDefaultZoomDepth());
228231
}
229232

230233
@FXML
@@ -259,7 +262,10 @@ void onHome(MouseEvent event) {
259262

260263
@FXML
261264
void onHomeViewButton(ActionEvent event) {
262-
navigationCube.focusOrentation(new TransformNR(0,0,0,new RotationNR(0,45,-45)));
265+
engine.focusOrentation(
266+
new TransformNR(0,0,0,new RotationNR(0,45,-45)),
267+
new TransformNR(),
268+
engine.getFlyingCamera().getDefaultZoomDepth());
263269
}
264270

265271
@FXML
@@ -330,11 +336,15 @@ void onWOrkplane(ActionEvent event) {
330336
@FXML
331337
void onZoomIn(ActionEvent event) {
332338

339+
System.out.println("Zoom In");
340+
engine.setZoom((int)engine.getFlyingCamera().getZoomDepth()+20);
333341
}
334342

335343
@FXML
336344
void onZoomOut(ActionEvent event) {
345+
System.out.println("Zoom Out");
337346

347+
engine.setZoom((int)engine.getFlyingCamera().getZoomDepth()-20);
338348
}
339349

340350
@FXML
@@ -352,18 +362,6 @@ void showAll(ActionEvent event) {
352362

353363
}
354364

355-
@FXML
356-
void zoomInView(MouseEvent event) {
357-
System.out.println("Zoom In");
358-
engine.setZoom((int)engine.getFlyingCamera().getZoomDepth()-20);
359-
}
360-
361-
@FXML
362-
void zoomOutViewButton(MouseEvent event) {
363-
System.out.println("Zoom Out");
364-
365-
engine.setZoom((int)engine.getFlyingCamera().getZoomDepth()+20);
366-
}
367365

368366
@FXML // This method is called by the FXMLLoader when initialization is complete
369367
void initialize() {
@@ -483,7 +481,7 @@ public boolean isRotate(MouseEvent me) {
483481
boolean primaryButtonDown = me.isPrimaryButtonDown();
484482
boolean secondaryButtonDown = me.isSecondaryButtonDown();
485483
boolean ctrl = me.isControlDown();
486-
if(ctrl && primaryButtonDown)
484+
if(ctrl && primaryButtonDown && (!shiftDown))
487485
return true;
488486
if((!shiftDown)&& secondaryButtonDown)
489487
return true;
@@ -493,9 +491,13 @@ public boolean isRotate(MouseEvent me) {
493491
@Override
494492
public boolean isMove(MouseEvent me) {
495493
boolean shiftDown = me.isShiftDown();
494+
boolean primaryButtonDown = me.isPrimaryButtonDown();
496495
boolean secondaryButtonDown = me.isSecondaryButtonDown();
496+
boolean ctrl = me.isControlDown();
497497
if((shiftDown)&& secondaryButtonDown)
498498
return true;
499+
if(ctrl && shiftDown && primaryButtonDown)
500+
return true;
499501
return false ;
500502
}
501503
});
@@ -505,6 +507,7 @@ private void setUpNavigationCube() {
505507
navigationCube = new BowlerStudio3dEngine();
506508
navigationCube.rebuild(false);
507509
navigationCube.setZoom(-400);
510+
navigationCube.lockZoom();
508511
navigationCube.setMouseScale(10);
509512
BowlerStudio.runLater(() -> {
510513
navigationCube.getSubScene().setFocusTraversable(false);
@@ -527,6 +530,7 @@ private void setUpNavigationCube() {
527530
ViewCube viewcube= new ViewCube();
528531
MeshView viewCubeMesh = viewcube.createTexturedCube(navigationCube);
529532
navigationCube.addUserNode(viewCubeMesh);
533+
530534
}
531535

532536

src/main/resources/com/commonwealthrobotics/MainWindow.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
</Button>
231231
<Button fx:id="zoomInButton" mnemonicParsing="false" onAction="#onZoomIn" styleClass="image-button" GridPane.rowIndex="3">
232232
<graphic>
233-
<ImageView fitHeight="30.0" fitWidth="30.0" onDragDetected="#zoomOutViewButton" pickOnBounds="true" preserveRatio="true">
233+
<ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true">
234234
<image>
235235
<Image url="@zoomIn.png" />
236236
</image>
@@ -239,7 +239,7 @@
239239
</Button>
240240
<Button fx:id="zoomOutButton" mnemonicParsing="false" onAction="#onZoomOut" styleClass="image-button" GridPane.rowIndex="4">
241241
<graphic>
242-
<ImageView fitHeight="30.0" fitWidth="30.0" onDragDetected="#zoomInView" pickOnBounds="true" preserveRatio="true">
242+
<ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true">
243243
<image>
244244
<Image url="@zoomOut.png" />
245245
</image>

0 commit comments

Comments
 (0)