Having a pair of red/cyan anaglyph glasses laying around on my desk.
So, I made a quick Proof Of Concept (POC!) to generate anaglyph 3D objects:
- put on your glasses
- hold device in portrait position
- touch the screen to generate some 3D objects
nothing more, yet. but it's cool enough, eh? :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | --[[ --- ANAGLYPH 3D OBJECTS --- -- by finefin 2011 -- ]]-- display.setStatusBar(display.HiddenStatusBar) local yRay = 10 -- y start position local theObjects = {} -- objects table local function make3DCircle ( theX, theY, radius, depthLevel) local TDobjectTable = {} -- objects table to hold left/right objects local theXright = theX + depthLevel -- declare parameters... local theXleft = theX - depthLevel local theY = theY local radius = radius -- create two objects for left & right eye local new3DCircle1 = display.newCircle( theXright, theY, radius ) local new3DCircle2 = display.newCircle( theXleft, theY, radius ) new3DCircle1.alpha = 0.4 -- make transparent new3DCircle2.alpha = 0.4 new3DCircle2:setFillColor( 255, 0, 0 ) -- red new3DCircle1:setFillColor( 0, 255, 255 ) -- cyan new3DCircle1.blendMode = "add" -- set blend mode to "add" new3DCircle2.blendMode = "add" -- put objects into local table TDobjectTable[#TDobjectTable + 1] = new3DCircle1 TDobjectTable[#TDobjectTable + 1] = new3DCircle2 return TDobjectTable -- return the local table end local function create3DObject () yRay = yRay + 40 -- steps on y-axis local theX = math.random(200) + 50 -- random x-position local theY = yRay local theDepth = math.random(20) - 10 -- random depth level local theRadius = math.random(10) + 10 -- random size -- add a new 3D object to theObjects table -- remember: make3DCircle returns a table of two display objects! theObjects[#theObjects + 1] = make3DCircle ( theX, theY, theRadius, theDepth) end local function clearScreenMakeNew () -- iterate through the objects table for i,val in pairs(theObjects) do -- each object consists of two display objects (left/right): for iX,valBut in pairs(val) do valBut:removeSelf() -- remove the objects val[iX]=nil end theObjects[i] = nil -- remove from table end yRay = 10 -- reset y start position for i=0, 10,1 do -- make new objects create3DObject() end end Runtime:addEventListener( "touch", clearScreenMakeNew ) |
tinker around with this as you like.
I think it'd be cool to have accelerometer support
to move the objects accurately when you tilt your device
and stuff like that...
have fun
-finefin
Wow that was cool. I had some paper 3d glasses, so I tested it out. It looks like the DNA helix or something?
Hehe, very cool.