Skip to content

Instantly share code, notes, and snippets.

--# Main
-- Walkthrough main
function setup()
if Backup then Backup("Town 102") end --my backup software
posX,posY,posZ=140,20,-20 --starting position (Y and Z are transposed, Y is vertical eye position)
angle=0
rad=math.pi/180
Map:setup() --set up the map mesh, buildings etc
@dermotbalson
dermotbalson / gist:8780502
Last active January 25, 2017 23:40
Rotation demos v1a
--# Notes
--[[
ROTATION WITH QUATERNIONS AND FLYING
This project demonstrates the use of quaternions to rotate objects and fly them
The Main tab only contains code to help you choose from a number of demo projects. You will not need it in
your own projects.
--# Notes
--[[
This set of demos is aimed at people who have not worked with 3D before.
3D is a very, very big subject, with a lot to learn, so this set of demos can only scratch the surface, and cannot possibly explain everything there is to know.
You can simply watch the demos to see what Codea can do, but ideally,you should read up on 3D before trying to understand how the demos work, and before trying your own projects.
Also, this is not a set of "Wow, look what 3D can do" demos. If you look at them all without reading the notes,
--# Notes
--[[
This project shows how to add different types of lighting to 3D scenes (in this case, a cube)
--HOW TO USE THIS PROJECT
There are a number of tabs at the top. Press on a tab to see its code.
Work through the tabs from left to right, to see the project develop
--# Main
displayMode(FULLSCREEN)
function setup()
size,radius=150,15
CreateScene()
end
function CreateScene() --size is size of 3D box
--# Main
--# Main
displayMode(FULLSCREEN)
function setup()
size,radius=150,15
CreateScene()
--# Main
--# Main
displayMode(FULLSCREEN)
function setup()
size,radius=200,10
CreateScene()
--# Main
displayMode(FULLSCREEN)
function setup()
size,radius=200,10
pos=vec3(0,0,0) --assumes centre of box is (0,0,0)
CreateScene()
notStarted=true
end
--# Main
displayMode(FULLSCREEN)
function setup()
size,radius=200,10
startPos=vec3(size/2,size/2,-size/2) --assumes centre of box is (0,0,0)
CreateScene(size,radius,startPos)
notStarted=true
end