示例#1
0
        public void GenerateVisualAIMesh()
        {
            if (aimesh != null)
            {
                int index = 0;
                foreach (var vertexData in aimesh.AIMeshVertexData)
                {
                    AIMeshVertex visualVertex = new AIMeshVertex();
                    visualVertex.Position = vertexData;
                    Entity    visualAIMeshVertexEnt       = scm.CreateEntity("AIMESH_VERTEX_ENT_" + index, "marker_vertex.mesh");
                    SceneNode visualAIMeshVertexSceneNode = scm.RootSceneNode.CreateChildSceneNode("AIMESH_VERTEX_SCENENODE_" + index);
                    visualAIMeshVertexSceneNode.AttachObject(visualAIMeshVertexEnt);
                    visualAIMeshVertexSceneNode.Position = vertexData;
                    visualAIMeshVertexEnt.QueryFlags     = 1 << 0;
                    visualAIMeshVertexEnt.Visible        = true;
                    visualVertex.Mesh = visualAIMeshVertexEnt;
                    index++;
                }
                index = 0;
                foreach (var indexData in aimesh.AIMeshIndicsData)
                {
                    int lastVertexNumber = -1;
                    foreach (int vertexNumber in indexData.VertexNumber)
                    {
                        if (lastVertexNumber != -1)
                        {
                            Vector3 startVertexData = aimesh.AIMeshVertexData.ElementAt(lastVertexNumber - 1);
                            Vector3 endVertexData   = aimesh.AIMeshVertexData.ElementAt(vertexNumber - 1);
                            Vector3 startToEndVect  = new Vector3(
                                endVertexData.x - startVertexData.x,
                                endVertexData.y - startVertexData.y,
                                endVertexData.z - startVertexData.z
                                );
                            Vector3 centralVertexData = new Vector3(
                                (startVertexData.x - endVertexData.x) / 2,
                                (startVertexData.y - endVertexData.y) / 2,
                                (startVertexData.z - endVertexData.z) / 2
                                );

                            AIMeshEdge visualEdge = new AIMeshEdge();
                            visualEdge.Position = centralVertexData;
                            Entity visualAIMeshLineEnt = map.CreateEntityWithMaterial(
                                "AIMESH_LINE_ENT_" + Guid.NewGuid().ToString(),
                                "marker_line.mesh",
                                "marker_line"
                                );
                            SceneNode visualAIMeshLineSceneNode = scm.RootSceneNode.CreateChildSceneNode("AIMESH_LINE_SCENENODE_" + index);
                            visualAIMeshLineSceneNode.AttachObject(visualAIMeshLineEnt);
                            visualAIMeshLineSceneNode.Position = centralVertexData;
                            Radian angle = Mogre.Math.ACos(startToEndVect.DotProduct(Vector3.UNIT_Z) / startToEndVect.Normalise());
                            visualAIMeshLineSceneNode.Rotate(Vector3.UNIT_Y, angle);
                            visualEdge.Mesh = visualAIMeshLineEnt;
                        }
                        lastVertexNumber = vertexNumber;
                        index++;
                    }
                }
            }
        }
示例#2
0
        public Entity AddNewAIMeshVertex(Vector3 newVertexPos)
        {
            AIMeshVertex newVertex = new AIMeshVertex();

            newVertex.Position = newVertexPos;
            aimesh.AIMeshVertics.Add(newVertex);
            Entity    visualAIMeshVertexEnt       = scm.CreateEntity("AIMESH_VERTEX_ENT_" + Guid.NewGuid().ToString(), "marker_vertex.mesh");
            SceneNode visualAIMeshVertexSceneNode = scm.RootSceneNode.CreateChildSceneNode("AIMESH_VERTEX_SCENENODE_" + Guid.NewGuid().ToString());

            visualAIMeshVertexSceneNode.AttachObject(visualAIMeshVertexEnt);
            visualAIMeshVertexSceneNode.Position = newVertexPos;
            visualAIMeshVertexEnt.QueryFlags     = 1 << 0;
            newVertex.Mesh = visualAIMeshVertexEnt;
            return(visualAIMeshVertexEnt);
        }
示例#3
0
 public void Connect(AIMeshVertex vertex1, AIMeshVertex vertex2)
 {
     this.vertex1 = vertex1;
     this.vertex2 = vertex2;
 }
示例#4
0
 public AIMeshEdge(AIMeshVertex vertex1, AIMeshVertex vertex2)
 {
     this.vertex1 = vertex1;
     this.vertex2 = vertex2;
 }
示例#5
0
 public AIMeshEdge()
 {
     vertex1 = null;
     vertex2 = null;
 }