diff options
Diffstat (limited to 'Resources')
15 files changed, 168 insertions, 73 deletions
diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/GL/init.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/GL/init.lua index 87d47d3..f69d1f6 100644 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/GL/init.lua +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/GL/init.lua @@ -1,6 +1,20 @@ local GL = GameLab.Engine.GL or {} GameLab.Engine.GL = GL +local Matrix44 = GameLab.find("GameLab.Engine.Math.Matrix44") +GL.LoadPixelMatrix = function(l, r, b, t) + local ortho = Matrix44.New() + ortho:SetOrtho(l, r, b, t, 0.1, 10) + GL.MatrixMode(GL.EMatrixMode.Projection) + GL.LoadIdentity() + GL.LoadMatrix(ortho) + GL.MatrixMode(GL.EMatrixMode.ModelView) + GL.LoadIdentity() +end + +GL.LoadPixelMatrixTL = function (l, r, b, t) + +end return GL
\ No newline at end of file diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix33.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix33.lua new file mode 100644 index 0000000..8cb7e72 --- /dev/null +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix33.lua @@ -0,0 +1,7 @@ +local Matrix33 = GameLab.Class("GameLab.Engine.Math.Matrix33") + +Matrix33.Ctor = function(self) + +end + +return Matrix33
\ No newline at end of file diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix3x3.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix3x3.lua deleted file mode 100644 index b0aad47..0000000 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix3x3.lua +++ /dev/null @@ -1,7 +0,0 @@ -local Matrix3x3 = GameLab.Class("GameLab.Engine.Math.Matrix3x3") - -Matrix3x3.Ctor = function(self) - -end - -return Matrix3x3
\ No newline at end of file diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix44.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix44.lua new file mode 100644 index 0000000..2347207 --- /dev/null +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix44.lua @@ -0,0 +1,73 @@ +local Matrix44 = GameLab.Class("GameLab.Engine.Math.Matrix44") + +Matrix44.Ctor = function(self) + for r = 0, 3 do + for c = 0, 3 do + self["m"..r..c] = 0 + end + end +end + +Matrix44.Clear = function(self) + for r = 0, 3 do + for c = 0, 3 do + self["m"..r..c] = 0 + end + end +end + +Matrix44.SetRow = function(self, row, value) + +end + +Matrix44.SetColum = function(self, colum, value) + +end + +Matrix44.Set = function(self, row, colum ,value) + +end + +Matrix44.GetColum = function(self, colum) + +end + +Matrix44.GetRow = function(self, row) + +end + +-- note: n>0, f>0 +Matrix44.SetOrtho = function(self, l, r, b, t, n, f) + self:Clear() + self.m00 = 2 / (r - l) + self.m03 = (r + l) / (l - r) + self.m11 = 2 / (t - b) + self.m13 = (t + b) / (b - t) + self.m22 = 2 / (n - f) + self.m23 = (f + n) / (n - f) + self.m33 = 1 +end + +-- note: n>0, f>0 +Matrix44.SetFrustum = function(self, l, r, b, t, n, f) + self:Clear() + self.m00 = 2 * n / (r - l) + self.m02 = (r + l) / (r - l) + self.m11 = 2 * n / (t - b) + self.m12 = (t + b) / (t - b) + self.m22 = (f + n) / (n - f) + self.m23 = 2 * f * n / (n - f) + self.m32 = -1 +end + +-- note: n>0, f>0 +Matrix44.SetPerspective = function(self, fov, aspect, near, far) + self:Clear() + self.m00 = 1 / (aspect * math.tan(fov/2)) + self.m11 = 1 / math.tan(fov/2) + self.m22 = (far + near) / (near - far) + self.m23 = 2 * far * near / (near - far) + self.m32 = -1 +end + +return Matrix44
\ No newline at end of file diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix4x4.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix4x4.lua deleted file mode 100644 index 8e4d70a..0000000 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/Matrix4x4.lua +++ /dev/null @@ -1,31 +0,0 @@ -local Matrix4x4 = GameLab.Class("GameLab.Engine.Math.Matrix4x4") - -Matrix4x4.Ctor = function(self) - for r = 0, 3 do - for c = 0, 3 do - self["m"..r..c] = 0 - end - end -end - -Matrix4x4.SetRow = function(self, row, value) - -end - -Matrix4x4.SetColum = function(self, colum, value) - -end - -Matrix4x4.Set = function(self, row, colum ,value) - -end - -Matrix4x4.GetColum = function(self, colum) - -end - -Matrix4x4.GetRow = function(self, row) - -end - -return Matrix4x4
\ No newline at end of file diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/init.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/init.lua index bebc9ee..eb75db7 100644 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/Math/init.lua +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/Math/init.lua @@ -1,15 +1,15 @@ local m = GameLab.Engine.Math or {}
GameLab.Engine.Math = m
-local require = GameLab.require(...)
+local import = GameLab.import(...)
-require("Math")
-m.Vector2 = require("Vector2")
-m.Vector3 = require("Vector3")
-m.Vector4 = require("Vector4")
-m.Matrix4x4 = require("Matrix4x4")
-m.Matrix3x3 = require("Matrix3x3")
-m.Quaternion = require("Quaternion")
+import("Math")
+m.Vector2 = import("Vector2")
+m.Vector3 = import("Vector3")
+m.Vector4 = import("Vector4")
+m.Matrix44 = import("Matrix44")
+m.Matrix33 = import("Matrix33")
+m.Quaternion = import("Quaternion")
GameLab.Debug.Log("GameLab.Engine.Math loaded")
diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color.lua index fb3e773..bf908a4 100644 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color.lua +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color.lua @@ -1,7 +1,4 @@ local Color = GameLab.Class("GameLab.Engine.Rendering.Color") -GameLab.Engine.Rendering.Color = Color -- 避免require循环 - -local Color32 = GameLab.Engine.Rendering.Color32 or require("GameLab.Engine.Rendering.Color32") Color.Ctor = function(self, r, g, b, a) self.r = r @@ -11,6 +8,7 @@ Color.Ctor = function(self, r, g, b, a) end Color.ToColor32 = function(self) + local Color32 = GameLab.find("GameLab.Engine.Rendering.Color32") local c32 = Color32.New() c32.r = self.r * 255 c32.g = self.g * 255 diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color32.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color32.lua index c17187a..d108dfb 100644 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color32.lua +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/Color32.lua @@ -1,7 +1,4 @@ local Color32 = GameLab.Class("GameLab.Engine.Rendering.Color32") -GameLab.Engine.Rendering.Color32 = Color32 -- 避免require循环 - -local Color = GameLab.Engine.Rendering.Color or require("GameLab.Engine.Rendering.Color") Color32.Ctor = function(self, r, g, b, a) self.r = r @@ -11,6 +8,7 @@ Color32.Ctor = function(self, r, g, b, a) end Color32.ToColor = function(self) + local Color = GameLab.find("GameLab.Engine.Rendering.Color") local c = Color.New() c.r = self.r / 255 c.g = self.g / 255 diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua index 933adc1..d9b4e3e 100644 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/Rendering/init.lua @@ -1,10 +1,10 @@ local m = GameLab.Engine.Rendering or {} GameLab.Engine.Rendering = m -local require = GameLab.require(...) +local import = GameLab.import(...) -m.Color = require("Color") -m.Color32 = require("Color32") +m.Color = import("Color") +m.Color32 = import("Color32") m.LoadTexture = function(path) diff --git a/Resources/DefaultContent/Libraries/GameLab/Engine/init.lua b/Resources/DefaultContent/Libraries/GameLab/Engine/init.lua index 3987de1..f6f46a4 100644 --- a/Resources/DefaultContent/Libraries/GameLab/Engine/init.lua +++ b/Resources/DefaultContent/Libraries/GameLab/Engine/init.lua @@ -1,5 +1,5 @@ GameLab.Engine = GameLab.Engine or {} -local require = GameLab.require(...) +local import = GameLab.import(...) return GameLab.Engine
\ No newline at end of file diff --git a/Resources/DefaultContent/Libraries/GameLab/init.lua b/Resources/DefaultContent/Libraries/GameLab/init.lua index 92fef6c..51e1901 100644 --- a/Resources/DefaultContent/Libraries/GameLab/init.lua +++ b/Resources/DefaultContent/Libraries/GameLab/init.lua @@ -2,14 +2,35 @@ GameLab = GameLab or {} -- methods
-- 用于模块的init.lua中加载模块内的脚本
-GameLab.require = function(packageName)
- local _require = function(path)
+GameLab.import = function(packageName)
+ local _import = function(path)
local name = packageName .. "." .. path
local m = require(name)
--package.loaded[name] = m
return m
end
- return _require
+ return _import
+end
+
+-- 用于相对路径包含
+-- GameLab.require = function(className)
+-- local packageName = (type(className) == "string") and string.match(className, "^(.+)%.%w+$") or ""
+-- local _require = function(path)
+-- local name = packageName .. "." .. path
+-- local m = require(name)
+-- return m
+-- end
+-- return _require
+-- end
+
+GameLab.find = function(fullName)
+ if _G[fullName] ~= nil then
+ return _G[fullName]
+ end
+ if package.loaded[fullName] ~= nil then
+ return package.loaded[fullName]
+ end
+ return require(fullName)
end
-- classes
diff --git a/Resources/Libraries/GameLab/Editor/GUI/init.lua b/Resources/Libraries/GameLab/Editor/GUI/init.lua index e1b4576..def4237 100644 --- a/Resources/Libraries/GameLab/Editor/GUI/init.lua +++ b/Resources/Libraries/GameLab/Editor/GUI/init.lua @@ -1,10 +1,10 @@ GameLab.Editor.GUI = GameLab.Editor.GUI or {}
local m = GameLab.Editor.GUI
-local require = GameLab.require(...)
+local import = GameLab.import(...)
-m.EditorWindow = require("EditorWindow")
+m.EditorWindow = import("EditorWindow")
-require("Functions")
+import("Functions")
return m
\ No newline at end of file diff --git a/Resources/Scripts/Editor/AssetBrowser.lua b/Resources/Scripts/Editor/AssetBrowser.lua index 3d03302..e6e4a4a 100644 --- a/Resources/Scripts/Editor/AssetBrowser.lua +++ b/Resources/Scripts/Editor/AssetBrowser.lua @@ -1,10 +1,11 @@ local Debug = GameLab.Debug
local AssetBrowser = GameLab.Editor.GUI.EditorWindow.Extend("GameLab.Editor.AssetBrowser")
local GL = GameLab.Engine.GL
+local Matrix44 = GameLab.Engine.Math.Matrix44
+local inspect = require("inspect")
AssetBrowser.Ctor = function(self)
self.base.Ctor(self, "AssetBrowser")
-
end
AssetBrowser.OnGUI = function(self)
@@ -12,10 +13,11 @@ AssetBrowser.OnGUI = function(self) GL.ClearColor({0,0,0,1})
GL.Clear(GL.EBufferType.ColorBuffer)
GL.Color({1,1,0,1})
+ GL.LoadPixelMatrix(-250, 250, -300, 300)
GL.Begin(GL.EPrimitiveType.Triangles)
GL.Vertex({0,0,-1})
- GL.Vertex({0,1,-1})
- GL.Vertex({1,0,-1})
+ GL.Vertex({0,300,-1})
+ GL.Vertex({250,0,-1})
GL.End()
end
diff --git a/Resources/Scripts/EditorApplication.lua b/Resources/Scripts/EditorApplication.lua index e91725a..747e443 100644 --- a/Resources/Scripts/EditorApplication.lua +++ b/Resources/Scripts/EditorApplication.lua @@ -47,8 +47,25 @@ Debug.Log(inspect(GL.EBufferType)) GL.ClearColor({1,1,1,1}) GL.Clear(GL.EBufferType.ColorBuffer) +local files = { +"README.txt", +"README.txt", +"README.txt", +"README.txt", +"README.txt", +"README.txt", +"README.txt", +"README.txt", +"README.txt", +} + +GameLab.IO.ReadFiles(files, function() + Debug.Log("finished") +end) + while true do + app:OnStep() app:PullMessage() end
\ No newline at end of file diff --git a/Resources/boot.lua b/Resources/boot.lua index 118dd74..a07c96a 100644 --- a/Resources/boot.lua +++ b/Resources/boot.lua @@ -1,11 +1,17 @@ +-- "macros"
+GAMELAB_PROFILE = true
+GAMELAB_DEBUG = true
+
-- 模块搜索目录
-local engineLuaLibs = "./DefaultContent/Libraries/?.lua" .. ";./DefaultContent/Libraries/?/init.lua" .. ";./DefaultContent/Libraries/?/?.lua" .. ";./DefaultContent/Libraries/?/?"
-local editorLuaLibs = "./Libraries/?.lua" .. ";./Libraries/?/init.lua" .. ";./Libraries/?/?.lua" .. ";./Libraries/?/?"
+local engineLuaLibs = "./DefaultContent/Libraries/?.lua" .. ";./DefaultContent/Libraries/?/init.lua" .. ";./DefaultContent/Libraries/?/?.lua" .. ";./DefaultContent/Libraries/?/?" ..
+ ";./DefaultContent/Plugins/?.lua" .. ";./DefaultContent/Plugins/?/init.lua" .. ";./DefaultContent/Plugins/?/?.lua" .. ";./DefaultContent/Plugins/?/?"
+local editorLuaLibs = "./Libraries/?.lua" .. ";./Libraries/?/init.lua" .. ";./Libraries/?/?.lua" .. ";./Libraries/?/?" ..
+ ";./Plugins/?.lua" .. ";./Plugins/?/init.lua" .. ";./Plugins/?/?.lua" .. ";./Plugins/?/?"
local editorScripts = "./Scripts/?.lua"
package.path=package.path .. ";" .. editorScripts .. ";" .. engineLuaLibs .. ";" .. editorLuaLibs
-local engineCLibs = "./DefaultContent/Libraries/?.dll"
-local editorCLibs = "./Libraries/?.dll"
+local engineCLibs = "./DefaultContent/Libraries/?.dll" .. ";./DefaultContent/Plugins/?.dll"
+local editorCLibs = "./Libraries/?.dll" .. "./Plugins/?.dll"
package.cpath=package.cpath .. ";" .. engineCLibs .. ";" .. editorCLibs
-- debugging
@@ -14,15 +20,12 @@ require("LuaPanda").start("127.0.0.1",8818) -- redirect
print = GameLab.Debug.Log
--- "macros"
-GAMELAB_PROFILE = true
-GAMELAB_DEBUG = true
-
-- load gamelab modules
require "GameLab"
require "GameLab.Engine"
require "GameLab.Engine.Math"
require "GameLab.Engine.Rendering"
+require "GameLab.Engine.GL"
require "GameLab.Editor"
require "GameLab.Editor.GUI"
|