This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
416 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2012 | ||
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "FSSceneKit", "FSSceneKit\FSSceneKit.fsproj", "{F478F9C8-C4F9-4D4B-9714-564D982E3D68}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|iPhoneSimulator = Debug|iPhoneSimulator | ||
Release|iPhoneSimulator = Release|iPhoneSimulator | ||
Debug|iPhone = Debug|iPhone | ||
Release|iPhone = Release|iPhone | ||
Ad-Hoc|iPhone = Ad-Hoc|iPhone | ||
AppStore|iPhone = AppStore|iPhone | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.AppStore|iPhone.ActiveCfg = AppStore|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.AppStore|iPhone.Build.0 = AppStore|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Debug|iPhone.ActiveCfg = Debug|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Debug|iPhone.Build.0 = Debug|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Release|iPhone.ActiveCfg = Release|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Release|iPhone.Build.0 = Release|iPhone | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator | ||
{F478F9C8-C4F9-4D4B-9714-564D982E3D68}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator | ||
EndGlobalSection | ||
GlobalSection(MonoDevelopProperties) = preSolution | ||
StartupItem = FSSceneKit\FSSceneKit.fsproj | ||
EndGlobalSection | ||
EndGlobal |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions
11
CardboardMiniHack/SceneKitFsharp/FSSceneKit/Content/city.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
length, width, height, x, y | ||
1.0, 1.0, 2.0, 0.0, 0.0 | ||
1.0, 1.0, 1.0, 1.0, 0.0 | ||
1.0, 1.0, 2.5, -1.5, 0.0 | ||
1.0, 1.0, 2.0, 2.0, 1.5 | ||
1.0, 1.0, 2.5, -2.5, 1.5 | ||
1.0, 1.0, 1.0, 3.0, 1.5 | ||
1.0, 2.0, 3.0, 2.0, -1.5 | ||
2.0, 2.0, 5.5, -2.5, -1.5 | ||
1.0, 1.0, 1.0, 1.5, -1.5 | ||
3.0, 3.0, 4.0, 0.0, -4.5 |
6 changes: 6 additions & 0 deletions
6
CardboardMiniHack/SceneKitFsharp/FSSceneKit/Entitlements.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
</dict> | ||
</plist> |
132 changes: 132 additions & 0 deletions
132
CardboardMiniHack/SceneKitFsharp/FSSceneKit/FSSceneKit.fsproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform> | ||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids> | ||
<ProjectGuid>{F478F9C8-C4F9-4D4B-9714-564D982E3D68}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>FSSceneKit</RootNamespace> | ||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix> | ||
<AssemblyName>FSSceneKit</AssemblyName> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath> | ||
<DefineConstants>DEBUG</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<Tailcalls>false</Tailcalls> | ||
<ConsolePause>false</ConsolePause> | ||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> | ||
<PlatformTarget> | ||
</PlatformTarget> | ||
<MtouchDebug>true</MtouchDebug> | ||
<MtouchLink>None</MtouchLink> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' "> | ||
<DebugSymbols>false</DebugSymbols> | ||
<DebugType>none</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<PlatformTarget> | ||
</PlatformTarget> | ||
<MtouchLink>None</MtouchLink> | ||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> | ||
<ConsolePause>false</ConsolePause> | ||
<Tailcalls>true</Tailcalls> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\iPhone\Debug</OutputPath> | ||
<DefineConstants>DEBUG</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<Tailcalls>false</Tailcalls> | ||
<ConsolePause>false</ConsolePause> | ||
<MtouchDebug>true</MtouchDebug> | ||
<PlatformTarget> | ||
</PlatformTarget> | ||
<CodesignKey>iPhone Developer</CodesignKey> | ||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' "> | ||
<DebugSymbols>false</DebugSymbols> | ||
<DebugType>none</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhone\Release</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<PlatformTarget> | ||
</PlatformTarget> | ||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> | ||
<CodesignKey>iPhone Developer</CodesignKey> | ||
<ConsolePause>false</ConsolePause> | ||
<Tailcalls>true</Tailcalls> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' "> | ||
<DebugSymbols>false</DebugSymbols> | ||
<DebugType>none</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<PlatformTarget> | ||
</PlatformTarget> | ||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> | ||
<BuildIpa>true</BuildIpa> | ||
<CodesignKey>iPhone Distribution</CodesignKey> | ||
<CodesignProvision>Automatic:AdHoc</CodesignProvision> | ||
<ConsolePause>false</ConsolePause> | ||
<Tailcalls>true</Tailcalls> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' "> | ||
<DebugSymbols>false</DebugSymbols> | ||
<DebugType>none</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\iPhone\AppStore</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<PlatformTarget> | ||
</PlatformTarget> | ||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements> | ||
<CodesignKey>iPhone Distribution</CodesignKey> | ||
<CodesignProvision>Automatic:AppStore</CodesignProvision> | ||
<ConsolePause>false</ConsolePause> | ||
<Tailcalls>true</Tailcalls> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="FSharp.Core" /> | ||
<Reference Include="monotouch" /> | ||
<Reference Include="Zlib.Portable"> | ||
<HintPath>..\packages\Zlib.Portable.1.10.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll</HintPath> | ||
</Reference> | ||
<Reference Include="FSharp.Data"> | ||
<HintPath>..\packages\FSharp.Data.2.0.14\lib\portable-net40+sl5+wp8+win8\FSharp.Data.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<BundleResource Include="Resources\Default-568h%402x.png" /> | ||
<BundleResource Include="textureX.png" /> | ||
<BundleResource Include="Content\building1.jpg" /> | ||
<BundleResource Include="Content\building2.jpg" /> | ||
<BundleResource Include="Content\building3.jpg" /> | ||
<BundleResource Include="Content\city.csv" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Info.plist" /> | ||
<None Include="Entitlements.plist" /> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="FSSceneKitViewController.fs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.FSharp.targets" /> | ||
<ItemGroup> | ||
<Folder Include="Content\" /> | ||
</ItemGroup> | ||
</Project> |
124 changes: 124 additions & 0 deletions
124
CardboardMiniHack/SceneKitFsharp/FSSceneKit/FSSceneKitViewController.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
namespace SceneKitFSharp | ||
|
||
open System | ||
open System.IO | ||
open System.Linq | ||
open FSharp.Data | ||
open MonoTouch.UIKit | ||
open MonoTouch.Foundation | ||
open MonoTouch.SceneKit | ||
open MonoTouch.CoreAnimation | ||
open System.Drawing | ||
|
||
[<Register("FSSceneKitViewController")>] | ||
type FSSceneKitViewController() = | ||
inherit UIViewController() | ||
|
||
let building width length height posx posy (scene:SCNScene) (rnd:Random) = | ||
let boxNode = new SCNNode () | ||
boxNode.Geometry <- new SCNBox( | ||
Width = width, | ||
Height = height, | ||
Length = length, | ||
ChamferRadius = 0.02f | ||
) | ||
boxNode.Position <- new SCNVector3(posx, height/2.0F, posy) | ||
|
||
scene.RootNode.AddChildNode (boxNode) | ||
let buildings = ["Content/building1.jpg"; "Content/building2.jpg"; "Content/building3.jpg"] | ||
let material = new SCNMaterial () | ||
material.Diffuse.Contents <- UIImage.FromFile (buildings.[rnd.Next(buildings.Length)]) | ||
material.Diffuse.ContentsTransform <- SCNMatrix4.Scale ( new SCNVector3(width,height,1.F)) | ||
material.Diffuse.WrapS <- SCNWrapMode.Repeat | ||
material.Diffuse.WrapT <- SCNWrapMode.Repeat | ||
material.Diffuse.MipFilter <- SCNFilterMode.Linear | ||
material.Diffuse.MinificationFilter <- SCNFilterMode.Linear | ||
material.Diffuse.MagnificationFilter <- SCNFilterMode.Linear | ||
material.Specular.Contents <- UIColor.Gray | ||
|
||
material.LocksAmbientWithDiffuse <- true | ||
|
||
boxNode.Geometry.FirstMaterial <- material | ||
boxNode | ||
|
||
let random (min, max, (rnd:Random)) = | ||
float32 (rnd.Next(min, max)) | ||
|
||
let buildCamera (scene : SCNScene) loc = | ||
let c = new SCNNode() | ||
c.Camera <- new SCNCamera() | ||
scene.RootNode.AddChildNode (c) | ||
c.Position <- loc | ||
c | ||
|
||
let configView (view : SCNView) scene = | ||
view.ClipsToBounds <- true | ||
view.Scene <- scene | ||
view.AllowsCameraControl <- false | ||
view.ShowsStatistics <- false | ||
view.BackgroundColor <- UIColor.FromRGB(52, 152, 219) | ||
view | ||
|
||
override this.ViewDidLoad () = | ||
let scene = new SCNScene () | ||
|
||
//Positions everyone! | ||
let rnd = new Random(); | ||
|
||
let bs = List.map (fun i -> (building | ||
(random (1, 5, rnd)) | ||
(random (1, 5, rnd)) | ||
(random (1, 10, rnd)) | ||
(random (-50, 50, rnd)) | ||
(random (-50, 50, rnd)) | ||
scene | ||
rnd)) [0..200] | ||
|
||
//Lights! | ||
let lightNode = new SCNNode() | ||
lightNode.Light <- new SCNLight () | ||
lightNode.Light.LightType <- SCNLightType.Omni | ||
lightNode.Position <- new SCNVector3 (30.0F, 20.0F, 60.0F) | ||
scene.RootNode.AddChildNode (lightNode) | ||
|
||
let ambientLightNode = new SCNNode () | ||
ambientLightNode.Light <- new SCNLight () | ||
ambientLightNode.Light.LightType <- SCNLightType.Ambient | ||
ambientLightNode.Light.Color <- UIColor.DarkGray | ||
scene.RootNode.AddChildNode (ambientLightNode) | ||
|
||
//Cameras! | ||
let leftCameraNode = buildCamera scene (new SCNVector3 (0.0F, 9.0F, 50.0F)) | ||
|
||
let targetNode = new SCNNode () | ||
targetNode.Position <- new SCNVector3 (00.0F, 0.0F, 20.0F); | ||
scene.RootNode.AddChildNode (targetNode) | ||
|
||
//Point the camera | ||
let lc = SCNLookAtConstraint.Create (targetNode); | ||
leftCameraNode.Constraints <- [lc].ToArray().Cast<SCNConstraint>().ToArray() | ||
|
||
//Configure view | ||
let r = new RectangleF(new PointF(0.0f, 0.0f), new SizeF(UIScreen.MainScreen.Bounds.Size)) | ||
let s = new SCNView(r) | ||
configView s scene |> ignore | ||
this.View <- s | ||
|
||
[<Register ("AppDelegate")>] | ||
type AppDelegate () = | ||
inherit UIApplicationDelegate () | ||
|
||
let mutable window:UIWindow = null | ||
|
||
// This method is invoked when the application is ready to run. | ||
override this.FinishedLaunching (app, options) = | ||
window <- new UIWindow (UIScreen.MainScreen.Bounds) | ||
window.RootViewController <- new FSSceneKitViewController() | ||
window.MakeKeyAndVisible () | ||
true | ||
|
||
module Main = | ||
[<EntryPoint>] | ||
let main args = | ||
UIApplication.Main (args, null, "AppDelegate") | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
</dict> | ||
</plist> |
Binary file added
BIN
+2.16 KB
CardboardMiniHack/SceneKitFsharp/FSSceneKit/Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="FSharp.Data" version="2.0.14" targetFramework="MonoTouch10" /> | ||
<package id="Zlib.Portable" version="1.10.0" targetFramework="MonoTouch10" /> | ||
</packages> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.