-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
panorama viewer
- Loading branch information
There are no files selected for viewing
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 | ||
} | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
m_EditorVersion: 5.4.0f3 | ||
m_StandardAssetsVersion: 0 |