├── .gitignore ├── Assets ├── ThetaStreaming.meta └── ThetaStreaming │ ├── LitJson.dll │ ├── LitJson.dll.meta │ ├── Materials.meta │ ├── Materials │ ├── ThetaView.mat │ ├── ThetaView.mat.meta │ ├── phong1.mat │ └── phong1.mat.meta │ ├── Models.meta │ ├── Models │ ├── Sphere100.fbx │ └── Sphere100.fbx.meta │ ├── ThetaWifiStreaming.cs │ ├── ThetaWifiStreaming.cs.meta │ ├── ThetaWifiStreamingDemo.unity │ └── ThetaWifiStreamingDemo.unity.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityConnectSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD solution and project files 9 | ExportedObj/ 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | *.svd 20 | 21 | 22 | # Unity3D generated meta files 23 | *.pidb.meta 24 | 25 | # Unity3D Generated File On Crash Reports 26 | sysinfo.txt 27 | 28 | # Builds 29 | *.apk 30 | *.unitypackage 31 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5e8ec7d3b59643eeaabf4e664f117b2 3 | folderAsset: yes 4 | timeCreated: 1471909452 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/LitJson.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/Assets/ThetaStreaming/LitJson.dll -------------------------------------------------------------------------------- /Assets/ThetaStreaming/LitJson.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d72154bcdd7c422aa3163683d8657b8 3 | timeCreated: 1471878522 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 1 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | platformData: 11 | Any: 12 | enabled: 1 13 | settings: {} 14 | Editor: 15 | enabled: 0 16 | settings: 17 | DefaultValueInitialized: true 18 | WindowsStoreApps: 19 | enabled: 0 20 | settings: 21 | CPU: AnyCPU 22 | userData: 23 | assetBundleName: 24 | assetBundleVariant: 25 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 458f23ebc45304448833d36b198a5daf 3 | folderAsset: yes 4 | timeCreated: 1471884513 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Materials/ThetaView.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/Assets/ThetaStreaming/Materials/ThetaView.mat -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Materials/ThetaView.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7a105b95682a44738eb254d4e763a52 3 | timeCreated: 1471882068 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Materials/phong1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/Assets/ThetaStreaming/Materials/phong1.mat -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Materials/phong1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f05373f5f68b84f4ba4042c97c02026f 3 | timeCreated: 1471909583 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Models.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f9a237c7d4d3494dbb5495ba203fea7 3 | folderAsset: yes 4 | timeCreated: 1471909498 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Models/Sphere100.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/Assets/ThetaStreaming/Models/Sphere100.fbx -------------------------------------------------------------------------------- /Assets/ThetaStreaming/Models/Sphere100.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88fde9f4332b5468e842448b936f56af 3 | timeCreated: 1471884513 4 | licenseType: Pro 5 | ModelImporter: 6 | serializedVersion: 19 7 | fileIDToRecycleName: 8 | 100000: //RootNode 9 | 400000: //RootNode 10 | 2300000: //RootNode 11 | 3300000: //RootNode 12 | 4300000: pSphere1 13 | 9500000: //RootNode 14 | materials: 15 | importMaterials: 1 16 | materialName: 0 17 | materialSearch: 1 18 | animations: 19 | legacyGenerateAnimations: 4 20 | bakeSimulation: 0 21 | resampleCurves: 1 22 | optimizeGameObjects: 0 23 | motionNodeName: 24 | animationImportErrors: 25 | animationImportWarnings: 26 | animationRetargetingWarnings: 27 | animationDoRetargetingWarnings: 0 28 | animationCompression: 1 29 | animationRotationError: 0.5 30 | animationPositionError: 0.5 31 | animationScaleError: 0.5 32 | animationWrapMode: 0 33 | extraExposedTransformPaths: [] 34 | clipAnimations: [] 35 | isReadable: 1 36 | meshes: 37 | lODScreenPercentages: [] 38 | globalScale: 1 39 | meshCompression: 0 40 | addColliders: 0 41 | importBlendShapes: 1 42 | swapUVChannels: 0 43 | generateSecondaryUV: 0 44 | useFileUnits: 1 45 | optimizeMeshForGPU: 1 46 | keepQuads: 0 47 | weldVertices: 1 48 | secondaryUVAngleDistortion: 8 49 | secondaryUVAreaDistortion: 15.000001 50 | secondaryUVHardAngle: 88 51 | secondaryUVPackMargin: 4 52 | useFileScale: 1 53 | tangentSpace: 54 | normalSmoothAngle: 60 55 | normalImportMode: 0 56 | tangentImportMode: 3 57 | importAnimation: 1 58 | copyAvatar: 0 59 | humanDescription: 60 | human: [] 61 | skeleton: [] 62 | armTwist: 0.5 63 | foreArmTwist: 0.5 64 | upperLegTwist: 0.5 65 | legTwist: 0.5 66 | armStretch: 0.05 67 | legStretch: 0.05 68 | feetSpacing: 0 69 | rootMotionBoneName: 70 | hasTranslationDoF: 0 71 | lastHumanDescriptionAvatarSource: {instanceID: 0} 72 | animationType: 2 73 | humanoidOversampling: 1 74 | additionalBone: 0 75 | userData: 76 | assetBundleName: 77 | assetBundleVariant: 78 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/ThetaWifiStreaming.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Net; 4 | using System.IO; 5 | using System.Text; 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using LitJson; 9 | 10 | public class ThetaWifiStreaming : MonoBehaviour { 11 | 12 | private bool isLooping = true; 13 | private Renderer myRenderer; 14 | public string thetaUrl = "http://192.168.1.1:80"; 15 | private string executeCmd = "/osc/commands/execute"; 16 | public JsonData outputJson = new JsonData(); 17 | 18 | // Use this for initialization 19 | IEnumerator Start () { 20 | string jsonStr; 21 | myRenderer = GetComponent(); 22 | 23 | jsonStr = "{" + 24 | "\"name\" : \"camera.startSession\", " + 25 | "\"parameters\": {} " + 26 | "}"; 27 | yield return StartCoroutine( SendThetaCmd( jsonStr ) ); 28 | print( outputJson["results"]["sessionId"] ); 29 | string sessionId = (string)(outputJson["results"]["sessionId"]); 30 | 31 | string url = thetaUrl + executeCmd; 32 | var request = HttpWebRequest.Create (url); 33 | HttpWebResponse response = null; 34 | request.Method = "POST"; 35 | request.Timeout = (int)(30 * 10000f); 36 | request.ContentType = "application/json;charset=utf-8"; 37 | 38 | byte[] postBytes = Encoding.Default.GetBytes ("{" + 39 | "\"name\": \"camera._getLivePreview\"," + 40 | "\"parameters\": { " + 41 | "\"sessionId\": \"" + sessionId +"\"" + 42 | "}" + 43 | "}"); 44 | request.ContentLength = postBytes.Length; 45 | 46 | Stream reqStream = request.GetRequestStream (); 47 | reqStream.Write (postBytes, 0, postBytes.Length); 48 | reqStream.Close (); 49 | Stream stream = request.GetResponse ().GetResponseStream (); 50 | 51 | BinaryReader reader = new BinaryReader (new BufferedStream (stream), new System.Text.ASCIIEncoding ()); 52 | 53 | List imageBytes = new List (); 54 | bool isLoadStart = false; 55 | while( isLooping ) { 56 | byte byteData1 = reader.ReadByte (); 57 | byte byteData2 = reader.ReadByte (); 58 | 59 | if (!isLoadStart) { 60 | if (byteData1 == 0xFF && byteData2 == 0xD8){ 61 | // mjpeg start! ( [0xFF 0xD8 ... ) 62 | imageBytes.Add(byteData1); 63 | imageBytes.Add(byteData2); 64 | 65 | isLoadStart = true; 66 | } 67 | } else { 68 | imageBytes.Add(byteData1); 69 | imageBytes.Add(byteData2); 70 | 71 | if (byteData1 == 0xFF && byteData2 == 0xD9){ 72 | // mjpeg end (... 0xFF 0xD9] ) 73 | 74 | Texture2D tex = new Texture2D(2, 2); 75 | tex.LoadImage ((byte[])imageBytes.ToArray ()); 76 | myRenderer.material.mainTexture = tex; 77 | imageBytes.Clear(); 78 | yield return null; 79 | isLoadStart = false; 80 | } 81 | } 82 | } 83 | } 84 | 85 | public IEnumerator SendThetaCmd ( string inputJsonText ) { 86 | 87 | Dictionary header = new Dictionary (); 88 | header.Add ("Content-Type", "application/json; charset=UTF-8"); 89 | 90 | byte[] postBytes = Encoding.Default.GetBytes (inputJsonText); 91 | 92 | string url = thetaUrl + executeCmd; 93 | WWW myWww = new WWW (url, postBytes, header); 94 | yield return myWww; 95 | 96 | if (myWww.error == null) { 97 | Debug.Log("Success"); 98 | outputJson = JsonMapper.ToObject( myWww.text ); 99 | print( myWww.text ); 100 | } 101 | else{ 102 | Debug.Log("Failure"); 103 | } 104 | } 105 | // Update is called once per frame 106 | void Update () { 107 | if ( Input.GetKey(KeyCode.Escape) ) { 108 | isLooping = false; 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/ThetaWifiStreaming.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bedcd74e030a54b7b940d243f4542abf 3 | timeCreated: 1471909931 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/ThetaStreaming/ThetaWifiStreamingDemo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/Assets/ThetaStreaming/ThetaWifiStreamingDemo.unity -------------------------------------------------------------------------------- /Assets/ThetaStreaming/ThetaWifiStreamingDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 548e165c1386e449a8b6a3390831799a 3 | timeCreated: 1471882316 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Makoto Ito 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.4.0f3 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/ThetaWifiStreaming/5d45b9f314675c60c016e0e8c0611a5aec259bb7/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ThetaWifiStreaming 2 | Theta S Wifi Streaming Demo with Unity 3 | 4 | ## 準備するもの 5 | 1. Theta S 6 | 2. Wifiが使えるPC/Mac(iOS/Androidでも多分使えます) 7 | 8 | ## 使い方 9 | 1. Theta S を起動させて、Wifiモードをオンにする。 10 | 2. PC/Mac と Theta をWifiで繋げる。パスワードはThetaの底に書いてある、「XS」に後に続く数字8桁(XSは除く)。 11 | 3. このプロジェクトをUnityで開いてスタートさせると、Sphere100のマテリアルにストリーミング画像が出る。 12 | 13 | ## 謝辞 14 | - のしぷさんのブログを参考にさせていただきました。 http://noshipu.hateblo.jp/entry/2016/04/21/183439 ありがとうございました! 15 | - This project uses LitJson to read Json format. https://lbv.github.io/litjson/ Thank you very much. 16 | --------------------------------------------------------------------------------