Skip to content

Instantly share code, notes, and snippets.

Oliver Dew Utsira

Block or report user

Report or block Utsira

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View example_augmentedOffice_planeBoundary.swift
private func planeBoundary(extent: float3) -> (min: SCNVector3, max: SCNVector3) {
let radius = extent * 0.5
return (min: SCNVector3(-radius), max: SCNVector3(radius))
}
View example_augmentedOffice_didUpdateNode.swift
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
guard let plane = anchor as? ARPlaneAnchor,
let geometry = node.geometry as? ARSCNPlaneGeometry
else { return }
geometry.update(from: plane.geometry)
node.boundingBox = planeBoundary(extent: plane.extent)
}
View example_augmentedOffice_nodeForAnchor.swift
func renderer(_ renderer: SCNSceneRenderer, nodeFor anchor: ARAnchor) -> SCNNode? {
guard let plane = anchor as? ARPlaneAnchor,
let device = renderer.device,
let geometry = ARSCNPlaneGeometry(device: device)
else { return nil }
geometry.update(from: plane.geometry)
let maskMaterial = SCNMaterial()
maskMaterial.colorBufferWriteMask = []
geometry.materials = [maskMaterial]
let node = SCNNode(geometry: geometry)
View example_augmentedOffice_startTracking.swift
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
startTracking()
}
private func startTracking() {
sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints]
let configuration = ARWorldTrackingConfiguration()
configuration.planeDetection = [.vertical, .horizontal]
sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
@Utsira
Utsira / example_augmentedOffice_didUpdateNode.swift
Created Jun 9, 2018
Examples for augmented office blog post
View example_augmentedOffice_didUpdateNode.swift
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
guard let plane = anchor as? ARPlaneAnchor,
let geometry = node.geometry as? ARSCNPlaneGeometry
else { return }
geometry.update(from: plane.geometry)
node.boundingBox = planeBoundary(extent: plane.extent)
}
@Utsira
Utsira / InstancingOBJtest.lua
Created Oct 30, 2015
Profiling instancing of obj models in Codea
View InstancingOBJtest.lua
--# Main
--Simple Blender .obj loader
--assumes each object has only one texture image
--currently only supports one object per file
--todo: remote images
local touches, tArray, lastPinchDist = {}, {}
@Utsira
Utsira / Main.lua
Last active Aug 29, 2015 — forked from tarrouye/Main.lua
Multiplayer Class (and Drawing Example)
View Main.lua
function setup()
local connectionMade = function()
output.clear()
parameter.clear()
print("Connected!")
gameSetup()
end
multihandler = Multiplayer(receiveData, connectionMade)
@Utsira
Utsira / MarkdownCodeaParaStitch
Created Jul 12, 2015
Markdown Codea with paragraph stitching
View MarkdownCodeaParaStitch
--# Main
-- Markdown Codea
-- paragraph-stitching version
-- by Yojimbo2000
displayMode(OVERLAY)
displayMode(FULLSCREEN)
function setup()
state = Stitch
state.init()
@Utsira
Utsira / MarkdownCodea
Last active Jan 9, 2016
Markdown-like text formatting in Codea
View MarkdownCodea
--# Main
-- Markdown Codea
-- by Yojimbo2000
displayMode(FULLSCREEN)
function setup()
setText()
y,vel = 0,0
scrollY={} --store deltas for smooth scrolling upon finger release
end
@Utsira
Utsira / SaveBox2DStateAsJson
Created Jun 22, 2015
Save and load a snapshot of a Box2D scene using JSON
View SaveBox2DStateAsJson
--# Main
-- Json Test
supportedOrientations(LANDSCAPE_LEFT)
displayMode(OVERLAY)
-- Use this function to perform your initial setup
function setup()
parameter.action("Take snapshot", function() tabSave(objects, "Test") end)
parameter.action("Load from snapshot", function() killBodies() loadBodies() end)
AddToJson() --establish metamethods for encoding vec2, vec3, vec4, matrix as json objects
You can’t perform that action at this time.