コード例 #1
0
        public PortalTemplate(XmlNode xmlNode)
        {
            int pixel_x     = Int32.Parse(xmlNode.Attributes["x"].Value);
            int pixel_y     = Int32.Parse(xmlNode.Attributes["y"].Value);
            int pixel_width =
                (xmlNode.Attributes["width"] != null)
                ? Int32.Parse(xmlNode.Attributes["width"].Value)
                : (int)GameConstants.TILE_PIXEL_SIZE;
            int pixel_height =
                (xmlNode.Attributes["height"] != null)
                ? Int32.Parse(xmlNode.Attributes["height"].Value)
                : (int)GameConstants.TILE_PIXEL_SIZE;

            Point3d position0 = GameConstants.ConvertPixelPositionToRoomPosition(pixel_x, pixel_y);
            Point3d position1 = GameConstants.ConvertPixelPositionToRoomPosition(pixel_x + pixel_width, pixel_y + pixel_height);

            portal_id = Int32.Parse(xmlNode.Attributes["id"].Value);

            bounding_box =
                new AABB3d(
                    Point3d.Min(position0, position1),
                    Point3d.Max(position0, position1));

            roomSide = (MathConstants.eSignedDirection)Enum.Parse(typeof(MathConstants.eSignedDirection), xmlNode.Attributes["Direction"].Value);

            portal_type = (ePortalType)Enum.Parse(typeof(ePortalType), xmlNode.Attributes["Type"].Value);
        }
コード例 #2
0
 public EnergyTankData()
 {
     energy_tank_id = -1;
     energy = 0;
     ownership = GameConstants.eFaction.neutral;
     position = new Point3d();
     boundingBox = new AABB3d();
     room_key = new RoomKey();
 }
コード例 #3
0
        public AABB3d bounding_box; // Room Relative

        public Portal()
        {
            portal_id        = -1;
            target_portal_id = -1;
            room_x           = 0;
            room_y           = 0;
            room_z           = 0;
            portal_type      = ePortalType.door;
            room_side        = MathConstants.eSignedDirection.positive_x;
            bounding_box     = new AABB3d();
        }
コード例 #4
0
ファイル: Portal.cs プロジェクト: ltloibrights/AsyncRPG
 public Portal()
 {
     portal_id= -1;
     target_portal_id = -1;
     room_x= 0;
     room_y= 0;
     room_z= 0;
     portal_type = ePortalType.door;
     room_side = MathConstants.eSignedDirection.positive_x;
     bounding_box = new AABB3d();
 }
コード例 #5
0
        public void AppendAABB(AABB3d aabb)
        {
            Point3d p0 = aabb.Min;
            Point3d p1 = aabb.Max;

            int start = vertices.Count + 1; // Vertex indices are 1-based, not 0-based

            vertices.Add(new Point3d(p0.x, p0.y, p0.z)); // 0
            vertices.Add(new Point3d(p1.x, p0.y, p0.z)); // 1
            vertices.Add(new Point3d(p1.x, p1.y, p0.z)); // 2
            vertices.Add(new Point3d(p0.x, p1.y, p0.z)); // 3
            vertices.Add(new Point3d(p0.x, p0.y, p1.z)); // 4
            vertices.Add(new Point3d(p1.x, p0.y, p1.z)); // 5
            vertices.Add(new Point3d(p1.x, p1.y, p1.z)); // 6
            vertices.Add(new Point3d(p0.x, p1.y, p1.z)); // 7

            faces.Add(new Face(start + 0, start + 1, start + 5, start + 4)); // -Y face
            faces.Add(new Face(start + 1, start + 2, start + 6, start + 5)); // +X face
            faces.Add(new Face(start + 2, start + 3, start + 7, start + 6)); // +Y face
            faces.Add(new Face(start + 3, start + 0, start + 4, start + 7)); // -X face
            faces.Add(new Face(start + 4, start + 5, start + 6, start + 7)); // +Z face
            faces.Add(new Face(start + 0, start + 3, start + 2, start + 1)); // -Z face
        }
コード例 #6
0
 public bool Equals(AABB3d other)
 {
     return(m_pMin.Equals(other.m_pMin) && m_pMax.Equals(other.m_pMax));
 }
コード例 #7
0
 public AABB3d(AABB3d other)
 {
     this.m_pMin = new Point3d(other.m_pMin);
     this.m_pMax = new Point3d(other.m_pMax);
 }
コード例 #8
0
 public AABB3d EncloseAABB(AABB3d other)
 {
     return(new AABB3d(Point3d.Min(m_pMin, other.m_pMin), Point3d.Max(m_pMax, other.m_pMax)));
 }
コード例 #9
0
ファイル: AABB3d.cs プロジェクト: ltloibrights/AsyncRPG
 public AABB3d(AABB3d other)
 {
     this.m_pMin = new Point3d(other.m_pMin);
     this.m_pMax = new Point3d(other.m_pMax);
 }
コード例 #10
0
ファイル: NavMesh.cs プロジェクト: ltloibrights/AsyncRPG
 public NavMesh()
 {
     m_roomKey = null;
     m_boundingBox = new AABB3d();
     m_rowCount = 0;
     m_colomnCount = 0;
     m_nonEmptyNavCellCount = 0;
     m_navCells = null;
     m_pvs = null;
 }
コード例 #11
0
        private void DumpLayoutGeometry(
            string dumpGeometryPath, 
            DungeonLayout layout)
        {
            GeometryFileWriter fileWriter = new GeometryFileWriter();
            string filename= string.Format("DungeonLayout_Game{0}_Size{1}", layout.GameID, layout.LayoutWorldTemplate.dungeon_size);
            string header = string.Format("DungeonLayout for GameID:{0} DungeonSize: {1}", layout.GameID, layout.LayoutWorldTemplate.dungeon_size);
            string result = SuccessMessages.GENERAL_SUCCESS;
            Vector3d roomSize = new Vector3d(WorldConstants.ROOM_X_SIZE, WorldConstants.ROOM_Y_SIZE, WorldConstants.ROOM_Z_SIZE);

            for (DungeonLayout.RoomIndexIterator iterator = new DungeonLayout.RoomIndexIterator(layout.RoomGrid);
                iterator.Valid;
                iterator.Next())
            {
                DungeonLayout.RoomIndex roomIndex = iterator.Current;
                Room room = layout.GetRoomByIndex(roomIndex);
                AABB3d roomAABB = new AABB3d(room.world_position, room.world_position + roomSize);
                AABB3d shrunkRoomAABB = roomAABB.ScaleAboutCenter(0.5f);
                AABB3d centerAABB = roomAABB.ScaleAboutCenter(0.05f);

                // Add the AABB for this room
                fileWriter.AppendAABB(shrunkRoomAABB);

                // Create portal AABBs to all adjacent rooms
                for (MathConstants.eSignedDirection roomSide = MathConstants.eSignedDirection.first;
                    roomSide < MathConstants.eSignedDirection.count;
                    ++roomSide)
                {
                    if (room.RoomHasPortalOnSide(roomSide))
                    {
                        DungeonLayout.RoomIndex neighborRoomIndex = null;
                        switch (roomSide)
                        {
                            case MathConstants.eSignedDirection.positive_x:
                                neighborRoomIndex = roomIndex.Offset(1, 0, 0);
                                break;
                            case MathConstants.eSignedDirection.negative_x:
                                neighborRoomIndex = roomIndex.Offset(-1, 0, 0);
                                break;
                            case MathConstants.eSignedDirection.positive_y:
                                neighborRoomIndex = roomIndex.Offset(0, 1, 0);
                                break;
                            case MathConstants.eSignedDirection.negative_y:
                                neighborRoomIndex = roomIndex.Offset(0, -1, 0);
                                break;
                            case MathConstants.eSignedDirection.positive_z:
                                neighborRoomIndex = roomIndex.Offset(0, 0, 1);
                                break;
                            case MathConstants.eSignedDirection.negative_z:
                                neighborRoomIndex = roomIndex.Offset(0, 0, -1);
                                break;
                        }

                        Room neighborRoom = layout.GetRoomByIndex(neighborRoomIndex);
                        AABB3d neighborRoomAABB = new AABB3d(neighborRoom.world_position, neighborRoom.world_position + roomSize);
                        AABB3d neighborCenterAABB = neighborRoomAABB.ScaleAboutCenter(0.05f);
                        AABB3d portalAABB = centerAABB.EncloseAABB(neighborCenterAABB);

                        fileWriter.AppendAABB(portalAABB);
                    }
                }

                // TODO: DumpLayoutGeometry: Color the rooms by teleporter pair
            }

            if (!fileWriter.SaveFile(dumpGeometryPath, filename, header, out result))
            {
                _logger.WriteLine("DungeonValidator: WARNING: Failed to save layout geometry file");
                _logger.WriteLine(result);
            }
        }
コード例 #12
0
ファイル: RoomPortal.cs プロジェクト: ltloibrights/AsyncRPG
 public RoomPortal()
 {
     portal_id = -1;
     target_portal_id = -1;
     boundingBox = new AABB3d();
 }
コード例 #13
0
 public EnvironmentObjectDefinition()
 {
     classifier = eEnvironmentObjectClassifier.invalid;
     bounding_box = new AABB3d();
 }
コード例 #14
0
ファイル: NavMesh.cs プロジェクト: ltloibrights/AsyncRPG
        private void NavCellsFromXML(XmlNode navMeshXml)
        {
            string[] navMeshStringRows = navMeshXml.InnerText.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            uint rowCount = (uint)navMeshStringRows.Length;
            uint colomnCount = (uint)navMeshStringRows[0].Length;

            // Compute derived room properties
            float roomWidth = (float)colomnCount * GameConstants.NAV_MESH_WORLD_UNITS_SIZE;
            float roomHeight = (float)rowCount * GameConstants.NAV_MESH_WORLD_UNITS_SIZE;
            BitArray navCellData = new BitArray((int)(rowCount * colomnCount));
            int navMeshDataIndex = 0;

            foreach (string rowString in navMeshStringRows)
            {
                foreach (char c in rowString)
                {
                    navCellData[navMeshDataIndex] = (c == '1');
                    ++navMeshDataIndex;
                }
            }

            m_colomnCount = colomnCount;
            m_rowCount = rowCount;
            m_nonEmptyNavCellCount = 0;
            m_roomKey = null;
            m_boundingBox = new AABB3d();
            m_boundingBox.SetBounds2d(-roomWidth / 2.0f, -roomHeight / 2.0f, roomWidth / 2.0f, roomHeight / 2.0f);

            NavMesh.BuildNavCellConnectivityGrid(
                colomnCount,
                rowCount,
                navCellData,
                out m_navCells,
                out m_nonEmptyNavCellCount);
        }
コード例 #15
0
ファイル: NavMesh.cs プロジェクト: ltloibrights/AsyncRPG
        private void NavCellsFromCompressedRawByteArray(
            byte[] compressedNavCells)
        {
            byte[] header = new byte[COMPRESSED_DATA_HEADER_BYTE_COUNT];
            byte[] uncompressed =
                CompressionUtilities.RunLengthDecodeByteArray(
                    compressedNavCells,
                    CompressionUtilities.eEncodeType.Zeros,
                    header);
            BitArray navCellData = new BitArray(uncompressed);

            // Read out the header
            Debug.Assert(COMPRESSED_DATA_HEADER_BYTE_COUNT == 2);
            uint colomnCount = (uint)header[0];
            uint rowCount = (uint)header[1];

            // Compute derived room properties
            int navCellCount = (int)(rowCount * colomnCount);
            float roomWidth = (float)colomnCount * GameConstants.NAV_MESH_WORLD_UNITS_SIZE;
            float roomHeight = (float)rowCount * GameConstants.NAV_MESH_WORLD_UNITS_SIZE;

            // Initialize the nav cell derived data
            m_colomnCount = colomnCount;
            m_rowCount = rowCount;
            m_nonEmptyNavCellCount = 0;
            m_roomKey = null;
            m_boundingBox = new AABB3d();
            m_boundingBox.SetBounds2d(-roomWidth / 2.0f, -roomHeight / 2.0f, roomWidth / 2.0f, roomHeight / 2.0f);

            // Truncate extra bits added due to the bit array getting rounded up to the nearest byte
            navCellData.Length = navCellCount;

            // Compute the connectivity data from the nav cell bit array
            NavMesh.BuildNavCellConnectivityGrid(
                colomnCount,
                rowCount,
                navCellData,
                out m_navCells,
                out m_nonEmptyNavCellCount);
        }
コード例 #16
0
ファイル: Portal.cs プロジェクト: ltloibrights/AsyncRPG
        public PortalTemplate(XmlNode xmlNode)
        {
            int pixel_x = Int32.Parse(xmlNode.Attributes["x"].Value);
            int pixel_y = Int32.Parse(xmlNode.Attributes["y"].Value);
            int pixel_width =
                (xmlNode.Attributes["width"] != null)
                ? Int32.Parse(xmlNode.Attributes["width"].Value)
                : (int)GameConstants.TILE_PIXEL_SIZE;
            int pixel_height =
                (xmlNode.Attributes["height"] != null)
                ? Int32.Parse(xmlNode.Attributes["height"].Value)
                : (int)GameConstants.TILE_PIXEL_SIZE;

            Point3d position0 = GameConstants.ConvertPixelPositionToRoomPosition(pixel_x, pixel_y);
            Point3d position1 = GameConstants.ConvertPixelPositionToRoomPosition(pixel_x + pixel_width, pixel_y + pixel_height);

            portal_id = Int32.Parse(xmlNode.Attributes["id"].Value);

            bounding_box =
                new AABB3d(
                    Point3d.Min(position0, position1),
                    Point3d.Max(position0, position1));

            roomSide = (MathConstants.eSignedDirection)Enum.Parse(typeof(MathConstants.eSignedDirection), xmlNode.Attributes["Direction"].Value);

            portal_type = (ePortalType)Enum.Parse(typeof(ePortalType), xmlNode.Attributes["Type"].Value);
        }
コード例 #17
0
ファイル: AABB3d.cs プロジェクト: ltloibrights/AsyncRPG
 public AABB3d EncloseAABB(AABB3d other)
 {
     return new AABB3d(Point3d.Min(m_pMin, other.m_pMin), Point3d.Max(m_pMax, other.m_pMax));
 }
コード例 #18
0
ファイル: AABB3d.cs プロジェクト: ltloibrights/AsyncRPG
 public bool Equals(AABB3d other)
 {
     return m_pMin.Equals(other.m_pMin) && m_pMax.Equals(other.m_pMax);
 }
コード例 #19
0
        public AABB3d bounding_box; // Object Relative

        public EnvironmentObjectDefinition()
        {
            classifier   = eEnvironmentObjectClassifier.invalid;
            bounding_box = new AABB3d();
        }
コード例 #20
0
ファイル: NavMesh.cs プロジェクト: ltloibrights/AsyncRPG
        public NavMesh(RoomKey roomKey, NavMesh navMeshTemplate)
        {
            m_roomKey = new RoomKey(roomKey);
            m_boundingBox = new AABB3d(navMeshTemplate.m_boundingBox);

            m_rowCount = navMeshTemplate.m_rowCount;
            m_colomnCount = navMeshTemplate.m_colomnCount;
            m_nonEmptyNavCellCount = navMeshTemplate.m_nonEmptyNavCellCount;

            m_navCells = new NavCell[navMeshTemplate.m_navCells.Length];
            Array.Copy(navMeshTemplate.m_navCells, m_navCells, m_navCells.Length);

            m_pvs = new PotentiallyVisibleSet(navMeshTemplate.m_pvs);
        }