I bet you never thought I could do this, well HA! I DID IT! Muahahahaha! I’m kidding.
WARNING: PLEASE PASTE INTO PROJECT FOR FULL COMPATIBILITY
Features:
-A cube, that you can move with touch
-Size, you can increase/decrease the size of the cube
-Textures, 6 different textures to choose from
-Auto Rotation, can be toggled on and off
COMING SOON:
-Options menu
-Custom vertices
-Physics
Very special thanks to @Ignatz @yojimbo2000 and @dave1707 for the help and support for 3D, it’s greatly appreciated!
Any feedback and update ideas would be appreciated, thanks!
function setup()
parameter.number("Size", 1,100,10)
parameter.boolean("Auto_Rotate", true)
parameter.action("Change Texture", texPage)
parameter.action("Options", opPressed)
camX,camY,camZ = 0,0,-500
lookX,lookY,lookZ = 0,0,-1000
X,Y,Z = 50,0,-1000
moveZ = 5
RX,RY,RZ = 0,0,0
rX,rY,rZ = 0.1,0.5,1.0
SetupCube(Size)
end
function opPressed()
if opPressed then
parameter.clear()
parameter.action("?", returned)
parameter.watch("No options yet. :(")
end
end
function SetupCube(Size)
local d = 0.5 * Size
local vertices = {
vec3(-d, -d, d),
vec3( d, -d, d),
vec3( d, d, d),
vec3(-d, d, d),
vec3(-d, -d, -d),
vec3( d, -d, -d),
vec3( d, d, -d),
vec3(-d, d, -d),
}
local cVert = {
vertices[1], vertices[2], vertices[3],
vertices[1], vertices[3], vertices[4],
vertices[2], vertices[6], vertices[7],
vertices[2], vertices[7], vertices[3],
vertices[6], vertices[5], vertices[8],
vertices[6], vertices[8], vertices[7],
vertices[5], vertices[1], vertices[4],
vertices[5], vertices[4], vertices[8],
vertices[4], vertices[3], vertices[7],
vertices[4], vertices[7], vertices[8],
vertices[5], vertices[6], vertices[2],
vertices[5], vertices[2], vertices[1],
}
local texvertices = { vec2(0.03,0.24),
vec2(0.97,0.24),
vec2(0.03,0.69),
vec2(0.97,0.69) }
local tCoords = {
texvertices[1], texvertices[2], texvertices[4],
texvertices[1], texvertices[4], texvertices[3],
texvertices[1], texvertices[2], texvertices[4],
texvertices[1], texvertices[4], texvertices[3],
texvertices[1], texvertices[2], texvertices[4],
texvertices[1], texvertices[4], texvertices[3],
texvertices[1], texvertices[2], texvertices[4],
texvertices[1], texvertices[4], texvertices[3],
texvertices[1], texvertices[2], texvertices[4],
texvertices[1], texvertices[4], texvertices[3],
texvertices[1], texvertices[2], texvertices[4],
texvertices[1], texvertices[4], texvertices[3],
}
m = mesh()
m.vertices = cVert
m.texture = "Planet Cute:Dirt Block"
m.texCoords = tCoords
m:setColors(255,255,255,255)
end
function draw()
background(0)
perspective()
camera(camX, camY, camZ, lookX, lookY, lookZ)
pushMatrix()
translate(X,Y,Z)
rotate(-CurrentTouch.y, 1, 0, 0)
rotate(CurrentTouch.x, 0,1,0)
rotate(RZ,0,0,1)
if Auto_Rotate == true then
rotate(ElapsedTime*10, 1,0,0)
rotate(ElapsedTime*10, 0,1,0)
rotate(ElapsedTime*10, 0,0,1)
else
rotate(0, 1,0,0)
rotate(0, 0,1,0)
rotate(0, 0,0,1)
end
local s = Size*0.25
scale(s,s,s)
m:draw()
resetMatrix()
sprite("SpaceCute:Background", 0, 0, 300, 300)
rotate(45,0,1,0)
translate(0, -100, -200)
popMatrix()
popStyle()
end
function texPage()
if texPage then
parameter.clear()
parameter.action("?", returned)
parameter.action("Dirt", function() m.texture = "Planet Cute:Dirt Block"end)
parameter.action("Grass", function() m.texture = "Planet Cute:Grass Block"end)
parameter.action("Stone", function() m.texture = "Planet Cute:Stone Block"end)
parameter.action("Wood", function() m.texture = "Planet Cute:Wood Block"end)
parameter.action("Water", function() m.texture = "Planet Cute:Water Block"end)
parameter.action("Quartz & Wood", function() m.texture = "Planet Cute:Wall Block"end)
end
end
function returned()
if returned then
parameter.clear()
parameter.number("Size", 1,100,Size)
parameter.boolean("Auto_Rotate", true)
parameter.action("Change Texture", texPage)
parameter.action("Options", opPressed)
end
end