Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/AssetStoreDownloads/OBJImport/OBJLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public static GameObject LoadOBJFile(string fn)
m.RecalculateNormals();
}
m.RecalculateBounds();
m.Optimize();
;

MeshFilter mf = subObject.AddComponent<MeshFilter>();
MeshRenderer mr = subObject.AddComponent<MeshRenderer>();
Expand Down
6 changes: 4 additions & 2 deletions Assets/TangoPrefabs/Shaders/ARPostProcess.shader
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Shader "Tango/ARPostProcess" {
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Tango/ARPostProcess" {
Properties
{
_MainTex ("Texture", 2D) = "white" {}
Expand Down Expand Up @@ -40,7 +42,7 @@
{
v2f o;
o.uv = v.uv;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.vertex = UnityObjectToClipPos(v.vertex);
return o;
}

Expand Down
6 changes: 4 additions & 2 deletions Assets/TangoPrefabs/Shaders/PointCloud.shader
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Shader "Tango/PointCloud" {
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Tango/PointCloud" {
Properties{
point_size("Point Size", Float) = 5.0
}
Expand Down Expand Up @@ -28,7 +30,7 @@ Properties{
v2f vert (appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.vertex = UnityObjectToClipPos(v.vertex);
o.size = point_size;

// Color should be based on pose relative info
Expand Down
6 changes: 4 additions & 2 deletions Assets/TangoPrefabs/Shaders/PointCloud_Occlusion.shader
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Shader "Tango/PointCloud (Occlusion)" {
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Tango/PointCloud (Occlusion)" {
SubShader {
Tags { "Queue" = "Background-1" }
Pass {
Expand All @@ -24,7 +26,7 @@
v2f vert (appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.vertex = UnityObjectToClipPos(v.vertex);
o.size = 30;
return o;
}
Expand Down
10 changes: 10 additions & 0 deletions Assets/TangoResearch/Common/Behaviours/FreezeRotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ public class FreezeRotation : MonoBehaviour {

private Quaternion _rotation;

public bool _FreezeX = false;
public bool _FreezeY = false;
public bool _FreezeZ = false;

void Start()
{
_rotation = transform.rotation;
Expand All @@ -13,5 +17,11 @@ void Start()
void Update()
{
transform.rotation = _rotation;
if (_FreezeX)
transform.eulerAngles = new Vector3(0, transform.rotation.y, transform.rotation.z);
if (_FreezeY)
transform.eulerAngles = new Vector3(transform.rotation.x, 0, transform.rotation.z);
if (_FreezeZ)
transform.eulerAngles = new Vector3(transform.rotation.x, transform.rotation.y, 0);
}
}

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

9 changes: 9 additions & 0 deletions Assets/TangoResearch/Common/SourceAssets.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/TangoResearch/Common/SourceAssets/Textures.meta

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

128 changes: 128 additions & 0 deletions Assets/TangoResearch/Common/Utils/ImageProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,128 @@ public static Texture2D RenderTextureToTexture2D(RenderTexture rTex)
return c;
}

public static Vector3[,] CubemapFaceToRGBArray(Cubemap cubeMap, CubemapFace face)
{
Vector3[,] c = new Vector3[cubeMap.width, cubeMap.height];

for (int i = 0; i < cubeMap.width; i++)
{
for (int j = 0; j < cubeMap.height; j++)
{
c[i, j] = ColorToVector3(cubeMap.GetPixel(face, i, j)) * 255;
}
}

return c;
}

public static Color[] CubemapFaceToColorArray(Cubemap cubeMap, CubemapFace face)
{
Color[] c = cubeMap.GetPixels(face);
return c;
}

public static Color[,] CubemapFaceTo2DColorArray(Cubemap cubeMap, CubemapFace face)
{
Color[] c = cubeMap.GetPixels(face);

Color[,] c2 = new Color[cubeMap.width, cubeMap.height];
for (int i = 0; i < cubeMap.width; i++)
{
for (int j = 0; j < cubeMap.height; j++)
{
c2[i, j] = c[j * cubeMap.width + i];
}
}

return c2;
}

public static Vector3[,] CubemapFaceTo2DVector3Array(Cubemap cubeMap, CubemapFace face)
{
Color[] c = cubeMap.GetPixels(face);

Vector3[,] c2 = new Vector3[cubeMap.width, cubeMap.height];
for (int i = 0; i < cubeMap.width; i++)
{
for (int j = 0; j < cubeMap.height; j++)
{
c2[i, cubeMap.height - j - 1] = ColorToVector3( c[j * cubeMap.width + i] );
}
}

return c2;
}

public static Vector2 BrightestPoint(Color[,] c)
{
Vector2 p = Vector3.zero;

float max = 0;
for (int i = 0; i < c.GetLength(0); i++)
{
for (int j = 0; j < c.GetLength(1); j++)
{
float cur = Grayscale(c[i,j]);
if(cur > max)
{
max = cur;
p = new Vector2(i, j);
}
}
}

return p;
}

public static Vector2 BrightestPoint(Vector3[,] c, out float average)
{
Vector2 p = Vector3.zero;
average = 0f;

float max = 0;
for (int i = 0; i < c.GetLength(0); i++)
{
for (int j = 0; j < c.GetLength(1); j++)
{
float cur = Grayscale(c[i, j]);
average += cur;
if (cur > max)
{
max = cur;
p = new Vector2(i, j);
}
}
}
average /= c.GetLength(0) * c.GetLength(1);

return p;
}

public static Vector2 BrightestPoint(float[,] c, out float average)
{
Vector2 p = Vector3.zero;
average = 0f;

float max = 0;
for (int i = 0; i < c.GetLength(0); i++)
{
for (int j = 0; j < c.GetLength(1); j++)
{
float cur = c[i, j];
average += cur;
if (cur > max)
{
max = cur;
p = new Vector2(i, j);
}
}
}
average /= c.GetLength(0) * c.GetLength(1);

return p;
}

#endregion

#region Converters
Expand Down Expand Up @@ -244,6 +366,12 @@ public static float Grayscale(Vector3 rgb)
return luma;
}

public static float Grayscale(Color rgb)
{
float luma = 0.2126f * rgb.r + 0.7152f * rgb.g + 0.0722f * rgb.b;
return luma;
}

#endregion

#region Rendering
Expand Down
Loading