|
@@ -3,10 +3,7 @@ package xyz.tbvns.GeometryDash;
|
|
|
import com.badlogic.gdx.graphics.g3d.ModelInstance;
|
|
|
import com.badlogic.gdx.math.Vector3;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.joml.Matrix4d;
|
|
|
-import org.joml.Vector3d;
|
|
|
-import org.joml.Vector4d;
|
|
|
-import org.joml.Vector4f;
|
|
|
+import org.joml.*;
|
|
|
import xyz.tbvns.Editor.ModelsManager;
|
|
|
import xyz.tbvns.GDConstant;
|
|
|
import xyz.tbvns.LevelInfo;
|
|
@@ -15,6 +12,7 @@ import xyz.tbvns.Models.Face;
|
|
|
import xyz.tbvns.Models.GDInstance;
|
|
|
import xyz.tbvns.Models.GDModel;
|
|
|
|
|
|
+import java.lang.Math;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -26,24 +24,23 @@ public class Render {
|
|
|
public double currentPercent;
|
|
|
public double currentDistance;
|
|
|
public HashMap<GDInstance, Integer> animationToCurrentframe = new HashMap<>();
|
|
|
+
|
|
|
public String fullRender(double fps) {
|
|
|
- LevelStringBuilder builder = new LevelStringBuilder(LevelInfo.getLevelString(), 10); //TODO: make the editor layer configurable
|
|
|
+ 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);
|
|
|
while (currentPercent <= 1) {
|
|
|
double speed = LevelInfo.getLevel().getSpeedAt((float) currentPercent);
|
|
|
double distancePerFrame = (speed / fps);
|
|
|
-// currentPercent += distancePerFrame;
|
|
|
double realDistancePerFrame = (speed / fps) * 30;
|
|
|
double distancePerFramePercent = realDistancePerFrame / LevelInfo.getLevel().getMaxPos() / 30;
|
|
|
currentPercent += distancePerFramePercent;
|
|
|
- System.out.println(currentPercent);
|
|
|
-// log.info("Speed: {} \n distancePerFrame: {} \n currentPercent: {} \n realDistancePerFrame: {}");
|
|
|
|
|
|
- Matrix4d camera = new Matrix4d();
|
|
|
- camera.perspective(Math.toRadians(2), (double) 16/9, 0.001, 1000);
|
|
|
- Vector3d cameraTranslation = new Vector3d(realDistancePerFrame * currentPercent, 5, 10);
|
|
|
+ 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);
|
|
|
|
|
|
+ System.out.println(currentPercent * 100);
|
|
|
|
|
|
for (ModelInstance model : ModelsManager.getLoadedModels()) {
|
|
|
GDInstance instance = (GDInstance) model.userData;
|
|
@@ -56,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, 0);
|
|
|
- Vector4d projected = projectPoint(camera, point);
|
|
|
- builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x, Y_PROPERTY_ID, projected.y);
|
|
|
+ point = point.add(translation.x, translation.y, translation.z, 1);
|
|
|
+ Vector4f projected = projectPoint(camera, point);
|
|
|
+ builder.add(1, POINT_OBJECT_ID, X_PROPERTY_ID, projected.x * 30, Y_PROPERTY_ID, projected.y * 30);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -69,25 +66,25 @@ 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, 0);
|
|
|
- Vector4d projected = projectPoint(camera, point);
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return builder.getLevelString();
|
|
|
+ return builder.getLevelString().toString();
|
|
|
}
|
|
|
|
|
|
- public Vector4d projectPoint(Matrix4d camera, Vector4f input) {
|
|
|
- Vector4d point = camera.transform(new Vector4d(input.x, input.y, input.z, input.w));
|
|
|
+ public Vector4f projectPoint(Matrix4f camera, Vector4f input) {
|
|
|
+ camera.transform(input);
|
|
|
|
|
|
- point.x = (float) (point.x / point.w);
|
|
|
- point.y = (float) (point.y / point.w);
|
|
|
- point.z = (float) (point.z / point.w);
|
|
|
+ input.x = input.x / input.w;
|
|
|
+ input.y = input.y / input.w;
|
|
|
+ input.z = input.z / input.w;
|
|
|
|
|
|
- return point;
|
|
|
+ return input;
|
|
|
}
|
|
|
|
|
|
public static float getZ(Face face) {
|