Exemplo n.º 1
0
    // UnityのOnValidate : SprBehaviourのものをオーバーライド
    public override void OnValidate()
    {
        if (GetDescStruct() == null)
        {
            ResetDescStruct();
        }

        if (sprObject != null)
        {
            // PHSceneの設定
            {
                PHSceneDesc d = new PHSceneDesc();
                phScene.GetDesc(d);
                desc.ApplyTo(d);
                phScene.SetDesc(d);
            }

            // PHIKEngineの設定
            {
                PHIKEngineDesc d = new PHIKEngineDesc();
                phScene.GetIKEngine().GetDesc(d);
                descIK.ApplyTo(d);
                phScene.GetIKEngine().SetDesc(d);
            }

            // DescではなくStateに含まれる変数。ApplyToで自動同期されないので手動で設定
            phScene.SetTimeStep(desc.timeStep);
            phScene.SetHapticTimeStep(desc.haptictimeStep);

            // IKの有効・無効の切り替え
            phScene.GetIKEngine().Enable(enableIK);
        }

        ApplyCollisionList();
    }
Exemplo n.º 2
0
    // UnityのOnValidate : SprBehaviourのものをオーバーライド
    public override void OnValidate()
    {
        if (GetDescStruct() == null)
        {
            ResetDescStruct();
        }

        if (sprObject != null)
        {
            // PHSceneの設定
            {
                PHSceneDesc d = new PHSceneDesc();
                phScene.GetDesc(d);
                desc.ApplyTo(d);
                phScene.SetDesc(d);
            }

            // PHIKEngineの設定
            {
                PHIKEngineDesc d = new PHIKEngineDesc();
                phScene.GetIKEngine().GetDesc(d);
                descIK.ApplyTo(d);
                phScene.GetIKEngine().SetDesc(d);
            }

            // DescではなくStateに含まれる変数。ApplyToで自動同期されないので手動で設定
            phScene.SetTimeStep(desc.timeStep);
            phScene.SetHapticTimeStep(desc.haptictimeStep);

            // IKの有効・無効の切り替え
            phScene.GetIKEngine().Enable(enableIK);
        }

        // <!!> PHJointBehaviourのdisableCollisionと衝突するので要検討
        if (sprObject != null)
        {
            for (int i = 0; i < collision.Count; i++)
            {
                CollisionSetting c = collision[i];
                if (c.solid1 == null && c.solid2 == null)
                {
                    phScene.SetContactMode(c.mode);
                }
                else if (c.solid1 == null)
                {
                    if (c.solid2.sprObject != null)
                    {
                        phScene.SetContactMode(c.solid2.phSolid, c.mode);
                    }
                }
                else if (c.solid2 == null)
                {
                    if (c.solid1.sprObject != null)
                    {
                        phScene.SetContactMode(c.solid1.phSolid, c.mode);
                    }
                }
                else
                {
                    if (c.solid1.sprObject != null && c.solid2.sprObject != null)
                    {
                        phScene.SetContactMode(c.solid1.phSolid, c.solid2.phSolid, c.mode);
                    }
                }
            }
        }
    }