Skip to content

Commit

Permalink
Updated Keyboard, 3D Cube and 3D Model samples to use the new API (#62)
Browse files Browse the repository at this point in the history
* Changed Keyboard.show to Keyboard.start

* Seperated texture loading and updated draw call.

* Seperated texture loading and updated draw call.
  • Loading branch information
fatihdgn committed Apr 2, 2022
1 parent 778da41 commit 777fb33
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
10 changes: 7 additions & 3 deletions samples/3D Cube/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ model = {

}

-- Load image
texture = Graphics.loadImage("ux0:/data/lpp-vita/samples/3D Cube/texture.png");
-- Load the cube
mod1 = Render.loadModel(model, "ux0:/data/lpp-vita/samples/3D Cube/texture.png")
mod1 = Render.loadModel(model, texture)

-- Set default angle, position and translation values
z = -6.0
x = 0.0
y = 0.0
angleX = 1.0
angleY = 1.0
angleZ = 1.0;
translX = 0.0017
translY = 0.0034

Expand All @@ -81,6 +84,7 @@ while true do
-- Rotate the model
angleX = angleX + 0.2
angleY = angleY + 0.2
angleZ = angleZ + 0.2

-- Move the model
x = x + translX
Expand All @@ -89,7 +93,7 @@ while true do
-- Blend the model with info on screen
Graphics.initBlend()
Screen.clear()
Render.drawModel(mod1, math.sin(x), math.cos(y), z, angleX, angleY)
Render.drawModel(mod1, math.sin(x), math.cos(y), z, angleX, angleY, angleZ);
Graphics.debugPrint(3, 3, "Lua Player Plus Vita - Render Module Sample - Cube Test", Color.new(255,255,255))
Graphics.debugPrint(3, 23, "Press TRIANGLE to return to the main menu.", Color.new(255,255,255))
Graphics.termBlend()
Expand All @@ -104,4 +108,4 @@ while true do
break
end

end
end
10 changes: 7 additions & 3 deletions samples/3D Model/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ System.setBusSpeed(222)
System.setGpuSpeed(222)
System.setGpuXbarSpeed(166)

-- Load image
texture = Graphics.loadImage("ux0:/data/lpp-vita/samples/3D Model/Monkey.bmp")
-- Load the model
mod1 = Render.loadObject("ux0:/data/lpp-vita/samples/3D Model/Monkey.obj", "ux0:/data/lpp-vita/samples/3D Model/Monkey.bmp")
mod1 = Render.loadObject("ux0:/data/lpp-vita/samples/3D Model/Monkey.obj", texture)

-- Set default angle, position and translation values
z = -20.0
x = 0.0
y = 0.0
angleX = 1.0
angleY = 1.0
angleZ = 1.0
translX = 0.0017
translY = 0.0034

Expand All @@ -22,6 +25,7 @@ while true do
-- Rotate the model
angleX = angleX + 0.2
angleY = angleY + 0.2
angleZ = angleY + 0.2

-- Move the model
x = x + translX
Expand All @@ -30,7 +34,7 @@ while true do
-- Blend the model with info on screen
Graphics.initBlend()
Screen.clear()
Render.drawModel(mod1, math.sin(x), math.cos(y), z, angleX, angleY)
Render.drawModel(mod1, math.sin(x), math.cos(y), z, angleX, angleY, angleZ)
Graphics.debugPrint(3, 3, "Lua Player Plus Vita - Render Module Sample - 3D Model Test", Color.new(255,255,255))
Graphics.debugPrint(3, 23, "Press TRIANGLE to return to the main menu.", Color.new(255,255,255))
Graphics.termBlend()
Expand All @@ -42,4 +46,4 @@ while true do
break
end

end
end
4 changes: 2 additions & 2 deletions samples/Keyboard/index.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Initializing a Keyboard
Keyboard.show("Sample Title", "Sample Text")
Keyboard.start("Sample Title", "Sample Text")
ret = "Waiting for user input..."

-- Main loop
Expand Down Expand Up @@ -37,4 +37,4 @@ while true do
Graphics.termBlend()
Screen.flip()

end
end

0 comments on commit 777fb33

Please sign in to comment.