diff --git a/vr-configurator/Assets/Scripts/Models/BaseModel.cs b/vr-configurator/Assets/Scripts/Models/BaseModel.cs index 5b1b04c..3a0ff6d 100644 --- a/vr-configurator/Assets/Scripts/Models/BaseModel.cs +++ b/vr-configurator/Assets/Scripts/Models/BaseModel.cs @@ -4,7 +4,12 @@ using UnityEngine; // Data definition of BaseModel public class BaseModel : Model { - public BaseModel(string nameHuman, string nameId, Mesh mesh, Material material, List ports = null) + public BaseModel(string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset, Quaternion rotation, Vector3 scale, List ports) + : base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports) + { + + } + public BaseModel(string nameHuman, string nameId, Mesh mesh, Material material, List ports) : base(nameHuman, nameId, mesh, material, ports) { diff --git a/vr-configurator/Assets/Scripts/Models/ChildModel.cs b/vr-configurator/Assets/Scripts/Models/ChildModel.cs index 96c395f..bb579ec 100644 --- a/vr-configurator/Assets/Scripts/Models/ChildModel.cs +++ b/vr-configurator/Assets/Scripts/Models/ChildModel.cs @@ -6,6 +6,12 @@ public class ChildModel : Model { public string port { get; private set; } // port + public ChildModel(string port, string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset, Quaternion rotation, Vector3 scale, List ports = null) + : base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports) + { + this.port = port; + } + public ChildModel(string port, string nameHuman, string nameId, Mesh mesh, Material material, List ports = null) : base(nameHuman, nameId, mesh, material, ports) { diff --git a/vr-configurator/Assets/Scripts/Models/Model.cs b/vr-configurator/Assets/Scripts/Models/Model.cs index d1210a0..66645e4 100644 --- a/vr-configurator/Assets/Scripts/Models/Model.cs +++ b/vr-configurator/Assets/Scripts/Models/Model.cs @@ -7,10 +7,24 @@ public class Model public string nameId { get; internal set; } // JSON export name, should be unique public Mesh mesh { get; internal set; } // obj/fbx public Material material { get; internal set; } // skin - - + public readonly List ports; + + public readonly Vector3 offset; + public readonly Quaternion rotation; + public readonly Vector3 scale; + public Model(string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset, Quaternion rotation, Vector3 scale, List ports = null) + { + this.nameHuman = nameHuman; + this.nameId = nameId; + this.mesh = mesh; + this.material = material; + this.ports = ports; + this.offset = offset; + this.rotation = rotation; + this.scale = scale; + } public Model(string nameHuman, string nameId, Mesh mesh, Material material, List ports = null) { this.nameHuman = nameHuman; @@ -18,6 +32,9 @@ public class Model this.mesh = mesh; this.material = material; this.ports = ports; + this.offset = Vector3.zero; + this.rotation = Quaternion.identity; + this.scale = Vector3.one; } public bool hasPorts() diff --git a/vr-configurator/Assets/Scripts/Models/ModelBehaviour.cs b/vr-configurator/Assets/Scripts/Models/ModelBehaviour.cs index 7793046..d5d8450 100644 --- a/vr-configurator/Assets/Scripts/Models/ModelBehaviour.cs +++ b/vr-configurator/Assets/Scripts/Models/ModelBehaviour.cs @@ -19,7 +19,7 @@ public class ModelBehaviour : MonoBehaviour set { _model = value; - UpdateModel( value); + UpdateModel(value); } } //should be verified internal List children; @@ -63,6 +63,9 @@ public class ModelBehaviour : MonoBehaviour meshFilter.sharedMesh = _model.mesh; meshRenderer.material = _model.material; meshRenderer.sharedMaterial = _model.material; + transform.rotation = _model.rotation; + transform.localScale = _model.scale; + transform.localPosition += _model.offset; } public void UpdateChild(int childNum, string id) diff --git a/vr-configurator/Assets/Scripts/Models/ModelList.cs b/vr-configurator/Assets/Scripts/Models/ModelList.cs index 6239134..18b98df 100644 --- a/vr-configurator/Assets/Scripts/Models/ModelList.cs +++ b/vr-configurator/Assets/Scripts/Models/ModelList.cs @@ -15,6 +15,9 @@ public class ModelList "bike", Resources.Load("Model/Bicycle/Models/Low-Poly Bicycle"), new Material(Shader.Find("VR/SpatialMapping/Occlusion")), + Vector3.zero, + Quaternion.Euler(0,90,0), + Vector3.one, new List { //please dont ask about the numbers @@ -32,6 +35,9 @@ public class ModelList "erlbach", Resources.Load("Model/ERLbach/02.01.98.0000-ERLbach_vereinfacht"), new Material(Shader.Find("VR/SpatialMapping/Occlusion")), + new Vector3(0,0,4f), //big car needs big space + Quaternion.Euler(-90f,0f,0f), //rotate correctly + new Vector3(0.03f,0.03f,0.03f), //model bisschen groß new List { new Port(Definitions.PORT_ERLBACH_0, new Vector3(0f, 0f, 0f), "idErlbachPart0"), diff --git a/vr-configurator/Assets/Scripts/Models/ModelManager.cs b/vr-configurator/Assets/Scripts/Models/ModelManager.cs index f972383..ea03d33 100644 --- a/vr-configurator/Assets/Scripts/Models/ModelManager.cs +++ b/vr-configurator/Assets/Scripts/Models/ModelManager.cs @@ -1,8 +1,5 @@ using UnityEngine; -using UnityEditor; -using System.Collections; using System.Collections.Generic; -using Unity.VisualScripting; public class ModelManager : MonoBehaviour { @@ -12,7 +9,7 @@ public class ModelManager : MonoBehaviour public List baseModelList; //available BaseModels public GameObject baseModel; //current baseModel - public AutoModelSelector autoModelSelector; + public BaseModelSelector baseModelSelector; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() @@ -21,7 +18,7 @@ public class ModelManager : MonoBehaviour portDict = new Dictionary>(); childModelDict = new Dictionary(); baseModelList = new List(); - autoModelSelector = FindFirstObjectByType(); + baseModelSelector = FindFirstObjectByType(); foreach (var baseModel in ModelList.BaseModels) {