Exemplo n.º 1
0
/// public メソッド
///---------------------------------------------------------------------------

        /// 初期化
        public void Init()
        {
            calCollSphMove = new CollisionSphereMove();
            moveMoveCap    = new DemoGame.GeometryCapsule();

            moveType = Data.CollTypeId.ChMove;
        }
Exemplo n.º 2
0
        /// カプセルとカプセルとの衝突
        public bool Check(DemoGame.GeometryCapsule moveCap, ShapeCapsule trgCap)
        {
            /// 同じ座標にいる場合はすり抜ける
            if (moveCap.StartPos == trgCap.Capsule.StartPos)
            {
                //           return false;
            }

            /// 対象と反対向きへ移動する際にはすり抜ける
            float rot = Common.VectorUtil.GetPointRotY(moveCap.Line.Vec, moveCap.StartPos, trgCap.Capsule.StartPos);

            if (rot <= -50.0f || rot >= 50.0f)
            {
//            return false;
            }

            Vector3 collPos = StaticDataList.getVectorZero();

            calMovePos = moveCap.EndPos;
            if (DemoGame.CommonCollision.CheckCapsuleAndCapsule(moveCap, trgCap.Capsule, ref collPos) == true)
            {
                calMovePos = collPos;
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
 /// 継承 メソッド
 ///---------------------------------------------------------------------------
 /// 初期化
 public override bool Init( int num )
 {
     this.Capsule            = new DemoGame.GeometryCapsule();
     objEntryPos             = new Vector4[2];
     this.CollisionType      = 0;
     this.ShapeType          = TypeId.Capsule;
     return( true );
 }
Exemplo n.º 4
0
 /// 破棄
 public override void Term()
 {
     this.Capsule        = null;
     objEntryPos         = null;
 }
Exemplo n.º 5
0
 /// 破棄
 public void Term()
 {
     calCollSphMove    = null;
     moveMoveCap       = null;
 }
Exemplo n.º 6
0
        /// public メソッド
        ///---------------------------------------------------------------------------
        /// 初期化
        public void Init()
        {
            calCollSphMove  = new CollisionSphereMove();
            moveMoveCap     = new DemoGame.GeometryCapsule();

            moveType        = Data.CollTypeId.ChMove;
        }
Exemplo n.º 7
0
 /// 破棄
 public void Term()
 {
     calCollSphMove = null;
     moveMoveCap    = null;
 }
Exemplo n.º 8
0
        private float calBestDis;              /// 衝突した距離


/// public メソッド
///---------------------------------------------------------------------------

        /// カプセルと三角形との衝突
        public bool Check(DemoGame.GeometryCapsule moveCap, ShapeTriangles trgShape)
        {
            Vector3 collPos = StaticDataList.getVectorZero();

            calMovePos = moveCap.EndPos;
            calBestDis = -1.0f;
            calBestId  = -1;

            float checDis = moveCap.Line.Length + moveCap.R + collCheckDis;

            if (AppDebug.CollLightFlg == false)
            {
                for (int i = 0; i < trgShape.EntryNum; i++)
                {
                    float a = (calMovePos.Dot(trgShape.Triangle[i].Plane.Nor) + trgShape.Triangle[i].Plane.D);
                    if (a >= checDis || a <= -checDis)
                    {
                        continue;
                    }

                    if (DemoGame.CommonCollision.CheckSphereAndTriangle(moveCap, trgShape.Triangle[i], ref collPos) == true)
                    {
                        float dis = Common.VectorUtil.Distance(collPos, moveCap.StartPos);
                        if (dis < calBestDis || calBestId < 0)
                        {
                            calMovePos = collPos;
                            calBestDis = dis;
                            calBestId  = i;
                        }
                    }
                    AppDebug.CollCnt++;
                }
            }
            else
            {
                for (int i = 0; i < trgShape.EntryNum; i++)
                {
                    float a = (calMovePos.Dot(trgShape.Triangle[i].Plane.Nor) + trgShape.Triangle[i].Plane.D);
                    if (a >= checDis || a <= -checDis)
                    {
                        continue;
                    }

                    if (DemoGame.CommonCollision.CheckLineAndTriangle(moveCap.Line, trgShape.Triangle[i], ref collPos) == true)
                    {
                        float dis = Common.VectorUtil.Distance(collPos, moveCap.StartPos);
                        if (dis < calBestDis || calBestId < 0)
                        {
                            calMovePos = collPos;
                            calBestDis = dis;
                            calBestId  = i;
                        }
                    }
                    AppDebug.CollCnt++;
                }
            }

            if (calBestId >= 0)
            {
                return(true);
            }
            return(false);
        }