The missile knows where it is at all times. It knows this because it knows where it isn't. By subtracting where it is from where it isn't, or where it isn't from where it is (whichever is greater), it obtains a difference, or deviation. The guidance subsystem uses deviations to generate corrective commands to drive the missile from a position where it is to a position where it isn't, and arriving at a position where it wasn't, it now is. Consequently, the position where it is, is now the position that it wasn't, and it follows that the position that it was, is now the position that it isn't.

In the event that the position that it is in is not the position that it wasn't, the system has acquired a variation, the variation being the difference between where the missile is, and where it wasn't. If variation is considered to be a significant factor, it too may be corrected by the GEA. However, the missile must also know where it was.
The missile guidance computer scenario works as follows. Because a variation has modified some of the information the missile has obtained, it is not sure just where it is. However, it is sure where it isn't, within reason, and it knows where it was. It now subtracts where it should be from where it wasn't, or vice-versa, and by differentiating this from the algebraic sum of where it shouldn't be, and where it was, it is able to obtain the deviation and its variation, which is called error.
This commit is contained in:
Tim
2025-07-09 01:49:02 +02:00
parent 5853d74435
commit bf8257cb14
8 changed files with 213 additions and 130 deletions

View File

@@ -5,20 +5,28 @@ using UnityEngine;
// Data definition of ChildModel
public class ChildModel : Model
{
public string Port { get; private set; }
public string ParentPort { get; private set; }
public ChildModel(string port, string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset,
Quaternion rotation, Vector3 scale, List<Port> ports = null, List<Color> colors = null)
: base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports, colors)
public ChildModel(string parentPort, string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset,
Quaternion rotation, Vector3 scale, List<Port> ports = null, List<Color> colors = null, bool passthrough = false)
: base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports, colors, passthrough)
{
this.Port = port;
this.ParentPort = parentPort;
}
public ChildModel(string port, string nameHuman, string nameId, Mesh mesh,
Material material, List<Port> ports = null, List<Color> color = null)
: base(nameHuman, nameId, mesh, material, ports, color)
public ChildModel(string parentPort, string nameHuman, string nameId, Mesh mesh,
Material material, List<Port> ports = null, List<Color> color = null, bool passthrough = false)
: base(nameHuman, nameId, mesh, material, ports, color, passthrough)
{
this.Port = port;
this.ParentPort = parentPort;
}
// For Groups, no Mesh
public ChildModel(string parentPort, string nameHuman, string nameId, Material material, Vector3 offset,
Quaternion rotation, Vector3 scale, List<Port> ports = null, List<Color> colors = null, bool passthrough = false)
: base(nameHuman, nameId, new Mesh(), material, offset, rotation, scale, ports, colors, passthrough)
{
this.ParentPort = parentPort;
}
}

View File

@@ -1,4 +1,5 @@
using System;
using UnityEngine;
public class ChildModelBehaviour : ModelBehaviour
{
@@ -21,5 +22,21 @@ public class ChildModelBehaviour : ModelBehaviour
Model = value;
}
}
public ModelBehaviour Parent { get; set; }
public Port GetParentPort()
{
Debug.Log($"Searching port for {name} with PortID {ChildModel.ParentPort} with parent {Parent}");
foreach (Port parentPort in Parent.Model.Ports)
{
if (parentPort.PortID == ChildModel.ParentPort)
{
Debug.Log($"Found port for {name} with PortID {parentPort.PortID} {parentPort.PortName} for {ChildModel.ParentPort}");
return parentPort;
}
}
Debug.LogWarning($"Didn't find port for {name} with PortID {ChildModel.ParentPort}");
return null;
}
}

View File

@@ -96,14 +96,15 @@ public class Definitions
public const string PORT_ERLBACH_77 = "portErlbach77";
public const string PORT_ERLBACH_78 = "portErlbach78";
public const string PORT_ERLBACH_79 = "portErlbach79";
public const string PORT_ERL_RIM_LH = "erlRimLH";
public const string PORT_ERL_RIM_LV = "erlRimLV";
public const string PORT_ERL_RIM_RV = "erlRimRV";
public const string PORT_ERL_RIM_RH = "erlRimRH";
public const string PORT_ERL_TIRE_LH = "erlTire";
public const string PORT_ERL_TIRE_LV = "tire1";
public const string PORT_ERL_TIRE_RH = "tire2";
public const string PORT_ERL_TIRE_RV = "tire3";
public const string PORT_ERL_RIMS = "erlRims";
public const string PORT_ERL_RIM_LH = "erlRimLinksHinten";
public const string PORT_ERL_RIM_LV = "erlRimLinksVorne";
public const string PORT_ERL_RIM_RV = "erlRimRechtsVorne";
public const string PORT_ERL_RIM_RH = "erlRimRechtsHinten";
public const string PORT_ERL_TIRE_LH = "erlTireLinksHinten";
public const string PORT_ERL_TIRE_LV = "erlTireLinksVorne";
public const string PORT_ERL_TIRE_RV = "erlTireRechtsVorne";
public const string PORT_ERL_TIRE_RH = "erlTireRechtsHinten";
public const string PORT_ERLBACH_Body = "body";
public const string PORT_ERLBACH_Bumper = "portErlbach85";
public const string PORT_ERLBACH_FrontBumper = "portErlbach86";

View File

@@ -9,6 +9,7 @@ public class Model
public Material Material { get; internal set; } // skin
public List<Color> Color { get; set; } // koleur
public readonly bool Passthrough; //whether this passes through color
public readonly List<Port> Ports;
@@ -17,7 +18,7 @@ public class Model
public readonly Vector3 Scale;
public Model(string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset,
Quaternion rotation, Vector3 scale, List<Port> ports = null, List<Color> color = null)
Quaternion rotation, Vector3 scale, List<Port> ports = null, List<Color> color = null, bool passthrough = false)
{
this.NameHuman = nameHuman;
this.NameId = nameId;
@@ -28,8 +29,9 @@ public class Model
this.Rotation = rotation;
this.Scale = scale;
this.Color = color;
this.Passthrough = passthrough;
}
public Model(string nameHuman, string nameId, Mesh mesh, Material material, List<Port> ports = null, List<Color> color = null)
public Model(string nameHuman, string nameId, Mesh mesh, Material material, List<Port> ports = null, List<Color> color = null, bool passthrough = false)
{
this.NameHuman = nameHuman;
this.NameId = nameId;
@@ -40,6 +42,7 @@ public class Model
this.Rotation = Quaternion.identity;
this.Scale = Vector3.one;
this.Color = color;
this.Passthrough = passthrough;
}
public bool HasColor()
@@ -52,9 +55,4 @@ public class Model
return Ports != null && Ports.Count > 0;
}
public void AddPort(Port port)
{
Ports.Add(port);
}
}

View File

@@ -5,7 +5,7 @@ using UnityEngine;
/// <summary>
/// Base for BaseModelBehaviour and ChildModelBehaviour
/// </summary>
public class ModelBehaviour : MonoBehaviour
public class ModelBehaviour : MonoBehaviour, IResettable
{
public ModelManager ModelManager;
private Model _model;
@@ -22,11 +22,35 @@ public class ModelBehaviour : MonoBehaviour
_model = value;
}
} //should be verified
private readonly List<GameObject> _children = new List<GameObject>();
private MeshFilter _meshFilter;
private MeshRenderer _meshRenderer;
readonly List<GameObject> _children = new List<GameObject>();
MeshFilter _meshFilter;
MeshRenderer _meshRenderer;
private Color Color = Color.black;
Color _color = Color.black;
Color Color
{
get
{
return _color;
}
set
{
var clonedMaterial = new Material(_meshRenderer.material); //clone da sonst alle anderen mit dem mat auch colorchanged werden
clonedMaterial.color = value;
_meshRenderer.material = clonedMaterial;
Debug.Log($"{name}: Set color from {_color} to {value}");
_color = value;
if (Model.Passthrough)
{
Debug.Log($"{name}: Passthrough {_children.Count}");
foreach (GameObject go in _children)
{
Debug.Log($"{name}: coloring {go.name}");
go.GetComponent<ChildModelBehaviour>().Color = value;
}
}
}
}
void Start()
{
@@ -45,26 +69,26 @@ public class ModelBehaviour : MonoBehaviour
void UpdateModel(Model newModel)
{
Debug.Log($"UpdateModel: {name} updates from {(Model == null ? "null" : Model.NameId)} to {newModel.NameId}");
Init(); // I love race conditions
if (newModel is BaseModel)
{
this.name = "BaseModel:" + newModel.NameId;
name = "BaseModel:" + newModel.NameId;
}
else if (newModel is ChildModel cModel)
{
this.name = cModel.Port + ":" + newModel.NameId;
Debug.Log($"UpdateModel Name: {name} to {cModel.ParentPort}:{newModel.NameId}");
name = cModel.ParentPort + ":" + newModel.NameId;
}
//unapply previous model offset
if (Model != null)
{
Debug.Log($"Model {name} reset old {Model} offsets.");
Debug.Log($"UpdateModel: Model {name} reset old {Model} offsets.");
transform.localPosition -= Model.Offset;
transform.localRotation *= Quaternion.Inverse(Model.Rotation);
transform.localScale -= Model.Scale;
}
Debug.Log($"Model {name} update to new {newModel} Model.");
//kill old children
foreach (var compo in GetComponentsInChildren<ChildModelBehaviour>())
{
@@ -72,15 +96,9 @@ public class ModelBehaviour : MonoBehaviour
{
continue;
}
Debug.Log($"Destroying {name}'s Child {compo.gameObject.name}");
Debug.Log($"UpdateModel: Destroying {name}'s Child {compo.gameObject.name}");
Destroy(compo.gameObject); // will be destroyed next frame
}
//spawn new childPorts
if (newModel.HasPorts())
{
Debug.Log($"Spawning {gameObject.name}'s ports");
SpawnChildPorts(newModel);
_children.Remove(compo.gameObject);
}
//change ourselves
_meshFilter.mesh = newModel.Mesh;
@@ -90,6 +108,13 @@ public class ModelBehaviour : MonoBehaviour
transform.localRotation = newModel.Rotation;
transform.localScale = newModel.Scale;
transform.localPosition += newModel.Offset;
//spawn new childPorts
if (newModel.HasPorts())
{
Debug.Log($"Spawning {gameObject.name}'s ports");
SpawnChildPorts(newModel);
}
}
public void UpdateChild(int childNum, string id)
@@ -100,7 +125,9 @@ public class ModelBehaviour : MonoBehaviour
}
Model.Ports[childNum].Unapply(_children[childNum].transform);
//set new
_children[childNum].GetComponent<ChildModelBehaviour>().ChildModel = ModelManager.GetById(id);
var cmb = _children[childNum].GetComponent<ChildModelBehaviour>();
cmb.ChildModel = ModelManager.GetById(id);
cmb.Parent = this;
Model.Ports[childNum].Apply(_children[childNum].transform);
}
@@ -108,9 +135,9 @@ public class ModelBehaviour : MonoBehaviour
/// Spawns all Port-GO's, should be called only on Model Switch <b>after</b> cleanup
/// </summary>
/// <param name="newModel"><c>Model</c> the New Model to spawn ports from</param>
private void SpawnChildPorts(Model newModel)
void SpawnChildPorts(Model newModel)
{
Debug.Log($"{newModel.NameId}: Spawning {this.name} count of {newModel.Ports.Count} Ports");
Debug.Log($"SpawnChildPorts: {name} : {newModel.NameId} spawns {newModel.Ports.Count} Ports");
if (ModelManager == null)
{
Debug.LogError("ModelManager not found");
@@ -121,8 +148,8 @@ public class ModelBehaviour : MonoBehaviour
{
var port = newModel.Ports[i];
Debug.Log(i + ". Creating port " + port.PortID);
// bike:wheel:num
GameObject child = new GameObject(this.name + ":" + port.PortID + ":" + i);
// name is set in UpdateModel of own model
GameObject child = new GameObject("unattended child");
child.transform.SetParent(this.transform); //makes this an actual child
child.transform.localPosition = Vector3.zero; //i love unity
ChildModelBehaviour cmb = child.AddComponent<ChildModelBehaviour>();
@@ -136,9 +163,12 @@ public class ModelBehaviour : MonoBehaviour
continue;
}
Debug.Log($"POS {child.transform.gameObject.name} pos {child.transform.localPosition} {child.transform.rotation} {child.transform.localScale}");
Debug.Log($"SET POS {child.transform.gameObject.name} pos {child.transform.localPosition} {child.transform.rotation} {child.transform.localScale}");
cmb.Parent = this;
cmb.ChildModel = childModel;
Debug.Log($"AFTER SET PRE PORT POS {child.transform.gameObject.name} pos {child.transform.localPosition} {child.transform.rotation} {child.transform.localScale}");
port.Apply(child.transform); // move to correct position
Debug.Log($"AFTER PORT POS {child.transform.gameObject.name} pos {child.transform.localPosition} {child.transform.rotation} {child.transform.localScale}");
}
}
@@ -159,7 +189,7 @@ public class ModelBehaviour : MonoBehaviour
export += $"\"modelId\": \"{Model.NameId}\"";
if(Model is ChildModel cm)
{
export += $", \"portId\": \"{cm.Port}\"";
export += $", \"portId\": \"{cm.ParentPort}\"";
}
if (Model.HasColor())
{
@@ -203,24 +233,11 @@ public class ModelBehaviour : MonoBehaviour
Debug.LogWarning($"PortIndex {portIndex} invalid: there are {_children.Count} children.");
return;
}
var child = _children[portIndex];
var meshRenderer = child.GetComponent<MeshRenderer>();
child.GetComponent<ModelBehaviour>().Color = color;
if (meshRenderer == null)
{
Debug.LogWarning($"MeshRenderer for {portIndex} is null, skipping color set");
return;
}
// Klonen des Materials und Setzen der Farbe
var clonedMaterial = new Material(meshRenderer.material);
clonedMaterial.color = color;
meshRenderer.material = clonedMaterial; // Setzt den MeshRenderer auf den Klon
Debug.Log($"PortNum {portIndex}: Cloned Material and Set color to {color}");
_children[portIndex].GetComponent<ChildModelBehaviour>().Color = color;
}
public void ClearChildren()
{
Debug.Log("Removing Children...");
Debug.Log($"Removing Children of {name}...");
foreach (var child in _children)
{
if (child != null)
@@ -232,4 +249,9 @@ public class ModelBehaviour : MonoBehaviour
Debug.Log("Removed.");
}
public void ResetThis()
{
Debug.Log($"Resetting {name}...");
ClearChildren();
}
}

View File

@@ -137,14 +137,11 @@ public class ModelList
Port.Hidden(Definitions.PORT_ERLBACH_77, "idErlbachPart77", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 0f, 30f)),
Port.Hidden(Definitions.PORT_ERLBACH_78, "idErlbachPart78", Vector3.zero),
Port.Hidden(Definitions.PORT_ERLBACH_79, "idErlbachPart79", Vector3.zero),
Port.Hidden(Definitions.PORT_ERL_TIRE_LH, "LH", new Vector3(0f,0f,0f), Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Choosable("Back Wheel Right", Definitions.PORT_ERL_RIM_LH, "idErlbachWheel_LH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_TIRE_LV, "LV", new Vector3(0f,0f,0f), Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Choosable("Front Wheel Right", Definitions.PORT_ERL_RIM_LV, "idErlbachWheel_LV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_TIRE_RH, "RH", new Vector3(0f,0f,0f), Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Choosable("Back Wheel Left", Definitions.PORT_ERL_RIM_RH, "idErlbachWheel_RH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_TIRE_RV, "RV", new Vector3(0f,0f,0f), Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Choosable("Front Wheel Left", Definitions.PORT_ERL_RIM_RV, "idErlbachWheel_RV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_TIRE_LH, "erlTire1_LH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_TIRE_LV, "erlTire1_LV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_TIRE_RH, "erlTire1_RH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_TIRE_RV, "erlTire1_RV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Choosable("Rims", Definitions.PORT_ERL_RIMS, "erlRims_1", Vector3.zero, Quaternion.identity, 1f),
Port.Choosable("Body", Definitions.PORT_ERLBACH_Body, "idErlbachPart84", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 0f, 100f)),
Port.Choosable("Rear Bumper", Definitions.PORT_ERLBACH_Bumper, "idErlbachPart85", Vector3.zero, Quaternion.identity, 1f, new Vector3(20f, 0f, 0f)),
Port.Hidden(Definitions.PORT_ERLBACH_Headlight_V_Cover, "idErlbachPart86", new Vector3(2.1f, 0f, 0f), Quaternion.identity, 1f, new Vector3(-10f, 0f, 0f)),
@@ -161,11 +158,66 @@ public class ModelList
};
public static readonly List<ChildModel> ChildModels = new List<ChildModel>()
{
//Felge 1
//Felgensets
new ChildModel(
Definitions.PORT_ERL_RIMS,
"Normal Rims",
"erlRims_1",
Resources.Load<Material>($"Material/AluminiumScratched"),
Vector3.zero, // offset to the port
Quaternion.identity,
Vector3.one,
new List<Port>
{
Port.Hidden(Definitions.PORT_ERL_RIM_LH, "erlRim1_LH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_LV, "erlRim1_LV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_RH, "erlRim1_RH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_RV, "erlRim1_RV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
},
DefaultColors,
true
),
new ChildModel(
Definitions.PORT_ERL_RIMS,
"Sport Rims",
"erlRims_2",
Resources.Load<Material>($"Material/AluminiumScratched"),
Vector3.zero, // offset to the port
Quaternion.identity,
Vector3.one,
new List<Port>
{
Port.Hidden(Definitions.PORT_ERL_RIM_LH, "erlRim2_LH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_LV, "erlRim2_LV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_RH, "erlRim2_RH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_RV, "erlRim2_RV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
},
DefaultColors,
true
),
new ChildModel(
Definitions.PORT_ERL_RIMS,
"Elegance Rims",
"erlRims_3",
Resources.Load<Material>($"Material/AluminiumScratched"),
Vector3.zero, // offset to the port
Quaternion.identity,
Vector3.one,
new List<Port>
{
Port.Hidden(Definitions.PORT_ERL_RIM_LH, "erlRim3_LH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_LV, "erlRim3_LV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, -30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_RH, "erlRim3_RH", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
Port.Hidden(Definitions.PORT_ERL_RIM_RV, "erlRim3_RV", Vector3.zero, Quaternion.identity, 1f, new Vector3(0f, 30f, 0f)),
},
DefaultColors,
true
),
// Sport
new ChildModel(
Definitions.PORT_ERL_RIM_RH,
"Sport Rim",
"radRH",
"erlRim2_RH",
Resources.Load<Mesh>($"Model/ERLbach/Felge1"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(60f, 65f, -15f), // offset to the port
@@ -177,7 +229,7 @@ public class ModelList
new ChildModel(
Definitions.PORT_ERL_RIM_RV,
"Sport Rim",
"radRV",
"erlRim2_RV",
Resources.Load<Mesh>($"Model/ERLbach/Felge1"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(-105f, 65f, -15f), // offset to the port
@@ -189,7 +241,7 @@ public class ModelList
new ChildModel(
Definitions.PORT_ERL_RIM_LV,
"Sport Rim",
"radLV",
"erlRim2_LV",
Resources.Load<Mesh>($"Model/ERLbach/Felge1"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(-105f, -30f, -15f), // offset to the port
@@ -201,7 +253,7 @@ public class ModelList
new ChildModel(
Definitions.PORT_ERL_RIM_LH,
"Sport Rim",
"rimLH",
"erlRim2_LH",
Resources.Load<Mesh>($"Model/ERLbach/Felge1"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(-60f, -30f, -15f), // offset to the port
@@ -210,11 +262,11 @@ public class ModelList
null,
DefaultColors
),
//Felge 2
// Elegance
new ChildModel(
Definitions.PORT_ERL_RIM_RH,
"Elegance Rim",
"erlRimRH3",
"erlRim3_RH",
Resources.Load<Mesh>($"Model/ERLbach/Felge3"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(60f, 65f, -15f), // offset to the port
@@ -226,7 +278,7 @@ public class ModelList
new ChildModel(
Definitions.PORT_ERL_RIM_RV,
"Elegance Rim",
"erlRimRV3",
"erlRim3_RV",
Resources.Load<Mesh>($"Model/ERLbach/Felge3"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(-105f, 65f, -15f), // offset to the port
@@ -238,7 +290,7 @@ public class ModelList
new ChildModel(
Definitions.PORT_ERL_RIM_LV,
"Elegance Rim",
"erlRimLV3",
"erlRim3_LV",
Resources.Load<Mesh>($"Model/ERLbach/Felge3"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(-105f, -30f, -15f), // offset to the port
@@ -250,7 +302,7 @@ public class ModelList
new ChildModel(
Definitions.PORT_ERL_RIM_LH,
"Elegance Rim",
"erlRimLH3",
"erlRim3_LH",
Resources.Load<Mesh>($"Model/ERLbach/Felge3"),
Resources.Load<Material>($"Material/AluminiumScratched"),
new Vector3(-60f, -30f, -15f), // offset to the port
@@ -259,6 +311,7 @@ public class ModelList
null,
DefaultColors
),
// GRILL
new ChildModel(
Definitions.PORT_ERLBACH_GRILL,
"Grille Elegance",
@@ -389,14 +442,14 @@ public class ModelList
new ModelElement( Definitions.PORT_ERLBACH_77, "Erlbach Part 77", "idErlbachPart77", Resources.Load<Material>($"Material/PVC"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERLBACH_78, "Erlbach Part 78", "idErlbachPart78", Resources.Load<Material>($"Material/PVC"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERLBACH_79, "Erlbach Part 79", "idErlbachPart79", Resources.Load<Material>($"Material/PVC"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_TIRE_LH, "Tire LH", "LH", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_LH, "Standard Rim", "idErlbachWheel_LH", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERL_TIRE_LV, "Tire LV", "LV", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_LV, "Standard Rim", "idErlbachWheel_LV", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERL_TIRE_RH, "Tire RH", "RH", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_RH, "Standard Rim", "idErlbachWheel_RH", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERL_TIRE_RV, "Tire RV", "RV", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_RV, "Standard Rim", "idErlbachWheel_RV", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERL_TIRE_LH, "Tire LH", "erlTire1_LH", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_LH, "Standard Rim", "erlRim1_LH", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERL_TIRE_LV, "Tire LV", "erlTire1_LV", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_LV, "Standard Rim", "erlRim1_LV", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERL_TIRE_RH, "Tire RH", "erlTire1_RH", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_RH, "Standard Rim", "erlRim1_RH", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERL_TIRE_RV, "Tire RV", "erlTire1_RV", Resources.Load<Material>($"Material/CarTire"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),
new ModelElement( Definitions.PORT_ERL_RIM_RV, "Standard Rim", "erlRim1_RV", Resources.Load<Material>($"Material/AluminiumScratched"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERLBACH_Body, "Body", "idErlbachPart84", Resources.Load<Material>($"Material/AluminiumPolished"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERLBACH_Bumper, "Rear Bumper", "idErlbachPart85", Resources.Load<Material>($"Material/AluminiumPolished"), Vector3.zero, Quaternion.identity, Vector3.one, null, DefaultColors ),
new ModelElement( Definitions.PORT_ERLBACH_Headlight_V_Cover, "Headlight Cover", "idErlbachPart86", Resources.Load<Material>($"Material/AluminiumPolished"), Vector3.zero, Quaternion.identity, Vector3.one, null, null ),

View File

@@ -73,7 +73,7 @@ public class ModelManager : MonoBehaviour, IResettable
void RegisterChildModel(ChildModel model)
{
Debug.Log($"Registering {model.NameId} for Port {model.Port} ({model})");
Debug.Log($"Registering {model.NameId} for Port {model.ParentPort} ({model})");
//childModelDict
if (_childModelDict.ContainsKey(model.NameId))
{
@@ -83,21 +83,21 @@ public class ModelManager : MonoBehaviour, IResettable
_childModelDict[model.NameId] = model;
//portDict
if (string.IsNullOrEmpty(model.Port))
if (string.IsNullOrEmpty(model.ParentPort))
{
Debug.LogWarning("Model " + model.NameId + " has no Port! [portDict] Skipping...");
return;
}
if (!_portDict.ContainsKey(model.Port))
if (!_portDict.ContainsKey(model.ParentPort))
{
_portDict.Add(model.Port, new HashSet<ChildModel>());
_portDict.Add(model.ParentPort, new HashSet<ChildModel>());
}
if (_portDict[model.Port].Contains(model))
if (_portDict[model.ParentPort].Contains(model))
{
Debug.LogWarning("Model " + model.NameId + " already registered! [portDict] Skipping...");
return;
}
_portDict[model.Port].Add(model);
_portDict[model.ParentPort].Add(model);
}
void RegisterBaseModel(BaseModel baseModel)
@@ -132,22 +132,20 @@ public class ModelManager : MonoBehaviour, IResettable
public void LoadSelectedModel(BaseModel baseModel)
{
Debug.Log($"Model {baseModel.NameHuman} started loading.");
//create if doesn't exist
if (this.baseModelGO == null)
if (baseModelGO == null)
{
// Create new GameObject for the baseModel
this.baseModelGO = new GameObject(baseModel.NameId)
{
name = baseModel.NameId,
};
this.baseModelGO.AddComponent<BaseModelBehaviour>();
// Positioning
this.baseModelGO.transform.position = new Vector3(0, 0, 1);
this.baseModelGO.transform.localRotation = Quaternion.Euler(0, 90, 0);
this.baseModelGO.SetActive(true);
Debug.Log($"Spawning BaseModelGO.");
baseModelGO = new GameObject(baseModel.NameId);
baseModelGO.AddComponent<BaseModelBehaviour>();
baseModelGO.transform.position = new Vector3(0, 0, 1);
baseModelGO.transform.localRotation = Quaternion.Euler(0, 90, 0);
baseModelGO.SetActive(true);
Debug.Log($"Spawned BaseModelGO.");
}
this.baseModelGO.GetComponent<BaseModelBehaviour>().BaseModel = baseModel;
this.baseModelGO.SetActive(true);
baseModelGO.GetComponent<BaseModelBehaviour>().BaseModel = baseModel;
baseModelGO.SetActive(true);
Debug.Log($"Model {baseModel.NameHuman} lock and loaded.");
}
@@ -176,23 +174,9 @@ public class ModelManager : MonoBehaviour, IResettable
tw.Write(BaseModelBehaviour.ExportJson());
tw.Close();
}
public Port GetPortForChildModel(ChildModel childModel)
{
foreach (var port in BaseModel.Ports)
{
if (port.PortID == childModel.Port)
{
return port;
}
}
Debug.Log($"No child model found for port {childModel.Port}");
return null;
}
public void ResetThis()
{
OpenSelector();
BaseModelBehaviour.ClearChildren();
}
}

View File

@@ -37,7 +37,7 @@ public class ChildModelSelector : MonoBehaviour, IResettable
foreach (var childModel in childModels)
{
Debug.Log($"Adding {childModel}");
GameObject go = Spawn.GO(cmpPrefab, daddy.transform, Vector3.zero, "picker:" + childModel.Port + ":" + childModel.NameId);
GameObject go = Spawn.GO(cmpPrefab, daddy.transform, Vector3.zero, "picker:" + childModel.ParentPort + ":" + childModel.NameId);
go.SetActive(true);
go.GetNamedChild("Icon").GetComponent<Image>().sprite = Resources.Load<Sprite>($"sprites/" + childModel.NameId);
TextMeshProUGUI[] label = go.GetComponentsInChildren<TextMeshProUGUI>();