Skip to content

Commit

Permalink
sample demo
Browse files Browse the repository at this point in the history
panorama viewer
  • Loading branch information
Shirlman committed Oct 14, 2016
1 parent 081de0a commit 2d33f47
Show file tree
Hide file tree
Showing 33 changed files with 351 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/Assets/AssetStoreTools*

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd


# Unity3D generated meta files
*.pidb.meta

# Unity3D Generated File On Crash Reports
sysinfo.txt

# Builds
*.apk
*.unitypackage
Binary file added Assets/Dining&Living_Door.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions Assets/Dining&Living_Door.JPG.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/HighSphere.fbx
Binary file not shown.
77 changes: 77 additions & 0 deletions Assets/HighSphere.fbx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions Assets/InsideVisible.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Based on Unlit shader, but culls the front faces instead of the back

Shader "InsideVisible" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader {
Tags { "RenderType"="Opaque" }
Cull front // ADDED BY BERNIE, TO FLIP THE SURFACES
LOD 100

Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"

struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};

struct v2f {
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
};

sampler2D _MainTex;
float4 _MainTex_ST;

v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
// ADDED BY BERNIE:
v.texcoord.x = 1 - v.texcoord.x;
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}

fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord);
return col;
}
ENDCG
}
}

}
9 changes: 9 additions & 0 deletions Assets/InsideVisible.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/Dining&Living_Door.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Materials/Dining&Living_Door.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Materials/lambert1.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Materials/lambert1.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions Assets/PanoramaCameraController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using UnityEngine;
using System.Collections;

public class PanoramaCameraController : MonoBehaviour
{
private Camera mCamera;

//方向灵敏度
private float mTouchSensitivity = 0.3f;
private float mMouseSensitivity = 5F;

//上下最大视角(Y视角)
private float minimumY = -60F;
private float maximumY = 60F;

private float rotationY = 0F;

// Use this for initialization
void Start ()
{
mCamera = this.GetComponent<Camera>();

if (mCamera == null)
{
mCamera = Camera.main;
}

rotationY = -mCamera.transform.localEulerAngles.x;
}

// Update is called once per frame
void Update () {
if(Application.platform == RuntimePlatform.Android)
{
TouchControl();
}
else
{
MouseControl();
}
}

void MouseControl()
{
//鼠标右键
if (Input.GetMouseButton(0))
{
//根据鼠标移动的快慢(增量), 获得相机左右旋转的角度(处理X)
float rotationX = mCamera.transform.localEulerAngles.y - Input.GetAxis("Mouse X") * mMouseSensitivity;

//根据鼠标移动的快慢(增量), 获得相机上下旋转的角度(处理Y)
rotationY -= Input.GetAxis("Mouse Y") * mMouseSensitivity;
//角度限制. rotationY小于min,返回min. 大于max,返回max. 否则返回value
rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

//总体设置一下相机角度
mCamera.transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
}

void TouchControl()
{
if (Input.touchCount == 1)//一个手指触摸屏幕
{
if (Input.touches[0].phase == TouchPhase.Moved)//手指移动
{
float rotationX = mCamera.transform.localEulerAngles.y - Input.touches[0].deltaPosition.x * mTouchSensitivity;

rotationY -= Input.touches[0].deltaPosition.y * mTouchSensitivity;
rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

mCamera.transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
}
}
}
12 changes: 12 additions & 0 deletions Assets/PanoramaCameraController.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/main.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/main.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added ProjectSettings/AudioManager.asset
Binary file not shown.
Binary file added ProjectSettings/ClusterInputManager.asset
Binary file not shown.
Binary file added ProjectSettings/DynamicsManager.asset
Binary file not shown.
Binary file added ProjectSettings/EditorBuildSettings.asset
Binary file not shown.
Binary file added ProjectSettings/EditorSettings.asset
Binary file not shown.
Binary file added ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file added ProjectSettings/InputManager.asset
Binary file not shown.
Binary file added ProjectSettings/NavMeshAreas.asset
Binary file not shown.
Binary file added ProjectSettings/NetworkManager.asset
Binary file not shown.
Binary file added ProjectSettings/Physics2DSettings.asset
Binary file not shown.
Binary file added ProjectSettings/ProjectSettings.asset
Binary file not shown.
2 changes: 2 additions & 0 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
m_EditorVersion: 5.4.0f3
m_StandardAssetsVersion: 0
Binary file added ProjectSettings/QualitySettings.asset
Binary file not shown.
Binary file added ProjectSettings/TagManager.asset
Binary file not shown.
Binary file added ProjectSettings/TimeManager.asset
Binary file not shown.
Binary file added ProjectSettings/UnityAdsSettings.asset
Binary file not shown.
Binary file added ProjectSettings/UnityConnectSettings.asset
Binary file not shown.

0 comments on commit 2d33f47

Please sign in to comment.