|
@@ -25,7 +25,7 @@ public class Render {
|
|
|
public double currentDistance;
|
|
|
public HashMap<GDInstance, Integer> animationToCurrentframe = new HashMap<>();
|
|
|
|
|
|
- public String fullRender(double fps) {
|
|
|
+ public String fullRender(double fps) throws CloneNotSupportedException {
|
|
|
LevelStringBuilder builder = new LevelStringBuilder(new StringBuilder(LevelInfo.getLevelString()), 10); //TODO: make the editor layer configurable
|
|
|
Matrix4f camera = new Matrix4f();
|
|
|
camera.perspective((float) Math.toRadians(2), (float) 16 /9, 0.001F, 1000);
|
|
@@ -38,7 +38,7 @@ public class Render {
|
|
|
|
|
|
Vector3f cameraTranslation = new Vector3f(0, 0, 5);
|
|
|
camera.translation(cameraTranslation); //TODO: make that follow a new camera path editor
|
|
|
- //builder.add(1, 1, X_PROPERTY_ID, projectPoint(camera, new Vector4f((float) cameraTranslation.x, (float) cameraTranslation.y, (float) cameraTranslation.z, 0)).x, Y_PROPERTY_ID,projectPoint(camera, new Vector4f((float) cameraTranslation.x, (float) cameraTranslation.y, (float) cameraTranslation.z, 0)).y);
|
|
|
+ builder.add(1, 1, X_PROPERTY_ID, projectPoint(camera, new Vector4f((float) cameraTranslation.x, (float) cameraTranslation.y, (float) cameraTranslation.z - 1, 1)).x, Y_PROPERTY_ID,projectPoint(camera, new Vector4f((float) cameraTranslation.x, (float) cameraTranslation.y, (float) cameraTranslation.z - 1, 1)).y);
|
|
|
|
|
|
System.out.println(currentPercent * 100);
|
|
|
|
|
@@ -53,9 +53,9 @@ public class Render {
|
|
|
for (Face face : gdModel.getFaces()) {
|
|
|
for (Vector4f point : face.points) {
|
|
|
Vector3 translation = instance.getInstance().transform.getTranslation(Vector3.Zero);
|
|
|
- point = point.add(translation.x, translation.y, translation.z, 1);
|
|
|
+ point = point.add(translation.x * 30, translation.y * 30, translation.z * 30, 0);
|
|
|
Vector4f projected = projectPoint(camera, point);
|
|
|
- builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x * 30, Y_PROPERTY_ID, projected.y * 30);
|
|
|
+ builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x, Y_PROPERTY_ID, projected.y);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -64,25 +64,30 @@ public class Render {
|
|
|
} else {
|
|
|
GDModel gdModel = instance.getGdModel();
|
|
|
for (Face face : gdModel.getFaces()) {
|
|
|
+//
|
|
|
for (Vector4f point : face.points) {
|
|
|
+ Vector4f vector = (Vector4f) point.clone();
|
|
|
Vector3 translation = instance.getInstance().transform.getTranslation(Vector3.Zero);
|
|
|
- point = point.add(translation.x * 30, translation.y * 30, translation.z * 30, 1);
|
|
|
- Vector4f projected = projectPoint(camera, point);
|
|
|
- builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x, Y_PROPERTY_ID, projected.y);
|
|
|
+ vector.add(translation.x * 30, translation.y * 30, translation.z * 30, 0);
|
|
|
+ Vector4f projected = projectPoint(camera, vector);
|
|
|
+ builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x * 30, Y_PROPERTY_ID, projected.y * 30);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
return builder.getLevelString().toString();
|
|
|
}
|
|
|
|
|
|
public Vector4f projectPoint(Matrix4f camera, Vector4f input) {
|
|
|
- camera.transform(input);
|
|
|
+ System.out.println(input);
|
|
|
+ input = camera.transform(input);
|
|
|
+ System.out.println(input);
|
|
|
|
|
|
- input.x = input.x / input.w;
|
|
|
- input.y = input.y / input.w;
|
|
|
- input.z = input.z / input.w;
|
|
|
+ input.x = input.x / input.z;
|
|
|
+ input.y = input.y / input.z;
|
|
|
+ input.z = input.z / input.z;
|
|
|
|
|
|
return input;
|
|
|
}
|