LoginSignup
4
0

More than 5 years have passed since last update.

THETA&unityで360画像/動画球体を作ってみた

Last updated at Posted at 2019-05-08

まずはTHETAのアプリをダウンロード。

https://support.theta360.com/ja/download/
DRLはここ、適宜なバージョンを選択してダウンロードします。

THETAから画像をPC側にコピー

THETAはReadOnlyなので、コピーしないと作業できない。

THETAで撮った動画をアプリにドラッグ(画像ならこのステップは不要)

変換完了まで待つ
image.png
完了あと変換できた画像をUnityにインポート

シーンの中でスフィアを作る

image.png

球体の材質を変える

ディフォルトの材質は物理に基づくレンダリングなので、テクスチャーは光に影響される。これを避けるために、まずは新しいマテリアルを作って、それから【UnlitShader】を作る。
image.png
次にUnlitShaderをマテリアルに与える。
最後にマテリアルを球体に与える
image.png
↑こういう感じです。

画像をドラッグしてマテリアルに与える

image.png

動画の場合

image.png
image.png
↑ここにドラッグ

こうすると、もう画像が見えましたが、テクスチャーがスフィアの外についてるので、法線を反転しないといけない。

最後のステップ

下のスクリプトを球体に追加

C#:NormalReverser.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NormalReverser : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        int[] triangles = GetComponent<MeshFilter>().mesh.triangles;
        for (int i = 0; i < triangles.Length; i += 3)
        {
            int t = triangles[i];
            triangles[i] = triangles[i + 2];
            triangles[i + 2] = t;
        }
        GetComponent<MeshFilter>().mesh.triangles = triangles;

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

    }

}

image.png
スクリプトファイルの名前とクラスの名前は一緒じゃないとだめ。

何をやったかというと、マッシュの三角形の第二の点と第三の点を入れ替わった。
image.png
image.png
こうして、法線ベクトルが反転された。

テスト

カメラの位置を球体の中心に合わせて、Play!
おすすめの位置はimage.png
image.png
ResetPositionをタッチすると自動に(0,0,0)に戻る。

最後はこういう感じです。
image.png

4
0
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
4
0