Initial late commit
This commit is contained in:
1
application/assets/lua_library/lib.lua
Normal file
1
application/assets/lua_library/lib.lua
Normal file
@@ -0,0 +1 @@
|
||||
---@meta
|
||||
53
application/assets/scripts/camera.lua
Normal file
53
application/assets/scripts/camera.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local velocity = 5
|
||||
|
||||
function HandleMouse(camera, delta_time)
|
||||
local mouse_sensitivity = 0.2
|
||||
local xoffset, yoffset = Input:GetMouseOffset()
|
||||
|
||||
xoffset = xoffset * mouse_sensitivity;
|
||||
yoffset = yoffset * mouse_sensitivity;
|
||||
|
||||
local pitch, yaw = camera:GetPitchYaw()
|
||||
yaw = yaw + xoffset;
|
||||
pitch = pitch + yoffset;
|
||||
|
||||
if pitch > 89.0 then
|
||||
pitch = 89.0;
|
||||
if pitch < -89.0 then
|
||||
pitch = -89.0;
|
||||
end
|
||||
end
|
||||
|
||||
camera:SetPitchYaw(pitch, yaw)
|
||||
|
||||
end
|
||||
|
||||
function Update()
|
||||
local delta_time = Time:DeltaTime();
|
||||
--local inp = Input:GetKeyStatus(GLFW_KEY_W)
|
||||
local transform = Parent:GetTransform()
|
||||
local camera = Parent:GetCamera()
|
||||
local forward = camera:forward()
|
||||
local right = camera:right()
|
||||
local translation
|
||||
|
||||
HandleMouse(camera, delta_time)
|
||||
|
||||
if Input:GetKeyStatus(GLFW_KEY_W) == 1 then
|
||||
translation = normalize(forward * vec3:new(1.0, 0.0, 1.0)) * velocity * delta_time
|
||||
end
|
||||
|
||||
if Input:GetKeyStatus(GLFW_KEY_S) == 1 then
|
||||
translation = normalize(forward * vec3:new(1.0, 0.0, 1.0)) * -velocity * delta_time
|
||||
end
|
||||
|
||||
if Input:GetKeyStatus(GLFW_KEY_A) == 1 then
|
||||
translation = normalize(right * vec3:new(1.0, 0.0, 1.0)) * -velocity * delta_time
|
||||
end
|
||||
|
||||
if Input:GetKeyStatus(GLFW_KEY_D) == 1 then
|
||||
translation = normalize(right * vec3:new(1.0, 0.0, 1.0)) * velocity * delta_time
|
||||
end
|
||||
|
||||
transform:Translate(translation)
|
||||
end
|
||||
28
application/assets/scripts/script.lua
Normal file
28
application/assets/scripts/script.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
io.write("script loaded successfully\n")
|
||||
|
||||
local time_elapsed = 0
|
||||
|
||||
function Start(trans)
|
||||
io.write("lua: Start\n")
|
||||
end
|
||||
|
||||
function Update()
|
||||
time_elapsed = time_elapsed + Time:DeltaTime()
|
||||
local x = math.sin(time_elapsed * 2) * 2
|
||||
local z = math.cos(time_elapsed * 2) * 2
|
||||
|
||||
local transform = Parent:GetTransform()
|
||||
transform.position = vec3:new(x, 1.0, z - 7.0)
|
||||
local light = Parent:GetPointLight()
|
||||
|
||||
local r = 0.5 * (1 + math.sin(time_elapsed * 2.5) * 1.1)
|
||||
local g = 0.5 * (1 + math.cos(time_elapsed * 1.5) * 1.2)
|
||||
local b = 0.5 * (1 + math.sin(time_elapsed * 3.5) * 1.3)
|
||||
r = 1.0
|
||||
g = 1.0
|
||||
b = 1.0
|
||||
light.color = vec3:new(r, g, b)
|
||||
end
|
||||
|
||||
-- Todo: faire bouger le cube
|
||||
-- Get inputs to script
|
||||
12
application/assets/shaders/fragment.frag
Normal file
12
application/assets/shaders/fragment.frag
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
in vec3 v_Position;
|
||||
in vec4 v_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = vec4(v_Position * 0.5 + 0.5, 1.0f);
|
||||
color = v_Color;
|
||||
}
|
||||
8
application/assets/shaders/light.frag
Normal file
8
application/assets/shaders/light.frag
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec3 objectColor;
|
||||
|
||||
void main() {
|
||||
FragColor = vec4(objectColor, 1.0);
|
||||
}
|
||||
11
application/assets/shaders/light.vert
Normal file
11
application/assets/shaders/light.vert
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330 core
|
||||
|
||||
layout (location = 0) in vec3 aPos;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
void main() {
|
||||
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
||||
}
|
||||
16
application/assets/shaders/vertex.vert
Normal file
16
application/assets/shaders/vertex.vert
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 a_Position;
|
||||
layout(location = 1) in vec4 a_Color;
|
||||
|
||||
uniform mat4 u_ViewProjection;
|
||||
|
||||
out vec3 v_Position;
|
||||
out vec4 v_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_Position = a_Position;
|
||||
v_Color = a_Color;
|
||||
gl_Position = u_ViewProjection * vec4(a_Position, 1.0);
|
||||
}
|
||||
BIN
application/assets/textures/awesomeface.png
Normal file
BIN
application/assets/textures/awesomeface.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
BIN
application/assets/textures/container.jpg
Normal file
BIN
application/assets/textures/container.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 181 KiB |
BIN
application/assets/textures/container2.png
Normal file
BIN
application/assets/textures/container2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 457 KiB |
BIN
application/assets/textures/container2_specular.png
Normal file
BIN
application/assets/textures/container2_specular.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 141 KiB |
BIN
application/assets/textures/container2_specular2.png
Normal file
BIN
application/assets/textures/container2_specular2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Reference in New Issue
Block a user