Commit 8fb0197b authored by BlackAngle233's avatar BlackAngle233
Browse files

12.1 update MR version

parent 41013d65
...@@ -121,103 +121,6 @@ NavMeshSettings: ...@@ -121,103 +121,6 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1 &384968185
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 384968189}
- component: {fileID: 384968188}
- component: {fileID: 384968187}
- component: {fileID: 384968186}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &384968186
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 384968185}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a6c90b73b6862d24b9b9bd76ad26b47b, type: 3}
m_Name:
m_EditorClassIdentifier:
formula: x + y
minX: -1
maxX: 1
minY: -1
maxY: 1
--- !u!33 &384968187
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 384968185}
m_Mesh: {fileID: 4300018, guid: a37785fa4a4129246a58f79132a1b6c6, type: 3}
--- !u!23 &384968188
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 384968185}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!4 &384968189
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 384968185}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 9.43}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &595124460 --- !u!1 &595124460
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
This diff is collapsed.
...@@ -275,7 +275,8 @@ public class Calculator2D ...@@ -275,7 +275,8 @@ public class Calculator2D
} }
while(opstack.Count > 0) while(opstack.Count > 0)
{ {
calculateStack(3, ref numstack, ref opstack); if (!calculateStack(3, ref numstack, ref opstack))
return false;
} }
yOut = numstack.Peek(); yOut = numstack.Peek();
return true; return true;
......
...@@ -279,7 +279,8 @@ public class Calculator3D ...@@ -279,7 +279,8 @@ public class Calculator3D
} }
while (opstack.Count > 0) while (opstack.Count > 0)
{ {
calculateStack(3, ref numstack, ref opstack); if (!calculateStack(3, ref numstack, ref opstack))
return false;
} }
zOut = numstack.Peek(); zOut = numstack.Peek();
//Debug.Log(x.ToString() + "," + y.ToString() + "=" + zOut.ToString()); //Debug.Log(x.ToString() + "," + y.ToString() + "=" + zOut.ToString());
......
...@@ -38,12 +38,14 @@ public class Customized : MonoBehaviour ...@@ -38,12 +38,14 @@ public class Customized : MonoBehaviour
int[] triangle = new int[100 * (maxX - minX) * 2]; int[] triangle = new int[100 * (maxX - minX) * 2];
int k = 0; int k = 0;
float step = 0.01f; float step = 0.01f;
for (float i = minX; i <= maxX + 0.01f; i += step) for (float i = minX; i <= maxX; i += step)
{ {
float y = 0; float y = 0;
if(calculator2D.calculate2D(formula, i ,out y)) if(calculator2D.calculate2D(formula, i ,out y))
{ {
vectors[k] = new Vector3(i, y, 0); vectors[k] = new Vector3(i, y, 0);
if (k != 0)
{
if (isContinue) if (isContinue)
{ {
triangle[2 * (k - 1)] = k - 1; triangle[2 * (k - 1)] = k - 1;
...@@ -54,6 +56,7 @@ public class Customized : MonoBehaviour ...@@ -54,6 +56,7 @@ public class Customized : MonoBehaviour
triangle[2 * (k - 1)] = k; triangle[2 * (k - 1)] = k;
triangle[2 * (k - 1) + 1] = k; triangle[2 * (k - 1) + 1] = k;
} }
}
isContinue = true; isContinue = true;
} }
else else
...@@ -71,4 +74,80 @@ public class Customized : MonoBehaviour ...@@ -71,4 +74,80 @@ public class Customized : MonoBehaviour
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void DrawCustomized3D()
{
mesh.Clear();
bool isContinue = false;
Vector3[] vectors = new Vector3[200 * (maxX - minX) + 2];
int[] triangle = new int[100 * (maxX - minX) * 6];
int k = 0;
float step = 0.01f;
for (float i = minX; i <= maxX; i += step)
{
float y = 0;
if (calculator2D.calculate2D(formula, i, out y))
{
vectors[k] = new Vector3(i, y, -5);
vectors[k + 1] = new Vector3(i, y, 5);
if (k != 0)
{
if (isContinue)
{
triangle[3 * (k - 2)] = k - 2;
triangle[3 * (k - 2) + 1] = k - 1;
triangle[3 * (k - 2) + 2] = k;
triangle[3 * (k - 2) + 3] = k - 1;
triangle[3 * (k - 2) + 4] = k + 1;
triangle[3 * (k - 2) + 5] = k;
}
else
{
triangle[3 * (k - 2)] = k - 2;
triangle[3 * (k - 2) + 1] = k - 1;
triangle[3 * (k - 2) + 2] = k - 1;
triangle[3 * (k - 2) + 3] = k;
triangle[3 * (k - 2) + 4] = k + 1;
triangle[3 * (k - 2) + 5] = k;
}
}
isContinue = true;
}
else
{
if (k != 0)
{
vectors[k] = vectors[k - 2];
vectors[k + 1] = vectors[k - 1];
}
else
{
vectors[k] = new Vector3(0, 0, -1000);
vectors[k + 1] = new Vector3(0, 0, -1000);
}
isContinue = false;
}
k += 2;
}
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh;
}
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
...@@ -57,4 +57,69 @@ public class Ellipse : MonoBehaviour ...@@ -57,4 +57,69 @@ public class Ellipse : MonoBehaviour
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void DrawEllipse3D()
{
mesh.Clear();
Vector3[] vectors = new Vector3[400];
int k = 0;
float step = a / 50;
for (float i = -a; i <= a; i += step)
{
float y = 1 - i * i / (a * a);
y *= (b * b);
y = Mathf.Sqrt(y);
vectors[k] = new Vector3(i, y, -5);
if (y != 0)
{
vectors[400 - k] = new Vector3(i, -y, -5);
}
k++;
vectors[k] = new Vector3(i, y, 5);
if (y != 0)
{
if(k % 2 == 0)
vectors[400 - k] = new Vector3(i, -y, 5);
else
vectors[402 - k] = new Vector3(i, -y, 5);
}
k++;
}
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, (vectors[i].y + 4) / 8);
}
mesh.uv = uvs;
int[] triangle = new int[1200];
for (int i = 0; i < 199; ++i)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
triangle[1194] = 398;
triangle[1195] = 399;
triangle[1196] = 0;
triangle[1197] = 399;
triangle[1198] = 1;
triangle[1199] = 0;
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh;
}
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
...@@ -25,7 +25,6 @@ public class Exponential : MonoBehaviour ...@@ -25,7 +25,6 @@ public class Exponential : MonoBehaviour
{ {
} }
public void DrawExponential() public void DrawExponential()
{ {
mesh.Clear(); mesh.Clear();
...@@ -54,4 +53,53 @@ public class Exponential : MonoBehaviour ...@@ -54,4 +53,53 @@ public class Exponential : MonoBehaviour
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void DrawExponential3D()
{
mesh.Clear();
float step = 0.01f;
Vector3[] vectors = new Vector3[200 * (maxX - minX) + 2];
int k = 0;
for (float i = minX; i <= maxX; i = i + step)
{
float y = Mathf.Pow(c, i);
y *= factor;
vectors[k] = new Vector3(i, y, -5);
k++;
vectors[k] = new Vector3(i, y, 5);
k++;
}
vectors[200 * (maxX - minX)] = new Vector3(maxX, Mathf.Pow(c, maxX) * factor, -5);
vectors[200 * (maxX - minX) + 1] = new Vector3(maxX, Mathf.Pow(c, maxX) * factor, 5);
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
int[] triangle = new int[100 * (maxX - minX) * 6];
for (int i = 0; i < 100 * (maxX - minX); ++i)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh;
}
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
...@@ -81,4 +81,108 @@ public class Hyperbola : MonoBehaviour ...@@ -81,4 +81,108 @@ public class Hyperbola : MonoBehaviour
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void DrawHyperbola3D()
{
mesh.Clear();
Vector3[] vectors = new Vector3[404];
int k = 0;
float step = a / 100;
float x = -a;
while (k < 101)
{
float y = x * x / (a * a) - 1;
y *= (b * b);
y = Mathf.Sqrt(y);
vectors[100 + k] = new Vector3(x, y, -5);
if (y != 0)
{
if(k % 2 == 0)
vectors[100 - k] = new Vector3(x, -y, -5);
else
vectors[102 - k] = new Vector3(x, -y, -5);
}
k++;
vectors[100 + k] = new Vector3(x, y, 5);
if (y != 0)
{
if (k % 2 == 0)
vectors[100 - k] = new Vector3(x, -y, 5);
else
vectors[102 - k] = new Vector3(x, -y, 5);
}
x -= step;
step *= 1.1f;
k++;
}
x = a;
step = a / 100;
k = 0;
while (k < 101)
{
float y = x * x / (a * a) - 1;
y *= (b * b);
y = Mathf.Sqrt(y);
vectors[301 + k] = new Vector3(x, y, -5);
if (y != 0)
{
if (k % 2 == 0)
vectors[301 - k] = new Vector3(x, -y, -5);
else
vectors[303 - k] = new Vector3(x, -y, -5);
}
k++;
vectors[301 + k] = new Vector3(x, y, 5);
if (y != 0)
{
if (k % 2 == 0)
vectors[301 - k] = new Vector3(x, -y, 5);
else
vectors[303 - k] = new Vector3(x, -y, 5);
}
x += step;
step *= 1.1f;
k++;
}
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
int[] triangle = new int[1200];
for (int i = 0; i < 99; ++i)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
for (int i = 101; i < 200; ++i)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh;
}
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
...@@ -120,4 +120,123 @@ public class InverseTri : MonoBehaviour ...@@ -120,4 +120,123 @@ public class InverseTri : MonoBehaviour
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void DrawInverseTri3D()
{
mesh.Clear();
if(inverseTriTpye != InverseTriTpye.Arctan)
{
float step = 0.01f;
Vector3[] vectors = new Vector3[200 * 2 + 2];
int k = 0;
for (float i = -1; i <= 1; i = i + step)
{
float y = i;
switch (inverseTriTpye)
{
case InverseTriTpye.Arcsin:
y = Mathf.Asin(y);
break;
case InverseTriTpye.Arccos:
y = Mathf.Acos(y);
break;
default:
break;
}
vectors[k] = new Vector3(i, y, -5);
k++;
vectors[k] = new Vector3(i, y, 5);
k++;
}
switch (inverseTriTpye)
{
case InverseTriTpye.Arcsin:
vectors[200 * 2] = new Vector3(1, Mathf.Asin(1), -5);
vectors[200 * 2 + 1] = new Vector3(1, Mathf.Asin(1), 5);
break;
case InverseTriTpye.Arccos:
vectors[200 * 2] = new Vector3(1, Mathf.Acos(1), -5);
vectors[200 * 2 + 1] = new Vector3(1, Mathf.Acos(1), 5);
break;
default:
break;
}
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
int[] triangle = new int[100 * 2 * 6];
for (int i = 0; i < 200; ++i)
{
if (vectors[2 * i].y * vectors[2 * i + 2].y >= 0)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
else
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i;
triangle[6 * i + 3] = 2 * i + 3;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
}
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
}
else
{
float step = 0.01f;
Vector3[] vectors = new Vector3[200 * (maxX - minX) + 2];
int k = 0;
for (float i = minX; i <= maxX; i = i + step)
{
float y = i;
y = Mathf.Atan(y);
vectors[k] = new Vector3(i, y, -5);
k++;
vectors[k] = new Vector3(i, y, 5);
k++;
}
vectors[200 * (maxX - minX)] = new Vector3(maxX, Mathf.Atan(maxX), -5);
vectors[200 * (maxX - minX) + 1] = new Vector3(maxX, Mathf.Atan(maxX), 5);
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
int[] triangle = new int[100 * (maxX - minX) * 6];
for (int i = 0; i < 100 * (maxX - minX); ++i)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
}
GetComponent<MeshFilter>().mesh = mesh;
}
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
...@@ -53,4 +53,54 @@ public class Logarithmic : MonoBehaviour ...@@ -53,4 +53,54 @@ public class Logarithmic : MonoBehaviour
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void DrawLogarithmic3D()
{
mesh.Clear();
float step = 0.01f;
Vector3[] vectors = new Vector3[200 * maxX];
int k = 0;
float down = Mathf.Log(a);
for (float i = step; i <= maxX; i = i + step)
{
float y = Mathf.Log(i) / down;
y *= factor;
vectors[k] = new Vector3(i, y, -5);
k++;
vectors[k] = new Vector3(i, y, 5);
k++;
}
vectors[200 * maxX - 2] = new Vector3(maxX, Mathf.Log(maxX) / down * factor, -5);
vectors[200 * maxX - 1] = new Vector3(maxX, Mathf.Log(maxX) / down * factor, 5);
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
int[] triangle = new int[100 * maxX * 6 - 6];
for (int i = 0; i < 100 * maxX - 1; ++i)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh;
}
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
using System.Collections; using Microsoft.MixedReality.Toolkit.UI;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
...@@ -9,6 +10,9 @@ public class Spline : MonoBehaviour ...@@ -9,6 +10,9 @@ public class Spline : MonoBehaviour
public int minX; public int minX;
public int maxX; public int maxX;
bool is2D = false;
bool is3D = false;
public List<float> factors; public List<float> factors;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -17,10 +21,6 @@ public class Spline : MonoBehaviour ...@@ -17,10 +21,6 @@ public class Spline : MonoBehaviour
{ {
name = "Spline" name = "Spline"
}; };
factors = new List<float>();
factors.Add(1);
factors.Add(0);
factors.Add(1);
} }
// Update is called once per frame // Update is called once per frame
...@@ -48,6 +48,16 @@ public class Spline : MonoBehaviour ...@@ -48,6 +48,16 @@ public class Spline : MonoBehaviour
vectors[k] = new Vector3(i, y, 0); vectors[k] = new Vector3(i, y, 0);
k++; k++;
} }
float ym = 0;
for (int j = factors.Count - 1; j > 0; --j)
{
ym += factors[j];
ym *= maxX;
}
ym += factors[0];
vectors[100 * (maxX - minX)] = new Vector3(maxX, ym, 0);
mesh.vertices = vectors; mesh.vertices = vectors;
int[] triangle = new int[100 * (maxX - minX) * 2]; int[] triangle = new int[100 * (maxX - minX) * 2];
...@@ -60,6 +70,96 @@ public class Spline : MonoBehaviour ...@@ -60,6 +70,96 @@ public class Spline : MonoBehaviour
mesh.SetIndices(triangle, MeshTopology.Lines, 0); mesh.SetIndices(triangle, MeshTopology.Lines, 0);
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
is2D = true;
}
public void DrawSpline3D()
{
mesh.Clear();
Vector3[] vectors = new Vector3[200 * (maxX - minX) + 2];
int k = 0;
float step = 0.01f;
for (float i = minX; i <= maxX; i += step)
{
float y = 0;
for (int j = factors.Count - 1; j > 0; --j)
{
y += factors[j];
y *= i;
}
y += factors[0];
vectors[k] = new Vector3(i, y, -5);
k++;
vectors[k] = new Vector3(i, y, 5);
k++;
}
float ym = 0;
for (int j = factors.Count - 1; j > 0; --j)
{
ym += factors[j];
ym *= maxX;
}
ym += factors[0];
vectors[200 * (maxX - minX)] = new Vector3(maxX, ym, -5);
vectors[200 * (maxX - minX) + 1] = new Vector3(maxX, ym, 5);
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
int[] triangle = new int[100 * (maxX - minX) * 6];
for (int i = 0; i < 100 * (maxX - minX); ++i)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh;
is3D = true;
} }
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
is2D = false;
is3D = false;
}
public void OnSliderUpdated(SliderEventData eventData)
{
factors[1] = Mathf.Tan((eventData.NewValue - 0.5f) * Mathf.PI);
if (is2D)
DrawSpline();
if (is3D)
DrawSpline3D();
}
public void OnSliderUpdated2(SliderEventData eventData)
{
int n = (int)((eventData.NewValue ) * 5);
factors = new List<float>();
for(int i = 0; i < n; ++i)
{
factors.Add(0);
}
factors.Add(1);
if (is2D)
DrawSpline();
if (is3D)
DrawSpline3D();
}
} }
...@@ -22,11 +22,10 @@ public class ThreeD : MonoBehaviour ...@@ -22,11 +22,10 @@ public class ThreeD : MonoBehaviour
name = "ThreeD" name = "ThreeD"
}; };
calculator3D = new Calculator3D(); calculator3D = new Calculator3D();
DrawCustomized();
} }
// Update is called once per frame // Update is called once per frame
public void DrawCustomized() public void DrawThreeD()
{ {
mesh.Clear(); mesh.Clear();
...@@ -70,8 +69,22 @@ public class ThreeD : MonoBehaviour ...@@ -70,8 +69,22 @@ public class ThreeD : MonoBehaviour
} }
mesh.vertices = vectors; mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
mesh.SetIndices(triangle, MeshTopology.Triangles, 0); mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
...@@ -96,4 +96,91 @@ public class Trigonometric : MonoBehaviour ...@@ -96,4 +96,91 @@ public class Trigonometric : MonoBehaviour
GetComponent<MeshFilter>().mesh = mesh; GetComponent<MeshFilter>().mesh = mesh;
} }
public void DrawTrigonometric3D()
{
mesh.Clear();
float step = 0.01f;
Vector3[] vectors = new Vector3[200 * (maxX - minX) + 2];
int k = 0;
for (float i = minX; i <= maxX; i = i + step)
{
float y = a * i + b;
switch (triType)
{
case TriType.Sin:
y = Mathf.Sin(y);
break;
case TriType.Cos:
y = Mathf.Cos(y);
break;
case TriType.Tan:
y = Mathf.Tan(y);
break;
default:
break;
}
y *= factor;
vectors[k] = new Vector3(i, y, -5);
k++;
vectors[k] = new Vector3(i, y, 5);
k++;
}
switch (triType)
{
case TriType.Sin:
vectors[200 * (maxX - minX)] = new Vector3(maxX, Mathf.Sin(a * maxX + b) * factor, -5);
vectors[200 * (maxX - minX) + 1] = new Vector3(maxX, Mathf.Sin(a * maxX + b) * factor, 5);
break;
case TriType.Cos:
vectors[200 * (maxX - minX)] = new Vector3(maxX, Mathf.Cos(a * maxX + b) * factor, -5);
vectors[200 * (maxX - minX) + 1] = new Vector3(maxX, Mathf.Cos(a * maxX + b) * factor, 5);
break;
case TriType.Tan:
vectors[200 * (maxX - minX)] = new Vector3(maxX, Mathf.Tan(a * maxX + b) * factor, -5);
vectors[200 * (maxX - minX) + 1] = new Vector3(maxX, Mathf.Tan(a * maxX + b) * factor, 5);
break;
default:
break;
}
mesh.vertices = vectors;
Vector2[] uvs = new Vector2[vectors.Length];
for (int i = 0; i < uvs.Length; i++)
{
uvs[i] = new Vector2(0, vectors[i].y / 100);
}
mesh.uv = uvs;
int[] triangle = new int[100 * (maxX - minX) * 6];
for (int i = 0; i < 100 * (maxX - minX); ++i)
{
if(vectors[2 * i].y * vectors[2 * i + 2].y >= 0)
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i + 2;
triangle[6 * i + 3] = 2 * i + 1;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
else
{
triangle[6 * i] = 2 * i;
triangle[6 * i + 1] = 2 * i + 1;
triangle[6 * i + 2] = 2 * i;
triangle[6 * i + 3] = 2 * i + 3;
triangle[6 * i + 4] = 2 * i + 3;
triangle[6 * i + 5] = 2 * i + 2;
}
}
mesh.SetIndices(triangle, MeshTopology.Triangles, 0);
GetComponent<MeshFilter>().mesh = mesh;
}
public void MeshClear()
{
mesh.Clear();
GetComponent<MeshFilter>().mesh = mesh;
}
} }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIManager : MonoBehaviour
{
public Spline li;
public Spline sp;
public Ellipse el;
public Exponential ex;
public Hyperbola hy;
public InverseTri it;
public Logarithmic log;
public ThreeD td;
public Trigonometric tr;
public Customized cus;
public GameObject liUI;
public GameObject spUI;
public GameObject elUI;
public GameObject exUI;
public GameObject hyUI;
public GameObject itUI;
public GameObject logUI;
public GameObject tdUI;
public GameObject trUI;
public GameObject cusUI;
// Start is called before the first frame update
void Start()
{
CloseAllUI();
}
// Update is called once per frame
void Update()
{
}
public void OpenLiUI()
{
CloseAllUI();
liUI.SetActive(true);
}
public void DrawLine2D()
{
AllClear();
li.DrawSpline();
}
public void DrawLine3D()
{
AllClear();
li.DrawSpline3D();
}
public void OpenSpUI()
{
CloseAllUI();
spUI.SetActive(true);
}
public void DrawSpline2D()
{
AllClear();
sp.DrawSpline();
}
public void DrawSpline3D()
{
AllClear();
sp.DrawSpline3D();
}
public void OpenElUI()
{
CloseAllUI();
elUI.SetActive(true);
}
public void DrawEllipse2D()
{
AllClear();
el.DrawEllipse();
}
public void DrawEllipse3D()
{
AllClear();
el.DrawEllipse3D();
}
public void OpenExUI()
{
CloseAllUI();
exUI.SetActive(true);
}
public void DrawExponential()
{
AllClear();
ex.DrawExponential();
}
public void DrawExponential3D()
{
AllClear();
ex.DrawExponential3D();
}
public void OpenHyUI()
{
CloseAllUI();
hyUI.SetActive(true);
}
public void DrawHyperbola2D()
{
AllClear();
hy.DrawHyperbola();
}
public void DrawHyperbola3D()
{
AllClear();
hy.DrawHyperbola3D();
}
public void OpenItUI()
{
CloseAllUI();
itUI.SetActive(true);
}
public void DrawInverseTri2D()
{
AllClear();
it.DrawInverseTri();
}
public void DrawInverseTri3D()
{
AllClear();
it.DrawInverseTri3D();
}
public void OpenLogUI()
{
CloseAllUI();
logUI.SetActive(true);
}
public void DrawLogarithmic2D()
{
AllClear();
log.DrawLogarithmic();
}
public void DrawLogarithmic3D()
{
AllClear();
log.DrawLogarithmic3D();
}
public void OpenTrUI()
{
CloseAllUI();
trUI.SetActive(true);
}
public void DrawTrigonometric2D()
{
AllClear();
tr.DrawTrigonometric();
}
public void DrawTrigonometric3D()
{
AllClear();
tr.DrawTrigonometric3D();
}
public void OpenCusUI()
{
CloseAllUI();
cusUI.SetActive(true);
}
public void DrawCustomized2D()
{
AllClear();
cus.DrawCustomized();
}
public void DrawCustomized3D()
{
AllClear();
cus.DrawCustomized3D();
}
public void OpenTdUI()
{
CloseAllUI();
tdUI.SetActive(true);
}
public void DrawThreeD()
{
AllClear();
td.DrawThreeD();
}
public void AllClear()
{
li.MeshClear();
sp.MeshClear();
el.MeshClear();
ex.MeshClear();
hy.MeshClear();
it.MeshClear();
log.MeshClear();
td.MeshClear();
tr.MeshClear();
cus.MeshClear();
}
public void CloseAllUI()
{
liUI.SetActive(false);
spUI.SetActive(false);
elUI.SetActive(false);
exUI.SetActive(false);
hyUI.SetActive(false);
itUI.SetActive(false);
logUI.SetActive(false);
tdUI.SetActive(false);
trUI.SetActive(false);
cusUI.SetActive(false);
}
}
Shader "Unlit/Colorful"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 100
Pass
{
Cull off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Unlit/TestShader"
{
Properties
{
_Color1("Color1", Color) = (1.0, 1.0, 1.0, 1.0)
_Color2("Color2", Color) = (0.0, 0.0, 0.0, 1.0)
_Color3("Color3", Color) = (0.0, 0.0, 0.0, 1.0)
[PowerSlider(1)] _Top("Top", Range(0.0, 1.0)) = 0.75
[PowerSlider(1)] _Bottom("Bottom", Range(0.0, 1.0)) = 0.25
}
SubShader
{
Pass
{
Cull off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
fixed4 _Color1;
fixed4 _Color2;
fixed4 _Color3;
float _Weights;
float _Top;
float _Bottom;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
//注意,uv的0最大值是(1, 1)
fixed4 frag(v2f i) : SV_Target
{
fixed4 col;
float lp = 0.0;
if (i.uv.y >= _Top)
{
lp = (1 - i.uv.y) / (1 - _Top);
col = lerp(_Color1, _Color2, lp);
}
else if (i.uv.y <= _Bottom)
{
lp = i.uv.y / _Bottom;
col = lerp(_Color3, _Color2, lp);
}
else
{
col = _Color2;
}
return col;
}
ENDCG
}
}
}
...@@ -6,8 +6,8 @@ EditorBuildSettings: ...@@ -6,8 +6,8 @@ EditorBuildSettings:
serializedVersion: 2 serializedVersion: 2
m_Scenes: m_Scenes:
- enabled: 1 - enabled: 1
path: Assets/MRTK/Examples/Demos/HandTracking/Scenes/HandInteractionExamples.unity path: Assets/Scenes/Test.unity
guid: 3dd4a396b5225f8469b9a1eb608bfa57 guid: 62e0698f46e1e684f8c39632a42194ce
m_configObjects: m_configObjects:
Unity.XR.WindowsMR.Settings: {fileID: 11400000, guid: 1748663c0ac4b0f46a888e6376b37089, Unity.XR.WindowsMR.Settings: {fileID: 11400000, guid: 1748663c0ac4b0f46a888e6376b37089,
type: 2} type: 2}
......
...@@ -41,7 +41,8 @@ GraphicsSettings: ...@@ -41,7 +41,8 @@ GraphicsSettings:
m_PreloadedShaders: [] m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0} type: 0}
m_CustomRenderPipeline: {fileID: 0} m_CustomRenderPipeline: {fileID: 11400000, guid: d2f08773202f0f94bbfffcdad2a7697a,
type: 2}
m_TransparencySortMode: 0 m_TransparencySortMode: 0
m_TransparencySortAxis: {x: 0, y: 0, z: 1} m_TransparencySortAxis: {x: 0, y: 0, z: 1}
m_DefaultRenderingPath: 1 m_DefaultRenderingPath: 1
......
...@@ -1253,3 +1253,195 @@ InputManager: ...@@ -1253,3 +1253,195 @@ InputManager:
type: 2 type: 2
axis: 2 axis: 2
joyNum: 0 joyNum: 0
- serializedVersion: 3
m_Name: Enable Debug Button 1
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left ctrl
altNegativeButton:
altPositiveButton: joystick button 8
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Enable Debug Button 2
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: backspace
altNegativeButton:
altPositiveButton: joystick button 9
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Reset
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left alt
altNegativeButton:
altPositiveButton: joystick button 1
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Next
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: page down
altNegativeButton:
altPositiveButton: joystick button 5
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Previous
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: page up
altNegativeButton:
altPositiveButton: joystick button 4
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Validate
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: return
altNegativeButton:
altPositiveButton: joystick button 0
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Persistent
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: right shift
altNegativeButton:
altPositiveButton: joystick button 2
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Multiplier
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: left shift
altNegativeButton:
altPositiveButton: joystick button 3
gravity: 0
dead: 0
sensitivity: 0
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 0
axis: 0
joyNum: 0
- serializedVersion: 3
m_Name: Debug Vertical
descriptiveName:
descriptiveNegativeName:
negativeButton: down
positiveButton: up
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 2
axis: 6
joyNum: 0
- serializedVersion: 3
m_Name: Debug Horizontal
descriptiveName:
descriptiveNegativeName:
negativeButton: left
positiveButton: right
altNegativeButton:
altPositiveButton:
gravity: 1000
dead: 0.001
sensitivity: 1000
snap: 0
invert: 0
type: 2
axis: 5
joyNum: 0
...@@ -579,7 +579,16 @@ PlayerSettings: ...@@ -579,7 +579,16 @@ PlayerSettings:
webGLLinkerTarget: 1 webGLLinkerTarget: 1
webGLThreadsSupport: 0 webGLThreadsSupport: 0
webGLWasmStreaming: 0 webGLWasmStreaming: 0
scriptingDefineSymbols: {} scriptingDefineSymbols:
1: UNITY_POST_PROCESSING_STACK_V2
7: UNITY_POST_PROCESSING_STACK_V2
13: UNITY_POST_PROCESSING_STACK_V2
19: UNITY_POST_PROCESSING_STACK_V2
21: UNITY_POST_PROCESSING_STACK_V2
25: UNITY_POST_PROCESSING_STACK_V2
27: UNITY_POST_PROCESSING_STACK_V2
28: UNITY_POST_PROCESSING_STACK_V2
29: UNITY_POST_PROCESSING_STACK_V2
platformArchitecture: {} platformArchitecture: {}
scriptingBackend: {} scriptingBackend: {}
il2cppCompilerConfiguration: {} il2cppCompilerConfiguration: {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment