diff --git a/sjplayer/src/sjplayer/ScheduledController.d b/sjplayer/src/sjplayer/ScheduledController.d index 2d33298..b634dfc 100644 --- a/sjplayer/src/sjplayer/ScheduledController.d +++ b/sjplayer/src/sjplayer/ScheduledController.d @@ -11,7 +11,6 @@ import sjscript; import sjplayer.AbstractScheduledController, sjplayer.ScheduledControllerInterface, sjplayer.VarStoreInterface, - sjplayer.util.MatrixFactory, sjplayer.util.Parameter; /// @@ -73,7 +72,7 @@ class ScheduledController( default: } static if (MatrixModificationAvailable) { - const value = matrix_factory_.GetValueByName(name); + const value = matrix_factory_.GetModelMatrixParameterValueByName(name); if (!value.isNull) return value; } return super.GetVariable(name); @@ -88,7 +87,7 @@ class ScheduledController( default: } static if (MatrixModificationAvailable) { - if (param.CalculateMatrixParameter(matrix_factory_, vars)) return; + if (param.CalculateModelMatrixParameter(matrix_factory_, vars)) return; } super.SetParameter(param, vars); } @@ -96,6 +95,6 @@ class ScheduledController( Target target_; static if (MatrixModificationAvailable) { - MatrixFactory matrix_factory_; + ModelMatrixFactory!3 matrix_factory_; } } diff --git a/sjplayer/src/sjplayer/util/MatrixFactory.d b/sjplayer/src/sjplayer/util/MatrixFactory.d deleted file mode 100644 index 49009ec..0000000 --- a/sjplayer/src/sjplayer/util/MatrixFactory.d +++ /dev/null @@ -1,42 +0,0 @@ -/// License: MIT -module sjplayer.util.MatrixFactory; - -import std.typecons; - -import gl4d; - -/// -struct MatrixFactory { - public: - /// - mat3 Create() const { - auto m = mat3.identity; - m.scale(scale.x, scale.y, scale.z); - m.rotatex(rotation.x); - m.rotatey(rotation.y); - m.rotatez(rotation.z); - m.translate(translation.x, translation.y, 1); - return m; - } - - /// - Nullable!float GetValueByName(string name) const { - switch (name) { - case "scale_x": return Nullable!float(scale.x); - case "scale_y": return Nullable!float(scale.y); - case "rotation_x": return Nullable!float(rotation.x); - case "rotation_y": return Nullable!float(rotation.y); - case "rotation_z": return Nullable!float(rotation.z); - case "translation_x": return Nullable!float(translation.x); - case "translation_y": return Nullable!float(translation.y); - default: return Nullable!float.init; - } - } - - /// - vec3 scale = vec3(1, 1, 1); - /// - vec3 rotation = vec3(0, 0, 0); - /// - vec2 translation = vec2(0, 0); -} diff --git a/sjplayer/src/sjplayer/util/Parameter.d b/sjplayer/src/sjplayer/util/Parameter.d index 132066a..af61138 100644 --- a/sjplayer/src/sjplayer/util/Parameter.d +++ b/sjplayer/src/sjplayer/util/Parameter.d @@ -1,9 +1,11 @@ /// License: MIT module sjplayer.util.Parameter; -import sjscript; +import std.typecons; -import sjplayer.util.MatrixFactory; +import gl4d; + +import sjscript; /// void CalculateParameter(T)( @@ -14,8 +16,8 @@ void CalculateParameter(T)( } /// -bool CalculateMatrixParameter(T)( - in Parameter param, ref MatrixFactory m, T vars) { +bool CalculateModelMatrixParameter(T)( + in Parameter param, ref ModelMatrixFactory!3 m, T vars) { switch (param.name) { case "translation_x": param.CalculateParameter(m.translation.x, vars); @@ -44,3 +46,18 @@ bool CalculateMatrixParameter(T)( default: return false; } } + +/// +Nullable!float GetModelMatrixParameterValueByName( + ref in ModelMatrixFactory!3 m, string name) { + switch (name) { + case "scale_x": return Nullable!float(m.scale.x); + case "scale_y": return Nullable!float(m.scale.y); + case "rotation_x": return Nullable!float(m.rotation.x); + case "rotation_y": return Nullable!float(m.rotation.y); + case "rotation_z": return Nullable!float(m.rotation.z); + case "translation_x": return Nullable!float(m.translation.x); + case "translation_y": return Nullable!float(m.translation.y); + default: return Nullable!float.init; + } +} diff --git a/src/sj/LobbyWorld.d b/src/sj/LobbyWorld.d index 922a580..f1823e8 100644 --- a/src/sj/LobbyWorld.d +++ b/src/sj/LobbyWorld.d @@ -45,7 +45,7 @@ class LobbyWorld { /// mat4 view = mat4.look_at(vec3(0, 0, -1), vec3(0, 0, 0), vec3(0, 1, 0)); /// - vec3 light_color = vec3(1, 1, 1, 1); + vec3 light_color = vec3(1, 1, 1); /// vec3 light_direction = vec3(0, 1, 0); /// diff --git a/thirdparty/gl4d b/thirdparty/gl4d index 51ad927..33883a6 160000 --- a/thirdparty/gl4d +++ b/thirdparty/gl4d @@ -1 +1 @@ -Subproject commit 51ad9270d58fd7cd64b494450dd447b39b21bb45 +Subproject commit 33883a68a9179cdfca72da9d0f60a88e1f385715