public override void Bind(BlenderObject bo) { // transform matrix transform.localPosition = bo.matrix.GetTranslation(); transform.localRotation = bo.matrix.GetRotation(); transform.localScale = bo.matrix.GetScale(); // mesh if (bo.HasMesh) { MeshFilter mf = GetComponent <MeshFilter>(); var mesh = new Mesh(); mf.mesh = mesh; mesh.vertices = bo.verts; mesh.normals = bo.normals; mesh.uv = bo.uvs; mesh.triangles = bo.faces; mesh.RecalculateBounds(); } // materials if (bo.HasMaterials) { MeshRenderer mr = GetComponent <MeshRenderer>(); // temporarily supporting a single material mr.sharedMaterial = CreateMaterial(bo.materials[0]); } // children if (bo.HasChildren) { foreach (var i in Enumerable.Range(0, bo.children.Length)) { BlenderObject boChild = bo.children[i]; // has child? Transform tChild = transform.Find(boChild.name); if (tChild == null) { GameObject goChild = new GameObject(boChild.name); goChild.AddComponent <BlenderGameObject>(); tChild = goChild.transform; tChild.parent = transform; } BlenderGameObject bgoChild = tChild.GetComponent <BlenderGameObject>(); bgoChild.Bind(boChild); } } }
public override void Bind(BlenderObject bo) { if (transform.childCount == 0) { GameObject childGO = new GameObject(bo.name); BlenderGameObject childBGO = childGO.AddComponent <BlenderGameObject>(); childBGO.transform.parent = transform; } transform.GetChild(0).GetComponent <BaseBlenderGameObject>().Bind(bo); // world anchor if (bo.worldAnchor != null) { Debug.Log("Anchor received from service"); SetAnchor(bo.worldAnchor); } }