Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7sharp9/43d21e99a1072bb2c599 to your computer and use it in GitHub Desktop.
Save 7sharp9/43d21e99a1072bb2c599 to your computer and use it in GitHub Desktop.
namespace FSHelloSceneKit
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
open MonoTouch.SceneKit
type FSHelloSceneKitViewController () =
inherit UIViewController()
let CreateDiffuseLightNode (color: UIColor, position: SCNVector3, lightType: NSString): SCNNode =
new SCNNode (Light = new SCNLight (Color = color, LightType = lightType),
Position = position)
override this.ViewDidLoad () =
let scene = new SCNScene ()
let view = new SCNView (this.View.Frame, Scene = scene, AutoresizingMask = UIViewAutoresizing.All, AllowsCameraControl = true)
scene.RootNode.AddChildNode
new SCNNode (Camera = new SCNCamera (XFov = 40.0, YFov = 40.0),
Position = new SCNVector3(0.0F, 0.0F, 40.0F))
let material = new SCNMaterial ()
material.Diffuse.Contents <- UIImage.FromFile "monkey.png"
material.Specular.Contents <- UIColor.White
let sphere = new SCNNode (Geometry = SCNSphere.Create(10.0F), Position = new SCNVector3(0.0F, 0.0F, 0.0F))
sphere.Geometry.FirstMaterial <- material
scene.RootNode.AddChildNode sphere
scene.RootNode.AddChildNode
new SCNNode (Light = new SCNLight (LightType = SCNLightType.Ambient, Color = UIColor.Purple))
[| ( UIColor.Blue, new SCNVector3 (-40.0F, 40.0F, 60.0F) )
( UIColor.Yellow, new SCNVector3 (20.0F, 20.0F, -70.0F) )
( UIColor.Red, new SCNVector3 (20.0F, -20.0F, 40.0F) )
( UIColor.Green, new SCNVector3 (20.0F, -40.0F, 70.0F) ) |]
|> Seq.map (fun (color, pos) -> CreateDiffuseLightNode(color, pos, SCNLightType.Omni))
|> Seq.iter scene.RootNode.AddChildNode
this.View.Add(view)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment