Cleanup
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
package mindustry.graphics;
|
package mindustry.graphics;
|
||||||
|
|
||||||
import arc.*;
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.VertexAttributes.*;
|
import arc.graphics.VertexAttributes.*;
|
||||||
import arc.graphics.gl.*;
|
import arc.graphics.gl.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
|
import arc.util.ArcAnnotate.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.graphics.Pgrid.*;
|
import mindustry.graphics.Pgrid.*;
|
||||||
|
|
||||||
public class PlanetMesh{
|
public class PlanetMesh{
|
||||||
private float[] floats = new float[3 + 3 + 1];
|
private float[] floats = new float[3 + 3 + 1];
|
||||||
private Shader shader = new Shader(Core.files.internal("shaders/planet.vertex.glsl").readString(), Core.files.internal("shaders/planet.fragment.glsl").readString());
|
private Vec3 center = new Vec3(0, 0, 0);
|
||||||
private Mesh mesh;
|
private Mesh mesh;
|
||||||
private Pgrid grid;
|
private Pgrid grid;
|
||||||
|
|
||||||
@@ -40,14 +40,27 @@ public class PlanetMesh{
|
|||||||
public void render(Mat3D mat){
|
public void render(Mat3D mat){
|
||||||
Gl.enable(Gl.depthTest);
|
Gl.enable(Gl.depthTest);
|
||||||
|
|
||||||
shader.begin();
|
Shaders.planet.begin();
|
||||||
shader.setUniformMatrix4("u_projModelView", mat.val);
|
Shaders.planet.setUniformMatrix4("u_projModelView", mat.val);
|
||||||
mesh.render(shader, lines ? Gl.lines : Gl.triangles);
|
mesh.render(Shaders.planet, lines ? Gl.lines : Gl.triangles);
|
||||||
shader.end();
|
Shaders.planet.end();
|
||||||
|
|
||||||
Gl.disable(Gl.depthTest);
|
Gl.disable(Gl.depthTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable Ptile getTile(Ray ray){
|
||||||
|
Vec3 vec = intersect(ray);
|
||||||
|
if(vec == null) return null;
|
||||||
|
return Structs.findMin(grid.tiles, t -> t.v.dst(vec));
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Vec3 intersect(Ray ray){
|
||||||
|
if(Intersector3D.intersectRaySphere(ray, center, length, Tmp.v33)){
|
||||||
|
return Tmp.v33;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void generateMesh(){
|
private void generateMesh(){
|
||||||
|
|
||||||
for(Ptile tile : grid.tiles){
|
for(Ptile tile : grid.tiles){
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ public class PlanetRenderer{
|
|||||||
Gl.clearColor(0, 0, 0, 1);
|
Gl.clearColor(0, 0, 0, 1);
|
||||||
Gl.clear(Gl.depthBufferBit | Gl.colorBufferBit);
|
Gl.clear(Gl.depthBufferBit | Gl.colorBufferBit);
|
||||||
|
|
||||||
|
Ray ray = cam.getPickRay(Core.input.mouseX(), Core.input.mouseY());
|
||||||
|
|
||||||
input();
|
input();
|
||||||
|
|
||||||
cam.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
|
cam.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class Shaders{
|
|||||||
public static MenuShader menu;
|
public static MenuShader menu;
|
||||||
public static LightShader light;
|
public static LightShader light;
|
||||||
public static SurfaceShader water, tar, slag;
|
public static SurfaceShader water, tar, slag;
|
||||||
|
public static Shader planet;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
shadow = new Shadow();
|
shadow = new Shadow();
|
||||||
@@ -35,6 +36,7 @@ public class Shaders{
|
|||||||
water = new SurfaceShader("water");
|
water = new SurfaceShader("water");
|
||||||
tar = new SurfaceShader("tar");
|
tar = new SurfaceShader("tar");
|
||||||
slag = new SurfaceShader("slag");
|
slag = new SurfaceShader("slag");
|
||||||
|
planet = new LoadShader("planet", "planet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LightShader extends LoadShader{
|
public static class LightShader extends LoadShader{
|
||||||
|
|||||||
Reference in New Issue
Block a user