rendering code cleanup work
This commit is contained in:
parent
5507a5c261
commit
69af65ab53
@ -1886,6 +1886,8 @@ Support lack of macro data for chunk gens
|
|||||||
Support multichunk select all blocks
|
Support multichunk select all blocks
|
||||||
More block types
|
More block types
|
||||||
New door furniture item
|
New door furniture item
|
||||||
|
Commenting rendering classes
|
||||||
|
Convert Mesh.java to only use GL45
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -44,35 +44,55 @@ public class Actor {
|
|||||||
*/
|
*/
|
||||||
public static final int INVALID_ANIMATION = -1;
|
public static final int INVALID_ANIMATION = -1;
|
||||||
|
|
||||||
//the model path of the model backing the actor
|
/**
|
||||||
|
* the model path of the model backing the actor
|
||||||
|
*/
|
||||||
String modelPath;
|
String modelPath;
|
||||||
|
|
||||||
//used for statically binding textures in pipelines that dont bind textures on a per-mesh level
|
/**
|
||||||
//ie when in the ui, this can be set to bind a texture at the actor level
|
* used for statically binding textures in pipelines that dont bind textures on a per-mesh level
|
||||||
|
* ie when in the ui, this can be set to bind a texture at the actor level
|
||||||
|
*/
|
||||||
String textureOverride;
|
String textureOverride;
|
||||||
|
|
||||||
//scales the time that animations are played at
|
/**
|
||||||
|
* scales the time that animations are played at
|
||||||
|
*/
|
||||||
float animationScalar = 1.0f;
|
float animationScalar = 1.0f;
|
||||||
|
|
||||||
//The stack of animations being applied to a given actor
|
/**
|
||||||
|
* The stack of animations being applied to a given actor
|
||||||
|
*/
|
||||||
Set<ActorAnimationMask> animationQueue = new TreeSet<ActorAnimationMask>();
|
Set<ActorAnimationMask> animationQueue = new TreeSet<ActorAnimationMask>();
|
||||||
|
|
||||||
//Mask for overwriting meshes in a given actor
|
/**
|
||||||
|
* Mask for overwriting meshes in a given actor
|
||||||
|
*/
|
||||||
ActorMeshMask meshMask = new ActorMeshMask();
|
ActorMeshMask meshMask = new ActorMeshMask();
|
||||||
|
|
||||||
//optional overrides for specific shaders
|
/**
|
||||||
|
* optional overrides for specific shaders
|
||||||
|
*/
|
||||||
List<ActorShaderMask> shaderMasks = new LinkedList<ActorShaderMask>();
|
List<ActorShaderMask> shaderMasks = new LinkedList<ActorShaderMask>();
|
||||||
|
|
||||||
//optional overrides for textures
|
/**
|
||||||
|
* optional overrides for textures
|
||||||
|
*/
|
||||||
Map<String,ActorTextureMask> textureMap = null;
|
Map<String,ActorTextureMask> textureMap = null;
|
||||||
|
|
||||||
//bone rotators
|
/**
|
||||||
|
* bone rotators
|
||||||
|
*/
|
||||||
Map<String,ActorBoneRotator> boneRotators = new HashMap<String,ActorBoneRotator>();
|
Map<String,ActorBoneRotator> boneRotators = new HashMap<String,ActorBoneRotator>();
|
||||||
|
|
||||||
//static morph for this specific actor
|
/**
|
||||||
|
* static morph for this specific actor
|
||||||
|
*/
|
||||||
ActorStaticMorph staticMorph;
|
ActorStaticMorph staticMorph;
|
||||||
|
|
||||||
//The list of bone groups
|
/**
|
||||||
|
* The list of bone groups
|
||||||
|
*/
|
||||||
List<BoneGroup> boneGroups;
|
List<BoneGroup> boneGroups;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +100,9 @@ public class Actor {
|
|||||||
*/
|
*/
|
||||||
ActorUniformMap uniformMap = new ActorUniformMap();
|
ActorUniformMap uniformMap = new ActorUniformMap();
|
||||||
|
|
||||||
//Controls whether the actor should obey frustum culling
|
/**
|
||||||
|
* Controls whether the actor should obey frustum culling
|
||||||
|
*/
|
||||||
boolean frustumCull = true;
|
boolean frustumCull = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -25,24 +25,6 @@ import org.joml.Vector3d;
|
|||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
import org.joml.Vector3i;
|
import org.joml.Vector3i;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL15;
|
|
||||||
import org.lwjgl.opengl.GL40;
|
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_INT;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_INT;
|
|
||||||
import static org.lwjgl.opengl.GL15.GL_ARRAY_BUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL15.GL_ELEMENT_ARRAY_BUFFER;
|
|
||||||
import static org.lwjgl.opengl.GL15.GL_STATIC_DRAW;
|
|
||||||
import static org.lwjgl.opengl.GL15.glBindBuffer;
|
|
||||||
import static org.lwjgl.opengl.GL15.glGenBuffers;
|
|
||||||
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
|
|
||||||
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
|
||||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
|
||||||
import static org.lwjgl.opengl.GL30.glGenVertexArrays;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL45;
|
import org.lwjgl.opengl.GL45;
|
||||||
import org.lwjgl.system.MemoryStack;
|
import org.lwjgl.system.MemoryStack;
|
||||||
@ -52,24 +34,64 @@ import org.lwjgl.system.MemoryStack;
|
|||||||
*/
|
*/
|
||||||
public class Mesh {
|
public class Mesh {
|
||||||
|
|
||||||
//the name of the mesh
|
/**
|
||||||
|
* The name of this mesh
|
||||||
|
*/
|
||||||
private String meshName;
|
private String meshName;
|
||||||
|
|
||||||
//THIS IS NOT GUARANTEED TO BE THE PARENT MODEL THAT THIS WAS LOADED IN
|
/**
|
||||||
//THIS CAN BE POST-LOAD SET IN MODEL VIA MODELMASK BEHAVIOR
|
* The parent model
|
||||||
|
* <p>
|
||||||
|
* THIS IS NOT GUARANTEED TO BE THE PARENT MODEL THAT THIS WAS LOADED IN
|
||||||
|
* THIS CAN BE POST-LOAD SET IN MODEL VIA MODELMASK BEHAVIOR
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
private Model parent;
|
private Model parent;
|
||||||
|
|
||||||
//various buffers that may or may not be allocated
|
//various buffers that may or may not be allocated
|
||||||
|
/**
|
||||||
|
* Pointer to the vertex buffer
|
||||||
|
*/
|
||||||
private int vertexBuffer;
|
private int vertexBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the normal buffer
|
||||||
|
*/
|
||||||
private int normalBuffer;
|
private int normalBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the element array buffer
|
||||||
|
*/
|
||||||
private int elementArrayBuffer;
|
private int elementArrayBuffer;
|
||||||
private int elementCount; //pulls double duty as both the element array count as well as the direct array count, based on whichever is used
|
|
||||||
|
/**
|
||||||
|
* pulls double duty as both the element array count as well as the direct array count, based on whichever is used
|
||||||
|
*/
|
||||||
|
private int elementCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the VAO
|
||||||
|
*/
|
||||||
private int vertexArrayObject;
|
private int vertexArrayObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the bone weight buffer
|
||||||
|
*/
|
||||||
private int boneWeightBuffer;
|
private int boneWeightBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the bone index buffer
|
||||||
|
*/
|
||||||
private int boneIndexBuffer;
|
private int boneIndexBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the texture coordinate buffer
|
||||||
|
*/
|
||||||
private int textureCoordBuffer;
|
private int textureCoordBuffer;
|
||||||
|
|
||||||
//uses element instances
|
/**
|
||||||
|
* Tracks whether the mesh uses element instances or not
|
||||||
|
*/
|
||||||
private boolean useElementArray = true;
|
private boolean useElementArray = true;
|
||||||
|
|
||||||
|
|
||||||
@ -78,20 +100,34 @@ public class Mesh {
|
|||||||
private List<Bone> bones = new ArrayList<Bone>();
|
private List<Bone> bones = new ArrayList<Bone>();
|
||||||
private ArrayList<String> boneIdList = new ArrayList<String>();
|
private ArrayList<String> boneIdList = new ArrayList<String>();
|
||||||
|
|
||||||
//the texture mask that may or may not be masking the mesh
|
/**
|
||||||
|
* the texture mask that may or may not be masking the mesh
|
||||||
|
*/
|
||||||
private ActorTextureMask textureMask;
|
private ActorTextureMask textureMask;
|
||||||
|
|
||||||
//the shaders currently associated with the mesh
|
/**
|
||||||
|
* The main shader for the mesh
|
||||||
|
*/
|
||||||
private VisualShader shader;
|
private VisualShader shader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The OIT shader
|
||||||
|
*/
|
||||||
private VisualShader oitShader;
|
private VisualShader oitShader;
|
||||||
|
|
||||||
//the uniforms to be sent to the gpu
|
/**
|
||||||
|
* the uniforms to be sent to the gpu
|
||||||
|
*/
|
||||||
private HashMap<String,Object> uniforms = new HashMap<String,Object>();
|
private HashMap<String,Object> uniforms = new HashMap<String,Object>();
|
||||||
|
|
||||||
//the material currently associated with the mesh
|
/**
|
||||||
|
* the material currently associated with the mesh
|
||||||
|
*/
|
||||||
private Material material;
|
private Material material;
|
||||||
|
|
||||||
//the bounding sphere for this mesh
|
/**
|
||||||
|
* the bounding sphere for this mesh
|
||||||
|
*/
|
||||||
private Sphered boundingSphere;
|
private Sphered boundingSphere;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,15 +143,15 @@ public class Mesh {
|
|||||||
* Generates the VAO for this mesh
|
* Generates the VAO for this mesh
|
||||||
*/
|
*/
|
||||||
public void generateVAO(){
|
public void generateVAO(){
|
||||||
vertexArrayObject = glGenVertexArrays();
|
vertexArrayObject = GL45.glGenVertexArrays();
|
||||||
glBindVertexArray(vertexArrayObject);
|
GL45.glBindVertexArray(vertexArrayObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees this mesh
|
* Frees this mesh
|
||||||
*/
|
*/
|
||||||
public void free(){
|
public void free(){
|
||||||
GL40.glDeleteBuffers(new int[]{
|
GL45.glDeleteBuffers(new int[]{
|
||||||
vertexBuffer,
|
vertexBuffer,
|
||||||
normalBuffer,
|
normalBuffer,
|
||||||
elementArrayBuffer,
|
elementArrayBuffer,
|
||||||
@ -123,7 +159,7 @@ public class Mesh {
|
|||||||
boneIndexBuffer,
|
boneIndexBuffer,
|
||||||
textureCoordBuffer,
|
textureCoordBuffer,
|
||||||
});
|
});
|
||||||
GL40.glDeleteVertexArrays(vertexArrayObject);
|
GL45.glDeleteVertexArrays(vertexArrayObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,9 +191,9 @@ public class Mesh {
|
|||||||
*/
|
*/
|
||||||
public void bufferFaces(IntBuffer faces, int elementCount){
|
public void bufferFaces(IntBuffer faces, int elementCount){
|
||||||
if(!EngineState.EngineFlags.HEADLESS){
|
if(!EngineState.EngineFlags.HEADLESS){
|
||||||
elementArrayBuffer = glGenBuffers();
|
elementArrayBuffer = GL45.glGenBuffers();
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementArrayBuffer);
|
GL45.glBindBuffer(GL45.GL_ELEMENT_ARRAY_BUFFER, elementArrayBuffer);
|
||||||
GL15.glBufferData(GL_ELEMENT_ARRAY_BUFFER, faces, GL_STATIC_DRAW);
|
GL45.glBufferData(GL45.GL_ELEMENT_ARRAY_BUFFER, faces, GL45.GL_STATIC_DRAW);
|
||||||
this.elementCount = elementCount;
|
this.elementCount = elementCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,11 +222,11 @@ public class Mesh {
|
|||||||
* @param buffer The buffer containing the bone indices
|
* @param buffer The buffer containing the bone indices
|
||||||
*/
|
*/
|
||||||
public void bufferBoneIndices(FloatBuffer buffer){
|
public void bufferBoneIndices(FloatBuffer buffer){
|
||||||
boneIndexBuffer = glGenBuffers();
|
boneIndexBuffer = GL45.glGenBuffers();
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, boneIndexBuffer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, boneIndexBuffer);
|
||||||
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
|
GL45.glBufferData(GL45.GL_ARRAY_BUFFER, buffer, GL45.GL_STATIC_DRAW);
|
||||||
glVertexAttribPointer(3, 4, GL_FLOAT, false, 0, 0);
|
GL45.glVertexAttribPointer(3, 4, GL45.GL_FLOAT, false, 0, 0);
|
||||||
glEnableVertexAttribArray(3);
|
GL45.glEnableVertexAttribArray(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,11 +234,11 @@ public class Mesh {
|
|||||||
* @param buffer The buffer containing the bone weights
|
* @param buffer The buffer containing the bone weights
|
||||||
*/
|
*/
|
||||||
public void bufferBoneWeights(FloatBuffer buffer){
|
public void bufferBoneWeights(FloatBuffer buffer){
|
||||||
boneWeightBuffer = glGenBuffers();
|
boneWeightBuffer = GL45.glGenBuffers();
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, boneWeightBuffer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, boneWeightBuffer);
|
||||||
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
|
GL45.glBufferData(GL45.GL_ARRAY_BUFFER, buffer, GL45.GL_STATIC_DRAW);
|
||||||
glVertexAttribPointer(2, 4, GL_FLOAT, false, 0, 0);
|
GL45.glVertexAttribPointer(2, 4, GL45.GL_FLOAT, false, 0, 0);
|
||||||
glEnableVertexAttribArray(2);
|
GL45.glEnableVertexAttribArray(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,11 +251,11 @@ public class Mesh {
|
|||||||
public int bufferCustomFloatAttribArray(FloatBuffer buffer, int bufferDimension, int attribIndex){
|
public int bufferCustomFloatAttribArray(FloatBuffer buffer, int bufferDimension, int attribIndex){
|
||||||
int bufferPointer = 0;
|
int bufferPointer = 0;
|
||||||
if(!EngineState.EngineFlags.HEADLESS){
|
if(!EngineState.EngineFlags.HEADLESS){
|
||||||
bufferPointer = glGenBuffers();
|
bufferPointer = GL45.glGenBuffers();
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
|
GL45.glBufferData(GL45.GL_ARRAY_BUFFER, buffer, GL45.GL_STATIC_DRAW);
|
||||||
glVertexAttribPointer(attribIndex, bufferDimension, GL_FLOAT, false, 0, 0);
|
GL45.glVertexAttribPointer(attribIndex, bufferDimension, GL45.GL_FLOAT, false, 0, 0);
|
||||||
glEnableVertexAttribArray(attribIndex);
|
GL45.glEnableVertexAttribArray(attribIndex);
|
||||||
}
|
}
|
||||||
return bufferPointer;
|
return bufferPointer;
|
||||||
}
|
}
|
||||||
@ -234,11 +270,11 @@ public class Mesh {
|
|||||||
public int bufferCustomIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){
|
public int bufferCustomIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){
|
||||||
int bufferPointer = 0;
|
int bufferPointer = 0;
|
||||||
if(!EngineState.EngineFlags.HEADLESS){
|
if(!EngineState.EngineFlags.HEADLESS){
|
||||||
bufferPointer = glGenBuffers();
|
bufferPointer = GL45.glGenBuffers();
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
|
GL45.glBufferData(GL45.GL_ARRAY_BUFFER, buffer, GL45.GL_STATIC_DRAW);
|
||||||
GL40.glVertexAttribIPointer(attribIndex, bufferDimension, GL_INT, 0, 0);
|
GL45.glVertexAttribIPointer(attribIndex, bufferDimension, GL45.GL_INT, 0, 0);
|
||||||
glEnableVertexAttribArray(attribIndex);
|
GL45.glEnableVertexAttribArray(attribIndex);
|
||||||
}
|
}
|
||||||
return bufferPointer;
|
return bufferPointer;
|
||||||
}
|
}
|
||||||
@ -254,11 +290,11 @@ public class Mesh {
|
|||||||
public int bufferCustomUIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){
|
public int bufferCustomUIntAttribArray(IntBuffer buffer, int bufferDimension, int attribIndex){
|
||||||
int bufferPointer = 0;
|
int bufferPointer = 0;
|
||||||
if(!EngineState.EngineFlags.HEADLESS){
|
if(!EngineState.EngineFlags.HEADLESS){
|
||||||
bufferPointer = glGenBuffers();
|
bufferPointer = GL45.glGenBuffers();
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, bufferPointer);
|
GL45.glBindBuffer(GL45.GL_ARRAY_BUFFER, bufferPointer);
|
||||||
GL15.glBufferData(GL_ARRAY_BUFFER, buffer, GL_STATIC_DRAW);
|
GL45.glBufferData(GL45.GL_ARRAY_BUFFER, buffer, GL45.GL_STATIC_DRAW);
|
||||||
GL40.glVertexAttribIPointer(attribIndex, bufferDimension, GL_UNSIGNED_INT, 0, 0);
|
GL45.glVertexAttribIPointer(attribIndex, bufferDimension, GL45.GL_UNSIGNED_INT, 0, 0);
|
||||||
glEnableVertexAttribArray(attribIndex);
|
GL45.glEnableVertexAttribArray(attribIndex);
|
||||||
}
|
}
|
||||||
return bufferPointer;
|
return bufferPointer;
|
||||||
}
|
}
|
||||||
@ -313,7 +349,7 @@ public class Mesh {
|
|||||||
uniforms.put(key, o);
|
uniforms.put(key, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bufferAllUniforms(OpenGLState openGLState){
|
private void bufferAllUniforms(OpenGLState openGLState){
|
||||||
for(String key : uniforms.keySet()){
|
for(String key : uniforms.keySet()){
|
||||||
Object currentUniformRaw = uniforms.get(key);
|
Object currentUniformRaw = uniforms.get(key);
|
||||||
if(currentUniformRaw instanceof Matrix4f){
|
if(currentUniformRaw instanceof Matrix4f){
|
||||||
@ -350,7 +386,7 @@ public class Mesh {
|
|||||||
Globals.profiler.beginAggregateCpuSample("Mesh.complexDraw");
|
Globals.profiler.beginAggregateCpuSample("Mesh.complexDraw");
|
||||||
|
|
||||||
//bind vao off the rip
|
//bind vao off the rip
|
||||||
GL40.glBindVertexArray(vertexArrayObject);
|
GL45.glBindVertexArray(vertexArrayObject);
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
|
|
||||||
if(renderPipelineState.getUseMeshShader()){
|
if(renderPipelineState.getUseMeshShader()){
|
||||||
@ -441,9 +477,9 @@ public class Mesh {
|
|||||||
|
|
||||||
if(renderPipelineState.getUseShadowMap()){
|
if(renderPipelineState.getUseShadowMap()){
|
||||||
int shadowMapTextureUnit = 3;
|
int shadowMapTextureUnit = 3;
|
||||||
openGLState.glActiveTexture(GL40.GL_TEXTURE0 + shadowMapTextureUnit);
|
openGLState.glActiveTexture(GL45.GL_TEXTURE0 + shadowMapTextureUnit);
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
openGLState.glBindTexture(GL_TEXTURE_2D, RenderingEngine.lightBufferDepthTexture.getTexturePointer());
|
openGLState.glBindTexture(GL45.GL_TEXTURE_2D, RenderingEngine.lightBufferDepthTexture.getTexturePointer());
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
openGLState.getActiveShader().setUniform(openGLState, "shadowMap", shadowMapTextureUnit);
|
openGLState.getActiveShader().setUniform(openGLState, "shadowMap", shadowMapTextureUnit);
|
||||||
}
|
}
|
||||||
@ -509,23 +545,23 @@ public class Mesh {
|
|||||||
|
|
||||||
if(renderPipelineState.getInstanced()){
|
if(renderPipelineState.getInstanced()){
|
||||||
if(elementCount > 0 ){
|
if(elementCount > 0 ){
|
||||||
GL45.glDrawElementsInstanced(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, renderPipelineState.getInstanceCount());
|
GL45.glDrawElementsInstanced(GL45.GL_TRIANGLES, elementCount, GL45.GL_UNSIGNED_INT, 0, renderPipelineState.getInstanceCount());
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(useElementArray){
|
if(useElementArray){
|
||||||
if(elementCount > 0){
|
if(elementCount > 0){
|
||||||
GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
GL45.glDrawElements(GL45.GL_TRIANGLES, elementCount, GL45.GL_UNSIGNED_INT, 0);
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(elementCount > 0){
|
if(elementCount > 0){
|
||||||
GL11.glDrawArrays(GL_TRIANGLES, 0, elementCount);
|
GL45.glDrawArrays(GL45.GL_TRIANGLES, 0, elementCount);
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GL40.glBindVertexArray(0);
|
GL45.glBindVertexArray(0);
|
||||||
Globals.renderingEngine.checkError();
|
Globals.renderingEngine.checkError();
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,41 +41,84 @@ import org.lwjgl.assimp.AINode;
|
|||||||
*/
|
*/
|
||||||
public class Model {
|
public class Model {
|
||||||
|
|
||||||
//the model matrix for this model
|
/**
|
||||||
|
* The model matrix of the model
|
||||||
|
*/
|
||||||
private Matrix4d modelMatrix = new Matrix4d();
|
private Matrix4d modelMatrix = new Matrix4d();
|
||||||
|
|
||||||
//the real world coordinates of this object (not model space)
|
/**
|
||||||
|
* the real world coordinates of this object (not model space)
|
||||||
|
*/
|
||||||
private Vector3d worldPos = new Vector3d();
|
private Vector3d worldPos = new Vector3d();
|
||||||
|
|
||||||
//an optional global transform applied to the parent bone. Typically found in models loaded from files
|
/**
|
||||||
|
* an optional global transform applied to the parent bone. Typically found in models loaded from files
|
||||||
|
*/
|
||||||
private Matrix4d rootTransform = new Matrix4d();
|
private Matrix4d rootTransform = new Matrix4d();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The inverse root transform
|
||||||
|
*/
|
||||||
private Matrix4d globalInverseTransform = new Matrix4d();
|
private Matrix4d globalInverseTransform = new Matrix4d();
|
||||||
|
|
||||||
//the meshes in the model
|
/**
|
||||||
|
* The list of meshes in the model
|
||||||
|
*/
|
||||||
private List<Mesh> meshes = new ArrayList<Mesh>();
|
private List<Mesh> meshes = new ArrayList<Mesh>();
|
||||||
|
|
||||||
//the materials in the model
|
/**
|
||||||
|
* The materials of the model
|
||||||
|
*/
|
||||||
private List<Material> materials = new ArrayList<Material>();
|
private List<Material> materials = new ArrayList<Material>();
|
||||||
|
|
||||||
//bone data for the model
|
/**
|
||||||
|
* The list of all bones
|
||||||
|
*/
|
||||||
private List<Bone> bones = new ArrayList<Bone>();
|
private List<Bone> bones = new ArrayList<Bone>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The map of name -> bone
|
||||||
|
*/
|
||||||
private Map<String,Bone> boneMap = new HashMap<String,Bone>();
|
private Map<String,Bone> boneMap = new HashMap<String,Bone>();
|
||||||
|
|
||||||
//these structures are used to parse the tree of bones of the model
|
/**
|
||||||
|
* The root animation node
|
||||||
|
*/
|
||||||
private AnimNode rootAnimNode;
|
private AnimNode rootAnimNode;
|
||||||
|
/**
|
||||||
|
* The map of animation node name -> node
|
||||||
|
*/
|
||||||
private Map<String,AnimNode> nodeMap = new HashMap<String,AnimNode>();
|
private Map<String,AnimNode> nodeMap = new HashMap<String,AnimNode>();
|
||||||
|
|
||||||
//animation data for the model
|
/**
|
||||||
|
* The animations in the model
|
||||||
|
*/
|
||||||
private List<Animation> animations = new ArrayList<Animation>();
|
private List<Animation> animations = new ArrayList<Animation>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The map of animation name -> animation
|
||||||
|
*/
|
||||||
private Map<String,Animation> animMap = new HashMap<String,Animation>();
|
private Map<String,Animation> animMap = new HashMap<String,Animation>();
|
||||||
|
|
||||||
|
|
||||||
//these are masks that can be applied to the model to overwrite meshes, shaders, and textures of it
|
/**
|
||||||
|
* A mask that overwrites meshes themsselves
|
||||||
|
*/
|
||||||
private ActorMeshMask meshMask;
|
private ActorMeshMask meshMask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mask that overwrites shaders on a given mesh
|
||||||
|
*/
|
||||||
private Map<String,ActorShaderMask> shaderMask = new HashMap<String,ActorShaderMask>();
|
private Map<String,ActorShaderMask> shaderMask = new HashMap<String,ActorShaderMask>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mask that overwrites textures on a given mesh
|
||||||
|
*/
|
||||||
private Map<String,ActorTextureMask> textureMap = new HashMap<String,ActorTextureMask>();
|
private Map<String,ActorTextureMask> textureMap = new HashMap<String,ActorTextureMask>();
|
||||||
|
|
||||||
//The bounding sphere for this particular model
|
/**
|
||||||
|
* The bounding sphere for this particular model
|
||||||
|
*/
|
||||||
private Sphered boundingSphere = new Sphered();
|
private Sphered boundingSphere = new Sphered();
|
||||||
|
|
||||||
|
|
||||||
@ -272,7 +315,7 @@ public class Model {
|
|||||||
* @param oldShader The original shader on the mesh
|
* @param oldShader The original shader on the mesh
|
||||||
* @return The correct shader program to use for this mesh
|
* @return The correct shader program to use for this mesh
|
||||||
*/
|
*/
|
||||||
VisualShader getCorrectShader(Map<String,ActorShaderMask> shaderMask, Mesh mesh, VisualShader oldShader){
|
private VisualShader getCorrectShader(Map<String,ActorShaderMask> shaderMask, Mesh mesh, VisualShader oldShader){
|
||||||
VisualShader rVal = oldShader;
|
VisualShader rVal = oldShader;
|
||||||
if(shaderMask.containsKey(mesh.getMeshName())){
|
if(shaderMask.containsKey(mesh.getMeshName())){
|
||||||
ActorShaderMask specificMask = shaderMask.get(mesh.getMeshName());
|
ActorShaderMask specificMask = shaderMask.get(mesh.getMeshName());
|
||||||
@ -392,7 +435,7 @@ public class Model {
|
|||||||
* @param boneRotators The bone rotators to apply
|
* @param boneRotators The bone rotators to apply
|
||||||
* @param staticMorph The static morph to apply
|
* @param staticMorph The static morph to apply
|
||||||
*/
|
*/
|
||||||
void updateNodeTransform(AnimNode n, Map<String,ActorBoneRotator> boneRotators, ActorStaticMorph staticMorph){
|
private void updateNodeTransform(AnimNode n, Map<String,ActorBoneRotator> boneRotators, ActorStaticMorph staticMorph){
|
||||||
Matrix4d parentTransform = new Matrix4d();
|
Matrix4d parentTransform = new Matrix4d();
|
||||||
if(n.parent != null){
|
if(n.parent != null){
|
||||||
parentTransform = new Matrix4d(n.parent.getTransform());
|
parentTransform = new Matrix4d(n.parent.getTransform());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user