added correct project source

This commit is contained in:
Sven Vogel 2023-02-17 16:05:44 +01:00
parent b162c4fee8
commit a3db520517
92 changed files with 1712 additions and 6281 deletions

377
pom.xml
View File

@ -5,384 +5,13 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>me.teridax</groupId> <groupId>me.teridax</groupId>
<artifactId>Gytebot-intellij</artifactId> <artifactId>JPath</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<properties> <properties>
<maven.compiler.source>16</maven.compiler.source> <maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target> <maven.compiler.target>19</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lwjgl.version>3.3.1</lwjgl.version>
<joml.version>1.10.5</joml.version>
<lwjgl.natives>natives-linux</lwjgl.natives>
</properties> </properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-bom</artifactId>
<version>${lwjgl.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-assimp</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-bgfx</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-cuda</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-egl</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-jawt</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-jemalloc</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-libdivide</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-llvm</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-lmdb</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-lz4</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-meow</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-meshoptimizer</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-nanovg</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-nfd</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-nuklear</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-odbc</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openal</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opencl</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opengles</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openvr</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openxr</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opus</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-par</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-remotery</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-rpmalloc</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-shaderc</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-spvc</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-sse</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-stb</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-tinyexr</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-tinyfd</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-tootle</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-vma</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-vulkan</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-xxhash</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-yoga</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-zstd</artifactId>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-assimp</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-bgfx</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-glfw</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-jemalloc</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-libdivide</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-llvm</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-lmdb</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-lz4</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-meow</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-meshoptimizer</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-nanovg</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-nfd</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-nuklear</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openal</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opengl</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opengles</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openvr</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-openxr</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-opus</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-par</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-remotery</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-rpmalloc</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-shaderc</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-spvc</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-sse</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-stb</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-tinyexr</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-tinyfd</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-tootle</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-vma</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-xxhash</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-yoga</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.lwjgl</groupId>
<artifactId>lwjgl-zstd</artifactId>
<classifier>${lwjgl.natives}</classifier>
</dependency>
<dependency>
<groupId>org.joml</groupId>
<artifactId>joml</artifactId>
<version>${joml.version}</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -0,0 +1,171 @@
package basics.math.algebra;
public class Matrix {
public double fields[][];
public Matrix() {
this.fields = new double[4][4];
}
public static Matrix translation(Vector offset) {
Matrix result = new Matrix();
result.toIdentity();
result.fields[3][0] = offset.x;
result.fields[3][1] = offset.y;
result.fields[3][2] = offset.z;
return result;
}
public static Matrix scale(Vector scale) {
Matrix result = new Matrix();
result.toIdentity();
result.fields[0][0] = scale.x;
result.fields[1][1] = scale.y;
result.fields[2][2] = scale.z;
return result;
}
public static Matrix rotationX(double theta) {
Matrix result = new Matrix();
double cos = Math.cos(theta);
double sin = Math.sin(theta);
result.fields = new double[][]{
{1, 0, 0, 0},
{0, cos, -sin, 0},
{0, sin, cos, 0},
{0, 0, 0, 1}
};
return result;
}
public static Matrix rotationY(double theta) {
Matrix result = new Matrix();
double cos = Math.cos(theta);
double sin = Math.sin(theta);
result.fields = new double[][]{
{cos, 0, sin, 0},
{0, 1, 0, 0},
{-sin, 0, cos, 0},
{0, 0, 0, 1}
};
return result;
}
public static Matrix rotationZ(double theta) {
Matrix result = new Matrix();
double cos = Math.cos(theta);
double sin = Math.sin(theta);
result.fields = new double[][]{
{cos, -sin, 0, 0},
{sin, cos, 0, 0},
{0, 0, 1, 0},
{0, 0, 0, 1}
};
return result;
}
public static Matrix rotation(Vector angles) {
Matrix rotX = Matrix.rotationX(angles.x);
Matrix rotY = Matrix.rotationX(angles.y);
Matrix rotZ = Matrix.rotationX(angles.z);
return rotX.mul(rotY).mul(rotZ);
}
public void toIdentity() {
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
if (x == y) {
this.fields[x][y] = 1;
} else {
this.fields[x][y] = 0;
}
}
}
}
public Matrix scale(double factor) {
Matrix result = new Matrix();
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
result.fields[x][y] *= factor;
}
}
return result;
}
public Matrix mul(Matrix other) {
Matrix result = new Matrix();
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
for (int v = 0; v < 4; v++) {
result.fields[x][y] += this.fields[v][x] * other.fields[y][v];
}
}
}
return result;
}
public Vector mul(Vector vector) {
Vector result = Vector.origin();
result.x = this.fields[0][0] * vector.x + this.fields[1][0] * vector.y + this.fields[2][0] * vector.z + this.fields[3][0];
result.y = this.fields[0][1] * vector.x + this.fields[1][1] * vector.y + this.fields[2][1] * vector.z + this.fields[3][1];
result.z = this.fields[0][2] * vector.x + this.fields[1][2] * vector.y + this.fields[2][2] * vector.z + this.fields[3][2];
return result;
}
public Matrix add(Matrix other) {
Matrix result = new Matrix();
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
result.fields[x][y] = this.fields[x][y] + other.fields[x][y];
}
}
return result;
}
public Matrix sub(Matrix other) {
Matrix result = new Matrix();
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 4; y++) {
result.fields[x][y] = this.fields[x][y] - other.fields[x][y];
}
}
return result;
}
@Override
public String toString() {
String value = "";
for (int x = 0; x < 4; x++) {
value += String.format("{ %f, %f, %f, %f }\n", this.fields[0][x], this.fields[1][x], this.fields[2][x], this.fields[3][x]);
}
return value;
}
}

View File

@ -0,0 +1,44 @@
package basics.math.algebra;
public class Ray {
private Vector origin;
private Vector direction;
private double near;
private double far;
public Ray(Vector origin, Vector direction, double near, double far) {
this.origin = origin;
this.direction = direction;
this.near = near;
this.far = far;
}
public Vector getOrigin() {
return origin;
}
public void setOrigin(Vector origin) {
this.origin = origin;
}
public Vector getDirection() {
return direction;
}
public void setDirection(Vector direction) {
this.direction = direction;
}
public double getNear() {
return near;
}
public double getFar() {
return far;
}
public Vector travel(double distance) {
return this.origin.add(this.direction.scale(distance));
}
}

View File

@ -0,0 +1,13 @@
package basics.math.algebra;
public class Utils {
public static int roundDownToSquareNumber(int x) {
int i = 1;
while( (i + 1) * (i + 1) < x)
i ++;
return i;
}
}

View File

@ -0,0 +1,115 @@
package basics.math.algebra;
public class Vector {
public double x;
public double y;
public double z;
public Vector(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public static Vector origin() {
return new Vector(0, 0, 0);
}
public static Vector diagonal(double k) {
return new Vector(k, k, k);
}
public Vector add(Vector other) {
return new Vector(this.x + other.x, this.y + other.y, this.z + other.z);
}
public Vector sub(Vector other) {
return new Vector(this.x - other.x, this.y - other.y, this.z - other.z);
}
public Vector scale(double scalar) {
return new Vector(this.x * scalar, this.y * scalar, this.z * scalar);
}
public double dot(Vector other) {
return this.x * other.x + this.y * other.y + this.z * other.z;
}
public double length() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
}
public Vector normalize() {
return this.scale(1.0 / this.length());
}
@Override
public String toString() {
return String.format("{ %f, %f, %f }", this.x, this.y, this.z);
}
public Vector shuffle(SwizzleMask mask) {
Vector result = new Vector(x, y, z);
switch (mask) {
case XYZ -> {
}
case YXZ -> {
result.x = this.y;
result.y = this.x;
result.z = this.z;
}
case ZXY -> {
result.x = this.z;
result.y = this.x;
result.z = this.y;
}
case ZYX -> {
result.x = this.z;
result.y = this.y;
result.z = this.x;
}
case XZY -> {
result.x = this.x;
result.y = this.z;
result.z = this.y;
}
case YZX -> {
result.x = this.y;
result.y = this.z;
result.z = this.x;
}
}
return result;
}
public Vector negate() {
return new Vector(-x, -y, -z);
}
public Vector cross(Vector other) {
return new Vector(
this.y * other.z - this.z * other.y,
this.z * other.x - this.x * other.z,
this.x * other.y - this.y * other.x
);
}
public Vector reflect(Vector normal) {
return this.sub(normal.scale(this.dot(normal) * 2.0));
}
public Vector lerp(Vector other, double k) {
return this.scale(k).add(other.scale(1.0 - k));
}
public enum SwizzleMask {
XYZ,
YXZ,
ZXY,
ZYX,
XZY,
YZX,
}
}

View File

@ -0,0 +1,22 @@
package entry;
import optics.view.PlayerController;
import raytracing.Raytracer;
import renderer.Display;
import renderer.Resolution;
public class Main {
public static void main(String[] args) {
Resolution resolution = new Resolution(800, 800, 2);
PlayerController controller = new PlayerController();
Display display = new Display(resolution, controller);
Raytracer raytracer = new Raytracer();
display.start(raytracer, controller);
}
}

View File

@ -0,0 +1,22 @@
package geometry.scene;
import basics.math.algebra.Ray;
import renderer.mesh.Mesh;
import java.util.Optional;
/**
* Planned:
* - brute force
* - spatial grid
* - bvh
*
*/
public interface AccelerationStructure {
Optional<Hit> intersect(Ray ray);
void addMesh(Mesh mesh);
void removeMesh(Mesh mesh);
}

View File

@ -0,0 +1,23 @@
package geometry.scene;
import renderer.mesh.Mesh;
import renderer.primitive.Primitive;
public class Hit {
private Mesh mesh;
private double distance;
public Hit(Mesh mesh, double distance) {
this.mesh = mesh;
this.distance = distance;
}
public Mesh getMesh() {
return mesh;
}
public double getDistance() {
return distance;
}
}

View File

@ -0,0 +1,42 @@
package geometry.scene;
import basics.math.algebra.Ray;
import renderer.mesh.Mesh;
import java.util.ArrayList;
import java.util.Optional;
public class LinearList implements AccelerationStructure {
private ArrayList<Mesh> meshes = new ArrayList<>();
@Override
public Optional<Hit> intersect(Ray ray) {
Mesh closestHit = null;
double closetDistance = ray.getFar();
for (Mesh mesh : this.meshes) {
double distance = mesh.intersect(ray);
if (distance > ray.getNear() && distance < closetDistance) {
closetDistance = distance;
closestHit = mesh;
}
}
if (closestHit == null)
return Optional.empty();
return Optional.of(new Hit(closestHit, closetDistance));
}
@Override
public void addMesh(Mesh mesh) {
this.meshes.add(mesh);
}
@Override
public void removeMesh(Mesh mesh) {
this.meshes.remove(mesh);
}
}

View File

@ -0,0 +1,60 @@
package geometry.scene;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
import optics.light.Color;
import optics.light.Directional;
import optics.light.LightSource;
import optics.light.Point;
import raytracing.BasicMaterial;
import renderer.mesh.BasicMesh;
import renderer.mesh.Mesh;
import renderer.primitive.Plane;
import renderer.primitive.Sphere;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class Scene {
private AccelerationStructure structure;
private List<LightSource> lights;
public Scene(AccelerationStructure structure) {
this.structure = structure;
this.lights = new ArrayList<>();
}
public static Scene generateExampleScene() {
Scene scene = new Scene(new LinearList());
scene.addMesh(new BasicMesh(new BasicMaterial(new Color(0.8, 0.4, 0.2), 1.0, new Color(1,0.4,0.1)), new Sphere(new Vector(2,0,0), 1.0)));
scene.addMesh(new BasicMesh(new BasicMaterial(new Color(0.8, 0.4, 0.2), 0.0, new Color(1,0.4,0.1)), new Sphere(Vector.origin(), 1.0)));
scene.addMesh(new BasicMesh(new BasicMaterial(new Color(1, 1, 1), 0.2, new Color(1.0)), new Plane(new Vector(1, 0, 0), 1.0)));
scene.addMesh(new BasicMesh(new BasicMaterial(new Color(1, 1, 1), 0.0, new Color(1.0)), new Plane(new Vector(0, 1, 0), 1.0)));
//scene.addLight(new Point(new Color(0.9, 0, 0), new Vector(8,3,-2)));
scene.addLight(new Point(new Color(0,0.8,0), new Vector(4,3,2)));
//scene.addLight(new Directional(new Color(1), new Vector(1, 1, 0).normalize()));
return scene;
}
public void addLight(LightSource light) {
this.lights.add(light);
}
public void addMesh(Mesh mesh) {
this.structure.addMesh(mesh);
}
public Optional<Hit> intersect(Ray ray) {
return this.structure.intersect(ray);
}
public List<LightSource> getLights() {
return lights;
}
}

View File

@ -0,0 +1,112 @@
package optics.light;
public class Color {
public static final Color BLACK = new Color(0,0,0);
public double r;
public double g;
public double b;
public Color(double r, double g, double b) {
this.r = r;
this.g = g;
this.b = b;
}
public Color(double k) {
this.r = k;
this.g = k;
this.b = k;
}
public static Color diagonal(double k) {
return new Color(k, k, k);
}
public Color add(Color other) {
return new Color(this.r + other.r, this.g + other.g, this.b + other.b);
}
public Color sub(Color other) {
return new Color(this.r - other.r, this.g - other.g, this.b - other.b);
}
public Color mul(Color other) {
return new Color(this.r * other.r, this.g * other.g, this.b * other.b);
}
public Color scale(double scalar) {
return new Color(this.r * scalar, this.g * scalar, this.b * scalar);
}
public double average() {
return (this.r + this.g + this.b) / 3.0;
}
@Override
public String toString() {
return String.format("{ %f, %f, %f }", this.r, this.g, this.b);
}
public Color shuffle(Color.SwizzleMask mask) {
Color result = new Color(r, g, b);
switch (mask) {
case rgb -> {
}
case grb -> {
result.r = this.g;
result.g = this.r;
result.b = this.b;
}
case brg -> {
result.r = this.b;
result.g = this.r;
result.b = this.g;
}
case bgr -> {
result.r = this.b;
result.g = this.g;
result.b = this.r;
}
case rbg -> {
result.r = this.r;
result.g = this.b;
result.b = this.g;
}
case gbr -> {
result.r = this.g;
result.g = this.b;
result.b = this.r;
}
}
return result;
}
public Color negate() {
return new Color(-r, -g, -b);
}
public Color cross(Color other) {
return new Color(
this.g * other.b - this.b * other.g,
this.b * other.r - this.r * other.b,
this.r * other.g - this.g * other.r
);
}
public Color lerp(Color other, double k) {
return this.scale(k).add(other.scale(1.0 - k));
}
public enum SwizzleMask {
rgb,
grb,
brg,
bgr,
rbg,
gbr,
}
}

View File

@ -0,0 +1,22 @@
package optics.light;
import basics.math.algebra.Vector;
public class Directional extends LightSource {
private Vector orientation;
public Directional(Color color, Vector orientation) {
super(color);
this.orientation = orientation;
}
public Vector getOrientation() {
return orientation;
}
@Override
public Vector getDirection(Vector point) {
return orientation;
}
}

View File

@ -0,0 +1,22 @@
package optics.light;
import basics.math.algebra.Vector;
public abstract class LightSource {
protected Color color;
public LightSource(Color color) {
this.color = color;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public abstract Vector getDirection(Vector point);
}

View File

@ -0,0 +1,17 @@
package optics.light;
import basics.math.algebra.Vector;
public class Point extends LightSource {
private Vector position;
public Point(Color color, Vector position) {
super(color);
this.position = position;
}
@Override
public Vector getDirection(Vector point) {
return position.sub(point).normalize();
}
}

View File

@ -0,0 +1,18 @@
package optics.view;
import basics.math.algebra.Matrix;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
public interface Camera {
/**
* Generate a view ray for a 2D point on the image plane of the camera
*
* @param u X-Coordiante of image plane
* @param v Y-Coordiante of image plane
* @return
*/
Ray generateViewRay(double u, double v);
void transform(Vector translation, Matrix rotation);
}

View File

@ -0,0 +1,50 @@
package optics.view;
import basics.math.algebra.Matrix;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
public class PinholeCamera implements Camera {
private Vector center;
private Vector up;
private Vector front;
private Vector left;
private double nearPlane;
private double farPlane;
private double fov;
public PinholeCamera(Vector from, Vector lookat, double fov, double nearPlane, double farPlane) {
this.center = from;
this.nearPlane = nearPlane;
this.farPlane = farPlane;
this.fov = 1.0 / Math.tan(Math.toRadians(fov * 0.5));
this.front = lookat.sub(from).normalize();
this.up = front.shuffle(Vector.SwizzleMask.YZX).negate().normalize();
this.left = this.front.cross(this.up).normalize();
}
@Override
public Ray generateViewRay(double u, double v) {
return new Ray(center, front.scale(this.fov).add(left.scale(u)).add(up.scale(v)).normalize(), this.nearPlane, this.farPlane);
}
@Override
public void transform(Vector translation, Matrix rotation) {
this.front = rotation.mul(this.front);
this.left = rotation.mul(this.left);
this.up = rotation.mul(this.up);
this.center = this.center.add(this.front.scale(translation.z));
this.center = this.center.add(this.left.scale(-translation.x));
this.center = this.center.add(this.up.scale(translation.y));
}
@Override
public String toString() {
return "Pinhole-Camera { from: " + center.toString() + " front: " + front.toString() + " up: " + up.toString() + " left: " + left.toString() + " }";
}
}

View File

@ -0,0 +1,81 @@
package optics.view;
import basics.math.algebra.Matrix;
import basics.math.algebra.Vector;
import renderer.Renderer;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
public class PlayerController {
private Vector translation;
private Matrix rotation;
private int cursor;
private boolean changed;
public PlayerController() {
this.translation = new Vector(0,0,0);
this.rotation = new Matrix();
this.rotation.toIdentity();
}
public void motionKeyControl(KeyEvent e) {
this.rotation.toIdentity();
this.translation = new Vector(0,0,0);
switch (e.getKeyChar()) {
case 'w':
this.translation = new Vector(0,0,0.2);
this.changed = true;
break;
case 's':
this.translation = new Vector(0,0,-0.2);
this.changed = true;
break;
case 'a':
this.translation = new Vector(0.2,0, 0);
this.changed = true;
break;
case 'd':
this.translation = new Vector(-0.2, 0,0);
this.changed = true;
break;
case 'e':
this.translation = new Vector(0, -0.2,0);
this.changed = true;
break;
case 'q':
this.translation = new Vector(0, 0.2,0);
this.changed = true;
break;
}
}
public boolean changed() {
boolean tmp = changed;
this.changed = false;
return tmp;
}
public void apply(Renderer renderer) {
renderer.getCamera().transform(this.translation, this.rotation);
}
public void motionMouseControl(MouseEvent e) {
this.translation = new Vector(0,0,0);
double delta = (this.cursor - e.getX()) * 1e-2;
this.cursor = e.getX();
this.rotation = Matrix.rotationY(delta);
this.changed = true;
}
public void mouseReleased() {
this.cursor = 0;
}
}

View File

@ -1,20 +0,0 @@
package org.bot;
public enum Direction {
NORTH, SOUTH, WEST, EAST;
public static Direction directionFromCodePoint(char current) {
switch (current) {
case '^':
return NORTH;
case '>':
return WEST;
case 'V':
case 'v':
return SOUTH;
case '<':
return EAST;
}
return NORTH;
}
}

View File

@ -1,11 +0,0 @@
package org.bot;
public class FloatUtils {
public static final float PI = 3.1415927F;
public static final float PI_HALF = 1.5707964F;
private static final float EPSILON = 0.001F;
public static final boolean isZeroWithTolerance(float x) {
return (Math.abs(x) < 0.001F);
}
}

View File

@ -1,172 +0,0 @@
package org.bot;
import org.objects.WorldObject;
import java.awt.*;
import java.awt.geom.Point2D;
public class Gytebot extends WorldObject {
private static final float RCP_FORCE_DAMPING = 8.0F;
private Direction direction;
private Point2D.Float velocity;
private float angleVelocity;
private float viewAngle;
private boolean isReady;
public Gytebot(Point2D.Float position, Direction direction) {
super(position);
this.direction = direction;
this.velocity = new Point2D.Float();
convertDirectionToAngle(direction);
}
public Gytebot(Gytebot gytebot) {
super(new Point2D.Float());
if (gytebot != null) {
this.direction = gytebot.getDirection();
this.viewAngle = gytebot.getViewAngle();
this.angleVelocity = gytebot.getViewAngleVelocity();
this.position.x = (gytebot.getPosition()).x;
this.position.y = (gytebot.getPosition()).y;
}
}
private float getViewAngleVelocity() {
return this.angleVelocity;
}
public void updateRotation(float elapsedTime) {
this.viewAngle += this.angleVelocity * elapsedTime * 8.0F;
this.angleVelocity += -this.angleVelocity * elapsedTime * 8.0F;
this.position.x += this.velocity.x * elapsedTime * 8.0F;
this.position.y += this.velocity.y * elapsedTime * 8.0F;
this.velocity.x += -this.velocity.x * elapsedTime * 8.0F;
this.velocity.y += -this.velocity.y * elapsedTime * 8.0F;
this.isReady = (FloatUtils.isZeroWithTolerance(this.angleVelocity) && FloatUtils.isZeroWithTolerance(this.velocity.x) && FloatUtils.isZeroWithTolerance(this.velocity.y));
}
public void turnRight() {
switch (this.direction) {
case NORTH:
this.direction = Direction.WEST;
break;
case WEST:
this.direction = Direction.SOUTH;
break;
case SOUTH:
this.direction = Direction.EAST;
break;
case EAST:
this.direction = Direction.NORTH;
break;
default:
break;
}
this.angleVelocity = 1.5707964F;
this.isReady = false;
}
public void turnLeft() {
switch (this.direction) {
case NORTH:
this.direction = Direction.EAST;
break;
case EAST:
this.direction = Direction.SOUTH;
break;
case SOUTH:
this.direction = Direction.WEST;
break;
case WEST:
this.direction = Direction.NORTH;
default:
break;
}
this.angleVelocity = -1.5707964F;
this.isReady = false;
}
private void convertDirectionToAngle(Direction direction) {
switch (direction) {
case NORTH:
this.viewAngle = 1.5707964F;
break;
case SOUTH:
this.viewAngle = -1.5707964F;
break;
case EAST:
this.viewAngle = 0.0F;
break;
case WEST:
this.viewAngle = 3.1415927F;
default:
break;
}
}
public void goForward() {
switch (this.direction) {
case NORTH:
this.velocity = new Point2D.Float(0.0F, -1.0F);
break;
case SOUTH:
this.velocity = new Point2D.Float(0.0F, 1.0F);
break;
case EAST:
this.velocity = new Point2D.Float(-1.0F, 0.0F);
break;
case WEST:
this.velocity = new Point2D.Float(1.0F, 0.0F);
break;
default:
this.velocity = new Point2D.Float();
break;
}
this.isReady = false;
}
public Point getForwardLocation() {
switch (this.direction) {
case NORTH:
return new Point(Math.round(this.position.x), Math.round(this.position.y) - 1);
case SOUTH:
return new Point(Math.round(this.position.x), Math.round(this.position.y) + 1);
case EAST:
return new Point(Math.round(this.position.x) - 1, Math.round(this.position.y));
case WEST:
return new Point(Math.round(this.position.x) + 1, Math.round(this.position.y));
default:
break;
}
return null;
}
public final Direction getDirection() {
return this.direction;
}
public final float getViewAngle() {
return this.viewAngle;
}
public boolean isReady() {
return this.isReady;
}
}

View File

@ -1,155 +0,0 @@
package org.engine;
import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWFramebufferSizeCallback;
import org.lwjgl.glfw.GLFWImage;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
public class Display implements AutoCloseable {
private final long handle;
private final Dimension size;
private GLFWFramebufferSizeCallback framebufferSizeCallback;
private volatile boolean requiredRebuild;
public Display(BufferedImage icon) {
this.size = Toolkit.getDefaultToolkit().getScreenSize();
this.size.width >>= 1;
this.size.height >>= 1;
GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(131076, 0);
GLFW.glfwWindowHint(131075, 1);
this.handle = GLFW.glfwCreateWindow(this.size.width, this.size.height, "RTX-GYTEBOT", 0L, 0L);
setWindowIcon(icon);
if (this.handle == 0L) {
throw new AssertionError("Failed to create the GLFW window!");
}
orientateWindow();
GLFW.glfwMakeContextCurrent(this.handle);
Exception exception1 = null, exception2 = null;
try {
MemoryStack frame = MemoryStack.stackPush();
try {
IntBuffer framebufferSize = frame.mallocInt(2);
GLFW.nglfwGetFramebufferSize(this.handle, MemoryUtil.memAddress(framebufferSize), MemoryUtil.memAddress(framebufferSize) + 4L);
this.size.width = framebufferSize.get(0);
this.size.height = framebufferSize.get(1);
} finally {
if (frame != null) frame.close();
}
} finally {
exception2 = null;
if (exception1 == null) {
exception1 = exception2;
} else if (exception1 != exception2) {
exception1.addSuppressed(exception2);
}
}
}
private void setWindowIcon(BufferedImage icon) {
byte[] data = ((DataBufferByte) icon.getRaster().getDataBuffer()).getData();
ByteBuffer pixels = BufferUtils.createByteBuffer(data.length);
pixels.put(data);
pixels.flip();
GLFWImage.Buffer gb = GLFWImage.create(1);
GLFWImage image = GLFWImage.create().set(icon.getWidth(), icon.getHeight(), pixels);
gb.put(0, image);
GLFW.glfwSetWindowIcon(this.handle, gb);
}
private void orientateWindow() {
int[] left = new int[1];
int[] top = new int[1];
int[] right = new int[1];
int[] bottom = new int[1];
GLFW.glfwGetWindowFrameSize(this.handle, left, top, right, bottom);
this.size.width = this.size.width - left[0] - right[0];
this.size.height = this.size.height - bottom[0] - top[0];
GLFW.glfwSetWindowSize(this.handle, this.size.width, this.size.height);
GLFW.glfwSetWindowPos(this.handle, right[0], top[0]);
}
public final void close() {
//this.framebufferSizeCallback.free();
GLFW.glfwDestroyWindow(this.handle);
}
public final void show() {
GLFW.glfwShowWindow(this.handle);
}
public final boolean shouldNotClose() {
return !GLFW.glfwWindowShouldClose(this.handle);
}
public final void swapBuffers() {
GLFW.glfwSwapBuffers(this.handle);
}
public final long getWindowHandle() {
return this.handle;
}
public final int getWidth() {
return this.size.width;
}
public final int getHeight() {
return this.size.height;
}
public final Dimension getSize() {
return this.size;
}
public boolean wasScaled() {
if (this.requiredRebuild) {
this.requiredRebuild = false;
return true;
}
return false;
}
}

View File

@ -1,172 +0,0 @@
/* */ package org.engine;
/* */
/* */ import org.lwjgl.glfw.GLFW;
/* */ import org.lwjgl.glfw.GLFWErrorCallback;
/* */ import org.lwjgl.glfw.GLFWErrorCallbackI;
/* */ import org.lwjgl.opengl.GL;
/* */ import org.ui.UIAccess;
/* */ import org.ui.icons.IconLoader;
/* */ import org.view.Camera;
/* */ import org.world.World;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Engine
/* */ {
/* */ private GLFWErrorCallback errorCallback;
/* */ private Display display;
/* */ private Renderer renderer;
/* */ private Camera camera;
/* */ private UIAccess ui;
/* */ private World world;
/* */ private float globalTime;
/* */ private float elapsedTime;
/* */
/* */ public Engine() {
/* */ try {
/* 40 */ this.ui = new UIAccess();
/* */
/* 42 */ this.ui.putInfoLoadingMessage("Loading Icon set...", 10);
/* */
/* 44 */ IconLoader.loadIcons();
/* */
/* 46 */ GLFW.glfwSetErrorCallback((GLFWErrorCallbackI)(this.errorCallback = GLFWErrorCallback.createPrint(System.err)));
/* */
/* 48 */ this.ui.putInfoLoadingMessage("Initalizing GLFW...", 25);
/* */
/* 50 */ if (!GLFW.glfwInit()) {
/* 51 */ throw new AssertionError("Could not initalize GLFW!");
/* */ }
/* 53 */ this.ui.putInfoLoadingMessage("Creating GLFW window...", 50);
/* */
/* 55 */ this.display = new Display(this.ui.getWindowIcon());
/* */
/* */
/* 58 */ GLFW.glfwSwapInterval(1);
/* */
/* 60 */ GL.createCapabilities();
/* */
/* 62 */ this.ui.putInfoLoadingMessage("Creating Shaders...", 65);
/* */
/* 64 */ this.renderer = new Renderer(this.display.getSize());
/* */
/* 66 */ this.ui.putInfoLoadingMessage("Setting up window callbacks", 80);
/* */
/* 68 */ this.camera = new Camera(this.display.getWindowHandle());
/* */
/* 70 */ this.ui.putInfoLoadingMessage("Creating World...", 90);
/* */
/* 72 */ this.world = new World();
/* */
/* 74 */ this.ui.putInfoLoadingMessage("Done", 100);
/* */ }
/* 76 */ catch (Exception e) {
/* 77 */ e.printStackTrace();
/* */ } finally {
/* */
/* 80 */ this.ui.close();
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void run() {
/* */ try {
/* 94 */ this.ui.apply(this.world, this.renderer.getPpConfig());
/* */
/* 96 */ this.display.show();
/* */
/* 98 */ // this.ui.openDocs();
/* */
/* 101 */ while (this.display.shouldNotClose() && !this.ui.windowCloseRequest()) {
/* */
/* 103 */ long startTime = System.currentTimeMillis();
/* */
/* 105 */ GLFW.glfwPollEvents();
/* */
/* 107 */ if (this.world.getGytebot() != null)
/* */ {
/* 109 */ this.world.getGytebot().updateRotation(this.elapsedTime);
/* */ }
/* */
/* 112 */ this.camera.update(this.elapsedTime);
/* */
/* 114 */ this.renderer.update(this.display.getSize(), this.globalTime, this.camera, this.world, this.display.wasScaled());
/* */
/* 116 */ this.renderer.render();
/* */
/* 118 */ this.display.swapBuffers();
/* */
/* */
/* 121 */ long passedTime = System.currentTimeMillis() - startTime;
/* */
/* 123 */ if (passedTime < 16L) {
/* 124 */ Thread.sleep(16L - passedTime);
/* */ }
/* */
/* 127 */ this.elapsedTime = (float)(System.currentTimeMillis() - startTime) * 0.001F;
/* */
/* 129 */ this.globalTime += this.elapsedTime;
/* */ }
/* 131 */ } catch (InterruptedException e) {
/* */
/* 133 */ e.printStackTrace();
/* */ } finally {
/* */
/* 136 */ close();
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */ private final void close() {
/* */ try {
/* 145 */ this.errorCallback.free();
/* */
/* 147 */ this.camera.close();
/* 148 */ this.display.close();
/* 149 */ this.renderer.close();
/* 150 */ } catch (Exception e) {
/* 151 */ e.printStackTrace();
/* */ } finally {
/* */
/* 154 */ GLFW.glfwTerminate();
/* 155 */ System.exit(0);
/* */ }
/* */ }
/* */
/* */
/* */ public static void main(String[] args) {
/* 161 */ (new Engine()).run();
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/engine/Engine.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,202 +0,0 @@
/* */ package org.engine;
/* */
/* */ import java.awt.Dimension;
/* */ import java.nio.FloatBuffer;
/* */ import org.lwjgl.BufferUtils;
/* */ import org.lwjgl.opengl.GL11;
/* */ import org.lwjgl.opengl.GL15;
/* */ import org.lwjgl.opengl.GL20;
/* */ import org.lwjgl.opengl.GL30C;
/* */ import org.renderer.FBO;
/* */ import org.renderer.PostProcessConfig;
/* */ import org.renderer.PostProcessor;
/* */ import org.renderer.SceneRenderer;
/* */ import org.view.Camera;
/* */ import org.world.World;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Renderer
/* */ implements AutoCloseable
/* */ {
/* 26 */ private static final float[] QUAD_VERTICES = new float[] { -1.0F, 1.0F, 1.0F, 1.0F, 1.0F, -1.0F, 1.0F, -1.0F, -1.0F, -1.0F, -1.0F, 1.0F };
/* 27 */ private static final int DRAW_COUNT = QUAD_VERTICES.length >> 1;
/* */
/* */
/* */
/* */ private int arrayBufferHandle;
/* */
/* */
/* */
/* */ private PostProcessConfig ppConfig;
/* */
/* */
/* */
/* */ private PostProcessor postProcessor;
/* */
/* */
/* */ private SceneRenderer sceneRenderer;
/* */
/* */
/* */ private FBO fbo;
/* */
/* */
/* */ private Dimension size;
/* */
/* */
/* */
/* */ public Renderer(Dimension size) throws AssertionError {
/* 53 */ this.ppConfig = new PostProcessConfig();
/* */
/* 55 */ createQuadGeometry();
/* */
/* 57 */ GL11.glEnable(3553);
/* */
/* 59 */ this.sceneRenderer = new SceneRenderer();
/* 60 */ this.postProcessor = new PostProcessor();
/* */
/* 62 */ this.fbo = new FBO(size);
/* */
/* */
/* 65 */ this.size = size;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void createQuadGeometry() {
/* 73 */ this.arrayBufferHandle = GL15.glGenBuffers();
/* */
/* */
/* 76 */ FloatBuffer buffer = BufferUtils.createFloatBuffer(QUAD_VERTICES.length);
/* 77 */ buffer.put(QUAD_VERTICES);
/* 78 */ buffer.flip();
/* */
/* */
/* 81 */ GL15.glBindBuffer(34962, this.arrayBufferHandle);
/* 82 */ GL15.glBufferData(34962, buffer, 35044);
/* 83 */ GL15.glBindBuffer(34962, 0);
/* */
/* */
/* 86 */ buffer.clear();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void update(Dimension size, float globalTime, Camera camera, World world, boolean rebuildFBO) {
/* 100 */ if (rebuildFBO) {
/* 101 */ this.fbo.recreate(size);
/* */ }
/* */
/* 104 */ this.sceneRenderer.bind();
/* */
/* 106 */ this.sceneRenderer.loadUniformData(size, globalTime, camera, world);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final void render() {
/* 114 */ renderSceneToFBO();
/* */
/* 116 */ renderFBOtoScreen();
/* */ }
/* */
/* */
/* */
/* */
/* */ private void renderFBOtoScreen() {
/* 123 */ GL11.glEnableClientState(32884);
/* */
/* */
/* 126 */ GL15.glBindBuffer(34962, this.arrayBufferHandle);
/* */
/* 128 */ GL11.glVertexPointer(2, 5126, 0, 0L);
/* */
/* */
/* 131 */ this.postProcessor.bind();
/* */
/* 133 */ this.postProcessor.loadData(this.size, this.fbo, this.ppConfig);
/* */
/* */
/* 136 */ GL11.glDrawArrays(4, 0, DRAW_COUNT);
/* */
/* 138 */ this.postProcessor.unbind();
/* */
/* */
/* */
/* 142 */ GL15.glBindBuffer(34962, 0);
/* 143 */ GL30C.glBindVertexArray(0);
/* */
/* */
/* 146 */ GL11.glDisableClientState(32884);
/* */ }
/* */
/* */
/* */
/* */
/* */ private void renderSceneToFBO() {
/* 153 */ GL11.glEnableClientState(32884);
/* */
/* */
/* 156 */ GL15.glBindBuffer(34962, this.arrayBufferHandle);
/* */
/* 158 */ GL11.glVertexPointer(2, 5126, 0, 0L);
/* */
/* 160 */ this.fbo.bind();
/* */
/* */
/* 163 */ GL11.glDrawArrays(4, 0, DRAW_COUNT);
/* */
/* */
/* 166 */ this.fbo.unbind();
/* */
/* */
/* 169 */ GL15.glBindBuffer(34962, 0);
/* 170 */ GL30C.glBindVertexArray(0);
/* */
/* 172 */ GL20.glUseProgram(0);
/* */
/* */
/* 175 */ GL11.glDisableClientState(32884);
/* */ }
/* */
/* */
/* */
/* */ public void close() throws Exception {
/* 181 */ GL15.glDeleteBuffers(this.arrayBufferHandle);
/* */
/* 183 */ this.sceneRenderer.close();
/* 184 */ this.postProcessor.close();
/* 185 */ this.fbo.close();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final PostProcessConfig getPpConfig() {
/* 194 */ return this.ppConfig;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/engine/Renderer.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,166 +0,0 @@
/* */ package org.logic;
/* */
/* */ import org.run.ForcedStopException;
/* */ import org.world.World;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class GyteController
/* */ {
/* */ private World world;
/* */ private int coinCount;
/* */
/* */ public GyteController(World world) {
/* 26 */ this.world = world;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void turnRight() throws ForcedStopException {
/* 35 */ this.world.getGytebot().turnRight();
/* */
/* 37 */ waitForGytebotApprove();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void turnLeft() throws ForcedStopException {
/* 46 */ this.world.getGytebot().turnLeft();
/* */
/* 48 */ waitForGytebotApprove();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void goForward() throws ForcedStopException {
/* 57 */ if (!this.world.isLocationObstructed(this.world.getGytebot().getForwardLocation())) {
/* 58 */ this.world.getGytebot().goForward();
/* */ }
/* 60 */ waitForGytebotApprove();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void pickup() throws ForcedStopException {
/* 72 */ if (this.world.isCoinPlacedHere(this.world.getGytebot().getPosition())) {
/* */
/* */
/* 75 */ this.world.removeObject(Math.round((this.world.getGytebot().getPosition()).x), Math.round((this.world.getGytebot().getPosition()).y));
/* 76 */ this.coinCount++;
/* */ }
/* */
/* 79 */ delay();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void delay() throws ForcedStopException {
/* */ try {
/* 92 */ Thread.sleep(250L);
/* 93 */ } catch (InterruptedException e) {
/* */
/* 95 */ throw new ForcedStopException();
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void place() throws ForcedStopException {
/* 107 */ if (this.coinCount > 0) {
/* */
/* */
/* 110 */ this.world.setCoin(Math.round((this.world.getGytebot().getPosition()).x), Math.round((this.world.getGytebot().getPosition()).y));
/* 111 */ this.coinCount--;
/* */ }
/* 113 */ delay();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void waitForGytebotApprove() throws ForcedStopException {
/* 123 */ while (!this.world.getGytebot().isReady()) {
/* */ try {
/* 125 */ Thread.sleep(30L);
/* */ }
/* 127 */ catch (InterruptedException e) {
/* */
/* 129 */ throw new ForcedStopException();
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final boolean hasWallFront() throws ForcedStopException {
/* 141 */ return this.world.isLocationObstructed(this.world.getGytebot().getForwardLocation());
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final boolean isOnCoin() throws ForcedStopException {
/* 151 */ return this.world.isCoinPlacedHere(this.world.getGytebot().getPosition());
/* */ }
/* */
/* */
/* */
/* */
/* */ public final int getCoinCount() throws ForcedStopException {
/* 158 */ return this.coinCount;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/logic/GyteController.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,111 +0,0 @@
/* */ package org.logic;
/* */
/* */ import java.lang.reflect.InvocationTargetException;
/* */ import javax.swing.JOptionPane;
/* */ import org.ui.editors.code.CodeEditor;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class GyteProcessor
/* */ extends Thread
/* */ {
/* */ private GyteController gyteController;
/* */ private CodeEditor editor;
/* */ private Program program;
/* */
/* */ public GyteProcessor(GyteController gyteController, CodeEditor editor) {
/* 32 */ this.gyteController = gyteController;
/* 33 */ this.editor = editor;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void run() {
/* 45 */ this.editor.setProgramStatus(true);
/* */
/* */ try {
/* 48 */ this.program.getMainMethod().invoke(this.program.getProgram(), new Object[] { this.gyteController });
/* */ }
/* 50 */ catch (IllegalAccessException e) {
/* 51 */ e.printStackTrace();
/* 52 */ } catch (IllegalArgumentException e) {
/* 53 */ e.printStackTrace();
/* 54 */ } catch (InvocationTargetException e) {
/* 55 */ if (!(e.getCause() instanceof org.run.ForcedStopException))
/* */ {
/* */
/* */
/* 59 */ System.err.println("The Gyte-Processors Thread did not respond in time and killed");
/* */ }
/* */ }
/* 62 */ System.out.println("> Gyte-Processor has finished");
/* 63 */ this.editor.setProgramStatus(false);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void dispatchProgram(Program program) {
/* 72 */ this.program = program;
/* */
/* 74 */ synchronized (this) {
/* */
/* 76 */ start();
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void halt() {
/* 89 */ interrupt();
/* */
/* */
/* */
/* 93 */ try { join(2000L);
/* */
/* */
/* 96 */ if (isAlive()) {
/* 97 */ stop();
/* */ } }
/* 99 */ catch (InterruptedException interruptedException) { }
/* 100 */ catch (SecurityException death)
/* */
/* 102 */ { JOptionPane.showMessageDialog(null, "The Thread running GYTEBOTS code needed to be stopped by ThreadDeath", "Error - stopping Thread", 0); }
/* */
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/logic/GyteProcessor.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,48 +0,0 @@
/* */ package org.logic;
/* */
/* */ import java.lang.reflect.Method;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Program
/* */ {
/* */ private Object program;
/* */ private Method mainMethod;
/* */
/* */ public Program(Object program, Method mainMethod) {
/* 25 */ this.program = program;
/* 26 */ this.mainMethod = mainMethod;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final Object getProgram() {
/* 33 */ return this.program;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final Method getMainMethod() {
/* 40 */ return this.mainMethod;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/logic/Program.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,28 +0,0 @@
/* */ package org.objects;
/* */
/* */ import java.awt.geom.Point2D;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Coin
/* */ extends WorldObject
/* */ {
/* */ public Coin(Point2D.Float position) {
/* 20 */ super(position);
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/objects/Coin.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,27 +0,0 @@
/* */ package org.objects;
/* */
/* */ import java.awt.geom.Point2D;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Wall
/* */ extends WorldObject
/* */ {
/* */ public Wall(Point2D.Float position) {
/* 19 */ super(position);
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/objects/Wall.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,50 +0,0 @@
/* */ package org.objects;
/* */
/* */ import java.awt.geom.Point2D;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public abstract class WorldObject
/* */ {
/* */ protected Point2D.Float position;
/* */
/* */ public WorldObject(Point2D.Float position) {
/* 24 */ this.position = position;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final Point2D.Float getPosition() {
/* 33 */ return this.position;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void setPosition(Point2D.Float position) {
/* 42 */ this.position = position;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/objects/WorldObject.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,130 +0,0 @@
/* */ package org.renderer;
/* */
/* */ import java.awt.Dimension;
import java.nio.ByteBuffer;
/* */ import org.lwjgl.opengl.GL11C;
/* */ import org.lwjgl.opengl.GL30C;
/* */ import org.lwjgl.opengl.GL32C;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class FBO
/* */ implements AutoCloseable
/* */ {
/* */ private int fboHandle;
/* */ private int fboTexture;
/* */
/* */ public FBO(Dimension size) {
/* 45 */ generate(size);
/* */
/* 47 */ unbind();
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void generate(Dimension size) {
/* 57 */ this.fboHandle = GL30C.glGenFramebuffers();
/* */
/* 59 */ this.fboTexture = GL11C.glGenTextures();
/* */
/* */
/* 62 */ GL11C.glBindTexture(3553, this.fboTexture);
/* */
/* */
/* 65 */ GL11C.glTexImage2D(3553, 0, 34836, size.width, size.height, 0, 6408, 5126, (ByteBuffer) null);
/* */
/* */
/* 68 */ GL11C.glTexParameteri(3553, 10240, 9729);
/* 69 */ GL11C.glTexParameteri(3553, 10241, 9729);
/* */
/* */
/* 72 */ GL30C.glBindFramebuffer(36160, this.fboHandle);
/* */
/* 74 */ GL32C.glFramebufferTexture(36160, 36064, this.fboTexture, 0);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void recreate(Dimension size) {
/* 84 */ GL30C.glDeleteFramebuffers(this.fboHandle);
/* 85 */ GL11C.glDeleteTextures(this.fboTexture);
/* */
/* 87 */ generate(size);
/* */ }
/* */
/* */
/* */
/* */
/* */ public final void bind() {
/* 94 */ GL11C.glBindTexture(3553, 0);
/* 95 */ GL30C.glBindFramebuffer(36160, this.fboHandle);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final void unbind() {
/* 103 */ GL30C.glBindFramebuffer(36160, 0);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public int getTextureHandle() {
/* 112 */ return this.fboTexture;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final void close() {
/* 120 */ GL30C.glDeleteFramebuffers(this.fboHandle);
/* 121 */ GL11C.glDeleteTextures(this.fboTexture);
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/renderer/FBO.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,104 +0,0 @@
/* */ package org.renderer;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class PostProcessConfig
/* */ {
/* */ private boolean filterDoF = true;
/* */ private boolean filterFXAA = true;
/* */ private boolean filterGrain = true;
/* */
/* */ public final boolean isFilterGrain() {
/* 34 */ return this.filterGrain;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final void setFilterGrain(boolean filterGrain) {
/* 41 */ this.filterGrain = filterGrain;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final boolean isFilterDoF() {
/* 48 */ return this.filterDoF;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final void setFilterDoF(boolean filterDoF) {
/* 56 */ this.filterDoF = filterDoF;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final boolean isFilterFXAA() {
/* 64 */ return this.filterFXAA;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final void setFilterFXAA(boolean filterFXAA) {
/* 72 */ this.filterFXAA = filterFXAA;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public int getFilterFXAAAsInteger() {
/* 80 */ return this.filterFXAA ? 1 : 0;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public int getFilterGrainAsInteger() {
/* 88 */ return this.filterGrain ? 1 : 0;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public int getFilterDoFAsInteger() {
/* 96 */ return this.filterDoF ? 1 : 0;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/renderer/PostProcessConfig.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,79 +0,0 @@
/* */ package org.renderer;
/* */
/* */ import java.awt.Dimension;
/* */ import org.lwjgl.opengl.GL11C;
/* */ import org.lwjgl.opengl.GL13C;
/* */ import org.lwjgl.opengl.GL20C;
/* */ import org.shader.ShaderProgram;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class PostProcessor
/* */ extends ShaderProgram
/* */ {
/* */ private int fboTextureLocation;
/* */ private int resolutionLocation;
/* */ private int useFXAALocation;
/* */ private int useDoFLocation;
/* */ private int useGrainLocation;
/* */
/* */ public PostProcessor() throws AssertionError {
/* 34 */ super("/data/shader/PostProcessor");
/* */
/* */
/* */
/* 38 */ this.fboTextureLocation = GL20C.glGetUniformLocation(this.program, "fboTexture");
/* 39 */ this.resolutionLocation = GL20C.glGetUniformLocation(this.program, "resolution");
/* */
/* */
/* 42 */ this.useFXAALocation = GL20C.glGetUniformLocation(this.program, "boolFilterFXAA");
/* 43 */ this.useDoFLocation = GL20C.glGetUniformLocation(this.program, "boolFilterDoF");
/* 44 */ this.useGrainLocation = GL20C.glGetUniformLocation(this.program, "boolFilterGrain");
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void loadData(Dimension size, FBO fbo, PostProcessConfig config) {
/* 53 */ GL20C.glUniform2f(this.resolutionLocation, size.width, size.height);
/* */
/* */
/* 56 */ GL20C.glUniform1i(this.useFXAALocation, config.getFilterFXAAAsInteger());
/* 57 */ GL20C.glUniform1i(this.useDoFLocation, config.getFilterDoFAsInteger());
/* 58 */ GL20C.glUniform1i(this.useGrainLocation, config.getFilterGrainAsInteger());
/* */
/* */
/* 61 */ GL13C.glActiveTexture(33984);
/* 62 */ GL11C.glBindTexture(3553, fbo.getTextureHandle());
/* 63 */ GL20C.glUniform1i(this.fboTextureLocation, 0);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final void close() {
/* 71 */ super.close();
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/renderer/PostProcessor.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,255 +0,0 @@
/* */ package org.renderer;
/* */
/* */ import java.awt.Dimension;
/* */ import java.nio.IntBuffer;
/* */ import java.util.HashMap;
/* */ import java.util.Map;
/* */ import javax.swing.JOptionPane;
/* */ import org.lwjgl.BufferUtils;
/* */ import org.lwjgl.opengl.GL11C;
/* */ import org.lwjgl.opengl.GL13C;
/* */ import org.lwjgl.opengl.GL15C;
/* */ import org.lwjgl.opengl.GL20C;
/* */ import org.lwjgl.opengl.GL30C;
/* */ import org.lwjgl.opengl.GL43C;
/* */ import org.shader.ShaderProgram;
/* */ import org.textures.Texture;
/* */ import org.view.Camera;
/* */ import org.world.World;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class SceneRenderer
/* */ extends ShaderProgram
/* */ {
/* 50 */ public static final String[] UNIFORM_NAMES = new String[] {
/* 51 */ "resolution",
/* 52 */ "time",
/* 53 */ "cameraRotation",
/* 54 */ "cameraZoom",
/* 55 */ "worldTexture",
/* 56 */ "environmentTexture",
/* 57 */ "coinTexture",
/* 58 */ "width",
/* 59 */ "height",
/* 60 */ "drawGytebot",
/* 61 */ "gytebotLocation",
/* 62 */ "gytebotRotation" };
/* */
/* */
/* */ private Texture worldTexture;
/* */
/* */
/* */ private Texture environmentTexture;
/* */
/* */
/* */ private Texture coinTexture;
/* */
/* */
/* */ private Texture testTexture;
/* */
/* */ private int coinBuffer;
/* */
/* */ private int coinSsbo;
/* */
/* */ private int wallBuffer;
/* */
/* */ private int wallSsbo;
/* */
/* */ private Map<String, Integer> uniformLocations;
/* */
/* */
/* */ public SceneRenderer() throws AssertionError {
/* 88 */ super("/data/shader/SceneRenderer");
/* */
/* 90 */ this.uniformLocations = new HashMap<>();
/* */
/* */
/* 93 */ this.coinSsbo = GL15C.glGenBuffers();
/* 94 */ this.wallSsbo = GL15C.glGenBuffers();
/* */
/* 96 */ createUniforms();
/* */
/* */
/* */ try {
/* 100 */ createTextures();
/* */ }
/* 102 */ catch (Exception e) {
/* */
/* */
/* 105 */ JOptionPane.showMessageDialog(null, "Unable to load texture(s)", "Error - loading textures", 0);
/* 106 */ e.printStackTrace();
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void createTextures() throws Exception {
/* 116 */ this.worldTexture = new Texture("data/icons/atlas.png");
/* 117 */ this.environmentTexture = new Texture("data/icons/environment.png");
/* 118 */ this.coinTexture = new Texture("data/icons/coin.png");
/* 119 */ this.testTexture = new Texture("data/icons/test.png");
/* */ }
/* */
/* */
/* */ private void createUniforms() {
/* */ byte b;
/* */ int i;
/* */ String[] arrayOfString;
/* 127 */ for (i = (arrayOfString = UNIFORM_NAMES).length, b = 0; b < i; ) { String uniformName = arrayOfString[b];
/* */
/* 129 */ int location = GL20C.glGetUniformLocation(this.program, uniformName);
/* */
/* 131 */ if (location == -1)
/* */ {
/* 133 */ System.err.println("Unable to find uniform: " + uniformName);
/* */ }
/* */
/* */
/* 137 */ this.uniformLocations.put(uniformName, Integer.valueOf(location));
/* */
/* */ b++; }
/* */
/* 141 */ GL20C.glUseProgram(this.program);
/* */
/* */
/* 144 */ IntBuffer props = BufferUtils.createIntBuffer(1);
/* 145 */ IntBuffer params = BufferUtils.createIntBuffer(1);
/* 146 */ props.put(0, 37634);
/* */
/* */
/* 149 */ int coinBufferResourceIndex = GL43C.glGetProgramResourceIndex(this.program, 37606, "CoinBuffer");
/* 150 */ int wallBufferResourceIndex = GL43C.glGetProgramResourceIndex(this.program, 37606, "WallBuffer");
/* */
/* */
/* 153 */ GL43C.glGetProgramResourceiv(this.program, 37606, coinBufferResourceIndex, props, null, params);
/* 154 */ this.coinBuffer = params.get(0);
/* */
/* */
/* 157 */ GL43C.glGetProgramResourceiv(this.program, 37606, wallBufferResourceIndex, props, null, params);
/* 158 */ this.wallBuffer = params.get(0);
/* */
/* 160 */ GL20C.glUseProgram(0);
/* */ }
/* */
/* */
/* */
/* */ public void loadUniformData(Dimension size, float globalTime, Camera camera, World world) {
/* 166 */ if (world.updateCoinTextureData()) {
/* */
/* 168 */ GL15C.glBindBuffer(34962, this.coinSsbo);
/* 169 */ GL15C.glBufferData(34962, world.getCoinTextureData(), 35044);
/* 170 */ GL15C.glBindBuffer(34962, 0);
/* */ }
/* */
/* */
/* 174 */ if (world.updateWallBufferData()) {
/* */
/* 176 */ GL15C.glBindBuffer(34962, this.wallSsbo);
/* 177 */ GL15C.glBufferData(34962, world.getWallBufferData(), 35044);
/* 178 */ GL15C.glBindBuffer(34962, 0);
/* */ }
/* */
/* */
/* */
/* */
/* 184 */ GL20C.glUniform2f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[0])).intValue(), size.width, size.height);
/* 185 */ GL20C.glUniform1f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[1])).intValue(), globalTime);
/* */
/* 187 */ GL20C.glUniform2f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[2])).intValue(), camera.getCameraRotationX(), camera.getCameraRotationY());
/* 188 */ GL20C.glUniform1f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[3])).intValue(), camera.getCameraZoom());
/* */
/* 190 */ GL13C.glActiveTexture(33984);
/* 191 */ GL11C.glBindTexture(3553, this.worldTexture.getHandle());
/* 192 */ GL20C.glUniform1i(((Integer)this.uniformLocations.get(UNIFORM_NAMES[4])).intValue(), 0);
/* */
/* 194 */ GL13C.glActiveTexture(33985);
/* 195 */ GL11C.glBindTexture(3553, this.environmentTexture.getHandle());
/* 196 */ GL20C.glUniform1i(((Integer)this.uniformLocations.get(UNIFORM_NAMES[5])).intValue(), 1);
/* */
/* 198 */ GL13C.glActiveTexture(33986);
/* 199 */ GL11C.glBindTexture(3553, this.coinTexture.getHandle());
/* 200 */ GL20C.glUniform1i(((Integer)this.uniformLocations.get(UNIFORM_NAMES[6])).intValue(), 2);
/* */
/* 202 */ GL13C.glActiveTexture(33987);
/* 203 */ GL11C.glBindTexture(3553, this.testTexture.getHandle());
/* 204 */ GL20C.glUniform1i(GL20C.glGetUniformLocation(this.program, "testTexture"), 3);
/* */
/* 206 */ GL20C.glUniform1f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[7])).intValue(), world.getWidth());
/* 207 */ GL20C.glUniform1f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[8])).intValue(), world.getHeight());
/* */
/* 209 */ GL20C.glUniform1i(((Integer)this.uniformLocations.get(UNIFORM_NAMES[9])).intValue(), world.getDrawGytebotAsInt());
/* */
/* */
/* 212 */ if (world.getGytebot() != null) {
/* */
/* 214 */ GL20C.glUniform2f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[10])).intValue(), (world.getGytebot().getPosition()).x, (world.getGytebot().getPosition()).y);
/* 215 */ GL20C.glUniform1f(((Integer)this.uniformLocations.get(UNIFORM_NAMES[11])).intValue(), world.getGytebot().getViewAngle());
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void bind() {
/* 225 */ super.bind();
/* 226 */ GL30C.glBindBufferBase(37074, this.coinBuffer, this.coinSsbo);
/* 227 */ GL30C.glBindBufferBase(37074, this.wallBuffer, this.wallSsbo);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void unbind() {
/* 236 */ super.unbind();
/* 237 */ GL30C.glBindBufferBase(37074, this.coinBuffer, 0);
/* 238 */ GL30C.glBindBufferBase(37074, this.wallBuffer, 0);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final void close() {
/* 246 */ super.close();
/* */
/* 248 */ GL15C.glDeleteBuffers(this.coinSsbo);
/* 249 */ GL15C.glDeleteBuffers(this.coinSsbo);
/* */
/* 251 */ this.worldTexture.close();
/* 252 */ this.environmentTexture.close();
/* 253 */ this.coinTexture.close();
/* */ }
/* */ }

View File

@ -1,26 +0,0 @@
/* */ package org.run;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ForcedStopException
/* */ extends Exception
/* */ {
/* */ private static final long serialVersionUID = -5622884875009979898L;
/* */
/* */ public ForcedStopException() {
/* 18 */ super("The running thread needed to be stopped violently, no excusses");
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/run/ForcedStopException.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,252 +0,0 @@
/* */ package org.run;
/* */
/* */ import java.io.File;
/* */ import java.io.IOException;
/* */ import java.lang.reflect.InvocationTargetException;
/* */ import java.lang.reflect.Method;
/* */ import java.net.MalformedURLException;
/* */ import java.net.URL;
/* */ import java.net.URLClassLoader;
/* */ import java.nio.file.Files;
/* */ import java.nio.file.Path;
/* */ import java.nio.file.Paths;
/* */ import java.nio.file.attribute.FileAttribute;
/* */ import java.util.Arrays;
/* */ import javax.tools.Diagnostic;
/* */ import javax.tools.DiagnosticCollector;
/* */ import javax.tools.JavaCompiler;
/* */ import javax.tools.JavaFileObject;
/* */ import javax.tools.StandardJavaFileManager;
/* */ import javax.tools.ToolProvider;
/* */ import org.logic.GyteController;
/* */ import org.logic.GyteProcessor;
/* */ import org.logic.Program;
/* */ import org.ui.debug.Console;
/* */ import org.ui.debug.Entry;
/* */ import org.ui.editors.code.CodeEditor;
/* */ import org.world.World;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class GyteCompiler
/* */ {
/* */ private static final String CLASS_NAME = "GyteProgram";
/* */ private static final String METHOD_NAME = "run";
/* */ private static final boolean SUCCESS = true;
/* */ private volatile GyteProcessor processor;
/* */ private World world;
/* */ private CodeEditor editor;
/* */ private Console console;
/* */ private File[] file;
/* */ private JavaCompiler compiler;
/* */ private StandardJavaFileManager fileManager;
/* */ private Iterable<? extends JavaFileObject> compilationUnits;
/* */ private DiagnosticCollector<JavaFileObject> diagnostics;
/* */ private boolean isCompilerInstalled;
/* */
/* */ public GyteCompiler(World world, Console console, CodeEditor editor) {
/* 73 */ this.world = world;
/* 74 */ this.console = console;
/* 75 */ this.editor = editor;
/* */
/* */
/* 78 */ this.compiler = ToolProvider.getSystemJavaCompiler();
/* */
/* 80 */ this.isCompilerInstalled = (this.compiler != null);
/* */
/* 82 */ if (this.isCompilerInstalled) {
/* */
/* 84 */ this.fileManager = this.compiler.getStandardFileManager(null, null, null);
/* */
/* */ }
/* */ else {
/* */
/* 89 */ console.createLog("No Java Compiler could be found on this system\n", Entry.WARNING);
/* 90 */ console.createLog("See README.MD for futher instructions/help\n", Entry.WARNING);
/* */ }
/* */
/* */
/* 94 */ System.setOut(console.getStdOut());
/* 95 */ System.setErr(console.getStdErr());
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void compileAndRunProgram(String source) {
/* 104 */ this.console.createLog("Compiling source...\n", Entry.INFORMATION);
/* */
/* */
/* 107 */ Path temp = Paths.get(System.getProperty("java.io.tmpdir"), new String[] { "GyteProgram" });
/* */
/* */
/* */ try {
/* 111 */ Files.createDirectories(temp, (FileAttribute<?>[])new FileAttribute[0]);
/* */
/* */
/* 114 */ Path javaSourceFile = Paths.get(temp.normalize().toAbsolutePath().toString(), new String[] { "GyteProgram.java" });
/* */
/* */
/* 117 */ Files.write(javaSourceFile, source.getBytes(), new java.nio.file.OpenOption[0]);
/* */
/* */
/* 120 */ compile(javaSourceFile, temp);
/* */
/* 122 */ Path classFile = Paths.get(temp.normalize().toAbsolutePath().toString(), new String[] { "GyteProgram.class" });
/* */
/* */
/* 125 */ if (Files.exists(classFile, new java.nio.file.LinkOption[0])) {
/* 126 */ Files.delete(classFile);
/* */ }
/* */
/* 129 */ Files.delete(javaSourceFile);
/* */
/* 131 */ Files.delete(temp);
/* */ }
/* 133 */ catch (IOException e1) {
/* 134 */ this.console.createLog("Unable to find or edit \"java.io.tmpdir\": " + temp.toString() + "\n", Entry.ERROR);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void compile(Path javaSourceFile, Path temp) {
/* 145 */ this.file = new File[] { javaSourceFile.toFile() };
/* 146 */ this.compilationUnits = this.fileManager.getJavaFileObjectsFromFiles(Arrays.asList(this.file));
/* 147 */ this.diagnostics = new DiagnosticCollector<>();
/* */
/* */
/* 150 */ JavaCompiler.CompilationTask task = this.compiler.getTask(null, this.fileManager, this.diagnostics, null, null, this.compilationUnits);
/* */
/* */
/* 153 */ boolean compilationStatus = task.call().booleanValue();
/* */
/* */
/* 156 */ for (Diagnostic<?> diagnostic : this.diagnostics.getDiagnostics()) {
/* */
/* 158 */ this.console.createLog(String.format("Error in line: %d\nat: %s\n%s\n\n", new Object[] { Long.valueOf(diagnostic.getLineNumber()), diagnostic.getSource(), diagnostic.getMessage(null) }), Entry.ERROR);
/* */
/* 160 */ this.editor.markLine((int)diagnostic.getLineNumber());
/* */ }
/* */
/* */
/* 164 */ if (compilationStatus) {
/* 165 */ runProgram(temp);
/* */ }
/* */
/* */ try {
/* 169 */ this.fileManager.close();
/* 170 */ } catch (IOException e) {
/* 171 */ this.console.createLog("The compiler's file resources could not be deleted\n", Entry.ERROR);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void runProgram(Path temp) {
/* */ try {
/* 184 */ ClassLoader classLoader = getClass().getClassLoader();
/* 185 */ URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { temp.toUri().toURL() }, classLoader);
/* */
/* */
/* */
/* */
/* */
/* */ try {
/* 192 */ Class<?> javaDemoClass = urlClassLoader.loadClass("GyteProgram");
/* */
/* */ try {
/* 195 */ Object instance = javaDemoClass.getConstructor(new Class[0]).newInstance(new Object[0]);
/* 196 */ Method method = instance.getClass().getMethod("run", new Class[] { GyteController.class });
/* */
/* 198 */ if (this.processor != null && this.processor.isAlive()) {
/* */
/* */
/* 201 */ this.processor.halt();
/* 202 */ this.console.createLog("A processor was still running, an was thus shutdown\n", Entry.WARNING);
/* */ }
/* */
/* */
/* 206 */ this.processor = new GyteProcessor(new GyteController(this.world), this.editor);
/* */
/* 208 */ this.processor.dispatchProgram(new Program(instance, method));
/* */
/* 210 */ this.console.createLog("Dispatching program...\n", Entry.INFORMATION);
/* */ }
/* 212 */ catch (InstantiationException e) {
/* 213 */ e.printStackTrace();
/* 214 */ } catch (IllegalAccessException e) {
/* 215 */ e.printStackTrace();
/* 216 */ } catch (IllegalArgumentException e) {
/* 217 */ e.printStackTrace();
/* 218 */ } catch (InvocationTargetException e) {
/* 219 */ e.printStackTrace();
/* */ }
/* */
/* 222 */ urlClassLoader.close();
/* */ }
/* 224 */ catch (ClassNotFoundException e1) {
/* 225 */ this.console.createLog("The required Class \"GyteProgram\" was not defined or could not be compiled.\n", Entry.ERROR);
/* 226 */ } catch (NoSuchMethodException e1) {
/* 227 */ this.console.createLog("The required Method \"run\"\nin type \"GyteProgram\" was not defined.\n", Entry.ERROR);
/* 228 */ } catch (SecurityException e1) {
/* 229 */ this.console.createLog("Security violation detected.", Entry.ERROR);
/* 230 */ } catch (IOException e) {
/* 231 */ this.console.createLog("Unable to close class loader", Entry.ERROR);
/* */ }
/* 233 */ } catch (MalformedURLException e) {
/* 234 */ this.console.createLog("The class file(s) URL was invalid!\n", Entry.ERROR);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final GyteProcessor getProcessor() {
/* 244 */ return this.processor;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/run/GyteCompiler.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,84 +0,0 @@
/* */ package org.shader;
/* */
/* */ import java.io.BufferedReader;
/* */ import java.io.InputStreamReader;
/* */ import org.lwjgl.opengl.GL20C;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Shader
/* */ implements AutoCloseable
/* */ {
/* */ private int shaderHandle;
/* */
/* */ public Shader(String fileName, int shaderType) throws AssertionError {
/* 28 */ this.shaderHandle = GL20C.glCreateShader(shaderType);
/* */
/* 30 */ GL20C.glShaderSource(this.shaderHandle, getSource(fileName));
/* 31 */ GL20C.glCompileShader(this.shaderHandle);
/* */
/* 33 */ if (GL20C.glGetShaderi(this.shaderHandle, 35713) == 0) {
/* */
/* 35 */ System.err.println(GL20C.glGetShaderInfoLog(this.shaderHandle));
/* 36 */ throw new AssertionError("Could not compile Shader: " + fileName);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private String getSource(String fileName) {
/* */ try {
/* 49 */ BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResource(fileName).openStream()));
/* */
/* 51 */ String result = reader.lines().reduce("", (A, B) -> String.valueOf(A) + B + System.lineSeparator());
/* */
/* 53 */ reader.close();
/* */
/* 55 */ return result;
/* 56 */ } catch (Exception e) {
/* 57 */ e.printStackTrace();
/* 58 */ return null;
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final int getHandle() {
/* 68 */ return this.shaderHandle;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public void close() {
/* 76 */ GL20C.glDeleteShader(this.shaderHandle);
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/shader/Shader.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,85 +0,0 @@
/* */ package org.shader;
/* */
/* */ import org.lwjgl.opengl.GL20C;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ShaderProgram
/* */ implements AutoCloseable
/* */ {
/* */ protected int program;
/* */ private Shader vertexShader;
/* */ private Shader fragmentShader;
/* */
/* */ public ShaderProgram(String shaderName) throws AssertionError {
/* 28 */ this.program = GL20C.glCreateProgram();
/* */
/* */
/* 31 */ this.vertexShader = new Shader(String.valueOf(shaderName) + ".vsh.glsl", 35633);
/* 32 */ this.fragmentShader = new Shader(String.valueOf(shaderName) + ".fsh.glsl", 35632);
/* */
/* */
/* 35 */ GL20C.glAttachShader(this.program, this.vertexShader.getHandle());
/* 36 */ GL20C.glAttachShader(this.program, this.fragmentShader.getHandle());
/* */
/* 38 */ GL20C.glBindAttribLocation(this.program, 0, "vertexPosition");
/* */
/* 40 */ GL20C.glLinkProgram(this.program);
/* 41 */ if (GL20C.glGetProgrami(this.program, 35714) == 0) {
/* */
/* 43 */ System.err.println(GL20C.glGetProgramInfoLog(this.program));
/* 44 */ throw new AssertionError("Unable to create shader program");
/* */ }
/* */
/* 47 */ GL20C.glValidateProgram(this.program);
/* 48 */ if (GL20C.glGetProgrami(this.program, 35715) == 0) {
/* */
/* 50 */ System.err.println(GL20C.glGetProgramInfoLog(this.program));
/* 51 */ throw new AssertionError("Unable to create shader program");
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */ public void bind() {
/* 59 */ GL20C.glUseProgram(this.program);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public void close() {
/* 67 */ GL20C.glDeleteProgram(this.program);
/* */
/* 69 */ this.vertexShader.close();
/* 70 */ this.fragmentShader.close();
/* */ }
/* */
/* */
/* */
/* */
/* */ public void unbind() {
/* 77 */ GL20C.glUseProgram(0);
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/shader/ShaderProgram.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,72 +0,0 @@
package org.textures;
import org.lwjgl.opengl.GL11C;
import org.lwjgl.opengl.GL30C;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.io.InputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidParameterException;
public class Texture implements AutoCloseable {
private int textureHandle;
public Texture(String resource) throws Exception {
final BufferedImage image = loadImageDataAsARGB(resource);
final int[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();
// generate OpenGL texture buffer
this.textureHandle = GL11C.glGenTextures();
GL11C.glBindTexture(GL11C.GL_TEXTURE_2D, this.textureHandle);
GL11C.glPixelStorei(3317, 1);
GL11C.glTexParameteri(3553, 10241, 9987);
GL11C.glTexParameteri(3553, 10240, 9729);
GL11C.glTexParameteri(3553, 10242, 10497);
GL11C.glTexParameteri(3553, 10243, 10497);
GL11C.glTexImage2D(3553, 0, 6408, image.getWidth(), image.getHeight(), 0, 6408, 5121, pixels);
GL30C.glGenerateMipmap(3553);
GL11C.glBindTexture(3553, 0);
}
/**
* Load image from disk as array of colors in ARGB format
*
* @param resource file path to load
* @return array of ARGB values
*/
private BufferedImage loadImageDataAsARGB(String resource) throws Exception {
InputStream stream = Texture.class.getClassLoader().getResourceAsStream(resource);
if (stream == null)
throw new InvalidParameterException("Resource not found: " + resource);
// buffer raw image data
BufferedImage rawData = ImageIO.read(stream);
// create buffer of fixed color layout of ARGB-Bytes
BufferedImage layoutedData = new BufferedImage(rawData.getWidth(), rawData.getHeight(), BufferedImage.TYPE_INT_ARGB);
// write raw image data into buffer with known color format
layoutedData.createGraphics().drawImage(rawData, 0, 0, null);
return layoutedData;
}
public final int getHandle() {
return this.textureHandle;
}
public void close() {
GL11C.glDeleteTextures(this.textureHandle);
}
}

View File

@ -1,74 +0,0 @@
/* */ package org.ui;
/* */
/* */ import java.awt.Dimension;
/* */ import java.awt.Toolkit;
/* */ import java.io.BufferedReader;
/* */ import java.io.InputStreamReader;
/* */ import javax.swing.JEditorPane;
/* */ import javax.swing.JFrame;
/* */ import javax.swing.JOptionPane;
/* */ import javax.swing.JScrollPane;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Documentation
/* */ extends JFrame
/* */ {
/* */ private static final long serialVersionUID = 4741160972916811991L;
/* */ private JEditorPane textPane;
/* */
/* */ public Documentation() {
/* 33 */ Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
/* */
/* */
/* 36 */ this.textPane = new JEditorPane();
/* 37 */ this.textPane.setContentType("text/html");
/* 38 */ this.textPane.setEditable(false);
/* */
/* 40 */ loadDocsFromFile();
/* */
/* */
/* 43 */ setTitle("RTX-GYTEBOT - Documentation (also README)");
/* 44 */ getContentPane().add(new JScrollPane(this.textPane));
/* 45 */ setSize(size.width * 3 >> 2, size.height * 3 >> 2);
/* 46 */ setLocationRelativeTo(null);
/* 47 */ setVisible(true);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void loadDocsFromFile() {
/* */ try {
/* 56 */ BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/data/docs.html")));
/* */
/* */
/* 59 */ this.textPane.setText(reader.lines().reduce("", (A, B) -> String.valueOf(A) + B + "\n"));
/* */
/* 61 */ reader.close();
/* 62 */ } catch (Exception e) {
/* */
/* 64 */ JOptionPane.showMessageDialog(null, "Could not open or read the deocumentation", "Error - documentation", 0);
/* 65 */ e.printStackTrace();
/* */ }
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/Documentation.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,95 +0,0 @@
package org.ui;
import com.formdev.flatlaf.FlatDarkLaf;
import org.renderer.PostProcessConfig;
import org.ui.editors.code.CodeEditor;
import org.ui.editors.map.MapEditor;
import org.ui.icons.IconLoader;
import org.world.World;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
public class UIAccess
implements AutoCloseable {
private JFrame startUpWindow;
private JProgressBar infoLog;
private Documentation docs;
private MapEditor mapEditor;
private CodeEditor codeEditor;
private BufferedImage windowIcon;
public UIAccess() {
try {
this.windowIcon = IconLoader.loadWindowIcon();
if (!FlatDarkLaf.setup()) {
}
this.infoLog = new JProgressBar(0, 0, 100);
this.infoLog.setStringPainted(true);
this.startUpWindow = new JFrame("RTX-GYTEBOT");
this.startUpWindow.setIconImage(this.windowIcon);
this.startUpWindow.setUndecorated(true);
this.startUpWindow.setDefaultCloseOperation(0);
this.startUpWindow.getContentPane().setLayout(new BorderLayout());
this.startUpWindow.getContentPane().add(new JLabel(new ImageIcon(ImageIO.read(getClass().getResourceAsStream("/data/icons/startup.png")))), "Center");
this.startUpWindow.getContentPane().add(this.infoLog, "South");
this.startUpWindow.pack();
this.startUpWindow.setLocationRelativeTo(null);
this.startUpWindow.setVisible(true);
} catch (IOException | NullPointerException e) {
this.startUpWindow.dispose();
throw new AssertionError("Unable to load or find startup image");
}
}
public final boolean windowCloseRequest() {
return !(!this.mapEditor.getWindowCloseRequest() && !this.codeEditor.getWindowCloseRequest());
}
public final void apply(World world, PostProcessConfig postProcessConfig) {
this.mapEditor = new MapEditor(world);
this.mapEditor.setIconImage(this.windowIcon);
this.codeEditor = new CodeEditor(world, postProcessConfig);
this.codeEditor.setIconImage(this.windowIcon);
}
public final void openDocs() {
this.docs = new Documentation();
}
public void putInfoLoadingMessage(String message, int progress) {
this.infoLog.setString(message);
this.infoLog.setValue(progress);
}
public final void close() {
this.startUpWindow.setVisible(false);
this.startUpWindow.dispose();
}
public BufferedImage getWindowIcon() {
return this.windowIcon;
}
}

View File

@ -1,29 +0,0 @@
/* */ package org.ui;
/* */
/* */ import java.awt.Color;
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class UIConfig
/* */ {
/* */ public static final int GUI_SCALE = 28;
/* */ public static final int MAP_FONT_SIZE = 24;
/* */ public static final int CODE_FONT_SIZE = 16;
/* */ public static final int CONSOLE_FONT_SIZE = 14;
/* */ public static final int INFORMATION_FONT_SIZE = 12;
/* */ public static final String DEFAULT_FONT = "Consolas";
/* */ public static final String DEFAULT_WINDOW_TITLE = "RTX-GYTEBOT";
/* */ public static final int CONSOLE_QUEUE_SIZE = 36;
/* */ public static final int CONSOLE_ENTRY_SIZE = 48;
/* */ public static final long MIN_FRAME_TIME_LIMIT = 16L;
/* 22 */ public static final Color CONTENT_BACKGROUND = new Color(15921131);
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/UIConfig.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,32 +0,0 @@
package org.ui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class UICreator {
public static JButton createIconifiedButton(char iconCharacterCode) {
final JButton button = new JButton(String.valueOf(iconCharacterCode));
button.setFont(new Font("RTX-GYTEBOT-ICONS", 0, 28));
button.setFocusPainted(false);
button.setContentAreaFilled(false);
button.setBorder(BorderFactory.createEmptyBorder(2, 10, 2, 10));
button.setOpaque(false);
button.addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent event) {
button.setCursor(new Cursor(12));
}
public void mouseExited(MouseEvent event) {
button.setCursor(new Cursor(0));
}
});
return button;
}
}

View File

@ -1,258 +0,0 @@
/* */ package org.ui.debug;
/* */
/* */ import java.awt.BorderLayout;
/* */ import java.awt.Color;
/* */ import java.awt.FlowLayout;
/* */ import java.awt.Font;
/* */ import java.awt.event.ActionEvent;
/* */ import java.io.PrintStream;
/* */ import javax.swing.BorderFactory;
/* */ import javax.swing.BoxLayout;
/* */ import javax.swing.JButton;
/* */ import javax.swing.JLabel;
/* */ import javax.swing.JPanel;
/* */ import javax.swing.JScrollPane;
/* */ import javax.swing.JTextArea;
/* */ import org.ui.UICreator;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Console
/* */ extends JPanel
/* */ {
/* */ private static final long serialVersionUID = -1800165403047521827L;
/* */ private JPanel consoleLogger;
/* */ private JScrollPane scrollPane;
/* */ private JPanel toolBar;
/* */ private JButton clear;
/* */ private JLabel queueSize;
/* */ private JLabel info;
/* */ private ConsoleWriteStream stdout;
/* */ private ConsoleWriteStream stderr;
/* 50 */ private Entry lastEntry = Entry.NORMAL;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public Console() {
/* 59 */ setLayout(new BorderLayout());
/* */
/* 61 */ createUI();
/* */
/* 63 */ setupUI();
/* */
/* 65 */ createListener();
/* */
/* 67 */ createWriteStreams();
/* */
/* */
/* 70 */ add(this.scrollPane, "Center");
/* 71 */ add(this.toolBar, "North");
/* */
/* */
/* 74 */ createLog("Console was created successfully\n", Entry.INFORMATION);
/* */ }
/* */
/* */
/* */
/* */
/* */ private void createListener() {
/* 81 */ this.clear.addActionListener(e -> {
/* */ this.consoleLogger.removeAll();
/* */ this.consoleLogger.revalidate();
/* */ this.consoleLogger.repaint();
/* */ this.queueSize.setText("| Elements: (none)");
/* */ this.info.setText((String)null);
/* */ });
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void setupUI() {
/* 97 */ this.consoleLogger.setLayout(new BoxLayout(this.consoleLogger, 1));
/* 98 */ this.info.setForeground(Color.YELLOW);
/* */
/* */
/* 101 */ this.clear.setToolTipText("Clear the console logger's buffer.\nThis means deleting all current log entries in the console.");
/* */
/* 103 */ this.scrollPane.setVerticalScrollBarPolicy(22);
/* 104 */ this.scrollPane.setHorizontalScrollBarPolicy(30);
/* 105 */ this.scrollPane.setAutoscrolls(true);
/* */
/* */
/* 108 */ this.toolBar.add(new JLabel("Console"));
/* 109 */ this.toolBar.add(this.clear);
/* 110 */ this.toolBar.add(this.queueSize);
/* 111 */ this.toolBar.add(this.info);
/* */ }
/* */
/* */
/* */
/* */
/* */ private void createUI() {
/* 118 */ this.toolBar = new JPanel(new FlowLayout(0, 4, 0));
/* */
/* 120 */ this.consoleLogger = new JPanel();
/* */
/* 122 */ this.scrollPane = new JScrollPane(this.consoleLogger);
/* */
/* 124 */ this.clear = UICreator.createIconifiedButton('c');
/* 125 */ this.queueSize = new JLabel();
/* 126 */ this.info = new JLabel();
/* */ }
/* */
/* */
/* */
/* */
/* */ private void createWriteStreams() {
/* 133 */ this.stdout = new ConsoleWriteStream(this, Entry.NORMAL);
/* 134 */ this.stderr = new ConsoleWriteStream(this, Entry.ERROR);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final synchronized void createLog(String message, Entry entryType) {
/* 148 */ JTextArea lastLog = getLastEntryLog();
/* */
/* */
/* */
/* 152 */ if (this.lastEntry == entryType && lastLog != null && (int)lastLog.getText().lines().count() < 48) {
/* */
/* */
/* 155 */ lastLog.setText(String.format("%s%s", new Object[] { lastLog.getText(), message }));
/* */
/* */
/* 158 */ this.scrollPane.getVerticalScrollBar().setValue(this.scrollPane.getVerticalScrollBar().getMaximum());
/* 159 */ this.scrollPane.repaint();
/* */
/* */ }
/* */ else {
/* */
/* 164 */ boolean isQueueFull = ((this.consoleLogger.getComponents()).length > 36);
/* */
/* */
/* 167 */ this.info.setText(isQueueFull ? "Elements were deleted form Console buffer due to limited queue size" : null);
/* */
/* */
/* 170 */ if (isQueueFull)
/* */ {
/* */
/* 173 */ this.consoleLogger.remove(this.consoleLogger.getComponents()[0]);
/* */ }
/* */
/* */
/* 177 */ createBasicConsoleLog(message, Entry.getColorByEnum(entryType));
/* */ }
/* */
/* 180 */ this.lastEntry = entryType;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private JTextArea getLastEntryLog() {
/* 190 */ int elementIndex = (this.consoleLogger.getComponents()).length - 1;
/* */
/* 192 */ if (elementIndex < 0)
/* */ {
/* 194 */ return null;
/* */ }
/* */
/* */
/* 198 */ return (JTextArea)this.consoleLogger.getComponents()[elementIndex];
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void createBasicConsoleLog(String message, Color color) {
/* 211 */ JTextArea messageBlock = new JTextArea(message);
/* */
/* */
/* */
/* */
/* 216 */ messageBlock.setBorder(BorderFactory.createEmptyBorder());
/* */
/* 218 */ messageBlock.setFont(new Font("Consolas", 0, 14));
/* */
/* 220 */ messageBlock.setEditable(false);
/* */
/* 222 */ messageBlock.setBackground(new Color(1579032));
/* */
/* 224 */ messageBlock.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.DARK_GRAY));
/* 225 */ messageBlock.setForeground(color);
/* */
/* */
/* */
/* 229 */ this.consoleLogger.add(messageBlock);
/* 230 */ this.scrollPane.getVerticalScrollBar().setValue(this.scrollPane.getVerticalScrollBar().getMaximum());
/* */
/* 232 */ this.queueSize.setText(String.format("Elements: (%d)", new Object[] { Integer.valueOf((this.consoleLogger.getComponents()).length) }));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public PrintStream getStdOut() {
/* 241 */ return new PrintStream(this.stdout);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public PrintStream getStdErr() {
/* 250 */ return new PrintStream(this.stderr);
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/debug/Console.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,59 +0,0 @@
/* */ package org.ui.debug;
/* */
/* */ import java.io.IOException;
/* */ import java.io.OutputStream;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class ConsoleWriteStream
/* */ extends OutputStream
/* */ {
/* */ private Console parentConsole;
/* */ private String streamBuffer;
/* */ private Entry entryType;
/* */
/* */ public ConsoleWriteStream(Console parentConsole, Entry entryType) {
/* 30 */ this.parentConsole = parentConsole;
/* 31 */ this.entryType = entryType;
/* 32 */ this.streamBuffer = new String();
/* */ }
/* */
/* */
/* */ public void write(int b) throws IOException {
/* 37 */ this.streamBuffer = String.valueOf(this.streamBuffer) + (char)b;
/* */ }
/* */
/* */
/* */
/* */ public void write(byte[] b, int off, int len) throws IOException {
/* 43 */ for (int i = off; i < off + len; i++) {
/* 44 */ this.streamBuffer = String.valueOf(this.streamBuffer) + (char)b[i];
/* */ }
/* */
/* 47 */ this.parentConsole.createLog(this.streamBuffer, this.entryType);
/* */
/* 49 */ this.streamBuffer = new String();
/* */ }
/* */
/* */ public void flush() {}
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/debug/ConsoleWriteStream.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,46 +0,0 @@
/* */ package org.ui.debug;
/* */
/* */ import java.awt.Color;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public enum Entry
/* */ {
/* 14 */ INFORMATION, NORMAL, ERROR, WARNING;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static final Color getColorByEnum(Entry entryType) {
/* 32 */ switch (entryType) { case INFORMATION:
/* 33 */ return new Color(5355775);
/* 34 */ case ERROR: return new Color(16729156);
/* 35 */ case WARNING: return new Color(16772433);
default: return new Color(14935011);
}
/* */
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/debug/Entry.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,393 +0,0 @@
/* */
package org.ui.editors.code;
import org.renderer.PostProcessConfig;
import org.run.GyteCompiler;
import org.ui.UICreator;
import org.ui.debug.Console;
import org.world.World;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
import java.util.Formatter;
public class CodeEditor extends JFrame {
private static final long serialVersionUID = -5830316930709180479L;
private volatile boolean closeRequest;
private JSplitPane consoleSplitter;
private JPanel editorPane;
private JScrollPane scrollPane;
private JLineNumberTextPane lineNumbers;
private JPanel editorBase;
private JPanel controlPanel;
private JLabel programStatus;
private GraphicsConfig configs;
private JTextPane codeEditor;
private Console console;
private JButton run;
private JButton stop;
private JButton load;
private JButton save;
private JButton settings;
private JavaSyntaxHighlighter highligher;
private GyteCompiler compiler;
public CodeEditor(World world, PostProcessConfig postProcessConfig) {
setOpacity(1.0f);
setBackground(Color.BLACK);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.configs = new GraphicsConfig(postProcessConfig);
createUIComponents();
setupUIComponents();
createUIListener(world);
this.compiler = new GyteCompiler(world, this.console, this);
setTitle("RTX-GYTEBOT - Logic Editor");
getContentPane().add(this.consoleSplitter);
setSize(screenSize.width / 2, screenSize.height);
setLocation(screenSize.width / 2, 0);
setVisible(true);
this.consoleSplitter.setDividerLocation(0.7D);
}
private void createUIComponents() {
/* 120 */
this.codeEditor = new JTextPane();
/* 121 */
this.lineNumbers = new JLineNumberTextPane(this.codeEditor);
/* 122 */
this.highligher = new JavaSyntaxHighlighter(this.codeEditor, 16);
/* 123 */
this.console = new Console();
this.controlPanel = new JPanel(new FlowLayout(0, 6, 4));
/* 127 */
this.editorBase = new JPanel(new BorderLayout());
/* 128 */
this.consoleSplitter = new JSplitPane(0);
/* 129 */
this.editorPane = new JPanel(new BorderLayout());
this.run = UICreator.createIconifiedButton('e');
/* 133 */
this.run.setToolTipText("Compile and run the program.");
/* 134 */
this.stop = UICreator.createIconifiedButton('d');
/* 135 */
this.stop.setToolTipText("Kill the current running program");
/* 136 */
this.load = UICreator.createIconifiedButton('a');
/* 137 */
this.load.setToolTipText("Import an external file of code");
this.save = UICreator.createIconifiedButton('b');
this.save.setToolTipText("Save the current code to disk");
this.settings = UICreator.createIconifiedButton('i');
this.settings.setToolTipText("Open settings");
this.programStatus = new JLabel();
}
private void setupUIComponents() {
/* 152 */
this.editorBase.add(this.codeEditor, "Center");
/* 153 */
this.editorBase.add(this.lineNumbers, "West");
this.codeEditor.setText(getDefaultCode());
this.codeEditor.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 16));
this.highligher.updateSource();
this.lineNumbers.updateLineNumbers();
this.programStatus.setOpaque(true);
/* 167 */
this.programStatus.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY),
BorderFactory.createEmptyBorder(4, 8, 4, 16)));
this.programStatus.setText("Off");
this.consoleSplitter.setTopComponent(this.editorPane);
this.consoleSplitter.setBottomComponent((Component) this.console);
this.scrollPane = new JScrollPane(this.editorBase);
this.scrollPane.getVerticalScrollBar().setUnitIncrement(16);
this.editorPane.add(this.controlPanel, "North");
/* 183 */
this.editorPane.add(this.scrollPane, "Center");
this.controlPanel.add(Box.createHorizontalStrut(12));
/* 187 */
this.controlPanel.add(this.settings);
/* 188 */
this.controlPanel.add(Box.createHorizontalStrut(8));
/* 189 */
this.controlPanel.add(this.load);
/* 190 */
this.controlPanel.add(this.save);
/* 191 */
this.controlPanel.add(Box.createHorizontalStrut(8));
/* 192 */
this.controlPanel.add(this.run);
/* 193 */
this.controlPanel.add(this.stop);
/* 194 */
this.controlPanel.add(Box.createHorizontalStrut(8));
/* 195 */
this.controlPanel.add(this.programStatus);
}
private void createUIListener(World world) {
this.settings.addActionListener(e -> this.configs.open());
addWindowListener(new WindowAdapter()
/* */ {
/* */
/* */
public void windowClosing(WindowEvent event)
/* */ {
CodeEditor.this.closeRequest = true;
}
/* */
});
this.save.addActionListener(e -> {
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(1);
int value = chooser.showDialog(null, "Choose File to Save to");
if (value == 0) {
saveCodeToFile(chooser.getSelectedFile());
}
});
this.load.addActionListener(e -> {
JFileChooser chooser = new JFileChooser();
chooser.setDialogType(0);
int value = chooser.showDialog(null, "Choose File to Load");
if (value == 0) {
try {
BufferedReader reader = new BufferedReader(new FileReader(chooser.getSelectedFile()));
this.codeEditor.setText(reader.lines().reduce("", (a, b) -> a + b));
this.highligher.updateSource();
this.lineNumbers.updateLineNumbers();
reader.close();
} catch (Exception e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(null, "Unable to find/open/read selected file", "Error - loading file", 0);
}
}
});
/* */
/* 267 */
this.codeEditor.addKeyListener(new KeyAdapter()
/* */ {
/* */
/* */
/* */
public void keyReleased(KeyEvent event)
/* */ {
final int scrollValue = CodeEditor.this.scrollPane.getVerticalScrollBar().getValue();
CodeEditor.this.highligher.updateSource();
CodeEditor.this.lineNumbers.updateLineNumbers();
SwingUtilities.invokeLater(new Runnable()
/* */ {
/* */
public void run()
/* */ {
scrollPane.getVerticalScrollBar().setValue(scrollValue);
/* */
}
/* */
});
/* */
}
/* */
});
/* */
/* */
/* 290 */
this.stop.addActionListener(e -> {
/* */
if (this.compiler.getProcessor() != null) {
/* */
this.compiler.getProcessor().halt();
/* */
}
/* */
});
/* */
/* */
/* */
/* 298 */
this.run.addActionListener(e -> {
if (world.getGytebot() != null) {
SwingUtilities.invokeLater(() -> this.compiler.compileAndRunProgram(this.codeEditor.getText()));
} else {
JOptionPane.showMessageDialog(null, "No GYTEBOT is associated with the current code", "Exception - Headless processor", 0);
}
/* */
});
/* */
}
private void saveCodeToFile(File saveFile) {
/* */
try {
/* 319 */
Formatter formatter = new Formatter(saveFile);
/* */
/* 321 */
formatter.format("%s", new Object[]{this.codeEditor.getText()});
/* */
/* 323 */
formatter.close();
/* 324 */
} catch (FileNotFoundException e) {
/* */
/* 326 */
JOptionPane.showMessageDialog(null, "Could not save code to file: " + saveFile.toURI(), "Error - saving code", 0);
/* 327 */
e.printStackTrace();
/* */
}
/* */
}
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
public final void markLine(int lineNumber) {
/* */
try {
/* 339 */
String text = this.codeEditor.getStyledDocument().getText(0, this.codeEditor.getStyledDocument().getLength());
/* */
/* 341 */
int lineCounter = lineNumber - 1;
/* */
/* */
/* 344 */
int start = 0;
/* 345 */
int end = 0;
/* */
/* */
/* 348 */
for (int i = 0; i < text.length(); i++) {
/* 349 */
if (text.charAt(i) == '\n') {
/* */
/* */
/* 352 */
lineCounter--;
/* */
/* */
/* 355 */
if (lineCounter == 0) {
/* */
/* 357 */
start = i;
/* */
/* */
/* 360 */
for (int k = i + 1; k < text.length(); k++) {
/* 361 */
if (text.charAt(k) == '\n') {
/* */
/* 363 */
end = k;
/* */
/* */
break;
/* */
}
/* */
}
/* */
/* */
break;
/* */
}
/* */
}
/* */
}
/* */
/* 374 */
StyleContext sc = StyleContext.getDefaultStyleContext();
/* */
/* */
/* 377 */
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Background, new Color(16537688));
/* */
/* 379 */
this.codeEditor.getStyledDocument().setCharacterAttributes(start, end - start, aset, false);
/* 380 */
} catch (BadLocationException e) {
/* 381 */
e.printStackTrace();
/* */
}
/* */
}
public void setProgramStatus(boolean isRunning) {
/* 391 */
this.programStatus.setText(isRunning ? "Running..." : "Off");
/* 392 */
this.programStatus.setBackground(isRunning ? Color.GREEN : Color.LIGHT_GRAY);
/* */
}
private String getDefaultCode() {
/* */
try {
/* 403 */
return new String(getClass().getResourceAsStream("/data/defaultCode.java.example").readAllBytes());
/* 404 */
} catch (IOException e) {
/* 405 */
JOptionPane.showMessageDialog(null, "Unable to read or open default code template", "Error - loading default code template", 0);
/* */
/* 407 */
return null;
/* */
}
/* */
}
public boolean getWindowCloseRequest() {
/* 417 */
return this.closeRequest;
/* */
}
/* */
}

View File

@ -1,84 +0,0 @@
/* */
package org.ui.editors.code;
/* */
/* */
import org.renderer.PostProcessConfig;
import javax.swing.*;
import java.awt.*;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class GraphicsConfig
/* */ {
/* */ private Box base;
private JLabel title;
private JCheckBox dof;
private JCheckBox fxaa;
private JCheckBox grain;
private PostProcessConfig postProcessConfig;
public GraphicsConfig(PostProcessConfig postProcessConfig) {
this.postProcessConfig = postProcessConfig;
}
public final void open() {
this.base = Box.createVerticalBox();
this.title = new JLabel("Settings");
this.title.setFont(new Font("Dialog", 0, 24));
this.title.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
this.fxaa = new JCheckBox("Toggle Fast approXimate Anti Aliasing");
this.fxaa.setSelected(this.postProcessConfig.isFilterFXAA());
this.fxaa.addActionListener(e -> this.postProcessConfig.setFilterFXAA(this.fxaa.isSelected()));
this.dof = new JCheckBox("Toggle Depth of Field");
this.dof.setSelected(this.postProcessConfig.isFilterDoF());
this.dof.addActionListener(e -> this.postProcessConfig.setFilterDoF(this.dof.isSelected()));
this.grain = new JCheckBox("Toggle Film Grain");
this.grain.setSelected(this.postProcessConfig.isFilterGrain());
this.grain.addActionListener(e -> this.postProcessConfig.setFilterGrain(this.grain.isSelected()));
this.base.add(this.title);
this.base.add(this.fxaa);
this.base.add(this.grain);
this.base.add(this.dof);
JOptionPane.showConfirmDialog(null, this.base, "RTX-GYTEBOT - Settings", 0);
}
}

View File

@ -1,37 +0,0 @@
package org.ui.editors.code;
import javax.swing.*;
import javax.swing.text.Element;
import java.awt.*;
public class JLineNumberTextPane extends JTextArea {
private static final long serialVersionUID = -2596467098026617439L;
private JTextPane textPane;
public JLineNumberTextPane(JTextPane textPane) {
this.textPane = textPane;
setFont(new Font("Consolas", 0, 16));
setEditable(false);
setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, getBackground().darker()), BorderFactory.createEmptyBorder(0, 12, 0, 16)));
}
public final void updateLineNumbers() {
setText(getLineNumbersText());
}
private String getLineNumbersText() {
Integer caretPosition = Integer.valueOf(this.textPane.getDocument().getLength());
Element root = this.textPane.getDocument().getDefaultRootElement();
StringBuilder textBuilder = new StringBuilder();
textBuilder.append("1").append(System.lineSeparator());
for (int elementIndex = 2; elementIndex < root.getElementIndex(caretPosition.intValue()) + 2; elementIndex++) {
textBuilder.append(elementIndex).append(System.lineSeparator());
}
return textBuilder.toString();
}
}

View File

@ -1,50 +0,0 @@
package org.ui.editors.code;
import java.awt.Color;
import javax.swing.JTextPane;
import org.ui.syntaxes.CharAttrib;
import org.ui.syntaxes.SyntaxHighlighter;
public class JavaSyntaxHighlighter
extends SyntaxHighlighter
{
private static final String OPERATOR_REGEX = "[\\+\\-\\*/!&|\\^~.:?=]";
private static final String DELEMITER_REGEX = "[\\[\\]\\(\\)\\{\\},;]";
private static final String KEYWORD_REGEX = "\\W?(\\bextends|implements|this|super|import|package|public|private|throws|throw|protected|void|class|static|volatile|const|final|break|continue|while|for|do|switch|case|default|if|else\\b)\\W";
private static final String DATATYPES_REGEX = "\\W(\\bbyte|boolean|short|char|int|long|float|double\\b)\\W";
private static final String COMMENT_REGEX = "(/\\*(.)*?\\*/)|(//[^\\n]*)";
private static final String JAVADOC_REGEX = "(/\\*\\*(.)*?\\*/)";
private static final String ESC_SEQ_EXT_REGEX = "\\bTODO|@author|@version|@date|@serial|@apiNote|@see|@implNote|@since|@category|\\\\|\\n|\\t|\\?|\\'|\\\"|\\b|\\r|\\f\\b";
private static final String STRING_REGEX = "\".*?\"|'.?'";
private static Color RED = new Color(0xff604a);
private static Color ORANGE = new Color(0xFFA84A);
private static Color YELLOW = new Color(0xffe74a);
private static Color GREEN = new Color(0x8fff4a);
private static Color CYAN = new Color(0x4ae9ff);
private static Color BLUE = new Color(0x4a62ff);
public JavaSyntaxHighlighter(JTextPane textPane, int fontSize) {
super(textPane, 4.0F, fontSize, textPane.getBackground());
createHighlightPattern(OPERATOR_REGEX, new CharAttrib(false, false, RED));
createHighlightPattern(DELEMITER_REGEX, new CharAttrib(false, false, Color.LIGHT_GRAY));
createHighlightPattern(KEYWORD_REGEX, new CharAttrib(false, false, RED));
createHighlightPattern(DATATYPES_REGEX, new CharAttrib(false, false, RED));
createHighlightPattern(COMMENT_REGEX, new CharAttrib(false, true, Color.GRAY));
createHighlightPattern(JAVADOC_REGEX, new CharAttrib(false, false, CYAN));
createHighlightPattern(ESC_SEQ_EXT_REGEX, new CharAttrib(true, false, CYAN.darker()));
createHighlightPattern(STRING_REGEX, new CharAttrib(false, false, ORANGE));
}
public final void updateSource() {
highlight();
}
}

View File

@ -1,238 +0,0 @@
/* */ package org.ui.editors.map;
/* */
/* */ import java.awt.*;
/* */
/* */
/* */
/* */ import java.awt.event.ActionEvent;
/* */ import java.awt.event.KeyAdapter;
/* */ import java.awt.event.KeyEvent;
/* */ import java.awt.event.WindowAdapter;
/* */ import java.awt.event.WindowEvent;
/* */ import java.io.FileNotFoundException;
/* */ import java.util.Formatter;
/* */ import javax.swing.Box;
/* */ import javax.swing.JButton;
/* */ import javax.swing.JFileChooser;
/* */ import javax.swing.JFrame;
/* */ import javax.swing.JLabel;
/* */ import javax.swing.JOptionPane;
/* */ import javax.swing.JPanel;
/* */ import javax.swing.JScrollPane;
/* */ import javax.swing.JTextPane;
/* */ import org.ui.UICreator;
/* */ import org.world.World;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class MapEditor
/* */ extends JFrame
/* */ {
/* */ private static final long serialVersionUID = -6076124740248473039L;
/* */ private volatile boolean closeRequest;
/* */ private JPanel buttonPane;
/* */ private JButton updateWorld;
/* */ private JButton reset;
/* */ private JButton load;
/* */ private JButton save;
/* */ private JButton info;
/* */ private JLabel infoLabel;
/* */ private JTextPane preview;
/* */ private MapTextHighlighter highlighter;
/* */
/* */ public MapEditor(World world) {
setOpacity(1.0f);
setBackground(Color.BLACK);
/* 64 */ createUIComponents();
/* */
/* 66 */ setupUIComponents(world);
/* */
/* 68 */ createListener(world);
/* */
/* */
/* */
/* 72 */ this.buttonPane.add(Box.createHorizontalStrut(12));
/* 73 */ this.buttonPane.add(this.updateWorld);
/* 74 */ this.buttonPane.add(this.reset);
/* 75 */ this.buttonPane.add(Box.createHorizontalStrut(6));
/* 76 */ this.buttonPane.add(this.load);
/* 77 */ this.buttonPane.add(this.save);
/* 78 */ this.buttonPane.add(Box.createHorizontalStrut(6));
/* 79 */ this.buttonPane.add(this.infoLabel);
/* 80 */ this.buttonPane.add(this.info);
/* */
/* */
/* */
/* */
/* 85 */ Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
/* */
/* */
/* */
/* */
/* */
/* 91 */ getContentPane().setLayout(new BorderLayout());
/* 92 */ getContentPane().add(new JScrollPane(this.preview), "Center");
/* 93 */ getContentPane().add(this.buttonPane, "South");
/* */
/* */
/* 96 */ setTitle("RTX-GYTEBOT - Map Editor");
/* */
/* 98 */ setSize(size.width >> 1, size.height >> 1);
/* */
/* 100 */ setLocation(0, size.height >> 1);
/* */
/* 102 */ setVisible(true);
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void createListener(World world) {
/* 112 */ this.preview.addKeyListener(new KeyAdapter()
/* */ {
/* */ public final void keyReleased(KeyEvent event)
/* */ {
/* 116 */ MapEditor.this.highlighter.highlight();
/* */ }
/* */ });
/* */
/* */
/* 121 */ this.reset.addActionListener(e -> {
/* */ this.preview.setText(world.toString());
/* */
/* */
/* */ this.highlighter.highlight();
/* */ });
/* */
/* 128 */ this.updateWorld.addActionListener(e -> world.setDataString(this.preview.getText()));
/* */
/* */
/* 131 */ this.load.addActionListener(e -> {
/* */ JFileChooser chooser = new JFileChooser();
/* */
/* */
/* */ chooser.setDialogType(0);
/* */
/* */
/* */ int value = chooser.showDialog(null, "Choose File");
/* */
/* */ if (value == 0) {
/* */ world.setWorld(chooser.getSelectedFile().getAbsolutePath());
/* */ }
/* */
/* */ this.preview.setText(world.toString());
/* */
/* */ this.infoLabel.setText(String.format("Size: %d %d Coins: %d", new Object[] { Integer.valueOf(world.getWidth()), Integer.valueOf(world.getHeight()), Integer.valueOf(world.getCoinCount()) }));
/* */
/* */ this.highlighter.highlight();
/* */ });
/* */
/* 151 */ this.info.addActionListener(e -> {
/* */
/* */ });
/* 154 */ this.save.addActionListener(e -> {
/* */ JFileChooser chooser = new JFileChooser();
/* */
/* */
/* */ chooser.setDialogType(1);
/* */
/* */
/* */ int value = chooser.showDialog(null, "Choose File to save to");
/* */
/* */
/* */ if (value == 0) {
/* */ try {
/* */ Formatter formatter = new Formatter(chooser.getSelectedFile());
/* */
/* */
/* */ formatter.format("%s", new Object[] { world.toString() });
/* */
/* */
/* */ formatter.close();
/* 173 */ } catch (FileNotFoundException e1) {
/* */ String errorMessage = String.format("Could not save current map to file: %s", new Object[] { chooser.getSelectedFile().toURI() });
/* */
/* */ JOptionPane.showMessageDialog(null, errorMessage, "Error - saving map", 0);
/* */
/* */ e1.printStackTrace();
/* */ }
/* */ }
/* */ });
/* */
/* 183 */ addWindowListener(new WindowAdapter()
/* */ {
/* */ public void windowClosing(WindowEvent event)
/* */ {
/* 187 */ MapEditor.this.closeRequest = true;
/* */ }
/* */ });
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void setupUIComponents(World world) {
/* 198 */ this.preview.setText(world.toString());
/* */
/* 200 */ this.highlighter.highlight();
/* */ }
/* */
/* */
/* */
/* */
/* */ private void createUIComponents() {
/* 207 */ this.preview = new JTextPane();
/* 208 */ this.highlighter = new MapTextHighlighter(this.preview);
/* */
/* */
/* 211 */ this.buttonPane = new JPanel(new FlowLayout(0, 4, 2));
/* */
/* */
/* 214 */ this.updateWorld = UICreator.createIconifiedButton('g');
/* 215 */ this.reset = UICreator.createIconifiedButton('f');
/* 216 */ this.load = UICreator.createIconifiedButton('a');
/* 217 */ this.save = UICreator.createIconifiedButton('b');
/* 218 */ this.info = UICreator.createIconifiedButton('h');
/* */
/* 220 */ this.infoLabel = new JLabel();
/* */ }
/* */
/* */
/* */
/* */
/* */ public boolean getWindowCloseRequest() {
/* 227 */ return this.closeRequest;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/editors/map/MapEditor.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,94 +0,0 @@
/* */ package org.ui.editors.map;
/* */
/* */ import java.awt.Font;
/* */ import javax.swing.Box;
/* */ import javax.swing.JLabel;
/* */ import javax.swing.JOptionPane;
/* */ import org.world.World;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class MapInformation
/* */ {
/* */ private Box content;
/* */ private JLabel title;
/* */ private JLabel nameLabel;
/* */ private JLabel authorLabel;
/* */ private JLabel dateLabel;
/* */ private JLabel versionLabel;
/* */ private JLabel sizeLabel;
/* */ private JLabel coinsLabel;
/* */
/* */ public MapInformation(World world) {
/* 38 */ this.content = Box.createVerticalBox();
/* 39 */ this.content.setAlignmentX(0.0F);
/* */
/* */
/* 42 */ this.title = new JLabel("Map information");
/* 43 */ this.title.setFont(new Font("Verdana", 0, 12));
/* 44 */ this.title.setAlignmentX(0.0F);
/* */
/* */
/* */
/* */
/* 49 */ this.nameLabel = new JLabel("Map: " + world.getName());
/* */
/* 51 */ this.authorLabel = new JLabel("Author: " + world.getAuthor());
/* */
/* 53 */ this.dateLabel = new JLabel("Date: " + world.getDate());
/* */
/* 55 */ this.versionLabel = new JLabel("Version: " + world.getVersion());
/* */
/* 57 */ this.sizeLabel = new JLabel("Size: " + world.getWidth() + "x" + world.getHeight());
/* */
/* 59 */ this.coinsLabel = new JLabel("Coins(total) : " + world.getCoinCount());
/* */
/* */
/* */
/* 63 */ this.nameLabel.setAlignmentX(0.0F);
/* 64 */ this.authorLabel.setAlignmentX(0.0F);
/* 65 */ this.dateLabel.setAlignmentX(0.0F);
/* 66 */ this.versionLabel.setAlignmentX(0.0F);
/* */
/* */
/* */
/* 70 */ this.content.add(Box.createVerticalStrut(12));
/* 71 */ this.content.add(this.title);
/* 72 */ this.content.add(Box.createVerticalStrut(6));
/* 73 */ this.content.add(this.nameLabel);
/* 74 */ this.content.add(Box.createVerticalStrut(4));
/* 75 */ this.content.add(this.sizeLabel);
/* 76 */ this.content.add(Box.createVerticalStrut(6));
/* 77 */ this.content.add(this.coinsLabel);
/* 78 */ this.content.add(Box.createVerticalStrut(6));
/* 79 */ this.content.add(this.authorLabel);
/* 80 */ this.content.add(Box.createVerticalStrut(4));
/* 81 */ this.content.add(this.dateLabel);
/* 82 */ this.content.add(Box.createVerticalStrut(4));
/* 83 */ this.content.add(this.versionLabel);
/* */
/* */
/* 86 */ JOptionPane.showInternalConfirmDialog(null, this.content, "RTX-GYTEBOT - map information", 0);
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/editors/map/MapInformation.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,50 +0,0 @@
/* */ package org.ui.editors.map;
/* */
/* */ import java.awt.Color;
/* */ import javax.swing.JTextPane;
/* */ import org.ui.syntaxes.CharAttrib;
/* */ import org.ui.syntaxes.SyntaxHighlighter;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class MapTextHighlighter
/* */ extends SyntaxHighlighter
/* */ {
/* */ private static final String WALL_REGEX = "[#]";
/* */ private static final String BOT_REGEX = "[<^>vV]";
/* */ private static final String COIN_REGEX = "[€$]";
/* */ private static final String TAG_REGEX = "\\b|@date|@author|@version|@name\\b";
/* */ private static final String DATA_REGEX = "@[^\\n]*";
/* */ private static final String COMMENT_REGEX = "//[^\\n]*";
/* */
/* */ public MapTextHighlighter(JTextPane textPane) {
/* 28 */ super(textPane, 1.0F, 24);
/* */
/* */
/* */
/* 32 */ createHighlightPattern("[#]", new CharAttrib(false, false, Color.DARK_GRAY));
/* */
/* 34 */ createHighlightPattern("[<^>vV]", new CharAttrib(false, true, Color.RED));
/* */
/* 36 */ createHighlightPattern("[€$]", new CharAttrib(true, false, Color.ORANGE));
/* */
/* 38 */ createHighlightPattern("\\b|@date|@author|@version|@name\\b", new CharAttrib(true, false, Color.GRAY));
/* */
/* 40 */ createHighlightPattern("@[^\\n]*", new CharAttrib(true, false, Color.GRAY));
/* */
/* 42 */ createHighlightPattern("//[^\\n]*", new CharAttrib(true, false, Color.LIGHT_GRAY));
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/editors/map/MapTextHighlighter.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,40 +0,0 @@
/* */
package org.ui.icons;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
public class IconLoader {
public static final char LOAD_ICON_CODE_POINT = 'a';
public static final char SAVE_ICON_CODE_POINT = 'b';
public static final char CLEAR_ICON_CODE_POINT = 'c';
public static final char STOP_ICON_CODE_POINT = 'd';
public static final char RUN_ICON_CODE_POINT = 'e';
public static final char RESET_ICON_CODE_POINT = 'f';
public static final char APPLY_ICON_CODE_POINT = 'g';
public static final char INFO_ICON_CODE_POINT = 'h';
public static final char OPTIONS_ICON_CODE_POINT = 'i';
private static final String FONT_FILE_NAME = "data/icons/RTX-GYTEBOT-ICONS.ttf";
private static final String ICON_FILE_NAME = "data/icons/gytebotIcon.png";
public static final void loadIcons() throws AssertionError {
try {
Font iconFont = Font.createFont(0, (IconLoader.class.getClassLoader().getResourceAsStream(FONT_FILE_NAME)));
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(iconFont);
} catch (FontFormatException e) {
throw new AssertionError("Unable to register icon font");
} catch (Exception e) {
throw new AssertionError("Unable to find or load icon font file:" + FONT_FILE_NAME);
}
}
public static final BufferedImage loadWindowIcon() throws AssertionError {
try {
return ImageIO.read(IconLoader.class.getClassLoader().getResourceAsStream(ICON_FILE_NAME));
} catch (Exception e) {
throw new AssertionError("Unable to find or load image file:" + ICON_FILE_NAME);
}
}
}

View File

@ -1,98 +0,0 @@
/* */ package org.ui.syntaxes;
/* */
/* */ import java.awt.Color;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class CharAttrib
/* */ {
/* */ private boolean bold;
/* */ private boolean italic;
/* */ private Color color;
/* */ private Color backgroundColor;
/* */
/* */ public CharAttrib(boolean bold, boolean italic, Color color) {
/* 31 */ this.bold = bold;
/* 32 */ this.italic = italic;
/* 33 */ this.color = color;
/* 34 */ this.backgroundColor = Color.WHITE;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final boolean isBold() {
/* 41 */ return this.bold;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final void setBold(boolean bold) {
/* 48 */ this.bold = bold;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final boolean isItalic() {
/* 55 */ return this.italic;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final void setItalic(boolean italic) {
/* 62 */ this.italic = italic;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final Color getColor() {
/* 69 */ return this.color;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final void setColor(Color color) {
/* 76 */ this.color = color;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final Color getBackgroundColor() {
/* 83 */ return this.backgroundColor;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final void setBackgroundColor(Color backgroundColor) {
/* 90 */ this.backgroundColor = backgroundColor;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/syntaxes/CharAttrib.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,52 +0,0 @@
/* */ package org.ui.syntaxes;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Pair<A, B>
/* */ {
/* */ private A a;
/* */ private B b;
/* */
/* */ public Pair(A a, B b) {
/* 29 */ this.a = a;
/* 30 */ this.b = b;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final A getA() {
/* 37 */ return this.a;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final B getB() {
/* 44 */ return this.b;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/ui/syntaxes/Pair.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,104 +0,0 @@
package org.ui.syntaxes;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SyntaxHighlighter {
private final CharAttrib defaultCharAttribs;
protected JTextPane textPane;
protected TabSet tabset;
private final List<Pair<String, CharAttrib>> elements;
private int selectionStart;
private int selectionLength;
private final int fontSize;
public SyntaxHighlighter(JTextPane textPane, float tabSize, int fontSize) {
this.textPane = textPane;
this.fontSize = fontSize;
this.elements = new ArrayList<>();
this.defaultCharAttribs = new CharAttrib(false, false, textPane.getForeground());
createTabset(tabSize);
}
public SyntaxHighlighter(JTextPane textPane, float tabSize, int fontSize, Color backgroundColor) {
this.textPane = textPane;
this.fontSize = fontSize;
this.elements = new ArrayList<>();
this.defaultCharAttribs = new CharAttrib(false, false, textPane.getForeground());
this.defaultCharAttribs.setBackgroundColor(backgroundColor);
createTabset(tabSize);
}
protected void createHighlightPattern(String regex, CharAttrib attribs) {
this.elements.add(new Pair<>(regex, attribs));
}
private void createTabset(float tabSize) {
TabStop[] tabs = new TabStop[8];
for (int i = 0; i < tabs.length; i++) {
tabs[i] = new TabStop(tabSize * i + tabSize, 0, 0);
}
this.tabset = new TabSet(tabs);
}
public final void highlight() {
this.selectionStart = 0;
this.selectionLength = this.textPane.getDocument().getLength();
createHighlight(this.defaultCharAttribs);
try {
for (Pair<String, CharAttrib> entry : this.elements) {
Matcher matcher = Pattern.compile(entry.getA(), Pattern.MULTILINE | Pattern.DOTALL).matcher(
this.textPane.getDocument().getText(0, this.textPane.getDocument().getLength()));
while (matcher.find()) {
this.selectionStart = matcher.start();
this.selectionLength = matcher.end() - this.selectionStart;
createHighlight(entry.getB());
}
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
private void createHighlight(CharAttrib attribs) {
StyleContext sc = StyleContext.getDefaultStyleContext();
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Background, this.defaultCharAttribs.getBackgroundColor());
aset = sc.addAttribute(aset, StyleConstants.FontFamily, new Font("Monospaced", Font.PLAIN, 16).getFamily());
aset = sc.addAttribute(aset, StyleConstants.FontSize, this.fontSize);
aset = sc.addAttribute(aset, StyleConstants.Bold, attribs.isBold());
aset = sc.addAttribute(aset, StyleConstants.Italic, attribs.isItalic());
aset = sc.addAttribute(aset, StyleConstants.TabSet, this.tabset);
if (attribs.getColor() == null) {
Color foregroundColor = (Color) this.textPane.getStyledDocument()
.getCharacterElement(this.selectionStart).getAttributes()
.getAttribute(StyleConstants.Foreground);
aset = sc.addAttribute(aset, StyleConstants.Foreground, foregroundColor.darker());
} else {
aset = sc.addAttribute(aset, StyleConstants.Foreground, attribs.getColor());
}
this.textPane.getStyledDocument().setCharacterAttributes(this.selectionStart, this.selectionLength, aset, false);
}
}

View File

@ -1,159 +0,0 @@
/* */ package org.view;
/* */
/* */ import org.lwjgl.glfw.GLFW;
/* */ import org.lwjgl.glfw.GLFWCursorPosCallback;
/* */ import org.lwjgl.glfw.GLFWCursorPosCallbackI;
/* */ import org.lwjgl.glfw.GLFWMouseButtonCallback;
/* */ import org.lwjgl.glfw.GLFWMouseButtonCallbackI;
/* */ import org.lwjgl.glfw.GLFWScrollCallback;
/* */ import org.lwjgl.glfw.GLFWScrollCallbackI;
/* */ import org.lwjgl.glfw.GLFWVidMode;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class Camera
/* */ implements AutoCloseable
/* */ {
/* */ private static final float MIN_CAMERA_ZOOM = -8.0F;
/* */ private static final float MAX_CAMERA_ZOOM = -0.5F;
/* */ private static final float MAX_CAMERA_ROT_Y = -1.5707964F;
/* */ private static final float MIN_CAMERA_ROT_Y = -3.1415927F;
/* */ private GLFWCursorPosCallback cursorPosCallback;
/* */ private GLFWMouseButtonCallback mouseButtonCallback;
/* */ private GLFWScrollCallback scrollCallback;
/* */ private boolean isMouseButton1Down;
/* 37 */ private float cameraZoom = -0.5F;
/* */
/* 39 */ private float cameraRotationX = 1.3F;
/* 40 */ private float cameraRotationY = -2.3F;
/* */
/* */
/* */ private float deltaRotationX;
/* */
/* */
/* */ private float deltaRotationY;
/* */
/* */
/* */ private float cameraRotationVelocityX;
/* */
/* */ private float cameraRotationVelocityY;
/* */
/* */ private float cameraZoomVelocity;
/* */
/* */
/* */ public Camera(long windowHandle) {
/* 57 */ GLFW.glfwSetMouseButtonCallback(windowHandle, (GLFWMouseButtonCallbackI)(this.mouseButtonCallback = new GLFWMouseButtonCallback()
/* */ {
/* */
/* */ public void invoke(long arg0, int arg1, int arg2, int arg3)
/* */ {
/* 62 */ Camera.this.isMouseButton1Down = ((arg1 == 0)) ^ ((arg2 == 0));
/* */ }
/* */ }));
/* */
/* */
/* 67 */ GLFW.glfwSetScrollCallback(windowHandle, (GLFWScrollCallbackI)(this.scrollCallback = new GLFWScrollCallback()
/* */ {
/* */ public void invoke(long window, double dx, double dy)
/* */ {
/* 71 */ Camera.this.cameraZoomVelocity = (float)(Camera.this.cameraZoomVelocity + dy * 0.019999999552965164D);
/* */ }
/* */ }));
/* */
/* */
/* 76 */ GLFW.glfwSetCursorPosCallback(windowHandle, (GLFWCursorPosCallbackI)(this.cursorPosCallback = new GLFWCursorPosCallback()
/* */ {
/* */
/* */ public void invoke(long window, double cursorX, double cursorY)
/* */ {
/* 81 */ GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
/* */
/* 83 */ float rotationDifferenceX = (float)(cursorX / vidmode.width());
/* 84 */ float rotationDifferenceY = (float)(cursorY / vidmode.height());
/* */
/* */
/* 87 */ if (Camera.this.isMouseButton1Down) {
/* */
/* */
/* 90 */ Camera.this.cameraRotationVelocityX = (Camera.this.deltaRotationX - rotationDifferenceX) * 2.0F;
/* */
/* 92 */ Camera.this.cameraRotationVelocityY = (Camera.this.deltaRotationY - rotationDifferenceY) * 1.8F;
/* */ }
/* */
/* 95 */ Camera.this.deltaRotationX = rotationDifferenceX;
/* 96 */ Camera.this.deltaRotationY = rotationDifferenceY;
/* */ }
/* */ }));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public void update(float elapsedTime) {
/* 108 */ float timeStep = elapsedTime * 100.0F;
/* */
/* */
/* */
/* */
/* 113 */ this.cameraRotationY = Math.min(Math.max(this.cameraRotationY + this.cameraRotationVelocityY * timeStep, -3.1415927F), -1.5707964F);
/* 114 */ this.cameraRotationX += this.cameraRotationVelocityX * timeStep;
/* */
/* */
/* 117 */ this.cameraRotationVelocityX += -this.cameraRotationVelocityX * 0.08F * timeStep;
/* 118 */ this.cameraRotationVelocityY += -this.cameraRotationVelocityY * 0.05F * timeStep;
/* */
/* */
/* 121 */ this.cameraZoom = Math.max(Math.min(this.cameraZoom + this.cameraZoomVelocity, -0.5F), -8.0F);
/* */
/* 123 */ this.cameraZoomVelocity += -this.cameraZoomVelocity * 0.04F * timeStep * Math.abs(2.0F / this.cameraZoom);
/* */ }
/* */
/* */
/* */ public final void close() {
/* 128 */ this.cursorPosCallback.free();
/* 129 */ this.mouseButtonCallback.free();
/* 130 */ this.scrollCallback.free();
/* */ }
/* */
/* */
/* */
/* */
/* */ public final float getCameraZoom() {
/* 137 */ return this.cameraZoom;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final float getCameraRotationX() {
/* 144 */ return this.cameraRotationX;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final float getCameraRotationY() {
/* 151 */ return this.cameraRotationY;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/view/Camera.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,603 +0,0 @@
/* */ package org.world;
/* */
/* */ import java.awt.Point;
/* */ import java.awt.geom.Point2D;
/* */ import java.io.BufferedReader;
/* */ import java.io.File;
/* */ import java.io.FileReader;
/* */ import java.io.IOException;
/* */ import java.io.InputStreamReader;
/* */ import java.util.Arrays;
/* */ import java.util.LinkedList;
/* */ import java.util.List;
/* */ import javax.swing.JOptionPane;
/* */ import org.bot.Direction;
/* */ import org.bot.Gytebot;
/* */ import org.objects.Coin;
/* */ import org.objects.Wall;
/* */ import org.objects.WorldObject;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class World
/* */ {
/* */ public static final int MAP_SIZE = 32;
/* */ private List<String> rawMapData;
/* */ private int rawDataWidth;
/* */ private int coinCount;
/* */ private String author;
/* */ private String version;
/* */ private String name;
/* */ private String date;
/* */ private String mapPath;
/* */ private volatile WorldObject[][] objects;
/* */ private volatile Gytebot gytebot;
/* */ private boolean updateCoinBuffer;
/* */ private int[] coinBufferData;
/* */ private boolean updateWallBufferData;
/* */ private float[] wallBufferData;
/* */
/* */ public World() {
/* 71 */ this.rawMapData = new LinkedList<>();
/* */
/* 73 */ this.coinBufferData = new int[1024];
/* 74 */ this.wallBufferData = new float[1024];
/* */
/* */
/* 77 */ setWorld("/data/standardlevel.map");
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void setWorld(String fileName) {
/* 88 */ BufferedReader reader = null;
/* */
/* */
/* */
/* */ try {
/* 93 */ reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(fileName)));
/* 94 */ } catch (Exception e1) {
/* */
/* */ try {
/* 97 */ reader = new BufferedReader(new FileReader(new File(fileName)));
/* 98 */ } catch (Exception e2) {
/* */
/* 100 */ JOptionPane.showMessageDialog(null, "Unable to open Map: " + fileName, "Error - opening map", 0);
/* */ }
/* */ }
/* */
/* 104 */ if (reader != null) {
/* */
/* */ try {
/* */
/* */
/* */
/* 110 */ this.gytebot = null;
/* 111 */ this.rawDataWidth = 0;
/* 112 */ this.rawMapData.clear();
/* */
/* */
/* */ try {
/* 116 */ reader.lines().forEachOrdered(line -> parseLine(line));
/* */
/* */
/* 119 */ if (this.rawDataWidth > 0 && this.rawMapData.size() > 0) {
/* */
/* */
/* */
/* 123 */ this.objects = new WorldObject[this.rawDataWidth][this.rawMapData.size()];
/* */
/* 125 */ createWorldData();
/* */
/* 127 */ updateTransferBuffers();
/* */
/* 129 */ this.mapPath = fileName;
/* */
/* */ }
/* */ else {
/* */
/* 134 */ setWorld(this.mapPath);
/* */
/* 136 */ JOptionPane.showMessageDialog(null, "Unable to open Map: " + fileName, "Error - opening map", 0);
/* */ }
/* 138 */ } catch (Error e) {
/* */
/* 140 */ setWorld(this.mapPath);
/* */
/* 142 */ JOptionPane.showMessageDialog(null, "Unable to open Map: " + fileName, "Error - opening map", 0);
/* */ } finally {
/* */
/* 145 */ reader.close();
/* */ }
/* 147 */ } catch (IOException e) {
/* 148 */ e.printStackTrace();
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void setDataString(String data) {
/* 161 */ this.gytebot = null;
/* 162 */ this.rawDataWidth = 0;
/* 163 */ this.rawMapData.clear();
/* */
/* */
/* */ try {
/* 167 */ Arrays.<String>asList(data.split("(?=\\n)")).forEach(line -> parseLine(line));
/* */
/* */
/* 170 */ if (this.rawDataWidth > 0 && this.rawMapData.size() > 0) {
/* */
/* */
/* 173 */ this.objects = new WorldObject[this.rawDataWidth][this.rawMapData.size()];
/* */
/* 175 */ createWorldData();
/* */
/* 177 */ updateTransferBuffers();
/* */
/* */ }
/* */ else {
/* */
/* */
/* 183 */ setWorld(this.mapPath);
/* 184 */ JOptionPane.showMessageDialog(null, "The map was not properly loaded", "Error - converting map", 0);
/* */ }
/* 186 */ } catch (Error e) {
/* */
/* 188 */ setWorld(this.mapPath);
/* 189 */ JOptionPane.showMessageDialog(null, "Unable to convert Map: " + e.getMessage(), "Error - converting map", 0);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void parseLine(String line) throws Error {
/* 201 */ String trimed = line.trim();
/* */
/* */
/* 204 */ if (trimed.length() != 0) {
/* */
/* */
/* 207 */ String[] splitted = trimed.split("[/](?=/)|(?=[@])");
/* */
/* 209 */ String rawMapLine = new String(); byte b;
/* */ int i;
/* */ String[] arrayOfString1;
/* 212 */ for (i = (arrayOfString1 = splitted).length, b = 0; b < i; ) { String content = arrayOfString1[b];
/* */
/* 214 */ if (content.startsWith("/")) {
/* */ break;
/* */ }
/* */
/* */
/* 219 */ if (content.startsWith("@")) {
/* */
/* */
/* 222 */ String[] tag = content.split("\\s+");
/* */
/* */
/* 225 */ if (tag.length > 2)
/* */ {
/* */
/* 228 */ throw new AssertionError("To many arguments provided for tag: " + content);
/* */ }
/* */
/* */
/* */ String str;
/* */
/* 234 */ switch ((str = tag[0]).hashCode()) { case -440667701: if (str.equals("@author")) {
/* 235 */ this.author = tag[1]; break;
/* */ }
/* */ case 62181358:
/* 238 */ if (str.equals("@date")) { this.date = tag[1]; break; } case 62479051: if (str.equals("@name")) { this.name = tag[1]; break; } case 222319768: if (str.equals("@version")) { this.version = tag[1]; break; }
/* 239 */ default: throw new AssertionError("Unknown tag found: " + tag[0]); }
/* */
/* */
/* */
/* */ } else {
/* 244 */ rawMapLine = String.valueOf(rawMapLine) + content;
/* */ } b++; }
/* */
/* 247 */ if (rawMapLine.length() > 0) {
/* 248 */ this.rawMapData.add(rawMapLine);
/* */ }
/* */
/* 251 */ this.rawDataWidth = Math.max(this.rawDataWidth, rawMapLine.length());
/* */
/* */
/* 254 */ if (this.rawDataWidth > 32)
/* */ {
/* 256 */ throw new AssertionError("Map size exceeds valid map bounds of 32x32! It is to wide");
/* */ }
/* 258 */ if (this.rawMapData.size() > 32)
/* */ {
/* 260 */ throw new AssertionError("Map size exceeds valid map bounds of 32x32! It is to large");
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void createWorldData() {
/* 272 */ this.coinCount = 0;
/* */
/* */
/* 275 */ for (int y = 0; y < this.rawMapData.size(); y++) {
/* */
/* 277 */ for (int x = 0; x < ((String)this.rawMapData.get(y)).length(); x++) {
/* */
/* 279 */ char current = ((String)this.rawMapData.get(y)).charAt(x);
/* */
/* 281 */ if (current == '#') {
/* */
/* */
/* 284 */ this.objects[x][y] = (WorldObject)new Wall(new Point2D.Float(x, y));
/* */ }
/* 286 */ else if (current == '€' || current == '$') {
/* */
/* */
/* 289 */ this.objects[x][y] = (WorldObject)new Coin(new Point2D.Float(x, y));
/* */
/* 291 */ this.coinCount++;
/* */ }
/* 293 */ else if (current == '^' || current == '>' || current == 'v' || current == 'V' || current == '<') {
/* */
/* */
/* 296 */ if (this.gytebot != null) {
/* */
/* 298 */ System.err.println("Conflicting world rule: There is already a gytebot!");
/* 299 */ JOptionPane.showMessageDialog(null, "Conflicting world rule: There is already a gytebot", "Error - converting map", 0);
/* */
/* */
/* */
/* */
/* */ }
/* 305 */ else if (x < ((String)this.rawMapData.get(0)).length() && y < this.rawMapData.size()) {
/* */
/* 307 */ this.gytebot = new Gytebot(new Point2D.Float(x, y), Direction.directionFromCodePoint(current));
/* */ } else {
/* */
/* 310 */ this.gytebot = null;
/* 311 */ JOptionPane.showMessageDialog(null, "Gytebot is placed outside Map", "Error - converting map", 0);
/* */ }
/* */
/* */ }
/* 315 */ else if (current != ' ') {
/* */
/* */
/* 318 */ System.err.println("Unkown map entity: " + current);
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void updateTransferBuffers() {
/* 332 */ Arrays.fill(this.coinBufferData, 0);
/* 333 */ Arrays.fill(this.wallBufferData, 0.0F);
/* */
/* */
/* 336 */ for (int y = 0; y < (this.objects[0]).length; y++) {
/* 337 */ for (int x = 0; x < this.objects.length; x++) {
/* */
/* 339 */ if (this.objects[x][y] instanceof Coin) {
/* */
/* */
/* 342 */ this.coinBufferData[x + y * this.objects.length] = 1;
/* */ }
/* 344 */ else if (this.objects[x][y] instanceof Wall) {
/* */
/* */
/* 347 */ this.wallBufferData[x + y * 32] = 1.0F;
/* */ }
/* */ }
/* */ }
/* */
/* 352 */ this.updateCoinBuffer = true;
/* 353 */ this.updateWallBufferData = true;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void setWall(int x, int y) {
/* 364 */ setObject(x, y, (WorldObject)new Wall(new Point2D.Float(x, y)));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void setCoin(int x, int y) {
/* 375 */ setObject(x, y, (WorldObject)new Coin(new Point2D.Float(x, y)));
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final void removeObject(int x, int y) {
/* 385 */ if (this.objects[x][y] != null) {
/* */
/* */
/* 388 */ this.objects[x][y] = null;
/* */
/* 390 */ updateTransferBuffers();
/* */
/* */ }
/* */ else {
/* */
/* 395 */ JOptionPane.showMessageDialog(null, "Index to remove object from is already empty", "Exception", 0);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ private void setObject(int x, int y, WorldObject object) {
/* 410 */ if (x >= 0 && x < this.objects.length && y >= 0 && y < (this.objects[0]).length) {
/* */
/* */
/* 413 */ this.objects[x][y] = object;
/* */
/* 415 */ updateTransferBuffers();
/* */ }
/* */ else {
/* */
/* 419 */ JOptionPane.showMessageDialog(null, "The requested object placement occured outside of valid bounds!", "Exception", 0);
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public boolean isLocationObstructed(Point point) {
/* 432 */ if (point.x < 0 || point.y < 0 || point.x >= getWidth() || point.y >= getHeight())
/* */ {
/* 434 */ return true;
/* */ }
/* 436 */ if (this.objects[point.x][point.y] instanceof Wall)
/* */ {
/* 438 */ return true;
/* */ }
/* */
/* */
/* */
/* 443 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public boolean isCoinPlacedHere(Point2D.Float location) {
/* 455 */ if (location.x < 0.0F || location.y < 0.0F || location.x >= getWidth() || location.y >= getHeight())
/* */ {
/* 457 */ return false;
/* */ }
/* 459 */ if (this.objects[Math.round(location.x)][Math.round(location.y)] instanceof Coin)
/* */ {
/* 461 */ return true;
/* */ }
/* */
/* */
/* */
/* 466 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public final String toString() {
/* 476 */ return this.rawMapData.stream().reduce("", (A, B) -> String.valueOf(A) + B + System.lineSeparator());
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public boolean updateWallBufferData() {
/* 486 */ if (this.updateWallBufferData) {
/* */
/* 488 */ this.updateWallBufferData = false;
/* 489 */ return true;
/* */ }
/* */
/* */
/* 493 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public boolean updateCoinTextureData() {
/* 504 */ if (this.updateCoinBuffer) {
/* */
/* 506 */ this.updateCoinBuffer = false;
/* 507 */ return true;
/* */ }
/* */
/* 510 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ public final int getCoinCount() {
/* 518 */ return this.coinCount;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final String getAuthor() {
/* 525 */ return this.author;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final String getVersion() {
/* 532 */ return this.version;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final String getName() {
/* 539 */ return this.name;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final String getDate() {
/* 546 */ return this.date;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final synchronized Gytebot getGytebot() {
/* 553 */ return this.gytebot;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final int[] getCoinBufferData() {
/* 560 */ return this.coinBufferData;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final int getWidth() {
/* 567 */ return this.objects.length;
/* */ }
/* */
/* */
/* */
/* */
/* */ public final int getHeight() {
/* 574 */ return (this.objects[0]).length;
/* */ }
/* */
/* */
/* */
/* */
/* */ public int getDrawGytebotAsInt() {
/* 581 */ return (this.gytebot == null) ? 0 : 1;
/* */ }
/* */
/* */
/* */
/* */
/* */ public int[] getCoinTextureData() {
/* 588 */ return this.coinBufferData;
/* */ }
/* */
/* */
/* */
/* */
/* */ public float[] getWallBufferData() {
/* 595 */ return this.wallBufferData;
/* */ }
/* */ }
/* Location: /home/teridax/Projects/Gytebot/GYTEBOT.jar!/org/world/World.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,29 @@
package raytracing;
import optics.light.Color;
import shading.Material;
public class BasicMaterial implements Material {
private Color diffuse;
private double glossieness;
private Color reflectionTint;
public BasicMaterial(Color diffuse, double glossieness, Color reflectionTint) {
this.diffuse = diffuse;
this.glossieness = glossieness;
this.reflectionTint = reflectionTint;
}
public Color getDiffuse() {
return diffuse;
}
public double getGlossieness() {
return glossieness;
}
public Color getReflectionTint() {
return reflectionTint;
}
}

View File

@ -0,0 +1,92 @@
package raytracing;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
import geometry.scene.Hit;
import geometry.scene.Scene;
import optics.light.Color;
import optics.light.LightSource;
import optics.view.Camera;
import optics.view.PinholeCamera;
import renderer.Renderer;
import java.util.Optional;
public class Raytracer implements Renderer {
private Camera camera = new PinholeCamera(new Vector(0,0,-4), Vector.origin(), 90, 1e-3, 1e3);
private Scene scene = Scene.generateExampleScene();
private double traceShadow(Vector point, Vector sun) {
Ray shadowRay = new Ray(point, sun, 1e-3, 1e3);
Optional<Hit> result = scene.intersect(shadowRay);
if (result.isEmpty()) {
return 1.0;
}
return 0.0;
}
private Color traceDirect(Ray directRay, int depth) {
if (depth == 4) {
return Color.BLACK;
}
Optional<Hit> result = scene.intersect(directRay);
if (result.isEmpty()) {
// Background color
return Color.BLACK;
}
Vector intersection = directRay.travel(result.get().getDistance());
Vector normal = result.get().getMesh().normalAt(intersection);
BasicMaterial material = (BasicMaterial) result.get().getMesh().getMaterial();
// indirect light sum
Color incoming = new Color(0,0,0);
for (LightSource light : scene.getLights()) {
double directInfluence = castShadow(light, intersection, normal);
Color directLight = material.getDiffuse().scale(directInfluence).mul(light.getColor());
Color reflectedLight = reflectedLight(directRay, material, normal, intersection, depth);
incoming = incoming.add(directLight);
}
return incoming;
}
private Color reflectedLight(Ray incomingRay, BasicMaterial material, Vector normal, Vector point, int depth) {
Vector reflected = incomingRay.getDirection().reflect(normal);
Color reflectedLight = traceDirect(new Ray(point, reflected, 1e-3, 1e3), depth + 1);
double highlightFactor = reflected.dot(normal);
return reflectedLight.add(new Color(highlightFactor)).mul(material.getReflectionTint());
}
private double castShadow(LightSource target, Vector point, Vector surfaceNormal) {
Vector lightDirection = target.getDirection(point);
double shadow = traceShadow(point, lightDirection);
return Math.max(surfaceNormal.dot(lightDirection), 0.0) * shadow;
}
@Override
public Color traceCameraRay(double u, double v) {
Ray viewRay = camera.generateViewRay(u, v);
return traceDirect(viewRay, 0);
}
@Override
public Camera getCamera() {
return camera;
}
}

View File

@ -0,0 +1,132 @@
package renderer;
import optics.light.Color;
import optics.view.PlayerController;
import renderer.canvas.RenderTarget;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Display {
private JFrame window;
private RenderTarget target;
private Resolution resolution;
private volatile boolean close;
private volatile boolean resized;
private int sampleCount;
private long frametime;
public Display(Resolution resolution, PlayerController controller) {
this.resolution = resolution;
this.window = new JFrame("JPath - CPU - Pathtracer");
this.window.setMinimumSize(new Dimension(320, 320));
this.window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.window.setSize(resolution.getWidth(), resolution.getHeight());
this.window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
close = true;
}
});
this.window.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
super.componentResized(e);
resized = true;
}
});
this.window.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
super.keyPressed(e);
controller.motionKeyControl(e);
}
});
this.window.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseDragged(MouseEvent e) {
super.mouseDragged(e);
controller.motionMouseControl(e);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
controller.mouseReleased();
}
});
this.target = new RenderTarget(resolution);
}
public void start(Renderer renderer, PlayerController controller) {
var program = new FragmentProgram() {
@Override
public Color fragment(double u, double v) {
return renderer.traceCameraRay(u, v);
}
};
this.window.setContentPane(target);
this.window.setLocationRelativeTo(null);
this.window.setVisible(true);
try (Scheduler scheduler = Scheduler.getInstance()) {
var tasks = scheduler.generateTasks(this.target, program);
while (!this.close) {
this.frametime = System.currentTimeMillis();
if (resized) {
this.resolution.setSize(window.getSize());
// Window has been resized, rebuild drawing buffer
this.target.buildBuffer(this.resolution);
// rebuild rendering tasks
tasks = scheduler.generateTasks(this.target, program);
this.target.getBuffer().clear();
this.sampleCount = 0;
this.resized = false;
}
if (controller.changed()) {
this.target.getBuffer().clear();
controller.apply(renderer);
}
scheduler.schedule(tasks);
this.sampleCount ++;
target.refresh();
SwingUtilities.invokeLater(target::repaint);
this.frametime = System.currentTimeMillis() - this.frametime;
updateOverlay();
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void updateOverlay() {
var overlay = target.getOverlay();
overlay.setTargetDimension(resolution);
overlay.setTileDimensions(resolution.getScaledWidth() / Scheduler.THREADS_PER_SIDE, resolution.getScaledHeight() / Scheduler.THREADS_PER_SIDE);
overlay.setThreads();
overlay.setFrametime(this.frametime);
overlay.setSamples(sampleCount);
}
}

View File

@ -0,0 +1,8 @@
package renderer;
import optics.light.Color;
public interface FragmentProgram {
Color fragment(double u, double v);
}

View File

@ -0,0 +1,11 @@
package renderer;
import optics.light.Color;
import optics.view.Camera;
public interface Renderer {
Color traceCameraRay(double u, double v);
Camera getCamera();
}

View File

@ -0,0 +1,41 @@
package renderer;
import java.awt.*;
public class Resolution {
private int width;
private int height;
private int downScale;
public Resolution(int width, int height, int downScale) {
this.width = width;
this.height = height;
this.downScale = downScale;
}
public int getScaledWidth() {
return width / downScale;
}
public int getScaledHeight() {
return height / downScale;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public int getDownScale() {
return downScale;
}
public void setSize(Dimension size) {
this.width = size.width;
this.height = size.height;
}
}

View File

@ -0,0 +1,62 @@
package renderer;
import basics.math.algebra.Utils;
import renderer.canvas.ContributionBuffer;
import renderer.canvas.RenderTarget;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Scheduler implements AutoCloseable {
public static final int THREADS_PER_SIDE = Utils.roundDownToSquareNumber(Runtime.getRuntime().availableProcessors());
private static final Scheduler INSTANCE = new Scheduler();
private ExecutorService executorService = Executors.newCachedThreadPool();
private Scheduler() {
}
public static Scheduler getInstance() {
return INSTANCE;
}
public void schedule(ArrayList<TileProcessor> worker) throws InterruptedException {
executorService.invokeAll(worker);
}
public ArrayList<TileProcessor> generateTasks(RenderTarget target, FragmentProgram program) {
ContributionBuffer buffer = target.getBuffer();
int totalThreads = THREADS_PER_SIDE * THREADS_PER_SIDE;
int tileWidth = buffer.getWidth() / THREADS_PER_SIDE;
int tileHeight = buffer.getHeight() / THREADS_PER_SIDE;
ArrayList processors = new ArrayList(totalThreads);
for (int x = 0; x < THREADS_PER_SIDE; x++) {
int x0 = x * tileWidth;
for (int y = 0; y < THREADS_PER_SIDE; y++) {
int y0 = y * tileHeight;
TileProcessor processor = new TileProcessor(buffer,
x0, y0,
x0 + tileWidth, y0 + tileHeight,
buffer.getWidth(), buffer.getHeight(),
program);
processors.add(processor);
}
}
return processors;
}
@Override
public void close() {
executorService.close();
}
}

View File

@ -0,0 +1,47 @@
package renderer;
import basics.math.algebra.Vector;
import renderer.canvas.ContributionBuffer;
import java.util.concurrent.Callable;
public class TileProcessor implements Callable<Void> {
private final ContributionBuffer buffer;
private FragmentProgram program;
private int width;
private int height;
private int x0;
private int y0;
private int x1;
private int y1;
public TileProcessor(ContributionBuffer buffer, int x0, int y0, int x1, int y1, int width, int height, FragmentProgram program) {
this.buffer = buffer;
this.width = width;
this.height = height;
this.x0 = x0;
this.y0 = y0;
this.x1 = x1;
this.y1 = y1;
this.program = program;
}
@Override
public Void call() throws Exception {
for (int x = this.x0; x < x1; x++) {
double u = (x + Math.random()) / (double) this.width * 2.0 - 1.0;
for (int y = this.y0; y < y1; y++) {
double v = (y + Math.random()) / (double) this.height * 2.0 - 1.0;
this.buffer.contribute(x, y, this.program.fragment(u, v));
}
}
return null;
}
}

View File

@ -0,0 +1,82 @@
package renderer.canvas;
import basics.math.algebra.Vector;
import optics.light.Color;
public class ContributionBuffer {
// linear rgb colors
private volatile Color[][] buffer;
// amount of samples for every pixel
private volatile double[][] samples;
private int width;
private int height;
public ContributionBuffer(int width, int height) {
this.width = width;
this.height = height;
this.buffer = new Color[width][height];
this.samples = new double[width][height];
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
this.buffer[x][y] = Color.BLACK;
}
}
}
public void contribute(int x, int y, Color color) {
buffer[x][y] = buffer[x][y].add(color);
samples[x][y]++;
}
/**
* Set all color values and sample count to zero
* All other calls to contribute() should be blocked during execution
*/
public void clear() {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
// clear color
Color color = buffer[x][y];
color.r = color.g = color.b = 0;
// reset sample count
samples[x][y] = 0;
}
}
}
private int getRGB(int x, int y) {
Color linearRGB = buffer[x][y].scale(1.0 / samples[x][y]);
int red = (int) (linearRGB.r * 255.0);
int green = (int) (linearRGB.g * 255.0);
int blue = (int) (linearRGB.b * 255.0);
red = Math.max(Math.min(red, 255), 0);
green = Math.max(Math.min(green, 255), 0);
blue = Math.max(Math.min(blue, 255), 0);
return 0xff000000 | red << 16 | green << 8 | blue;
}
public void blit(int[] buffer) {
for (int y = 0; y < height; y++) {
int col = y * width;
for (int x = 0; x < width; x++) {
buffer[col + x] = getRGB(x, y);
}
}
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
}

View File

@ -0,0 +1,73 @@
package renderer.canvas;
import optics.view.PlayerController;
import renderer.Resolution;
import renderer.Scheduler;
import renderer.debug.DebugOverlay;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
public class RenderTarget extends JPanel {
private BufferedImage target;
private int[] pixels;
private ContributionBuffer buffer;
private DebugOverlay overlay;
private boolean visualizeThreads = true;
public RenderTarget(Resolution resolution) {
super();
this.overlay = new DebugOverlay();
this.overlay.setup();
this.buildBuffer(resolution);
setLayout(new BorderLayout());
add(this.overlay.getRoot(), BorderLayout.NORTH);
}
public void buildBuffer(Resolution resolution) {
int scaledWidth = resolution.getScaledWidth();
int scaledHeight = resolution.getScaledHeight();
this.target = new BufferedImage(scaledWidth, scaledHeight, BufferedImage.TYPE_INT_ARGB);
this.pixels = ((DataBufferInt) target.getRaster().getDataBuffer() ).getData();
this.buffer = new ContributionBuffer(scaledWidth, scaledHeight);
}
public void refresh() {
this.buffer.blit(this.pixels);
}
public ContributionBuffer getBuffer() {
return buffer;
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(this.target, 0, 0, this.getWidth(), this.getHeight(), null);
if (visualizeThreads) {
int tileWidth = getWidth() / Scheduler.THREADS_PER_SIDE;
int tileHeight = getHeight() / Scheduler.THREADS_PER_SIDE;
Graphics2D g2 = (Graphics2D) g.create();
g2.setColor(Color.MAGENTA);
g2.setStroke(new BasicStroke(2));
for (int x = 1; x < Scheduler.THREADS_PER_SIDE; x++) {
g2.drawLine(0, x * tileHeight, getWidth(), x * tileHeight);
g2.drawLine(x * tileWidth, 0, x * tileWidth, getHeight());
}
}
}
public DebugOverlay getOverlay() {
return overlay;
}
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="renderer.debug.DebugOverlay">
<grid id="27dc6" binding="root" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="4" left="4" bottom="4" right="4"/>
<constraints>
<xy x="20" y="20" width="575" height="453"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="eb7a2" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="8" bottom="0" right="8"/>
<constraints>
<grid row="0" column="0" row-span="9" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="60279" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Frametime"/>
</properties>
</component>
<vspacer id="8c764">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="4bbcc" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Threads"/>
</properties>
</component>
<component id="65119" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Target dimension"/>
</properties>
</component>
<component id="c4388" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Tile dimensions"/>
</properties>
</component>
<component id="bf78a" class="javax.swing.JLabel">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Samples"/>
</properties>
</component>
<component id="b0d6b" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Down scale"/>
</properties>
</component>
<component id="33454" class="javax.swing.JLabel" binding="frametime">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="16ms"/>
</properties>
</component>
<component id="66b77" class="javax.swing.JLabel" binding="threads">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="4"/>
</properties>
</component>
<component id="a6a30" class="javax.swing.JLabel" binding="targetDimension">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="800x800"/>
</properties>
</component>
<component id="d0037" class="javax.swing.JLabel" binding="downScale">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="2"/>
</properties>
</component>
<component id="83c7b" class="javax.swing.JLabel" binding="tileDimensions">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="200x200"/>
</properties>
</component>
<component id="44f8c" class="javax.swing.JLabel" binding="samples">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="866"/>
</properties>
</component>
</children>
</grid>
<hspacer id="6cc64">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</form>

View File

@ -0,0 +1,47 @@
package renderer.debug;
import renderer.Resolution;
import renderer.Scheduler;
import javax.swing.*;
import java.awt.*;
public class DebugOverlay {
private JLabel frametime;
private JLabel threads;
private JLabel targetDimension;
private JLabel tileDimensions;
private JLabel samples;
private JPanel root;
private JLabel downScale;
public void setup(){
this.root.setOpaque(false);
this.root.setBackground(new Color(0,0,0,0));
}
public void setFrametime(long ms) {
this.frametime.setText(String.format("%dms", ms));
}
public void setSamples(int samples) {
this.samples.setText("" + samples);
}
public void setTargetDimension(Resolution resolution) {
this.targetDimension.setText(String.format("%dx%d", resolution.getScaledWidth(), resolution.getScaledHeight()));
this.downScale.setText("" + resolution.getDownScale());
}
public void setThreads() {
this.threads.setText("" + Scheduler.THREADS_PER_SIDE * Scheduler.THREADS_PER_SIDE);
}
public void setTileDimensions(int width, int height) {
this.tileDimensions.setText(String.format("%dx%d", width, height));
}
public JPanel getRoot() {
return root;
}
}

View File

@ -0,0 +1,34 @@
package renderer.mesh;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
import raytracing.BasicMaterial;
import renderer.primitive.Primitive;
import shading.Material;
public class BasicMesh extends Mesh {
private BasicMaterial material;
private Primitive shape;
public BasicMesh(BasicMaterial material, Primitive shape) {
this.material = material;
this.shape = shape;
}
@Override
public Material getMaterial() {
return (Material) material;
}
@Override
public double intersect(Ray ray) {
return shape.intersect(ray);
}
@Override
public Vector normalAt(Vector surfacePoint) {
return shape.normalAt(surfacePoint);
}
}

View File

@ -0,0 +1,14 @@
package renderer.mesh;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
import shading.Material;
public abstract class Mesh {
public abstract double intersect(Ray ray);
public abstract Vector normalAt(Vector surfacePoint);
public abstract Material getMaterial();
}

View File

@ -0,0 +1,25 @@
package renderer.primitive;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
public class Plane implements Primitive {
private double offset;
private Vector normal;
public Plane(Vector normal, double offset) {
this.offset = offset;
this.normal = normal;
}
@Override
public double intersect(Ray ray) {
return -(ray.getOrigin().dot(normal) + offset) / ray.getDirection().dot(normal);
}
@Override
public Vector normalAt(Vector surfacePoint) {
return normal;
}
}

View File

@ -0,0 +1,11 @@
package renderer.primitive;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
public interface Primitive {
double intersect(Ray ray);
Vector normalAt(Vector surfacePoint);
}

View File

@ -0,0 +1,34 @@
package renderer.primitive;
import basics.math.algebra.Ray;
import basics.math.algebra.Vector;
public class Sphere implements Primitive {
private Vector center;
private double radius;
public Sphere(Vector center, double radius) {
this.center = center;
this.radius = radius;
}
@Override
public double intersect(Ray ray) {
Vector oc = ray.getOrigin().sub(this.center);
double b = ray.getDirection().dot(oc);
double c = oc.dot(oc) - this.radius * this.radius;
double h = b * b - c;
if (h < 0.0)
return -1.0;
return -b - h;
}
@Override
public Vector normalAt(Vector surfacePoint) {
return surfacePoint.sub(center).normalize();
}
}

View File

@ -0,0 +1,4 @@
package shading;
public interface Material {
}

View File

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Main-Class: org.engine.Engine

View File

@ -1,45 +0,0 @@
import org.logic.GyteController;
import org.run.ForcedStopException;
/**
* @author SvenV
* @date 09.01.2021
* @version 1.1.1
*
* This class is the start and heart of every program ran by the GYTE-Processor.
*/
public class GyteProgram {
// default constructor, must be in here always.
public GyteProgram() {}
/* This method is the start where the processor will start executing */
public void run(GyteController controller) throws ForcedStopException {
// METHOD: random-walk
while(true) {
if (controller.isOnCoin() ) {
controller.pickup();
System.out.println("Coin count: " + controller.getCoinCount() );
}
double number = Math.random();
if (number < 0.5) {
if (number < 0.25) {
controller.turnRight();
} else {
controller.turnLeft();
}
}
while (controller.hasWallFront() ) {
if (number < 0.5) {
controller.turnRight();
} else {
controller.turnLeft();
}
}
controller.goForward();
}
}
}

View File

@ -1,69 +0,0 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>RTX-GYTEBOT Documentation full</title>
</head>
<body>
<h1>RTX-GYTEBOT Documentation</h1>
<h2 id="contents">Contents</h2>
<ol>
<li>Introduction</li>
<ul>
<li><a href="#contents">Contents</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#overview">Overview</a></li>
</ul>
<br>
<li>User Interface</li>
<ul>
<li><a href="#ui">User interface</a></li>
<li><a href="#map-editor">Map editor</a></li>
<li><a href="#code-editor">Code editor</a></li>
<li><a href="#viewport">3D-Viewport</a></li>
</ul>
<br>
<li>Technical details</li>
<ul>
<li><a href="#core">About the Engine</a></li>
</ul>
<br>
<li>Licences</li>
<ul>
<li><a href="#licences">Licences</a></li>
</ul>
</ol>
<h2 id="usage">Usage</h2>
<p>
RTX-GYTEBOT is a free open source project made for educational purpose only.<br>
I, Sven Vogel, the author of this project did not want this program or any of its resources to be given to any third-party person.<br>
Any of the provided source code or resources can be used for private purposes, but nor for commercial ones.<br>
Further instructions about the usage of individual resources are provided in the <a href="#licences">Licences</a> section down below.<br>
</p>
<h2 id="overview">Quick Overview</h2>
<p>
<b>author:</b>Sven Vogel <br>
<b>date:</b> 04.01.2021 <br>
<b>project:</b> RTX-GYTEBOT <br>
<br>
RTX-GYTEBOT is small project that aimed at bringing a programmable, object oriented robot simulator to life.<br>
Thereby using OpenGL to render a 3D preview scene, instead of giving some lame and hard to read console output.<br>
Several inbuilt editors are available to control and manipulate the world the robot spawns in.<br>
These are primarily a map editor which gives you control about where what is placed initially in the world.<br>
Additionally a code editor is used to directly program the robot in Java.<br>
The soure code is fully documented with plenty of javadocs and inline comments.<br>
</p>
<h2 id="overview">User interface</h2>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

View File

@ -1,26 +0,0 @@
// information tag to pass some general data
@author SvenV
@version 1.0.0
@name pack-man!
@date 08.01.2021
// original packman map
// but no ghosts :(
#################
# # #
# ## ## # ## ## #
#$ $ #
#### # ### # ####
# # #€ # # # #
#### ## # ## ####
# € #
#### ## # ## ####
# # # #> # # #
#### # ### # ####
# € #
# ## ## # ##€## #
# $ # #
# ## ## #$## ## #
# # #
#################

View File

@ -1,303 +0,0 @@
#version 430 core
// general luminance threshold at which antialiasing will take place
const float contrastThreshold = 0.03;
// additional relative luminance threshold at which antialiasing will take place
const float relativeThreshold = 0.06;
// gamma value
const float epsilon = 1.5; // used for tone mapping and gamma correcting DoF bokeh blur
// distance from the camera's origin to focal point
const float focusDistance = 0.4;
// // range of focus.
const float focusRange = 0.5; // Lower values mean more sharper image
// contrast of fragment
const float contrast = 0.3;
// additional brightness of fragment
const float brightness = 0.05;
// output fragment color
out vec4 fragColor;
// screen resolution in pixels
uniform vec2 resolution;
// fbo texture sampler
uniform sampler2D fboTexture; // RGB-components store pixel color, alpha holds linear world scene depth from the camera's origin
uniform int boolFilterDoF; // enabled Depth of Field
uniform int boolFilterFXAA; // enabled Fast Approximate Anti Aliasing
uniform int boolFilterGrain;// enable some graininess to add to every pixels
// normalized fragment coordinates
const vec2 fragCoords = gl_FragCoord.xy / resolution;
// texel size
const vec2 fboTexelSize = 1.0 / resolution;
#define true 1 // true is not natively defined
// FXAA implementation from: https://catlikecoding.com/unity/tutorials/advanced-rendering/fxaa/
// with some minor optimizations regarding branches and texture lookups
struct LuminanceData {
// stores information about luminance
float max, min, diff; // maximum, minimum and luminance difference between max/min
// fragment values and its neighboors
float texels[3][3];
// field names
#define lumSouthWest lumData.texels[0][0]
#define lumSouth lumData.texels[1][0]
#define lumSouthEast lumData.texels[2][0]
#define lumWest lumData.texels[0][1]
#define lumMiddle lumData.texels[1][1]
#define lumEast lumData.texels[2][1]
#define lumNorthWest lumData.texels[0][2]
#define lumNorth lumData.texels[1][2]
#define lumNorthEast lumData.texels[2][2]
};
float luminanceFromLinearRgb(in vec3 linearRgb)
{
// relative luminance coefficent factors
const vec3 luminanceFactors = vec3(0.2126729, 0.7151522, 0.0721750);
// compute luminance
return dot(linearRgb, luminanceFactors);
}
float texelLuminosity(in vec2 pixelOffset)
{
vec3 linearRgb = texture2D(fboTexture, fragCoords + pixelOffset * fboTexelSize).rgb;
return luminanceFromLinearRgb(linearRgb);
}
// clamp between [0, 1]
#define saturate(x) clamp(x, 0.0, 1.0)
// collect luminance data and fill struct
void collectLuminance(inout LuminanceData lumData)
{
// collect data
for (int x = -1; x < 2; x++) {
for (int y = -1; y < 2; y++) {
lumData.texels[x + 1][y + 1] = texelLuminosity(vec2(float(x), float(y) ) );
}
}
// calculate highest and lowest + difference i.e the contrast
lumData.max = max(max(max(max(lumEast, lumWest), lumSouth), lumNorth), lumMiddle);
lumData.min = min(min(min(min(lumEast, lumWest), lumSouth), lumNorth), lumMiddle);
// compute difference
lumData.diff = lumData.max - lumData.min;
}
// apply a basic tent blur filter, to average the fragments luminance
float fragBlendFactor(in LuminanceData lumData)
{
// these should matter more, so double their influence
float fac = 2.0 * (lumNorth + lumSouth + lumWest + lumEast);
fac += lumNorthWest + lumNorthEast + lumSouthWest + lumSouthEast;
fac /= 12.0; // scale down
fac = abs(fac - lumMiddle);
fac = saturate(fac / lumData.diff);
float blendFac = smoothstep(0.0, 1.0, fac);
return blendFac * blendFac;
}
// determine the edge type
bool determineEdge(in LuminanceData lumData)
{
// change in horizontal pixels
float hori =
abs(lumNorth + lumSouth - 2.0 * lumMiddle) * 2.0 +
abs(lumNorthEast + lumSouthEast - 2.0 * lumEast) +
abs(lumNorthWest + lumSouthWest - 2.0 * lumWest);
// change in vertical pixels
float veri =
abs(lumEast + lumWest - 2.0 * lumMiddle) * 2.0 +
abs(lumNorthEast + lumNorthWest - 2.0 * lumNorth) +
abs(lumSouthEast + lumSouthWest - 2.0 * lumSouth);
return hori >= veri;
}
vec3 filterFXAA()
{
// collect luminance data off current fragment
LuminanceData lumData;
collectLuminance(lumData);
vec2 st = fragCoords;
if (lumData.diff > max(contrastThreshold, relativeThreshold * lumData.max) )
{
float fac = fragBlendFactor(lumData);
bool edge = determineEdge(lumData);
float pixelStep = edge ? fboTexelSize.y : fboTexelSize.x;
float pLum = edge ? lumNorth : lumEast;
float nLum = edge ? lumSouth : lumWest;
float pGrad = abs(pLum - lumMiddle);
float nGrad = abs(nLum - lumMiddle);
pixelStep = pixelStep * sign(pGrad - nGrad);
st += edge ? vec2(0, pixelStep * fac) : vec2(pixelStep * fac, 0);
}
return texture2D(fboTexture, st).rgb;
}
// apply gamma correctio to linear RGB color
vec3 gamma(in vec3 linearRgb)
{
return pow(linearRgb, vec3(epsilon) );
}
// de-gamma linear RGB color
// degamma() is the inverse function of gamma()
vec3 degamma(in vec3 linearRgb)
{
return pow(linearRgb, vec3(1.0 / epsilon) );
}
// Gold Noise ©2015 dcerisano@standard3d.com
// - based on the Golden Ratio
// - uniform normalized distribution
// - (fastest?) static noise generator function (also runs at low precision)
// generate some 1D noise
// no seed required
float goldNoise(in vec2 xy)
{
const float phi = 1.61803398874989484820459; // Φ = Golden Ratio
return fract(tan(distance(xy * phi, xy) ) * xy.x) * 2.0 - 1.0;
}
// gamma corrected bokeh down sampling filter as DoF blur
vec3 bokeh(in float bokehSize)
{
// if sampling rate is low enough, clamp it to use FXAA instead of a single unfiltered texture lookup
if (bokehSize < 2.0)
{
if (boolFilterFXAA == true)
{
// if filter FXAA
return filterFXAA();
}
else
{
// if no DoF and no FXAA, do nearly nothing
return texture2D(fboTexture, fragCoords).rgb;
}
}
vec3 color = vec3(0);
const int steps = 8; // samples to take per axis {x,y}
const int stepsHalf = steps / 2;
const float stepSize = bokehSize / steps;
float samples = 0.0; // samples actually taken
for (int i = -stepsHalf; i < stepsHalf; i++) {
float u = stepSize * float(i) * fboTexelSize.x;
for (int j = -stepsHalf; j < stepsHalf; j++) {
float v = stepSize * float(j) * fboTexelSize.y;
// calculate sample effectiveness, as circle for perfect bokeh
float shape = 1.0 - step(stepsHalf, length(vec2(i, j) ) );
// if we have enough effectiveness, take a sample
if (shape > 0.5) {
// calculate offset coordinates for sample, and add some noise to break of grid patterns when using low amount of samples
float noiseX = goldNoise(vec2(i, j) + gl_FragCoord.xy + 1.0);
float noiseY = goldNoise(vec2(i, j) + gl_FragCoord.xy + 4.0);
vec2 coords = vec2(noiseX, noiseY) * fboTexelSize + fragCoords + vec2(u, v);
// gamma correct texture lookup and contribute
color += gamma(texture2D(fboTexture, coords).rgb * shape);
samples += shape; // we have taken a sample, so remember for normalization later
}
}
}
// de-gamma correct and normalize
return degamma(color / samples);
}
vec3 filterDoF()
{
// get scene depth
float depth = texture2D(fboTexture, fragCoords).a;
// Circle of Confusion
float CoC = clamp( (depth - focusDistance) / focusRange, -1, 1) * 16.0;
// compute bokeh blur
return bokeh(abs(CoC) );
}
void filmGrain(inout vec3 color)
{
float noiseRed = goldNoise(gl_FragCoord.xy + 1.0);
float noiseGreen = goldNoise(gl_FragCoord.xy + 16.0);
float noiseBlue = goldNoise(gl_FragCoord.xy + 32.0);
vec3 noise = vec3(noiseRed, noiseGreen, noiseBlue);
float intensity = 1.0 - sqrt(texelLuminosity(vec2(0) ) );
color = color + color * noise * intensity * 0.2;
}
void sampleColorTexture(inout vec3 color)
{
if (boolFilterDoF == true)
{
// apply DoF
color = filterDoF();
}
else if (boolFilterFXAA == true)
{
// if no DoF, filter FXAA
color = filterFXAA();
}
else
{
// if no DoF and no FXAA, do nearly nothing
color = texture2D(fboTexture, fragCoords).rgb;
}
}
void main()
{
vec3 color;
// get primary scene color
sampleColorTexture(color);
// adjust contrast and brightness
color = (color - 0.5) * (1.0 + contrast) + 0.5 + brightness;
// vignette
// falloff
float falloff = distance(fragCoords, vec2(0.5, 0.5) );
// adjust falloff and darken
color = color * (1.0 - falloff * falloff * falloff * 0.2);
// tone map
color = clamp(color, 0.0, 1.0);
color = 1.0 - pow(1.0 - color, vec3(epsilon) );
if (boolFilterGrain == true)
{
// add some film grain
filmGrain(color);
}
fragColor = vec4(color, 1);
}

View File

@ -1,20 +0,0 @@
#version 430 core
// _______ _________ _______ _______ _
// ( ____ \\__ __/( ___ )( ____ )( )
// | ( \/ ) ( | ( ) || ( )|| |
// | (_____ | | | | | || (____)|| |
// (_____ ) | | | | | || _____)| |
// ) | | | | | | || ( (_)
// /\____) | | | | (___) || ) _
// \_______) )_( (_______)|/ (_)
//
// PLEASE DO NOT TRY TO EDIT ANY OF THE FOLLOWING CODE IF NOT NECESSARY!
// was auch immer man bei dem bisschen schon kaputt machen wollen w<>rde...
in vec2 vertexPosition;
void main() {
gl_Position = vec4(vertexPosition, 1, 1);
}

View File

@ -1,559 +0,0 @@
#version 430 core
out vec4 fragColor;
// input variables
uniform vec2 resolution; // screen resolution
uniform float time; // global time
uniform vec2 cameraRotation; // rotation of camera in x and y
uniform float cameraZoom; // zoom of camera
uniform sampler2D worldTexture; // stone
uniform sampler2D environmentTexture; // texture of background as environemnt
uniform sampler2D coinTexture; // texture of coins
uniform sampler2D testTexture; // test
uniform float width;
uniform float height;
uniform int drawGytebot;
uniform vec2 gytebotLocation;
uniform float gytebotRotation;
layout(std430, binding = 0) readonly buffer CoinBuffer
{
int coinBuffer[];
};
layout(std430, binding = 1) readonly buffer WallBuffer
{
float wallBuffer[];
};
// material indexes
const int MaterialNone = 0;
const int MaterialBlue = 1;
const int MaterialEyes = 2;
const int MaterialDark = 3;
const int MaterialCoin = 4;
const int MaterialRockDef = 5;
const int MaterialRockExt = 6;
#define SDF3D vec2 // SDF data type
// _______ _________ _______ _______ _
// ( ____ \\__ __/( ___ )( ____ )( )
// | ( \/ ) ( | ( ) || ( )|| |
// | (_____ | | | | | || (____)|| |
// (_____ ) | | | | | || _____)| |
// ) | | | | | | || ( (_)
// /\____) | | | | (___) || ) _
// \_______) )_( (_______)|/ (_)
//
// PLEASE DO NOT TRY TO EDIT ANY OF THE FOLLOWING CODE IF NOT NECESSARY!
const float PI = 3.14159265359;
const int mapBounds = 32;
const float nearPlane = 1e-3; // camera near plane
const float farPlane = 1e3; // camera far plane
const float wallHeight = 0.05; // height of walls. NOTE: if raised or lowered coins and the bot may float or sink into the ground
// TODO: adjust coin and bot elevation by wallHeight
const float borderSize = 0.03; // extended border for map
// recommend values: [ 0.015, 0.030, 0.04 ]
const vec2 epsilon = vec2(1e-3, 0); // small value for creating tiny gaps to prevent errors, not recommend to change
// gytebot exceeds width of 1.0, so adjust scale factor to make him fit in!
const float gytebotScale = (mapBounds + 18);
const float invGytebotScale = 1.0 / gytebotScale;
// boundary of walls
const vec3 wallBounding = vec3(width/mapBounds + epsilon.x, wallHeight + epsilon.x, height/mapBounds + epsilon.x);
// ^ add some space on top for cleaner normal calculations
const float gytebotElevation = -invGytebotScale - 0.02;
// create a "3D" texture lookup by blending all 3 different sides of an cube together
// TODO: Replace with biplanar-mapping
vec3 textureBox2D(in sampler2D sampler, in vec3 normal, in vec3 point)
{
vec3 x = texture2D(sampler, point.yz).bgr;
vec3 y = texture2D(sampler, point.zx).bgr;
vec3 z = texture2D(sampler, point.xy).bgr;
vec3 blend = pow(abs(normal), vec3(0.5) );
return (x * blend.x + y * blend.y + z * blend.z) / (blend.x + blend.y + blend.z);
}
float sampleWallMap(in vec2 point)
{
vec2 f = fract(point * vec2(width, height) );
int x = int(point.x * width);
int y = int(point.y * height);
// cubic hermite curve to smooth interpolation factors
f = f * f * (3.0 - 2.0 * f);
// apply mix factor transformation to 'harden' edges
f = pow(f, vec2(16.0) );
float s00 = wallBuffer[(x + 0) + (y + 0) * mapBounds];
float s10 = wallBuffer[(x + 1) + (y + 0) * mapBounds];
float s01 = wallBuffer[(x + 0) + (y + 1) * mapBounds];
float s11 = wallBuffer[(x + 1) + (y + 1) * mapBounds];
// mix top and bottom samples from left to right
float south = mix(s00, s10, f.x);
float north = mix(s01, s11, f.x);
// mix top and bottom together and invert
return 1.0 - mix(south, north, f.y);
}
// extrude a 2D sdf (on x,z) to 3D (x,y,z)
// by Inigo Quilez: https://iquilezles.org/www/articles/distfunctions/distfunctions.htm
float extrudeSdf(in vec3 position, in float sdf)
{
vec2 w = vec2(sdf, abs(position.y) - wallHeight);
return min(max(w.x, w.y), 0.0) + length(max(w, 0.0) );
}
// wall sdf
float sdfMap(in vec3 position)
{
// sample flat 2D-walls
float sdfWall = sampleWallMap( (position.xz + wallBounding.xz) / (2.0 * wallBounding.xz) - vec2(0.11/vec2(width, height) ) ) * 0.01 - 0.002;
// extrude 2D-walls to 3D
return extrudeSdf(position, sdfWall);
}
float sdfBox(vec3 p, vec3 b)
{
vec3 q = abs(p) - b;
return length(max(q, 0.0) ) + min(max(q.x, max(q.y, q.z) ), 0.0);
}
float borderBox(in vec3 position)
{
// compute bounding container, by cutting out a small box out of a big box via boolean difference
return max(
sdfBox(position, wallBounding + vec3(borderSize, 0.02, borderSize) ), // big box
-sdfBox(position + vec3(0, 0.1, 0), wallBounding - vec3(0.01, -0.05, 0.01) ) // small box
);
}
// AABB ray-intersection algorithm
// by Inigo Quilez: https://iquilezles.org/www/articles/intersectors/intersectors.htm
vec2 boxIntersection(in vec3 origin, in vec3 direction, inout vec3 normal, in vec3 boxSize)
{
vec3 m = 1.0 / direction;
vec3 n = m * origin; // can precompute if traversing a set of aligned boxes
vec3 k = abs(m) * boxSize;
vec3 t1 = -n - k;
vec3 t2 = -n + k;
float tN = max(max(t1.x, t1.y), t1.z);
float tF = min(min(t2.x, t2.y), t2.z);
if(tN > tF || tF < 0.0)
return vec2(-1.0); // no intersection
normal = -sign(direction) * step(t1.yzx, t1.xyz) * step(t1.zxy, t1.xyz);
return vec2(tN, tF);
}
SDF3D sdfUnion(in SDF3D a, in SDF3D b)
{
return a.x < b.x ? a : b;
}
float smoothmin(in float d1, in float d2, in float k)
{
float h = clamp(0.5 + 0.5 * (d2 - d1) / k, 0.0, 1.0);
return mix(d2, d1, h) - k * h * (1.0 - h);
}
SDF3D sdfGytebot(in vec3 position)
{
return sdfUnion(
SDF3D(
// wheels
min(
length(position - vec3( 0, 1.5, 1) ) - 0.58,
min(
length(position - vec3( 0.75, 1.5, -0.5) ) - 0.58,
length(position - vec3(-0.75, 1.5, -0.5) ) - 0.58
)
), MaterialDark),
sdfUnion(
// eye
SDF3D( (length( (position + vec3(0, 0, 0.7) ) * vec3(1, 1, 2.0) ) - 0.5) * 0.5, MaterialEyes),
SDF3D(
min(
// head as sliced sphere shell
max(-dot(position, vec3(0, 0, 1) ) - 0.7, abs(length(position) - 1.0) - 0.05 ),
max(
-dot(position, vec3(0, -1, 0) ) - 1.8, // slice
smoothmin(
length(position - vec3(0,1,0)) - 0.6, // body, will connect three wheels
min(
length(position - vec3( 0, 1.5, 1) ) - 0.6, // back wheel
min(
length(position - vec3( 0.75, 1.5, -0.5) ) - 0.6, // right wheel
length(position - vec3(-0.75, 1.5, -0.5) ) - 0.6 // left wheel
)
), 0.2
)
)
), MaterialBlue)
)
);
}
mat2 constructRotationMatrix(float theta)
{
float sinTheta = sin(theta); // sine of theta
float cosTheta = cos(theta); // cosine of theta
mat2 matrix = mat2(sinTheta, -cosTheta, cosTheta, sinTheta); // construct rotation matrix
return matrix;
}
// standard arguments required for composing a mesh
#define stdArgs inout vec3 viewPosition, \
inout vec3 viewDirection, \
inout vec3 position, \
inout vec3 normal, \
inout float depth, \
inout int materialIndex
float sdfCoin(in vec3 position)
{
vec2 d = abs(vec2(length(position.xy), position.z) ) - vec2(0.43, 0.0001);
return min(max(d.x, d.y), 0.0) + length(max(d, 0.0) ) / 64.0;
}
vec2 coinUv;
void renderMap(stdArgs)
{
// get intersection distances with box containing the map
vec2 bound = boxIntersection(viewPosition, viewDirection, normal, wallBounding);
if (bound.y > 0.0) // if we hit, i.e tFar is greater than 0 or not behind the camera
{
float rayLength = max(bound.x, epsilon.x);
vec3 intersection = viewPosition + viewDirection * rayLength;
float maxDist = distance(intersection, viewPosition + viewDirection * bound.y);
float map;
// march through cube
for (float dist = epsilon.x; dist < maxDist; dist += map) {
vec3 location = intersection + viewDirection * dist;
map = sdfMap(location);
if (map < epsilon.x)
{
// set material data
depth = max(bound.x, epsilon.x) + dist;
position = location;
normal = normalize(map.x - vec3(
sdfMap(location + epsilon.xyy).x,
sdfMap(location + epsilon.yxy).x,
sdfMap(location + epsilon.yyx).x ) );
materialIndex = MaterialRockDef;
break; // were done, break out
}
}
// traverse a grid of 2D cells via bransham
// if we enter a cell check if there is coin in it, if not continue, if yes, render coin.
// in case there was a coin, but it has no effect, meaning we missed it, continue
// calculate start- and end-points of bounding box containing the cells
vec2 endPoint = vec3(viewPosition + viewDirection * bound.y).xz;
vec2 startPoint = vec3(viewPosition + viewDirection * max(bound.x, epsilon.x) ).xz;
// remap to [0, width/height]
endPoint = (endPoint / wallBounding.xz * 0.5 + 0.5) * vec2(width, height);
startPoint = (startPoint / wallBounding.xz * 0.5 + 0.5) * vec2(width, height);
vec2 diff = endPoint - startPoint;
// number of steps we need to travel
float dist = abs(diff.x) + abs(diff.y);
// amount of space we need to travel for each cell
vec2 delta = diff / dist;
// traverse grid
for (float i = 0.0; i < ceil(dist); i += 1.0) {
// position in grid
vec2 pos = floor(startPoint + delta * i);
// index of coin
int index = int(pos.x + pos.y * width);
int isCoin = coinBuffer[index];
// do we have a coin?
if (isCoin == 1)
{
mat2 coinRotation = constructRotationMatrix(time);
// transform local cell space to world space
vec2 localSpace = (pos / vec2(width, height) * 2.0 - 1.0) * wallBounding.xz;
// construct world space translation
vec3 translation = vec3(localSpace.x, 0, localSpace.y) + vec3(1.0 / mapBounds, -0.03, 1.0 / mapBounds);
float t = epsilon.x;
// march a cylinder as a coin
for (int x = 0; x < 80; x++) {
vec3 location = (intersection - translation + viewDirection * t) * mapBounds;
location.xz *= coinRotation;
float h = sdfCoin(location);
if (h < epsilon.x)
{
// hit it!
position = intersection + viewDirection * t;
depth = t + rayLength;
normal = normalize(h - vec3(
sdfCoin(location + epsilon.xyy).x,
sdfCoin(location + epsilon.yxy).x,
sdfCoin(location + epsilon.yyx).x ) );
normal.xz *= inverse(coinRotation);
materialIndex = MaterialCoin;
coinUv = location.xy - vec2(0, 0.5);
i = 100.0;
break;
}
t += h;
// view is obstructed, break up
if (t + rayLength > depth)
break;
}
}
}
}
}
void renderBoundingBox(stdArgs)
{
float dist = nearPlane;
for (int i = 0; i < 128; i++) {
vec3 location = viewPosition + viewDirection * dist;
float map = borderBox(location);
dist += map;
if (dist > depth)
break;
else if (map < epsilon.x * dist)
{
depth = dist;
position = location;
normal = normalize(map.x - vec3(
borderBox(location + epsilon.xyy).x,
borderBox(location + epsilon.yxy).x,
borderBox(location + epsilon.yyx).x ) );
materialIndex = MaterialRockExt;
break;
}
}
}
float gytebotOcclusion = 0.0;
int renderGytebot(stdArgs, in vec2 worldGytebotLocation)
{
float dist = nearPlane;
vec3 gytebotPosition = viewPosition - vec3(worldGytebotLocation.x, gytebotElevation, worldGytebotLocation.y);
for (int i = 0; i < 80; i++) {
vec3 location = gytebotPosition + viewDirection * dist;
vec3 scaledLocation = location * gytebotScale;
SDF3D map = sdfGytebot(scaledLocation) * vec2(invGytebotScale, 1);
if (map.x < epsilon.x)
{
depth = dist;
position = location;
// compute normal
normal = normalize(sdfGytebot(scaledLocation).x * invGytebotScale - vec3(
sdfGytebot(scaledLocation + epsilon.xyy).x * invGytebotScale,
sdfGytebot(scaledLocation + epsilon.yxy).x * invGytebotScale,
sdfGytebot(scaledLocation + epsilon.yyx).x * invGytebotScale) );
materialIndex = int(map.y);
return 1;
}
dist += map.x;
if (dist > depth)
break;
}
gytebotOcclusion = min(sdfGytebot( (gytebotPosition + viewDirection * depth) * gytebotScale).x * 0.6 + 0.4, 1.0);
return 0;
}
const vec2 invAtan = vec2(0.1591, 0.3183);
vec2 getSphericalSt(in vec3 direction)
{
vec2 uv = vec2(atan(direction.z, direction.x), asin(direction.y) );
uv *= invAtan;
uv += 0.5;
return uv;
}
vec3 shadeMaterial(in vec3 incoming, in vec3 position, in vec3 normal, in vec3 albedo, in float roughness)
{
vec2 uv = getSphericalSt(normal);
vec3 irradiance = textureGrad(environmentTexture, uv, vec2(0.05), vec2(0.05) ).bgr;
float lod = pow(roughness, 4.0);
vec2 specUv = getSphericalSt(reflect(incoming, normal) );
vec3 specular = textureGrad(environmentTexture, specUv, vec2(lod), vec2(lod) ).bgr;
float R = min(pow(1.0 - dot(incoming, normal), 2.0) * (1.0 - roughness * roughness), 1.0);
return mix(irradiance * albedo, specular, R);
}
void main()
{
// create rotation matracies
mat2 horizontalCamerRotation = constructRotationMatrix(cameraRotation.x);
mat2 verticalCamerRotation = constructRotationMatrix(cameraRotation.y);
mat2 gytebotRotationMat = constructRotationMatrix(gytebotRotation );
// create camera untransformed data
vec2 screenCoords = (gl_FragCoord.xy - 0.5 * resolution.xy) / resolution.y; // re-map fragment coordinates to [-1, 1]
vec3 viewDirection = normalize(vec3(screenCoords, 1) ); // construct origin
vec3 viewPosition = vec3(0, 0, cameraZoom);
vec3 normal;
vec3 position;
int materialIndex = MaterialNone;
// camera view depth
// initially set to the farthest
float depth = farPlane;
// rotate camera on y
viewPosition.yz *= verticalCamerRotation;
viewDirection.yz *= verticalCamerRotation;
// rotate camera on x
viewPosition.xz *= horizontalCamerRotation;
viewDirection.xz *= horizontalCamerRotation;
// compose the maps walls and coins
renderMap(viewPosition, viewDirection, position, normal, depth, materialIndex);
// compose a bounding box
renderBoundingBox(viewPosition, viewDirection, position, normal, depth, materialIndex);
vec3 cameraDirection = viewDirection;
vec2 worldGytebotLocation = (gytebotLocation / vec2(width, height) * 2.0 - 1.0) * wallBounding.xz + vec2(0.03);
viewPosition.xz -= worldGytebotLocation; // move camera to origin, to not have the rotation affect the translation
// rotate camera, to "fake" a gytebot rotation
viewPosition.xz *= gytebotRotationMat;
viewDirection.xz *= gytebotRotationMat;
viewPosition.xz += worldGytebotLocation; // move camera back
if (drawGytebot == 1)
{
if (renderGytebot(viewPosition, viewDirection, position, normal, depth, materialIndex, worldGytebotLocation) == 1)
{
// rotate normal back to world space
normal.xz *= inverse(gytebotRotationMat);
}
}
vec3 color;
if (materialIndex == MaterialNone)
{
// sample environment texture + gamma correction
color = texture2D(environmentTexture, getSphericalSt(cameraDirection) ).bgr;
} else if (depth < nearPlane)
{
color = vec3(0);
} else
{
vec3 albedo;
switch(materialIndex) {
#define stdParams cameraDirection, position, normal, albedo
case MaterialRockDef:
albedo = textureBox2D(worldTexture, normal, position * 5.0);
color = shadeMaterial(stdParams, 0.85);
color *= min(pow(abs(position.y), 0.5) * 8, 1);
break;
case MaterialRockExt:
albedo = textureBox2D(worldTexture, normal, position * 5.0);
color = shadeMaterial(stdParams, 0.85);
if (normal.x < 1e-2 && normal.z < 1e-2 && normal.y > 0.99 && position.y > -wallHeight * 0.4)
{
// paint ambient occlusion
vec2 point = (position.xz + wallBounding.xz) / (2.0 * wallBounding.xz);
color *= vec3(sampleWallMap(point - vec2(0.11/vec2(width, height) ) ) );
color *= vec3(gytebotOcclusion);
// paint grid lines
point *= vec2(width, height);
color += vec3(step(0.95, fract(point.x) ) + step(0.95, fract(point.y) ) ) * pow(texture2D(worldTexture, position.xz).g, 2.0);
color *= 1.0 - vec3(step(0.0, sin(point.x * PI) * sin(point.y * PI) ) ) * 0.1;
}
break;
case MaterialBlue:
albedo = vec3(0.275, 0.796, 1);
color = shadeMaterial(stdParams, 0.1);
break;
case MaterialDark:
albedo = vec3(0.1);
color = shadeMaterial(stdParams, 0.6);
break;
case MaterialEyes:
albedo = vec3(0.1);
color = shadeMaterial(stdParams, 0.1);
color += smoothstep(0.97, 1.0, dot(normal, vec3(cos(gytebotRotation), 0, sin(gytebotRotation) ) ) ); // emission
break;
case MaterialCoin:
albedo = texture2D(coinTexture, coinUv).bgr;
color = shadeMaterial(stdParams, 0.2);
break;
default: break;
}
}
// color += texture2D(testTexture, screenCoords).rgb;
fragColor = vec4(color, depth);
}

View File

@ -1,20 +0,0 @@
#version 430 core
// _______ _________ _______ _______ _
// ( ____ \\__ __/( ___ )( ____ )( )
// | ( \/ ) ( | ( ) || ( )|| |
// | (_____ | | | | | || (____)|| |
// (_____ ) | | | | | || _____)| |
// ) | | | | | | || ( (_)
// /\____) | | | | (___) || ) _
// \_______) )_( (_______)|/ (_)
//
// PLEASE DO NOT TRY TO EDIT ANY OF THE FOLLOWING CODE IF NOT NECESSARY!
// was auch immer man bei dem bisschen schon kaputt machen wollen w<>rde...
in vec2 vertexPosition;
void main() {
gl_Position = vec4(vertexPosition, 1, 1);
}

View File

@ -1,18 +0,0 @@
// information tag to pass some general data
@author SvenV
@version 1.3.1
@name standard
@date 17.12.2020
###############
# #
# ########
# # #$ #
# # #
# $ #
###### ####
# v #
# # #
# # $ #
###############