New object types for all types.
This commit is contained in:
@@ -136,5 +136,5 @@ function RL.draw()
|
||||
|
||||
camera:endMode3D()
|
||||
|
||||
RL.DrawText( 0, "Use keys [Y][R][G][B] to toggle lights", { 10, 10 }, 20, 4, RL.DARKGRAY )
|
||||
RL.DrawText( RL.defaultFont, "Use keys [Y][R][G][B] to toggle lights", { 10, 10 }, 20, 4, RL.DARKGRAY )
|
||||
end
|
||||
|
||||
@@ -9,6 +9,7 @@ local TILE_SIZE = 32
|
||||
|
||||
local monitor = 0
|
||||
local camera = {}
|
||||
local groundRenderTexture = -1
|
||||
local groundTexture = -1
|
||||
local tilesetTex = -1
|
||||
local heigthImage = -1
|
||||
@@ -47,10 +48,11 @@ function RL.init()
|
||||
|
||||
mesh = RL.GenMeshHeightmap( heigthImage, { 16, 4, 16 } )
|
||||
tilesetTex = RL.LoadTexture( RL.GetBasePath().."../resources/images/tiles.png" )
|
||||
groundTexture = RL.LoadRenderTexture( { TILE_SIZE * 16, TILE_SIZE * 16 } )
|
||||
groundRenderTexture = RL.LoadRenderTexture( { TILE_SIZE * 16, TILE_SIZE * 16 } )
|
||||
groundTexture = RL.GetRenderTextureTexture( groundRenderTexture )
|
||||
|
||||
-- Draw to ground texture.
|
||||
RL.BeginTextureMode( groundTexture )
|
||||
RL.BeginTextureMode( groundRenderTexture )
|
||||
|
||||
for x = 1, 16 do
|
||||
for y = 1, 16 do
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
local monitor = 0
|
||||
local camera = -1
|
||||
local texture = nil
|
||||
local material = -1
|
||||
local model = -1
|
||||
local animations = -1
|
||||
local animationCount = 0
|
||||
local animations = {}
|
||||
local frame = 0
|
||||
local curAnim = 0
|
||||
local frameCount = 0
|
||||
@@ -24,12 +24,14 @@ function RL.init()
|
||||
RL.SetCamera3DTarget( camera, { 0, 0, 0 } )
|
||||
RL.SetCamera3DUp( camera, { 0, 1, 0 } )
|
||||
|
||||
texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/monkey_tex.png" )
|
||||
|
||||
material = RL.CreateMaterial( {
|
||||
maps = {
|
||||
{
|
||||
RL.MATERIAL_MAP_ALBEDO,
|
||||
{
|
||||
texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/monkey_tex.png" ),
|
||||
texture = texture,
|
||||
color = RL.WHITE,
|
||||
},
|
||||
},
|
||||
@@ -38,21 +40,19 @@ function RL.init()
|
||||
|
||||
model = RL.LoadModel( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
|
||||
RL.SetModelMaterial( model, 0, material )
|
||||
animations, animationCount = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
|
||||
|
||||
print( "animationCount", animationCount )
|
||||
animations = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
|
||||
end
|
||||
|
||||
function RL.process( delta )
|
||||
if RL.IsKeyPressed( RL.KEY_ENTER ) then
|
||||
curAnim = curAnim + 1
|
||||
|
||||
if animationCount <= curAnim then
|
||||
if #animations <= curAnim then
|
||||
curAnim = 0
|
||||
end
|
||||
|
||||
frame = 0.0
|
||||
frameCount = RL.GetModelAnimationFrameCount( animations, curAnim )
|
||||
frameCount = RL.GetModelAnimationFrameCount( animations[ curAnim + 1 ] )
|
||||
elseif RL.IsKeyPressed( RL.KEY_UP ) then
|
||||
animSpeed = animSpeed + 5
|
||||
elseif RL.IsKeyPressed( RL.KEY_DOWN ) then
|
||||
@@ -60,7 +60,7 @@ function RL.process( delta )
|
||||
end
|
||||
|
||||
if RL.IsKeyDown( RL.KEY_SPACE ) then
|
||||
RL.UpdateModelAnimation( model, animations, curAnim, math.floor( frame ) )
|
||||
RL.UpdateModelAnimation( model, animations[ curAnim + 1 ], math.floor( frame ) )
|
||||
frame = frame + animSpeed * delta
|
||||
|
||||
if frameCount < frame then
|
||||
@@ -80,7 +80,7 @@ function RL.draw()
|
||||
RL.DrawModelEx( model, { 0, 0, 0 }, { 1.0, 0.0, 0.0 }, -90.0, { 1.0, 1.0, 1.0 }, RL.WHITE )
|
||||
RL.EndMode3D()
|
||||
|
||||
RL.DrawText( 0,
|
||||
RL.DrawText( RL.defaultFont,
|
||||
"Enter: Change animation\
|
||||
Space: Play animation\
|
||||
Up arrow: Inreace animation speed\
|
||||
|
||||
@@ -55,6 +55,8 @@ function RL.init()
|
||||
shader = RL.LoadShader( RL.GetBasePath().."../resources/shaders/glsl330/lightmap.vs",
|
||||
RL.GetBasePath().."../resources/shaders/glsl330/lightmap.fs" )
|
||||
|
||||
print( "shader", shader )
|
||||
|
||||
local materialData = {
|
||||
shader = shader,
|
||||
maps = {
|
||||
@@ -77,6 +79,9 @@ function RL.init()
|
||||
},
|
||||
}
|
||||
material = RL.CreateMaterial( materialData )
|
||||
|
||||
print( "material", material )
|
||||
|
||||
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
|
||||
end
|
||||
|
||||
@@ -102,3 +107,10 @@ function RL.draw()
|
||||
RL.DrawMesh( mesh, material, matrix )
|
||||
camera:endMode3D()
|
||||
end
|
||||
|
||||
function RL.exit()
|
||||
material = nil
|
||||
collectgarbage( "collect" )
|
||||
tileTexture = nil
|
||||
collectgarbage( "collect" )
|
||||
end
|
||||
@@ -32,5 +32,5 @@ end
|
||||
function RL.draw()
|
||||
RL.ClearBackground( RL.RAYWHITE )
|
||||
RL.DrawTexture( texture, { 20, 20 }, RL.WHITE )
|
||||
RL.DrawText( RL.fontDefault, text, textPos, 20, 2, textColor )
|
||||
RL.DrawText( RL.defaultFont, text, textPos, 20, 2, textColor )
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user