• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão7dd7e71c0c9d32ae1c68f784a97eda4ac53c2f0b (tree)
Hora2021-06-07 20:09:07
Autorsebastian_bugiu
Commitersebastian_bugiu

Mensagem de Log

Now objects from scene get saved as asteroids with position and orientation.

Mudança Sumário

Diff

diff -r b4e284a558f6 -r 7dd7e71c0c9d HotshotEditor/src/com/javafx/experiments/jfx3dviewer/ContentModel.java
--- a/HotshotEditor/src/com/javafx/experiments/jfx3dviewer/ContentModel.java Sun Jun 06 17:22:33 2021 +0300
+++ b/HotshotEditor/src/com/javafx/experiments/jfx3dviewer/ContentModel.java Mon Jun 07 14:09:07 2021 +0300
@@ -81,6 +81,9 @@
8181 private double currentIntersectedNodeDistance;
8282 private Point3D currentIntersectedNodeInitialPos;
8383 private HashMap<Node, Group> meshToParentGroupMap = new HashMap<>();
84+ private ArrayList<Asteroid> asteroidList = new ArrayList<>();
85+ private HashMap<Node, Asteroid> nodeToAsteroidMap = new HashMap<>();
86+ private HashMap<Node, NodeData> nodeMap = new HashMap<>();
8487
8588 private AmbientLight ambientLight = new AmbientLight(Color.DARKGREY);
8689 private SimpleBooleanProperty ambientLightEnabled = new SimpleBooleanProperty(false) {
@@ -279,10 +282,6 @@
279282 }
280283 };
281284
282-
283-
284- private HashMap<Node, NodeData> nodeMap = new HashMap<>();
285-
286285 {
287286 contentProperty().addListener((ov, oldContent, newContent) -> {
288287 // autoScalingGroup.getChildren()
@@ -297,6 +296,9 @@
297296 // Beyond retarded.
298297 Group group = (Group) newContent;
299298 meshToParentGroupMap.put(group.getChildren().get(0), group);
299+ Asteroid asteroid = new Asteroid();
300+ asteroidList.add(asteroid);
301+ nodeToAsteroidMap.put(group.getChildren().get(0), asteroid);
300302 setWireFrame(newContent, wireframe);
301303 // TODO mesh is updated each time these are called even if no rendering needs to happen
302304 setSubdivisionLevel(newContent, subdivisionLevel);
@@ -473,10 +475,20 @@
473475 Group group = meshToParentGroupMap.get(currentIntersectedNode);
474476 if (group != null) {
475477 meshToParentGroupMap.remove(currentIntersectedNode);
478+ Asteroid asteroid = nodeToAsteroidMap.remove(currentIntersectedNode);
479+ if (asteroid == null) {
480+ System.out.println("Could not find asteroid to remove");
481+ } else {
482+ asteroidList.remove(asteroid);
483+ }
476484 boolean remove = autoScalingGroup.getChildren().remove(group);
477485 if (!remove) {
478486 System.out.println("currentIntersectedNode: " + currentIntersectedNode.getId() + " could not be removed");
479487 }
488+ NodeData remove1 = nodeMap.remove(currentIntersectedNode);
489+ if (remove1 == null) {
490+ System.out.println("Could not find nodeData to remove");
491+ }
480492 resetCurrentIntersectedNode();
481493 }
482494 }
@@ -487,6 +499,10 @@
487499 //System.out.println(cameraXform.getTranslateX() + ", " + cameraXform.getTranslateY() + ", " + cameraXform.getTranslateZ());
488500
489501 };
502+
503+ }
504+
505+ {
490506 mouseEventHandler = event -> {
491507 // System.out.println("MouseEvent ...");
492508
@@ -557,6 +573,8 @@
557573 Point3D p = vecPos.subtract(currentIntersectedNodeInitialPos).multiply(currentIntersectedNodeDistance);
558574 nodeData.getNodePos().addInPlace(new ENG_Vector4D(p.getX(), -1 * p.getY(), p.getZ(), 1.0));
559575 // getCurrentIntersectedNodeTransform().appendTranslation(p.getX(), -1 * p.getY(), p.getZ());
576+ Asteroid asteroid = nodeToAsteroidMap.get(currentIntersectedNode);
577+ asteroid.getPosition().set(nodeData.getNodePos());
560578 currentIntersectedNodeInitialPos = vecPos;
561579 currentIntersectedNodeDistance = event.getPickResult().getIntersectedDistance();
562580 } else if (currentModifier == Modifier.ROTATION) {
@@ -573,6 +591,8 @@
573591 nodeRotation.mulInPlace(inverse);
574592 nodeRotation.mulInPlace(currentRot);
575593 nodeRotation.mulInPlace(currentOrientationCopy);
594+ Asteroid asteroid = nodeToAsteroidMap.get(currentIntersectedNode);
595+ asteroid.getOrientation().set(nodeRotation);
576596 // Point3D pivot = new Point3D(getCurrentIntersectedNodeTransform().getTx(), getCurrentIntersectedNodeTransform().getTy(), getCurrentIntersectedNodeTransform().getTz());
577597 // System.out.println("rot pivot: " + pivot);
578598 // getCurrentIntersectedNodeTransform().appendRotation(1, new Point3D(0, 0, 0), rotAxis);
@@ -1029,9 +1049,8 @@
10291049 }
10301050
10311051 public void export(VelocityContext templateContext) {
1032- ArrayList<Asteroid> asteroids = new ArrayList<>();
1033- asteroids.add(new Asteroid("Asteroid0", new ENG_Vector3D(0.0f, 200.0f, -250.0f), new ENG_Quaternion(true), 50));
1034- asteroids.add(new Asteroid("Asteroid1", new ENG_Vector3D(1500.0f -200.0f -250.0f), new ENG_Quaternion(true), 50));
1035- templateContext.put("asteroids", asteroids);
1052+// asteroidList.add(new Asteroid("Asteroid0", new ENG_Vector3D(0.0f, 200.0f, -250.0f), new ENG_Quaternion(true), 50));
1053+// asteroidList.add(new Asteroid("Asteroid1", new ENG_Vector3D(1500.0f -200.0f -250.0f), new ENG_Quaternion(true), 50));
1054+ templateContext.put("asteroids", asteroidList);
10361055 }
10371056 }
diff -r b4e284a558f6 -r 7dd7e71c0c9d HotshotEditor/src/headwayent/hotshotengine/ENG_Quaternion.java
--- a/HotshotEditor/src/headwayent/hotshotengine/ENG_Quaternion.java Sun Jun 06 17:22:33 2021 +0300
+++ b/HotshotEditor/src/headwayent/hotshotengine/ENG_Quaternion.java Mon Jun 07 14:09:07 2021 +0300
@@ -1135,7 +1135,7 @@
11351135 }
11361136
11371137 public String toString() {
1138- return (String.valueOf(x) + ", " + String.valueOf(y) + ", " +
1139- String.valueOf(z) + ", " + String.valueOf(w));
1138+ return (String.valueOf(x) + " " + String.valueOf(y) + " " +
1139+ String.valueOf(z) + " " + String.valueOf(w));
11401140 }
11411141 }
diff -r b4e284a558f6 -r 7dd7e71c0c9d HotshotEditor/src/headwayent/hotshotengine/ENG_Vector2D.java
--- a/HotshotEditor/src/headwayent/hotshotengine/ENG_Vector2D.java Sun Jun 06 17:22:33 2021 +0300
+++ b/HotshotEditor/src/headwayent/hotshotengine/ENG_Vector2D.java Mon Jun 07 14:09:07 2021 +0300
@@ -514,7 +514,7 @@
514514 }
515515
516516 public String toString(boolean format, NumberFormat formatter) {
517- return (formatter.format(x) + ", " + formatter.format(y));
517+ return (x + " " + y);
518518 }
519519
520520 public String toString() {
diff -r b4e284a558f6 -r 7dd7e71c0c9d HotshotEditor/src/headwayent/hotshotengine/ENG_Vector3D.java
--- a/HotshotEditor/src/headwayent/hotshotengine/ENG_Vector3D.java Sun Jun 06 17:22:33 2021 +0300
+++ b/HotshotEditor/src/headwayent/hotshotengine/ENG_Vector3D.java Mon Jun 07 14:09:07 2021 +0300
@@ -673,8 +673,7 @@
673673 }
674674
675675 public String toString(boolean format, NumberFormat formatter) {
676- return (formatter.format(x) + ", " + formatter.format(y) + ", " +
677- formatter.format(z));
676+ return (x + " " + y + " " + z);
678677 }
679678
680679 public String toString() {
diff -r b4e284a558f6 -r 7dd7e71c0c9d HotshotEditor/src/headwayent/hotshotengine/ENG_Vector4D.java
--- a/HotshotEditor/src/headwayent/hotshotengine/ENG_Vector4D.java Sun Jun 06 17:22:33 2021 +0300
+++ b/HotshotEditor/src/headwayent/hotshotengine/ENG_Vector4D.java Mon Jun 07 14:09:07 2021 +0300
@@ -1649,8 +1649,7 @@
16491649 }
16501650
16511651 public String toString(boolean format, NumberFormat formatter) {
1652- return (/*"Vector3("*/formatter.format(x) + " " + formatter.format(y) + " " +
1653- formatter.format(z) + " " + formatter.format(w)/* + ")"*/);
1652+ return (x + " " + y + " " + z + " " + w);
16541653 }
16551654
16561655 public String toString() {