forked from komietty/unity-vectorfield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrivialConnectionViewer.cs
61 lines (56 loc) · 1.91 KB
/
TrivialConnectionViewer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
namespace VectorField {
public class TrivialConnectionViewer : MonoBehaviour {
[SerializeField] protected List<float> singularities;
private List<List<HalfEdge>> genes;
private HomologyGenerator hg;
private HeGeom G;
void Start() {
var c = GetComponent<GeomContainer>();
G = c.geom;
hg = new HomologyGenerator(G);
genes = hg.BuildGenerators();
var b = new float[G.nVerts];
foreach (var s in singularities) {
var i = Random.Range(0, G.nVerts);
b[i] = s;
if (s != 0) c.PutSingularityPoint(i);
}
var t = new TrivialConnectionHD(G);
var p = t.ComputeConnections(b);
var f = t.GetFaceVectorFromConnection(p);
c.BuildFaceArrowBuffer(f);
c.surfMode = GeomContainer.SurfMode.blackBase;
c.showFaceArrow = true;
c.showVertArrow = false;
}
/*
// Homology generator viewer
[SerializeField] protected Material mat;
void OnRenderObject() {
if (genes == null) return;
GL.PushMatrix();
mat.SetPass(0);
GL.Begin(GL.LINES);
foreach (var g in genes) {
foreach (var h in g)
{
var c1 = G.Centroid(h.face);
var c2 = G.Centroid(h.twin.face);
var p1 = G.Pos[h.vid];
var p2 = G.Pos[h.twin.vid];
var m = (p1 + p2) * 0.5f;
GL.Vertex(c1);
GL.Vertex(m);
GL.Vertex(m);
GL.Vertex(c2);
}
}
GL.End();
GL.PopMatrix();
}
*/
}
}