public BoneForPdkTreeVisualizer(Bone bone, BoneForPdkTreeVisualizer parent) { _bone = bone; _parent = parent; //Transformを正しく保持するために用いる実際の骨オブジェクト BoneObject = new GameObject(); BoneObject.name = _bone.Name; //見た目としてBoneObjectの位置を表す球 var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.name = "renderSphere"; sphere.transform.parent = BoneObject.transform; sphere.transform.localScale = new Vector3(.05f, .05f, .05f); sphere.transform.localPosition = Vector3.zero; if (_parent != null) { BoneObject.transform.parent = _parent.BoneObject.transform; _lineRenderer = BoneObject.AddComponent <LineRenderer>(); _lineRenderer.SetWidth(0.05f, 0.0f); _lineRenderer.SetColors(Color.blue, Color.green); } //再帰的な子ボーンの初期化。 _childs = bone .Childs .Select(b => new BoneForPdkTreeVisualizer(b, this)) .ToArray(); }
/// <summary>Qumarionの動作を適用するモデルの生成と、デバイスとの接続を行います。</summary> void Start() { _model = PdkManager.CreateStandardModelPS(); //NOTE: ルート以下については再帰的に生成する感じのアレ _rootBone = new BoneForPdkTreeVisualizer(_model.Root, null); _rootBone.BoneObject.transform.parent = transform; if (PdkManager.ConnectedDeviceCount == 0) { Debug.LogWarning("QUMARION was not found"); } else { _model.AttachQumarion(PdkManager.GetDefaultQumarion()); _model.AccelerometerRestrictMode = AccelerometerRestrictMode.None; } }