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