work towards marching, need to fix point lights
This commit is contained in:
parent
9e2b0d396e
commit
5c7d9e7153
@ -55,6 +55,11 @@ uniform sampler2D shadowMap;
|
|||||||
uniform sampler2D volumeDepthFrontface;
|
uniform sampler2D volumeDepthFrontface;
|
||||||
uniform sampler2D volumeDepthBackface;
|
uniform sampler2D volumeDepthBackface;
|
||||||
|
|
||||||
|
//transform matrices uniforms
|
||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 view;
|
||||||
|
uniform mat4 projection;
|
||||||
|
|
||||||
//function declarations
|
//function declarations
|
||||||
vec4 openSimplex2_Conventional(vec3 X);
|
vec4 openSimplex2_Conventional(vec3 X);
|
||||||
vec4 openSimplex2_ImproveXY(vec3 X);
|
vec4 openSimplex2_ImproveXY(vec3 X);
|
||||||
@ -85,76 +90,32 @@ void main(){
|
|||||||
//based on distance of model coords from center
|
//based on distance of model coords from center
|
||||||
float dist = length(modelCoord.xyz);
|
float dist = length(modelCoord.xyz);
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/38938498/how-do-i-convert-gl-fragcoord-to-a-world-space-point-in-a-fragment-shader
|
||||||
|
vec4 ndcPos;
|
||||||
|
ndcPos.xy = ((2.0 * gl_FragCoord.xy) - (2.0 * projCoord.xy)) / (projCoord.zw) - 1;
|
||||||
|
ndcPos.z = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far) /
|
||||||
|
(gl_DepthRange.far - gl_DepthRange.near);
|
||||||
|
ndcPos.w = 1.0;
|
||||||
|
|
||||||
//noise
|
vec4 clipPos = ndcPos / gl_FragCoord.w;
|
||||||
// float noiseInX = modelCoord.x * 7.0;
|
// vec4 eyePos = inverse(model) * inverse(view) * inverse(projection) * clipPos;
|
||||||
// float noiseInZ = FragPos.y * 7.0 - timeS;
|
vec4 eyePos = inverse(projection) * inverse(view) * inverse(model) * clipPos;
|
||||||
// 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 red = 0.1984;
|
||||||
float green = 0.6464;
|
float green = 0.6464;
|
||||||
float blue = 0.7366;
|
float blue = 0.7366;
|
||||||
float alpha = volume * 7.0;
|
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(
|
vec4 noiseVal = openSimplex2_Conventional(vec3(
|
||||||
projCoordNorm.x * 20,
|
projCoordNorm.x * 20,
|
||||||
projCoordNorm.y * 20,
|
projCoordNorm.y * 20,
|
||||||
projCoordNorm.z * 20 + timeS * 3));
|
projCoordNorm.z * 20 + timeS * 3));
|
||||||
|
|
||||||
vec4 color = vec4(
|
vec4 color = vec4(
|
||||||
noiseVal.x,
|
FragPos.x / 10,
|
||||||
noiseVal.y,
|
FragPos.y / 10,
|
||||||
noiseVal.z,
|
FragPos.z / 10,
|
||||||
alpha * volume
|
alpha * volume
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,7 @@ public class CameraEntityUtils {
|
|||||||
if(Globals.playerEntity != null){
|
if(Globals.playerEntity != null){
|
||||||
Vector3d entityPos = EntityUtils.getPosition(Globals.playerEntity);
|
Vector3d entityPos = EntityUtils.getPosition(Globals.playerEntity);
|
||||||
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
CameraEntityUtils.setCameraCenter(rVal, new Vector3f((float)entityPos.x,(float)entityPos.y,(float)entityPos.z).add(getOrbitalCameraRadialOffset(rVal)));
|
||||||
|
Globals.viewMatrix = CameraEntityUtils.getCameraViewMatrix(Globals.playerCamera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -135,7 +136,7 @@ public class CameraEntityUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Matrix4f getCameraViewMatrix(Entity camera){
|
public static Matrix4f getCameraViewMatrix(Entity camera){
|
||||||
Vector3f cameraCenter = new Vector3f(0,0,0);//getViewMatrixCenterOffset(camera);
|
Vector3f cameraCenter = getCameraCenter(camera);//new Vector3f(0,0,0);//getViewMatrixCenterOffset(camera);
|
||||||
Vector3f cameraEye = new Vector3f(cameraCenter).add(getCameraEye(camera));
|
Vector3f cameraEye = new Vector3f(cameraCenter).add(getCameraEye(camera));
|
||||||
Vector3f cameraUp = new Vector3f(0,1.0f,0);
|
Vector3f cameraUp = new Vector3f(0,1.0f,0);
|
||||||
// System.out.println("eye: " + cameraEye);
|
// System.out.println("eye: " + cameraEye);
|
||||||
|
|||||||
@ -559,11 +559,10 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraCenter = CameraEntityUtils.getCameraCenter(Globals.playerCamera);
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(cameraCenter);
|
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix = modelTransformMatrix.identity();
|
modelTransformMatrix = modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
@ -624,10 +623,10 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
@ -663,10 +662,10 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
@ -718,10 +717,10 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
@ -757,9 +756,9 @@ public class RenderingEngine {
|
|||||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/unitsphere.fbx")) != null){
|
if((hitboxModel = Globals.assetManager.fetchModel("Models/unitsphere.fbx")) != null){
|
||||||
Vector3d position = EntityUtils.getPosition(currentHitbox);
|
Vector3d position = EntityUtils.getPosition(currentHitbox);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
// modelTransformMatrix.translate(-0.25f, 0.0f, 0.5f); //center sphere
|
// modelTransformMatrix.translate(-0.25f, 0.0f, 0.5f); //center sphere
|
||||||
modelTransformMatrix.scale(data.getRadius() * 2);
|
modelTransformMatrix.scale(data.getRadius() * 2);
|
||||||
hitboxModel.modelMatrix = modelTransformMatrix;
|
hitboxModel.modelMatrix = modelTransformMatrix;
|
||||||
@ -769,9 +768,9 @@ public class RenderingEngine {
|
|||||||
if((hitboxModel = Globals.assetManager.fetchModel("Models/unitsphere_1.fbx")) != null){
|
if((hitboxModel = Globals.assetManager.fetchModel("Models/unitsphere_1.fbx")) != null){
|
||||||
Vector3d position = EntityUtils.getPosition(currentHitbox);
|
Vector3d position = EntityUtils.getPosition(currentHitbox);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
// modelTransformMatrix.translate(-0.25f, 0.0f, 0.5f); //center sphere
|
// modelTransformMatrix.translate(-0.25f, 0.0f, 0.5f); //center sphere
|
||||||
modelTransformMatrix.scale(data.getRadius() * 2);
|
modelTransformMatrix.scale(data.getRadius() * 2);
|
||||||
hitboxModel.modelMatrix = modelTransformMatrix;
|
hitboxModel.modelMatrix = modelTransformMatrix;
|
||||||
@ -803,9 +802,9 @@ public class RenderingEngine {
|
|||||||
if((physicsGraphicsModel = Globals.assetManager.fetchModel("Models/unitcylinder.fbx")) != null){
|
if((physicsGraphicsModel = Globals.assetManager.fetchModel("Models/unitcylinder.fbx")) != null){
|
||||||
Vector3d position = EntityUtils.getPosition(physicsEntity);
|
Vector3d position = EntityUtils.getPosition(physicsEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).add(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z).add(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ());
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(physicsEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(physicsEntity));
|
||||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||||
modelTransformMatrix.scale(template.getDimension1(),template.getDimension2(),template.getDimension3());
|
modelTransformMatrix.scale(template.getDimension1(),template.getDimension2(),template.getDimension3());
|
||||||
@ -819,9 +818,9 @@ public class RenderingEngine {
|
|||||||
// Vector3f scale = EntityUtils.getScale(physicsEntity);
|
// Vector3f scale = EntityUtils.getScale(physicsEntity);
|
||||||
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).add(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z).add(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ());
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(rotation);
|
modelTransformMatrix.rotate(rotation);
|
||||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||||
modelTransformMatrix.scale(template.getDimension1(),template.getDimension2(),template.getDimension3());
|
modelTransformMatrix.scale(template.getDimension1(),template.getDimension2(),template.getDimension3());
|
||||||
@ -840,9 +839,9 @@ public class RenderingEngine {
|
|||||||
Vector3f scale = EntityUtils.getScale(physicsEntity);
|
Vector3f scale = EntityUtils.getScale(physicsEntity);
|
||||||
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(rotation);
|
modelTransformMatrix.rotate(rotation);
|
||||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||||
modelTransformMatrix.scale(scale);
|
modelTransformMatrix.scale(scale);
|
||||||
@ -855,9 +854,9 @@ public class RenderingEngine {
|
|||||||
Vector3f scale = EntityUtils.getScale(physicsEntity);
|
Vector3f scale = EntityUtils.getScale(physicsEntity);
|
||||||
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
Quaternionf rotation = EntityUtils.getRotation(physicsEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(rotation);
|
modelTransformMatrix.rotate(rotation);
|
||||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||||
modelTransformMatrix.scale(scale);
|
modelTransformMatrix.scale(scale);
|
||||||
@ -880,9 +879,9 @@ public class RenderingEngine {
|
|||||||
Vector3f scale = new Vector3f((float)(cube.getMaxPoint().x-cube.getMinPoint().x)/2,(float)(cube.getMaxPoint().y-cube.getMinPoint().y)/2,(float)(cube.getMaxPoint().z-cube.getMinPoint().z)/2);
|
Vector3f scale = new Vector3f((float)(cube.getMaxPoint().x-cube.getMinPoint().x)/2,(float)(cube.getMaxPoint().y-cube.getMinPoint().y)/2,(float)(cube.getMaxPoint().z-cube.getMinPoint().z)/2);
|
||||||
Quaternionf rotation = new Quaternionf();
|
Quaternionf rotation = new Quaternionf();
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(rotation);
|
modelTransformMatrix.rotate(rotation);
|
||||||
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
// modelTransformMatrix.translate(template.getOffsetX(),template.getOffsetY(),template.getOffsetZ()); //center sphere
|
||||||
modelTransformMatrix.scale(scale);
|
modelTransformMatrix.scale(scale);
|
||||||
@ -937,10 +936,10 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix.identity();
|
modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
@ -1168,7 +1167,7 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
//set projection matrix
|
//set projection matrix
|
||||||
// if(cameraModifiedPosition.length() > 2f){
|
// if(cameraModifiedPosition.length() > 2f){
|
||||||
// glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "projection"), false, farVolumeProjectionMatrix.get(new float[16]));
|
// glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "projection"), false, farVolumeProjectionMatrix.get(new float[16]));
|
||||||
@ -1180,7 +1179,7 @@ public class RenderingEngine {
|
|||||||
// glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "projection"), false, Globals.projectionMatrix.get(new float[16]));
|
// glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "projection"), false, Globals.projectionMatrix.get(new float[16]));
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix = modelTransformMatrix.identity();
|
modelTransformMatrix = modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
@ -1206,11 +1205,11 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
//set projection matrix
|
//set projection matrix
|
||||||
glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "projection"), false, nearVolumeProjectionMatrix.get(new float[16]));
|
glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "projection"), false, nearVolumeProjectionMatrix.get(new float[16]));
|
||||||
modelTransformMatrix = modelTransformMatrix.identity();
|
modelTransformMatrix = modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
@ -1255,10 +1254,10 @@ public class RenderingEngine {
|
|||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//calculate camera-modified vector3f
|
//calculate camera-modified vector3f
|
||||||
Vector3f cameraModifiedPosition = new Vector3f((float)position.x,(float)position.y,(float)position.z).sub(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3f positionf = new Vector3f((float)position.x,(float)position.y,(float)position.z);
|
||||||
//calculate and apply model transform
|
//calculate and apply model transform
|
||||||
modelTransformMatrix = modelTransformMatrix.identity();
|
modelTransformMatrix = modelTransformMatrix.identity();
|
||||||
modelTransformMatrix.translate(cameraModifiedPosition);
|
modelTransformMatrix.translate(positionf);
|
||||||
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
modelTransformMatrix.rotate(EntityUtils.getRotation(currentEntity));
|
||||||
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
modelTransformMatrix.scale(EntityUtils.getScale(currentEntity));
|
||||||
currentActor.applyModelMatrix(modelTransformMatrix);
|
currentActor.applyModelMatrix(modelTransformMatrix);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user