Add Gaze scene
This commit is contained in:
parent
c110a6e723
commit
15b298f399
13
Cluster.cs
13
Cluster.cs
@ -169,7 +169,7 @@ public class Cluster : Nucleus {
|
||||
int ix = GetNucleusIndex(this.clusterNuclei.ToArray(), output);
|
||||
if (ix < 0)
|
||||
continue;
|
||||
|
||||
|
||||
if (clone.clusterNuclei[ix] is not Neuron clonedOutput)
|
||||
continue;
|
||||
|
||||
@ -226,7 +226,7 @@ public class Cluster : Nucleus {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected int GetNucleusIndex(Nucleus[] nuclei, Nucleus nucleus) {
|
||||
@ -240,7 +240,7 @@ public class Cluster : Nucleus {
|
||||
protected int GetNucleusIndex(List<Nucleus> nuclei, Nucleus nucleus) {
|
||||
int i = 0;
|
||||
foreach (Nucleus nucleiElement in nuclei) {
|
||||
//for (int i = 0; i < nuclei.Length; i++) {
|
||||
//for (int i = 0; i < nuclei.Length; i++) {
|
||||
if (nucleus == nucleiElement)
|
||||
return i;
|
||||
}
|
||||
@ -420,10 +420,13 @@ public class Cluster : Nucleus {
|
||||
}
|
||||
|
||||
public IReceptor GetReceptor(string receptorName) {
|
||||
string receptorName0 = receptorName + ": 0";
|
||||
foreach (Nucleus nucleus in this.clusterNuclei) {
|
||||
if (nucleus is IReceptor receptor)
|
||||
if (receptor.GetName() == receptorName)
|
||||
if (nucleus is IReceptor receptor) {
|
||||
if (nucleus.name == receptorName | nucleus.name == receptorName0)
|
||||
//if (receptor.GetName() == receptorName)
|
||||
return receptor;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -108,11 +108,13 @@ public class ClusterInspector : Editor {
|
||||
};
|
||||
|
||||
List<string> names = this.prefab.outputs.Select(output => output.name).ToList();
|
||||
outputsField = new(names, names.First()) {
|
||||
style = { flexGrow = 1 }
|
||||
};
|
||||
outputsField.RegisterValueChangedCallback(evt => OnOutputChanged(evt.newValue));
|
||||
outputContainer.Add(outputsField);
|
||||
if (names.Count > 0 && names.First() != null) {
|
||||
outputsField = new(names, names.First()) {
|
||||
style = { flexGrow = 1 }
|
||||
};
|
||||
outputsField.RegisterValueChangedCallback(evt => OnOutputChanged(evt.newValue));
|
||||
outputContainer.Add(outputsField);
|
||||
}
|
||||
|
||||
Button addButton = new(() => OnAddClusterOutput()) {
|
||||
text = "Add"
|
||||
@ -271,84 +273,84 @@ public class ClusterInspector : Editor {
|
||||
// maxValue = value;
|
||||
// }
|
||||
|
||||
// float spacing = 400f / receptor.instances.Count();
|
||||
// float margin = 10 + spacing / 2;
|
||||
// float xMin = 150 - size;
|
||||
// float xMax = 150 + size;
|
||||
// float yMin = 10 + margin - size / 2;
|
||||
// float yMax = 400 - margin + size;
|
||||
// Vector3[] verts = new Vector3[4] {
|
||||
// new(xMin, yMin, 0),
|
||||
// new(xMax, yMin, 0),
|
||||
// new(xMax, yMax, 0),
|
||||
// new(xMin, yMax, 0)
|
||||
// };
|
||||
// Handles.color = Color.black;
|
||||
// Handles.DrawAAConvexPolygon(verts);
|
||||
// int row = 0;
|
||||
// foreach (Nucleus nucleus in receptor.instances) {
|
||||
// Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
||||
// Handles.color = Color.white;
|
||||
// // The selected nucleus highlight ring
|
||||
// Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
||||
// DrawNucleus(nucleus, pos, maxValue, size);
|
||||
// row++;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
if (this.currentNucleus is IReceptor receptor1) {
|
||||
float maxValue = 0;
|
||||
foreach (Nucleus nucleus in receptor1.array.nuclei) {
|
||||
float value = length(nucleus.outputValue);
|
||||
if (value > maxValue)
|
||||
maxValue = value;
|
||||
}
|
||||
// float spacing = 400f / receptor.instances.Count();
|
||||
// float margin = 10 + spacing / 2;
|
||||
// float xMin = 150 - size;
|
||||
// float xMax = 150 + size;
|
||||
// float yMin = 10 + margin - size / 2;
|
||||
// float yMax = 400 - margin + size;
|
||||
// Vector3[] verts = new Vector3[4] {
|
||||
// new(xMin, yMin, 0),
|
||||
// new(xMax, yMin, 0),
|
||||
// new(xMax, yMax, 0),
|
||||
// new(xMin, yMax, 0)
|
||||
// };
|
||||
// Handles.color = Color.black;
|
||||
// Handles.DrawAAConvexPolygon(verts);
|
||||
// int row = 0;
|
||||
// foreach (Nucleus nucleus in receptor.instances) {
|
||||
// Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
||||
// Handles.color = Color.white;
|
||||
// // The selected nucleus highlight ring
|
||||
// Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
||||
// DrawNucleus(nucleus, pos, maxValue, size);
|
||||
// row++;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
if (this.currentNucleus is IReceptor receptor1) {
|
||||
float maxValue = 0;
|
||||
foreach (Nucleus nucleus in receptor1.array.nuclei) {
|
||||
float value = length(nucleus.outputValue);
|
||||
if (value > maxValue)
|
||||
maxValue = value;
|
||||
}
|
||||
|
||||
float spacing = 400f / receptor1.array.nuclei.Count();
|
||||
float margin = 10 + spacing / 2;
|
||||
float xMin = 150 - size;
|
||||
float xMax = 150 + size;
|
||||
float yMin = 10 + margin - size / 2;
|
||||
float yMax = 400 - margin + size;
|
||||
Vector3[] verts = new Vector3[4] {
|
||||
float spacing = 400f / receptor1.array.nuclei.Count();
|
||||
float margin = 10 + spacing / 2;
|
||||
float xMin = 150 - size;
|
||||
float xMax = 150 + size;
|
||||
float yMin = 10 + margin - size / 2;
|
||||
float yMax = 400 - margin + size;
|
||||
Vector3[] verts = new Vector3[4] {
|
||||
new(xMin, yMin, 0),
|
||||
new(xMax, yMin, 0),
|
||||
new(xMax, yMax, 0),
|
||||
new(xMin, yMax, 0)
|
||||
};
|
||||
Handles.color = Color.black;
|
||||
Handles.DrawAAConvexPolygon(verts);
|
||||
int row = 0;
|
||||
foreach (Nucleus nucleus in receptor1.array.nuclei) {
|
||||
Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
||||
Handles.color = Color.white;
|
||||
// The selected nucleus highlight ring
|
||||
Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
||||
DrawNucleus(nucleus, pos, maxValue, size);
|
||||
row++;
|
||||
}
|
||||
GUIStyle style = new(EditorStyles.label) {
|
||||
alignment = TextAnchor.UpperCenter,
|
||||
normal = { textColor = Color.white },
|
||||
fontStyle = FontStyle.Bold,
|
||||
};
|
||||
Vector3 labelPos = new(150, yMax + size + 5, 0);
|
||||
string receptorName = receptor1.GetName();
|
||||
int colonPos = receptorName.IndexOf(":");
|
||||
if (colonPos > 0) {
|
||||
string baseName = receptorName[..colonPos];
|
||||
Handles.Label(labelPos, baseName, style);
|
||||
}
|
||||
else
|
||||
Handles.Label(labelPos, receptorName, style);
|
||||
}
|
||||
else {
|
||||
Handles.color = Color.black;
|
||||
Handles.DrawAAConvexPolygon(verts);
|
||||
int row = 0;
|
||||
foreach (Nucleus nucleus in receptor1.array.nuclei) {
|
||||
Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
||||
Handles.color = Color.white;
|
||||
// The selected nucleus highlight ring
|
||||
Handles.DrawSolidDisc(position, Vector3.forward, size + 2);
|
||||
DrawNucleus(this.currentNucleus, position, length(this.currentNucleus.outputValue), 20);
|
||||
|
||||
Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
||||
DrawNucleus(nucleus, pos, maxValue, size);
|
||||
row++;
|
||||
}
|
||||
GUIStyle style = new(EditorStyles.label) {
|
||||
alignment = TextAnchor.UpperCenter,
|
||||
normal = { textColor = Color.white },
|
||||
fontStyle = FontStyle.Bold,
|
||||
};
|
||||
Vector3 labelPos = new(150, yMax + size + 5, 0);
|
||||
string receptorName = receptor1.GetName();
|
||||
int colonPos = receptorName.IndexOf(":");
|
||||
if (colonPos > 0) {
|
||||
string baseName = receptorName[..colonPos];
|
||||
Handles.Label(labelPos, baseName, style);
|
||||
}
|
||||
else
|
||||
Handles.Label(labelPos, receptorName, style);
|
||||
}
|
||||
else {
|
||||
Handles.color = Color.white;
|
||||
// The selected nucleus highlight ring
|
||||
Handles.DrawSolidDisc(position, Vector3.forward, size + 2);
|
||||
DrawNucleus(this.currentNucleus, position, length(this.currentNucleus.outputValue), 20);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
Handles.color = Color.white;
|
||||
@ -565,7 +567,7 @@ public class ClusterInspector : Editor {
|
||||
style.alignment = TextAnchor.UpperCenter;
|
||||
Vector3 labelPos = position - Vector3.down * (size + 5); // below disc along up axis
|
||||
int colonPos = nucleus.name.IndexOf(":");
|
||||
if (expandArray || (colonPos > 0 && colonPos < nucleus.name.Length - 2)) {
|
||||
if (expandArray && nucleus is Receptor) { //} || (colonPos > 0 && colonPos < nucleus.name.Length - 2)) {
|
||||
// string baseName = nucleus.name[..colonPos];
|
||||
// Handles.Label(labelPos, baseName, style);
|
||||
}
|
||||
@ -614,14 +616,17 @@ public class ClusterInspector : Editor {
|
||||
if (nucleus == this.currentNucleus) {
|
||||
if (nucleus is Receptor || nucleus is ClusterReceptor)
|
||||
expandArray = !expandArray;
|
||||
else
|
||||
expandArray = false;
|
||||
}
|
||||
else if (nucleus is ReceptorInstance receptor) {
|
||||
expandArray = false;
|
||||
this.currentNucleus = receptor.receptor;
|
||||
expandArray = false;
|
||||
BuildLayers();
|
||||
}
|
||||
else if (nucleus is Nucleus n) {
|
||||
this.currentNucleus = n;
|
||||
else {
|
||||
this.currentNucleus = nucleus;
|
||||
expandArray = false;
|
||||
BuildLayers();
|
||||
}
|
||||
}
|
||||
|
||||
11
Receptor.cs
11
Receptor.cs
@ -6,6 +6,8 @@ using static Unity.Mathematics.math;
|
||||
public class Receptor : Neuron, IReceptor {
|
||||
public Receptor(Cluster parent, string name) : base(parent, name) {
|
||||
this.array ??= new NucleusArray(this);
|
||||
if (this.name.IndexOf(":") < 0)
|
||||
this.name += ": 0";
|
||||
}
|
||||
public Receptor(ClusterPrefab prefab, string name) : base(prefab, name) {
|
||||
this.array ??= new NucleusArray(this);
|
||||
@ -16,20 +18,15 @@ public class Receptor : Neuron, IReceptor {
|
||||
}
|
||||
|
||||
public override Nucleus ShallowCloneTo(Cluster parent) {
|
||||
Receptor clone = new(parent, name) {
|
||||
//array = this.array
|
||||
};
|
||||
Receptor clone = new(parent, name);
|
||||
CloneFields(clone);
|
||||
return clone;
|
||||
}
|
||||
public override Nucleus Clone(ClusterPrefab prefab) {
|
||||
Receptor clone = new(prefab, name) {
|
||||
//array = this.array
|
||||
array = this.array
|
||||
};
|
||||
CloneFields(clone);
|
||||
// Adding receivers will also add synapses to the receivers
|
||||
foreach (Nucleus receiver in this.receivers)
|
||||
clone.AddReceiver(receiver);
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user