Asteroid progress
This commit is contained in:
7
core/src/mindustry/graphics/g3d/GenericMesh.java
Normal file
7
core/src/mindustry/graphics/g3d/GenericMesh.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package mindustry.graphics.g3d;
|
||||
|
||||
import arc.math.geom.*;
|
||||
|
||||
public interface GenericMesh{
|
||||
void render(Mat3D projection, Mat3D transform);
|
||||
}
|
||||
@@ -15,6 +15,9 @@ public class HexMesh extends PlanetMesh{
|
||||
super(planet, MeshBuilder.buildHex(mesher, divisions, false, planet.radius, 0.2f), shader);
|
||||
}
|
||||
|
||||
public HexMesh(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRender(){
|
||||
Shaders.planet.lightDir.set(planet.solarSystem.position).sub(planet.position).rotate(Vec3.Y, planet.getRotation()).nor();
|
||||
|
||||
22
core/src/mindustry/graphics/g3d/MatMesh.java
Normal file
22
core/src/mindustry/graphics/g3d/MatMesh.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package mindustry.graphics.g3d;
|
||||
|
||||
import arc.math.geom.*;
|
||||
|
||||
//TODO maybe this is a bad idea
|
||||
/** A GenericMesh that wraps and applies an additional transform to a generic mesh. */
|
||||
public class MatMesh implements GenericMesh{
|
||||
private static final Mat3D tmp = new Mat3D();
|
||||
|
||||
GenericMesh mesh;
|
||||
Mat3D mat;
|
||||
|
||||
public MatMesh(GenericMesh mesh, Mat3D mat){
|
||||
this.mesh = mesh;
|
||||
this.mat = mat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Mat3D projection, Mat3D transform){
|
||||
mesh.render(projection, tmp.set(transform).mul(mat));
|
||||
}
|
||||
}
|
||||
18
core/src/mindustry/graphics/g3d/MultiMesh.java
Normal file
18
core/src/mindustry/graphics/g3d/MultiMesh.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package mindustry.graphics.g3d;
|
||||
|
||||
import arc.math.geom.*;
|
||||
|
||||
public class MultiMesh implements GenericMesh{
|
||||
GenericMesh[] meshes;
|
||||
|
||||
public MultiMesh(GenericMesh... meshes){
|
||||
this.meshes = meshes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Mat3D projection, Mat3D transform){
|
||||
for(var v : meshes){
|
||||
v.render(projection, transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
core/src/mindustry/graphics/g3d/NoiseMesh.java
Normal file
28
core/src/mindustry/graphics/g3d/NoiseMesh.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package mindustry.graphics.g3d;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.noise.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class NoiseMesh extends HexMesh{
|
||||
Simplex sim;
|
||||
|
||||
public NoiseMesh(Planet planet, int seed, int divisions, Color color, float radius, int octaves, float persistence, float scale, float mag){
|
||||
this.planet = planet;
|
||||
this.sim = new Simplex(planet.id + seed);
|
||||
this.shader = Shaders.planet;
|
||||
this.mesh = MeshBuilder.buildHex(new HexMesher(){
|
||||
@Override
|
||||
public float getHeight(Vec3 position){
|
||||
return (float)sim.octaveNoise3D(octaves, persistence, scale, 5f + position.x, 5f + position.y, 5f + position.z) * mag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(Vec3 position){
|
||||
return color;
|
||||
}
|
||||
}, divisions, false, radius, 0.2f);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,13 @@ package mindustry.graphics.g3d;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
/** Defines a mesh that is rendered for a planet. Subclasses provide a mesh and a shader. */
|
||||
public abstract class PlanetMesh implements Disposable{
|
||||
protected final Mesh mesh;
|
||||
protected final Planet planet;
|
||||
protected final Shader shader;
|
||||
public abstract class PlanetMesh implements GenericMesh{
|
||||
protected Mesh mesh;
|
||||
protected Planet planet;
|
||||
protected Shader shader;
|
||||
|
||||
public PlanetMesh(Planet planet, Mesh mesh, Shader shader){
|
||||
this.planet = planet;
|
||||
@@ -18,9 +17,12 @@ public abstract class PlanetMesh implements Disposable{
|
||||
this.shader = shader;
|
||||
}
|
||||
|
||||
public PlanetMesh(){}
|
||||
|
||||
/** Should be overridden to set up any shader parameters such as planet position, normals, etc. */
|
||||
public abstract void preRender();
|
||||
|
||||
@Override
|
||||
public void render(Mat3D projection, Mat3D transform){
|
||||
preRender();
|
||||
shader.bind();
|
||||
@@ -29,9 +31,4 @@ public abstract class PlanetMesh implements Disposable{
|
||||
shader.apply();
|
||||
mesh.render(shader, Gl.triangles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
mesh.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +173,8 @@ public class PlanetRenderer implements Disposable{
|
||||
}
|
||||
|
||||
batch.proj(cam.combined);
|
||||
renderOrbit(planet);
|
||||
|
||||
renderOrbit(planet);
|
||||
}
|
||||
|
||||
public void renderOrbit(Planet planet){
|
||||
|
||||
Reference in New Issue
Block a user