diff --git a/core/assets/warsmash.ini b/core/assets/warsmash.ini index 6e6fe50..e2a1669 100644 --- a/core/assets/warsmash.ini +++ b/core/assets/warsmash.ini @@ -1,17 +1,17 @@ [DataSources] Count=7 Type00=MPQ -Path00="E:\Games\Warcraft III Patch 1.22\war3.mpq" +Path00="D:\Games\Warcraft III Patch 1.22\war3.mpq" Type01=MPQ -Path01="E:\Games\Warcraft III Patch 1.22\War3x.mpq" +Path01="D:\Games\Warcraft III Patch 1.22\War3x.mpq" Type02=MPQ -Path02="E:\Games\Warcraft III Patch 1.22\War3xlocal.mpq" +Path02="D:\Games\Warcraft III Patch 1.22\War3xlocal.mpq" Type03=MPQ -Path03="E:\Games\Warcraft III Patch 1.22\War3Patch.mpq" +Path03="D:\Games\Warcraft III Patch 1.22\War3Patch.mpq" Type04=Folder Path04="..\..\resources" Type05=Folder -Path05="E:\Backups\Warsmash\Data" +Path05="D:\Backups\Warsmash\Data" Type06=Folder Path06="." @@ -23,4 +23,6 @@ Path06="." //FilePath="PlayerPeasants.w3m" //FilePath="FireLord.w3x" //FilePath="Maps\Campaign\NightElf03.w3m" -FilePath="PhoenixAttack.w3x" \ No newline at end of file +//FilePath="PhoenixAttack.w3x" +FilePath="LightEnvironmentTest.w3x" +//FilePath="TorchLight2.w3x" \ No newline at end of file diff --git a/core/src/com/etheller/warsmash/viewer5/Shaders.java b/core/src/com/etheller/warsmash/viewer5/Shaders.java index 9981c2b..2adfbf8 100644 --- a/core/src/com/etheller/warsmash/viewer5/Shaders.java +++ b/core/src/com/etheller/warsmash/viewer5/Shaders.java @@ -86,32 +86,31 @@ public class Shaders { + ", lightDirection), 0.0, 1.0);\r\n" + // " if(lightFactorContribution.r > 1.0 || lightFactorContribution.g > 1.0 || lightFactorContribution.b > 1.0) {\r\n" + // - " lightFactorContribution = normalize(lightFactorContribution);\r\n" + // + " lightFactorContribution = clamp(lightFactorContribution, 0.0, 1.0);\r\n" + // " }\r\n" + // " lightFactor += lightFactorContribution + lightAmbColor.a * lightAmbColor.rgb;\r\n" + // " } else {\r\n" + // " // Omnidirectional light;\r\n" + // " vec3 deltaBtwn = " + positionName + " - lightPosition.xyz;\r\n" + // - " float dist = length(" + positionName + " - vec3(lightPosition." + (terrain ? "xyw" : "xyz") - + "));\r\n" + // - " float attenuationStart = lightExtra.y;\r\n" + // - " float attenuationEnd = lightExtra.z;\r\n" + // - " if( dist <= attenuationEnd ) {\r\n" + // - " float attenuationDist = clamp((dist-attenuationStart), 0.001, (attenuationEnd-attenuationStart));\r\n" - + // - " float attenuationFactor = 1.0/(attenuationDist);\r\n" + // - " vec3 lightDirection = -deltaBtwn;\r\n" + // - " vec3 lightFactorContribution = attenuationFactor * lightColor.a * lightColor.rgb * clamp(dot(" + " float dist = length(" + positionName + " - vec3(lightPosition." + (terrain ? "xyz" : "xyz") + + ")) / 64.0 + 1.0;\r\n" + // + " vec3 lightDirection = normalize(-deltaBtwn);\r\n" + // + " vec3 lightFactorContribution = (lightColor.a/(pow(dist, 2.0))) * lightColor.rgb * clamp(dot(" + normalName + ", lightDirection), 0.0, 1.0);\r\n" + // - " if(lightFactorContribution.r > 1.0 || lightFactorContribution.g > 1.0 || lightFactorContribution.b > 1.0) {\r\n" + " if(lightFactorContribution.r > 1.0 || lightFactorContribution.g > 1.0 || lightFactorContribution.b > 1.0) {\r\n" + // - " lightFactorContribution = normalize(lightFactorContribution);\r\n" + // - " }\r\n" + // - " lightFactor += lightFactorContribution + attenuationFactor * lightAmbColor.a * lightAmbColor.rgb;\r\n" - + // - " \r\n" + // + " lightFactorContribution = clamp(lightFactorContribution, 0.0, 1.0);\r\n" + // " }\r\n" + // + " lightFactor += lightFactorContribution + (lightAmbColor.a/(pow(dist, 2.0))) * lightAmbColor.rgb;\r\n" + + // " }\r\n" + // - " }\r\n"; + " }\r\n";// + // + +// " vec4 sRGB = vec4(lightFactor, 1.0);" + // +// " bvec4 cutoff = lessThan(sRGB, vec4(0.04045));" + // +// " vec4 higher = pow((sRGB + vec4(0.055))/vec4(1.055), vec4(2.4));" + // +// " vec4 lower = sRGB/vec4(12.92);" + // +// "" + // +// " lightFactor = (higher * (vec4(1.0) - vec4(cutoff)) + lower * vec4(cutoff)).xyz;"; } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/mdx/MdxComplexInstance.java b/core/src/com/etheller/warsmash/viewer5/handlers/mdx/MdxComplexInstance.java index b480bfc..b08c9de 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/mdx/MdxComplexInstance.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/mdx/MdxComplexInstance.java @@ -763,10 +763,12 @@ public class MdxComplexInstance extends ModelInstance { } public void setFrameByRatio(final float ratioOfAnimationCompleted) { - final Sequence currentlyPlayingSequence = ((MdxModel) this.model).sequences.get(this.sequence); - this.floatingFrame = currentlyPlayingSequence.getInterval()[0] - + ((currentlyPlayingSequence.getInterval()[1] - currentlyPlayingSequence.getInterval()[0]) - * ratioOfAnimationCompleted); - this.frame = (int) this.floatingFrame; + if (this.sequence != -1) { + final Sequence currentlyPlayingSequence = ((MdxModel) this.model).sequences.get(this.sequence); + this.floatingFrame = currentlyPlayingSequence.getInterval()[0] + + ((currentlyPlayingSequence.getInterval()[1] - currentlyPlayingSequence.getInterval()[0]) + * ratioOfAnimationCompleted); + this.frame = (int) this.floatingFrame; + } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/mdx/SdSequence.java b/core/src/com/etheller/warsmash/viewer5/handlers/mdx/SdSequence.java index 956e693..58c91da 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/mdx/SdSequence.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/mdx/SdSequence.java @@ -102,7 +102,8 @@ public final class SdSequence { if (!this.constant) { // If there is no opening keyframe for this sequence, inject one // with the default value. - if (framesBuilder.get(0) != start) { + final boolean hasStart = framesBuilder.get(0) == start; + if (!hasStart) { framesBuilder.add(start); valuesBuilder.add(defval); @@ -116,11 +117,12 @@ public final class SdSequence { // with the default value. if (framesBuilder.get(framesBuilder.size() - 1) != end) { framesBuilder.add(end); - valuesBuilder.add(valuesBuilder.get(valuesBuilder.size() - 1)); + final int sourceIndex = hasStart ? 0 : (valuesBuilder.size() - 1); + valuesBuilder.add(valuesBuilder.get(sourceIndex)); if (interpolationType > 1) { - inTansBuilder.add(inTansBuilder.get(inTansBuilder.size() - 1)); - outTansBuilder.add(outTansBuilder.get(outTansBuilder.size() - 1)); + inTansBuilder.add(inTansBuilder.get(sourceIndex)); + outTansBuilder.add(outTansBuilder.get(sourceIndex)); } } } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/W3xScenePortraitLightManager.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/W3xScenePortraitLightManager.java index a643de6..d5fa535 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/W3xScenePortraitLightManager.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/W3xScenePortraitLightManager.java @@ -52,9 +52,9 @@ public class W3xScenePortraitLightManager implements SceneLightManager, W3xScene this.unitLightCount = 0; this.lightDataCopyHeap.clear(); int offset = 0; - if (this.viewer.dncTarget != null) { - if (!this.viewer.dncTarget.lights.isEmpty()) { - this.viewer.dncTarget.lights.get(0).bind(0, this.lightDataCopyHeap); + if (this.viewer.dncUnitDay != null) { + if (!this.viewer.dncUnitDay.lights.isEmpty()) { + this.viewer.dncUnitDay.lights.get(0).bind(0, this.lightDataCopyHeap); offset += 16; this.unitLightCount++; } diff --git a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java index c2b19ef..eeda60f 100644 --- a/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java +++ b/core/src/com/etheller/warsmash/viewer5/handlers/w3x/War3MapViewer.java @@ -158,6 +158,7 @@ public class War3MapViewer extends ModelViewer { private DataTable unitGlobalStrings; private MdxComplexInstance confirmationInstance; public MdxComplexInstance dncUnit; + public MdxComplexInstance dncUnitDay; public MdxComplexInstance dncTerrain; public MdxComplexInstance dncTarget; public CSimulation simulation; @@ -927,6 +928,8 @@ public class War3MapViewer extends ModelViewer { this.dncUnit.setFrameByRatio( this.simulation.getGameTimeOfDay() / this.simulation.getGameplayConstants().getGameDayHours()); this.dncUnit.update(rawDeltaTime, null); + this.dncUnitDay.setFrameByRatio(0.5f); + this.dncUnitDay.update(rawDeltaTime, null); this.dncTarget.setFrameByRatio( this.simulation.getGameTimeOfDay() / this.simulation.getGameplayConstants().getGameDayHours()); this.dncTarget.update(rawDeltaTime, null); @@ -1281,6 +1284,9 @@ public class War3MapViewer extends ModelViewer { this.dncUnit = (MdxComplexInstance) unitDNCModel.addInstance(); this.dncUnit.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP); this.dncUnit.setSequence(0); + this.dncUnitDay = (MdxComplexInstance) unitDNCModel.addInstance(); + this.dncUnitDay.setSequenceLoopMode(SequenceLoopMode.ALWAYS_LOOP); + this.dncUnitDay.setSequence(0); final MdxModel targetDNCModel = (MdxModel) load( mdx("Environment\\DNC\\DNCLordaeron\\DNCLordaeronTarget\\DNCLordaeronTarget.mdl"), PathSolver.DEFAULT, null);