summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorjussi2023-04-10 23:52:13 +0300
committerjussi2023-04-10 23:52:13 +0300
commit3445d935d66969a7eec97e8691b68496dc51af0b (patch)
treeab9678193bd3e896c50ef80965f7e906b141cedd /examples
parent6938cdbaede7eb63b9bc2adb9e0a93e243e291ee (diff)
downloadreilua-enhanced-3445d935d66969a7eec97e8691b68496dc51af0b.tar.gz
reilua-enhanced-3445d935d66969a7eec97e8691b68496dc51af0b.tar.bz2
reilua-enhanced-3445d935d66969a7eec97e8691b68496dc51af0b.zip
Camera3D lib. New camera3D functions.
Diffstat (limited to 'examples')
-rw-r--r--examples/ReiLuaGui_examples/main.lua2
-rw-r--r--examples/heightmap/main.lua40
-rw-r--r--examples/lightmap/main.lua4
3 files changed, 35 insertions, 11 deletions
diff --git a/examples/ReiLuaGui_examples/main.lua b/examples/ReiLuaGui_examples/main.lua
index 29dace8..3c120b5 100644
--- a/examples/ReiLuaGui_examples/main.lua
+++ b/examples/ReiLuaGui_examples/main.lua
@@ -1,7 +1,7 @@
package.path = package.path..";"..RL.GetBasePath().."?.lua"
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
-util = require( "utillib" )
+Util = require( "utillib" )
Vec2 = require( "vector2" )
Rect = require( "rectangle" )
Color = require( "color" )
diff --git a/examples/heightmap/main.lua b/examples/heightmap/main.lua
index d046d2a..eb660b3 100644
--- a/examples/heightmap/main.lua
+++ b/examples/heightmap/main.lua
@@ -1,7 +1,14 @@
+package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
+
+Util = require( "utillib" )
+Vec2 = require( "vector2" )
+Vec3 = require( "vector3" )
+Cam3D = require( "camera3d" )
+
local TILE_SIZE = 32
local monitor = 0
-local camera = -1
+local camera = {}
local groundTexture = -1
local tilesetTex = -1
local heigthImage = -1
@@ -27,11 +34,14 @@ function RL.init()
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
- camera = RL.CreateCamera3D()
- RL.SetCamera3DPosition( camera, { 0, 8, 16 } )
- RL.SetCamera3DTarget( camera, { 0, 0, 0 } )
- RL.SetCamera3DUp( camera, { 0, 1, 0 } )
- -- RL.SetCameraMode( camera, RL.CAMERA_FREE )
+ camera = Cam3D:new()
+
+ camera:setPosition( { 0, 8, 16 } )
+ camera:setTarget( { 0, 0, 0 } )
+ camera:setUp( { 0, 1, 0 } )
+ -- camera.mode = camera.MODES.ORBITAL
+ camera.mode = camera.MODES.FREE
+ -- camera.mode = camera.MODES.FIRST_PERSON
heigthImage = RL.LoadImage( RL.GetBasePath().."../resources/images/heightmap.png" )
@@ -74,11 +84,23 @@ function RL.init()
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
end
+function RL.process( delta )
+ camera:process( delta )
+
+ if RL.IsKeyPressed( RL.KEY_SPACE ) then
+ if camera.mode == camera.MODES.FREE then
+ camera.mode = camera.MODES.FIRST_PERSON
+ else
+ camera.mode = camera.MODES.FREE
+ end
+ end
+end
+
function RL.draw()
RL.ClearBackground( { 100, 150, 100 } )
- RL.UpdateCamera3D( camera, RL.CAMERA_FIRST_PERSON )
- RL.BeginMode3D( camera )
+ camera:beginMode3D()
RL.DrawMesh( mesh, material, matrix )
- RL.EndMode3D()
+ -- camera:draw()
+ camera:endMode3D()
end
diff --git a/examples/lightmap/main.lua b/examples/lightmap/main.lua
index a85527e..991bc2d 100644
--- a/examples/lightmap/main.lua
+++ b/examples/lightmap/main.lua
@@ -78,7 +78,9 @@ end
function RL.draw()
RL.ClearBackground( { 25, 50, 50 } )
- RL.UpdateCamera3D( camera, RL.CAMERA_ORBITAL )
+ -- RL.UpdateCamera3D( camera, RL.CAMERA_ORBITAL )
+ -- RL.UpdateCamera3D( camera, RL.CAMERA_FREE )
+ RL.UpdateCamera3D( camera, RL.CAMERA_FIRST_PERSON )
RL.BeginMode3D( camera )
RL.DrawMesh( mesh, material, matrix )