Major refactor, remove IS stuff
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target/
|
||||
46
nbactions-lwjgl-natives-macos.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>run</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-XstartOnFirstThread -classpath %classpath electrosphere.main.Main</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -XstartOnFirstThread -classpath %classpath electrosphere.main.Main</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<jpda.listen>true</jpda.listen>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>profile</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-XstartOnFirstThread -classpath %classpath electrosphere.main.Main</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
||||
@ -10,7 +10,36 @@
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath main.Main</exec.args>
|
||||
<exec.args>-classpath %classpath electrosphere.main.Main</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>debug</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath electrosphere.main.Main</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
<jpda.listen>true</jpda.listen>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>profile</actionName>
|
||||
<packagings>
|
||||
<packaging>jar</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>process-classes</goal>
|
||||
<goal>org.codehaus.mojo:exec-maven-plugin:3.0.0:exec</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<exec.args>-classpath %classpath electrosphere.main.Main</exec.args>
|
||||
<exec.executable>java</exec.executable>
|
||||
</properties>
|
||||
</action>
|
||||
|
||||
14
pom.xml
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>orbitalstudio</groupId>
|
||||
<artifactId>InfiniteStratos</artifactId>
|
||||
<groupId>electrosphere</groupId>
|
||||
<artifactId>Renderer</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
@ -79,11 +79,21 @@
|
||||
<artifactId>joml</artifactId>
|
||||
<version>${joml.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>electrosphere</groupId>
|
||||
<artifactId>TerrainGen</artifactId>
|
||||
<version>0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package audio;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class AudioEngine {
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -1,4 +1,4 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.joml.Matrix4f;
|
||||
@ -1,4 +1,4 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -1,4 +1,4 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -28,7 +28,7 @@ public class Bone {
|
||||
deform = new Matrix4f();
|
||||
final_transform = new Matrix4f();
|
||||
boneID = raw_data.mName().dataString();
|
||||
inverseBindPoseMatrix = util.util.convertAIMatrix(raw_data.mOffsetMatrix());
|
||||
inverseBindPoseMatrix = electrosphere.util.util.convertAIMatrix(raw_data.mOffsetMatrix());
|
||||
this.raw_data = raw_data;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
@ -1,4 +1,4 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package RendererObjects.Light;
|
||||
package electrosphere.RendererObjects.Light;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package RendererObjects.Light;
|
||||
package electrosphere.RendererObjects.Light;
|
||||
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.GL31.GL_UNIFORM_BUFFER;
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package RendererObjects.Light;
|
||||
package electrosphere.RendererObjects.Light;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package RendererObjects.Light;
|
||||
package electrosphere.RendererObjects.Light;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import RendererObjects.texture.Texture;
|
||||
import electrosphere.RendererObjects.texture.Texture;
|
||||
import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.assimp.AIMaterial;
|
||||
import org.lwjgl.assimp.AIMaterialProperty;
|
||||
@ -1,8 +1,8 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import main.Globals;
|
||||
import main.Main;
|
||||
import RendererObjects.Light.LightBuffer;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.RendererObjects.Light.LightBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
@ -243,7 +243,7 @@ public class Mesh {
|
||||
// System.out.println("Num weights: " + currentBoneData.mNumWeights());
|
||||
Bone currentBone = new Bone();
|
||||
currentBone.boneID = currentBoneData.mName().dataString();
|
||||
currentBone.inverseBindPoseMatrix = util.util.convertAIMatrix(currentBoneData.mOffsetMatrix());
|
||||
currentBone.inverseBindPoseMatrix = electrosphere.util.util.convertAIMatrix(currentBoneData.mOffsetMatrix());
|
||||
currentBone.numWeights = currentBoneData.mNumWeights();
|
||||
currentBone.weights = new HashMap();
|
||||
Iterator<AIVertexWeight> weightIterator = currentBoneData.mWeights().iterator();
|
||||
@ -409,7 +409,7 @@ public class Mesh {
|
||||
|
||||
GL20.glUniformMatrix4fv(glGetUniformLocation(shader.shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||
|
||||
Vector3f cam_Loc = Globals.camera_visible.pos_Center;
|
||||
Vector3f cam_Loc = Globals.cameraVisible.pos_Center;
|
||||
temp[0] = cam_Loc.x;
|
||||
temp[1] = cam_Loc.y;
|
||||
temp[2] = cam_Loc.z;
|
||||
@ -420,7 +420,7 @@ public class Mesh {
|
||||
|
||||
|
||||
if(material == null){
|
||||
Globals.material_default.apply_material(0,1);
|
||||
Globals.materialDefault.apply_material(0,1);
|
||||
GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 0);
|
||||
} else {
|
||||
material.apply_material();
|
||||
@ -463,7 +463,7 @@ public class Mesh {
|
||||
glUniformMatrix4fv(shader.shaderVertexModelLoc, false, parent.modelMatrix.get(new float[16]));
|
||||
glUniformMatrix4fv(shader.shaderVertexViewLoc, false, Globals.viewMatrix.get(new float[16]));
|
||||
glUniformMatrix4fv(shader.shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
||||
glUniform3fv(shader.shaderVertexViewPosLoc, Globals.camera_visible.pos_Center.get(BufferUtils.createFloatBuffer(3)));
|
||||
glUniform3fv(shader.shaderVertexViewPosLoc, Globals.cameraVisible.pos_Center.get(BufferUtils.createFloatBuffer(3)));
|
||||
|
||||
//
|
||||
//
|
||||
@ -488,7 +488,7 @@ public class Mesh {
|
||||
test_Light_Data[2] = 0.5f;
|
||||
glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.diffuse"), test_Light_Data);
|
||||
|
||||
Vector3f cam_Loc = Globals.camera_visible.pos_Center;
|
||||
Vector3f cam_Loc = Globals.cameraVisible.pos_Center;
|
||||
test_Light_Data = new float[3];
|
||||
test_Light_Data[0] = cam_Loc.x;
|
||||
test_Light_Data[1] = cam_Loc.y;
|
||||
@ -1,6 +1,6 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import main.Globals;
|
||||
import electrosphere.main.Globals;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -21,7 +21,7 @@ import static org.lwjgl.opengl.GL13.*;
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.GL20.*;
|
||||
import static org.lwjgl.opengl.GL30.*;
|
||||
import RendererObjects.texture.TextureMap;
|
||||
import electrosphere.RendererObjects.texture.TextureMap;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -119,7 +119,7 @@ public class Model {
|
||||
//parse animation nodes and form hierarchy
|
||||
//
|
||||
AINode rootNode = s.mRootNode();
|
||||
rVal.globalInverseTransform = util.util.convertAIMatrix(rootNode.mTransformation());
|
||||
rVal.globalInverseTransform = electrosphere.util.util.convertAIMatrix(rootNode.mTransformation());
|
||||
// System.out.println("Global inverse transform");
|
||||
// System.out.println(globalInverseTransform);
|
||||
rVal.root_anim_node = rVal.build_anim_node_map(s.mRootNode(),null);
|
||||
@ -324,7 +324,7 @@ public class Model {
|
||||
// System.out.println("\n\n\n\n");
|
||||
// }
|
||||
} else {
|
||||
n.transform = n.transform.mul(util.util.convertAIMatrix(n.raw_data.mTransformation()));
|
||||
n.transform = n.transform.mul(electrosphere.util.util.convertAIMatrix(n.raw_data.mTransformation()));
|
||||
}
|
||||
Iterator<AnimNode> node_iterator = n.children.iterator();
|
||||
while(node_iterator.hasNext()){
|
||||
@ -3,13 +3,13 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import main.Globals;
|
||||
import electrosphere.main.Globals;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
@ -44,10 +44,10 @@ import static org.lwjgl.opengl.GL30.glGenVertexArrays;
|
||||
*/
|
||||
public class RenderUtils {
|
||||
public static Model createSkyboxModel(Material optionalMaterial){
|
||||
Model skybox_model = new Model();
|
||||
skybox_model.meshes = new ArrayList();
|
||||
Model skyboxModel = new Model();
|
||||
skyboxModel.meshes = new ArrayList();
|
||||
|
||||
skybox_model.modelMatrix = new Matrix4f();
|
||||
skyboxModel.modelMatrix = new Matrix4f();
|
||||
|
||||
|
||||
|
||||
@ -61,8 +61,8 @@ public class RenderUtils {
|
||||
glUseProgram(shader.shaderProgram);
|
||||
|
||||
if(material == null){
|
||||
Globals.material_default.apply_material(0,1);
|
||||
Iterator<Vector3f> colorIterator = Globals.skybox_colors.iterator();
|
||||
Globals.materialDefault.apply_material(0,1);
|
||||
Iterator<Vector3f> colorIterator = Globals.skyboxColors.iterator();
|
||||
int counter = 0;
|
||||
float[] temp = new float[3];
|
||||
while(colorIterator.hasNext()){
|
||||
@ -85,7 +85,7 @@ public class RenderUtils {
|
||||
glUniformMatrix4fv(shader.shaderVertexModelLoc, false, parent.modelMatrix.get(new float[16]));
|
||||
glUniformMatrix4fv(shader.shaderVertexViewLoc, false, new Matrix4f(Globals.viewMatrix).scale(100).get(new float[16]));
|
||||
glUniformMatrix4fv(shader.shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
||||
glUniform3fv(shader.shaderVertexViewPosLoc, Globals.camera_visible.pos_Center.get(BufferUtils.createFloatBuffer(3)));
|
||||
glUniform3fv(shader.shaderVertexViewPosLoc, Globals.cameraVisible.pos_Center.get(BufferUtils.createFloatBuffer(3)));
|
||||
|
||||
|
||||
GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
||||
@ -268,12 +268,14 @@ public class RenderUtils {
|
||||
|
||||
skyboxmesh.nodeID = "skybox";
|
||||
|
||||
skyboxmesh.parent = skybox_model;
|
||||
skyboxmesh.parent = skyboxModel;
|
||||
|
||||
|
||||
skybox_model.meshes.add(skyboxmesh);
|
||||
skyboxModel.meshes.add(skyboxmesh);
|
||||
|
||||
|
||||
return skybox_model;
|
||||
return skyboxModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
package RendererObjects;
|
||||
package electrosphere.RendererObjects;
|
||||
|
||||
import main.Main;
|
||||
import electrosphere.main.Main;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package RendererObjects.texture;
|
||||
package electrosphere.RendererObjects.texture;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -1,4 +1,4 @@
|
||||
package RendererObjects.texture;
|
||||
package electrosphere.RendererObjects.texture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
9
src/main/java/electrosphere/audio/AudioEngine.java
Normal file
@ -0,0 +1,9 @@
|
||||
package electrosphere.audio;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class AudioEngine {
|
||||
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package entity;
|
||||
package electrosphere.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package entity;
|
||||
package electrosphere.entity;
|
||||
|
||||
import RendererObjects.Model;
|
||||
import main.Globals;
|
||||
import electrosphere.RendererObjects.Model;
|
||||
import electrosphere.main.Globals;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@ -38,8 +38,8 @@ public class EntityUtil {
|
||||
rVal.getData().put("position", new Vector3f(0,0,0));
|
||||
rVal.getData().put("rotation", new Quaternionf().rotateAxis((float)0, new Vector3f(1,0,0)));
|
||||
rVal.getData().put("scale", new Vector3f(1,1,1));
|
||||
Globals.entity_list.add(rVal);
|
||||
Globals.drawable_list.add(rVal);
|
||||
Globals.entityList.add(rVal);
|
||||
Globals.drawableList.add(rVal);
|
||||
return rVal;
|
||||
}
|
||||
}
|
||||
93
src/main/java/electrosphere/main/Globals.java
Normal file
@ -0,0 +1,93 @@
|
||||
package electrosphere.main;
|
||||
|
||||
import electrosphere.RendererObjects.Camera;
|
||||
import electrosphere.RendererObjects.Light.DirectionalLight;
|
||||
import electrosphere.RendererObjects.Light.PointLight;
|
||||
import electrosphere.RendererObjects.Light.SpotLight;
|
||||
import electrosphere.RendererObjects.Material;
|
||||
import electrosphere.RendererObjects.Model;
|
||||
import electrosphere.RendererObjects.texture.Texture;
|
||||
import electrosphere.RendererObjects.texture.TextureMap;
|
||||
import com.google.gson.Gson;
|
||||
import electrosphere.entity.Entity;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import electrosphere.util.ModelLoader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Globals {
|
||||
|
||||
//
|
||||
//OpenGL - Other
|
||||
//
|
||||
//Array that holds all models that need to be shoved to the gpu
|
||||
public static Matrix4f viewMatrix = new Matrix4f();
|
||||
public static Matrix4f projectionMatrix;
|
||||
|
||||
|
||||
|
||||
public static Texture textureDiffuseDefault;
|
||||
public static Texture textureSpecularDefault;
|
||||
public static Material materialDefault;
|
||||
|
||||
public static DirectionalLight lightDirectionalDefault;
|
||||
public static ArrayList<PointLight> lightPointListDefault;
|
||||
public static SpotLight lightSpotDefault;
|
||||
|
||||
public static TextureMap textureMapDefault;
|
||||
|
||||
public static ArrayList<Entity> entityList;
|
||||
public static ArrayList<Entity> drawableList;
|
||||
|
||||
public static Camera cameraVisible;
|
||||
|
||||
//
|
||||
//Game specific models
|
||||
//
|
||||
|
||||
//famous fuckin last words, but temporary solution
|
||||
//global arraylist of values for the skybox colors
|
||||
public static ArrayList<Vector3f> skyboxColors;
|
||||
|
||||
|
||||
|
||||
public static void initGlobals(){
|
||||
//create default textures
|
||||
textureDiffuseDefault = new Texture("Textures/default_diffuse.png");
|
||||
textureSpecularDefault = new Texture("Textures/default_specular.png");
|
||||
//create default material
|
||||
materialDefault = new Material();
|
||||
materialDefault.set_diffuse(textureDiffuseDefault);
|
||||
materialDefault.set_specular(textureSpecularDefault);
|
||||
//create default lights
|
||||
lightDirectionalDefault = new DirectionalLight(new Vector3f(0,-1f,0));
|
||||
//load in default texture map
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
//deserializes the texture map from its default path using gson
|
||||
//also done in one line
|
||||
textureMapDefault = gson.fromJson(Files.newBufferedReader(new File(Thread.currentThread().getContextClassLoader().getResource("Textures/default_texture_map.json").getFile()).toPath()), TextureMap.class); //only the best of coding practices :)
|
||||
} catch (IOException ex) { ex.printStackTrace(); } //TODO: handle better :tm:
|
||||
//create entity list
|
||||
entityList = new ArrayList();
|
||||
drawableList = new ArrayList();
|
||||
//create the camera object that generates view matrix
|
||||
cameraVisible = new Camera();
|
||||
//init game specific variables
|
||||
initGameSpecifics();
|
||||
//temporary hold for skybox colors
|
||||
skyboxColors = new ArrayList();
|
||||
}
|
||||
|
||||
public static void initGameSpecifics(){
|
||||
}
|
||||
}
|
||||
349
src/main/java/electrosphere/main/Main.java
Normal file
@ -0,0 +1,349 @@
|
||||
package electrosphere.main;
|
||||
|
||||
import electrosphere.RendererObjects.Camera;
|
||||
import electrosphere.RendererObjects.Material;
|
||||
import electrosphere.RendererObjects.Model;
|
||||
import electrosphere.RendererObjects.RenderUtils;
|
||||
import electrosphere.RendererObjects.ShaderProgram;
|
||||
import electrosphere.RendererObjects.texture.Texture;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtil;
|
||||
import electrosphere.terraingen.TerrainGen;
|
||||
import electrosphere.terraingen.models.TerrainModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.glfw.*;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL13.*;
|
||||
import static org.lwjgl.opengl.GL14.*;
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.GL20.*;
|
||||
import static org.lwjgl.opengl.GL30.*;
|
||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
||||
import electrosphere.util.ModelLoader;
|
||||
import electrosphere.util.util;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Main {
|
||||
//
|
||||
//Generic OpenGL Statements
|
||||
//
|
||||
//Callback function for opengl errors
|
||||
private final static GLFWErrorCallback ERROR_CALLBACK = GLFWErrorCallback.createPrint(System.err);
|
||||
private static long window;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
//Visualization Controls
|
||||
//
|
||||
//These are used in calculating the time between frames for visualization (camera) control and such
|
||||
public static float deltaTime = 0.0f;
|
||||
public static float lastFrame = 0.0f;
|
||||
//View Controls
|
||||
public static float view_Range = 2000.0f;
|
||||
public static Camera camera_Current = new Camera();
|
||||
/*
|
||||
Mouse Controls
|
||||
*/
|
||||
static float mouse_lastX = 400;
|
||||
static float mouse_lastY = 300;
|
||||
static double xpos = 400;
|
||||
static double ypos = 300;
|
||||
static float mouseSensitivity = .1f;
|
||||
static double mouse_X_Buffer[] = new double[1];
|
||||
static double mouse_Y_Buffer[] = new double[1];
|
||||
static float cameraSpeed;
|
||||
static float yaw = 150;
|
||||
static float pitch = 50;
|
||||
|
||||
|
||||
|
||||
//
|
||||
//Player Object Variables
|
||||
//
|
||||
public static boolean CAMERA_UNDER_USER_CONTROL = false;
|
||||
public static boolean CAMERA_UNDER_FREE_CONTROL = false;
|
||||
public static boolean PLAYER_UNDER_USER_CONTROL = true;
|
||||
public static boolean CAMERA_IS_ORBIT = true;
|
||||
public static float camera_Orbit_Length = 1.0f;
|
||||
// public static Camera cam_Player_Orbit;
|
||||
//Camera angles using theta-phi system
|
||||
//Euler angles where theta is applied, then phi
|
||||
//There is no bank applied to the camera
|
||||
|
||||
public static Model model;
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
//
|
||||
//
|
||||
// I N I T I A L I Z A T I O N
|
||||
//
|
||||
//
|
||||
|
||||
//run initialization stuff
|
||||
|
||||
//Create opengl
|
||||
createOpenglContext();
|
||||
|
||||
//init global variables
|
||||
Globals.initGlobals();
|
||||
|
||||
|
||||
|
||||
|
||||
initWorld();
|
||||
|
||||
initSkybox();
|
||||
|
||||
|
||||
|
||||
Entity player = new Entity();
|
||||
player.getData().put("position", new Vector3f(0f,6f,0f));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// C A M E R A C R E A T I O N
|
||||
///
|
||||
Camera camera_player_chase = new Camera();
|
||||
Camera cam_Player_Orbit = new Camera();
|
||||
|
||||
|
||||
|
||||
//main loop
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
|
||||
/*
|
||||
Frame calculation
|
||||
*/
|
||||
float currentFrame = (float) glfwGetTime();
|
||||
deltaTime = currentFrame - lastFrame;
|
||||
lastFrame = currentFrame;
|
||||
|
||||
//poll mouse variables and update camera variables
|
||||
updateMouseVariables();
|
||||
|
||||
|
||||
float cam_Player_Orbit_Magnitude = 1f;
|
||||
float cam_Player_Orbit_Offset_Height = 1f;
|
||||
cam_Player_Orbit.pos_Center = new Vector3f(0, 0, 0);
|
||||
cam_Player_Orbit.pos_Center.x = 0 + (float) Math.cos(yaw / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
|
||||
cam_Player_Orbit.pos_Center.y = 0 + (float) Math.sin(pitch / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
|
||||
cam_Player_Orbit.pos_Center.z = 0 + (float) Math.sin(yaw / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
|
||||
cam_Player_Orbit.pos_Center.normalize();
|
||||
// System.out.println(cam_Player_Orbit.pos_Center);
|
||||
|
||||
|
||||
|
||||
if(CAMERA_IS_ORBIT){
|
||||
camera_Current = cam_Player_Orbit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// I N P U T C O N T R O L S
|
||||
///
|
||||
cameraSpeed = 2.5f * deltaTime;
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
break;
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) {
|
||||
if(CAMERA_UNDER_FREE_CONTROL) {
|
||||
//cameraSpeed = cameraSpeed * 100;
|
||||
} else if(PLAYER_UNDER_USER_CONTROL) {
|
||||
|
||||
}
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(-camera_Current.pos_Center.x,0,-camera_Current.pos_Center.z));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(camera_Current.pos_Center.x,0,camera_Current.pos_Center.z));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(-camera_Current.pos_Center.x,0,-camera_Current.pos_Center.z).rotateY((float)(-90 * Math.PI / 180)));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(-camera_Current.pos_Center.x,0,-camera_Current.pos_Center.z).rotateY((float)(90 * Math.PI / 180)));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(0,0.6f,0));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(0,-0.6f,0));
|
||||
}
|
||||
|
||||
|
||||
// camera_player_chase.pos_Center = new Vector3f(EntityUtil.getEntityPosition(player)).sub(EntityUtil.getEntityRotation(player).transform(new Vector3f(-1,1,0)));
|
||||
|
||||
Globals.cameraVisible.apply_camera(camera_player_chase);
|
||||
|
||||
Globals.viewMatrix = Globals.cameraVisible.get_view_matrix();
|
||||
Globals.viewMatrix = new Matrix4f().setLookAt(camera_Current.pos_Center, new Vector3f(0,0,0), new Vector3f(camera_Current.pos_Center).add(new Vector3f(0,1.0f,0))).scale(1.0f, 1.5f, 1.0f);
|
||||
|
||||
//Sets the background color.
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
//
|
||||
// Draw all entities
|
||||
//
|
||||
Iterator<Entity> entity_iterator = Globals.drawableList.iterator();
|
||||
while(entity_iterator.hasNext()){
|
||||
Entity currentEntity = entity_iterator.next();
|
||||
Model currentModel = EntityUtil.getEntityModel(currentEntity);
|
||||
currentModel.modelMatrix = new Matrix4f();
|
||||
currentModel.modelMatrix.translate(new Vector3f(EntityUtil.getEntityPosition(currentEntity)).sub(EntityUtil.getEntityPosition(player)));
|
||||
currentModel.modelMatrix.rotate(EntityUtil.getEntityRotation(currentEntity));
|
||||
currentModel.modelMatrix.scale(EntityUtil.getEntityScale(currentEntity));
|
||||
currentModel.draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//check and call events and swap the buffers
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
//Terminate the program.
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
static void sleep(int i) {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(i);
|
||||
} catch (InterruptedException ex) {
|
||||
System.out.println("Sleep somehow interrupted?!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void createOpenglContext(){
|
||||
//Sets the variables that control the window sizing
|
||||
int screenWidth = 1920;
|
||||
int screenHeight = 1080;
|
||||
//Initializes opengl
|
||||
glfwInit();
|
||||
//Gives hints to glfw to control how opengl will be used
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
//Creates the window reference object
|
||||
window = glfwCreateWindow(screenWidth, screenHeight, "LearnOpenGL", NULL, NULL);
|
||||
//Errors for failure to create window (IE: No GUI mode on linux ?)
|
||||
if (window == NULL) {
|
||||
System.out.println("Failed to make window.");
|
||||
glfwTerminate();
|
||||
}
|
||||
//Makes the window that was just created the current OS-level window context
|
||||
glfwMakeContextCurrent(window);
|
||||
//Maximize it
|
||||
glfwMaximizeWindow(window);
|
||||
//Creates the OpenGL capabilities for the program.
|
||||
GL.createCapabilities();
|
||||
|
||||
//This enables Z-buffering so that farther-back polygons are not drawn over nearer ones
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Support for transparency
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
//Hide the cursor and capture it
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
|
||||
|
||||
|
||||
|
||||
//Points the texture uniforms in the shader programs at the correct variables
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Projection and View matrix creation
|
||||
//
|
||||
Globals.projectionMatrix = new Matrix4f();
|
||||
Globals.viewMatrix = new Matrix4f();
|
||||
float FOV = (float)(120.0f * Math.PI /180.0f);
|
||||
Globals.projectionMatrix.setPerspective(FOV, 1.0f, 0.1f, view_Range);
|
||||
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
||||
}
|
||||
|
||||
|
||||
public static void updateMouseVariables(){
|
||||
glfwGetCursorPos(window, mouse_X_Buffer, mouse_Y_Buffer);
|
||||
xpos = mouse_X_Buffer[0];
|
||||
ypos = mouse_Y_Buffer[0];
|
||||
float xoffset = (float) (xpos - mouse_lastX) * mouseSensitivity;
|
||||
float yoffset = (float) (mouse_lastY - ypos) * mouseSensitivity;
|
||||
mouse_lastX = (float) xpos;
|
||||
mouse_lastY = (float) ypos;
|
||||
|
||||
yaw = yaw + xoffset;
|
||||
pitch = pitch - yoffset;
|
||||
|
||||
if (pitch > 100.0f) {
|
||||
pitch = 100.0f;
|
||||
}
|
||||
if (pitch < -99.0f) {
|
||||
pitch = -99.0f;
|
||||
}
|
||||
}
|
||||
|
||||
static void initSkybox(){
|
||||
Model skyboxModel = RenderUtils.createSkyboxModel(null);
|
||||
Entity skyboxEntity = EntityUtil.spawnDrawableEntity(skyboxModel);
|
||||
EntityUtil.getEntityScale(skyboxEntity).mul(100);
|
||||
|
||||
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void initWorld(){
|
||||
TerrainGen terrainGen = new TerrainGen();
|
||||
TerrainModel terrainModel = terrainGen.generateModel();
|
||||
float[][] elevation = terrainModel.getElevation();
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package net;
|
||||
package electrosphere.net;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package net;
|
||||
package electrosphere.net;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -1,11 +1,11 @@
|
||||
package util;
|
||||
package electrosphere.util;
|
||||
|
||||
import main.Globals;
|
||||
import RendererObjects.Material;
|
||||
import RendererObjects.Mesh;
|
||||
import RendererObjects.Model;
|
||||
import RendererObjects.texture.Texture;
|
||||
import RendererObjects.texture.TextureMap;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.RendererObjects.Material;
|
||||
import electrosphere.RendererObjects.Mesh;
|
||||
import electrosphere.RendererObjects.Model;
|
||||
import electrosphere.RendererObjects.texture.Texture;
|
||||
import electrosphere.RendererObjects.texture.TextureMap;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -43,7 +43,7 @@ public class ModelLoader {
|
||||
//this way if we change the underlying structure of the TextureMap it doesn't fuck over this logic
|
||||
static void attempt_add_textures_from_pathname(String path, Model m){
|
||||
//first we get the default texture map that's global
|
||||
TextureMap global_map = Globals.texture_map_default;
|
||||
TextureMap global_map = Globals.textureMapDefault;
|
||||
//then we try to get the path of our model from the map
|
||||
Map<String,ArrayList<String>> mesh_map = global_map.get_mesh_map(path);
|
||||
//if it exists..
|
||||
@ -65,7 +65,7 @@ public class ModelLoader {
|
||||
final_material.set_diffuse(diffuse);
|
||||
System.out.println(diffuse);
|
||||
} else {
|
||||
final_material.set_diffuse(Globals.texture_diffuse_default);
|
||||
final_material.set_diffuse(Globals.textureDiffuseDefault);
|
||||
}
|
||||
String specular_path = TextureMap.get_specular_path(texture_path_list);
|
||||
if(specular_path != null){
|
||||
@ -73,7 +73,7 @@ public class ModelLoader {
|
||||
final_material.set_specular(specular);
|
||||
System.out.println(specular);
|
||||
} else {
|
||||
final_material.set_specular(Globals.texture_specular_default);
|
||||
final_material.set_specular(Globals.textureSpecularDefault);
|
||||
}
|
||||
//once we've either added default textures or actual textures,
|
||||
//set the current mesh's material to this new one
|
||||
@ -1,11 +1,11 @@
|
||||
package util;
|
||||
package electrosphere.util;
|
||||
|
||||
import RendererObjects.Material;
|
||||
import RendererObjects.Mesh;
|
||||
import RendererObjects.Model;
|
||||
import RendererObjects.ShaderProgram;
|
||||
import RendererObjects.texture.Texture;
|
||||
import RendererObjects.texture.TextureMap;
|
||||
import electrosphere.RendererObjects.Material;
|
||||
import electrosphere.RendererObjects.Mesh;
|
||||
import electrosphere.RendererObjects.Model;
|
||||
import electrosphere.RendererObjects.ShaderProgram;
|
||||
import electrosphere.RendererObjects.texture.Texture;
|
||||
import electrosphere.RendererObjects.texture.TextureMap;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -1,93 +0,0 @@
|
||||
package main;
|
||||
|
||||
import RendererObjects.Camera;
|
||||
import RendererObjects.Light.DirectionalLight;
|
||||
import RendererObjects.Light.PointLight;
|
||||
import RendererObjects.Light.SpotLight;
|
||||
import RendererObjects.Material;
|
||||
import RendererObjects.Model;
|
||||
import RendererObjects.texture.Texture;
|
||||
import RendererObjects.texture.TextureMap;
|
||||
import com.google.gson.Gson;
|
||||
import entity.Entity;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import util.ModelLoader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Globals {
|
||||
|
||||
//
|
||||
//OpenGL - Other
|
||||
//
|
||||
//Array that holds all models that need to be shoved to the gpu
|
||||
public static Matrix4f viewMatrix = new Matrix4f();
|
||||
public static Matrix4f projectionMatrix;
|
||||
|
||||
|
||||
|
||||
public static Texture texture_diffuse_default;
|
||||
public static Texture texture_specular_default;
|
||||
public static Material material_default;
|
||||
|
||||
public static DirectionalLight light_directional_default;
|
||||
public static ArrayList<PointLight> light_point_list_default;
|
||||
public static SpotLight light_spot_default;
|
||||
|
||||
public static TextureMap texture_map_default;
|
||||
|
||||
public static ArrayList<Entity> entity_list;
|
||||
public static ArrayList<Entity> drawable_list;
|
||||
|
||||
public static Camera camera_visible;
|
||||
|
||||
//
|
||||
//Game specific models
|
||||
//
|
||||
|
||||
//famous fuckin last words, but temporary solution
|
||||
//global arraylist of values for the skybox colors
|
||||
public static ArrayList<Vector3f> skybox_colors;
|
||||
|
||||
|
||||
|
||||
public static void init_globals(){
|
||||
//create default textures
|
||||
texture_diffuse_default = new Texture("Textures/default_diffuse.png");
|
||||
texture_specular_default = new Texture("Textures/default_specular.png");
|
||||
//create default material
|
||||
material_default = new Material();
|
||||
material_default.set_diffuse(texture_diffuse_default);
|
||||
material_default.set_specular(texture_specular_default);
|
||||
//create default lights
|
||||
light_directional_default = new DirectionalLight(new Vector3f(0,-1f,0));
|
||||
//load in default texture map
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
//deserializes the texture map from its default path using gson
|
||||
//also done in one line
|
||||
texture_map_default = gson.fromJson(Files.newBufferedReader(new File(Thread.currentThread().getContextClassLoader().getResource("Textures/default_texture_map.json").getFile()).toPath()), TextureMap.class); //only the best of coding practices :)
|
||||
} catch (IOException ex) { ex.printStackTrace(); } //TODO: handle better :tm:
|
||||
//create entity list
|
||||
entity_list = new ArrayList();
|
||||
drawable_list = new ArrayList();
|
||||
//create the camera object that generates view matrix
|
||||
camera_visible = new Camera();
|
||||
//init game specific variables
|
||||
init_game_specifics();
|
||||
//temporary hold for skybox colors
|
||||
skybox_colors = new ArrayList();
|
||||
}
|
||||
|
||||
public static void init_game_specifics(){
|
||||
}
|
||||
}
|
||||
@ -1,564 +0,0 @@
|
||||
package main;
|
||||
|
||||
import RendererObjects.Camera;
|
||||
import RendererObjects.Material;
|
||||
import RendererObjects.Model;
|
||||
import RendererObjects.RenderUtils;
|
||||
import RendererObjects.ShaderProgram;
|
||||
import RendererObjects.texture.Texture;
|
||||
import entity.Entity;
|
||||
import entity.EntityUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.glfw.*;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import org.lwjgl.opengl.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL13.*;
|
||||
import static org.lwjgl.opengl.GL14.*;
|
||||
import static org.lwjgl.opengl.GL15.*;
|
||||
import static org.lwjgl.opengl.GL20.*;
|
||||
import static org.lwjgl.opengl.GL30.*;
|
||||
import static org.lwjgl.system.MemoryUtil.NULL;
|
||||
import util.ModelLoader;
|
||||
import util.util;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class Main {
|
||||
//
|
||||
//Generic OpenGL Statements
|
||||
//
|
||||
//Callback function for opengl errors
|
||||
private final static GLFWErrorCallback ERROR_CALLBACK = GLFWErrorCallback.createPrint(System.err);
|
||||
private static long window;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
//Visualization Controls
|
||||
//
|
||||
//These are used in calculating the time between frames for visualization (camera) control and such
|
||||
public static float deltaTime = 0.0f;
|
||||
public static float lastFrame = 0.0f;
|
||||
//View Controls
|
||||
public static float view_Range = 2000.0f;
|
||||
public static Camera camera_Current = new Camera();
|
||||
/*
|
||||
Mouse Controls
|
||||
*/
|
||||
static float mouse_lastX = 400;
|
||||
static float mouse_lastY = 300;
|
||||
static double xpos = 400;
|
||||
static double ypos = 300;
|
||||
static float mouseSensitivity = .1f;
|
||||
static double mouse_X_Buffer[] = new double[1];
|
||||
static double mouse_Y_Buffer[] = new double[1];
|
||||
static float cameraSpeed;
|
||||
static float yaw = 150;
|
||||
static float pitch = 50;
|
||||
|
||||
|
||||
|
||||
//
|
||||
//Player Object Variables
|
||||
//
|
||||
public static boolean CAMERA_UNDER_USER_CONTROL = false;
|
||||
public static boolean CAMERA_UNDER_FREE_CONTROL = false;
|
||||
public static boolean PLAYER_UNDER_USER_CONTROL = true;
|
||||
public static boolean CAMERA_IS_ORBIT = true;
|
||||
public static float camera_Orbit_Length = 1.0f;
|
||||
// public static Camera cam_Player_Orbit;
|
||||
//Camera angles using theta-phi system
|
||||
//Euler angles where theta is applied, then phi
|
||||
//There is no bank applied to the camera
|
||||
|
||||
public static Model model;
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String args[]){
|
||||
|
||||
//
|
||||
//
|
||||
// I N I T I A L I Z A T I O N
|
||||
//
|
||||
//
|
||||
|
||||
//run initialization stuff
|
||||
|
||||
//Create opengl
|
||||
create_opengl_context();
|
||||
|
||||
//init global variables
|
||||
Globals.init_globals();
|
||||
|
||||
|
||||
|
||||
|
||||
initWorld();
|
||||
|
||||
init_skybox();
|
||||
|
||||
|
||||
|
||||
Entity player = new Entity();
|
||||
player.getData().put("position", new Vector3f(0f,6f,0f));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// C A M E R A C R E A T I O N
|
||||
///
|
||||
Camera camera_player_chase = new Camera();
|
||||
Camera cam_Player_Orbit = new Camera();
|
||||
|
||||
|
||||
|
||||
//main loop
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
|
||||
/*
|
||||
Frame calculation
|
||||
*/
|
||||
float currentFrame = (float) glfwGetTime();
|
||||
deltaTime = currentFrame - lastFrame;
|
||||
lastFrame = currentFrame;
|
||||
|
||||
//poll mouse variables and update camera variables
|
||||
update_mouse_variables();
|
||||
|
||||
|
||||
float cam_Player_Orbit_Magnitude = 1f;
|
||||
float cam_Player_Orbit_Offset_Height = 1f;
|
||||
cam_Player_Orbit.pos_Center = new Vector3f(0, 0, 0);
|
||||
cam_Player_Orbit.pos_Center.x = 0 + (float) Math.cos(yaw / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
|
||||
cam_Player_Orbit.pos_Center.y = 0 + (float) Math.sin(pitch / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
|
||||
cam_Player_Orbit.pos_Center.z = 0 + (float) Math.sin(yaw / 180.0f * Math.PI) * cam_Player_Orbit_Magnitude;
|
||||
cam_Player_Orbit.pos_Center.normalize();
|
||||
// System.out.println(cam_Player_Orbit.pos_Center);
|
||||
|
||||
|
||||
|
||||
if(CAMERA_IS_ORBIT){
|
||||
camera_Current = cam_Player_Orbit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// I N P U T C O N T R O L S
|
||||
///
|
||||
cameraSpeed = 2.5f * deltaTime;
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||
break;
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) {
|
||||
if(CAMERA_UNDER_FREE_CONTROL) {
|
||||
//cameraSpeed = cameraSpeed * 100;
|
||||
} else if(PLAYER_UNDER_USER_CONTROL) {
|
||||
|
||||
}
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(-camera_Current.pos_Center.x,0,-camera_Current.pos_Center.z));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(camera_Current.pos_Center.x,0,camera_Current.pos_Center.z));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(-camera_Current.pos_Center.x,0,-camera_Current.pos_Center.z).rotateY((float)(-90 * Math.PI / 180)));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(-camera_Current.pos_Center.x,0,-camera_Current.pos_Center.z).rotateY((float)(90 * Math.PI / 180)));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(0,0.6f,0));
|
||||
}
|
||||
if(glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS){
|
||||
EntityUtil.getEntityPosition(player).add(new Vector3f(0,-0.6f,0));
|
||||
}
|
||||
|
||||
|
||||
// camera_player_chase.pos_Center = new Vector3f(EntityUtil.getEntityPosition(player)).sub(EntityUtil.getEntityRotation(player).transform(new Vector3f(-1,1,0)));
|
||||
|
||||
Globals.camera_visible.apply_camera(camera_player_chase);
|
||||
|
||||
Globals.viewMatrix = Globals.camera_visible.get_view_matrix();
|
||||
Globals.viewMatrix = new Matrix4f().setLookAt(camera_Current.pos_Center, new Vector3f(0,0,0), new Vector3f(camera_Current.pos_Center).add(new Vector3f(0,1.0f,0))).scale(1.0f, 1.5f, 1.0f);
|
||||
|
||||
//Sets the background color.
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
//
|
||||
// Draw all entities
|
||||
//
|
||||
Iterator<Entity> entity_iterator = Globals.drawable_list.iterator();
|
||||
while(entity_iterator.hasNext()){
|
||||
Entity currentEntity = entity_iterator.next();
|
||||
Model currentModel = EntityUtil.getEntityModel(currentEntity);
|
||||
currentModel.modelMatrix = new Matrix4f();
|
||||
currentModel.modelMatrix.translate(new Vector3f(EntityUtil.getEntityPosition(currentEntity)).sub(EntityUtil.getEntityPosition(player)));
|
||||
currentModel.modelMatrix.rotate(EntityUtil.getEntityRotation(currentEntity));
|
||||
currentModel.modelMatrix.scale(EntityUtil.getEntityScale(currentEntity));
|
||||
currentModel.draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//check and call events and swap the buffers
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
//Terminate the program.
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
static void sleep(int i) {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(i);
|
||||
} catch (InterruptedException ex) {
|
||||
System.out.println("Sleep somehow interrupted?!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void create_opengl_context(){
|
||||
//Sets the variables that control the window sizing
|
||||
int screenWidth = 1920;
|
||||
int screenHeight = 1080;
|
||||
//Initializes opengl
|
||||
glfwInit();
|
||||
//Gives hints to glfw to control how opengl will be used
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
//Creates the window reference object
|
||||
window = glfwCreateWindow(screenWidth, screenHeight, "LearnOpenGL", NULL, NULL);
|
||||
//Errors for failure to create window (IE: No GUI mode on linux ?)
|
||||
if (window == NULL) {
|
||||
System.out.println("Failed to make window.");
|
||||
glfwTerminate();
|
||||
}
|
||||
//Makes the window that was just created the current OS-level window context
|
||||
glfwMakeContextCurrent(window);
|
||||
//Maximize it
|
||||
glfwMaximizeWindow(window);
|
||||
//Creates the OpenGL capabilities for the program.
|
||||
GL.createCapabilities();
|
||||
|
||||
//This enables Z-buffering so that farther-back polygons are not drawn over nearer ones
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
// Support for transparency
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
//Hide the cursor and capture it
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Points the texture uniforms in the shader programs at the correct variables
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Projection and View matrix creation
|
||||
//
|
||||
Globals.projectionMatrix = new Matrix4f();
|
||||
Globals.viewMatrix = new Matrix4f();
|
||||
float FOV = (float)(120.0f * Math.PI /180.0f);
|
||||
Globals.projectionMatrix.setPerspective(FOV, 1.0f, 0.1f, view_Range);
|
||||
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
||||
}
|
||||
|
||||
|
||||
public static void update_mouse_variables(){
|
||||
glfwGetCursorPos(window, mouse_X_Buffer, mouse_Y_Buffer);
|
||||
xpos = mouse_X_Buffer[0];
|
||||
ypos = mouse_Y_Buffer[0];
|
||||
float xoffset = (float) (xpos - mouse_lastX) * mouseSensitivity;
|
||||
float yoffset = (float) (mouse_lastY - ypos) * mouseSensitivity;
|
||||
mouse_lastX = (float) xpos;
|
||||
mouse_lastY = (float) ypos;
|
||||
|
||||
yaw = yaw + xoffset;
|
||||
pitch = pitch - yoffset;
|
||||
|
||||
if (pitch > 100.0f) {
|
||||
pitch = 100.0f;
|
||||
}
|
||||
if (pitch < -99.0f) {
|
||||
pitch = -99.0f;
|
||||
}
|
||||
}
|
||||
|
||||
static void init_skybox(){
|
||||
Model skyboxModel = RenderUtils.createSkyboxModel(null);
|
||||
Entity skyboxEntity = EntityUtil.spawnDrawableEntity(skyboxModel);
|
||||
EntityUtil.getEntityScale(skyboxEntity).mul(100);
|
||||
|
||||
|
||||
Globals.skybox_colors.add(new Vector3f(200,200,160));
|
||||
Globals.skybox_colors.add(new Vector3f(200,200,160));
|
||||
Globals.skybox_colors.add(new Vector3f(200,100,50));
|
||||
Globals.skybox_colors.add(new Vector3f(200,100,50));
|
||||
Globals.skybox_colors.add(new Vector3f(50,100,150));
|
||||
Globals.skybox_colors.add(new Vector3f(50,100,150));
|
||||
Globals.skybox_colors.add(new Vector3f(10,10,10));
|
||||
Globals.skybox_colors.add(new Vector3f(10,10,10));
|
||||
}
|
||||
|
||||
|
||||
//I swear it's a temporary function
|
||||
/*
|
||||
for(int angle = 0; angle < 45; angle=angle+2){
|
||||
for(int radius = 115; radius < 130; radius=radius+2){
|
||||
*/
|
||||
// static float[] getTreePos(){
|
||||
// return new float[]{
|
||||
// 115.0f,7.0f,0.0f,
|
||||
// 110.0f,7.0f,10.0f,
|
||||
//
|
||||
// 82.0f,7.0f,82.0f,
|
||||
// };
|
||||
// }
|
||||
|
||||
static void initWorld(){
|
||||
Model building_model = ModelLoader.load_Model_From_File("Models/arcdock5deg1Try2.fbx");
|
||||
Texture whiteTexture = new Texture("Textures/w1.png");
|
||||
Material whiteMaterial = new Material();
|
||||
whiteMaterial.set_diffuse(whiteTexture);
|
||||
whiteMaterial.set_specular(whiteTexture);
|
||||
building_model.meshes.get(0).set_material(whiteMaterial);
|
||||
for(int i = 0; i < 36; i++){
|
||||
Entity arcCurrent = EntityUtil.spawnDrawableEntity(building_model);
|
||||
float angleRad = i * 10;
|
||||
float angleDeg = (float)(angleRad * Math.PI / 180);
|
||||
float posX = (float)(Math.cos(angleDeg) * 100);
|
||||
float posY = (float)(Math.sin(angleDeg) * 100);
|
||||
EntityUtil.getEntityPosition(arcCurrent).set(posX, 0.01f, posY);
|
||||
EntityUtil.getEntityScale(arcCurrent).set(1f);
|
||||
EntityUtil.getEntityRotation(arcCurrent)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)((180-angleRad) * Math.PI / 180))
|
||||
;
|
||||
arcCurrent = EntityUtil.spawnDrawableEntity(building_model);
|
||||
angleRad = i * 10 + 5;
|
||||
angleDeg = (float)(angleRad * Math.PI / 180);
|
||||
posX = (float)(Math.cos(angleDeg) * 100);
|
||||
posY = (float)(Math.sin(angleDeg) * 100);
|
||||
EntityUtil.getEntityPosition(arcCurrent).set(posX, 5.01f, posY);
|
||||
EntityUtil.getEntityScale(arcCurrent).set(1f);
|
||||
EntityUtil.getEntityRotation(arcCurrent)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)((180-angleRad) * Math.PI / 180))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Model dirtPlane = ModelLoader.load_Model_From_File("Models/groundplanemassiveuv.fbx");
|
||||
Texture dirtTexture = new Texture("Textures/Ground/Dirt1.png");
|
||||
Material dirtMaterial = new Material();
|
||||
dirtMaterial.set_diffuse(dirtTexture);
|
||||
dirtMaterial.set_specular(dirtTexture);
|
||||
dirtPlane.meshes.get(0).set_material(dirtMaterial);
|
||||
for(int x = -120; x < 120; x=x+20){
|
||||
for(int y = -120; y < 120; y=y+20){
|
||||
Entity dirtPlaneEntity = EntityUtil.spawnDrawableEntity(dirtPlane);
|
||||
EntityUtil.getEntityPosition(dirtPlaneEntity).set(x, -1.0f, y);
|
||||
EntityUtil.getEntityScale(dirtPlaneEntity).set(10f);
|
||||
EntityUtil.getEntityRotation(dirtPlaneEntity)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Model tree2 = ModelLoader.load_Model_From_File("Models/tree2.fbx");
|
||||
Texture leavesTexture = new Texture("Textures/leaves.png");
|
||||
Material leavesMaterial = new Material();
|
||||
leavesMaterial.set_diffuse(leavesTexture);
|
||||
leavesMaterial.set_specular(leavesTexture);
|
||||
Texture trunkTexture = new Texture("Textures/trunk.png");
|
||||
Material trunkMaterial = new Material();
|
||||
trunkMaterial.set_diffuse(trunkTexture);
|
||||
trunkMaterial.set_specular(trunkTexture);
|
||||
tree2.meshes.get(0).set_material(trunkMaterial);
|
||||
tree2.meshes.get(1).set_material(leavesMaterial);
|
||||
tree2.meshes.get(2).set_material(leavesMaterial);
|
||||
Random treeRand = new Random();
|
||||
|
||||
ArrayList<Entity> treeList = new ArrayList();
|
||||
for(int angle = -105; angle < 45; angle=angle+2){
|
||||
for(int radius = 115; radius < 140; radius=radius+2){
|
||||
Entity treeEntity = EntityUtil.spawnDrawableEntity(tree2);
|
||||
EntityUtil.getEntityPosition(treeEntity).set(
|
||||
(float)Math.cos(angle * Math.PI / 180) * radius + (treeRand.nextFloat() - 0.5f) * 2,
|
||||
radius - 113 + treeRand.nextFloat(),
|
||||
(float)Math.sin(angle * Math.PI / 180) * radius + (treeRand.nextFloat() - 0.5f) * 2
|
||||
);
|
||||
EntityUtil.getEntityScale(treeEntity).set(1f);
|
||||
EntityUtil.getEntityRotation(treeEntity)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)((treeRand.nextFloat() * 359) * Math.PI / 180))
|
||||
;
|
||||
treeList.add(treeEntity);
|
||||
}
|
||||
}
|
||||
// float[] treepos = getTreePos();
|
||||
// for(int i = 0; i < treepos.length/3; i++){
|
||||
// float posX = treepos[i*3];
|
||||
// float posY = treepos[i*3+1];
|
||||
// float posZ = treepos[i*3+2];
|
||||
// Entity treeEntity = EntityUtil.spawnDrawableEntity(tree2);
|
||||
// EntityUtil.getEntityPosition(treeEntity).set(posX,posY,posZ);
|
||||
// EntityUtil.getEntityScale(treeEntity).set(1f);
|
||||
// EntityUtil.getEntityRotation(treeEntity)
|
||||
// .identity()
|
||||
// .rotateLocalX((float)(-Math.PI / 2))
|
||||
// .rotateLocalY((float)((treeRand.nextFloat() * 359) * Math.PI / 180))
|
||||
// ;
|
||||
// treeList.add(treeEntity);
|
||||
// }
|
||||
|
||||
Model arenaSpire = ModelLoader.load_Model_From_File("Models/ArenaSpire1.fbx");
|
||||
arenaSpire.meshes.get(0).set_material(whiteMaterial);
|
||||
Entity spireEntity = EntityUtil.spawnDrawableEntity(arenaSpire);
|
||||
EntityUtil.getEntityRotation(spireEntity)
|
||||
.identity()
|
||||
.rotateLocalZ((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(220) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(spireEntity).set(-105, 0, 0);
|
||||
|
||||
Model railTrackModel = ModelLoader.load_Model_From_File("Models/RailTrack1Part1.fbx");
|
||||
Texture railTrackTexture = new Texture("Textures/RailTrack1Part1.png");
|
||||
Material railTrackMaterial = new Material();
|
||||
railTrackMaterial.set_diffuse(railTrackTexture);
|
||||
railTrackMaterial.set_specular(railTrackTexture);
|
||||
railTrackModel.meshes.get(0).set_material(railTrackMaterial);
|
||||
Entity railTrackEntity = EntityUtil.spawnDrawableEntity(railTrackModel);
|
||||
EntityUtil.getEntityRotation(railTrackEntity)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(0) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(railTrackEntity).set(-15, 10, -20);
|
||||
|
||||
Model railSupportModel = ModelLoader.load_Model_From_File("Models/MonorailSupport.fbx");
|
||||
Texture railSupportTexture = new Texture("Textures/MonorailSupport.png");
|
||||
Material railSupportMaterial = new Material();
|
||||
railSupportMaterial.set_diffuse(railSupportTexture);
|
||||
railSupportMaterial.set_specular(railSupportTexture);
|
||||
railSupportModel.meshes.get(0).set_material(railSupportMaterial);
|
||||
|
||||
//support 1
|
||||
Entity railSupport1 = EntityUtil.spawnDrawableEntity(railSupportModel);
|
||||
EntityUtil.getEntityRotation(railSupport1)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(180) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(railSupport1).set(0, -71.5f, -125);
|
||||
|
||||
//support 2
|
||||
Entity railSupport2 = EntityUtil.spawnDrawableEntity(railSupportModel);
|
||||
EntityUtil.getEntityRotation(railSupport2)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(200) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(railSupport2).set(30, -69.5f, -115);
|
||||
|
||||
//support 3
|
||||
Entity railSupport3 = EntityUtil.spawnDrawableEntity(railSupportModel);
|
||||
EntityUtil.getEntityRotation(railSupport3)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(217) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(railSupport3).set(62, -65.5f, -95);
|
||||
|
||||
//support 4
|
||||
Entity railSupport4 = EntityUtil.spawnDrawableEntity(railSupportModel);
|
||||
EntityUtil.getEntityRotation(railSupport4)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(222) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(railSupport4).set(90, -61f, -70);
|
||||
|
||||
//support 5
|
||||
Entity railSupport5 = EntityUtil.spawnDrawableEntity(railSupportModel);
|
||||
EntityUtil.getEntityRotation(railSupport5)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(235) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(railSupport5).set(121, -57.5f, -25);
|
||||
|
||||
//support 6
|
||||
Entity railSupport6 = EntityUtil.spawnDrawableEntity(railSupportModel);
|
||||
EntityUtil.getEntityRotation(railSupport6)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(265) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(railSupport6).set(135, -58.5f, 30);
|
||||
|
||||
|
||||
Model tallBuildingModel = ModelLoader.load_Model_From_File("Models/tallbuilding1.fbx");
|
||||
tallBuildingModel.meshes.get(0).set_material(whiteMaterial);
|
||||
Entity tallBuildingEntity1 = EntityUtil.spawnDrawableEntity(tallBuildingModel);
|
||||
EntityUtil.getEntityRotation(tallBuildingEntity1)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(0) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(tallBuildingEntity1).set(200, 0.0f, -80);
|
||||
EntityUtil.getEntityScale(tallBuildingEntity1).set(0.6f, 0.6f, 1f);
|
||||
|
||||
Entity tallBuildingEntity2 = EntityUtil.spawnDrawableEntity(tallBuildingModel);
|
||||
EntityUtil.getEntityRotation(tallBuildingEntity2)
|
||||
.identity()
|
||||
.rotateLocalX((float)(-Math.PI / 2))
|
||||
.rotateLocalY((float)(-(35) * Math.PI / 180))
|
||||
;
|
||||
EntityUtil.getEntityPosition(tallBuildingEntity2).set(190, 10.0f, 10.0f);
|
||||
EntityUtil.getEntityScale(tallBuildingEntity2).set(0.5f, 0.5f, 1f);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
#version 430 core
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
struct Material {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//Vertex Shader
|
||||
#version 430 core
|
||||
#version 330 core
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//Vertex Shader
|
||||
#version 430 core
|
||||
#version 330 core
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
#version 430 core
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//Vertex Shader
|
||||
#version 430 core
|
||||
#version 330 core
|
||||
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |