Created
November 16, 2016 19:34
-
-
Save shakesoda/ceafafac07c559b0d6c86f8fc46d9f4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local l3d = require "love3d" | |
| local cpml = require "cpml" | |
| -- ... | |
| function love.draw() | |
| l3d.set_depth_test "less" | |
| love.graphics.setShader(shader) | |
| local w, h = love.graphics.getDimensions() | |
| local proj = cpml.mat4.from_perspective(60, w/h, 0.1, 1000.0) | |
| local model, view = cpml.mat4(), cpml.mat4() | |
| -- set camera to Y+5, Z-up, looking at 0,0,0 | |
| view:look_at(cpml.mat4(), | |
| cpml.vec3(0, 5, 0), | |
| cpml.vec3(0, 0, 0), | |
| cpml.vec3(0, 0, 1) | |
| ) | |
| -- move model up 1 unit | |
| model:identity() | |
| model:translate(model, cpml.vec3(0, 0, 1)) | |
| shader:send("u_projection", proj) | |
| shader:send("u_view", view) | |
| shader:send("u_model", model) | |
| love.graphics.draw(model.mesh) | |
| love.graphics.setShader() | |
| l3d.set_depth_test() | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment