this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

render ortho map thumbnails

+61 -2
+53 -1
src/main/java/game/map/editor/MapEditor.java
··· 399 399 public PostProcessFX postProcessFX = PostProcessFX.NONE; 400 400 401 401 public boolean thumbnailMode = false; 402 + public float thumbnailOrthoHalfHeight = 500f; 402 403 public boolean showModels; 403 404 public boolean showColliders; 404 405 public boolean showZones; ··· 747 748 obj.hidden = true; 748 749 for (MapObject obj : getCollisionMap().zoneTree) 749 750 obj.hidden = true; 750 - // for(MapObject obj : map.markerTree) obj.hidden = true; 751 751 752 752 if (!thumbnailInitialized) 753 753 initThumbnail(); 754 + 755 + // Isometric camera: 45 degrees right, 45 degrees down 756 + var camera = perspectiveView.camera; 757 + camera.yaw = -45f; 758 + camera.pitch = 45f; 759 + 760 + // Frame the map's model tree AABB 761 + BoundingBox aabb = map.modelTree.getRoot().getUserObject().AABB; 762 + Vector3f center = aabb.getCenter(); 763 + camera.setPosition(center); 764 + 765 + // Project all 8 AABB corners through the view rotation to find 766 + // the screen-space bounding box. View = Rx(pitch) * Ry(yaw) * (p - center). 767 + Vector3f bmin = aabb.getMin(); 768 + Vector3f bmax = aabb.getMax(); 769 + float[] xs = { bmin.x, bmax.x }; 770 + float[] ys = { bmin.y, bmax.y }; 771 + float[] zs = { bmin.z, bmax.z }; 772 + 773 + double yawRad = Math.toRadians(-45); 774 + double pitchRad = Math.toRadians(45); 775 + double cy = Math.cos(yawRad), sy = Math.sin(yawRad); 776 + double cp = Math.cos(pitchRad), sp = Math.sin(pitchRad); 777 + 778 + float screenMinX = Float.MAX_VALUE, screenMaxX = -Float.MAX_VALUE; 779 + float screenMinY = Float.MAX_VALUE, screenMaxY = -Float.MAX_VALUE; 780 + for (float wx : xs) { 781 + for (float wy : ys) { 782 + for (float wz : zs) { 783 + // translate to camera-relative 784 + float px = wx - center.x; 785 + float py = wy - center.y; 786 + float pz = wz - center.z; 787 + // Ry(yaw) 788 + float rx = (float)(px * cy + pz * sy); 789 + float ry = py; 790 + float rz = (float)(-px * sy + pz * cy); 791 + // Rx(pitch) 792 + float sx = rx; 793 + float syt = (float)(ry * cp - rz * sp); 794 + // screen X = sx, screen Y = syt 795 + screenMinX = Math.min(screenMinX, sx); 796 + screenMaxX = Math.max(screenMaxX, sx); 797 + screenMinY = Math.min(screenMinY, syt); 798 + screenMaxY = Math.max(screenMaxY, syt); 799 + } 800 + } 801 + } 802 + 803 + float halfW = (screenMaxX - screenMinX) / 2f; 804 + float halfH = (screenMaxY - screenMinY) / 2f; 805 + thumbnailOrthoHalfHeight = Math.max(Math.max(halfW, halfH), 50f); 754 806 755 807 perspectiveView.resize(0, 0, size, size); 756 808
+8 -1
src/main/java/game/map/editor/camera/PerspBaseCamera.java
··· 109 109 currentZfar = scriptData.camFarClip.get(); 110 110 } 111 111 112 - projMatrix.perspective(currentVfov, currentAspectRatio, currentZnear, currentZfar); 112 + if (editor.thumbnailMode) { 113 + float halfH = editor.thumbnailOrthoHalfHeight; 114 + float halfW = halfH * currentAspectRatio; 115 + projMatrix.ortho(-halfW, halfW, -halfH, halfH, -currentZfar, currentZfar); 116 + } 117 + else { 118 + projMatrix.perspective(currentVfov, currentAspectRatio, currentZnear, currentZfar); 119 + } 113 120 } 114 121 115 122 @Override