LoginSignup
14
18

More than 5 years have passed since last update.

Unity+THETA S+UVC Blenderでライブストーリミング画像を表示してみる

Last updated at Posted at 2017-04-21

Unityのお勉強でUVC Blenderを利用してTHETA Sのライブストリーミング画像を表示させてみた。
かなりあっさりできてしまったが、動いているものを見るとおーっとなる。
やったことをメモしておく。

環境

  • macOS 10.12.4
  • Unity 5.5.2f1
  • THETA S ファームバージョン 01.82
  • THETA UVC Blender v2.0.0 (THETA SそのままだとDua)

事前準備

Unityでしたこと

  • Sphere作成
    • Scale X, Y, Zをそれぞれ100に設定
  • Sphereモデルを天球として利用するシェーダー - Qiitaを参照して作成したSphereにシェーダーを適用(Sphereの中からストリーミング画像を見るため)
    • [Assets]で[Create] => [Shader] => [Unlit Shader]でシェーダー作成
    • 作成されたシェーダーをリンク先に従って編集
    • [Assets]で[Create] => [Material]でマテリアル作成
    • マテリアルの[Inspector] => [Shader]に作成したシェーダー設定
    • マテリアルをSphereにドラッグ&ドロップして適用
  • Sphereにスクリプトを設定
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WebCameraController : MonoBehaviour {

    // Use this for initialization
    void Start () {
        WebCamDevice[] devices = WebCamTexture.devices;
        Debug.Log ("DevicesLength:" + devices.Length.ToString ());
        for (var i = 0; i < devices.Length; i++) {
            Debug.Log (devices [i].name);
        }

        // 環境によってはindexの変更が必要
        WebCamTexture webCamTexture = new WebCamTexture (devices [0].name);
        GetComponent<Renderer> ().material.mainTexture = webCamTexture;
        webCamTexture.Play ();
    }

    // Update is called once per frame
    void Update () {

    }
}

追記

No hack, no work • UnityとOculusで360度パノラマ全天周動画を見る方法【無料編】で提供されているSphere100.fbxを使うと綺麗だし上のようなことをしないでも配置するだけですむ。

ただし、Sphere100.fbxは正面が少しずれているので正確に正面を設定するなら調整が必要。

Windows環境

先駆者に教えていただいたのだが、現状WebCamTextureを使うとWindowsではUVC Blenderが認識されないらしい。
Getting Unity to recognize THETA UVC FullHD Blender Camera - THETA Media - THETA 360 Developerのようにレジストリをいじるといけるらしい。

14
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
18