Commit 1bdb6cb7 authored by BlackAngle233's avatar BlackAngle233
Browse files

2021_6_1_14_45

parent 07399915
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
This diff is collapsed.
This diff is collapsed.
fileFormatVersion: 2
guid: 39bc7e7b244b82542b17c6ebeadb8ecd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 6658da0b86525fc4499692f44c3370fa
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 13021387cf451a640bc3ed5891b6af8d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 5b86e571ea2b50447866c8f9d0733c5b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class CanvasManager3D : MonoBehaviour
{
Dictionary<string, Point> points;
Dictionary<string, Line> lines;
Dictionary<string, Plane> planes;
List<Vector> vectors;
List<Angle> angles;
List<Constraint> constraints;
public bool isFin = false;
public CanvasManager3D()
{
points = new Dictionary<string, Point>();
lines = new Dictionary<string, Line>();
planes = new Dictionary<string, Plane>();
vectors = new List<Vector>();
angles = new List<Angle>();
constraints = new List<Constraint>();
}
public void calculateDig()
{
float startTime = Time.realtimeSinceStartup;
Point first = null;
if(points.Count != 0)
{
first = points.First().Value;
}
else
{
return ;
}
first.setPoint(1000, 0, 0);
first.setState(State.confirm);
HashSet<Point> usedPoint = new HashSet<Point>();
Queue<Point> restPoint = new Queue<Point>();
restPoint.Enqueue(first);
bool flag = true;
while(restPoint.Count != 0 && flag)
{
Point tmp = restPoint.Peek();
foreach(Line l in tmp.lines)
{
Point p = l.getAnotherPoint(tmp);
if(!restPoint.Contains(p) && !usedPoint.Contains(p))
restPoint.Enqueue(p);
}
if (tmp.getState() == State.confirm)
{
restPoint.Dequeue();
usedPoint.Add(tmp);
}
else
{
int check = tmp.checkConstraint();
if (check == 0)
{
tmp.setState(State.confirm);
restPoint.Dequeue();
usedPoint.Add(tmp);
}
else if (check == 1)
{
//calculate constaint
List<Constraint> calculates = new List<Constraint>();
foreach (Constraint c in tmp.constraints)
{
if (c.getState() == State.halfconfirm)
{
calculates.Add(c);
}
}
if (calculates.Count == 1)
{
calculates[0].calculateConstraint(tmp);
}
else
{
int count = 0;
bool isFinish = false;
while (count < 10000)
{
foreach (Constraint c in calculates)
{
c.tryCalculateConstraint(tmp);
}
if (checkConstraints(calculates))
{
isFinish = true;
foreach (Constraint c in calculates)
{
c.setState(State.confirm);
}
break;
}
count++;
}
if (!isFinish)
{
foreach (Constraint c in calculates)
{
c.setState(State.halfconfirm);
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class CanvasManager3D : MonoBehaviour
{
Dictionary<string, Point> points;
Dictionary<string, Line> lines;
Dictionary<string, Plane> planes;
List<Vector> vectors;
List<Angle> angles;
List<Constraint> constraints;
public bool isFin = false;
public CanvasManager3D()
{
points = new Dictionary<string, Point>();
lines = new Dictionary<string, Line>();
planes = new Dictionary<string, Plane>();
vectors = new List<Vector>();
angles = new List<Angle>();
constraints = new List<Constraint>();
}
public void calculateDig()
{
float startTime = Time.realtimeSinceStartup;
Point first = null;
if(points.Count != 0)
{
first = points.First().Value;
}
else
{
return ;
}
first.setPoint(1000, 0, 0);
first.setState(State.confirm);
HashSet<Point> usedPoint = new HashSet<Point>();
Queue<Point> restPoint = new Queue<Point>();
restPoint.Enqueue(first);
bool flag = true;
while(restPoint.Count != 0 && flag)
{
Point tmp = restPoint.Peek();
foreach(Line l in tmp.lines)
{
Point p = l.getAnotherPoint(tmp);
if(!restPoint.Contains(p) && !usedPoint.Contains(p))
restPoint.Enqueue(p);
}
if (tmp.getState() == State.confirm)
{
restPoint.Dequeue();
usedPoint.Add(tmp);
}
else
{
int check = tmp.checkConstraint();
if (check == 0)
{
tmp.setState(State.confirm);
restPoint.Dequeue();
usedPoint.Add(tmp);
}
else if (check == 1)
{
//calculate constaint
List<Constraint> calculates = new List<Constraint>();
foreach (Constraint c in tmp.constraints)
{
if (c.getState() == State.halfconfirm)
{
calculates.Add(c);
}
}
if (calculates.Count == 1)
{
calculates[0].calculateConstraint(tmp);
}
else
{
int count = 0;
bool isFinish = false;
while (count < 10000)
{
foreach (Constraint c in calculates)
{
c.tryCalculateConstraint(tmp);
}
if (checkConstraints(calculates))
{
isFinish = true;
foreach (Constraint c in calculates)
{
c.setState(State.confirm);
}
break;
}
count++;
}
if (!isFinish)
{
foreach (Constraint c in calculates)
{
c.setState(State.halfconfirm);
}
restPoint.Dequeue();
restPoint.Enqueue(tmp);
}
restPoint.Enqueue(tmp);
}
else
{
tmp.setState(State.confirm);
restPoint.Dequeue();
usedPoint.Add(tmp);
}
}
}
else if (check == 2)
{
//random
restPoint.Dequeue();
restPoint.Enqueue(tmp);
}
else
{
restPoint.Dequeue();
restPoint.Enqueue(tmp);
}
}
if(restPoint.Count == 0 && usedPoint.Count != points.Count)
{
foreach(var p in points)
{
if (!usedPoint.Contains(p.Value))
{
restPoint.Enqueue(p.Value);
break;
}
}
}
}
foreach(Point p in usedPoint)
{
p.x -= 1000;
}
PrintPoints();
isFin = true;
float endTime = Time.realtimeSinceStartup;
Debug.Log(endTime - startTime);
}
public string createPoint(string name = "")
{
if (name.Equals(""))
{
char n = 'A';
while (points.ContainsKey(n.ToString()))
{
n++;
}
name = n.ToString();
}
if (!points.ContainsKey(name))
{
Point p = new Point(0, 0, 0, name);
points.Add(name, p);
}
return name;
}
public void setPoint(string name, float x, float y, float z)
{
if (points.ContainsKey(name))
{
Point p = points[name];
p.setPoint(x, y, z);
p.update();
}
}
public Point GetPoint(string name)
{
if (points.ContainsKey(name))
{
Point p = points[name];
return p;
}
else
return null;
}
public Vector3[] GetPoints()
{
Vector3[] tmp = new Vector3[points.Count];
int i = 0;
foreach (var p in points)
{
tmp[i] = new Vector3(p.Value.x, p.Value.y, p.Value.z);
i++;
}
return tmp;
}
public string createLine(string n1, string n2, float length = 0)
{
Point p1 = null, p2 = null;
points.TryGetValue(n1, out p1);
points.TryGetValue(n2, out p2);
if (p1 != null && p2 != null)
{
Line line = new Line(p1, p2);
if(length != 0)
{
createConstraint(line, length, ConstraintType.LineLength);
}
string lineName = p1.name + p2.name;
lines[lineName] = line;
p1.addLine(line);
p2.addLine(line);
return lineName;
}
return "";
}
}
}
}
else if (check == 2)
{
//random
restPoint.Dequeue();
restPoint.Enqueue(tmp);
}
else
{
restPoint.Dequeue();
restPoint.Enqueue(tmp);
}
}
if(restPoint.Count == 0 && usedPoint.Count != points.Count)
{
foreach(var p in points)
{
if (!usedPoint.Contains(p.Value))
{
restPoint.Enqueue(p.Value);
break;
}
}
}
}
foreach(Point p in usedPoint)
{
p.x -= 1000;
}
PrintPoints();
isFin = true;
float endTime = Time.realtimeSinceStartup;
Debug.Log(endTime - startTime);
}
public string createPoint(string name = "")
{
if (name.Equals(""))
{
char n = 'A';
while (points.ContainsKey(n.ToString()))
{
n++;
}
name = n.ToString();
}
if (!points.ContainsKey(name))
{
Point p = new Point(0, 0, 0, name);
points.Add(name, p);
}
return name;
}
public void setPoint(string name, float x, float y, float z)
{
if (points.ContainsKey(name))
{
Point p = points[name];
p.setPoint(x, y, z);
p.update();
}
}
public Point GetPoint(string name)
{
if (points.ContainsKey(name))
{
Point p = points[name];
return p;
}
else
return null;
}
public Vector3[] GetPoints()
{
Vector3[] tmp = new Vector3[points.Count];
int i = 0;
foreach (var p in points)
{
tmp[i] = new Vector3(p.Value.x, p.Value.y, p.Value.z);
i++;
}
return tmp;
}
public string createLine(string n1, string n2, float length = 0)
{
Point p1 = null, p2 = null;
points.TryGetValue(n1, out p1);
points.TryGetValue(n2, out p2);
if (p1 != null && p2 != null)
{
Line line = new Line(p1, p2);
if(length != 0)
{
createConstraint(line, length, ConstraintType.LineLength);
}
string lineName = p1.name + p2.name;
lines[lineName] = line;
p1.addLine(line);
p2.addLine(line);
return lineName;
}
return "";
}
public string createPlane(string n1, string n2)
{
List<Point> ps = new List<Point>();
......@@ -255,7 +255,7 @@ public class CanvasManager3D : MonoBehaviour
ps.Add(line.point2);
}
else
return "";
return "";
lines.TryGetValue(n2, out line);
if (line != null)
......@@ -266,42 +266,42 @@ public class CanvasManager3D : MonoBehaviour
ps.Add(line.point2); ;
}
else
return "";
Plane plane = new Plane(ps);
string planeName = "";
return "";
Plane plane = new Plane(ps);
string planeName = "";
foreach (Point p in ps)
{
planeName += p.name;
}
planes.Add(planeName, plane);
return planeName;
}
public void setLine(string n, float length)
{
Line l1 = null;
lines.TryGetValue(n, out l1);
if(l1 != null)
{
createConstraint(l1, length, ConstraintType.LineLength);
}
}
public Line GetLine(string n)
{
Line l1 = null;
lines.TryGetValue(n, out l1);
return l1;
}
}
planes.Add(planeName, plane);
return planeName;
}
public void setLine(string n, float length)
{
Line l1 = null;
lines.TryGetValue(n, out l1);
if(l1 != null)
{
createConstraint(l1, length, ConstraintType.LineLength);
}
}
public Line GetLine(string n)
{
Line l1 = null;
lines.TryGetValue(n, out l1);
return l1;
}
public Plane GetPlane(string n)
{
Plane p = null;
......@@ -309,85 +309,85 @@ public class CanvasManager3D : MonoBehaviour
planes.TryGetValue(n, out p);
return p;
}
public List<Line> GetLines()
{
List<Line> tmp = new List<Line>();
foreach (var l in lines)
{
tmp.Add(l.Value);
}
return tmp;
}
public string createConstraint(object obj1, object obj2, ConstraintType type)
{
Constraint constraint = new Constraint(type, obj1, obj2);
constraints.Add(constraint);
return constraint.name;
}
void PrintPoints()
{
foreach(var p in points)
{
Point tmp = p.Value;
Debug.Log(tmp.name + ":(" + tmp.x.ToString() + ", " + tmp.y.ToString() + ", " + tmp.z.ToString() + ")");
}
foreach(var l in lines)
{
Line tmp = l.Value;
Debug.Log(l.Key + ":" + tmp.getLength());
}
}
bool checkConstraints(List<Constraint> constraint)
{
bool flag = true;
foreach(Constraint c in constraint)
{
if(Mathf.Abs(c.getConstraintValue()) > 0.001f)
{
flag = false;
break;
}
}
return flag;
}
public void test1(){
points.Clear();
lines.Clear();
Point a = new Point(0, 1, 0);
Point b = new Point(0, 0, 0);
Point c = new Point(1, 0, 0);
//Point d = new Point(1, 1, 0);
//Point e = new Point(0.5f, 1, 0.5f);
//Point f = new Point(0.5f, 0, 0);
//Point g = new Point(0.25f, 1, 0.25f);
points.Add("A", a);
points.Add("B", b);
points.Add("C", c);
//points.Add("D", d);
//points.Add("E", e);
//points.Add("F", f);
//points.Add("G", g);
lines.Add("AB", new Line(a, b));
lines.Add("BC", new Line(b, c));
//lines.Add("CD", new Line(c, d));
//lines.Add("AD", new Line(a, d));
//lines.Add("AE", new Line(a, e));
//lines.Add("DE", new Line(d, e));
//lines.Add("CE", new Line(c, e));
//lines.Add("FG", new Line(f, g));
isFin = true;
}
}
}
public List<Line> GetLines()
{
List<Line> tmp = new List<Line>();
foreach (var l in lines)
{
tmp.Add(l.Value);
}
return tmp;
}
public string createConstraint(object obj1, object obj2, ConstraintType type)
{
Constraint constraint = new Constraint(type, obj1, obj2);
constraints.Add(constraint);
return constraint.name;
}
void PrintPoints()
{
foreach(var p in points)
{
Point tmp = p.Value;
Debug.Log(tmp.name + ":(" + tmp.x.ToString() + ", " + tmp.y.ToString() + ", " + tmp.z.ToString() + ")");
}
foreach(var l in lines)
{
Line tmp = l.Value;
Debug.Log(l.Key + ":" + tmp.getLength());
}
}
bool checkConstraints(List<Constraint> constraint)
{
bool flag = true;
foreach(Constraint c in constraint)
{
if(Mathf.Abs(c.getConstraintValue()) > 0.001f)
{
flag = false;
break;
}
}
return flag;
}
public void test1(){
points.Clear();
lines.Clear();
Point a = new Point(0, 1, 0);
Point b = new Point(0, 0, 0);
Point c = new Point(1, 0, 0);
Point d = new Point(1, 1, 0);
Point e = new Point(0.5f, 1, 0.5f);
Point f = new Point(0.5f, 0, 0);
Point g = new Point(0.25f, 1, 0.25f);
points.Add("A", a);
points.Add("B", b);
points.Add("C", c);
points.Add("D", d);
points.Add("E", e);
points.Add("F", f);
points.Add("G", g);
lines.Add("AB", new Line(a, b));
lines.Add("BC", new Line(b, c));
lines.Add("CD", new Line(c, d));
lines.Add("AD", new Line(a, d));
lines.Add("AE", new Line(a, e));
lines.Add("DE", new Line(d, e));
lines.Add("CE", new Line(c, e));
lines.Add("FG", new Line(f, g));
isFin = true;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Controller : MonoBehaviour
{
private Touch _OldTouch1;
private Touch _OldTouch2;
Vector2 _M_Screenpos = new Vector2();
bool _bMoveOrRotation;
Vector3 _OldPosition;
void Start()
{
_OldPosition = Camera.main.transform.position;
}
void Update()
{
if (Input.touchCount <= 0)
{
return;
}
if (1 == Input.touchCount)
{
if (_bMoveOrRotation)
{
Touch _Touch = Input.GetTouch(0);
Vector2 _DeltaPos = _Touch.deltaPosition;
transform.Rotate(Vector3.down * _DeltaPos.x, Space.World);
transform.Rotate(Vector3.right * _DeltaPos.y, Space.World);
}
else
{
if (Input.touches[0].phase == TouchPhase.Began)
{
_M_Screenpos = Input.touches[0].position;
}
else if (Input.touches[0].phase == TouchPhase.Moved)
{
Camera.main.transform.Translate(new Vector3(-Input.touches[0].deltaPosition.x * Time.deltaTime * 0.1f, -Input.touches[0].deltaPosition.y * Time.deltaTime * 0.1f, 0));
}
}
}
Touch _NewTouch1 = Input.GetTouch(0);
Touch _NewTouch2 = Input.GetTouch(1);
if (_NewTouch2.phase == TouchPhase.Began)
{
_OldTouch2 = _NewTouch2;
_OldTouch1 = _NewTouch1;
return;
}
float _OldDistance = Vector2.Distance(_OldTouch1.position, _OldTouch2.position);
float _NewDistance = Vector2.Distance(_NewTouch1.position, _NewTouch2.position);
float _Offset = _NewDistance - _OldDistance;
float _ScaleFactor = _Offset / 100f;
Vector3 _LocalScale = transform.localScale;
Vector3 _Scale = new Vector3(_LocalScale.x + _ScaleFactor,
_LocalScale.y + _ScaleFactor,
_LocalScale.z + _ScaleFactor);
if (_Scale.x > 0.3f && _Scale.y > 0.3f && _Scale.z > 0.3f)
{
transform.localScale = _Scale;
}
_OldTouch1 = _NewTouch1;
_OldTouch2 = _NewTouch2;
}
public void BackPosition()
{
Camera.main.transform.position = _OldPosition;
Camera.main.transform.eulerAngles = Vector3.zero;
}
public void RotationOrMove()
{
_bMoveOrRotation = !_bMoveOrRotation;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 19d4823d2f70fba4bb0b9121dc196d89
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using ZXing;//引入库  
using ZXing.QrCode; 
public class QRcode : MonoBehaviour
{
    public Texture2D encoded;
    public string Lastresult;
    void Start()  
    {
        encoded = new Texture2D(256, 256);  
        Lastresult = "http://www.qq.com";  
    }
  
    private static Color32[] Encode(string textForEncoding, int width, int height)  
    {  
        var writer = new BarcodeWriter  
        {  
            Format = BarcodeFormat.QR_CODE,  
            Options = new QrCodeEncodingOptions  
            {  
                Height = height,  
                Width = width  
            }  
        };  
        return writer.Write(textForEncoding);  
    }  
  
  
    public void Save()  
    {  
        var textForEncoding = Lastresult;  
        if (textForEncoding != null)  
        {   
            var color32 = Encode(textForEncoding, encoded.width, encoded.height);  
            encoded.SetPixels32(color32);  
            encoded.Apply();
byte[] bytes = encoded.EncodeToPNG();
string path = Application.persistentDataPath;
Debug.Log(path);
#if UNITY_ANDROID
path = "/storage/emulated/0/DCIM/MathTec";
#endif
if (Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string savePath = string.Format("{0}/{1}.png", path, "pic");
File.WriteAllBytes(savePath, bytes);
        }  
    }  
  
}
\ No newline at end of file
fileFormatVersion: 2
guid: 341a32be5dc6c0e4f99bd2d98ea5a5c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIManager : MonoBehaviour
{
List<GameObject> points;
List<GameObject> lines;
List<GameObject> planes;
List<GameObject> constraints;
public GameObject constraintDropdown;
public GameObject constraintInput;
public Transform pointsParent;
public Transform linesParent;
public Transform planesParent;
public Transform constraintParent;
public GameObject button;
public GameObject line;
public GameObject constraint;
string chosen1 = "";
string chosen2 = "";
public CanvasManager3D CM;
enum UIState
{
none,
createLine,
createPlane,
linelength,
lineEqual,
lineNormal,
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIManager : MonoBehaviour
{
List<GameObject> points;
List<GameObject> lines;
List<GameObject> planes;
List<GameObject> constraints;
public List<GameObject> UIControl;
public GameObject constraintDropdown;
public GameObject constraintInput;
public Transform pointsParent;
public Transform linesParent;
public Transform planesParent;
public Transform constraintParent;
public GameObject button;
public GameObject line;
public GameObject constraint;
string chosen1 = "";
string chosen2 = "";
public CanvasManager3D CM;
enum UIState
{
none,
createLine,
createPlane,
linelength,
lineEqual,
lineNormal,
lineParallel,
lineParallelPlane,
lineCross,
......@@ -44,49 +46,49 @@ public class UIManager : MonoBehaviour
angleEqual,
planeParallelPlane,
planeNormalPlane,
planeArea
}
UIState state = UIState.none;
// Start is called before the first frame update
void Start()
{
points = new List<GameObject>();
lines = new List<GameObject>();
planes = new List<GameObject>();
constraints = new List<GameObject>();
}
// Update is called once per frame
void Update()
{
switch (state)
{
case UIState.none:
break;
case UIState.createLine:
if(!chosen1.Equals("") && !chosen2.Equals(""))
{
createLine();
}
break;
case UIState.createPlane:
if (!chosen1.Equals("") && !chosen2.Equals(""))
{
createPlane();
}
break;
planeArea
}
UIState state = UIState.none;
// Start is called before the first frame update
void Start()
{
points = new List<GameObject>();
lines = new List<GameObject>();
planes = new List<GameObject>();
constraints = new List<GameObject>();
}
// Update is called once per frame
void Update()
{
switch (state)
{
case UIState.none:
break;
case UIState.createLine:
if(!chosen1.Equals("") && !chosen2.Equals(""))
{
createLine();
}
break;
case UIState.createPlane:
if (!chosen1.Equals("") && !chosen2.Equals(""))
{
createPlane();
}
break;
case UIState.linelength:
case UIState.angleEqual:
case UIState.planeArea:
if (!chosen1.Equals("") && !constraintInput.GetComponent<InputField>().text.Equals(""))
{
createConstraint();
}
break;
case UIState.planeArea:
if (!chosen1.Equals("") && !constraintInput.GetComponent<InputField>().text.Equals(""))
{
createConstraint();
}
break;
case UIState.lineEqual:
case UIState.lineNormal:
case UIState.lineNormal:
case UIState.lineParallel:
case UIState.lineParallelPlane:
case UIState.lineCross:
......@@ -94,191 +96,191 @@ public class UIManager : MonoBehaviour
case UIState.pointOnLine:
case UIState.pointInPlane:
case UIState.planeParallelPlane:
case UIState.planeNormalPlane:
if (!chosen1.Equals("") && !chosen2.Equals(""))
{
createConstraint();
}
break;
}
}
public void createPoint()
{
string n = CM.createPoint();
GameObject tmp = Instantiate(button);
tmp.transform.SetParent(pointsParent);
points.Add(tmp);
tmp.transform.localPosition = new Vector3(100 + 70 * (points.Count - 1), 0, 0);
tmp.GetComponentInChildren<Text>().text = n;
tmp.GetComponent<Button>().onClick.AddListener(delegate(){ chooseObject(n); });
}
public void createLineButton()
{
state = UIState.createLine;
}
void createLine()
{
string n = CM.createLine(chosen1, chosen2);
chosen1 = "";
chosen2 = "";
GameObject tmp = Instantiate(line);
tmp.transform.SetParent(linesParent);
lines.Add(tmp);
tmp.transform.localPosition = new Vector3(100 + 70 * (lines.Count - 1), 0, 0);
tmp.GetComponentInChildren<Text>().text = n;
tmp.GetComponent<Button>().onClick.AddListener(delegate () { chooseObject(n); });
state = UIState.none;
}
case UIState.planeNormalPlane:
if (!chosen1.Equals("") && !chosen2.Equals(""))
{
createConstraint();
}
break;
}
}
public void createPoint()
{
string n = CM.createPoint();
GameObject tmp = Instantiate(button);
tmp.transform.SetParent(pointsParent);
points.Add(tmp);
tmp.transform.localPosition = new Vector3(100 + 70 * (points.Count - 1), 0, 0);
tmp.GetComponentInChildren<Text>().text = n;
tmp.GetComponent<Button>().onClick.AddListener(delegate(){ chooseObject(n); });
}
public void createLineButton()
{
state = UIState.createLine;
}
void createLine()
{
string n = CM.createLine(chosen1, chosen2);
chosen1 = "";
chosen2 = "";
GameObject tmp = Instantiate(line);
tmp.transform.SetParent(linesParent);
lines.Add(tmp);
tmp.transform.localPosition = new Vector3(100 + 70 * (lines.Count - 1), 0, 0);
tmp.GetComponentInChildren<Text>().text = n;
tmp.GetComponent<Button>().onClick.AddListener(delegate () { chooseObject(n); });
state = UIState.none;
}
public void createPlaneButton()
{
state = UIState.createPlane;
}
}
void createPlane()
{
string n = CM.createPlane(chosen1, chosen2);
chosen1 = "";
chosen2 = "";
GameObject tmp = Instantiate(line);
tmp.transform.SetParent(planesParent);
planes.Add(tmp);
tmp.transform.localPosition = new Vector3(100 + 70 * (planes.Count - 1), 0, 0);
tmp.GetComponentInChildren<Text>().text = n;
tmp.GetComponent<Button>().onClick.AddListener(delegate () { chooseObject(n); });
string n = CM.createPlane(chosen1, chosen2);
chosen1 = "";
chosen2 = "";
GameObject tmp = Instantiate(line);
tmp.transform.SetParent(planesParent);
planes.Add(tmp);
tmp.transform.localPosition = new Vector3(100 + 70 * (planes.Count - 1), 0, 0);
tmp.GetComponentInChildren<Text>().text = n;
tmp.GetComponent<Button>().onClick.AddListener(delegate () { chooseObject(n); });
state = UIState.none;
}
public void chooseObject(string obj)
{
if(state != UIState.none)
{
if (chosen1.Equals(""))
chosen1 = obj;
if (!chosen1.Equals("") && !chosen1.Equals(obj) && chosen2.Equals(""))
chosen2 = obj;
Debug.Log(obj);
}
}
public void LineButton()
{
if(state == UIState.none)
{
}
}
public void createConstraintButton()
{
constraintDropdown.SetActive(true);
}
public void constraintDropdownChange()
{
string text = constraintDropdown.GetComponent<Dropdown>().captionText.text;
if (text.Equals("None")) return;
ConstraintType type = (ConstraintType)System.Enum.Parse(typeof(ConstraintType), text);
switch (type)
{
case ConstraintType.LineLength:
state = UIState.linelength;
constraintInput.SetActive(true);
break;
case ConstraintType.LineEqual:
state = UIState.lineEqual;
break;
case ConstraintType.LineNormal:
state = UIState.lineNormal;
break;
}
public void chooseObject(string obj)
{
if(state != UIState.none)
{
if (chosen1.Equals(""))
chosen1 = obj;
if (!chosen1.Equals("") && !chosen1.Equals(obj) && chosen2.Equals(""))
chosen2 = obj;
Debug.Log(obj);
}
}
public void LineButton()
{
if(state == UIState.none)
{
}
}
public void createConstraintButton()
{
constraintDropdown.SetActive(true);
}
public void constraintDropdownChange()
{
string text = constraintDropdown.GetComponent<Dropdown>().captionText.text;
if (text.Equals("None")) return;
ConstraintType type = (ConstraintType)System.Enum.Parse(typeof(ConstraintType), text);
switch (type)
{
case ConstraintType.LineLength:
state = UIState.linelength;
constraintInput.SetActive(true);
break;
case ConstraintType.LineEqual:
state = UIState.lineEqual;
break;
case ConstraintType.LineNormal:
state = UIState.lineNormal;
break;
case ConstraintType.LineParallel:
state = UIState.lineParallel;
state = UIState.lineParallel;
break;
case ConstraintType.LineParallelPlane:
state = UIState.lineParallelPlane;
state = UIState.lineParallelPlane;
break;
case ConstraintType.LineCross:
state = UIState.lineCross;
state = UIState.lineCross;
break;
case ConstraintType.MidPoint:
state = UIState.midPoint;
state = UIState.midPoint;
break;
case ConstraintType.PointOnLine:
state = UIState.pointOnLine;
state = UIState.pointOnLine;
break;
case ConstraintType.PointInPlane:
state = UIState.pointInPlane;
state = UIState.pointInPlane;
break;
case ConstraintType.AngleEqual:
state = UIState.angleEqual;
state = UIState.angleEqual;
break;
case ConstraintType.PlaneParallelPlane:
state = UIState.planeParallelPlane;
state = UIState.planeParallelPlane;
break;
case ConstraintType.PlaneNormalPlane:
state = UIState.planeNormalPlane;
state = UIState.planeNormalPlane;
break;
case ConstraintType.PlaneArea:
state = UIState.planeArea;
constraintInput.SetActive(true);
break;
}
}
void createConstraint()
{
Point p = null;
Line l1 = null;
Line l2 = null;
Plane p1 = null;
Plane p2 = null;
float length;
string n = "";
switch (state)
{
case UIState.linelength:
l1 = CM.GetLine(chosen1);
length = float.Parse(constraintInput.GetComponent<InputField>().text);
n = CM.createConstraint(l1, length, ConstraintType.LineLength);
constraintInput.SetActive(false);
break;
case UIState.lineEqual:
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
n = CM.createConstraint(l1, l2, ConstraintType.LineEqual);
break;
case ConstraintType.PlaneArea:
state = UIState.planeArea;
constraintInput.SetActive(true);
break;
}
}
void createConstraint()
{
Point p = null;
Line l1 = null;
Line l2 = null;
Plane p1 = null;
Plane p2 = null;
float length;
string n = "";
switch (state)
{
case UIState.linelength:
l1 = CM.GetLine(chosen1);
length = float.Parse(constraintInput.GetComponent<InputField>().text);
n = CM.createConstraint(l1, length, ConstraintType.LineLength);
constraintInput.SetActive(false);
break;
case UIState.lineEqual:
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
n = CM.createConstraint(l1, l2, ConstraintType.LineEqual);
break;
case UIState.lineNormal:
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
n = CM.createConstraint(l1, l2, ConstraintType.LineNormal);
case UIState.lineNormal:
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
n = CM.createConstraint(l1, l2, ConstraintType.LineNormal);
break;
case UIState.lineParallel:
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
n = CM.createConstraint(l1, l2, ConstraintType.LineParallel);
break;
case UIState.lineParallelPlane:
l1 = CM.GetLine(chosen1);
p1 = CM.GetPlane(chosen2);
l1 = CM.GetLine(chosen1);
p1 = CM.GetPlane(chosen2);
n = CM.createConstraint(l1, p1, ConstraintType.LineParallelPlane);
break;
case UIState.lineCross:
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
l1 = CM.GetLine(chosen1);
l2 = CM.GetLine(chosen2);
n = CM.createConstraint(l1, l2, ConstraintType.LineCross);
break;
case UIState.midPoint:
l1 = CM.GetLine(chosen1);
p = CM.GetPoint(chosen2);
l1 = CM.GetLine(chosen1);
p = CM.GetPoint(chosen2);
n = CM.createConstraint(l1, p, ConstraintType.MidPoint);
break;
case UIState.planeParallelPlane:
......@@ -286,7 +288,7 @@ public class UIManager : MonoBehaviour
p2 = CM.GetPlane(chosen2);
n = CM.createConstraint(p1, p2, ConstraintType.PlaneParallelPlane);
break;
case UIState.planeNormalPlane:
case UIState.planeNormalPlane:
p1 = CM.GetPlane(chosen1);
p2 = CM.GetPlane(chosen2);
n = CM.createConstraint(p1, p2, ConstraintType.PlaneNormalPlane);
......@@ -294,19 +296,30 @@ public class UIManager : MonoBehaviour
case UIState.angleEqual:
case UIState.planeArea:
case UIState.pointOnLine:
case UIState.pointInPlane:
break;
}
chosen1 = "";
chosen2 = "";
GameObject tmp = Instantiate(constraint);
tmp.transform.SetParent(constraintParent);
constraints.Add(tmp);
tmp.transform.localPosition = new Vector3(150 + 165 * (constraints.Count - 1), 0, 0);
tmp.GetComponentInChildren<Text>().text = n;
state = UIState.none;
constraintDropdown.GetComponent<Dropdown>().captionText.text = "None";
constraintDropdown.GetComponent<Dropdown>().value = 0;
constraintDropdown.SetActive(false);
}
}
case UIState.pointInPlane:
break;
}
chosen1 = "";
chosen2 = "";
GameObject tmp = Instantiate(constraint);
tmp.transform.SetParent(constraintParent);
constraints.Add(tmp);
if(constraints.Count < 11)
tmp.transform.localPosition = new Vector3(150 + 165 * (constraints.Count - 1), 0, 0);
else
tmp.transform.localPosition = new Vector3(150 + 165 * (constraints.Count - 11), -80, 0);
tmp.GetComponentInChildren<Text>().text = n;
state = UIState.none;
constraintDropdown.GetComponent<Dropdown>().captionText.text = "None";
constraintDropdown.GetComponent<Dropdown>().value = 0;
constraintDropdown.SetActive(false);
}
public void UIShow()
{
foreach(var ui in UIControl)
{
ui.SetActive(!ui.activeSelf);
}
}
}
fileFormatVersion: 2
guid: be3555aa3d1aa6a40879bdbd184ac036
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
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