diff --git a/blight-editor/src/main/java/de/blight/editor/EditorApp.java b/blight-editor/src/main/java/de/blight/editor/EditorApp.java index 87aea51..270f563 100644 --- a/blight-editor/src/main/java/de/blight/editor/EditorApp.java +++ b/blight-editor/src/main/java/de/blight/editor/EditorApp.java @@ -8460,9 +8460,25 @@ public class EditorApp extends Application { // Spielaktionen (Item-Aufheben etc.) verändern so nie die Editor-Karte. Path srcMapDir = ProjectRoot.PATH.resolve( Paths.get("blight-map", "src", "main", "map")); - Path sessionDir = ProjectRoot.PATH.resolve("run") - .resolve("session-" + System.currentTimeMillis()); + Path runDir = ProjectRoot.PATH.resolve("run"); + Path sessionDir = runDir.resolve("session-" + System.currentTimeMillis()); copyDirectory(srcMapDir, sessionDir); + + // Alte Sessions aufräumen – nur die letzten 3 behalten. + try { + java.util.List sessions; + try (java.util.stream.Stream s = Files.list(runDir)) { + sessions = s.filter(p -> p.getFileName().toString().startsWith("session-")) + .sorted(java.util.Comparator.comparing(p -> p.getFileName().toString())) + .collect(java.util.stream.Collectors.toList()); + } + int keep = 3; + for (int i = 0; i < sessions.size() - keep; i++) { + deleteDirectoryRecursive(sessions.get(i)); + } + } catch (Exception e) { + log.warn("run/-Cleanup fehlgeschlagen: {}", e.getMessage()); + } String sessionMapPath = sessionDir.resolve("blight_map.blm").toString(); java.util.List cmd = new java.util.ArrayList<>(List.of( diff --git a/simarboreal/.gitignore b/simarboreal/.gitignore deleted file mode 100644 index da88288..0000000 --- a/simarboreal/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.gradle/ diff --git a/simarboreal/assets/MatDefs/MultiResolution.frag b/simarboreal/assets/MatDefs/MultiResolution.frag deleted file mode 100644 index 9682797..0000000 --- a/simarboreal/assets/MatDefs/MultiResolution.frag +++ /dev/null @@ -1,332 +0,0 @@ -#import "Common/ShaderLib/Parallax.glsllib" -#import "Common/ShaderLib/Optics.glsllib" -#define ATTENUATION -//#define HQ_ATTENUATION - -#import "MatDefs/FragScattering.glsllib" - -varying vec2 texCoord; -#ifdef SEPARATE_TEXCOORD - varying vec2 texCoord2; -#endif - -varying vec3 AmbientSum; -varying vec4 DiffuseSum; -varying vec3 SpecularSum; - -varying float z; - -#ifndef VERTEX_LIGHTING - uniform vec4 g_LightDirection; - //varying vec3 vPosition; - varying vec3 vViewDir; - varying vec4 vLightDir; - varying vec3 lightVec; -#else - varying vec2 vertexLightValues; -#endif - -#ifdef DIFFUSEMAP - uniform sampler2D m_DiffuseMap; - uniform sampler2D m_BackgroundDiffuseMap; - uniform sampler2D m_NoiseMap; -#endif - -#ifdef SPECULARMAP - uniform sampler2D m_SpecularMap; -#endif - -#ifdef PARALLAXMAP - uniform sampler2D m_ParallaxMap; -#endif -#if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING) - uniform float m_ParallaxHeight; -#endif - -#ifdef LIGHTMAP - uniform sampler2D m_LightMap; -#endif - -#ifdef NORMALMAP - uniform sampler2D m_NormalMap; -#else - varying vec3 vNormal; -#endif - -#ifdef ALPHAMAP - uniform sampler2D m_AlphaMap; -#endif - -#ifdef COLORRAMP - uniform sampler2D m_ColorRamp; -#endif - -uniform float m_AlphaDiscardThreshold; - -#ifndef VERTEX_LIGHTING -uniform float m_Shininess; - -#ifdef HQ_ATTENUATION -uniform vec4 g_LightPosition; -#endif - -#ifdef USE_REFLECTION - uniform float m_ReflectionPower; - uniform float m_ReflectionIntensity; - varying vec4 refVec; - - uniform ENVMAP m_EnvMap; -#endif - -float tangDot(in vec3 v1, in vec3 v2){ - float d = dot(v1,v2); - #ifdef V_TANGENT - d = 1.0 - d*d; - return step(0.0, d) * sqrt(d); - #else - return d; - #endif -} - -float lightComputeDiffuse(in vec3 norm, in vec3 lightdir, in vec3 viewdir){ - #ifdef MINNAERT - float NdotL = max(0.0, dot(norm, lightdir)); - float NdotV = max(0.0, dot(norm, viewdir)); - return NdotL * pow(max(NdotL * NdotV, 0.1), -1.0) * 0.5; - #else - return max(0.0, dot(norm, lightdir)); - #endif -} - -float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){ - // NOTE: check for shiny <= 1 removed since shininess is now - // 1.0 by default (uses matdefs default vals) - #ifdef LOW_QUALITY - // Blinn-Phong - // Note: preferably, H should be computed in the vertex shader - vec3 H = (viewdir + lightdir) * vec3(0.5); - return pow(max(tangDot(H, norm), 0.0), shiny); - #elif defined(WARDISO) - // Isotropic Ward - vec3 halfVec = normalize(viewdir + lightdir); - float NdotH = max(0.001, tangDot(norm, halfVec)); - float NdotV = max(0.001, tangDot(norm, viewdir)); - float NdotL = max(0.001, tangDot(norm, lightdir)); - float a = tan(acos(NdotH)); - float p = max(shiny/128.0, 0.001); - return NdotL * (1.0 / (4.0*3.14159265*p*p)) * (exp(-(a*a)/(p*p)) / (sqrt(NdotV * NdotL))); - #else - // Standard Phong - vec3 R = reflect(-lightdir, norm); - return pow(max(tangDot(R, viewdir), 0.0), shiny); - #endif -} - -vec2 computeLighting(in vec3 wvNorm, in vec3 wvViewDir, in vec3 wvLightDir){ - float diffuseFactor = lightComputeDiffuse(wvNorm, wvLightDir, wvViewDir); - float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, wvLightDir, m_Shininess); - - #ifdef HQ_ATTENUATION - float att = clamp(1.0 - g_LightPosition.w * length(lightVec), 0.0, 1.0); - #else - float att = vLightDir.w; - #endif - - if (m_Shininess <= 1.0) { - specularFactor = 0.0; // should be one instruction on most cards .. - } - - specularFactor *= diffuseFactor; - - return vec2(diffuseFactor, specularFactor) * vec2(att); -} -#endif - -vec4 getColor( in sampler2D diffuseMap, in sampler2D diffuseMap2, - in sampler2D normalMap, in vec2 tc, in float distMix, - out vec3 normal ) { - - vec2 tcOffset; - tcOffset = texture2D(m_NoiseMap, tc * 0.01).xy * 6.0 - 3.0; - vec4 diffuseColor = texture2D(diffuseMap, (tc + tcOffset) * 0.75); - - tcOffset = (texture2D(m_NoiseMap, tc * 0.01).xy * 6.0) - 3.0; - vec4 subColor = texture2D(diffuseMap2, ((tc + tcOffset) * 1.0) * 0.1 ); - diffuseColor = mix(diffuseColor, subColor, distMix); - - #ifdef NORMALMAP - vec4 normalHeight = texture2D(normalMap, tc); - normal = normalize((normalHeight.xyz * vec3(2.0) - vec3(1.0))); - #else - normal = vec3(0.0, 1.0, 0.0); - #endif - - return diffuseColor; -} - - -void main(){ - vec2 newTexCoord; - - #if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP))) && !defined(VERTEX_LIGHTING) - - #ifdef STEEP_PARALLAX - #ifdef NORMALMAP_PARALLAX - //parallax map is stored in the alpha channel of the normal map - newTexCoord = steepParallaxOffset(m_NormalMap, vViewDir, texCoord, m_ParallaxHeight); - #else - //parallax map is a texture - newTexCoord = steepParallaxOffset(m_ParallaxMap, vViewDir, texCoord, m_ParallaxHeight); - #endif - #else - #ifdef NORMALMAP_PARALLAX - //parallax map is stored in the alpha channel of the normal map - newTexCoord = classicParallaxOffset(m_NormalMap, vViewDir, texCoord, m_ParallaxHeight); - #else - //parallax map is a texture - newTexCoord = classicParallaxOffset(m_ParallaxMap, vViewDir, texCoord, m_ParallaxHeight); - #endif - #endif - #else - newTexCoord = texCoord; - #endif - - float distMix = z / 32.0; - distMix = clamp(distMix, 0.4, 1.0); - - #ifdef DIFFUSEMAP - vec3 newNormal; - #ifdef NORMALMAP - vec4 diffuseColor = getColor(m_DiffuseMap, m_BackgroundDiffuseMap, - m_NormalMap, texCoord, distMix, newNormal); - #else - vec4 diffuseColor = getColor(m_DiffuseMap, m_BackgroundDiffuseMap, - m_DiffuseMap, texCoord, distMix, newNormal); - #endif - #else - vec4 diffuseColor = vec4(1.0); - vec3 newNormal = vec3(0.0, 1.0, 0.0); - #endif - - float alpha = DiffuseSum.a * diffuseColor.a; - #ifdef ALPHAMAP - alpha = alpha * texture2D(m_AlphaMap, newTexCoord).r; - #endif - if(alpha < m_AlphaDiscardThreshold){ - discard; - } - - #ifndef VERTEX_LIGHTING - float spotFallOff = 1.0; - - #if __VERSION__ >= 110 - // allow use of control flow - if(g_LightDirection.w != 0.0){ - #endif - - vec3 L = normalize(lightVec.xyz); - vec3 spotdir = normalize(g_LightDirection.xyz); - float curAngleCos = dot(-L, spotdir); - float innerAngleCos = floor(g_LightDirection.w) * 0.001; - float outerAngleCos = fract(g_LightDirection.w); - float innerMinusOuter = innerAngleCos - outerAngleCos; - spotFallOff = (curAngleCos - outerAngleCos) / innerMinusOuter; - - #if __VERSION__ >= 110 - if(spotFallOff <= 0.0){ - gl_FragColor.rgb = AmbientSum * diffuseColor.rgb; - gl_FragColor.a = alpha; - return; - }else{ - spotFallOff = clamp(spotFallOff, 0.0, 1.0); - } - } - #else - spotFallOff = clamp(spotFallOff, step(g_LightDirection.w, 0.001), 1.0); - #endif - #endif - - // *********************** - // Read from textures - // *********************** - #if defined(NORMALMAP) && !defined(VERTEX_LIGHTING) - vec3 normal = newNormal; - #elif !defined(VERTEX_LIGHTING) - vec3 normal = vNormal; - #if !defined(LOW_QUALITY) && !defined(V_TANGENT) - normal = normalize(normal); - #endif - #endif - - #ifdef SPECULARMAP - vec4 specularColor = texture2D(m_SpecularMap, newTexCoord); - #else - vec4 specularColor = vec4(1.0); - #endif - - #ifdef LIGHTMAP - vec3 lightMapColor; - #ifdef SEPARATE_TEXCOORD - lightMapColor = texture2D(m_LightMap, texCoord2).rgb; - #else - lightMapColor = texture2D(m_LightMap, texCoord).rgb; - #endif - specularColor.rgb *= lightMapColor; - diffuseColor.rgb *= lightMapColor; - #endif - - #ifdef VERTEX_LIGHTING - vec2 light = vertexLightValues.xy; - #ifdef COLORRAMP - light.x = texture2D(m_ColorRamp, vec2(light.x, 0.0)).r; - light.y = texture2D(m_ColorRamp, vec2(light.y, 0.0)).r; - #endif - - #ifndef USE_SCATTERING - gl_FragColor.rgb = AmbientSum * diffuseColor.rgb + - DiffuseSum.rgb * diffuseColor.rgb * vec3(light.x) + - SpecularSum * specularColor.rgb * vec3(light.y); - #else - vec3 color = AmbientSum * diffuseColor.rgb + - DiffuseSum.rgb * diffuseColor.rgb * vec3(light.x) + - SpecularSum * specularColor.rgb * vec3(light.y); - gl_FragColor.rgb = calculateGroundColor(vec4(color, 1.0)).rgb; - #endif - #else - vec4 lightDir = vLightDir; - lightDir.xyz = normalize(lightDir.xyz); - vec3 viewDir = normalize(vViewDir); - - vec2 light = computeLighting(normal, viewDir, lightDir.xyz) * spotFallOff; - #ifdef COLORRAMP - diffuseColor.rgb *= texture2D(m_ColorRamp, vec2(light.x, 0.0)).rgb; - specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; - #endif - - // Workaround, since it is not possible to modify varying variables - vec4 SpecularSum2 = vec4(SpecularSum, 1.0); - #ifdef USE_REFLECTION - vec4 refColor = Optics_GetEnvColor(m_EnvMap, refVec.xyz); - - // Interpolate light specularity toward reflection color - // Multiply result by specular map - specularColor = mix(SpecularSum2 * light.y, refColor, refVec.w) * specularColor; - - SpecularSum2 = vec4(1.0); - light.y = 1.0; - #endif - - #ifndef USE_SCATTERING - gl_FragColor.rgb = AmbientSum * diffuseColor.rgb + - DiffuseSum.rgb * diffuseColor.rgb * vec3(light.x) + - SpecularSum * specularColor.rgb * vec3(light.y); - #else - vec3 color = AmbientSum * diffuseColor.rgb + - DiffuseSum.rgb * diffuseColor.rgb * vec3(light.x) + - SpecularSum * specularColor.rgb * vec3(light.y); - gl_FragColor.rgb = calculateGroundColor(vec4(color, 1.0)).rgb; - #endif - - #endif - gl_FragColor.a = alpha; -} diff --git a/simarboreal/assets/MatDefs/MultiResolution.j3md b/simarboreal/assets/MatDefs/MultiResolution.j3md deleted file mode 100644 index fab96ea..0000000 --- a/simarboreal/assets/MatDefs/MultiResolution.j3md +++ /dev/null @@ -1,352 +0,0 @@ -MaterialDef Phong Lighting { - - MaterialParameters { - - // Compute vertex lighting in the shader - // For better performance - Boolean VertexLighting - - // Use more efficent algorithms to improve performance - Boolean LowQuality - - // Improve quality at the cost of performance - Boolean HighQuality - - // Output alpha from the diffuse map - Boolean UseAlpha - - // Alpha threshold for fragment discarding - Float AlphaDiscardThreshold (AlphaTestFallOff) - - // Normal map is in BC5/ATI2n/LATC/3Dc compression format - Boolean LATC - - // Use the provided ambient, diffuse, and specular colors - Boolean UseMaterialColors - - // Activate shading along the tangent, instead of the normal - // Requires tangent data to be available on the model. - Boolean VTangent - - // Use minnaert diffuse instead of lambert - Boolean Minnaert - - // Use ward specular instead of phong - Boolean WardIso - - // Use vertex color as an additional diffuse color. - Boolean UseVertexColor - - // Ambient color - Color Ambient (MaterialAmbient) - - // Diffuse color - Color Diffuse (MaterialDiffuse) - - // Specular color - Color Specular (MaterialSpecular) - - // Specular power/shininess - Float Shininess (MaterialShininess) : 1 - - // Diffuse map - Texture2D DiffuseMap - - // Diffuse map - Texture2D BackgroundDiffuseMap - - // Diffuse map - Texture2D NoiseMap - - // Normal map - Texture2D NormalMap - - // Specular/gloss map - Texture2D SpecularMap - - // Parallax/height map - Texture2D ParallaxMap - - //Set to true is parallax map is stored in the alpha channel of the normal map - Boolean PackedNormalParallax - - //Sets the relief height for parallax mapping - Float ParallaxHeight : 0.05 - - //Set to true to activate Steep Parallax mapping - Boolean SteepParallax - - // Texture that specifies alpha values - Texture2D AlphaMap - - // Color ramp, will map diffuse and specular values through it. - Texture2D ColorRamp - - // Texture of the glowing parts of the material - Texture2D GlowMap - - // Set to Use Lightmap - Texture2D LightMap - - // Set to use TexCoord2 for the lightmap sampling - Boolean SeparateTexCoord - - // The glow color of the object - Color GlowColor - - // Parameters for fresnel - // X = bias - // Y = scale - // Z = power - Vector3 FresnelParams - - // Env Map for reflection - TextureCubeMap EnvMap - - // the env map is a spheremap and not a cube map - Boolean EnvMapAsSphereMap - - //shadows - Int FilterMode - Boolean HardwareShadows - - Texture2D ShadowMap0 - Texture2D ShadowMap1 - Texture2D ShadowMap2 - Texture2D ShadowMap3 - //pointLights - Texture2D ShadowMap4 - Texture2D ShadowMap5 - - Float ShadowIntensity - Vector4 Splits - Vector2 FadeInfo - - Matrix4 LightViewProjectionMatrix0 - Matrix4 LightViewProjectionMatrix1 - Matrix4 LightViewProjectionMatrix2 - Matrix4 LightViewProjectionMatrix3 - //pointLight - Matrix4 LightViewProjectionMatrix4 - Matrix4 LightViewProjectionMatrix5 - Vector3 LightPos - - Float PCFEdge - Float ShadowMapSize - - // For hardware skinning - Int NumberOfBones - Matrix4Array BoneMatrices - - - // Ground scattering parameters - Boolean UseScattering - Vector3 SunPosition - Float Exposure - Float KmESun - Float InnerRadius - Float RadiusScale - Float PlanetScale : 1 - Vector3 InvWavelengthsKrESun - Float AverageDensityScale - Float InvAverageDensityHeight; - Vector3 KWavelengths4PI; - - } - - Technique { - - LightMode MultiPass - - VertexShader GLSL110: MatDefs/MultiResolution.vert - FragmentShader GLSL110: MatDefs/MultiResolution.frag - - WorldParameters { - WorldViewProjectionMatrix - NormalMatrix - WorldViewMatrix - ViewMatrix - CameraPosition - WorldMatrix - } - - Defines { - LATC : LATC - VERTEX_COLOR : UseVertexColor - VERTEX_LIGHTING : VertexLighting - ATTENUATION : Attenuation - MATERIAL_COLORS : UseMaterialColors - V_TANGENT : VTangent - MINNAERT : Minnaert - WARDISO : WardIso - LOW_QUALITY : LowQuality - HQ_ATTENUATION : HighQuality - - DIFFUSEMAP : DiffuseMap - NORMALMAP : NormalMap - SPECULARMAP : SpecularMap - PARALLAXMAP : ParallaxMap - NORMALMAP_PARALLAX : PackedNormalParallax - STEEP_PARALLAX : SteepParallax - ALPHAMAP : AlphaMap - COLORRAMP : ColorRamp - LIGHTMAP : LightMap - SEPARATE_TEXCOORD : SeparateTexCoord - - USE_REFLECTION : EnvMap - SPHERE_MAP : SphereMap - - NUM_BONES : NumberOfBones - - USE_SCATTERING : UseScattering - } - } - - Technique PreShadow { - - VertexShader GLSL110 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL110 : Common/MatDefs/Shadow/PreShadow.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldViewMatrix - } - - Defines { - COLOR_MAP : ColorMap - DISCARD_ALPHA : AlphaDiscardThreshold - NUM_BONES : NumberOfBones - } - - ForcedRenderState { - FaceCull Off - DepthTest On - DepthWrite On - PolyOffset 5 3 - ColorWrite Off - } - - } - - - Technique PostShadow15{ - VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow15.vert - FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow15.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldMatrix - } - - Defines { - HARDWARE_SHADOWS : HardwareShadows - FILTER_MODE : FilterMode - PCFEDGE : PCFEdge - DISCARD_ALPHA : AlphaDiscardThreshold - COLOR_MAP : ColorMap - SHADOWMAP_SIZE : ShadowMapSize - FADE : FadeInfo - PSSM : Splits - POINTLIGHT : LightViewProjectionMatrix5 - NUM_BONES : NumberOfBones - } - - ForcedRenderState { - Blend Modulate - DepthWrite Off - PolyOffset -0.1 0 - } - } - - Technique PostShadow{ - VertexShader GLSL110: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL110: Common/MatDefs/Shadow/PostShadow.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldMatrix - } - - Defines { - HARDWARE_SHADOWS : HardwareShadows - FILTER_MODE : FilterMode - PCFEDGE : PCFEdge - DISCARD_ALPHA : AlphaDiscardThreshold - COLOR_MAP : ColorMap - SHADOWMAP_SIZE : ShadowMapSize - FADE : FadeInfo - PSSM : Splits - POINTLIGHT : LightViewProjectionMatrix5 - NUM_BONES : NumberOfBones - } - - ForcedRenderState { - Blend Modulate - DepthWrite Off - PolyOffset -0.1 0 - } - } - - Technique PreNormalPass { - - VertexShader GLSL110 : Common/MatDefs/SSAO/normal.vert - FragmentShader GLSL110 : Common/MatDefs/SSAO/normal.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldViewMatrix - NormalMatrix - } - - Defines { - DIFFUSEMAP_ALPHA : DiffuseMap - NUM_BONES : NumberOfBones - } - - } - - Technique GBuf { - - VertexShader GLSL110: Common/MatDefs/Light/GBuf.vert - FragmentShader GLSL110: Common/MatDefs/Light/GBuf.frag - - WorldParameters { - WorldViewProjectionMatrix - NormalMatrix - WorldViewMatrix - WorldMatrix - } - - Defines { - VERTEX_COLOR : UseVertexColor - MATERIAL_COLORS : UseMaterialColors - V_TANGENT : VTangent - MINNAERT : Minnaert - WARDISO : WardIso - - DIFFUSEMAP : DiffuseMap - NORMALMAP : NormalMap - SPECULARMAP : SpecularMap - PARALLAXMAP : ParallaxMap - } - } - - Technique Glow { - - VertexShader GLSL110: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL110: Common/MatDefs/Light/Glow.frag - - WorldParameters { - WorldViewProjectionMatrix - } - - Defines { - NEED_TEXCOORD1 - HAS_GLOWMAP : GlowMap - HAS_GLOWCOLOR : GlowColor - - NUM_BONES : NumberOfBones - } - } - -} diff --git a/simarboreal/assets/MatDefs/MultiResolution.vert b/simarboreal/assets/MatDefs/MultiResolution.vert deleted file mode 100644 index d5cbeed..0000000 --- a/simarboreal/assets/MatDefs/MultiResolution.vert +++ /dev/null @@ -1,237 +0,0 @@ -#define ATTENUATION -//#define HQ_ATTENUATION - -#import "Common/ShaderLib/Skinning.glsllib" -#import "MatDefs/VertScattering.glsllib" - - -uniform mat4 g_WorldViewProjectionMatrix; -uniform mat4 g_WorldViewMatrix; -uniform mat4 g_WorldMatrix; -uniform mat3 g_NormalMatrix; -uniform mat4 g_ViewMatrix; -uniform vec3 g_CameraPosition; - -uniform vec4 m_Ambient; -uniform vec4 m_Diffuse; -uniform vec4 m_Specular; -uniform float m_Shininess; - -uniform vec4 g_LightColor; -uniform vec4 g_LightPosition; -uniform vec4 g_AmbientLightColor; - -varying vec2 texCoord; -#ifdef SEPARATE_TEXCOORD - varying vec2 texCoord2; - attribute vec2 inTexCoord2; -#endif - -varying vec3 AmbientSum; -varying vec4 DiffuseSum; -varying vec3 SpecularSum; - -varying float z; - -attribute vec3 inPosition; -attribute vec2 inTexCoord; -attribute vec3 inNormal; - -varying vec3 lightVec; -//varying vec4 spotVec; - -#ifdef VERTEX_COLOR - attribute vec4 inColor; -#endif - -#ifndef VERTEX_LIGHTING - attribute vec4 inTangent; - - #ifndef NORMALMAP - varying vec3 vNormal; - #endif - //varying vec3 vPosition; - varying vec3 vViewDir; - varying vec4 vLightDir; -#else - varying vec2 vertexLightValues; - uniform vec4 g_LightDirection; -#endif - -#ifdef USE_REFLECTION - uniform vec3 g_CameraPosition; - uniform mat4 g_WorldMatrix; - - uniform vec3 m_FresnelParams; - varying vec4 refVec; - - - /** - * Input: - * attribute inPosition - * attribute inNormal - * uniform g_WorldMatrix - * uniform g_CameraPosition - * - * Output: - * varying refVec - */ - void computeRef(in vec4 modelSpacePos){ - vec3 worldPos = (g_WorldMatrix * modelSpacePos).xyz; - - vec3 I = normalize( g_CameraPosition - worldPos ).xyz; - vec3 N = normalize( (g_WorldMatrix * vec4(inNormal, 0.0)).xyz ); - - refVec.xyz = reflect(I, N); - refVec.w = m_FresnelParams.x + m_FresnelParams.y * pow(1.0 + dot(I, N), m_FresnelParams.z); - } -#endif - -// JME3 lights in world space -void lightComputeDir(in vec3 worldPos, in vec4 color, in vec4 position, out vec4 lightDir){ - float posLight = step(0.5, color.w); - vec3 tempVec = position.xyz * sign(posLight - 0.5) - (worldPos * posLight); - lightVec = tempVec; - #ifdef ATTENUATION - float dist = length(tempVec); - lightDir.w = clamp(1.0 - position.w * dist * posLight, 0.0, 1.0); - lightDir.xyz = tempVec / vec3(dist); - #else - lightDir = vec4(normalize(tempVec), 1.0); - #endif -} - -#ifdef VERTEX_LIGHTING - float lightComputeDiffuse(in vec3 norm, in vec3 lightdir){ - return max(0.0, dot(norm, lightdir)); - } - - float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){ - if (shiny <= 1.0){ - return 0.0; - } - #ifndef LOW_QUALITY - vec3 H = (viewdir + lightdir) * vec3(0.5); - return pow(max(dot(H, norm), 0.0), shiny); - #else - return 0.0; - #endif - } - -vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec4 wvLightPos){ - vec4 lightDir; - lightComputeDir(wvPos, g_LightColor, wvLightPos, lightDir); - float spotFallOff = 1.0; - if(g_LightDirection.w != 0.0){ - vec3 L=normalize(lightVec.xyz); - vec3 spotdir = normalize(g_LightDirection.xyz); - float curAngleCos = dot(-L, spotdir); - float innerAngleCos = floor(g_LightDirection.w) * 0.001; - float outerAngleCos = fract(g_LightDirection.w); - float innerMinusOuter = innerAngleCos - outerAngleCos; - spotFallOff = clamp((curAngleCos - outerAngleCos) / innerMinusOuter, 0.0, 1.0); - } - float diffuseFactor = lightComputeDiffuse(wvNorm, lightDir.xyz); - float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, lightDir.xyz, m_Shininess); - //specularFactor *= step(0.01, diffuseFactor); - return vec2(diffuseFactor, specularFactor) * vec2(lightDir.w)*spotFallOff; - } -#endif - -void main(){ - vec4 modelSpacePos = vec4(inPosition, 1.0); - vec3 modelSpaceNorm = inNormal; - - #ifndef VERTEX_LIGHTING - vec3 modelSpaceTan = inTangent.xyz; - #endif - - #ifdef NUM_BONES - #ifndef VERTEX_LIGHTING - Skinning_Compute(modelSpacePos, modelSpaceNorm, modelSpaceTan); - #else - Skinning_Compute(modelSpacePos, modelSpaceNorm); - #endif - #endif - - #ifdef USE_SCATTERING - vec4 wPos = g_WorldMatrix * modelSpacePos; - calculateVertexGroundScattering(wPos.xyz, g_CameraPosition); - #endif - - gl_Position = g_WorldViewProjectionMatrix * modelSpacePos; - texCoord = inTexCoord; - #ifdef SEPARATE_TEXCOORD - texCoord2 = inTexCoord2; - #endif - - vec3 wvPosition = (g_WorldViewMatrix * modelSpacePos).xyz; - - z = length(wvPosition); - - vec3 wvNormal = normalize(g_NormalMatrix * modelSpaceNorm); - vec3 viewDir = normalize(-wvPosition); - - //vec4 lightColor = g_LightColor[gl_InstanceID]; - //vec4 lightPos = g_LightPosition[gl_InstanceID]; - //vec4 wvLightPos = (g_ViewMatrix * vec4(lightPos.xyz, lightColor.w)); - //wvLightPos.w = lightPos.w; - - vec4 wvLightPos = (g_ViewMatrix * vec4(g_LightPosition.xyz,clamp(g_LightColor.w,0.0,1.0))); - wvLightPos.w = g_LightPosition.w; - vec4 lightColor = g_LightColor; - - #if defined(NORMALMAP) && !defined(VERTEX_LIGHTING) - vec3 wvTangent = normalize(g_NormalMatrix * modelSpaceTan); - vec3 wvBinormal = cross(wvNormal, wvTangent); - - mat3 tbnMat = mat3(wvTangent, wvBinormal * -inTangent.w,wvNormal); - - //vPosition = wvPosition * tbnMat; - //vViewDir = viewDir * tbnMat; - vViewDir = -wvPosition * tbnMat; - lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir); - vLightDir.xyz = (vLightDir.xyz * tbnMat).xyz; - #elif !defined(VERTEX_LIGHTING) - vNormal = wvNormal; - - //vPosition = wvPosition; - vViewDir = viewDir; - - lightComputeDir(wvPosition, lightColor, wvLightPos, vLightDir); - - #ifdef V_TANGENT - vNormal = normalize(g_NormalMatrix * inTangent.xyz); - vNormal = -cross(cross(vLightDir.xyz, vNormal), vNormal); - #endif - #endif - - //computing spot direction in view space and unpacking spotlight cos -// spotVec = (g_ViewMatrix * vec4(g_LightDirection.xyz, 0.0) ); -// spotVec.w = floor(g_LightDirection.w) * 0.001; -// lightVec.w = fract(g_LightDirection.w); - - lightColor.w = 1.0; - #ifdef MATERIAL_COLORS - AmbientSum = (m_Ambient * g_AmbientLightColor).rgb; - DiffuseSum = m_Diffuse * lightColor; - SpecularSum = (m_Specular * lightColor).rgb; - #else - AmbientSum = vec3(0.2, 0.2, 0.2) * g_AmbientLightColor.rgb; // Default: ambient color is dark gray - DiffuseSum = lightColor; - SpecularSum = vec3(0.0); - #endif - - #ifdef VERTEX_COLOR - AmbientSum *= inColor.rgb; - DiffuseSum *= inColor; - #endif - - #ifdef VERTEX_LIGHTING - vertexLightValues = computeLighting(wvPosition, wvNormal, viewDir, wvLightPos); - #endif - - #ifdef USE_REFLECTION - computeRef(modelSpacePos); - #endif -} diff --git a/simarboreal/assets/MatDefs/Null.frag b/simarboreal/assets/MatDefs/Null.frag deleted file mode 100644 index 04a9e2e..0000000 --- a/simarboreal/assets/MatDefs/Null.frag +++ /dev/null @@ -1,10 +0,0 @@ -#import "Common/ShaderLib/MultiSample.glsllib" - -uniform COLORTEXTURE m_Texture; -varying vec2 texCoord; - -void main() { - vec4 texVal = getColor(m_Texture, texCoord); - gl_FragColor = texVal; -} - diff --git a/simarboreal/assets/MatDefs/Null.j3md b/simarboreal/assets/MatDefs/Null.j3md deleted file mode 100644 index 98fe07f..0000000 --- a/simarboreal/assets/MatDefs/Null.j3md +++ /dev/null @@ -1,24 +0,0 @@ -MaterialDef Depth Blur { - - MaterialParameters { - Int NumSamples - Int NumSamplesDepth - Texture2D Texture - Texture2D DepthTexture - } - - Technique { - VertexShader GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100: MatDefs/Null.frag - - WorldParameters { - WorldViewProjectionMatrix - } - - Defines { - RESOLVE_MS : NumSamples - RESOLVE_DEPTH_MS : NumSamplesDepth - } - } - -} diff --git a/simarboreal/assets/MatDefs/Shadows.frag b/simarboreal/assets/MatDefs/Shadows.frag deleted file mode 100644 index 5041007..0000000 --- a/simarboreal/assets/MatDefs/Shadows.frag +++ /dev/null @@ -1,72 +0,0 @@ -#import "Common/ShaderLib/MultiSample.glsllib" - -//#define SHOW_BOX -//#define SHOW_DELTA - -uniform vec2 g_FrustumNearFar; -uniform vec4 g_ViewPort; - -uniform vec4 m_ShadowColor; -uniform COLORTEXTURE m_FrameTexture; -uniform DEPTHTEXTURE m_DepthTexture; - -varying vec3 texCoord; -varying vec3 vViewDir; -varying vec3 boxScale; - -void main(){ - vec4 color = vec4(1.0); - - vec2 uv = vec2(gl_FragCoord.x/g_ViewPort.z, gl_FragCoord.y/g_ViewPort.w); - - float zBuffer = getDepth( m_DepthTexture, uv ).r; - - // - // z_buffer_value = a + b / z; - // - // Where: - // a = zFar / ( zFar - zNear ) - // b = zFar * zNear / ( zNear - zFar ) - // z = distance from the eye to the object - // - // Which means: - // zb - a = b / z; - // z * (zb - a) = b - // z = b / (zb - a) - // - float a = g_FrustumNearFar.y / (g_FrustumNearFar.y - g_FrustumNearFar.x); - float b = g_FrustumNearFar.y * g_FrustumNearFar.x / (g_FrustumNearFar.x - g_FrustumNearFar.y); - float z = b / (zBuffer - a); - - float us = b / (gl_FragCoord.z - a); - - float modelScale = 1.0; - - float delta = (z-us) * modelScale; - - #if defined(SHOW_DELTA) - color = vec4(delta, 0.0, 0.0, 1.0); - #elif defined(SHOW_BOX) - color = vec4(texCoord * boxScale,1.0); - #else - - vec3 view = normalize(vViewDir); - vec3 scene = texCoord + view * delta; - vec3 stu = scene * boxScale; - - float xTex = (0.5 - stu.x) * 2.0; - float zTex = (0.5 - stu.z) * 2.0; - float t = stu.y; - - float low = (t - 0.75) * 1.33333; - float hi = (t - 0.75) * 4.0; - float yTex = low * step(t, 0.75) + hi * step(0.75, t); - - float col = sqrt((xTex * xTex) + (zTex * zTex) + (yTex * yTex)); - float shadow = (1.0 - col); - color = vec4(m_ShadowColor); - color.a *= clamp(shadow, 0.0, 0.8); - #endif - - gl_FragColor = color; -} diff --git a/simarboreal/assets/MatDefs/Shadows.j3md b/simarboreal/assets/MatDefs/Shadows.j3md deleted file mode 100644 index 62880c5..0000000 --- a/simarboreal/assets/MatDefs/Shadows.j3md +++ /dev/null @@ -1,29 +0,0 @@ -MaterialDef Simple Shadows { - - MaterialParameters { - Int NumSamples - Int NumSamplesDepth - - Color ShadowColor - - Texture2D FrameTexture - Texture2D DepthTexture - } - - Technique { - VertexShader GLSL120: MatDefs/Shadows.vert - FragmentShader GLSL130: MatDefs/Shadows.frag - - WorldParameters { - ViewProjectionMatrix - FrustumNearFar - ViewPort - } - - Defines { - RESOLVE_MS : NumSamples - RESOLVE_DEPTH_MS : NumSamplesDepth - } - } - -} diff --git a/simarboreal/assets/MatDefs/Shadows.vert b/simarboreal/assets/MatDefs/Shadows.vert deleted file mode 100644 index e04b6ba..0000000 --- a/simarboreal/assets/MatDefs/Shadows.vert +++ /dev/null @@ -1,22 +0,0 @@ - -uniform mat4 g_ViewProjectionMatrix; - -attribute vec3 inPosition; // the world position -attribute vec3 inTexCoord; // the model space position, relative to a corner -attribute vec3 inTexCoord2; // the x,y,z scale to get from model space to 0->1 space -attribute vec3 inNormal; // the view direction in model-space - -varying vec3 texCoord; -varying vec3 vViewDir; -varying vec3 boxScale; - - - -void main(){ - vec4 modelSpacePos = vec4(inPosition, 1.0); - gl_Position = g_ViewProjectionMatrix * modelSpacePos; - - vViewDir = inNormal; - texCoord = inTexCoord; - boxScale = inTexCoord2; -} diff --git a/simarboreal/assets/Models/female-parts.j3o b/simarboreal/assets/Models/female-parts.j3o deleted file mode 100644 index 16f027a..0000000 Binary files a/simarboreal/assets/Models/female-parts.j3o and /dev/null differ diff --git a/simarboreal/assets/Models/male-parts-no-bones.j3o b/simarboreal/assets/Models/male-parts-no-bones.j3o deleted file mode 100644 index 1767f16..0000000 Binary files a/simarboreal/assets/Models/male-parts-no-bones.j3o and /dev/null differ diff --git a/simarboreal/assets/Textures/brown-dirt-norm.jpg b/simarboreal/assets/Textures/brown-dirt-norm.jpg deleted file mode 100644 index 3ae610d..0000000 Binary files a/simarboreal/assets/Textures/brown-dirt-norm.jpg and /dev/null differ diff --git a/simarboreal/assets/Textures/grass-flat.jpg b/simarboreal/assets/Textures/grass-flat.jpg deleted file mode 100644 index 103be5d..0000000 Binary files a/simarboreal/assets/Textures/grass-flat.jpg and /dev/null differ diff --git a/simarboreal/assets/Textures/grass.jpg b/simarboreal/assets/Textures/grass.jpg deleted file mode 100644 index c07909b..0000000 Binary files a/simarboreal/assets/Textures/grass.jpg and /dev/null differ diff --git a/simarboreal/assets/Textures/test-pattern.png b/simarboreal/assets/Textures/test-pattern.png deleted file mode 100644 index a245956..0000000 Binary files a/simarboreal/assets/Textures/test-pattern.png and /dev/null differ diff --git a/simarboreal/build.gradle b/simarboreal/build.gradle deleted file mode 100644 index 1a7358e..0000000 --- a/simarboreal/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -plugins { - id 'application' -} - -application { - mainClass = 'com.simsilica.arboreal.TreeEditor' - applicationDefaultJvmArgs = ['-Xmx512m', '-XX:MaxDirectMemorySize=512m'] -} - -sourceSets.main.resources { - srcDirs += 'src/main/java' - exclude '**/*.java' - exclude '**/*.tmp' -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - runtimeOnly files('assets') -} - -tasks.register('extractNatives', Copy) { - from zipTree(file('libs/jME3-lwjgl-natives.jar')) - into "${buildDir}/natives" - duplicatesStrategy = DuplicatesStrategy.INCLUDE -} - -run { - dependsOn extractNatives - workingDir = rootDir - jvmArgs "-Djava.library.path=${buildDir}/natives" -} diff --git a/simarboreal/libs/Lemur.jar b/simarboreal/libs/Lemur.jar deleted file mode 100644 index 2001759..0000000 Binary files a/simarboreal/libs/Lemur.jar and /dev/null differ diff --git a/simarboreal/libs/LemurProps.jar b/simarboreal/libs/LemurProps.jar deleted file mode 100644 index d577b90..0000000 Binary files a/simarboreal/libs/LemurProps.jar and /dev/null differ diff --git a/simarboreal/libs/Pager.jar b/simarboreal/libs/Pager.jar deleted file mode 100644 index 36971f7..0000000 Binary files a/simarboreal/libs/Pager.jar and /dev/null differ diff --git a/simarboreal/libs/SimArboreal.jar b/simarboreal/libs/SimArboreal.jar deleted file mode 100644 index e10714c..0000000 Binary files a/simarboreal/libs/SimArboreal.jar and /dev/null differ diff --git a/simarboreal/libs/arboreal-assets.jar b/simarboreal/libs/arboreal-assets.jar deleted file mode 100644 index b47bc2f..0000000 Binary files a/simarboreal/libs/arboreal-assets.jar and /dev/null differ diff --git a/simarboreal/libs/assets.jar b/simarboreal/libs/assets.jar deleted file mode 100644 index d16ffb8..0000000 Binary files a/simarboreal/libs/assets.jar and /dev/null differ diff --git a/simarboreal/libs/groovy-all-2.1.9.jar b/simarboreal/libs/groovy-all-2.1.9.jar deleted file mode 100644 index 8f1eb05..0000000 Binary files a/simarboreal/libs/groovy-all-2.1.9.jar and /dev/null differ diff --git a/simarboreal/libs/guava-12.0.jar b/simarboreal/libs/guava-12.0.jar deleted file mode 100644 index fefd6b2..0000000 Binary files a/simarboreal/libs/guava-12.0.jar and /dev/null differ diff --git a/simarboreal/libs/jME3-core.jar b/simarboreal/libs/jME3-core.jar deleted file mode 100644 index 585ea7d..0000000 Binary files a/simarboreal/libs/jME3-core.jar and /dev/null differ diff --git a/simarboreal/libs/jME3-desktop.jar b/simarboreal/libs/jME3-desktop.jar deleted file mode 100644 index 528edfc..0000000 Binary files a/simarboreal/libs/jME3-desktop.jar and /dev/null differ diff --git a/simarboreal/libs/jME3-effects.jar b/simarboreal/libs/jME3-effects.jar deleted file mode 100644 index 4c09a75..0000000 Binary files a/simarboreal/libs/jME3-effects.jar and /dev/null differ diff --git a/simarboreal/libs/jME3-lwjgl-natives.jar b/simarboreal/libs/jME3-lwjgl-natives.jar deleted file mode 100644 index 8d55d8f..0000000 Binary files a/simarboreal/libs/jME3-lwjgl-natives.jar and /dev/null differ diff --git a/simarboreal/libs/jME3-lwjgl.jar b/simarboreal/libs/jME3-lwjgl.jar deleted file mode 100644 index d7093c0..0000000 Binary files a/simarboreal/libs/jME3-lwjgl.jar and /dev/null differ diff --git a/simarboreal/libs/jME3-plugins.jar b/simarboreal/libs/jME3-plugins.jar deleted file mode 100644 index b341a01..0000000 Binary files a/simarboreal/libs/jME3-plugins.jar and /dev/null differ diff --git a/simarboreal/libs/jinput.jar b/simarboreal/libs/jinput.jar deleted file mode 100644 index 4c75006..0000000 Binary files a/simarboreal/libs/jinput.jar and /dev/null differ diff --git a/simarboreal/libs/log4j-1.2.12.jar b/simarboreal/libs/log4j-1.2.12.jar deleted file mode 100644 index 9b5a720..0000000 Binary files a/simarboreal/libs/log4j-1.2.12.jar and /dev/null differ diff --git a/simarboreal/libs/lwjgl.jar b/simarboreal/libs/lwjgl.jar deleted file mode 100644 index f76c937..0000000 Binary files a/simarboreal/libs/lwjgl.jar and /dev/null differ diff --git a/simarboreal/libs/meta-jb-json-1.0.1.jar b/simarboreal/libs/meta-jb-json-1.0.1.jar deleted file mode 100644 index 3a70510..0000000 Binary files a/simarboreal/libs/meta-jb-json-1.0.1.jar and /dev/null differ diff --git a/simarboreal/libs/slf4j-api-1.7.5.jar b/simarboreal/libs/slf4j-api-1.7.5.jar deleted file mode 100644 index 8766455..0000000 Binary files a/simarboreal/libs/slf4j-api-1.7.5.jar and /dev/null differ diff --git a/simarboreal/libs/slf4j-log4j12-1.7.5.jar b/simarboreal/libs/slf4j-log4j12-1.7.5.jar deleted file mode 100644 index afce5c2..0000000 Binary files a/simarboreal/libs/slf4j-log4j12-1.7.5.jar and /dev/null differ diff --git a/simarboreal/nbproject/assets-impl.xml b/simarboreal/nbproject/assets-impl.xml deleted file mode 100644 index 0a47d8d..0000000 --- a/simarboreal/nbproject/assets-impl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/simarboreal/nbproject/build-impl.xml b/simarboreal/nbproject/build-impl.xml deleted file mode 100644 index 45400b2..0000000 --- a/simarboreal/nbproject/build-impl.xml +++ /dev/null @@ -1,1521 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set platform.home - Must set platform.bootcp - Must set platform.java - Must set platform.javac - - The J2SE Platform is not correctly set up. - Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. - Either open the project in the IDE and setup the Platform with the same name or add it manually. - For example like this: - ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) - or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.resources.dir - Must set src.java.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - ${platform.java} -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/simarboreal/nbproject/genfiles.properties b/simarboreal/nbproject/genfiles.properties deleted file mode 100644 index b988779..0000000 --- a/simarboreal/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=94bf7c61 -build.xml.script.CRC32=79a29eb7 -build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=0f2662fc -nbproject/build-impl.xml.script.CRC32=bb94fa75 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/simarboreal/nbproject/project.properties b/simarboreal/nbproject/project.properties deleted file mode 100644 index c6301cb..0000000 --- a/simarboreal/nbproject/project.properties +++ /dev/null @@ -1,124 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -ant.customtasks.libs=launch4j -application.desc=Editor for the tree parameters necessary for generating trees. -application.homepage=https://code.google.com/p/simsilica-tools/ -application.splash=C:\\Development\\google\\simsilica-tools\\trunk\\SimArboreal-Editor\\TreeEditor-Splash.png -application.title=SimArboreal-Editor -application.vendor=Simsilica, LLC -assets.jar.name=assets.jar -assets.excludes=**/*.j3odata,**/*.mesh,**/*.skeleton,**/*.mesh.xml,**/*.skeleton.xml,**/*.scene,**/*.material,**/*.obj,**/*.mtl,**/*.3ds,**/*.dae,**/*.blend,**/*.blend*[0-9],**/.backups/**,**/*.psd -assets.folder.name=assets -assets.compress=true -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form,**/.backups/** -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -compile.on.save=true -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/${application.title}.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.arboreal-assets.jar=..\\SimArboreal\\dist\\lib\\arboreal-assets.jar -file.reference.groovy-all-2.1.9.jar=lib\\groovy-all-2.1.9.jar -file.reference.guava-12.0.jar=lib\\guava-12.0.jar -file.reference.log4j-1.2.12.jar=lib\\log4j-1.2.12.jar -file.reference.meta-jb-json-1.0.1.jar=lib\\meta-jb-json-1.0.1.jar -file.reference.simfx-assets.jar=..\\SimFX\\dist\\lib\\simfx-assets.jar -file.reference.slf4j-api-1.7.5.jar=lib\\slf4j-api-1.7.5.jar -file.reference.slf4j-log4j12-1.7.5.jar=lib\\slf4j-log4j12-1.7.5.jar -includes=** -jar.compress=false -javac.classpath=\ - ${reference.SimArboreal.jar}:\ - ${libs.jme3-lwjgl.classpath}:\ - ${libs.jme3-effects.classpath}:\ - ${libs.jme3-desktop.classpath}:\ - ${file.reference.arboreal-assets.jar}:\ - ${reference.Pager.jar}:\ - ${reference.SimFX.jar}:\ - ${libs.jme3-core.classpath}:\ - ${reference.Lemur.jar}:\ - ${reference.LemurProps.jar}:\ - ${file.reference.groovy-all-2.1.9.jar}:\ - ${file.reference.guava-12.0.jar}:\ - ${file.reference.log4j-1.2.12.jar}:\ - ${file.reference.meta-jb-json-1.0.1.jar}:\ - ${file.reference.slf4j-api-1.7.5.jar}:\ - ${file.reference.slf4j-log4j12-1.7.5.jar}:\ - ${file.reference.simfx-assets.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.6 -javac.target=1.6 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api" -jnlp.codebase.type=local -jnlp.descriptor=application -jnlp.enabled=false -jnlp.offline-allowed=false -jnlp.signed=false -launch4j.exe.enabled=true -linux.launcher.enabled=true -mac.app.enabled=true -main.class=com.simsilica.arboreal.TreeEditor -meta.inf.dir=${src.dir}/META-INF -manifest.file=MANIFEST.MF -mkdist.disabled=false -platform.active=JDK_1.7 -project.Lemur=../../Lemur -project.LemurProps=../../Lemur/extensions/LemurProps -project.Pager=../Pager -project.SimArboreal=../SimArboreal -project.SimFX=../SimFX -reference.Lemur.jar=${project.Lemur}/dist/Lemur.jar -reference.LemurProps.jar=${project.LemurProps}/dist/LemurProps.jar -reference.Pager.jar=${project.Pager}/dist/Pager.jar -reference.SimArboreal.jar=${project.SimArboreal}/dist/SimArboreal.jar -reference.SimFX.jar=${project.SimFX}/dist/SimFX.jar -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${assets.folder.name} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs=-Xmx512m -XX:MaxDirectMemorySize=512m -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.java.dir=src\\main\\java -src.resources.dir=src\\main\\resources diff --git a/simarboreal/nbproject/project.xml b/simarboreal/nbproject/project.xml deleted file mode 100644 index 1e7497b..0000000 --- a/simarboreal/nbproject/project.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - - - - - - - - - - - - - - - SimArboreal-Editor - - - - - - - - - - Lemur - jar - - jar - clean - jar - - - LemurProps - jar - - jar - clean - jar - - - Pager - jar - - jar - clean - jar - - - SimArboreal - jar - - jar - clean - jar - - - SimFX - jar - - jar - clean - jar - - - - diff --git a/simarboreal/release/SimArboreal-Editor-Linux.zip b/simarboreal/release/SimArboreal-Editor-Linux.zip deleted file mode 100644 index 5976a29..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux.zip and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/SimArboreal-Editor.jar b/simarboreal/release/SimArboreal-Editor-Linux/SimArboreal-Editor.jar deleted file mode 100644 index e3e1d65..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/SimArboreal-Editor.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/SimArboreal-Editor.sh b/simarboreal/release/SimArboreal-Editor-Linux/SimArboreal-Editor.sh deleted file mode 100644 index 61026ac..0000000 --- a/simarboreal/release/SimArboreal-Editor-Linux/SimArboreal-Editor.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -java -Xmx512m -XX:MaxDirectMemorySize=512m -jar SimArboreal-Editor.jar - \ No newline at end of file diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/Lemur.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/Lemur.jar deleted file mode 100644 index 2001759..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/Lemur.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/LemurProps.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/LemurProps.jar deleted file mode 100644 index d577b90..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/LemurProps.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/Pager.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/Pager.jar deleted file mode 100644 index 36971f7..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/Pager.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/SimArboreal.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/SimArboreal.jar deleted file mode 100644 index e10714c..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/SimArboreal.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/arboreal-assets.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/arboreal-assets.jar deleted file mode 100644 index b47bc2f..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/arboreal-assets.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/assets.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/assets.jar deleted file mode 100644 index d16ffb8..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/assets.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/groovy-all-2.1.9.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/groovy-all-2.1.9.jar deleted file mode 100644 index 8f1eb05..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/groovy-all-2.1.9.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/guava-12.0.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/guava-12.0.jar deleted file mode 100644 index fefd6b2..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/guava-12.0.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-core.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-core.jar deleted file mode 100644 index 585ea7d..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-core.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-desktop.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-desktop.jar deleted file mode 100644 index 528edfc..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-desktop.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-effects.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-effects.jar deleted file mode 100644 index 4c09a75..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-effects.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-lwjgl-natives.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-lwjgl-natives.jar deleted file mode 100644 index 8d55d8f..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-lwjgl-natives.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-lwjgl.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-lwjgl.jar deleted file mode 100644 index d7093c0..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-lwjgl.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-plugins.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-plugins.jar deleted file mode 100644 index b341a01..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/jME3-plugins.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/jinput.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/jinput.jar deleted file mode 100644 index 4c75006..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/jinput.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/log4j-1.2.12.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/log4j-1.2.12.jar deleted file mode 100644 index 9b5a720..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/log4j-1.2.12.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/lwjgl.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/lwjgl.jar deleted file mode 100644 index f76c937..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/lwjgl.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/meta-jb-json-1.0.1.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/meta-jb-json-1.0.1.jar deleted file mode 100644 index 3a70510..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/meta-jb-json-1.0.1.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/slf4j-api-1.7.5.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/slf4j-api-1.7.5.jar deleted file mode 100644 index 8766455..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/slf4j-api-1.7.5.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/lib/slf4j-log4j12-1.7.5.jar b/simarboreal/release/SimArboreal-Editor-Linux/lib/slf4j-log4j12-1.7.5.jar deleted file mode 100644 index afce5c2..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/lib/slf4j-log4j12-1.7.5.jar and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/liblwjgl64.so b/simarboreal/release/SimArboreal-Editor-Linux/liblwjgl64.so deleted file mode 100644 index 314b892..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/liblwjgl64.so and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Linux/libopenal64.so b/simarboreal/release/SimArboreal-Editor-Linux/libopenal64.so deleted file mode 100644 index e0693c0..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Linux/libopenal64.so and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-MacOSX.zip b/simarboreal/release/SimArboreal-Editor-MacOSX.zip deleted file mode 100644 index c4b1545..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-MacOSX.zip and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-Windows.zip b/simarboreal/release/SimArboreal-Editor-Windows.zip deleted file mode 100644 index 553af11..0000000 Binary files a/simarboreal/release/SimArboreal-Editor-Windows.zip and /dev/null differ diff --git a/simarboreal/release/SimArboreal-Editor-changelog.txt b/simarboreal/release/SimArboreal-Editor-changelog.txt deleted file mode 100644 index 5777520..0000000 --- a/simarboreal/release/SimArboreal-Editor-changelog.txt +++ /dev/null @@ -1,71 +0,0 @@ -Revision ??? -------------- -- Added a dependency to the SimFX package and converted to use - its LightingState and SkyState (with scattering) -- Grass plane supports atmospherics and a toggle was added to - the visualization options panel. -- Added atmospheric support for trees along with a toggle. - - - -Revision 143 -------------- -- Added an action to save the tree atlas images - as PNG files. -- Fixed how the atlas textures are generated so that they - save as embedded textures in the j3o. -- Fixed impostor meshes to use short buffers instead of int. -- Added toggleable noise-based wind -- Added a video recodring option F12 -- Added editors for the tree wind-related parameters -- Changed the tree parameters file extension to just plain - .simap The old simap.json extension is still supported for - loading and the file format itself hasn't changed. - - -Revision 126 -------------- -- Reworked the FileActionsState to better allow embedding - in external applications. Save and load methods were added - and the buttons are now not added to the UI unless the state - is enabled. This should help facilitate a parallel JME SDK - plug-in effort. - - -Revision 94 ------------- -- Moved RollupPanel and TabbedPanel out into Lemur core. -- Moved the builder classes out into the new simsilica-tools Pager - library. -- Moved PropertyPanel into its own Lemur extension project LemurProps. -- Converted to use the now-standard Lemur 'glass' style with just a few - local custom extensions. -- Moved the Builderstate out to the builder project. - - -Revision 69 -------------- -- Added Y offset parameter that is separate from trunk - height. -- Added LOD support including two mesh reduction strategies: - Flat-Poly : renders the tree branches as a set of axis-aligned - billboarded flat quads. - Impostor : renders a single quad with a view-direction indexed texture. - (Note: impostors currently don't save properly to the j3o) -- Better visual separate of child properies in the UI. -- Reorganized UI to include outer rollup panels to separate vis - settings from tree parameters. -- Added an avatar toggle to the UI. -- Added shadow intensity and lighting direction settings to the - UI. -- Added a simplified 'drop shadow' filter that can be enabled instead - of regular shadows. -- File write operations now warn before overwriting existing files. -- Cleaned out the wire frame meshes from the exported j3o during save. -- Renamed the tree geometry elements to make more sense when viewing - the tree object in something like Scene Composer. - - -Revision 33 -------------- -- Initial release \ No newline at end of file diff --git a/simarboreal/release/SimArboreal-Editor.jar b/simarboreal/release/SimArboreal-Editor.jar deleted file mode 100644 index e3e1d65..0000000 Binary files a/simarboreal/release/SimArboreal-Editor.jar and /dev/null differ diff --git a/simarboreal/settings.gradle.bak b/simarboreal/settings.gradle.bak deleted file mode 100644 index 917403c..0000000 --- a/simarboreal/settings.gradle.bak +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'sim-arboreal-editor' diff --git a/simarboreal/src/main/java/com/simsilica/arboreal/AtlasGeneratorState.java b/simarboreal/src/main/java/com/simsilica/arboreal/AtlasGeneratorState.java deleted file mode 100644 index ff99bf2..0000000 --- a/simarboreal/src/main/java/com/simsilica/arboreal/AtlasGeneratorState.java +++ /dev/null @@ -1,576 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2014, Simsilica, LLC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.simsilica.arboreal; - -import com.simsilica.builder.BuilderState; -import com.jme3.app.Application; -import com.jme3.bounding.BoundingBox; -import com.jme3.font.BitmapFont; -import com.jme3.font.BitmapText; -import com.jme3.light.AmbientLight; -import com.jme3.light.DirectionalLight; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.FastMath; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.Renderer; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.RenderQueue.Bucket; -import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; -import com.jme3.scene.Node; -import com.jme3.scene.VertexBuffer; -import com.jme3.scene.debug.WireBox; -import com.jme3.scene.shape.Quad; -import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image; -import com.jme3.texture.Image.Format; -import com.jme3.texture.Texture2D; -import com.jme3.util.BufferUtils; -import com.simsilica.arboreal.mesh.BillboardedLeavesMeshGenerator; -import com.simsilica.arboreal.mesh.SkinnedTreeMeshGenerator; -import com.simsilica.arboreal.mesh.Vertex; -import com.simsilica.builder.Builder; -import com.simsilica.builder.BuilderReference; -import com.simsilica.lemur.GuiGlobals; -import com.simsilica.lemur.core.VersionedReference; -import com.simsilica.lemur.event.BaseAppState; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - * @author Paul Speed - */ -public class AtlasGeneratorState extends BaseAppState { - - static Logger log = LoggerFactory.getLogger(AtlasGeneratorState.class); - - private VersionedReference treeParametersRef; - private Material treeMaterial; - private Material leafMaterial; - - private Builder builder; - private AtlasTreeBuilderReference builderRef; - - private Mesh trunkMesh; - private Mesh leafMesh; - - private FrameBuffer diffuseFb; - private FrameBuffer normalFb; - private CellView[] cellViews = new CellView[8]; - private Image diffuseMap; - private Texture2D diffuseTexture; - private Image normalMap; - private Texture2D normalTexture; - private int needTextureUpdate; - - private BitmapFont font; - - private boolean debugTextures = false; - - private boolean useNormalMaps = true; - - public AtlasGeneratorState() { - } - - public Image getDiffuseMap() { - return diffuseMap; - } - - public Image getNormalMap() { - return normalMap; - } - - protected Image createFrameBufferImage( FrameBuffer fb ) { - int width = fb.getWidth(); - int height = fb.getHeight(); - int size = width * height * 4; - ByteBuffer buffer = BufferUtils.createByteBuffer(size); - Image.Format format = fb.getColorBuffer().getFormat(); - - // I guess readFrameBuffer always writes in the same - // format regardless of the frame buffer format - format = Format.BGRA8; - return new Image(format, width, height, buffer); - } - - protected void updateTextures() { - - Renderer renderer = getApplication().getRenderer(); - if( diffuseMap == null ) { - diffuseMap = createFrameBufferImage(diffuseFb); - diffuseTexture = new Texture2D(diffuseMap); - getState(ForestGridState.class).getImpostorMaterial().setTexture("DiffuseMap", diffuseTexture); - } - renderer.readFrameBuffer(diffuseFb, diffuseMap.getData(0)); - diffuseMap.setUpdateNeeded(); - - if( normalMap == null ) { - normalMap = createFrameBufferImage(normalFb); - normalTexture = new Texture2D(normalMap); - if( useNormalMaps ) { - getState(ForestGridState.class).getImpostorMaterial().setTexture("NormalMap", normalTexture); - } - } - renderer.readFrameBuffer(normalFb, normalMap.getData(0)); - normalMap.setUpdateNeeded(); - - needTextureUpdate = 0; - } - - @Override - protected void initialize( Application app ) { - - this.treeParametersRef = getState(TreeParametersState.class).getTreeParametersRef(); - this.treeMaterial = getState(ForestGridState.class).getTreeMaterial(); - this.leafMaterial = getState(ForestGridState.class).getLeafMaterial(); - - this.builder = getState(BuilderState.class).getBuilder(); - this.builderRef = new AtlasTreeBuilderReference(); - - - this.font = GuiGlobals.getInstance().loadFont("Interface/Fonts/Default.fnt"); - - Camera camera = app.getCamera().clone(); - camera.resize(256, 256, true); - camera.resize(1024, 256, false); - - - FrameBuffer fb1 = new FrameBuffer(1024, 256, 1); - diffuseFb = fb1; - Texture2D fbTex1 = new Texture2D(1024, 256, Format.RGBA8); - fb1.setDepthBuffer(Format.Depth); - fb1.setColorTexture(fbTex1); - - FrameBuffer fb2 = new FrameBuffer(1024, 256, 1); - normalFb = fb2; - Texture2D fbTex2 = new Texture2D(1024, 256, Format.RGBA8); - fb2.setDepthBuffer(Format.Depth); - fb2.setColorTexture(fbTex2); - - - if( debugTextures ) { - Quad testQuad = new Quad(512, 128); - Geometry testGeom = new Geometry("test", testQuad); - Material mat = GuiGlobals.getInstance().createMaterial(fbTex1, false).getMaterial(); - testGeom.setMaterial(mat); - ((TreeEditor)app).getGuiNode().attachChild(testGeom); - - testQuad = new Quad(512, 128); - testGeom = new Geometry("test", testQuad); - testGeom.setLocalTranslation(0, 128, 0); - mat = GuiGlobals.getInstance().createMaterial(fbTex2, false).getMaterial(); - testGeom.setMaterial(mat); - ((TreeEditor)app).getGuiNode().attachChild(testGeom); - - updateTextures(); - - testQuad = new Quad(512, 128); - testGeom = new Geometry("test", testQuad); - testGeom.setLocalTranslation(0, 256, 0); - mat = GuiGlobals.getInstance().createMaterial(diffuseTexture, false).getMaterial(); - testGeom.setMaterial(mat); - ((TreeEditor)app).getGuiNode().attachChild(testGeom); - - testQuad = new Quad(512, 128); - testGeom = new Geometry("test", testQuad); - testGeom.setLocalTranslation(0, 384, 0); - mat = GuiGlobals.getInstance().createMaterial(normalTexture, false).getMaterial(); - testGeom.setMaterial(mat); - ((TreeEditor)app).getGuiNode().attachChild(testGeom); - } - - DirectionalLight sun = new DirectionalLight(); - //sun.setDirection(new Vector3f(0, -1f, -1).normalizeLocal()); - sun.setDirection(new Vector3f(0, 0, -1).normalizeLocal()); - - AmbientLight ambient = new AmbientLight(); - - if( useNormalMaps ) { - sun.setColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 1)); - ambient.setColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 1)); - } else { - sun.setColor(new ColorRGBA(1, 1, 1, 1)); - ambient.setColor(new ColorRGBA(0.25f, 0.25f, 0.25f, 1)); - } - - //-x * FastMath.TWO_PI - FastMath.QUARTER_PI - // The texture quads actually run a, c, d, b starting with - // the +, + quadrant - cellViews[0] = new CellView(fb1, camera, sun, ambient, FastMath.QUARTER_PI, 0.25f * 0); - cellViews[1] = new CellView(fb1, camera, sun, ambient, -FastMath.QUARTER_PI, 0.25f * 1); - cellViews[2] = new CellView(fb1, camera, sun, ambient, FastMath.PI - FastMath.QUARTER_PI, 0.25f * 2); - cellViews[3] = new CellView(fb1, camera, sun, ambient, FastMath.PI + FastMath.QUARTER_PI, 0.25f * 3); - - cellViews[4] = new NormalMapCellView(fb2, camera, sun, ambient, FastMath.QUARTER_PI, 0.25f * 0); - cellViews[5] = new NormalMapCellView(fb2, camera, sun, ambient, -FastMath.QUARTER_PI, 0.25f * 1); - cellViews[6] = new NormalMapCellView(fb2, camera, sun, ambient, FastMath.PI - FastMath.QUARTER_PI, 0.25f * 2); - cellViews[7] = new NormalMapCellView(fb2, camera, sun, ambient, FastMath.PI + FastMath.QUARTER_PI, 0.25f * 3); - - } - - @Override - protected void cleanup( Application app ) { - for( CellView view : cellViews ) { - app.getRenderManager().removeMainView(view.getViewPort()); - } - } - - @Override - protected void enable() { - } - - @Override - protected void disable() { - } - - protected void updateTree( Mesh trunkMesh, Mesh leafMesh ) { - if( this.trunkMesh == trunkMesh ) { - return; - } - - releaseMesh(this.trunkMesh); - releaseMesh(this.leafMesh); - this.trunkMesh = trunkMesh; - this.leafMesh = leafMesh; - - for( CellView view : cellViews ) { - if( view != null ) { - view.updateMesh(trunkMesh, leafMesh); - } - } - - // Texture updates need to happen one frame late... - // but we get the notification that we need the check - // early in _this_ frame. ie: updateTree() is called - // before our update(), render(). If we want to render - // a frame later then we need to skip this frame before - // updating textures. - needTextureUpdate = 2; - } - - protected void releaseMesh( Mesh mesh ) { - if( mesh == null ) { - return; - } - - // Delete the old buffers - for( VertexBuffer vb : mesh.getBufferList() ) { - if( log.isTraceEnabled() ) { - log.trace("--destroying buffer:" + vb); - } - BufferUtils.destroyDirectBuffer( vb.getData() ); - } - } - - private float nextUpdateCheck = 0.1f; - private float lastTpf; - @Override - public void update( float tpf ) { - lastTpf = tpf; - - nextUpdateCheck += tpf; - if( nextUpdateCheck <= 0.1f ) { - return; - } - nextUpdateCheck = 0; - - boolean changed = treeParametersRef.update(); - if( changed ) { - builder.build(builderRef); - } - } - - @Override - public void render( RenderManager rm ) { - if( cellViews != null ) { - // We update the logical state here because it is - // done after the other updates. So if another app - // state or control has modified our root then we - // are guaranteed to run after. - for( CellView view : cellViews ) { - if( view != null ) { - view.update(lastTpf); - } - } - } - - // Texture updates need to happen one frame later... - // but we get the notification that we need the check - // early in _this_ frame. - if( needTextureUpdate > 0 ) { - needTextureUpdate--; - if( needTextureUpdate == 0 ) { - updateTextures(); - } - } - } - - private class CellView { - private ViewPort viewport; - private Camera camera; - private Node root; - private Mesh leafMesh; - private Mesh trunkMesh; - private Geometry trunkGeom; - private Geometry leafGeom; - private Geometry wireBounds; - private boolean debugBounds = false; - private boolean debugCell = false; - - public CellView( FrameBuffer fb, Camera templateCamera, DirectionalLight sun, AmbientLight ambient, float angle, float x ) { - - this.camera = templateCamera.clone(); - camera.setViewPort(x, x + 0.25f, 0, 1); - - this.root = new Node("CellRoot:" + x ); - this.viewport = getApplication().getRenderManager().createMainView("AtlasCell[" + x + "]", camera); - this.viewport.setOutputFrameBuffer(fb); - this.root.rotate(0, -angle, 0); - - if( debugCell ) { - BitmapText label = new BitmapText(font); - label.setText("u:" + x + "\na:" + angle); - label.setLocalScale(0.01f); - Quaternion labelRot = root.getLocalRotation().inverse(); - label.setLocalRotation(labelRot); - label.setLocalTranslation(labelRot.mult(new Vector3f(0, 1, 2))); - root.attachChild(label); - } - - viewport.attachScene(root); - root.addLight(sun); - root.addLight(ambient); - - viewport.setClearFlags(true, true, true); - viewport.setBackgroundColor(new ColorRGBA(0, 0, 0, 0)); - this.camera.lookAtDirection(new Vector3f(0, 0, -1), Vector3f.UNIT_Y); - } - - public ViewPort getViewPort() { - return viewport; - } - - public void update( float tpf ) { - root.updateLogicalState(tpf); - root.updateGeometricState(); - } - - protected Material getTreeMaterial() { - return treeMaterial; - } - - protected Material getLeafMaterial() { - return leafMaterial; - } - - public void updateMesh( Mesh trunkMesh, Mesh leafMesh ) { - if( trunkGeom == null ) { - // Create it - trunkGeom = new Geometry("Trunk", trunkMesh); - trunkGeom.setMaterial(getTreeMaterial()); - root.attachChild(trunkGeom); - } else { - // Just swap out the mesh - trunkGeom.setMesh(trunkMesh); - } - this.trunkMesh = trunkMesh; - this.leafMesh = leafMesh; - if( leafMesh == null ) { - if( leafGeom != null ) { - leafGeom.removeFromParent(); - leafGeom = null; - } - } else { - if( leafGeom == null ) { - // Create it - leafGeom = new Geometry("Leaves", leafMesh); - leafGeom.setMaterial(getLeafMaterial()); - leafGeom.setQueueBucket(Bucket.Transparent); - root.attachChild(leafGeom); - } else { - // Just swap out the mesh - leafGeom.setMesh(leafMesh); - } - } - updateCamera(); - } - - protected void updateCamera() { - - BoundingBox bb = (BoundingBox)trunkMesh.getBound(); - if( leafGeom != null ) { - BoundingBox bb2 = (BoundingBox)leafMesh.getBound(); - bb = (BoundingBox)bb.merge(bb2); - } - - Vector3f min = bb.getMin(null); - Vector3f max = bb.getMax(null); - - float xSize = Math.max(Math.abs(min.x), Math.abs(max.x)); - float ySize = max.y - min.y; - float zSize = Math.max(Math.abs(min.z), Math.abs(max.z)); - - float size = ySize * 0.5f; - size = Math.max(size, xSize); - size = Math.max(size, zSize); - - // In the projection matrix, [1][1] should be: - // (2 * Zn) / camHeight - // where Zn is distance to near plane. - float m11 = camera.getViewProjectionMatrix().m11; - - // We want our position to be such that - // 'size' is otherwise = cameraHeight when rendered. - float z = m11 * size; - - // Add the z extents so that we adjust for the near plane - // of the bounding box... well we will be rotating so - // let's just be sure and take the max of x and z - //float offset = Math.max(bb.getXExtent(), bb.getZExtent()); - //z += offset; - // This creates problems because it makes way too much - // space around the tree. A proper solution would require - // a bunch of math and in the end would also have to be duplicated - // on the quad generation side or somehow stored with the atlas. - - Vector3f center = bb.getCenter(); - - float sizeOffset = size - (ySize*0.5f); - - Vector3f camLoc = new Vector3f(0, center.y + sizeOffset, z); - camera.setLocation(camLoc); - - if( debugBounds ) { - WireBox box; - if( wireBounds == null ) { - box = new WireBox(); - wireBounds = new Geometry("wire box", box); - Material mat = GuiGlobals.getInstance().createMaterial(ColorRGBA.Yellow, false).getMaterial(); - wireBounds.setMaterial(mat); - root.attachChild(wireBounds); - } else { - box = (WireBox)wireBounds.getMesh(); - } - box.updatePositions(bb.getXExtent(), bb.getYExtent(), bb.getZExtent()); - box.setBound(new BoundingBox(new Vector3f(0,0,0), 0, 0, 0)); - wireBounds.setLocalTranslation(bb.getCenter()); - wireBounds.setLocalRotation(leafGeom.getLocalRotation()); - } - } - - } - - - private class NormalMapCellView extends CellView { - public NormalMapCellView( FrameBuffer fb, Camera templateCamera, DirectionalLight sun, AmbientLight ambient, float angle, float x ) { - super(fb, templateCamera, sun, ambient, angle, x); - } - - @Override - protected Material getTreeMaterial() { - Material normalMaterial = treeMaterial.clone(); - normalMaterial.selectTechnique("PreNormalPass", getApplication().getRenderManager()); - return normalMaterial; - } - - @Override - protected Material getLeafMaterial() { - Material normalMaterial = leafMaterial.clone(); - normalMaterial.selectTechnique("PreNormalPass", getApplication().getRenderManager()); - return normalMaterial; - } - } - - - private class AtlasTreeBuilderReference implements BuilderReference { - - private Mesh trunkMesh; - private Mesh leafMesh; - - @Override - public int getPriority() { - // A relatively low priority - return 100; - } - - @Override - public void build() { - - TreeParameters treeParameters = treeParametersRef.get(); - - TreeGenerator treeGen = new TreeGenerator(); - Tree tree = treeGen.generateTree(treeParameters); - - SkinnedTreeMeshGenerator meshGen = new SkinnedTreeMeshGenerator(); - - List tips = new ArrayList(); - trunkMesh = meshGen.generateMesh(tree, - treeParameters.getLod(0), - treeParameters.getYOffset(), - treeParameters.getTextureURepeat(), - treeParameters.getTextureVScale(), - tips); - - if( treeParameters.getGenerateLeaves() ) { - BillboardedLeavesMeshGenerator leafGen = new BillboardedLeavesMeshGenerator(); - leafMesh = leafGen.generateMesh(tips, treeParameters.getLeafScale()); - } else { - leafMesh = null; - } - } - - @Override - public void apply() { - // Set the new trunk - updateTree(trunkMesh, leafMesh); - } - - @Override - public void release() { - - } - } -} diff --git a/simarboreal/src/main/java/com/simsilica/arboreal/AvatarState.java b/simarboreal/src/main/java/com/simsilica/arboreal/AvatarState.java deleted file mode 100644 index 9fa6459..0000000 --- a/simarboreal/src/main/java/com/simsilica/arboreal/AvatarState.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * ${Id} - * - * Copyright (c) 2014, Simsilica, LLC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.simsilica.arboreal; - -import com.jme3.app.Application; -import com.jme3.app.SimpleApplication; -import com.jme3.asset.AssetManager; -import com.jme3.bounding.BoundingBox; -import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.renderer.queue.RenderQueue; -import com.jme3.scene.Node; -import com.jme3.scene.Spatial; -import com.jme3.scene.Spatial.CullHint; -import com.simsilica.lemur.GuiGlobals; -import com.simsilica.lemur.event.BaseAppState; - - -/** - * Shows some sample people for scale. - * - * @author Paul Speed - */ -public class AvatarState extends BaseAppState { - - private Node avatars; - private Spatial male; - private Spatial female; - - public AvatarState() { - } - - public void setShowAvatars( boolean b ) { - if( b ) { - avatars.setCullHint(CullHint.Inherit); - } else { - avatars.setCullHint(CullHint.Always); - } - } - - @Override - protected void initialize( Application app ) { - - AssetManager assets = app.getAssetManager(); - - // Add an avatar for scale - avatars = new Node("Avatars"); - avatars.move(2, 0, 0); - - female = (Node)assets.loadModel("Models/female-parts.j3o"); - BoundingBox bb = (BoundingBox)female.getWorldBound(); - float height = bb.getYExtent() * 2; - float femaleScale = 1.62f / height; - female.move(0, bb.getYExtent(), 0); - female.setLocalScale(femaleScale); - Material mat = GuiGlobals.getInstance().createMaterial(ColorRGBA.Gray, true).getMaterial(); - mat.setColor("Ambient", ColorRGBA.Gray); - female.setMaterial(mat); - female.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); - avatars.attachChild(female); - - // Add an avatar for scale - male = (Node)assets.loadModel("Models/male-parts-no-bones.j3o"); - bb = (BoundingBox)male.getWorldBound(); - height = bb.getYExtent() * 2; - float maleScale = 1.77f / height; - male.move(bb.getCenter().negate()); - male.move(1, bb.getYExtent(), 0); - male.setLocalScale(maleScale); - male.setMaterial(mat); - male.setShadowMode(RenderQueue.ShadowMode.CastAndReceive); - avatars.attachChild(male); - - // For testing - //Spatial tree = assets.loadModel("Models/test1.j3o"); - //tree.setLocalTranslation(-20, 0, -20); - //avatars.attachChild(tree); - - - TreeOptionsState options = getState(TreeOptionsState.class); - options.addOptionToggle("Avatars", this, "setShowAvatars").setChecked(true); - - } - - @Override - protected void cleanup( Application app ) { - } - - @Override - protected void enable() { - Node rootNode = ((SimpleApplication)getApplication()).getRootNode(); - rootNode.attachChild(avatars); - } - - @Override - protected void disable() { - avatars.removeFromParent(); - } -} diff --git a/simarboreal/src/main/java/com/simsilica/arboreal/DebugHudState.java b/simarboreal/src/main/java/com/simsilica/arboreal/DebugHudState.java deleted file mode 100644 index 0f3c766..0000000 --- a/simarboreal/src/main/java/com/simsilica/arboreal/DebugHudState.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2014, Simsilica, LLC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.simsilica.arboreal; - -import com.jme3.app.Application; -import com.jme3.app.SimpleApplication; -import com.jme3.math.Vector3f; -import com.jme3.renderer.Camera; -import com.jme3.util.MemoryUtils; -import com.simsilica.lemur.Container; -import com.simsilica.lemur.GuiGlobals; -import com.simsilica.lemur.HAlignment; -import com.simsilica.lemur.Label; -import com.simsilica.lemur.core.VersionedReference; -import com.simsilica.lemur.event.BaseAppState; -import com.simsilica.lemur.input.InputMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - * @author Paul Speed - */ -public class DebugHudState extends BaseAppState { - - static Logger log = LoggerFactory.getLogger(DebugHudState.class); - - private VersionedReference worldLoc; - private Runtime runtime = Runtime.getRuntime(); - - private Label location; - private Label memory; - private Label directMem; - - private long lastUsedMem; - private long lastMeg100; - private long lastDirectMem; - private long lastDirectMeg100; - private long nextUpdate = System.currentTimeMillis() + 16; // 60 FPS max - private long nextMemTime = System.currentTimeMillis() + 1000; - - private long frameCounter; - private long lastFrameCheck; - private double lastFps; - - private Container debugHud; - - public DebugHudState() { - } - - public void toggleHud() { - setEnabled( !isEnabled() ); - } - - @Override - protected void initialize( Application app ) { - - // Always register for our hot key as long as - // we are attached. - InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper(); - inputMapper.addDelegate( MainFunctions.F_HUD, this, "toggleHud" ); - - worldLoc = getState( MovementState.class ).getWorldPosition().createReference(); - - debugHud = new Container(); - - location = debugHud.addChild(new Label( "000.00 000.00 00.00" )); - location.setTextHAlignment( HAlignment.Right ); - resetLocation(); - - memory = debugHud.addChild(new Label( "Mem: 0.0 meg (0.0 %)" )); - memory.setTextHAlignment( HAlignment.Right ); - - directMem = debugHud.addChild(new Label( "DMem: 0.0 meg / 0" )); - directMem.setTextHAlignment( HAlignment.Right ); - } - - @Override - protected void cleanup( Application app ) { - InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper(); - inputMapper.removeDelegate( MainFunctions.F_HUD, this, "toggleHud" ); - } - - protected void resetLocation() { - Vector3f v = worldLoc.get(); - String loc = String.format( "%.2f, %.2f, %.2f", v.x, v.y, v.z ); - location.setText(loc); - } - - @Override - public void update( float tpf ) { - - frameCounter++; - long time = System.currentTimeMillis(); - if( time < nextUpdate ) - return; - nextUpdate = time + 16; // 60 FPS max - - if( worldLoc.update() ) { - resetLocation(); - } - - /*if( time > lastFrameCheck + 1000 ) - { - long delta = time - lastFrameCheck; - lastFrameCheck = time; - - double fps = frameCounter / (delta / 1000.0); - frameCounter = 0; - if( fps != lastFps ) - { - lastFps = fps; - String s = String.format( "FPS: %.2f", fps ); - fpsText.setText(s); - } - }*/ - - - // Refresh memory and other things less often---------------------------- - //----------------------------------------------------------------------- - if( time < nextMemTime ) - return; - nextMemTime = time + 1000; - - long usedMemory = runtime.totalMemory() - runtime.freeMemory(); - if( lastUsedMem != usedMemory ) { - lastUsedMem = usedMemory; - - long maxMemory = runtime.maxMemory(); - long meg100 = (usedMemory * 100) / (1024 * 1024); - if( lastMeg100 != meg100 ) { - lastMeg100 = meg100; - double meg = meg100 / 100.0; - double percent = (usedMemory * 100.0 / maxMemory); - String mem = String.format( "Mem: %.2f meg (%.1f %%)", meg, percent ); - memory.setText( mem ); - } - } - - long directUsage = MemoryUtils.getDirectMemoryUsage(); - if( directUsage != lastDirectMem ) { - lastDirectMem = directUsage; - - long meg100 = (directUsage * 100) / (1024 * 1024); - if( lastDirectMeg100 != meg100 ) { - long directCount = MemoryUtils.getDirectMemoryCount(); - double meg = meg100 / 100.0; - String mem = String.format( "DMem: %.2f meg / %d", meg, directCount ); - directMem.setText( mem ); - } - } - - Camera cam = getApplication().getCamera(); - Vector3f pref = debugHud.getPreferredSize(); - debugHud.setLocalTranslation(cam.getWidth() - pref.x - 10, cam.getHeight() - 10, 0); - } - - @Override - protected void enable() { - ((SimpleApplication)getApplication()).getGuiNode().attachChild(debugHud); - } - - @Override - protected void disable() { - debugHud.removeFromParent(); - } -} diff --git a/simarboreal/src/main/java/com/simsilica/arboreal/DropShadowFilter.java b/simarboreal/src/main/java/com/simsilica/arboreal/DropShadowFilter.java deleted file mode 100644 index ad19bc9..0000000 --- a/simarboreal/src/main/java/com/simsilica/arboreal/DropShadowFilter.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2013 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.simsilica.arboreal; - -import com.jme3.asset.AssetManager; -import com.jme3.bounding.BoundingBox; -import com.jme3.bounding.BoundingSphere; -import com.jme3.material.Material; -import com.jme3.material.RenderState.BlendMode; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Matrix4f; -import com.jme3.math.Quaternion; -import com.jme3.math.Vector3f; -import com.jme3.post.Filter; -import com.jme3.renderer.Camera; -import com.jme3.renderer.Camera.FrustumIntersect; -import com.jme3.renderer.RenderManager; -import com.jme3.renderer.ViewPort; -import com.jme3.renderer.queue.GeometryComparator; -import com.jme3.renderer.queue.GeometryList; -import com.jme3.renderer.queue.RenderQueue; -import com.jme3.renderer.queue.RenderQueue.ShadowMode; -import com.jme3.scene.Geometry; -import com.jme3.scene.Mesh; -import com.jme3.scene.Spatial; -import com.jme3.scene.VertexBuffer; -import com.jme3.scene.VertexBuffer.Type; -import com.jme3.shadow.ShadowUtil; -import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Texture; -import com.jme3.util.BufferUtils; -import java.nio.FloatBuffer; -import java.nio.ShortBuffer; - - -/** - * - * @author Paul Speed - */ -public class DropShadowFilter extends Filter { - - private static final int VERTS_PER_SHADOW = 8; // one per box corner - private static final int TRIS_PER_SHADOW = 12; // two per face - private static final int INDEXES_PER_SHADOW = TRIS_PER_SHADOW * 3; - - private static final Vector3f[] BASE_CORNERS = new Vector3f[] { - new Vector3f(-1, -1, 1), // 0 - new Vector3f( 1, -1, 1), // 1 - new Vector3f( 1, -1, -1), // 2 - new Vector3f(-1, -1, -1), // 3 - new Vector3f(-1, 1, 1), // 4 - new Vector3f( 1, 1, 1), // 5 - new Vector3f( 1, 1, -1), // 6 - new Vector3f(-1, 1, -1) // 7 - }; - - private static final short[] BASE_INDEXES = new short[] { - // top - 4, 5, 6, 4, 6, 7, - // bottom - 3, 2, 1, 3, 1, 0, - // +z - 0, 1, 5, 0, 5, 4, - // -z - 2, 3, 7, 2, 7, 6, - // -x - 3, 0, 4, 3, 4, 7, - // +x - 1, 2, 6, 1, 6, 5 - }; - - private Geometry shadowGeom; - private Material shadowMaterial; - private Mesh mesh; - private int maxShadows; - - private ColorRGBA shadowColor = new ColorRGBA(0, 0, 0, 0.75f); - - private VertexBuffer vbPos; - private VertexBuffer vbNormal; - private VertexBuffer vbTexCoord; - private VertexBuffer vbTexCoord2; - private VertexBuffer vbIndex; - - private GeometryList casters; - - public DropShadowFilter() { - this(500); - } - - public DropShadowFilter( int maxShadows ) { - this.maxShadows = maxShadows; - } - - public void setShadowIntensity( float f ) { - shadowColor.a = f; - } - - public float getShadowIntensity() { - return shadowColor.a; - } - - @Override - protected boolean isRequiresDepthTexture() { - return true; - } - - @Override - protected void initFilter(AssetManager assets, RenderManager rm, ViewPort vp, int w, int h) { - - // Cheating... side effect of being lazy and using a filter - // without actually needing to filter anything. - material = new Material( assets, "MatDefs/Null.j3md" ); - - mesh = new Mesh(); - - // Setup the mesh for the max shadows size - mesh.setBuffer( Type.Position, 3, BufferUtils.createVector3Buffer(maxShadows * VERTS_PER_SHADOW) ); - mesh.setBuffer( Type.Normal, 3, BufferUtils.createVector3Buffer(maxShadows * VERTS_PER_SHADOW) ); - mesh.setBuffer( Type.TexCoord, 3, BufferUtils.createVector3Buffer(maxShadows * VERTS_PER_SHADOW) ); - mesh.setBuffer( Type.TexCoord2, 3, BufferUtils.createVector3Buffer(maxShadows * VERTS_PER_SHADOW) ); - mesh.setBuffer( Type.Index, 3, BufferUtils.createShortBuffer(maxShadows * INDEXES_PER_SHADOW) ); - - vbPos = mesh.getBuffer(Type.Position); - vbNormal = mesh.getBuffer(Type.Normal); - vbTexCoord = mesh.getBuffer(Type.TexCoord); - vbTexCoord2 = mesh.getBuffer(Type.TexCoord2); - vbIndex = mesh.getBuffer(Type.Index); - - - shadowGeom = new Geometry("shadowVolumes", mesh); - Material m = shadowMaterial = new Material( assets, "MatDefs/Shadows.j3md" ); - m.setColor( "ShadowColor", shadowColor ); - m.getAdditionalRenderState().setDepthWrite(false); - m.getAdditionalRenderState().setDepthTest(false); - m.getAdditionalRenderState().setBlendMode(BlendMode.Alpha); - shadowGeom.setMaterial(m); - shadowGeom.setLocalTranslation(0, 100, 0); - - shadowGeom.updateLogicalState(0.1f); - shadowGeom.updateGeometricState(); - - // Set our custom comparator for shadow casters - casters = new GeometryList(new CasterComparator()); - } - - @Override - protected Material getMaterial() { - return material; - } - - @Override - protected void postFrame( RenderManager renderManager, ViewPort viewPort, FrameBuffer prevFilterBuffer, FrameBuffer sceneBuffer ) { - - RenderQueue rq = viewPort.getQueue(); - for (Spatial scene : viewPort.getScenes()) { - //ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), ShadowMode.Cast, casters); - } - if( casters.size() == 0 ) - return; - - Camera cam = viewPort.getCamera(); - BoundingSphere cullCheck = new BoundingSphere(); - Vector3f pos = new Vector3f(); - - Texture frameTex = prevFilterBuffer.getColorBuffer().getTexture(); - Texture depthTex = prevFilterBuffer.getDepthBuffer().getTexture(); - shadowMaterial.setTexture("FrameTexture", frameTex); - if( frameTex.getImage().getMultiSamples() > 1 ) { - shadowMaterial.setInt("NumSamples", frameTex.getImage().getMultiSamples()); - } else { - shadowMaterial.clearParam("NumSamples"); - } - - shadowMaterial.setTexture("DepthTexture", depthTex); - if( depthTex.getImage().getMultiSamples() > 1 ) { - shadowMaterial.setInt("NumSamplesDepth", depthTex.getImage().getMultiSamples()); - } else { - shadowMaterial.clearParam("NumSamplesDepth"); - } - - int size = casters.size(); - if( size > maxShadows ) { - // Give the shadows their best chance by sorting them. - casters.setCamera(cam); - casters.sort(); - } - - FloatBuffer bPos = (FloatBuffer)vbPos.getData().rewind(); - FloatBuffer bNormal = (FloatBuffer)vbNormal.getData().rewind(); - FloatBuffer bTexCoord = (FloatBuffer)vbTexCoord.getData().rewind(); - FloatBuffer bTexCoord2 = (FloatBuffer)vbTexCoord2.getData().rewind(); - ShortBuffer bIndex = (ShortBuffer)vbIndex.getData().rewind(); - - - Matrix4f viewMatrix = cam.getViewMatrix(); - Matrix4f worldMatrix = new Matrix4f(); - Matrix4f worldViewMatrix = new Matrix4f(); - float[] angles = new float[3]; - Vector3f vTemp = new Vector3f(); - Vector3f vert = new Vector3f(); - Vector3f viewDir = new Vector3f(); - Vector3f boxScale = new Vector3f(); - - int rendered = 0; - for( int i = 0; i < size; i++ ) { - Geometry g = casters.get(i); - - // Use the geometry bounds. We assumg it is still y-up - // and merely rotated. It's a decent enough approximiation - // in many cases and will produce better shadows for oblong - // objects than a simple round radius would. - BoundingBox bounds = (BoundingBox)g.getModelBound(); - - float scale = g.getWorldScale().x; - float xEx = bounds.getXExtent() * scale; - float yEx = bounds.getYExtent() * scale; - float zEx = bounds.getZExtent() * scale; - float volumeHeight = Math.max(yEx, Math.min(xEx,zEx)); - - float xOffset = bounds.getCenter().x * scale; - float yOffset = bounds.getCenter().y * scale; - float zOffset = bounds.getCenter().z * scale; - - yOffset -= yEx; - yOffset -= volumeHeight * 0.5f; - yOffset += 0.01f; - - pos.set(g.getWorldTranslation()); - pos.addLocal(xOffset, yOffset, zOffset); - - // A conservative approximation that works because our shadow volume - // is really just a round blob - float radius = Math.max(xEx, Math.max(yEx, zEx)); - cullCheck.setCenter(pos); - cullCheck.setRadius(radius); - - int save = cam.getPlaneState(); - cam.setPlaneState(0); - FrustumIntersect intersect = cam.contains(cullCheck); - cam.setPlaneState(save); - - if( intersect == FrustumIntersect.Outside ) { - continue; - } - - boxScale.set(0.5f/xEx, 0.5f/volumeHeight, 0.5f/zEx); - - Quaternion quat = g.getWorldRotation(); - angles = quat.toAngles(angles); - - Quaternion rotation = new Quaternion().fromAngles(0, angles[1], 0); - Quaternion invRotation = rotation.inverse(); - worldMatrix.setTranslation(pos); - worldMatrix.setRotationQuaternion(rotation); - - worldViewMatrix.set(viewMatrix); - worldViewMatrix.multLocal(worldMatrix); - - // Setup the vertexes for each corner - for( int j = 0; j < VERTS_PER_SHADOW; j++ ) { - vTemp.set(BASE_CORNERS[j].x * xEx, - BASE_CORNERS[j].y * volumeHeight, - BASE_CORNERS[j].z * zEx); - - // Get the transformed coordinate in world space - vert = worldMatrix.mult(vTemp, vert); - bPos.put(vert.x).put(vert.y).put(vert.z); - - // Now calculate the view direction - vert = vert.subtractLocal(cam.getLocation()); - vert.normalizeLocal(); - viewDir = invRotation.mult(vert, viewDir); - bNormal.put(viewDir.x).put(viewDir.y).put(viewDir.z); - - // Model space is easy to calculate - bTexCoord.put(BASE_CORNERS[j].x * xEx + xEx); - bTexCoord.put(BASE_CORNERS[j].y * volumeHeight + volumeHeight); - bTexCoord.put(BASE_CORNERS[j].z * zEx + zEx); - - // And so is the scale... since it's always the same - bTexCoord2.put(boxScale.x).put(boxScale.y).put(boxScale.z); - } - - // Fill in the index buffer - for( int j = 0; j < INDEXES_PER_SHADOW; j++ ) { - bIndex.put( (short)(BASE_INDEXES[j] + rendered * VERTS_PER_SHADOW) ); - } - - rendered++; - if( rendered >= maxShadows ) { - break; - } - } - - if( rendered > 0 ) { - // Need to zero out the left-overs - for( int i = rendered; i < maxShadows; i++ ) { - for( int j = 0; j < INDEXES_PER_SHADOW; j++ ) { - bIndex.put((short)0); - } - } - - // Update the buffers - bPos.rewind(); - bNormal.rewind(); - bTexCoord.rewind(); - bTexCoord2.rewind(); - bIndex.rewind(); - - vbPos.updateData(bPos); - vbNormal.updateData(bNormal); - vbTexCoord.updateData(bTexCoord); - vbTexCoord2.updateData(bTexCoord2); - vbIndex.updateData(bIndex); - - shadowGeom.updateGeometricState(); - renderManager.renderGeometry(shadowGeom); - } - - casters.clear(); - } - - private class CasterComparator implements GeometryComparator { - - private Camera cam; - private final Vector3f tempVec = new Vector3f(); - private final Vector3f tempVec2 = new Vector3f(); - - public void setCamera( Camera cam ) { - this.cam = cam; - } - - public float distanceToCam( Geometry spat ) { - if( spat == null ) { - return Float.NEGATIVE_INFINITY; - } - - if( spat.queueDistance != Float.NEGATIVE_INFINITY ) { - return spat.queueDistance; - } - - Vector3f camPosition = cam.getLocation(); - Vector3f viewVector = cam.getDirection(tempVec2); - Vector3f spatPosition; - - if( spat.getWorldBound() != null ) { - spatPosition = spat.getWorldBound().getCenter(); - } else { - spatPosition = spat.getWorldTranslation(); - } - - spatPosition.subtract(camPosition, tempVec); - spat.queueDistance = tempVec.dot(viewVector); - - return spat.queueDistance; - } - - public int compare( Geometry o1, Geometry o2 ) { - // Front to back sort - float d1 = distanceToCam(o1); - float d2 = distanceToCam(o2); - - if( d1 == d2 ) { - return 0; - } else if( d1 < d2 ) { - return -1; - } else { - return 1; - } - } - } - - -} diff --git a/simarboreal/src/main/java/com/simsilica/arboreal/FileActionsState.java b/simarboreal/src/main/java/com/simsilica/arboreal/FileActionsState.java deleted file mode 100644 index 5439902..0000000 --- a/simarboreal/src/main/java/com/simsilica/arboreal/FileActionsState.java +++ /dev/null @@ -1,393 +0,0 @@ -/* - * ${Id} - * - * Copyright (c) 2014, Simsilica, LLC - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.simsilica.arboreal; - -import com.jme3.app.Application; -import com.jme3.export.binary.BinaryExporter; -import com.jme3.scene.Geometry; -import com.jme3.scene.SceneGraphVisitorAdapter; -import com.jme3.scene.Spatial; -import com.jme3.system.JmeSystem; -import com.jme3.texture.Image; -import com.jme3.texture.Texture2D; -import com.simsilica.lemur.Button; -import com.simsilica.lemur.Command; -import com.simsilica.lemur.Container; -import com.simsilica.lemur.HAlignment; -import com.simsilica.lemur.event.BaseAppState; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Map; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; -import javax.swing.filechooser.FileFilter; -import org.progeeks.json.JsonParser; -import org.progeeks.json.JsonPrinter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * Manages the file-related actions. - * - * @author Paul Speed - */ -public class FileActionsState extends BaseAppState { - - static Logger log = LoggerFactory.getLogger(FileActionsState.class); - - private Container buttons; - - public FileActionsState() { - } - - @Override - protected void initialize( Application app ) { - - buttons = new Container(); - - Button saveParms = buttons.addChild(new Button("Save Parms", "glass")); - saveParms.addClickCommands(new SaveTreeParameters()); - saveParms.setTextHAlignment(HAlignment.Center); - - Button loadParms = buttons.addChild(new Button("Load Parms", "glass"), 1); - loadParms.addClickCommands(new LoadTreeParameters()); - loadParms.setTextHAlignment(HAlignment.Center); - - Button saveJ3o = buttons.addChild(new Button("Export j3o", "glass"), 2); - saveJ3o.addClickCommands(new SaveJ3o()); - saveJ3o.setTextHAlignment(HAlignment.Center); - - Button saveTreeAtlas = buttons.addChild(new Button("Save Tree Atlas", "glass")); - saveTreeAtlas.addClickCommands(new SaveTreeAtlas()); - saveTreeAtlas.setTextHAlignment(HAlignment.Center); - } - - @Override - protected void cleanup( Application app ) { - } - - @Override - protected void enable() { - getState(TreeOptionsState.class).getContents().addChild(buttons); - } - - @Override - protected void disable() { - getState(TreeOptionsState.class).getContents().removeChild(buttons); - } - - /** - * Filters out the stuff that we probably don't want to... or - * really shouldn't be saving in a j3o. We should also remove - * the Impostor LODs at least until there is a way to save and/or - * embed the impostor image... but I don't right now. - */ - protected Spatial filterClone( Spatial tree ) { - Spatial result = tree.deepClone(); - result.depthFirstTraversal(new SceneGraphVisitorAdapter() { - @Override - public void visit( Geometry g ) { - if( g.getName().startsWith("wire:") ) { - g.removeFromParent(); - } - } - }); - return result; - } - - private Map lastRoots = new HashMap(); - protected File chooseFile( final String description, final boolean save, String... extensions ) { - //final String ext = (!extension.startsWith(".") ? "." : "") + extension.toLowerCase(); - final String[] exts = new String[extensions.length]; - for( int i = 0; i < exts.length; i++ ) { - exts[i] = (!extensions[i].startsWith(".") ? "." : "") + extensions[i].toLowerCase(); - } - - File lastRoot = lastRoots.get(exts[0]); - if( lastRoot == null ) { - lastRoot = new File("."); - } - - log.info("Creating file chooser dialog..."); - final JFileChooser openDialog = new JFileChooser(); - - openDialog.setDialogTitle("Choose Location"); - if( save ) { - openDialog.setDialogType(JFileChooser.SAVE_DIALOG); - } else { - openDialog.setDialogType(JFileChooser.OPEN_DIALOG); - } - openDialog.setFileFilter(new FileFilter() { - - @Override - public boolean accept( File file ) { - if( file.isDirectory() ) { - return true; - } - String s = file.getName().toLowerCase(); - for( String e : exts ) { - if( s.endsWith(e) ) { - return true; - } - } - return false; - } - - @Override - public String getDescription() { - return description; - } - }); - openDialog.setCurrentDirectory(lastRoot); - - log.info("Opening file chooser dialog..."); - - final int[] dialogResult = new int[1]; //JFileChooser.CANCEL_OPTION ; - if( !SwingUtilities.isEventDispatchThread() ) { - try { - SwingUtilities.invokeAndWait( new Runnable() { - @Override - public void run() { - if( save ) { - dialogResult[0] = openDialog.showSaveDialog(null); - } else { - dialogResult[0] = openDialog.showOpenDialog(null); - } - } - }); - } catch( Exception e ) { - throw new RuntimeException("Error invoking", e); - } - } else { - if( save ) { - dialogResult[0] = openDialog.showSaveDialog(null); - } else { - dialogResult[0] = openDialog.showOpenDialog(null); - } - } - - if( dialogResult[0] != JFileChooser.APPROVE_OPTION ) { - return null; - } - - File result = openDialog.getSelectedFile(); - lastRoots.put(exts[0], result.getParentFile()); - - if( save && !result.getName().toLowerCase().endsWith(exts[0]) ) { - result = new File(result.getParent(), result.getName() + exts[0]); - } - - return result; - } - - protected void writeJson( File f, Map map ) throws IOException { - - FileWriter out = new FileWriter(f); - try { - JsonPrinter json = new JsonPrinter(); - json.write(map, out); - } finally { - out.close(); - } - } - - protected Map readJson( File f ) throws IOException { - FileReader in = new FileReader(f); - try { - JsonParser json = new JsonParser(); - return (Map)json.parse(in); - } finally { - in.close(); - } - } - - public void saveJ3o( File f ) throws IOException { - BinaryExporter exporter = BinaryExporter.getInstance(); - log.info("Writing:" + f); - exporter.save(filterClone(getState(ForestGridState.class).getMainTreeNode()), f); - } - - public void saveTreeParameters( File f ) throws IOException { - TreeParameters treeParameters = getState(TreeParametersState.class).getTreeParameters(); - Map map = treeParameters.toMap(); - log.info("Writing:" + f); - writeJson(f, map); - } - - public void loadTreeParameters( File f ) throws IOException { - Map map = readJson(f); - TreeParameters treeParameters = getState(TreeParametersState.class).getTreeParameters(); - treeParameters.fromMap(map); - getState(TreeParametersState.class).refreshTreePanels(); - getState(ForestGridState.class).rebuild(); - } - - public void savePng( File f, Image img ) throws IOException { - OutputStream out = new FileOutputStream(f); - try { - JmeSystem.writeImageFile(out, "png", img.getData(0), img.getWidth(), img.getHeight()); - } finally { - out.close(); - } - } - - public void saveTreeAtlas( File f ) throws IOException { - - Image diffuse = getState(AtlasGeneratorState.class).getDiffuseMap(); - savePng(f, diffuse); - - String normalName = f.getName(); - if( normalName.toLowerCase().endsWith(".png") ) { - normalName = normalName.substring(0, normalName.length() - ".png".length()); - } - f = new File(f.getParentFile(), normalName + "-normals.png"); - - Image normal = getState(AtlasGeneratorState.class).getNormalMap(); - savePng(f, normal); - } - - private class SaveJ3o implements Command