ui debug tools,macos settings,javascript engine
This commit is contained in:
parent
9bf2f81ae1
commit
ec66db9c08
@ -11,9 +11,13 @@
|
||||
|
||||
"graphicsPerformanceLODChunkRadius" : 3,
|
||||
"graphicsPerformanceEnableVSync" : false,
|
||||
"graphicsPerformanceDrawShadows" : true,
|
||||
"graphicsPerformanceDrawShadows" : false,
|
||||
"graphicsPerformanceOIT" : true,
|
||||
"graphicsViewRange" : 20000.0,
|
||||
|
||||
"renderResolutionX": 1280,
|
||||
"renderResolutionY": 800,
|
||||
|
||||
"graphicsDebugDrawCollisionSpheres" : false,
|
||||
"graphicsDebugDrawPhysicsObjects" : false,
|
||||
"graphicsDebugDrawMovementVectors" : false,
|
||||
|
||||
1
assets/Scripts/test.js
Normal file
1
assets/Scripts/test.js
Normal file
@ -0,0 +1 @@
|
||||
console.log("test")
|
||||
@ -12,14 +12,15 @@ uniform vec3 tDimension;
|
||||
void main(){
|
||||
vec2 finalPos = vec2(
|
||||
((aPos.x + 1)/2 * mDimension.x + mPosition.x) * 2 - 1,
|
||||
-((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||
((((aPos.y + 1)/2) * mDimension.y + (1 - mDimension.y) - mPosition.y) * 2 - 1)
|
||||
// ((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||
);
|
||||
gl_Position = vec4(finalPos.x, finalPos.y, 0.0, 1.0);
|
||||
|
||||
vec2 finalTex = vec2(
|
||||
aTexCoords.x * tDimension.x + tPosition.x,
|
||||
aTexCoords.y * tDimension.y + tPosition.y
|
||||
1 - (aTexCoords.y * tDimension.y + tPosition.y)
|
||||
);
|
||||
// vec2 finalTex = aTexCoords;
|
||||
// vec2 finalTex = vec2(
|
||||
|
||||
351
assets/Shaders/smoke1/smoke1.fs
Normal file
351
assets/Shaders/smoke1/smoke1.fs
Normal file
@ -0,0 +1,351 @@
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 railgunSR
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
/*
|
||||
THIS MAKES USE OF OPENSIMPLEX2, A NOISE ALGORITHM CREATED BY THE FINE FOLKS
|
||||
OVER AT https://github.com/KdotJPG/OpenSimplex2
|
||||
PLEASE GIVE THEM SOME LOVE.
|
||||
|
||||
IT ALSO MAKES USE OF FUNCTIONS FROM THE_FORCE, A SHADER IDE
|
||||
https://github.com/shawnlawson/The_Force
|
||||
|
||||
*/
|
||||
|
||||
//version
|
||||
#version 330 core
|
||||
|
||||
//output
|
||||
// out vec4 fragColor;
|
||||
|
||||
layout (location = 0) out vec4 accum;
|
||||
layout (location = 1) out float reveal;
|
||||
|
||||
//input
|
||||
in vec3 FragPos;
|
||||
in vec3 Normal;
|
||||
in vec2 TexCoord;
|
||||
in vec4 projCoord;
|
||||
in vec4 modelCoord;
|
||||
|
||||
//uniforms
|
||||
uniform float time;
|
||||
|
||||
//layout uniforms
|
||||
uniform sampler2D shadowMap;
|
||||
uniform sampler2D volumeDepthFrontface;
|
||||
uniform sampler2D volumeDepthBackface;
|
||||
|
||||
//function declarations
|
||||
vec4 openSimplex2_Conventional(vec3 X);
|
||||
vec4 openSimplex2_ImproveXY(vec3 X);
|
||||
float flameTex(float x, float y);
|
||||
float getNoise(float scale, float timeScale);
|
||||
float voronoi(vec2 point);
|
||||
vec3 voronoi(vec3 x);
|
||||
float linearCenterAroundPoint(float inputPt, float centerpoint, float falloff);
|
||||
|
||||
/*
|
||||
Main method
|
||||
*/
|
||||
void main(){
|
||||
|
||||
float timeS = time * 0.003;
|
||||
|
||||
// Normalized pixel coordinates (from 0 to 1)
|
||||
vec3 projCoordNorm = projCoord.xyz / projCoord.w / 2.0 + 0.5;
|
||||
//make vec2
|
||||
vec2 finalProd = projCoordNorm.xy;
|
||||
//grab depth values
|
||||
float closeDepth = texture(volumeDepthFrontface, finalProd.xy).r;
|
||||
float farDepth = texture(volumeDepthBackface, finalProd.xy).r;
|
||||
//distance between the two
|
||||
float volume = min(abs(farDepth - closeDepth),1);
|
||||
|
||||
|
||||
//based on distance of model coords from center
|
||||
float dist = length(modelCoord.xyz);
|
||||
|
||||
|
||||
//noise
|
||||
// float noiseInX = modelCoord.x * 7.0;
|
||||
// float noiseInZ = FragPos.y * 7.0 - timeS;
|
||||
// float noiseInY = modelCoord.y * 7.0;
|
||||
// float noise = openSimplex2_ImproveXY(vec3(noiseInX,noiseInY,noiseInZ)).x;
|
||||
float noise = (getNoise(7.0,1.5 * timeS) + getNoise(10.0,1.5 * (timeS + 0.1)) + getNoise(14.0,1.5 * (timeS + 0.2)) + getNoise(20.0,3.0 * timeS)) / 4.0;
|
||||
// float noise = getNoise(10.0,1.5);
|
||||
// float noise = getNoise(14.0,2.0);
|
||||
|
||||
float vertical = -modelCoord.z;
|
||||
|
||||
float amountOfFire = volume * 50.0 + vertical * 2.0 + noise * 0.1;// + dist * 0.1; //should be a function of volume + noise + dist from center
|
||||
|
||||
// if(amountOfFire < 0.1){
|
||||
// discard;
|
||||
// }
|
||||
|
||||
amountOfFire = amountOfFire * 2.0;
|
||||
|
||||
float red = 0.1984;
|
||||
float green = 0.6464;
|
||||
float blue = 0.7366;
|
||||
float alpha = volume * 7.0;
|
||||
|
||||
volume = volume * 3;
|
||||
|
||||
float foamFallout = max(1 - (volume * 7),0);
|
||||
float lightWaterVal = max(1 - (volume * 3),0);
|
||||
float darkWaterVal = linearCenterAroundPoint(volume,0.5,0.5);
|
||||
float blackWaterVal = max((volume * 3) - 2,0);
|
||||
|
||||
red = 0.1984 * lightWaterVal + darkWaterVal * 0.0000 + blackWaterVal * 0.0000;
|
||||
green = 0.6464 * lightWaterVal + darkWaterVal * 0.1370 + blackWaterVal * 0.0980;
|
||||
blue = 0.7366 * lightWaterVal + darkWaterVal * 0.3140 + blackWaterVal * 0.2200;
|
||||
|
||||
if(dot(Normal,vec3(0,1,0)) > 0.5){
|
||||
float foamVal = voronoi(vec3(modelCoord.x * 8,modelCoord.z * 8,timeS)).x;
|
||||
// foamVal = foamVal * foamVal * min(1 - volume * 10,0);
|
||||
foamVal = foamVal * foamVal;
|
||||
red = red + foamVal;// * foamFallout;
|
||||
blue = blue + foamVal;// * foamFallout;
|
||||
green = green + foamVal;// * foamFallout;
|
||||
alpha = alpha + foamVal;// * foamFallout;
|
||||
// // float foamVal = openSimplex2_ImproveXY(vec3(modelCoord.x * 5.0,modelCoord.z * 5.0,timeS)).x;
|
||||
// // if(foamVal > 0.4 && foamVal < 0.7){
|
||||
// // foamVal = 1.0 - foamVal * foamVal;
|
||||
// // red = foamVal + red;
|
||||
// // green = foamVal + green;
|
||||
// // blue = foamVal + blue;
|
||||
// // alpha = foamVal + alpha;
|
||||
// // }
|
||||
}
|
||||
|
||||
// alpha = 0.5;
|
||||
|
||||
// float red = volume * 10.0;
|
||||
// float green = volume * 10.0;
|
||||
// float blue = volume * 10.0;
|
||||
// float alpha = 1.0;
|
||||
|
||||
vec4 noiseVal = openSimplex2_Conventional(vec3(
|
||||
projCoordNorm.x * 20,
|
||||
projCoordNorm.y * 20,
|
||||
projCoordNorm.z * 20 + timeS * 3));
|
||||
|
||||
vec4 color = vec4(
|
||||
noiseVal.x,
|
||||
noiseVal.y,
|
||||
noiseVal.z,
|
||||
alpha * volume
|
||||
);
|
||||
|
||||
|
||||
// weight function
|
||||
float weight = clamp(pow(min(1.0, color.a * 10.0) + 0.01, 3.0) * 1e8 * pow(1.0 - gl_FragCoord.z * 0.9, 3.0), 1e-2, 3e3);
|
||||
|
||||
// store pixel color accumulation
|
||||
accum = vec4(color.rgb,1);
|
||||
|
||||
// store pixel revealage threshold
|
||||
reveal = volume;
|
||||
// reveal = 1.0;
|
||||
|
||||
// if(val < 0.3){
|
||||
// discard;
|
||||
// }
|
||||
|
||||
// Output to screen
|
||||
// fragColor = color;
|
||||
}
|
||||
|
||||
|
||||
float getNoise(float scale, float time){
|
||||
float noiseInX = modelCoord.x * scale;
|
||||
float noiseInZ = FragPos.y * scale - time;
|
||||
float noiseInY = modelCoord.y * scale;
|
||||
float noise = openSimplex2_ImproveXY(vec3(noiseInX,noiseInY,noiseInZ)).x;
|
||||
return noise;
|
||||
}
|
||||
|
||||
|
||||
//////////////// K.jpg's Re-oriented 4-Point BCC Noise (OpenSimplex2) ////////////////
|
||||
////////////////////// Output: vec4(dF/dx, dF/dy, dF/dz, value) //////////////////////
|
||||
|
||||
// Inspired by Stefan Gustavson's noise
|
||||
vec4 permute(vec4 t) {
|
||||
return t * (t * 34.0 + 133.0);
|
||||
}
|
||||
|
||||
// Gradient set is a normalized expanded rhombic dodecahedron
|
||||
vec3 grad(float hash) {
|
||||
|
||||
// Random vertex of a cube, +/- 1 each
|
||||
vec3 cube = mod(floor(hash / vec3(1.0, 2.0, 4.0)), 2.0) * 2.0 - 1.0;
|
||||
|
||||
// Random edge of the three edges connected to that vertex
|
||||
// Also a cuboctahedral vertex
|
||||
// And corresponds to the face of its dual, the rhombic dodecahedron
|
||||
vec3 cuboct = cube;
|
||||
cuboct[int(hash / 16.0)] = 0.0;
|
||||
|
||||
// In a funky way, pick one of the four points on the rhombic face
|
||||
float type = mod(floor(hash / 8.0), 2.0);
|
||||
vec3 rhomb = (1.0 - type) * cube + type * (cuboct + cross(cube, cuboct));
|
||||
|
||||
// Expand it so that the new edges are the same length
|
||||
// as the existing ones
|
||||
vec3 grad = cuboct * 1.22474487139 + rhomb;
|
||||
|
||||
// To make all gradients the same length, we only need to shorten the
|
||||
// second type of vector. We also put in the whole noise scale constant.
|
||||
// The compiler should reduce it into the existing floats. I think.
|
||||
grad *= (1.0 - 0.042942436724648037 * type) * 32.80201376986577;
|
||||
|
||||
return grad;
|
||||
}
|
||||
|
||||
// BCC lattice split up into 2 cube lattices
|
||||
vec4 openSimplex2Base(vec3 X) {
|
||||
|
||||
// First half-lattice, closest edge
|
||||
vec3 v1 = round(X);
|
||||
vec3 d1 = X - v1;
|
||||
vec3 score1 = abs(d1);
|
||||
vec3 dir1 = step(max(score1.yzx, score1.zxy), score1);
|
||||
vec3 v2 = v1 + dir1 * sign(d1);
|
||||
vec3 d2 = X - v2;
|
||||
|
||||
// Second half-lattice, closest edge
|
||||
vec3 X2 = X + 144.5;
|
||||
vec3 v3 = round(X2);
|
||||
vec3 d3 = X2 - v3;
|
||||
vec3 score2 = abs(d3);
|
||||
vec3 dir2 = step(max(score2.yzx, score2.zxy), score2);
|
||||
vec3 v4 = v3 + dir2 * sign(d3);
|
||||
vec3 d4 = X2 - v4;
|
||||
|
||||
// Gradient hashes for the four points, two from each half-lattice
|
||||
vec4 hashes = permute(mod(vec4(v1.x, v2.x, v3.x, v4.x), 289.0));
|
||||
hashes = permute(mod(hashes + vec4(v1.y, v2.y, v3.y, v4.y), 289.0));
|
||||
hashes = mod(permute(mod(hashes + vec4(v1.z, v2.z, v3.z, v4.z), 289.0)), 48.0);
|
||||
|
||||
// Gradient extrapolations & kernel function
|
||||
vec4 a = max(0.5 - vec4(dot(d1, d1), dot(d2, d2), dot(d3, d3), dot(d4, d4)), 0.0);
|
||||
vec4 aa = a * a; vec4 aaaa = aa * aa;
|
||||
vec3 g1 = grad(hashes.x); vec3 g2 = grad(hashes.y);
|
||||
vec3 g3 = grad(hashes.z); vec3 g4 = grad(hashes.w);
|
||||
vec4 extrapolations = vec4(dot(d1, g1), dot(d2, g2), dot(d3, g3), dot(d4, g4));
|
||||
|
||||
// Derivatives of the noise
|
||||
vec3 derivative = -8.0 * mat4x3(d1, d2, d3, d4) * (aa * a * extrapolations)
|
||||
+ mat4x3(g1, g2, g3, g4) * aaaa;
|
||||
|
||||
// Return it all as a vec4
|
||||
return vec4(derivative, dot(aaaa, extrapolations));
|
||||
}
|
||||
|
||||
// Use this if you don't want Z to look different from X and Y
|
||||
vec4 openSimplex2_Conventional(vec3 X) {
|
||||
|
||||
// Rotate around the main diagonal. Not a skew transform.
|
||||
vec4 result = openSimplex2Base(dot(X, vec3(2.0/3.0)) - X);
|
||||
return vec4(dot(result.xyz, vec3(2.0/3.0)) - result.xyz, result.w);
|
||||
}
|
||||
|
||||
// Use this if you want to show X and Y in a plane, then use Z for time, vertical, etc.
|
||||
vec4 openSimplex2_ImproveXY(vec3 X) {
|
||||
|
||||
// Rotate so Z points down the main diagonal. Not a skew transform.
|
||||
mat3 orthonormalMap = mat3(
|
||||
0.788675134594813, -0.211324865405187, -0.577350269189626,
|
||||
-0.211324865405187, 0.788675134594813, -0.577350269189626,
|
||||
0.577350269189626, 0.577350269189626, 0.577350269189626);
|
||||
|
||||
vec4 result = openSimplex2Base(orthonormalMap * X);
|
||||
return vec4(result.xyz * orthonormalMap, result.w);
|
||||
}
|
||||
|
||||
const mat2 myt = mat2(.12121212,.13131313,-.13131313,.12121212);
|
||||
const vec2 mys = vec2(1e4, 1e6);
|
||||
vec2 rhash(vec2 uv) {
|
||||
uv *= myt;
|
||||
uv *= mys;
|
||||
return fract(fract(uv/mys)*uv);
|
||||
}
|
||||
|
||||
vec3 hash( vec3 p ){
|
||||
return fract(sin(vec3( dot(p,vec3(1.0,57.0,113.0)),
|
||||
dot(p,vec3(57.0,113.0,1.0)),
|
||||
dot(p,vec3(113.0,1.0,57.0))))*43758.5453);
|
||||
|
||||
}
|
||||
|
||||
float voronoi(vec2 point){
|
||||
vec2 p = floor( point );
|
||||
vec2 f = fract( point );
|
||||
float res = 0.0;
|
||||
for( int j=-1; j<=1; j++ ) {
|
||||
for( int i=-1; i<=1; i++ ) {
|
||||
vec2 b = vec2( i, j );
|
||||
vec2 r = vec2( b ) - f + rhash( p + b);
|
||||
res += 1./pow(dot(r,r),8.);
|
||||
}
|
||||
}
|
||||
return pow(1./res, 0.0625);
|
||||
}
|
||||
|
||||
vec3 voronoi(vec3 x) {
|
||||
vec3 p = floor( x );
|
||||
vec3 f = fract( x );
|
||||
|
||||
float id = 0.0;
|
||||
vec2 res = vec2( 100.0 );
|
||||
for( int k=-1; k<=1; k++ ) {
|
||||
for( int j=-1; j<=1; j++ ) {
|
||||
for( int i=-1; i<=1; i++ ) {
|
||||
vec3 b = vec3( float(i), float(j), float(k) );
|
||||
vec3 r = vec3( b ) - f + hash( p + b );
|
||||
float d = dot( r, r );
|
||||
|
||||
if( d < res.x ) {
|
||||
id = dot( p+b, vec3(1.0,57.0,113.0 ) );
|
||||
res = vec2( d, res.x );
|
||||
}
|
||||
else if( d < res.y ) {
|
||||
res.y = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vec3( sqrt( res ), abs(id) );
|
||||
}
|
||||
|
||||
//////////////////////////////// End noise code ////////////////////////////////
|
||||
|
||||
|
||||
float linearCenterAroundPoint(float inputPt, float centerpoint, float falloff){
|
||||
return max(((-abs(inputPt - centerpoint)) + centerpoint)*falloff,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
47
assets/Shaders/smoke1/smoke1.vs
Normal file
47
assets/Shaders/smoke1/smoke1.vs
Normal file
@ -0,0 +1,47 @@
|
||||
//Vertex Shader
|
||||
#version 330 core
|
||||
|
||||
|
||||
|
||||
//input buffers
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 4) in vec2 aTex;
|
||||
|
||||
|
||||
//coordinate space transformation matrices
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform float time;
|
||||
|
||||
|
||||
|
||||
//output buffers
|
||||
out vec3 FragPos;
|
||||
out vec3 Normal;
|
||||
out vec2 TexCoord;
|
||||
out vec4 projCoord;
|
||||
out vec4 modelCoord;
|
||||
|
||||
|
||||
|
||||
void main() {
|
||||
//normalize posiiton and normal
|
||||
vec4 FinalVertex = vec4(aPos, 1.0);
|
||||
vec4 FinalNormal = vec4(aNormal, 1.0);
|
||||
|
||||
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
FragPos = vec3(model * FinalVertex);
|
||||
Normal = mat3(transpose(inverse(model))) * aNormal;
|
||||
TexCoord = aTex;
|
||||
projCoord = projection * view * model * FinalVertex;
|
||||
modelCoord = FinalVertex;
|
||||
|
||||
//set final position with opengl space
|
||||
vec4 outVec = projection * view * model * FinalVertex;
|
||||
// outVec.z = outVec.z - 0.1f;
|
||||
// outVec.z = -0.9;
|
||||
gl_Position = outVec;
|
||||
}
|
||||
@ -11,7 +11,7 @@ void main(){
|
||||
//0,0
|
||||
vec2 finalPos = vec2(
|
||||
((((aPos.x + 1)/2) * mDimension.x + mPosition.x) * 2 - 1),
|
||||
((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||
((((aPos.y + 1)/2) * mDimension.y + (1 - mDimension.y) - mPosition.y) * 2 - 1)
|
||||
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||
);
|
||||
gl_Position = vec4(finalPos.x, finalPos.y, 0.0, 1.0);
|
||||
@ -0,0 +1,18 @@
|
||||
#version 330 core
|
||||
|
||||
//threshold on borders of window where to actually draw outline
|
||||
#define threshold 0.01
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec3 color;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
void main(){
|
||||
if(abs(texCoord.x) > 1.0-threshold || abs(texCoord.y) > 1.0-threshold || abs(texCoord.x) < threshold || abs(texCoord.y) < threshold){
|
||||
FragColor = vec4(color,1.0);
|
||||
} else {
|
||||
FragColor = vec4(0.0);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 4) in vec2 aTexCoords;
|
||||
|
||||
out vec2 texCoord;
|
||||
|
||||
uniform vec3 mPosition;
|
||||
uniform vec3 mDimension;
|
||||
uniform vec3 tPosition;
|
||||
uniform vec3 tDimension;
|
||||
|
||||
void main(){
|
||||
vec2 finalPos = vec2(
|
||||
((aPos.x + 1)/2 * mDimension.x + mPosition.x) * 2 - 1,
|
||||
((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||
);
|
||||
gl_Position = vec4(finalPos.x, finalPos.y, 0.0, 1.0);
|
||||
|
||||
// vec2 finalTex = aTexCoords;
|
||||
// vec2 finalTex = vec2(
|
||||
// aTexCoords.x + 0.7,
|
||||
// aTexCoords.y
|
||||
// );
|
||||
texCoord = aTexCoords;
|
||||
}
|
||||
14
assets/Shaders/ui/window/window.fs
Normal file
14
assets/Shaders/ui/window/window.fs
Normal file
@ -0,0 +1,14 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoords;
|
||||
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
void main(){
|
||||
vec4 textureColor = texture(screenTexture, TexCoords);
|
||||
if(textureColor.a < 0.1){
|
||||
discard;
|
||||
}
|
||||
FragColor = textureColor;
|
||||
}
|
||||
30
assets/Shaders/ui/window/window.vs
Normal file
30
assets/Shaders/ui/window/window.vs
Normal file
@ -0,0 +1,30 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 4) in vec2 aTexCoords;
|
||||
|
||||
out vec2 TexCoords;
|
||||
|
||||
uniform vec3 mPosition;
|
||||
uniform vec3 mDimension;
|
||||
uniform vec3 tPosition;
|
||||
uniform vec3 tDimension;
|
||||
|
||||
void main(){
|
||||
vec2 finalPos = vec2(
|
||||
((aPos.x + 1)/2 * mDimension.x + mPosition.x) * 2 - 1,
|
||||
((((aPos.y + 1)/2) * mDimension.y + (1 - mDimension.y) - mPosition.y) * 2 - 1)
|
||||
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||
);
|
||||
gl_Position = vec4(finalPos.x, finalPos.y, 0.0, 1.0);
|
||||
|
||||
vec2 finalTex = vec2(
|
||||
aTexCoords.x * tDimension.x + tPosition.x,
|
||||
1 - (aTexCoords.y * tDimension.y + tPosition.y)
|
||||
);
|
||||
// vec2 finalTex = aTexCoords;
|
||||
// vec2 finalTex = vec2(
|
||||
// aTexCoords.x + 0.7,
|
||||
// aTexCoords.y
|
||||
// );
|
||||
TexCoords = finalTex;
|
||||
}
|
||||
14
assets/Shaders/ui/windowContent/windowContent.fs
Normal file
14
assets/Shaders/ui/windowContent/windowContent.fs
Normal file
@ -0,0 +1,14 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoords;
|
||||
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
void main(){
|
||||
vec4 textureColor = texture(screenTexture, TexCoords);
|
||||
if(textureColor.a < 0.1){
|
||||
discard;
|
||||
}
|
||||
FragColor = textureColor;
|
||||
}
|
||||
30
assets/Shaders/ui/windowContent/windowContent.vs
Normal file
30
assets/Shaders/ui/windowContent/windowContent.vs
Normal file
@ -0,0 +1,30 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
layout (location = 4) in vec2 aTexCoords;
|
||||
|
||||
out vec2 TexCoords;
|
||||
|
||||
uniform vec3 mPosition;
|
||||
uniform vec3 mDimension;
|
||||
uniform vec3 tPosition;
|
||||
uniform vec3 tDimension;
|
||||
|
||||
void main(){
|
||||
vec2 finalPos = vec2(
|
||||
((aPos.x + 1)/2 * mDimension.x + mPosition.x) * 2 - 1,
|
||||
((((aPos.y + 1)/2) * mDimension.y + mPosition.y) * 2 - 1)
|
||||
// aPos.y * mDimension.y + (mPosition.y) + (1 - mDimension.y)
|
||||
);
|
||||
gl_Position = vec4(finalPos.x, finalPos.y, 0.0, 1.0);
|
||||
|
||||
vec2 finalTex = vec2(
|
||||
aTexCoords.x * tDimension.x + tPosition.x,
|
||||
1 - (aTexCoords.y * tDimension.y + tPosition.y)
|
||||
);
|
||||
// vec2 finalTex = aTexCoords;
|
||||
// vec2 finalTex = vec2(
|
||||
// aTexCoords.x + 0.7,
|
||||
// aTexCoords.y
|
||||
// );
|
||||
TexCoords = finalTex;
|
||||
}
|
||||
29
pom.xml
29
pom.xml
@ -152,12 +152,41 @@
|
||||
<version>3.36.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!--JUnit-->
|
||||
<!--License: Eclipse Public License-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
|
||||
<!--GraalVM-->
|
||||
<!--License: GPLv2 w/ classpath exception-->
|
||||
<!--apparently maybe classpath exception allows use in eg game engine??-->
|
||||
<!-- https://mvnrepository.com/artifact/org.graalvm.js/js -->
|
||||
<dependency>
|
||||
<groupId>org.graalvm.js</groupId>
|
||||
<artifactId>js</artifactId>
|
||||
<version>22.1.0.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.graalvm.js/js-scriptengine -->
|
||||
<dependency>
|
||||
<groupId>org.graalvm.js</groupId>
|
||||
<artifactId>js-scriptengine</artifactId>
|
||||
<version>22.1.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<!--steamworks4j-->
|
||||
<!--License: MIT-->
|
||||
<!-- https://mvnrepository.com/artifact/com.code-disaster.steamworks4j/steamworks4j -->
|
||||
<dependency>
|
||||
<groupId>com.code-disaster.steamworks4j</groupId>
|
||||
<artifactId>steamworks4j</artifactId>
|
||||
<version>1.9.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@ -1,36 +1,66 @@
|
||||
package electrosphere.controls;
|
||||
|
||||
import electrosphere.audio.AudioUtils;
|
||||
import electrosphere.controls.Control.ControlMethod;
|
||||
import electrosphere.controls.Control.ControlType;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.state.ironsight.IronSightTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.movement.JumpTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementRelativeFacing;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementTreeState;
|
||||
import electrosphere.entity.state.movement.SprintTree;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.game.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.menu.WindowStrings;
|
||||
import electrosphere.menu.WindowUtils;
|
||||
import electrosphere.menu.MenuGenerators;
|
||||
import electrosphere.menu.MenuGeneratorsInventory;
|
||||
import electrosphere.renderer.ui.Window;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
import electrosphere.renderer.ui.events.KeyboardEvent;
|
||||
import electrosphere.renderer.ui.events.MenuEvent;
|
||||
import electrosphere.renderer.ui.events.MouseEvent;
|
||||
import electrosphere.renderer.ui.events.MenuEvent.MenuEventType;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_CURSOR;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_CURSOR_DISABLED;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_CURSOR_NORMAL;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_0;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_1;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_2;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_3;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_4;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_5;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_6;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_7;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_8;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_9;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_A;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_B;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_BACKSPACE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_C;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_CAPS_LOCK;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_D;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_DOWN;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_E;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ENTER;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_F;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_F24;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_G;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_H;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_I;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_J;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_K;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_L;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_CONTROL;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_LEFT_SHIFT;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_M;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_N;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_O;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_P;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_PERIOD;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_R;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_RIGHT;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_S;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_SLASH;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_SPACE;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_T;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_U;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_UP;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_V;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_W;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_X;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Y;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_KEY_Z;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_1;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_2;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
|
||||
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetCursorPos;
|
||||
import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent;
|
||||
import static org.lwjgl.glfw.GLFW.glfwMaximizeWindow;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetInputMode;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -41,9 +71,37 @@ import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetCursorPos;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetInputMode;
|
||||
import electrosphere.audio.AudioUtils;
|
||||
import electrosphere.controls.Control.ControlMethod;
|
||||
import electrosphere.controls.Control.ControlType;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.state.ironsight.IronSightTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementRelativeFacing;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementTreeState;
|
||||
import electrosphere.entity.state.movement.JumpTree;
|
||||
import electrosphere.entity.state.movement.SprintTree;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.game.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.menu.MenuGenerators;
|
||||
import electrosphere.menu.MenuGeneratorsDebug;
|
||||
import electrosphere.menu.MenuGeneratorsInventory;
|
||||
import electrosphere.menu.WindowStrings;
|
||||
import electrosphere.menu.WindowUtils;
|
||||
import electrosphere.renderer.ui.Window;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
import electrosphere.renderer.ui.events.KeyboardEvent;
|
||||
import electrosphere.renderer.ui.events.MenuEvent;
|
||||
import electrosphere.renderer.ui.events.MenuEvent.MenuEventType;
|
||||
import electrosphere.renderer.ui.events.MouseEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -126,6 +184,7 @@ public class ControlHandler {
|
||||
public static final String INPUT_CODE_INVENTORY_ITEM_DRAG = "inventoryDrag";
|
||||
|
||||
public static final String DEBUG_FRAMESTEP = "framestep";
|
||||
public static final String DEBUG_OPEN_DEBUG_MENU = "openDebugMenu";
|
||||
|
||||
|
||||
public static enum ControlsState {
|
||||
@ -164,6 +223,7 @@ public class ControlHandler {
|
||||
List<Control> menuNavigationControlList = new LinkedList<Control>();
|
||||
List<Control> typingControlList = new LinkedList<Control>();
|
||||
List<Control> inventoryControlList = new LinkedList<Control>();
|
||||
List<Control> alwaysOnDebugControlList = new LinkedList<Control>();
|
||||
|
||||
ControlHandler(){
|
||||
controls = new HashMap<String, Control>();
|
||||
@ -277,6 +337,7 @@ public class ControlHandler {
|
||||
Debug controls
|
||||
*/
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_DEBUG_SPAWN_ITEM, new Control(ControlType.KEY,GLFW_KEY_Q));
|
||||
handler.addControl(DEBUG_OPEN_DEBUG_MENU, new Control(ControlType.KEY, GLFW_KEY_O));
|
||||
|
||||
/*
|
||||
return
|
||||
@ -295,6 +356,7 @@ public class ControlHandler {
|
||||
case MAIN_GAME:
|
||||
runHandlers(mainGameControlList);
|
||||
runHandlers(mainGameDebugControlList);
|
||||
runHandlers(alwaysOnDebugControlList);
|
||||
break;
|
||||
|
||||
|
||||
@ -309,20 +371,24 @@ public class ControlHandler {
|
||||
Typing..
|
||||
*/
|
||||
runHandlers(typingControlList);
|
||||
runHandlers(alwaysOnDebugControlList);
|
||||
break;
|
||||
|
||||
case IN_GAME_MAIN_MENU:
|
||||
runHandlers(menuNavigationControlList);
|
||||
runHandlers(typingControlList);
|
||||
runHandlers(alwaysOnDebugControlList);
|
||||
// pollMenuNavigationControls();
|
||||
break;
|
||||
|
||||
case INVENTORY:
|
||||
runHandlers(inventoryControlList);
|
||||
runHandlers(menuNavigationControlList);
|
||||
runHandlers(alwaysOnDebugControlList);
|
||||
break;
|
||||
|
||||
case NO_INPUT:
|
||||
runHandlers(alwaysOnDebugControlList);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -335,6 +401,7 @@ public class ControlHandler {
|
||||
setMenuNavigationControls();
|
||||
setTypingControls();
|
||||
setInventoryControls();
|
||||
setAlwaysOnDebugControls();
|
||||
}
|
||||
|
||||
void setMainGameControls(){
|
||||
@ -803,6 +870,24 @@ public class ControlHandler {
|
||||
}});
|
||||
// RenderingEngine.incrementOutputFramebuffer();
|
||||
}
|
||||
|
||||
void setAlwaysOnDebugControls(){
|
||||
alwaysOnDebugControlList.add(controls.get(DEBUG_OPEN_DEBUG_MENU));
|
||||
controls.get(DEBUG_OPEN_DEBUG_MENU).setOnPress(new ControlMethod(){public void execute(){
|
||||
System.out.println("open debug menu");
|
||||
// Window mainMenuWindow = new Window(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
Window mainMenuInGame = MenuGeneratorsDebug.createTopLevelDebugMenu();
|
||||
// mainMenuWindow.addChild(mainMenuInGame);
|
||||
Globals.elementManager.registerWindow(WindowStrings.WINDOW_DEBUG, mainMenuInGame);
|
||||
WindowUtils.recursiveSetVisible(Globals.elementManager.getWindow(WindowStrings.WINDOW_DEBUG), true);
|
||||
Globals.elementManager.focusFirstElement();
|
||||
Globals.controlHandler.setHandlerState(ControlsState.IN_GAME_MAIN_MENU);
|
||||
Globals.controlHandler.showMouse();
|
||||
//play sound effect
|
||||
AudioUtils.playAudio("/Audio/openMenu.ogg");
|
||||
}});
|
||||
controls.get(DEBUG_OPEN_DEBUG_MENU).setRepeatTimeout(0.5f * Main.targetFrameRate);
|
||||
}
|
||||
|
||||
void setMenuNavigationControls(){
|
||||
menuNavigationControlList.add(controls.get(DATA_STRING_INPUT_CODE_MENU_NAVIGATE_FORWARD));
|
||||
|
||||
@ -14,6 +14,7 @@ import org.joml.Vector3f;
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.movement.ApplyRotationTree;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
@ -26,7 +27,6 @@ import electrosphere.game.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
||||
import electrosphere.game.collision.CommonWorldData;
|
||||
import electrosphere.game.data.creature.type.CreatureType;
|
||||
import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
import electrosphere.game.server.datacell.DataCellManager;
|
||||
import electrosphere.game.server.saves.SaveUtils;
|
||||
@ -44,12 +44,10 @@ import electrosphere.menu.WindowStrings;
|
||||
import electrosphere.menu.WindowUtils;
|
||||
import electrosphere.net.NetUtils;
|
||||
import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.net.parser.net.message.CharacterMessage;
|
||||
import electrosphere.net.server.Server;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.renderer.ui.Window;
|
||||
import electrosphere.util.FileUtils;
|
||||
import electrosphere.util.Utilities;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -761,6 +759,13 @@ public class LoadingThread extends Thread {
|
||||
// myCube.putData(EntityDataStrings.DRAW_TRANSPARENT_PASS, true);
|
||||
// EntityUtils.getPosition(myCube).set(3,1,3);
|
||||
|
||||
//work on smoke shader
|
||||
Entity myCube = EntityUtils.spawnDrawableEntity("Models/unitcube.fbx");
|
||||
EntityUtils.getActor(myCube).maskShader("Cube", "Shaders/smoke1/smoke1.vs", "Shaders/smoke1/smoke1.fs");
|
||||
Globals.assetManager.addShaderToQueue("Shaders/smoke1/smoke1.vs", "Shaders/smoke1/smoke1.fs");
|
||||
myCube.putData(EntityDataStrings.DRAW_TRANSPARENT_PASS, true);
|
||||
EntityUtils.getPosition(myCube).set(3,1,3);
|
||||
|
||||
// Globals.entityManager.registerBehaviorTree(new BehaviorTree() {
|
||||
// int i = 0;
|
||||
// public void simulate(){
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
package electrosphere.engine.assetmanager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class AssetLoadingThread implements Runnable {
|
||||
|
||||
List<String> pathQueueList = new CopyOnWriteArrayList<String>();
|
||||
|
||||
Map<String,String> pathContentMap = new ConcurrentHashMap<String,String>();
|
||||
|
||||
Semaphore pathTransitionLock = new Semaphore(1);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean running = true;
|
||||
|
||||
while(running){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsPath(String path){
|
||||
return pathContentMap.containsKey(path);
|
||||
}
|
||||
|
||||
public String getContent(String path){
|
||||
return pathContentMap.get(path);
|
||||
}
|
||||
|
||||
public void queuePath(String path){
|
||||
pathTransitionLock.acquireUninterruptibly();
|
||||
if(!pathContentMap.containsKey(path) && !pathQueueList.contains(path)){
|
||||
pathQueueList.add(path);
|
||||
}
|
||||
pathTransitionLock.release();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,12 @@
|
||||
package electrosphere.entity.state.gravity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.collision.dispatch.CollisionObject;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
@ -7,18 +14,9 @@ import electrosphere.entity.state.collidable.CollidableTree;
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
import electrosphere.entity.state.movement.FallTree;
|
||||
import electrosphere.entity.state.movement.JumpTree;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.game.collision.PhysicsUtils;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -35,6 +35,10 @@ public class UserSettings {
|
||||
int graphicsPerformanceLODChunkRadius;
|
||||
boolean graphicsPerformanceEnableVSync;
|
||||
boolean graphicsPerformanceDrawShadows;
|
||||
boolean graphicsPerformanceOIT;
|
||||
//resolution
|
||||
int renderResolutionX;
|
||||
int renderResolutionY;
|
||||
//debug
|
||||
boolean graphicsDebugDrawCollisionSpheres;
|
||||
boolean graphicsDebugDrawPhysicsObjects;
|
||||
@ -105,6 +109,18 @@ public class UserSettings {
|
||||
public boolean displayFullscreen(){
|
||||
return displayFullscreen;
|
||||
}
|
||||
|
||||
public int getRenderResolutionX(){
|
||||
return renderResolutionX;
|
||||
}
|
||||
|
||||
public int getRenderResolutionY(){
|
||||
return renderResolutionY;
|
||||
}
|
||||
|
||||
public boolean getGraphicsPerformanceOIT(){
|
||||
return graphicsPerformanceOIT;
|
||||
}
|
||||
|
||||
|
||||
public void setGraphicsDebugDrawCollisionSpheres(boolean draw){
|
||||
@ -162,6 +178,9 @@ public class UserSettings {
|
||||
rVal.graphicsFOV = 90.0f;
|
||||
rVal.graphicsPerformanceDrawShadows = true;
|
||||
rVal.graphicsPerformanceEnableVSync = true;
|
||||
rVal.graphicsPerformanceOIT = true;
|
||||
rVal.renderResolutionX = 1920;
|
||||
rVal.renderResolutionY = 1080;
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -404,6 +404,7 @@ public class Globals {
|
||||
assetManager.addModelPathToQueue("Models/unitplane.fbx");
|
||||
assetManager.addModelPathToQueue("Models/unitcube.fbx");
|
||||
imagePlaneModelID = assetManager.registerModel(RenderUtils.createPlaneModel("Shaders/plane/plane.vs", "Shaders/plane/plane.fs"));
|
||||
assetManager.addShaderToQueue("Shaders/plane/plane.vs", null, "Shaders/plane/plane.fs");
|
||||
solidPlaneModelID = assetManager.registerModel(RenderUtils.createInWindowPanel("Shaders/ui/plainBox/plainBox.vs", "Shaders/ui/plainBox/plainBox.fs"));
|
||||
|
||||
//image panel
|
||||
@ -420,9 +421,12 @@ public class Globals {
|
||||
// //in game ui stuff
|
||||
// elementManager.registerWindow(WindowStrings.WINDOW_MENU_MAIN,WidgetUtils.createInGameMainMenuButton());
|
||||
|
||||
Globals.assetManager.addShaderToQueue("Shaders/ui/debug/windowBound.vs", "Shaders/ui/debug/windowBound.fs");
|
||||
|
||||
//window content shader
|
||||
assetManager.addShaderToQueue("Shaders/ui/windowContent/windowContent.vs", null, "Shaders/ui/windowContent/windowContent.fs");
|
||||
|
||||
//debug shaders
|
||||
assetManager.addShaderToQueue("Shaders/ui/debug/windowBorder/windowBound.vs", null, "Shaders/ui/debug/windowBorder/windowBound.fs");
|
||||
assetManager.addShaderToQueue("Shaders/ui/debug/windowContentBorder/windowContentBound.vs", null, "Shaders/ui/debug/windowContentBorder/windowContentBound.fs");
|
||||
|
||||
//as these assets are required for the renderer to work, we go ahead and
|
||||
//load them into memory now. The loading time penalty is worth it I think.
|
||||
|
||||
@ -1,64 +1,19 @@
|
||||
package electrosphere.main;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import static org.lwjgl.glfw.GLFW.glfwGetTime;
|
||||
import static org.lwjgl.glfw.GLFW.glfwTerminate;
|
||||
import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import electrosphere.audio.AudioEngine;
|
||||
import electrosphere.audio.AudioSource;
|
||||
import electrosphere.audio.AudioUtils;
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.renderer.Material;
|
||||
import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.RenderUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.types.hitbox.HitboxUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.engine.LoadingThread;
|
||||
import electrosphere.engine.cli.CLIParser;
|
||||
import electrosphere.game.client.ClientFunctions;
|
||||
import electrosphere.game.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.game.config.UserSettings;
|
||||
import electrosphere.game.data.creature.type.Animation;
|
||||
import electrosphere.game.server.saves.SaveUtils;
|
||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
||||
import electrosphere.game.server.world.MacroData;
|
||||
import electrosphere.game.server.world.ServerWorldData;
|
||||
import electrosphere.game.simulation.MacroSimulation;
|
||||
import electrosphere.game.simulation.MicroSimulation;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
import electrosphere.util.FileUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.glfw.*;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
import electrosphere.util.ModelLoader;
|
||||
import electrosphere.util.worldviewer.TerrainViewer;
|
||||
import electrosphere.util.Utilities;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.security.Provider;
|
||||
import java.security.Security;
|
||||
import java.util.Scanner;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
package electrosphere.menu;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.controls.ControlHandler.ControlsState;
|
||||
import electrosphere.engine.LoadingThread;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.state.gravity.GravityUtils;
|
||||
import electrosphere.entity.state.gravity.GravityTree.GravityTreeState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.creature.type.CreatureType;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
import electrosphere.game.server.saves.SaveUtils;
|
||||
@ -24,17 +22,13 @@ import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorStaticMorph;
|
||||
import electrosphere.renderer.actor.ActorUtils;
|
||||
import electrosphere.renderer.ui.ClickableElement;
|
||||
import electrosphere.renderer.ui.DrawableElement;
|
||||
import electrosphere.renderer.ui.Element;
|
||||
import electrosphere.renderer.ui.FocusableElement;
|
||||
import electrosphere.renderer.ui.WidgetUtils;
|
||||
import electrosphere.renderer.ui.Window;
|
||||
import electrosphere.renderer.ui.ClickableElement.ClickEventCallback;
|
||||
import electrosphere.renderer.ui.DraggableElement.DragEventCallback;
|
||||
import electrosphere.renderer.ui.FocusableElement.FocusEventCallback;
|
||||
import electrosphere.renderer.ui.NavigableElement.NavigationEventCallback;
|
||||
import electrosphere.renderer.ui.ValueElement.ValueChangeEventCallback;
|
||||
import electrosphere.renderer.ui.Window;
|
||||
import electrosphere.renderer.ui.elements.ActorPanel;
|
||||
import electrosphere.renderer.ui.elements.Button;
|
||||
import electrosphere.renderer.ui.elements.Div;
|
||||
import electrosphere.renderer.ui.elements.ImagePanel;
|
||||
@ -43,18 +37,10 @@ import electrosphere.renderer.ui.elements.ScrollableContainer;
|
||||
import electrosphere.renderer.ui.elements.Slider;
|
||||
import electrosphere.renderer.ui.elements.TextInput;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
import electrosphere.renderer.ui.events.DragEvent;
|
||||
import electrosphere.renderer.ui.events.FocusEvent;
|
||||
import electrosphere.renderer.ui.events.NavigationEvent;
|
||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||
import electrosphere.renderer.ui.form.FormElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.management.relation.Relation;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
@ -464,6 +450,12 @@ public class MenuGenerators {
|
||||
Slider slider = new Slider(0, 0, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
rVal.addChild(slider);
|
||||
|
||||
ActorPanel actorPanel = new ActorPanel(500, 100, 500, 500, ActorUtils.createActorFromModelPath("Models/deer1.fbx"));
|
||||
if(Globals.playerCamera == null){
|
||||
Globals.playerCamera = CameraEntityUtils.spawnBasicCameraEntity(new Vector3f(0,0,0), new Vector3f(-1,0,0));
|
||||
}
|
||||
rVal.addChild(actorPanel);
|
||||
|
||||
// slider = new Slider(0, 100, 500, 100, new Vector3f(0.1f,0.1f,0.1f), new Vector3f(1,0,0));
|
||||
// rVal.addChild(slider);
|
||||
|
||||
|
||||
89
src/main/java/electrosphere/menu/MenuGeneratorsDebug.java
Normal file
89
src/main/java/electrosphere/menu/MenuGeneratorsDebug.java
Normal file
@ -0,0 +1,89 @@
|
||||
package electrosphere.menu;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.debug.DebugRendering;
|
||||
import electrosphere.renderer.ui.ClickableElement;
|
||||
import electrosphere.renderer.ui.ContainerElement;
|
||||
import electrosphere.renderer.ui.Element;
|
||||
import electrosphere.renderer.ui.WidgetUtils;
|
||||
import electrosphere.renderer.ui.Window;
|
||||
import electrosphere.renderer.ui.elements.Label;
|
||||
import electrosphere.renderer.ui.elements.ScrollableContainer;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author amaterasu
|
||||
*/
|
||||
public class MenuGeneratorsDebug {
|
||||
|
||||
static final int X_OFFSET = 1000;
|
||||
|
||||
public static Window createTopLevelDebugMenu(){
|
||||
Window rVal = new Window(X_OFFSET,100,800,800);
|
||||
|
||||
//label (title)
|
||||
Label titleLabel = new Label(100,50,1.0f);
|
||||
titleLabel.setText("DEBUG");
|
||||
rVal.addChild(titleLabel);
|
||||
|
||||
//show ui tree
|
||||
rVal.addChild(WidgetUtils.createLabelButton("Lst UI Elements",100,150,1.0f,new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||
WindowUtils.replaceWindowContents(WindowStrings.WINDOW_DEBUG, MenuGeneratorsDebug.createListUIElements());
|
||||
return false;
|
||||
}}));
|
||||
|
||||
//show ui tree
|
||||
rVal.addChild(WidgetUtils.createLabelButton("Debug UI",100,250,1.0f,new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||
WindowUtils.replaceWindowContents(WindowStrings.WINDOW_DEBUG, MenuGeneratorsDebug.createDebugUIMenu());
|
||||
return false;
|
||||
}}));
|
||||
|
||||
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Element createDebugUIMenu(){
|
||||
ScrollableContainer rVal = new ScrollableContainer(0, 0, 800, 800);
|
||||
rVal.addChild(WidgetUtils.createLabelButton("Toggle UI Outline",100,150,1.0f,new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||
DebugRendering.toggleOutlineMask();
|
||||
return false;
|
||||
}}));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Element createListUIElements(){
|
||||
ScrollableContainer rVal = new ScrollableContainer(0, 0, 800, 800);
|
||||
int verticalOffset = 0;
|
||||
int horizontalOffset = 0;
|
||||
List<Element> elementsToAdd = new LinkedList<Element>();
|
||||
for(Element window : Globals.elementManager.getWindowList()){
|
||||
verticalOffset = verticalOffset + recursivelyAppendElementTree(elementsToAdd, verticalOffset, horizontalOffset, rVal);
|
||||
}
|
||||
for(Element toAdd : elementsToAdd){
|
||||
rVal.addChild(toAdd);
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
static int recursivelyAppendElementTree(List<Element> toAddList, int verticalOffset, int horizontalOffset, Element child){
|
||||
Label currentWindowLabel = new Label(100 + horizontalOffset * 25,100 + verticalOffset * 50,0.5f);
|
||||
currentWindowLabel.setText(child.toString());
|
||||
toAddList.add(currentWindowLabel);
|
||||
if(child instanceof ContainerElement){
|
||||
int cummulativeOffset = 1;
|
||||
ContainerElement childCast = (ContainerElement) child;
|
||||
for(Element childOfChild : childCast.getChildren()){
|
||||
cummulativeOffset = cummulativeOffset + recursivelyAppendElementTree(toAddList, verticalOffset + cummulativeOffset, horizontalOffset + 1, childOfChild);
|
||||
}
|
||||
return cummulativeOffset;
|
||||
} else {
|
||||
return verticalOffset + 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,5 +10,6 @@ public class WindowStrings {
|
||||
public static final String WINDDOW_ITEM_DROP = "itemDrop";
|
||||
public static final String WINDOW_ITEM_DRAG_CONTAINER = "itemDragContainer";
|
||||
public static final String WINDOW_CHARACTER = "windowCharacter";
|
||||
public static final String WINDOW_DEBUG = "windowDebug";
|
||||
|
||||
}
|
||||
|
||||
@ -269,9 +269,9 @@ public class RenderingEngine {
|
||||
// screenTextureShaders = ShaderProgram.loadSpecificShader("/Shaders/screentexture/drawDepthBuffer/drawDepthBuffer.vs", "/Shaders/screentexture/drawDepthBuffer/drawDepthBuffer.fs");
|
||||
|
||||
//generate framebuffers
|
||||
screenTextureColor = FramebufferUtils.generateScreenTextureColor(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
screenTextureDepth = FramebufferUtils.generateScreenTextureDepth(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
screenFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, screenTextureColor, screenTextureDepth);
|
||||
screenTextureColor = FramebufferUtils.generateScreenTextureColor(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
screenTextureDepth = FramebufferUtils.generateScreenTextureDepth(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
screenFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), screenTextureColor, screenTextureDepth);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, GL_DEFAULT_FRAMEBUFFER);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, GL_DEFAULT_RENDERBUFFER);
|
||||
|
||||
@ -293,10 +293,10 @@ public class RenderingEngine {
|
||||
//create volume depth framebuffer/shader for volumetric rendering
|
||||
//
|
||||
volumeDepthShaderProgram = ShaderProgram.loadSpecificShader("/Shaders/volumeBuffer/volumetric.vs", "/Shaders/volumeBuffer/volumetric.fs");
|
||||
volumeDepthBackfaceTexture = FramebufferUtils.generateDepthBufferTexture(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
volumeDepthBackfaceFramebuffer = FramebufferUtils.generateDepthBuffer(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, volumeDepthBackfaceTexture);
|
||||
volumeDepthFrontfaceTexture = FramebufferUtils.generateDepthBufferTexture(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
volumeDepthFrontfaceFramebuffer = FramebufferUtils.generateDepthBuffer(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, volumeDepthFrontfaceTexture);
|
||||
volumeDepthBackfaceTexture = FramebufferUtils.generateDepthBufferTexture(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
volumeDepthBackfaceFramebuffer = FramebufferUtils.generateDepthBuffer(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), volumeDepthBackfaceTexture);
|
||||
volumeDepthFrontfaceTexture = FramebufferUtils.generateDepthBufferTexture(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
volumeDepthFrontfaceFramebuffer = FramebufferUtils.generateDepthBuffer(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), volumeDepthFrontfaceTexture);
|
||||
|
||||
//
|
||||
//Game normals
|
||||
@ -306,19 +306,19 @@ public class RenderingEngine {
|
||||
static Framebuffer gameImageNormalsFramebuffer;
|
||||
static ShaderProgram renderNormalsShader;
|
||||
*/
|
||||
gameImageNormalsTexture = FramebufferUtils.generateScreenTextureColor(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
Texture gameImageNormalsDepthTexture = FramebufferUtils.generateScreenTextureDepth(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
gameImageNormalsFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, gameImageNormalsTexture, gameImageNormalsDepthTexture);
|
||||
gameImageNormalsTexture = FramebufferUtils.generateScreenTextureColor(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
Texture gameImageNormalsDepthTexture = FramebufferUtils.generateScreenTextureDepth(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
gameImageNormalsFramebuffer = FramebufferUtils.generateScreenTextureFramebuffer(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), gameImageNormalsTexture, gameImageNormalsDepthTexture);
|
||||
renderNormalsShader = ShaderProgram.loadSpecificShader("Shaders/anime/renderNormals.vs", "Shaders/anime/renderNormals.fs");
|
||||
|
||||
//
|
||||
//Transparency framebuffers
|
||||
//
|
||||
transparencyAccumulatorClear = new float[]{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
transparencyAccumulatorTexture = FramebufferUtils.generateOITAccumulatorTexture(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
transparencyAccumulatorTexture = FramebufferUtils.generateOITAccumulatorTexture(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
transparencyRevealageClear = new float[]{1.0f, 0.0f, 0.0f, 0.0f};
|
||||
transparencyRevealageTexture = FramebufferUtils.generateOITRevealageTexture(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
transparencyBuffer = FramebufferUtils.generateOITFramebuffer(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, transparencyAccumulatorTexture, transparencyRevealageTexture, screenTextureDepth);
|
||||
transparencyRevealageTexture = FramebufferUtils.generateOITRevealageTexture(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
transparencyBuffer = FramebufferUtils.generateOITFramebuffer(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), transparencyAccumulatorTexture, transparencyRevealageTexture, screenTextureDepth);
|
||||
oitCompositeProgram = ShaderProgram.loadSpecificShader("Shaders/oit/composite.vs", "Shaders/oit/composite.fs");
|
||||
|
||||
//projection matrices
|
||||
@ -332,8 +332,8 @@ public class RenderingEngine {
|
||||
static Framebuffer normalsOutlineFrambuffer;
|
||||
static ShaderProgram normalsOutlineShader;
|
||||
*/
|
||||
normalsOutlineTexture = FramebufferUtils.generateScreenTextureColorAlpha(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
normalsOutlineFrambuffer = FramebufferUtils.generateScreenTextureFramebuffer(Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT, normalsOutlineTexture);
|
||||
normalsOutlineTexture = FramebufferUtils.generateScreenTextureColorAlpha(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
normalsOutlineFrambuffer = FramebufferUtils.generateScreenTextureFramebuffer(Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY(), normalsOutlineTexture);
|
||||
// normalsOutlineShader = ShaderProgram.loadSpecificShader("Shaders/anime/outlineNormals.vs", "Shaders/anime/outlineNormals.fs");
|
||||
Globals.assetManager.addShaderToQueue("Shaders/anime/outlineNormals.vs", "Shaders/anime/outlineNormals.fs");
|
||||
|
||||
@ -445,7 +445,11 @@ public class RenderingEngine {
|
||||
Render content to the game framebuffer
|
||||
*/
|
||||
if(Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT){
|
||||
renderGameContent();
|
||||
if(Globals.userSettings.getGraphicsPerformanceOIT()){
|
||||
renderGameContent();
|
||||
} else {
|
||||
renderGameContentNoOIT();
|
||||
}
|
||||
renderDebugContent();
|
||||
renderNormalsForOutline();
|
||||
applyKernelsAndPostprocessing();
|
||||
@ -493,7 +497,7 @@ public class RenderingEngine {
|
||||
Render boundaries of ui elements
|
||||
*/
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||
DebugRendering.drawUIBoundsPolygon();
|
||||
DebugRendering.drawUIBoundsWireframe();
|
||||
}
|
||||
|
||||
|
||||
@ -591,7 +595,7 @@ public class RenderingEngine {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(true);
|
||||
glViewport(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
glViewport(0, 0, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
|
||||
///
|
||||
/// R E N D E R I N G S T U F F
|
||||
@ -676,6 +680,57 @@ public class RenderingEngine {
|
||||
// glBindVertexArray(0);
|
||||
}
|
||||
|
||||
static void renderGameContentNoOIT(){
|
||||
|
||||
Matrix4f modelTransformMatrix = new Matrix4f();
|
||||
|
||||
//bind screen fbo
|
||||
screenFramebuffer.bind();
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(true);
|
||||
glViewport(0, 0, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunci(0, GL_ONE, GL_ONE);
|
||||
glBlendFunci(1, GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
///
|
||||
/// R E N D E R I N G S T U F F
|
||||
///
|
||||
//Sets the background color.
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
||||
//
|
||||
// D R A W A L L E N T I T I E S
|
||||
//
|
||||
Vector3f cameraPos = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
||||
modelTransformMatrix = new Matrix4f();
|
||||
for(Entity currentEntity : Globals.entityManager.getDrawable()){
|
||||
Vector3d position = EntityUtils.getPosition(currentEntity);
|
||||
if(
|
||||
(boolean)currentEntity.getData(EntityDataStrings.DATA_STRING_DRAW) &&
|
||||
drawPoint(cameraPos,new Vector3f((float)position.x,(float)position.y,(float)position.z))
|
||||
){
|
||||
//fetch actor
|
||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||
//calculate camera-modified vector3f
|
||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
//calculate and apply model transform
|
||||
modelTransformMatrix.identity();
|
||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||
//draw
|
||||
currentActor.draw(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void renderDebugContent(){
|
||||
|
||||
//bind screen fbo
|
||||
@ -683,7 +738,7 @@ public class RenderingEngine {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(true);
|
||||
glViewport(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
glViewport(0, 0, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
|
||||
///
|
||||
/// R E N D E R I N G S T U F F
|
||||
@ -856,7 +911,7 @@ public class RenderingEngine {
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(true);
|
||||
|
||||
glViewport(0, 0, Globals.WINDOW_WIDTH, Globals.WINDOW_HEIGHT);
|
||||
glViewport(0, 0, Globals.userSettings.getRenderResolutionX(), Globals.userSettings.getRenderResolutionY());
|
||||
|
||||
///
|
||||
/// R E N D E R I N G S T U F F
|
||||
|
||||
@ -469,6 +469,7 @@ public class ShaderProgram {
|
||||
success = glGetProgrami(rVal.shaderProgram, GL_LINK_STATUS);
|
||||
if (success != GL_TRUE) {
|
||||
LoggerInterface.loggerRenderer.ERROR(glGetProgramInfoLog(rVal.shaderProgram), new RuntimeException(glGetProgramInfoLog(rVal.shaderProgram)));
|
||||
LoggerInterface.loggerRenderer.WARNING("Shader sources: " + vertexPath + " " + fragmentPath);
|
||||
return Globals.defaultMeshShader;
|
||||
// throw new RuntimeException(glGetProgramInfoLog(rVal.shaderProgram));
|
||||
}
|
||||
|
||||
@ -21,8 +21,17 @@ import electrosphere.renderer.ui.elements.ImagePanel;
|
||||
|
||||
|
||||
public class DebugRendering {
|
||||
|
||||
public static boolean RENDER_DEBUG_OUTLINE_WINDOW = true;
|
||||
public static boolean RENDER_DEBUG_OUTLINE_DIV = false;
|
||||
public static boolean RENDER_DEBUG_OUTLINE_BUTTON = false;
|
||||
public static boolean RENDER_DEBUG_OUTLINE_LABEL = false;
|
||||
public static boolean RENDER_DEBUG_OUTLINE_ACTOR_PANEL = false;
|
||||
public static boolean RENDER_DEBUG_OUTLINE_SLIDER = false;
|
||||
|
||||
static int outlineMaskPosition = 0;
|
||||
|
||||
public static void drawUIBoundsPolygon(){
|
||||
public static void drawUIBoundsWireframe(){
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
for(Element currentElement : Globals.elementManager.getWindowList()){
|
||||
@ -40,14 +49,39 @@ public class DebugRendering {
|
||||
}
|
||||
|
||||
static ShaderProgram windowDrawDebugProgram = null;
|
||||
static ShaderProgram elementDrawDebugProgram = null;
|
||||
static Model planeModel = null;
|
||||
public static void drawUIBounds(int parentFramebufferPointer, Vector3f boxPosition, Vector3f boxDimensions, Vector3f color){
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||
if(planeModel == null){
|
||||
planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||
}
|
||||
if(elementDrawDebugProgram == null){
|
||||
elementDrawDebugProgram = Globals.assetManager.fetchShader("Shaders/ui/debug/windowContentBorder/windowContentBound.vs", null, "Shaders/ui/debug/windowContentBorder/windowContentBound.fs");
|
||||
}
|
||||
if(elementDrawDebugProgram != null && planeModel != null){
|
||||
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
|
||||
Globals.renderingEngine.setActiveShader(elementDrawDebugProgram);
|
||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "color", color);
|
||||
// planeModel.drawUI();
|
||||
// if(Globals.assetManager.fetchShader("Shaders/plane/plane.vs", null, "Shaders/plane/plane.fs") != null){
|
||||
// Globals.renderingEngine.setActiveShader(Globals.assetManager.fetchShader("Shaders/plane/plane.vs", null, "Shaders/plane/plane.fs"));
|
||||
// }
|
||||
//drawUI sets shader so overriding window bound shader
|
||||
planeModel.draw(false, false, true, false, false, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawUIBoundsWindow(int parentFramebufferPointer, Vector3f boxPosition, Vector3f boxDimensions, Vector3f color){
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||
if(planeModel == null){
|
||||
planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||
}
|
||||
if(windowDrawDebugProgram == null){
|
||||
windowDrawDebugProgram = Globals.assetManager.fetchShader("Shaders/ui/debug/windowBound.vs", null, "Shaders/ui/debug/windowBound.fs");
|
||||
windowDrawDebugProgram = Globals.assetManager.fetchShader("Shaders/ui/debug/windowBorder/windowBound.vs", null, "Shaders/ui/debug/windowBorder/windowBound.fs");
|
||||
}
|
||||
if(windowDrawDebugProgram != null && planeModel != null){
|
||||
Globals.renderingEngine.bindFramebuffer(parentFramebufferPointer);
|
||||
@ -56,6 +90,9 @@ public class DebugRendering {
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "color", color);
|
||||
// planeModel.drawUI();
|
||||
// if(Globals.assetManager.fetchShader("Shaders/plane/plane.vs", null, "Shaders/plane/plane.fs") != null){
|
||||
// Globals.renderingEngine.setActiveShader(Globals.assetManager.fetchShader("Shaders/plane/plane.vs", null, "Shaders/plane/plane.fs"));
|
||||
// }
|
||||
//drawUI sets shader so overriding window bound shader
|
||||
planeModel.draw(false, false, true, false, false, false, false);
|
||||
}
|
||||
@ -100,4 +137,36 @@ public class DebugRendering {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void toggleOutlineMask(){
|
||||
outlineMaskPosition = outlineMaskPosition + 1;
|
||||
RENDER_DEBUG_OUTLINE_WINDOW = false;
|
||||
RENDER_DEBUG_OUTLINE_DIV = false;
|
||||
RENDER_DEBUG_OUTLINE_BUTTON = false;
|
||||
RENDER_DEBUG_OUTLINE_LABEL = false;
|
||||
RENDER_DEBUG_OUTLINE_ACTOR_PANEL = false;
|
||||
switch(outlineMaskPosition){
|
||||
case 1:
|
||||
RENDER_DEBUG_OUTLINE_DIV = true;
|
||||
break;
|
||||
case 2:
|
||||
RENDER_DEBUG_OUTLINE_LABEL = true;
|
||||
break;
|
||||
case 3:
|
||||
RENDER_DEBUG_OUTLINE_BUTTON = true;
|
||||
break;
|
||||
case 4:
|
||||
RENDER_DEBUG_OUTLINE_ACTOR_PANEL = true;
|
||||
break;
|
||||
case 5:
|
||||
RENDER_DEBUG_OUTLINE_SLIDER = true;
|
||||
break;
|
||||
default:
|
||||
case 0:
|
||||
outlineMaskPosition = 0;
|
||||
RENDER_DEBUG_OUTLINE_WINDOW = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,12 +2,8 @@ package electrosphere.renderer.ui;
|
||||
|
||||
import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.ui.elements.ImagePanel;
|
||||
import electrosphere.renderer.ui.elements.Button;
|
||||
import electrosphere.renderer.ui.elements.Label;
|
||||
import electrosphere.renderer.ui.elements.TextInput;
|
||||
import electrosphere.renderer.ui.font.FontUtils;
|
||||
import electrosphere.renderer.ui.font.bitmapchar.BitmapCharacter;
|
||||
import electrosphere.renderer.ui.layout.LayoutSchemeListScrollable;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -151,6 +147,15 @@ public class WidgetUtils {
|
||||
// Globals.widgetManager.registerWidget(rVal);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static Button createLabelButton(String label, int posX, int posY, float fontSize, ClickableElement.ClickEventCallback callback){
|
||||
Button rVal = new Button();
|
||||
Label buttonLabel = new Label(posX,posY,fontSize);
|
||||
buttonLabel.setText(label);
|
||||
rVal.addChild(buttonLabel);
|
||||
rVal.setOnClick(callback);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -46,10 +46,10 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
// widgetBuffer = FramebufferUtils.generateScreensizeTextureFramebuffer();
|
||||
customMat.setTexturePointer(widgetBuffer.getTexturePointer());
|
||||
// customMat.setTexturePointer(Globals.assetManager.fetchTexture("Textures/Testing1.png").getTexturePointer());
|
||||
float ndcX = (float)positionX/Globals.WINDOW_WIDTH;
|
||||
float ndcY = (float)positionY/Globals.WINDOW_HEIGHT;
|
||||
float ndcWidth = (float)width/Globals.WINDOW_WIDTH;
|
||||
float ndcHeight = (float)height/Globals.WINDOW_HEIGHT;
|
||||
float ndcX = (float)positionX/Globals.WINDOW_WIDTH;
|
||||
float ndcY = (float)positionY/Globals.WINDOW_HEIGHT;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||
@ -88,8 +88,8 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model!!", new Exception());
|
||||
}
|
||||
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS && DebugRendering.RENDER_DEBUG_OUTLINE_WINDOW){
|
||||
DebugRendering.drawUIBoundsWindow(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,37 +1,37 @@
|
||||
package electrosphere.renderer.ui.elements;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_LESS;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.glDepthFunc;
|
||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_LESS;
|
||||
import static org.lwjgl.opengl.GL11.glClear;
|
||||
import static org.lwjgl.opengl.GL11.glClearColor;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.glDepthFunc;
|
||||
import static org.lwjgl.opengl.GL11.glDepthMask;
|
||||
import static org.lwjgl.opengl.GL11.glDisable;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.glViewport;
|
||||
import static org.lwjgl.opengl.GL30.GL_FRAMEBUFFER;
|
||||
import static org.lwjgl.opengl.GL30.glBindFramebuffer;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.renderer.Material;
|
||||
import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.debug.DebugRendering;
|
||||
import electrosphere.renderer.framebuffer.Framebuffer;
|
||||
import electrosphere.renderer.framebuffer.FramebufferUtils;
|
||||
import electrosphere.renderer.texture.Texture;
|
||||
import electrosphere.renderer.ui.DraggableElement;
|
||||
import electrosphere.renderer.ui.DrawableElement;
|
||||
import electrosphere.renderer.ui.events.DragEvent;
|
||||
import electrosphere.renderer.ui.events.Event;
|
||||
import electrosphere.renderer.ui.events.DragEvent.DragEventType;
|
||||
import electrosphere.renderer.ui.events.Event;
|
||||
|
||||
public class ActorPanel implements DrawableElement, DraggableElement {
|
||||
|
||||
@ -54,6 +54,8 @@ public class ActorPanel implements DrawableElement, DraggableElement {
|
||||
DragEventCallback onDragStart;
|
||||
DragEventCallback onDrag;
|
||||
DragEventCallback onDragRelease;
|
||||
|
||||
static final Vector3f windowDrawDebugColor = new Vector3f(0.0f,0.0f,1.0f);
|
||||
|
||||
public ActorPanel(int x, int y, int width, int height, Actor actor){
|
||||
elementBuffer = FramebufferUtils.generateTextureFramebuffer(width, height);
|
||||
@ -115,18 +117,24 @@ public class ActorPanel implements DrawableElement, DraggableElement {
|
||||
|
||||
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
|
||||
Globals.renderingEngine.setActiveShader(Globals.assetManager.fetchShader("Shaders/ui/windowContent/windowContent.vs", null, "Shaders/ui/windowContent/windowContent.fs"));
|
||||
|
||||
Model planeModel = Globals.assetManager.fetchModel(ImagePanel.imagePanelModelPath);
|
||||
Model planeModel = Globals.assetManager.fetchModel(Globals.imagePlaneModelID);
|
||||
if(planeModel != null){
|
||||
planeModel.pushUniformToMesh("plane", "mPosition", boxPosition);
|
||||
planeModel.pushUniformToMesh("plane", "mDimension", boxDimensions);
|
||||
planeModel.pushUniformToMesh("plane", "tPosition", texPosition);
|
||||
planeModel.pushUniformToMesh("plane", "tDimension", texScale);
|
||||
planeModel.meshes.get(0).setMaterial(customMat);
|
||||
planeModel.drawUI();
|
||||
planeModel.draw(false, false, true, true, false, false, false);
|
||||
} else {
|
||||
LoggerInterface.loggerRenderer.ERROR("Actor Panel unable to find plane model!!", new Exception());
|
||||
}
|
||||
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS && DebugRendering.RENDER_DEBUG_OUTLINE_ACTOR_PANEL){
|
||||
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||
}
|
||||
}
|
||||
|
||||
public int width = 1;
|
||||
|
||||
@ -5,6 +5,8 @@ import java.util.List;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.debug.DebugRendering;
|
||||
import electrosphere.renderer.ui.ClickableElement;
|
||||
import electrosphere.renderer.ui.ContainerElement;
|
||||
import electrosphere.renderer.ui.DrawableElement;
|
||||
@ -35,6 +37,8 @@ public class Button implements DrawableElement, FocusableElement, ContainerEleme
|
||||
FocusEventCallback onLoseFocusCallback;
|
||||
ClickEventCallback clickCallback;
|
||||
|
||||
static final Vector3f windowDrawDebugColor = new Vector3f(1.0f,1.0f,1.0f);
|
||||
|
||||
public int getWidth() {
|
||||
if(width == -1){
|
||||
int minX = -1;
|
||||
@ -207,6 +211,16 @@ public class Button implements DrawableElement, FocusableElement, ContainerEleme
|
||||
drawableChild.draw(parentFramebufferPointer,parentWidth,parentHeight);
|
||||
}
|
||||
}
|
||||
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS && DebugRendering.RENDER_DEBUG_OUTLINE_BUTTON){
|
||||
float ndcX = (float)positionX/parentWidth;
|
||||
float ndcY = (float)positionY/parentHeight;
|
||||
float ndcWidth = (float)getWidth()/parentWidth;
|
||||
float ndcHeight = (float)getHeight()/parentHeight;
|
||||
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -3,6 +3,10 @@ package electrosphere.renderer.ui.elements;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.debug.DebugRendering;
|
||||
import electrosphere.renderer.ui.ClickableElement;
|
||||
import electrosphere.renderer.ui.ContainerElement;
|
||||
import electrosphere.renderer.ui.DraggableElement;
|
||||
@ -12,10 +16,10 @@ import electrosphere.renderer.ui.FocusableElement;
|
||||
import electrosphere.renderer.ui.NavigableElement;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
import electrosphere.renderer.ui.events.DragEvent;
|
||||
import electrosphere.renderer.ui.events.DragEvent.DragEventType;
|
||||
import electrosphere.renderer.ui.events.Event;
|
||||
import electrosphere.renderer.ui.events.FocusEvent;
|
||||
import electrosphere.renderer.ui.events.NavigationEvent;
|
||||
import electrosphere.renderer.ui.events.DragEvent.DragEventType;
|
||||
|
||||
public class Div implements ClickableElement,ContainerElement,DraggableElement,FocusableElement,DrawableElement,NavigableElement {
|
||||
|
||||
@ -41,6 +45,8 @@ public class Div implements ClickableElement,ContainerElement,DraggableElement,F
|
||||
|
||||
public boolean visible = false;
|
||||
|
||||
static final Vector3f windowDrawDebugColor = new Vector3f(1.0f,1.0f,1.0f);
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
if(width == -1){
|
||||
@ -335,6 +341,16 @@ public class Div implements ClickableElement,ContainerElement,DraggableElement,F
|
||||
drawableChild.draw(parentFramebufferPointer,parentWidth,parentHeight);
|
||||
}
|
||||
}
|
||||
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS && DebugRendering.RENDER_DEBUG_OUTLINE_DIV){
|
||||
float ndcX = (float)positionX/parentWidth;
|
||||
float ndcY = (float)positionY/parentHeight;
|
||||
float ndcWidth = (float)getWidth()/parentWidth;
|
||||
float ndcHeight = (float)getHeight()/parentHeight;
|
||||
Vector3f boxPosition = new Vector3f(ndcX,ndcY,0);
|
||||
Vector3f boxDimensions = new Vector3f(ndcWidth,ndcHeight,0);
|
||||
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -86,7 +86,7 @@ public class Label implements DrawableElement {
|
||||
child.draw(parentFramebufferPointer, parentWidth, parentHeight);
|
||||
}
|
||||
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS){
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS && DebugRendering.RENDER_DEBUG_OUTLINE_LABEL){
|
||||
float ndcX = (float)positionX/parentWidth;
|
||||
float ndcY = (float)positionY/parentHeight;
|
||||
float ndcWidth = (float)getWidth()/parentWidth;
|
||||
|
||||
@ -5,22 +5,20 @@ import org.joml.Vector3f;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.debug.DebugRendering;
|
||||
import electrosphere.renderer.ui.ClickableElement;
|
||||
import electrosphere.renderer.ui.DraggableElement;
|
||||
import electrosphere.renderer.ui.DrawableElement;
|
||||
import electrosphere.renderer.ui.FocusableElement;
|
||||
import electrosphere.renderer.ui.KeyEventElement;
|
||||
import electrosphere.renderer.ui.MenuEventElement;
|
||||
import electrosphere.renderer.ui.ValueElement;
|
||||
import electrosphere.renderer.ui.events.ClickEvent;
|
||||
import electrosphere.renderer.ui.events.DragEvent;
|
||||
import electrosphere.renderer.ui.events.DragEvent.DragEventType;
|
||||
import electrosphere.renderer.ui.events.Event;
|
||||
import electrosphere.renderer.ui.events.FocusEvent;
|
||||
import electrosphere.renderer.ui.events.KeyboardEvent;
|
||||
import electrosphere.renderer.ui.events.MenuEvent;
|
||||
import electrosphere.renderer.ui.events.MouseEvent;
|
||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||
import electrosphere.renderer.ui.events.DragEvent.DragEventType;
|
||||
|
||||
public class Slider implements ClickableElement, DraggableElement, FocusableElement, DrawableElement, MenuEventElement, ValueElement {
|
||||
|
||||
@ -56,6 +54,8 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
||||
|
||||
static final int idealMargin = 5; //5 pixels margin ideally
|
||||
|
||||
static final Vector3f windowDrawDebugColor = new Vector3f(1.0f,1.0f,1.0f);
|
||||
|
||||
|
||||
|
||||
public Slider(int positionX, int positionY, int width, int height, Vector3f colorBackground, Vector3f colorForeground){
|
||||
@ -119,6 +119,10 @@ public class Slider implements ClickableElement, DraggableElement, FocusableElem
|
||||
} else {
|
||||
LoggerInterface.loggerRenderer.ERROR("Window unable to find plane model!!", new Exception());
|
||||
}
|
||||
if(Globals.RENDER_FLAG_RENDER_UI_BOUNDS && DebugRendering.RENDER_DEBUG_OUTLINE_SLIDER){
|
||||
boxDimensions.x = (float)((width - marginX * 2) * 1.0f)/parentWidth;
|
||||
DebugRendering.drawUIBounds(parentFramebufferPointer, boxPosition, boxDimensions, windowDrawDebugColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
60
src/main/java/electrosphere/script/ScriptEngine.java
Normal file
60
src/main/java/electrosphere/script/ScriptEngine.java
Normal file
@ -0,0 +1,60 @@
|
||||
package electrosphere.script;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.graalvm.polyglot.Context;
|
||||
import org.graalvm.polyglot.Source;
|
||||
import org.graalvm.polyglot.Value;
|
||||
|
||||
import electrosphere.util.FileUtils;
|
||||
|
||||
public class ScriptEngine {
|
||||
|
||||
Context context;
|
||||
|
||||
Map<String,Source> sourceMap;
|
||||
|
||||
public void init(){
|
||||
//init datastructures
|
||||
sourceMap = new HashMap<String,Source>();
|
||||
//create context
|
||||
context = Context.create("js");
|
||||
//read scripts into source map
|
||||
readScriptsDirectory("/Scripts", FileUtils.getAssetFile("/Scripts"));
|
||||
//create bindings
|
||||
try {
|
||||
String content = FileUtils.getAssetFileAsString("/Scripts/test.js");
|
||||
Source source = Source.create("js", content);
|
||||
context.eval(source);
|
||||
System.out.println("Evaluated");
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
void createBindings(){
|
||||
Value jsBindings = context.getBindings("js");
|
||||
jsBindings.putMember("name", "somescript");
|
||||
}
|
||||
|
||||
void readScriptsDirectory(String path, File directory){
|
||||
if(directory.exists() && directory.isDirectory()){
|
||||
File[] children = directory.listFiles();
|
||||
for(File childFile : children){
|
||||
String qualifiedName = path + "/" + childFile.getName();
|
||||
if(childFile.isDirectory()){
|
||||
readScriptsDirectory(qualifiedName,childFile);
|
||||
} else {
|
||||
//add to source map
|
||||
String content = FileUtils.readFileToString(childFile);
|
||||
sourceMap.put(qualifiedName,Source.create("js",content));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user