Skip to content

Commit

Permalink
Added rotation to model and modified file organisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Angar0Os committed Nov 18, 2024
1 parent 5eda550 commit 20e639d
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions scene_screenshot_buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,23 @@ state = "none"
while not hg.ReadKeyboard():Key(hg.K_Escape) and hg.IsWindowOpen(win) do
dt = hg.TickClock()

-- Update Scene and render to the frameBuffer
scene:Update(dt)

trs = scene:GetNode('engine_master'):GetTransform()
trs:SetRot(trs:GetRot() + hg.Vec3(0, hg.Deg(15) * hg.time_to_sec_f(dt), 0))

view_id = 0
view_id = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, res_x, res_y), true, pipeline, res,
frame_buffer.handle)
view_id = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, res_x, res_y), true, pipeline, res, frame_buffer.handle)

-- Draw a plabe using the texture the scene was rendered to
hg.SetViewPerspective(view_id, 0, 0, res_x, res_y, hg.TranslationMat4(hg.Vec3(0, 0, -1.8)))

val_uniforms = {hg.MakeUniformSetValue('color', hg.Vec4(1, 1, 1, 1))}
tex_uniforms = {hg.MakeUniformSetTexture('s_tex', tex_color, 0)}

hg.DrawModel(view_id, plane_mdl, plane_prg, val_uniforms, tex_uniforms,
hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Vec3(math.pi / 2, 0, math.pi)))

-- Change state to capture when user press Space and Capture is not already running
if (hg.ReadKeyboard():Key(hg.K_Space) and state == "none") then
Expand All @@ -58,18 +72,6 @@ while not hg.ReadKeyboard():Key(hg.K_Escape) and hg.IsWindowOpen(win) do
state = "none" -- Reset state to none to be able to screenshot again
end

-- Update Scene and render to the frameBuffer
scene:Update(dt)

-- Draw a plabe using the texture the scene was rendered to
hg.SetViewPerspective(view_id, 0, 0, res_x, res_y, hg.TranslationMat4(hg.Vec3(0, 0, -1.8)))

val_uniforms = {hg.MakeUniformSetValue('color', hg.Vec4(1, 1, 1, 1))}
tex_uniforms = {hg.MakeUniformSetTexture('s_tex', tex_color, 0)}

hg.DrawModel(view_id, plane_mdl, plane_prg, val_uniforms, tex_uniforms,
hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Vec3(math.pi / 2, 0, math.pi)))

--
frame = hg.Frame()
hg.UpdateWindow(win)
Expand Down

0 comments on commit 20e639d

Please sign in to comment.