diff --git a/jme3-core/src/main/java/com/jme3/animation/Bone.java b/jme3-core/src/main/java/com/jme3/animation/Bone.java index fcbacb337..3eae12137 100644 --- a/jme3-core/src/main/java/com/jme3/animation/Bone.java +++ b/jme3-core/src/main/java/com/jme3/animation/Bone.java @@ -812,13 +812,47 @@ public final class Bone implements Savable { output.writeSavableArrayList(children, "children", null); } + /** + * Sets the rotation of the bone in object space. + * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation + * @param rot + */ public void setLocalRotation(Quaternion rot){ if (!userControl) { throw new IllegalStateException("User control must be on bone to allow user transforms"); } - this.localRot = rot; + this.localRot.set(rot); } - + + /** + * Sets the position of the bone in object space. + * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation + * @param pos + */ + public void setLocalTranslation(Vector3f pos){ + if (!userControl) { + throw new IllegalStateException("User control must be on bone to allow user transforms"); + } + this.localPos.set(pos); + } + + /** + * Sets the scale of the bone in object space. + * Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation + * @param scale the scale to apply + */ + public void setLocalScale(Vector3f scale){ + if (!userControl) { + throw new IllegalStateException("User control must be on bone to allow user transforms"); + } + this.localScale.set(scale); + } + + /** + * returns true if this bone can be directly manipulated by the user. + * @see #setUserControl(boolean) + * @return + */ public boolean hasUserControl(){ return userControl; } diff --git a/jme3-core/src/main/java/com/jme3/light/SpotLight.java b/jme3-core/src/main/java/com/jme3/light/SpotLight.java index 636f1447f..70115bbc5 100644 --- a/jme3-core/src/main/java/com/jme3/light/SpotLight.java +++ b/jme3-core/src/main/java/com/jme3/light/SpotLight.java @@ -102,7 +102,7 @@ public class SpotLight extends Light { this(); setPosition(position); setDirection(direction); - this.spotRange = range; + setSpotRange(range); } /** @@ -133,7 +133,7 @@ public class SpotLight extends Light { computeAngleParameters(); setPosition(position); setDirection(direction); - this.spotRange = range; + setSpotRange(range); } /** @@ -158,7 +158,7 @@ public class SpotLight extends Light { computeAngleParameters(); setPosition(position); setDirection(direction); - this.spotRange = range; + setSpotRange(range); } diff --git a/jme3-core/src/main/java/com/jme3/math/FastMath.java b/jme3-core/src/main/java/com/jme3/math/FastMath.java index 4f1a7feed..c1c3fa8a9 100644 --- a/jme3-core/src/main/java/com/jme3/math/FastMath.java +++ b/jme3-core/src/main/java/com/jme3/math/FastMath.java @@ -942,8 +942,7 @@ final public class FastMath { * Converts a single precision (32 bit) floating point value * into half precision (16 bit). * - *

Source: - * http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf
broken link + *

Source: =colorBufs.size()) { + return colorBufs.get(0); + } + return colorBufs.get(colorBufIndex); } /** diff --git a/jme3-core/src/main/java/com/jme3/texture/Image.java b/jme3-core/src/main/java/com/jme3/texture/Image.java index 91b80ad3e..39c7725c0 100644 --- a/jme3-core/src/main/java/com/jme3/texture/Image.java +++ b/jme3-core/src/main/java/com/jme3/texture/Image.java @@ -299,7 +299,33 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ { * * Requires {@link Caps#TextureCompressionETC1}. */ - ETC1(4, false, true, false); + ETC1(4, false, true, false), + + R8I(8), + R8UI(8), + R16I(16), + R16UI(16), + R32I(32), + R32UI(32), + RG8I(16), + RG8UI(16), + RG16I(32), + RG16UI(32), + RG32I(64), + RG32UI(64), + RGB8I(24), + RGB8UI(24), + RGB16I(48), + RGB16UI(48), + RGB32I(96), + RGB32UI(96), + RGBA8I(32), + RGBA8UI(32), + RGBA16I(64), + RGBA16UI(64), + RGBA32I(128), + RGBA32UI(128) + ; private int bpp; private boolean isDepth; diff --git a/jme3-core/src/main/java/com/jme3/util/ListSort.java b/jme3-core/src/main/java/com/jme3/util/ListSort.java index 8f61961ad..b88235f37 100644 --- a/jme3-core/src/main/java/com/jme3/util/ListSort.java +++ b/jme3-core/src/main/java/com/jme3/util/ListSort.java @@ -698,9 +698,11 @@ public class ListSort { System.arraycopy(arr, iterB, arr, dest, lengthB); // The last element of run A belongs at the end of the merge. arr[dest + lengthB] = tempArray[iterA]; - } else if(lengthA== 0){ + } else if(lengthA == 0){ throw new UnsupportedOperationException("Compare function result changed! " + - "Make sure you do not modify the scene from another thread!"); + "Make sure you do not modify the scene from" + + " another thread and that the comparisons are not based" + + " on NaN values."); } else {//Fail label System.arraycopy(tempArray, iterA, arr, dest, lengthA); } diff --git a/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java b/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java index 5e85378ff..ac6b05a8c 100644 --- a/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java +++ b/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java @@ -226,23 +226,7 @@ public class TangentBinormalGenerator { processTriangleData(mesh, vertices, approxTangents,splitMirrored); //if the mesh has a bind pose, we need to generate the bind pose for the tangent buffer - if (mesh.getBuffer(Type.BindPosePosition) != null) { - - VertexBuffer tangents = mesh.getBuffer(Type.Tangent); - if (tangents != null) { - VertexBuffer bindTangents = new VertexBuffer(Type.BindPoseTangent); - bindTangents.setupData(Usage.CpuOnly, - 4, - Format.Float, - BufferUtils.clone(tangents.getData())); - - if (mesh.getBuffer(Type.BindPoseTangent) != null) { - mesh.clearBuffer(Type.BindPoseTangent); - } - mesh.setBuffer(bindTangents); - tangents.setUsage(Usage.Stream); - } - } + TangentUtils.generateBindPoseTangentsIfNecessary(mesh); } public static void generate(Mesh mesh, boolean approxTangents) { diff --git a/jme3-core/src/main/java/com/jme3/util/TangentUtils.java b/jme3-core/src/main/java/com/jme3/util/TangentUtils.java new file mode 100644 index 000000000..ae227896a --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/util/TangentUtils.java @@ -0,0 +1,29 @@ +package com.jme3.util; + +import com.jme3.scene.*; + +/** + * Created by Nehon on 03/10/2016. + */ +public class TangentUtils { + + public static void generateBindPoseTangentsIfNecessary(Mesh mesh){ + if (mesh.getBuffer(VertexBuffer.Type.BindPosePosition) != null) { + + VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent); + if (tangents != null) { + VertexBuffer bindTangents = new VertexBuffer(VertexBuffer.Type.BindPoseTangent); + bindTangents.setupData(VertexBuffer.Usage.CpuOnly, + 4, + VertexBuffer.Format.Float, + BufferUtils.clone(tangents.getData())); + + if (mesh.getBuffer(VertexBuffer.Type.BindPoseTangent) != null) { + mesh.clearBuffer(VertexBuffer.Type.BindPoseTangent); + } + mesh.setBuffer(bindTangents); + tangents.setUsage(VertexBuffer.Usage.Stream); + } + } + } +} diff --git a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java index d3f6f4395..48bc41dd8 100644 --- a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java +++ b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java @@ -7,9 +7,9 @@ package com.jme3.util.mikktspace; import com.jme3.math.FastMath; import com.jme3.math.Vector3f; -import com.jme3.scene.Geometry; -import com.jme3.scene.Node; -import com.jme3.scene.Spatial; +import com.jme3.scene.*; +import com.jme3.util.*; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -84,6 +84,7 @@ public class MikktspaceTangentGenerator { if(!genTangSpaceDefault(context)){ Logger.getLogger(MikktspaceTangentGenerator.class.getName()).log(Level.SEVERE, "Failed to generate tangents for geometry " + g.getName()); } + TangentUtils.generateBindPoseTangentsIfNecessary(g.getMesh()); } } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag index 0bd396383..852f66289 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -1,6 +1,6 @@ +#import "Common/ShaderLib/PBR.glsllib" #import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Parallax.glsllib" -#import "Common/ShaderLib/PBR.glsllib" #import "Common/ShaderLib/Lighting.glsllib" diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag index a2d191895..6d1cc7a5a 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag @@ -80,7 +80,7 @@ void main(){ #endif #ifdef FADE - shadow = max(0.0,mix(shadow,1.0,(shadowPosition - m_FadeInfo.x) * m_FadeInfo.y)); + shadow = max(0.0, mix(shadow, 1.0, max(0.0, (shadowPosition - m_FadeInfo.x) * m_FadeInfo.y))); #endif shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity); diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter15.frag b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter15.frag index 054382cd6..b68d8fa93 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter15.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter15.frag @@ -136,11 +136,6 @@ vec4 main_multiSample(in int numSample){ void main(){ - #if !defined( RENDER_SHADOWS ) - outFragColor = fetchTextureSample(m_Texture,texCoord,0); - return; - #endif - #ifdef RESOLVE_MS vec4 color = vec4(0.0); for (int i = 0; i < m_NumSamples; i++){ diff --git a/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java b/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java index 75fac22c1..388123e41 100644 --- a/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java +++ b/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java @@ -33,11 +33,11 @@ package jme3test.light.pbr; import com.jme3.app.SimpleApplication; import com.jme3.bounding.BoundingSphere; +import com.jme3.environment.util.*; import com.jme3.light.LightProbe; import com.jme3.environment.LightProbeFactory; import com.jme3.environment.EnvironmentCamera; import com.jme3.environment.generation.JobProgressAdapter; -import com.jme3.environment.util.LightsDebugState; import com.jme3.input.ChaseCamera; import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; @@ -71,6 +71,10 @@ public class TestPBRLighting extends SimpleApplication { TestPBRLighting app = new TestPBRLighting(); app.start(); } + + private Node tex; + private Node tex2; + private Geometry model; private DirectionalLight dl; private Node modelNode; @@ -135,7 +139,17 @@ public class TestPBRLighting extends SimpleApplication { @Override public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("debug") && isPressed) { - //envCam.toggleDebug(); + if (tex == null) { + return; + } + if (tex.getParent() == null && tex2.getParent() == null) { + guiNode.attachChild(tex); + } else if (tex2.getParent() == null){ + tex.removeFromParent(); + guiNode.attachChild(tex2); + } else { + tex2.removeFromParent(); + } } if (name.equals("up") && isPressed) { @@ -183,6 +197,8 @@ public class TestPBRLighting extends SimpleApplication { @Override public void done(LightProbe result) { System.err.println("Done rendering env maps"); + tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager); + tex2 = EnvMapUtils.getCubeMapCrossDebugView(result.getIrradianceMap(), assetManager); } }); ((BoundingSphere)probe.getBounds()).setRadius(100);