コード例 #1
0
 public void BuildWalkables2(GamePlay.GWorld world, Stack <GeoBox> stack)
 {
     while (stack.Count > 0)
     {
         GeoBox curBox = stack.Pop();
         foreach (var i in curBox.LinkedBox)
         {
             if (i == null)
             {
                 continue;//边缘
             }
             if (i.Walk)
             {
                 continue;//已经走过了
             }
             if (i.CanWalk == false)
             {
                 continue;//一个阻塞了
             }
             if (CheckBoxInPhy(world, ref i.Box, ref CurrentPosition, ref CurrentRotation))
             {
                 i.CanWalk = false;
             }
             else
             {
                 i.Walk    = true;
                 i.CanWalk = true;
                 stack.Push(i);
             }
         }
     }
 }
コード例 #2
0
 public void BuildWalkables(GamePlay.GWorld world, GeoBox curBox, int curDepth, ref int maxDepth)
 {//这里要递归改回溯算法,否则堆栈吃不消
     if (curDepth > maxDepth)
     {
         maxDepth = curDepth;
     }
     curBox.Walk    = true;
     curBox.CanWalk = true;
     foreach (var i in curBox.LinkedBox)
     {
         if (i == null)
         {
             continue;//边缘
         }
         if (i.Walk)
         {
             continue;//已经走过了
         }
         if (i.CanWalk == false)
         {
             continue;//一个阻塞了
         }
         if (CheckBoxInPhy(world, ref i.Box, ref CurrentPosition, ref CurrentRotation))
         {
             i.CanWalk = false;
         }
         else
         {
             BuildWalkables(world, i, curDepth + 1, ref maxDepth);
         }
     }
 }
コード例 #3
0
        //物理反馈的数据不精确 待优化
        private bool CheckBoxInPhy(GamePlay.GWorld world, ref BoundingBox box, ref Vector3 pos, ref Quaternion rotation)//float dis, float offset
        {
            GamePlay.SceneGraph.GSceneGraph DefaultScene = world.DefaultScene;
            Bricks.PhysicsCore.CPhyScene    PhyScene     = DefaultScene.PhyScene;
            var shape = CEngine.Instance.PhyContext.CreateShapeBox(PhysicsCore.CPhyMaterial.DefaultPhyMaterial, box.GetSize().X, box.GetSize().Y, box.GetSize().Z);

            GamePlay.SceneGraph.VHitResult result = new GamePlay.SceneGraph.VHitResult();

            Matrix mat1 = Matrix.Transformation(Vector3.UnitXYZ, Quaternion.Identity, box.GetCenter());
            Matrix mat2 = Matrix.Transformation(Vector3.UnitXYZ, rotation, pos);
            Matrix mat3 = mat1 * mat2;

            Vector3    scale;
            Vector3    position;
            Quaternion rot;

            mat3.Decompose(out scale, out rot, out position);
            return(PhyScene.Overlap(shape, position, rot, ref result));
        }
コード例 #4
0
        public async System.Threading.Tasks.Task CreateRenderInfos(GamePlay.GWorld world)
        {
            //EngineNS.Bricks.GraphDrawer.GraphLines
            AgentBoxs ab = AgentDatas[0];

            Agent.GeoBox[]        ap    = ab.AgentData.ToArray();
            GamePlay.Actor.GActor actor = new GamePlay.Actor.GActor();
            //创建包围盒的每个点
            for (int i = 0; i < ap.Length; i++)
            {
                EngineNS.Bricks.GraphDrawer.GraphLines graph = new EngineNS.Bricks.GraphDrawer.GraphLines();
                var  boxgen  = new EngineNS.Bricks.GraphDrawer.McBoxGen();
                bool allface = ap[i].FaceType == face;
                boxgen.Interval = allface ? 0.05f : 0.1f;
                boxgen.Segement = allface ? 1.0f : 0.2f;

                Vector4 outv4;
                Vector3.Transform(ref ap[i].Box.Maximum, ref ab.Mat, out outv4);
                ap[i].Box.Maximum = new Vector3(outv4.X, outv4.Y, outv4.Z);
                Vector3.Transform(ref ap[i].Box.Minimum, ref ab.Mat, out outv4);
                ap[i].Box.Minimum = new Vector3(outv4.X, outv4.Y, outv4.Z);
                boxgen.SetBoundBox(ap[i].Box);

                graph.LinesGen = boxgen;
                var mtl = await CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(
                    CEngine.Instance.RenderContext,
                    //蓝线就是六个面都通了
                    RName.GetRName(allface ? "editor/icon/icon_3D/material/physical_model.instmtl" : "editor/volume/mi_volume_octree.instmtl"));//rotator

                var init = await graph.Init(mtl, 0.0f);

                graph.GraphActor.Placement.Location = Vector3.Zero;
                graph.GraphActor.SpecialName        = ActorName;
                //world.AddActor(graph.GraphActor);
                //world.DefaultScene.AddActor(graph.GraphActor);
                actor.Children.Add(graph.GraphActor);
            }

            actor.SpecialName = "NavLineDebuger";
            world.AddActor(actor);
            world.DefaultScene.AddActor(actor);
        }