Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# Main
- --# Main
- -- 3D Grad
- function setup()
- print("Grad24")
- --displayMode(FULLSCREEN)
- local topBaseColrInit = getRandomHSBColr(1, 360, 0, 100, 50, 100)
- local bottomBaseColrInit = getRandomHSBColr(1, 360, 0, 100, 50, 100)
- colrGenerator = ColrGenerator()
- topBClrParamInitTime = 0
- btmBClrParamInitTime = 0
- topBClrParamInit(topBaseColrInit)
- btmBClrParamInit(bottomBaseColrInit)
- --[[print("topBaseColrInit:")
- print(topBaseColrInit)
- print("bottomBaseColrInit:")
- print(bottomBaseColrInit)]]
- updateColrParameters(topBaseColrInit, bottomBaseColrInit)
- backgrnd = gradBackground()
- -- or could set img
- updateRotationParameters()
- t = 0
- cubeSize = 25
- shapeWidth = 29
- -- Cube mesh data
- cubeMeshModel = CubeMeshModel()
- cubeMeshModel:setupCubeMesh()
- -- Block types and structures
- blockTypes = BlockTypes()
- blockStructures = BlockStructures()
- -- Scene data
- sceneDataModel = SceneDataModel()
- data = sceneDataModel:setupShapeData()
- sceneRenderer = SceneRenderer()
- -- setImg()
- updateCameraParameters()
- end
- -- This function gets called once every frame
- function draw()
- background(255,0)
- updateTopBtmBClrParamDur()
- backgrnd:draw()
- translate(WIDTH / 2, -HEIGHT/7, -700)
- rotate(rotationIdx*15, 0, 1, 0)
- ortho(0, WIDTH, 0, HEIGHT, -100, 2000)
- camera(cameraX, cameraHeight, cameraZ, 0,0,0, 0,1,0)
- sceneRenderer:renderSceneData(data)
- setContext()
- resetMatrix()
- --t = t + 1
- end
- function setImg()
- --Draw into an image
- --Do shape
- shapeImg = image(shapeWidth*cubeSize,shapeWidth*cubeSize)
- setContext(shapeImg)
- --Do drawing here
- setContext()
- end
- --# SceneDataModel
- SceneDataModel = class()
- function SceneDataModel:init()
- -- you can accept and set parameters here
- end
- function SceneDataModel:draw()
- -- Codea does not automatically call this method
- end
- function SceneDataModel:touched(touch)
- -- Codea does not automatically call this method
- end
- function SceneDataModel:setupShapeData()
- local retShapeData = {}
- -- Generate scene of empty air blocks
- for x = -1 * shapeWidth, shapeWidth do
- retShapeData[x] = {}
- for y = -1 * shapeWidth, shapeWidth do
- retShapeData[x][y] = {}
- for z = -1 * shapeWidth, shapeWidth do
- local retAirCube = Block()
- retAirCube.doesExist = false
- retAirCube.colr = color(255,0)
- retAirCube.x = x
- retAirCube.y = y
- retAirCube.z = z
- retShapeData[x][y][z] = retAirCube
- end
- end
- end
- for level = 1,3 do
- local planeXCoor1, planeXCoor2 = 0 + (level-1), 7 - (level-1)
- local planeYCoor = (level-1) * 5
- local planeZCoor1, planeZCoor2 = 0 + (level-1), 7 - (level-1)
- local planeBlockType = blockTypes:blockTypeColrB()
- retShapeData = blockStructures:spwnPlaneBtwnPnts(planeXCoor1, planeYCoor, planeZCoor1, planeXCoor2, planeYCoor, planeZCoor2, planeBlockType, retShapeData)
- for column = 1,4 do
- local colBaseYCoor = (level-1) * 5 + 1
- local colBaseXCoor1, colBaseXCoor2 = 0 + (level), 7 - (level)
- local colBaseZCoor1, colBaseZCoor2 = 0 + (level), 7 - (level)
- --Default
- local colBaseXCoor = colBaseXCoor1
- local colBaseZCoor = colBaseZCoor1
- local colBaseXZCoors = {}
- for colBaseXIdx = colBaseXCoor1, colBaseXCoor2, colBaseXCoor2 - colBaseXCoor1 do
- for colBaseZIdx = colBaseZCoor1, colBaseZCoor2, colBaseZCoor2 - colBaseZCoor1 do
- local XZCoor = {x= colBaseXIdx, z= colBaseZIdx}
- table.insert(colBaseXZCoors, XZCoor)
- end
- end
- colBaseXCoor = colBaseXZCoors[column].x
- colBaseZCoor = colBaseXZCoors[column].z
- local colHeight = 4
- local colBlockType = blockTypes:blockTypeColrA()
- --print(colBase)
- retShapeData = blockStructures:spwnColumnFrBasePnt(colBaseXCoor, colBaseYCoor, colBaseZCoor, colHeight, colBlockType, retShapeData)
- end
- end
- return retShapeData
- end
- --# Block
- Block = class()
- function Block:init()
- -- you can accept and set parameters here
- self.doesExist = false
- self.colr = ShapeColr
- self.type = ""
- self.x = 0
- self.y = 0
- self.z = 0
- end
- function Block:draw()
- -- Codea does not automatically call this method
- end
- function Block:touched(touch)
- -- Codea does not automatically call this method
- end
- --# BlockTypes
- BlockTypes = class()
- function BlockTypes:init()
- -- you can accept and set parameters here
- --TODO: BlockTypeTable
- --self.blockTypeTable = self:updateBlockTypeTable()
- end
- function BlockTypes:draw()
- -- Codea does not automatically call this method
- end
- function BlockTypes:touched(touch)
- -- Codea does not automatically call this method
- end
- function BlockTypes:updateBlockType(blockArg)
- local retBlock = blockArg
- local typeArg = blockArg.type
- if typeArg == "blockColrA" then
- retBlock.colr = blockColrA
- elseif typeArg == "blockColrB" then
- retBlock.colr = blockColrB
- end
- return retBlock
- end
- function BlockTypes:updateBlockTypeTable()
- --[[
- local retBlockTypeTable = {
- "blockColrA" = {Block().colr = blockColrA}}
- return retBlockTypeTable
- ]]
- end
- function BlockTypes:blockTypeColrA()
- return "blockColrA"
- end
- function BlockTypes:blockTypeColrB()
- return "blockColrB"
- end
- --# BlockStructures
- BlockStructures = class()
- --currently not in use, just for reference
- function BlockStructures:structures()
- -- Make a plane
- for x = 0,5 do
- for z = 0,5 do
- local cube = retShapeData[x][0][z]
- cube.doesExist = true
- cube.type = blockTypes:blockTypeColrB()
- cube = blockTypes:updateBlockType(cube)
- retShapeData[x][0][z] = cube
- end
- end
- --[[ Make a diagonal streak at specific coordinates
- local setCoors = {
- {x=3, y=1, z=0},
- {x=2, y=1, z=1},
- {x=1, y=1, z=2},
- {x=0, y=1, z=3}
- }
- for coorIdx,coor in ipairs(setCoors) do
- local setCoorCube = retShapeData[coor.x][coor.y][coor.z]
- setCoorCube.doesExist = true
- setCoorCube.type = blockTypes:blockTypeColrB()
- setCoorCube = blockTypes:updateBlockType(setCoorCube)
- retShapeData[coor.x][coor.y][coor.z] = setCoorCube
- end ]]
- -- Try spawning for the impossible triangle :)
- local impossibleTriCoors = {
- {x=3, y=1, z=3},
- {x=3, y=2, z=3},
- {x=3, y=3, z=3},
- {x=3, y=4, z=3},
- {x=3, y=5, z=3},
- {x=3, y=6, z=3},
- {x=3, y=1, z=2},
- {x=3, y=1, z=1},
- {x=3, y=1, z=0},
- {x=3, y=1, z=-1},
- {x=3, y=1, z=-2},
- {x=4, y=6, z=3},
- {x=5, y=6, z=3},
- {x=6, y=6, z=3},
- {x=7, y=6, z=3}
- }
- for coorIdx,coor in ipairs(impossibleTriCoors) do
- local setCoorCube = retShapeData[coor.x][coor.y][coor.z]
- setCoorCube.doesExist = true
- setCoorCube.type = blockTypes:blockTypeColrA()
- setCoorCube = blockTypes:updateBlockType(setCoorCube)
- retShapeData[coor.x][coor.y][coor.z] = setCoorCube
- end
- end
- function BlockStructures:spwnCubeAtPnt(xCoor, yCoor, zCoor, cubeTypeArg, dataArg)
- local dataRet = dataArg
- local cube = dataRet[xCoor][yCoor][zCoor]
- cube.doesExist = true
- cube.type = cubeTypeArg
- cube = blockTypes:updateBlockType(cube)
- dataRet[xCoor][yCoor][zCoor] = cube
- return dataRet
- end
- function BlockStructures:spwnColumnFrBasePnt(baseXCoor, baseYCoor, baseZCoor, height, cubeTypeArg, dataArg)
- local dataRet = dataArg
- -- Make a column
- for yIdx = baseYCoor, baseYCoor + height do
- dataRet = self:spwnCubeAtPnt(baseXCoor, yIdx, baseZCoor, cubeTypeArg, dataRet)
- end
- return dataRet
- end
- function BlockStructures:spwnPlaneBtwnPnts(xCoor1, yCoor1, zCoor1, xCoor2, yCoor2, zCoor2, cubeTypeArg, dataArg)
- local dataRet = dataArg
- --Checks which coor is constant
- --Note: one of coors must be constant for it to be a plane parallel to one of the axes
- if yCoor1 == yCoor2 then
- local yConstant = math.random(yCoor1, yCoor2)
- for xIdx = xCoor1, xCoor2 do
- for zIdx = zCoor1, zCoor2 do
- dataRet = self:spwnCubeAtPnt(xIdx, yConstant, zIdx, cubeTypeArg, dataRet)
- end
- end
- end
- return dataRet
- end
- --# CubeMeshModel
- CubeMeshModel = class()
- function CubeMeshModel:init()
- -- you can accept and set parameters here
- end
- function CubeMeshModel:draw()
- -- Codea does not automatically call this method
- end
- function CubeMeshModel:touched(touch)
- -- Codea does not automatically call this method
- end
- function CubeMeshModel:setupCubeMesh()
- cubeCrnrs = self:setupCubeCrnrs(cubeSize)
- cubeFacesVerts = self:setupCubeFaceVerts(cubeCrnrs)
- cubeMeshVerts = self:triangulateSixFaces(cubeFacesVerts)
- cubeMesh = mesh()
- cubeMesh.vertices = cubeMeshVerts
- end
- function CubeMeshModel:setupCubeCrnrs(size)
- local cbCrnrs = {}
- for z = 0,1 do
- for y = 0,1 do
- for x = 0,1 do
- table.insert(cbCrnrs, size * vec3(x,y,z))
- end
- end
- end
- return cbCrnrs
- --Does this: {vec3(0, 0, 0), vec3(50, 0, 0), vec3(0, 50, 0), vec3(50, 50, 0), vec3(0, 0, 50), vec3(50, 0, 50), vec3(0, 50, 50), vec3(50, 50, 50)}
- end
- function CubeMeshModel:setupCubeFaceVerts(cubeCrnrArg)
- --Set up vertices for 6 faces of a cube
- local facesVerts = {}
- --Face1,2,3,4 & Face5,6,7,8 print cubeCrnrArgIdx1 to see
- for oppSide = 0,1 do
- for crnrIdx = 1,4 do
- local faceVertsIdx1 = crnrIdx + 4*oppSide*3 -- 3 is number of pairs of opposite faces, 4 is for number of vertices
- local cubeCrnrArgIdx1 = crnrIdx + (oppSide*4) -- 4 is specific to above (1,2,3,4 & 5,6,7,8)
- facesVerts[faceVertsIdx1] = cubeCrnrArg[cubeCrnrArgIdx1]
- end
- end
- --Face1,3,5,7 & Face2,4,6,8 print cubeCrnrArgIdx2 to see
- for oppSide = 0,1 do
- for crnrIdx = 1,4 do
- faceVertsIdx2 = crnrIdx + 4*(oppSide*3 + 1)
- cubeCrnrArgIdx2 = (crnrIdx*2) - 1 + (oppSide)
- facesVerts[faceVertsIdx2] = cubeCrnrArg[cubeCrnrArgIdx2]
- end
- end
- --Face1,2,5,6 & Face3,4,7,8,print cubeCrnrArgIdx3 to see
- faceVertsIdx3 = 0
- for oppSide = 0,1 do
- faceVertsIdx3 = faceVertsIdx3 + 4*2 --second time, 8 ahead?
- for set = 0,1 do
- for partner = 1,2 do
- cubeCrnrArgIdx3 = partner + (set*4) + (oppSide*2)
- faceVertsIdx3 = faceVertsIdx3 + 1
- facesVerts[faceVertsIdx3] = cubeCrnrArg[cubeCrnrArgIdx3]
- end
- end
- end
- return facesVerts
- --Does this:
- --[[
- faceVerts = {cubeCrnrArg[1], cc[2], cc[3], cc[4],
- cc[1], cc[3], cc[5], cc[7],
- cc[1], cc[2], cc[5], cc[6],
- cc[5], cc[6], cc[7], cc[8],
- cc[2], cc[4], cc[6], cc[8],
- cc[3], cc[4], cc[7], cc[8]}
- ]]
- end
- function CubeMeshModel:triangulateSingleFace(faceVertices)
- --Splits set of quadrilateral vertices into two triangle halfs
- local triVertices = {}
- for triangleHalf = 0,1 do
- for triVertex = 1,3 do
- table.insert(triVertices, faceVertices[triVertex + triangleHalf])
- end
- end
- return triVertices
- --does this: {cc[1], cc[2], cc[3], cc[4]} –> {cc[1], cc[2], cc[3], cc[2], cc[3], cc[4]}
- end
- function CubeMeshModel:triangulateSixFaces(facesVerts)
- --Take faceVerts, separate into faces and triangulate each
- local retCubeMeshVerts = {}
- for face = 1,6 do
- local faceVertices = {}
- for polygonCorner = 1,4 do
- table.insert(faceVertices, facesVerts[polygonCorner + (face-1) * 4 ])
- end
- triFaceVertices = {}
- triFaceVertices = self:triangulateSingleFace(faceVertices)
- for i, vertex in ipairs(triFaceVertices) do
- table.insert(retCubeMeshVerts, vertex)
- end
- end
- return retCubeMeshVerts
- --does this: {cc[1], cc[2], cc[3], cc[4]} —> {cc[1], cc[2], cc[3], cc[2], cc[3], cc[4]}
- end
- --# SceneRenderer
- SceneRenderer = class()
- function SceneRenderer:init(x)
- -- you can accept and set parameters here
- end
- function SceneRenderer:draw()
- -- Codea does not automatically call this method
- end
- function SceneRenderer:touched(touch)
- -- Codea does not automatically call this method
- end
- function SceneRenderer:renderSceneData(sceneDataArg)
- for x = -1 * shapeWidth, shapeWidth do
- for y = -1 * shapeWidth, shapeWidth do
- for z = -1 * shapeWidth, shapeWidth do
- local cubeAtPoint = data[x][y][z]
- local cubeAtPoint = blockTypes:updateBlockType(cubeAtPoint)
- if cubeAtPoint.doesExist == true then
- translate(x * cubeSize, y * cubeSize, z * cubeSize)
- --shift m.colors depending on x, y, z
- --set m.color(self.colr:mix(black, distance from corner))
- cubeMesh.colors = self:cubeColor(cubeAtPoint.colr, x, y, z)
- cubeMesh:draw()
- translate(x * -1 * cubeSize, y * -1 * cubeSize, z * -1 * cubeSize)
- end
- end
- end
- end
- end
- function SceneRenderer:cubeColor(col, vecX, vecY, vecZ)
- local ret = {}
- vecRefPoint = vec3(-shapeWidth,-shapeWidth,-shapeWidth)
- for vertIdx, vertVec in ipairs(cubeMeshVerts) do
- --Base shading for perspective
- local baseShadeColr = col:mix(color(0, 0, 0, col.a), 1 - math.floor(((vertIdx - 1) % 18) / 6) * 0.15)
- --Shading for gradient
- vecToPoint = vec3((cubeSize*vecX)+vertVec.x,(cubeSize*vecY)+vertVec.y,(cubeSize*vecZ)+vertVec.z)
- distToRefPoint = vecRefPoint:dist(vecToPoint)
- maxDistAcross = vec3(-shapeWidth,-shapeWidth,-shapeWidth):dist(vec3(shapeWidth,shapeWidth,shapeWidth))
- baseShadeColr = baseShadeColr:mix(color(0), distToRefPoint/(maxDistAcross)) --NOTE: just tried math.min( 1) and doesn't shade
- --print(distToRefPoint/maxDistAcross) --takes really long
- table.insert(ret, baseShadeColr)
- end
- return ret
- end
- --# gradBackground
- gradBackground = class()
- function gradBackground:init()
- print("Smooth Background05 two tone")
- --[[
- parameter.color("topOuterColr", topBaseColr)
- parameter.color("topInnerColr", self.topInnerInitColr)
- parameter.color("bottomOuterColr", bottomBaseColr)
- parameter.color("bottomInnerColr", self.bottomInnerInitColr)
- ]]
- --parameter.action("Switch Colrs", self:switchColrs())
- end
- function gradBackground:draw()
- gradBackgrndMesh = gradBackground:generateMesh()
- gradBackgrndMesh:draw()
- end
- function gradBackground:drawMeshInImg()
- local bgImg = image(WIDTH, HEIGHT)
- return bgImg
- end
- function gradBackground:generateMesh()
- -- Note: these coors are unused at the moment
- topLeftCoor = vec2(0,HEIGHT)
- bottomLeftCoor = vec2(0,0)
- topRightCoor = vec2(WIDTH,HEIGHT)
- bottomRightCoor = vec2(WIDTH,0)
- local backgrndMesh = mesh()
- local backgrndMeshVerts = {}
- local backgrndMeshColrs = {}
- for xIdx = 0, 1 do
- --print("xIdx = "..xIdx)
- for triHalfIdx = 0, 1 do
- --print("triHalfIdx = "..triHalfIdx)
- diagTopVert = vec2()
- diagTopVert.x = WIDTH/2
- diagTopVert.y = HEIGHT
- diagTopVertColr = topInnerColr
- --print("diagTopVertX = "..diagTopVert.x.." diagTopVertY = "..diagTopVert.y)
- diagBtmVert = vec2()
- diagBtmVert.x = xIdx * WIDTH
- diagBtmVert.y = 0
- diagBtmVertColr = bottomOuterColr
- --print("diagBtmVertX = "..diagBtmVert.x.." diagBtmVertY = "..diagBtmVert.y)
- cornerVert = vec2()
- cornerVertXSign = xIdx*2 - 1
- cornerVert.x = WIDTH/2 + (triHalfIdx * WIDTH/2) * cornerVertXSign
- cornerVert.y = triHalfIdx * HEIGHT
- --print("cornerVertX = "..cornerVert.x.." cornerVertY = "..cornerVert.y)
- baseColrList = {bottomInnerColr, topOuterColr}
- cornerVertColr = baseColrList[triHalfIdx + 1]
- --Insert set of three verts as a triangle
- table.insert(backgrndMeshVerts, diagTopVert)
- table.insert(backgrndMeshVerts, diagBtmVert)
- table.insert(backgrndMeshVerts, cornerVert)
- table.insert(backgrndMeshColrs, diagTopVertColr)
- table.insert(backgrndMeshColrs, diagBtmVertColr)
- table.insert(backgrndMeshColrs, cornerVertColr)
- end
- end
- backgrndMesh.vertices = backgrndMeshVerts
- backgrndMesh.colors = backgrndMeshColrs
- return backgrndMesh
- end
- --# ColrGenerator
- ColrGenerator = class()
- function ColrGenerator:init()
- randomMixAmount = math.random(75,80)/100
- -- mixedTopAndBtmColr = topBaseColr:mix(bottomBaseColr, 0.5)
- print("Use the parameters to choose colo(u)rs.") --thanks to Inty :)
- end
- function ColrGenerator:draw()
- end
- function ColrGenerator:touched(touch)
- -- Codea does not automatically call this method
- end
- function HSB(hue, sat, bri)
- local h = hue % 360
- local s = math.min(math.max(sat, 0), 100)
- local b = math.min(math.max(bri, 0), 100)
- local colr = color(0, 0, 0)
- if h < 60 then
- colr = color(255, h * (17 / 4), 0)
- elseif h < 120 then
- colr = color((120 - h) * (17 / 4), 255, 0)
- elseif h < 180 then
- colr = color(0, 255, (h - 120) * (17 / 4))
- elseif h < 240 then
- colr = color(0, (240 - h) * (17 / 4), 255)
- elseif h < 300 then
- colr = color((h - 240) * (17 / 4), 0, 255)
- else
- colr = color(255, 0, (360 - h) * (17 / 4))
- end
- colr = colr:mix(color(255, 255, 255), s / 100)
- colr = colr:mix(color(0, 0, 0), b / 100)
- return colr.r, colr.g, colr.b
- end
- function getRandomRGBColr()
- local randomRGBColr = color(math.random(0,255), math.random(0,255), math.random(0,255))
- return randomRGBColr
- end
- function getRandomHSBColr(hueMin, hueMax, satMin, satMax, briMin, briMax)
- local randomHSBColr = color(HSB(math.random(hueMin, hueMax), math.random(satMin, satMax), math.random(briMin, briMax)))
- return randomHSBColr
- end
- function switchColrs()
- local currentTopColr = topOuterColr
- local currentBottomColr = bottomOuterColr
- topOuterColr = currentBottomColr
- bottomOuterColr = currentTopColr
- end
- function ColrGenerator:updateColrs(topBClrArg, btmBClrArg)
- topOuterColr = topBClrArg
- bottomOuterColr = btmBClrArg
- topInnerColrCalc = topBClrArg:mix(btmBClrArg, randomMixAmount)
- bottomInnerColrCalc = btmBClrArg:mix(topBClrArg, randomMixAmount)
- adjustedTopBaseColr = self:adjustBriForColr(topBClrArg)
- adjustedBottomBaseColr = self:adjustBriForColr(btmBClrArg)
- end
- function ColrGenerator:mixDarkerColr(colrArg)
- local retDarkerColr = colrArg:mix(color(0), math.random(90,100)/100)
- return retDarkerColr
- end
- function ColrGenerator:mixLighterColr(colrArg)
- local retLighterColr = colrArg:mix(color(255), math.random(90,100)/100)
- return retLighterColr
- end
- function ColrGenerator:getBriFrRGBColr(colrArg)
- local retBri = 0
- local redArg = colrArg.r
- local greenArg = colrArg.g/255
- local blueArg = colrArg.b/255
- retBri = math.max(redArg, greenArg, blueArg)/255 * 100
- return retBri
- end
- function ColrGenerator:adjustBriForColr(colrArg)
- local retAdjustedColr = colrArg
- local briArg = self:getBriFrRGBColr(colrArg)
- if briArg >= 75 then
- retAdjustedColr = self:mixDarkerColr(colrArg)
- elseif briArg <= 25 then
- retAdjustedColr = self:mixLighterColr(colrArg)
- end
- return retAdjustedColr
- end
- function ColrGenerator:adjustHueForColr()
- end
- --# ParameterUpdater
- function updateColrParameters(topBClrArg, btmBClrArg)
- --[[print("topBClrArg:")
- print(topBClrArg)
- print("btmBClrArg:")
- print(btmBClrArg)]]
- colrGenerator:updateColrs(topBClrArg, btmBClrArg)
- parameter.color("topInnerColr", topInnerColrCalc)
- parameter.color("bottomInnerColr", bottomInnerColrCalc)
- parameter.color("blockColrA", adjustedTopBaseColr)
- parameter.color("blockColrB", adjustedBottomBaseColr)
- end
- function updateTopBClrParameter(newColrValue)
- if topBClrParamDur >= 1 then
- parameter.clear()
- topBClrParamInit(newColrValue)
- btmBClrParamInit(bottomBaseColr)
- updateColrParameters(newColrValue, bottomBaseColr)
- updateRotationParameters()
- updateCameraParameters()
- end
- end
- function updateBtmBClrParameter(newColrValue)
- if btmBClrParamDur >= 1 then
- parameter.clear()
- topBClrParamInit(topBaseColr)
- btmBClrParamInit(newColrValue)
- updateColrParameters(topBaseColr, newColrValue)
- updateRotationParameters()
- updateCameraParameters()
- end
- end
- function topBClrParamInit(colrArg)
- topBClrParamInitTime = ElapsedTime
- updateTopBtmBClrParamDur()
- parameter.color("topBaseColr", colrArg, updateTopBClrParameter)
- end
- function btmBClrParamInit(colrArg)
- btmBClrParamInitTime = ElapsedTime
- updateTopBtmBClrParamDur()
- parameter.color("bottomBaseColr", colrArg, updateBtmBClrParameter)
- end
- function updateTopBtmBClrParamDur()
- topBClrParamDur = ElapsedTime - topBClrParamInitTime
- btmBClrParamDur = ElapsedTime - btmBClrParamInitTime
- end
- function updateRotationParameters()
- parameter.integer("rotationIdx", -24, 24, -3)
- parameter.watch("rotationIdx*15")
- end
- function updateCameraParameters()
- parameter.number("cameraX", -shapeWidth, shapeWidth, 0)
- parameter.number("cameraHeight", -5, 5, 3.55)
- parameter.number("cameraZ", 0, 5, 14)
- end
- function updateAllParameters()
- parameter.clear()
- updateColrParameters()
- updateRotationParameters()
- updateCameraParameters()
- end
- --# Credits
- -- Original 3D spinning shapes project by Valgo
- -- See here for code http://forum.gethopscotch.com/t/valgos-ama-ask-me-anything/20408/161
- -- Remix from t1:
- -- slight shading on blocks further from light source
- -- gradient background
- -- and some re-organisation (which is all over the place 😜😂)
- -- Thanks to yojimbo2000 for help with getting isometric camera angle and removing perspective
- -- See here for discussion https://codea.io/talk/discussion/comment/70587#Comment_70587
- -- Thanks to Intellection74 and everyone on Hopscotch for support and everything <3
- -- Thanks to Matthew C for helping me get started with coding in Codea too
- -- And thanks to ustwogames™ for bringing us the beautiful Monument Valley game ❤️❤️❤️
- -- This is just fan-made stuff inspired by their work; none of this is associated with them in any way
- -- And this is free to use/remix with credit; just let me (t1) know if you do for some reason decide to use it :)
- --# DevNotes
- -- Dev notes
- -- These are just tracking the titles of the projects
- -- (I have other notes elsewhere)
- -- 3D Grad11 sync colrs
- -- 3D Grad10 camera
- -- 3D Grad08 remove some history
- -- 3D Grad07 background
- -- could do radial
- -- do data[x][y][z] = 0, then can make shapes and set to 1
- -- project image on mesh
- -- set specific block types e.g. ladder, colourBlock from data[x][y][z] then in CubeColors() get block type from x, y, z of data array, then blockType[] = color(brown) | blockTypes = {"ladder" = etc, "blueBlock" = color(0,0,255)} | or separate for img mesh and colors
- -- 3D 2 by Valgo
- -- slight gradient remix from t1
- -- 3D Grad06 changed refPoint
- --3D Grad06 -- trying refPoint as -scaleWidth rather than origin
- -- 3D Grad05 -- scaled vecX, vecY, vecZ by cubeSize in CubeColors()
- -- 3D Grad04 --no setContext
- -- 3D by Valgo Gradient03 why shading individual
- --setContext cuts off part
- -- 3D by Valgo Gradient02
- -- 3D 2 by Valgo try gradient, -refactor
- -- 3D 2 by Valgo refactor2
- -- small remix with refactoring & spherical shape from t1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement