コード例 #1
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);
        }
コード例 #2
0
        public async System.Threading.Tasks.Task InitGraphLines()
        {
            LinesGen.Interval   = 0.1f;
            LinesGen.Segement   = 0.2f;
            GraphLines.LinesGen = LinesGen;
            EngineNS.Graphics.CGfxMaterialInstance mtl = await EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(
                EngineNS.CEngine.Instance.RenderContext,
                EngineNS.RName.GetRName("editor/volume/mi_volume_octree.instmtl"));//rotator

            EngineNS.Vector3 p1 = Vector3.Lerp(CStartPos, CEndPos, 0.3f);
            p1.Y = p1.Y + 5.0f;

            EngineNS.Vector3 p2 = Vector3.Lerp(CStartPos, CEndPos, 0.7f);
            p2.Y = p1.Y;
            LinesGen.SetBezier3D(CStartPos, p1, p2, CEndPos, 100);

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

            //GraphLines.GraphActor.Placement.Location = EngineNS.Vector3.Zero;

            mLineMeshComponent = GraphLines.GraphActor.GetComponent <GamePlay.Component.GMeshComponent>();
        }
コード例 #3
0
        public async System.Threading.Tasks.Task InitGraphLines()
        {
            if (mIsInitGraphLines && mNeedInitGraphLines == false)
            {
                return;
            }

            mNeedInitGraphLines = false;

            LinesGen.Interval   = 0.1f;
            LinesGen.Segement   = 0.2f;
            GraphLines.LinesGen = LinesGen;
            var mtl = await EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(
                EngineNS.CEngine.Instance.RenderContext,
                EngineNS.RName.GetRName("editor/volume/mi_volume_octree.instmtl"));//rotator

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

            GraphLines.GraphActor.Placement.Location = EngineNS.Vector3.Zero;
            VP1.World.AddEditorActor(GraphLines.GraphActor);
            //VP1.World.DefaultScene.AddActor(GraphLines.GraphActor);

            mIsInitGraphLines = true;
        }
コード例 #4
0
        private async System.Threading.Tasks.Task UpdateSelected(List <int> verts)
        {
            var rc = EngineNS.CEngine.Instance.RenderContext;

            foreach (var i in VertActors)
            {
                mPreviewSceneControl.RemoveActor(i);
            }
            VertActors.Clear();

            SelectedVerts = verts;

            if (verts.Count == 0)
            {
                return;
            }

            float bvl  = this.mPreviewActor.GetComponentMesh(null).MeshPrimitives.AABB.GetMaxSide() / 20;
            var   size = new EngineNS.Vector3(bvl, bvl, bvl);
            var   mtl0 = await EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(rc, RName.GetRName("TitanDemo/greentest.instmtl"));

            var mtl1 = await EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(rc, RName.GetRName("TitanDemo/redtest.instmtl"));

            foreach (var i in verts)
            {
                var curVert = mProgressMesh.Vertices[i];
                var center  = curVert.Position;

                var mesh = await EngineNS.CEngine.Instance.MeshManager.CreateMeshAsync(rc, RName.GetRName("editor/basemesh/box_center.gms"));

                var actor = EngineNS.GamePlay.Actor.GActor.NewMeshActorDirect(mesh);
                actor.Placement.Location = center;
                actor.Placement.Scale    = size;
                actor.GetComponentMesh(null).SetMaterialInstance(rc, 0, mtl0, null);

                VertActors.Add(actor);
                mPreviewSceneControl.AddDynamicActor(actor);

                foreach (var j in curVert.Linker.Vertices)
                {
                    curVert = mProgressMesh.Vertices[j];
                    center  = curVert.Position;

                    mesh = await EngineNS.CEngine.Instance.MeshManager.CreateMeshAsync(rc, RName.GetRName("editor/basemesh/box_center.gms"));

                    actor = EngineNS.GamePlay.Actor.GActor.NewMeshActorDirect(mesh);
                    actor.Placement.Location = center;
                    actor.Placement.Scale    = size;
                    actor.GetComponentMesh(null).SetMaterialInstance(rc, 0, mtl1, null);

                    VertActors.Add(actor);
                    mPreviewSceneControl.AddDynamicActor(actor);
                }
            }

            if (mGraphLines == null || mGraphLines.GraphActor == null)
            {
                mGraphLines                   = new EngineNS.Bricks.GraphDrawer.GraphLines();
                mGraphLines.LinesGen          = mLineGen;
                mGraphLines.LinesGen.Interval = 0f;
                mGraphLines.LinesGen.Segement = 100f;
                RName lineMaterial = RName.GetRName("editor/icon/icon_3d/material/line_df.instmtl");

                var curVert = mProgressMesh.Vertices[verts[0]];
                var start   = curVert.Position;
                mGraphLines.LinesGen.Start = start;

                var lnkVerts = curVert.Linker.Vertices;
                var end      = mProgressMesh.Vertices[lnkVerts[0]];

                mLineGen.SetVector3Points(new Vector3[] { start, end.Position });
                var mtl = await EngineNS.CEngine.Instance.MaterialInstanceManager.GetMaterialInstanceAsync(
                    EngineNS.CEngine.Instance.RenderContext,
                    lineMaterial);

                await mGraphLines.Init(mtl, 0);

                mGraphLines.UpdateGeomMesh(CEngine.Instance.RenderContext, 0);
                mGraphLines.GraphActor.Placement.Location = Vector3.Zero;

                mPreviewSceneControl.AddDynamicActor(mGraphLines.GraphActor);
            }
            else
            {
                mGraphLines.GraphActor.Visible = verts.Count > 0;

                var curVert = mProgressMesh.Vertices[verts[0]];
                var start   = curVert.Position;
                mGraphLines.LinesGen.Start = start;

                var            lnkVerts = curVert.Linker.Vertices;
                List <Vector3> points   = new List <Vector3>();
                foreach (var i in verts)
                {
                    curVert = mProgressMesh.Vertices[i];
                    start   = curVert.Position;
                    foreach (var j in curVert.Linker.Vertices)
                    {
                        curVert = mProgressMesh.Vertices[j];
                        var end = curVert.Position;

                        points.Add(start);
                        points.Add(end);
                    }
                }

                mLineGen.SetVector3Points(points.ToArray());
                mGraphLines.UpdateGeomMesh(CEngine.Instance.RenderContext, bvl * 0.1f);
            }
        }