focus gizmo add
This commit is contained in:
@@ -7,6 +7,8 @@ import com.replaymod.core.versions.MCVer;
|
|||||||
import com.replaymod.pathing.properties.CameraProperties;
|
import com.replaymod.pathing.properties.CameraProperties;
|
||||||
import com.replaymod.pathing.properties.SpectatorProperty;
|
import com.replaymod.pathing.properties.SpectatorProperty;
|
||||||
import com.replaymod.pathing.properties.TimestampProperty;
|
import com.replaymod.pathing.properties.TimestampProperty;
|
||||||
|
import com.replaymod.pathing.properties.LensProperties;
|
||||||
|
import com.replaymod.pathing.properties.FovProperty;
|
||||||
import com.replaymod.replay.ReplayHandler;
|
import com.replaymod.replay.ReplayHandler;
|
||||||
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
||||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||||
@@ -72,6 +74,8 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
private static final int SLOW_PATH_COLOR = 0xffcccc;
|
private static final int SLOW_PATH_COLOR = 0xffcccc;
|
||||||
private static final int FAST_PATH_COLOR = 0x660000;
|
private static final int FAST_PATH_COLOR = 0x660000;
|
||||||
private static final double FASTEST_PATH_SPEED = 0.01;
|
private static final double FASTEST_PATH_SPEED = 0.01;
|
||||||
|
private static final float DOF_GIZMO_SCALE = 10f;
|
||||||
|
private static final float DOF_GIZMO_FAR_LEN = 64f;
|
||||||
|
|
||||||
private final ReplayModSimplePathing mod;
|
private final ReplayModSimplePathing mod;
|
||||||
private final ReplayHandler replayHandler;
|
private final ReplayHandler replayHandler;
|
||||||
@@ -209,6 +213,9 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
int time = guiPathing.timeline.getCursorPosition();
|
int time = guiPathing.timeline.getCursorPosition();
|
||||||
|
float focal = path.getValue(LensProperties.FOCAL_DISTANCE, time).map(Triple::getLeft).orElse(LensProperties.DEFAULT_FOCAL_DISTANCE);
|
||||||
|
float aperture = path.getValue(LensProperties.APERTURE_RADIUS, time).map(Triple::getLeft).orElse(LensProperties.DEFAULT_APERTURE_RADIUS);
|
||||||
|
float fov = path.getValue(FovProperty.FOV, time).map(Triple::getLeft).orElse(FovProperty.DEFAULT_FOV);
|
||||||
Optional<Integer> entityId = path.getValue(SpectatorProperty.PROPERTY, time);
|
Optional<Integer> entityId = path.getValue(SpectatorProperty.PROPERTY, time);
|
||||||
if (entityId.isPresent()) {
|
if (entityId.isPresent()) {
|
||||||
// Spectating an entity
|
// Spectating an entity
|
||||||
@@ -218,6 +225,7 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
Location loc = entityTracker.getEntityPositionAtTimestamp(entityId.get(), replayTime.get());
|
Location loc = entityTracker.getEntityPositionAtTimestamp(entityId.get(), replayTime.get());
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
drawCamera(viewPos, loc2Vec(loc), new Vector3f(loc.getYaw(), loc.getPitch(), 0f));
|
drawCamera(viewPos, loc2Vec(loc), new Vector3f(loc.getYaw(), loc.getPitch(), 0f));
|
||||||
|
drawFocusGizmo(viewPos, loc2Vec(loc), new Vector3f(loc.getYaw(), loc.getPitch(), 0f), focal, aperture, fov);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,6 +235,7 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
Optional<Vector3f> cameraRot = path.getValue(CameraProperties.ROTATION, time).map(this::tripleF2Vec);
|
Optional<Vector3f> cameraRot = path.getValue(CameraProperties.ROTATION, time).map(this::tripleF2Vec);
|
||||||
if (cameraPos.isPresent() && cameraRot.isPresent()) {
|
if (cameraPos.isPresent() && cameraRot.isPresent()) {
|
||||||
drawCamera(viewPos, cameraPos.get(), cameraRot.get());
|
drawCamera(viewPos, cameraPos.get(), cameraRot.get());
|
||||||
|
drawFocusGizmo(viewPos, cameraPos.get(), cameraRot.get(), focal, aperture, fov);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -526,6 +535,100 @@ public class PathPreviewRenderer extends EventRegistrations {
|
|||||||
popMatrix();
|
popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawFocusGizmo(Vector3f view, Vector3f pos, Vector3f rot, float focalDistance, float apertureRadius, float fov) {
|
||||||
|
float a = Math.max(0.15f, apertureRadius * DOF_GIZMO_SCALE);
|
||||||
|
int rayColor = 0x66ccffaa; // RGBA: голубой (лучи апертуры)
|
||||||
|
int markerColor = 0xffaa00ff; // RGBA: оранжевый (маркер плоскости фокуса)
|
||||||
|
float mr = focalDistance * (float) Math.tan(Math.toRadians(fov) / 2.0); // радиус кольца-маркера
|
||||||
|
int markerSeg = 12;
|
||||||
|
|
||||||
|
pushMatrix();
|
||||||
|
|
||||||
|
Vector3f t = Vector3f.sub(pos, view, null);
|
||||||
|
GL11.glTranslatef(t.x, t.y, t.z);
|
||||||
|
GL11.glRotatef(-rot.x, 0, 1, 0); // Yaw
|
||||||
|
GL11.glRotatef(rot.y, 1, 0, 0); // Pitch
|
||||||
|
GL11.glRotatef(rot.z, 0, 0, 1); // Roll
|
||||||
|
|
||||||
|
//#if MC>=12105
|
||||||
|
//$$ VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
|
||||||
|
//$$ immediate.draw();
|
||||||
|
//#if MC>=12111
|
||||||
|
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayers.LINES);
|
||||||
|
//#else
|
||||||
|
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayer.LINES);
|
||||||
|
//#endif
|
||||||
|
//#else
|
||||||
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
|
//#if MC>=12100
|
||||||
|
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINES, VertexFormats.LINES);
|
||||||
|
//#else
|
||||||
|
BufferBuilder buffer = tessellator.getBuffer();
|
||||||
|
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
MatrixStack ms = new MatrixStack();
|
||||||
|
Vector3f apex = new Vector3f(0f, 0f, focalDistance); // точка схождения
|
||||||
|
|
||||||
|
for (Vector3f edge : new Vector3f[]{
|
||||||
|
new Vector3f( a, 0f, 0f), new Vector3f(-a, 0f, 0f),
|
||||||
|
new Vector3f(0f, a, 0f), new Vector3f(0f, -a, 0f)}) {
|
||||||
|
Vector3f dir = Vector3f.sub(apex, edge, null); // apex - edge
|
||||||
|
dir.normalise();
|
||||||
|
dir.scale(DOF_GIZMO_FAR_LEN);
|
||||||
|
Vector3f far = Vector3f.add(apex, dir, null);
|
||||||
|
emitLine(ms, buffer, edge, far, rayColor, 2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// маркер фокальной плоскости: крестик
|
||||||
|
emitLine(ms, buffer, new Vector3f(-mr, 0f, focalDistance), new Vector3f(mr, 0f, focalDistance), markerColor, 2f);
|
||||||
|
emitLine(ms, buffer, new Vector3f(0f, -mr, focalDistance), new Vector3f(0f, mr, focalDistance), markerColor, 2f);
|
||||||
|
// маркер фокальной плоскости: кольцо
|
||||||
|
Vector3f prev = null;
|
||||||
|
for (int i = 0; i <= markerSeg; i++) {
|
||||||
|
double ang = 2 * Math.PI * i / markerSeg;
|
||||||
|
Vector3f p = new Vector3f((float) (mr * Math.cos(ang)), (float) (mr * Math.sin(ang)), focalDistance);
|
||||||
|
if (prev != null) emitLine(ms, buffer, prev, p, markerColor, 2f);
|
||||||
|
prev = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#if MC>=12105
|
||||||
|
//$$ immediate.draw();
|
||||||
|
//#else
|
||||||
|
//#if MC>=12102
|
||||||
|
//$$ RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
|
||||||
|
//#elseif MC>=11700
|
||||||
|
//$$ RenderSystem.applyModelViewMatrix();
|
||||||
|
//$$ RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
|
||||||
|
//#else
|
||||||
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#if MC>=11700
|
||||||
|
//$$ RenderSystem.disableCull();
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#if MC>=12100
|
||||||
|
//$$ try (var builtBuffer = buffer.end()) {
|
||||||
|
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
|
||||||
|
//$$ }
|
||||||
|
//#else
|
||||||
|
tessellator.draw();
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#if MC>=11700
|
||||||
|
//$$ RenderSystem.enableCull();
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
//#if MC<11700
|
||||||
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||||
|
//#endif
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
popMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
//#if MC>=12105
|
//#if MC>=12105
|
||||||
//$$ private void vertex(VertexConsumer buffer, float x, float y, float z, float u, float v, int alpha) {
|
//$$ private void vertex(VertexConsumer buffer, float x, float y, float z, float u, float v, int alpha) {
|
||||||
//#else
|
//#else
|
||||||
|
|||||||
Reference in New Issue
Block a user