Initialer Upload neues Unity-Projekt
This commit is contained in:
93
Assets/CapturePanorama/Scripts/Icosphere.cs
Normal file
93
Assets/CapturePanorama/Scripts/Icosphere.cs
Normal file
@ -0,0 +1,93 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
// Based on http://blog.andreaskahler.com/2009/06/creating-icosphere-mesh-in-code.html
|
||||
// Currently unused but planned for use with future features like seam-free mono capture.
|
||||
namespace CapturePanorama
|
||||
{
|
||||
public static class Icosphere
|
||||
{
|
||||
|
||||
// Use this for initialization
|
||||
public static Mesh BuildIcosphere(float radius, int iterations)
|
||||
{
|
||||
Mesh result = BuildIcosahedron(radius);
|
||||
for (int i = 0; i < iterations; i++)
|
||||
Refine(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Mesh BuildIcosahedron(float radius) // radius is distance to each vertex from origin
|
||||
{
|
||||
Mesh result = new Mesh();
|
||||
|
||||
// create 12 vertices of a icosahedron
|
||||
float t = (float)((1.0 + Math.Sqrt(5.0)) / 2.0);
|
||||
|
||||
Vector3[] vertices = new Vector3[]
|
||||
{
|
||||
new Vector3(-1.0f, t, 0.0f),
|
||||
new Vector3( 1.0f, t, 0.0f),
|
||||
new Vector3(-1.0f, -t, 0.0f),
|
||||
new Vector3( 1.0f, -t, 0.0f),
|
||||
|
||||
new Vector3( 0.0f, -1.0f, t),
|
||||
new Vector3( 0.0f, 1.0f, t),
|
||||
new Vector3( 0.0f, -1.0f, -t),
|
||||
new Vector3( 0.0f, 1.0f, -t),
|
||||
|
||||
new Vector3( t, 0.0f, -1.0f),
|
||||
new Vector3( t, 0.0f, 1.0f),
|
||||
new Vector3( -t, 0.0f, -1.0f),
|
||||
new Vector3( -t, 0.0f, 1.0f),
|
||||
};
|
||||
|
||||
float scale = radius / new Vector3(1.0f, t, 0.0f).magnitude;
|
||||
for (int i = 0; i < vertices.Length; i++)
|
||||
vertices[i] *= scale;
|
||||
|
||||
result.vertices = vertices;
|
||||
|
||||
result.triangles = new int[]
|
||||
{
|
||||
// 5 faces around point 0
|
||||
0, 11, 5,
|
||||
0, 5, 1,
|
||||
0, 1, 7,
|
||||
0, 7, 10,
|
||||
0, 10, 11,
|
||||
|
||||
// 5 adjacent faces
|
||||
1, 5, 9,
|
||||
5, 11, 4,
|
||||
11, 10, 2,
|
||||
10, 7, 6,
|
||||
7, 1, 8,
|
||||
|
||||
// 5 faces around point 3
|
||||
3, 9, 4,
|
||||
3, 4, 2,
|
||||
3, 2, 6,
|
||||
3, 6, 8,
|
||||
3, 8, 9,
|
||||
|
||||
// 5 adjacent faces
|
||||
4, 9, 5,
|
||||
2, 4, 11,
|
||||
6, 2, 10,
|
||||
8, 6, 7,
|
||||
9, 8, 1,
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void Refine(Mesh m)
|
||||
{
|
||||
throw new Exception("TODO");
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CapturePanorama/Scripts/Icosphere.cs.meta
Normal file
12
Assets/CapturePanorama/Scripts/Icosphere.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c30b5cc0105feb4a97840530aece901
|
||||
timeCreated: 1437825051
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Assets/CapturePanorama/Scripts/ImageEffectCopyCamera.cs
Normal file
83
Assets/CapturePanorama/Scripts/ImageEffectCopyCamera.cs
Normal file
@ -0,0 +1,83 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CapturePanorama.Internals
|
||||
{
|
||||
class ImageEffectCopyCamera : MonoBehaviour
|
||||
{
|
||||
public struct InstanceMethodPair {
|
||||
public object Instance;
|
||||
public MethodInfo Method;
|
||||
}
|
||||
public List<InstanceMethodPair> onRenderImageMethods = new List<InstanceMethodPair>();
|
||||
|
||||
public static List<InstanceMethodPair> GenerateMethodList(Camera camToCopy)
|
||||
{
|
||||
var result = new List<InstanceMethodPair>();
|
||||
foreach (var script in camToCopy.gameObject.GetComponents<MonoBehaviour>())
|
||||
{
|
||||
if (script.enabled)
|
||||
{
|
||||
Type scriptType = script.GetType();
|
||||
MethodInfo m = scriptType.GetMethod("OnRenderImage",
|
||||
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null,
|
||||
new Type[] { typeof(RenderTexture), typeof(RenderTexture) }, null);
|
||||
if (m != null)
|
||||
{
|
||||
InstanceMethodPair pair = new InstanceMethodPair();
|
||||
pair.Instance = script;
|
||||
pair.Method = m;
|
||||
result.Add(pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
RenderTexture[] temp = new RenderTexture[] { null, null };
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
if (temp[i] != null)
|
||||
Destroy(temp[i]);
|
||||
temp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
void OnRenderImage(RenderTexture src, RenderTexture dest)
|
||||
{
|
||||
int desiredDepth = Math.Max(src.depth, dest.depth);
|
||||
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
if (onRenderImageMethods.Count > i + 1)
|
||||
{
|
||||
if (temp[i] != null &&
|
||||
(temp[i].width != dest.width || temp[i].height != dest.height || temp[i].depth != desiredDepth || temp[i].format != dest.format))
|
||||
{
|
||||
Destroy(temp[i]);
|
||||
temp[i] = null;
|
||||
}
|
||||
if (temp[i] == null)
|
||||
temp[i] = new RenderTexture(dest.width, dest.height, desiredDepth, dest.format);
|
||||
}
|
||||
}
|
||||
|
||||
var sequence = new List<RenderTexture>();
|
||||
sequence.Add(src);
|
||||
for (int i = 0; i < onRenderImageMethods.Count - 1; i++)
|
||||
sequence.Add(i % 2 == 0 ? temp[0] : temp[1]);
|
||||
sequence.Add(dest);
|
||||
|
||||
for (int i = 0; i < onRenderImageMethods.Count; i++)
|
||||
onRenderImageMethods[i].Method.Invoke(onRenderImageMethods[i].Instance, new object[] { sequence[i], sequence[i + 1] });
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CapturePanorama/Scripts/ImageEffectCopyCamera.cs.meta
Normal file
12
Assets/CapturePanorama/Scripts/ImageEffectCopyCamera.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 89b4b90d697c75942976465b0500b667
|
||||
timeCreated: 1438559789
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
120
Assets/CapturePanorama/Scripts/ReadPanoConfig.cs
Normal file
120
Assets/CapturePanorama/Scripts/ReadPanoConfig.cs
Normal file
@ -0,0 +1,120 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace CapturePanorama
|
||||
{
|
||||
public class ReadPanoConfig : MonoBehaviour
|
||||
{
|
||||
public string iniPath;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (Application.isEditor)
|
||||
return;
|
||||
|
||||
CapturePanorama pano = GetComponent<CapturePanorama>();
|
||||
string path = iniPath;
|
||||
if (path == "")
|
||||
{
|
||||
string filename = "CapturePanorama.ini";
|
||||
path = Application.dataPath + "/" + filename;
|
||||
}
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
// INI file does not exist, creating instead
|
||||
WriteConfig(path, pano);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string line in File.ReadAllLines(path))
|
||||
{
|
||||
if (line.Trim() == "")
|
||||
continue;
|
||||
|
||||
string[] splitLine = line.Split(new char[] { '=' }, 2);
|
||||
string key = splitLine[0].Trim();
|
||||
string val = splitLine[1].Trim();
|
||||
|
||||
if (key == "Panorama Name")
|
||||
pano.panoramaName = val;
|
||||
else if (key == "Capture Key")
|
||||
pano.captureKey = (KeyCode)Enum.Parse(typeof(KeyCode), val);
|
||||
else if (key == "Image Format")
|
||||
pano.imageFormat = (CapturePanorama.ImageFormat)Enum.Parse(typeof(CapturePanorama.ImageFormat), val);
|
||||
else if (key == "Capture Stereoscopic")
|
||||
pano.captureStereoscopic = bool.Parse(val);
|
||||
else if (key == "Interpupillary Distance")
|
||||
pano.interpupillaryDistance = float.Parse(val);
|
||||
else if (key == "Num Circle Points")
|
||||
pano.numCirclePoints = int.Parse(val);
|
||||
else if (key == "Panorama Width")
|
||||
pano.panoramaWidth = int.Parse(val);
|
||||
else if (key == "Anti Aliasing")
|
||||
pano.antiAliasing = (CapturePanorama.AntiAliasing)int.Parse(val);
|
||||
else if (key == "Ssaa Factor")
|
||||
pano.ssaaFactor = int.Parse(val);
|
||||
else if (key == "Save Image Path")
|
||||
pano.saveImagePath = val;
|
||||
else if (key == "Save Cubemap")
|
||||
pano.saveCubemap = bool.Parse(val);
|
||||
else if (key == "Upload Images")
|
||||
pano.uploadImages = bool.Parse(val);
|
||||
else if (key == "Use Default Orientation")
|
||||
pano.useDefaultOrientation = bool.Parse(val);
|
||||
else if (key == "Use Gpu Transform")
|
||||
pano.useGpuTransform = bool.Parse(val);
|
||||
else if (key == "Cpu Milliseconds Per Frame")
|
||||
pano.cpuMillisecondsPerFrame = (float)double.Parse(val);
|
||||
else if (key == "Capture Every Frame")
|
||||
pano.captureEveryFrame = bool.Parse(val);
|
||||
else if (key == "Frame Rate")
|
||||
pano.frameRate = int.Parse(val);
|
||||
else if (key == "Max Frames To Record")
|
||||
pano.maxFramesToRecord = val == "" ? 0 : int.Parse(val);
|
||||
else if (key == "Frame Number Digits")
|
||||
pano.frameNumberDigits = int.Parse(val);
|
||||
else if (key == "Fade During Capture")
|
||||
pano.fadeDuringCapture = bool.Parse(val);
|
||||
else if (key == "Fade Time")
|
||||
pano.fadeTime = float.Parse(val);
|
||||
else if (key == "Enable Debugging")
|
||||
pano.enableDebugging = bool.Parse(val);
|
||||
else
|
||||
Debug.LogError("Unrecognized key in line in CapturePanorama.ini: " + line);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteConfig(string path, CapturePanorama pano)
|
||||
{
|
||||
using (var writer = new StreamWriter(path))
|
||||
{
|
||||
writer.WriteLine("Panorama Name" + "=" + pano.panoramaName);
|
||||
writer.WriteLine("Capture Key" + "=" + pano.captureKey);
|
||||
writer.WriteLine("Image Format" + "=" + pano.imageFormat);
|
||||
writer.WriteLine("Capture Stereoscopic" + "=" + pano.captureStereoscopic);
|
||||
writer.WriteLine("Interpupillary Distance" + "=" + pano.interpupillaryDistance);
|
||||
writer.WriteLine("Num Circle Points" + "=" + pano.numCirclePoints);
|
||||
writer.WriteLine("Panorama Width" + "=" + pano.panoramaWidth);
|
||||
writer.WriteLine("Anti Aliasing" + "=" + (int)pano.antiAliasing);
|
||||
writer.WriteLine("Ssaa Factor" + "=" + pano.ssaaFactor);
|
||||
writer.WriteLine("Save Image Path" + "=" + pano.saveImagePath);
|
||||
writer.WriteLine("Save Cubemap" + "=" + pano.saveCubemap);
|
||||
writer.WriteLine("Upload Images" + "=" + pano.uploadImages);
|
||||
writer.WriteLine("Use Default Orientation" + "=" + pano.useDefaultOrientation);
|
||||
writer.WriteLine("Use Gpu Transform" + "=" + pano.useGpuTransform);
|
||||
writer.WriteLine("Cpu Milliseconds Per Frame" + "=" + pano.cpuMillisecondsPerFrame);
|
||||
writer.WriteLine("Capture Every Frame" + "=" + pano.captureEveryFrame);
|
||||
writer.WriteLine("Frame Rate" + "=" + pano.frameRate);
|
||||
writer.WriteLine("Max Frames To Record" + "=" + pano.maxFramesToRecord);
|
||||
writer.WriteLine("Frame Number Digits" + "=" + pano.frameNumberDigits);
|
||||
writer.WriteLine("Fade During Capture" + "=" + pano.fadeDuringCapture);
|
||||
writer.WriteLine("Fade Time" + "=" + pano.fadeTime);
|
||||
writer.WriteLine("Enable Debugging" + "=" + pano.enableDebugging);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CapturePanorama/Scripts/ReadPanoConfig.cs.meta
Normal file
12
Assets/CapturePanorama/Scripts/ReadPanoConfig.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa15e3b423ebd7c438d5e7c5c9e60a2a
|
||||
timeCreated: 1437619670
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/CapturePanorama/Scripts/ScreenFadeControl.cs
Normal file
32
Assets/CapturePanorama/Scripts/ScreenFadeControl.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace CapturePanorama.Internals
|
||||
{
|
||||
public class ScreenFadeControl : MonoBehaviour
|
||||
{
|
||||
public Material fadeMaterial = null;
|
||||
|
||||
// Based on OVRScreenFade
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
void OnCustomPostRender()
|
||||
#else
|
||||
void OnPostRender()
|
||||
#endif
|
||||
{
|
||||
fadeMaterial.SetPass(0);
|
||||
GL.PushMatrix();
|
||||
GL.LoadOrtho();
|
||||
GL.Color(fadeMaterial.color);
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.Vertex3(0f, 0f, -12f);
|
||||
GL.Vertex3(0f, 1f, -12f);
|
||||
GL.Vertex3(1f, 1f, -12f);
|
||||
GL.Vertex3(1f, 0f, -12f);
|
||||
GL.End();
|
||||
GL.PopMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CapturePanorama/Scripts/ScreenFadeControl.cs.meta
Normal file
12
Assets/CapturePanorama/Scripts/ScreenFadeControl.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d523dbe145a52c64aaf87e2287a4de1b
|
||||
timeCreated: 1432449878
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user