Exemplo n.º 1
0
        public HitStatus CheckHit(S3DLine line)
        {
            var res      = new HitStatus();
            var res_list = new List <HitStatus>();

            foreach (var p in panels)
            {
                var tmp_res = p.CheckHit(line);
                if (tmp_res.is_hit)
                {
                    res_list.Add(tmp_res);
                }
            }

            var min_range = -1.0;

            foreach (var r in res_list)
            {
                res.is_hit = true;
                if (min_range == -1 || min_range < r.range)
                {
                    res.point = r.point;
                    res.range = r.range;
                }
            }

            return(res);
        }
Exemplo n.º 2
0
        public HitStatus CheckHit(S3DLine line)
        {
            var res = new HitStatus();
            var p1  = line.p1.GetDXV();
            var p2  = line.p2.GetDXV();

            DX.VERTEX3D[] v6;
            GetDXVectors(out v6);

            // 三角ポリゴン2つで矩形と線分の判定の衝突判定をする
            var l1 = DX.HitCheck_Line_Triangle(p1, p2,
                                               DX.VGet(v6[0].pos.x, v6[0].pos.y, v6[0].pos.z),
                                               DX.VGet(v6[1].pos.x, v6[1].pos.y, v6[1].pos.z),
                                               DX.VGet(v6[2].pos.x, v6[2].pos.y, v6[2].pos.z));
            var l2 = DX.HitCheck_Line_Triangle(p1, p2,
                                               DX.VGet(v6[3].pos.x, v6[3].pos.y, v6[3].pos.z),
                                               DX.VGet(v6[4].pos.x, v6[4].pos.y, v6[4].pos.z),
                                               DX.VGet(v6[5].pos.x, v6[5].pos.y, v6[5].pos.z));

            if (l1.HitFlag == DX.TRUE)
            {
                res.is_hit = true;
                res.point  = new S3DPoint(l1.Position);
                res.range  = (new S3DLine(line.p1, res.point)).GetRange();
            }
            else if (l2.HitFlag == DX.TRUE)
            {
                res.is_hit = true;
                res.point  = new S3DPoint(l2.Position);
                res.range  = (new S3DLine(line.p2, res.point)).GetRange();
            }

            return(res);
        }