A method and apparatus for constructing game scenes
By performing raster scanning and bounding box algorithms on map tile data, the problem of being unable to generate complex buildings and conduct efficient collision tests in existing technologies has been solved, enabling the rapid construction of realistic and efficient game scenes.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2022-08-26
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies cannot generate complex building models or perform high-performance collision tests, resulting in unrealistic and inefficient game scene construction.
By acquiring map tile data and performing raster scanning, rasterized land cover data is generated. Game scene elements, including buildings and vegetation, are then placed based on the land cover data. The placement of building elements is determined using a bounding box algorithm, and vegetation areas are randomly generated and jittered to achieve rapid construction of game scenes.
It enables the rapid construction of complex game scenes, avoids the phenomenon of buildings clipping through each other, and can perform high-performance collision testing, thereby improving the realism of game scenes and construction efficiency.
Smart Images

Figure CN115364480B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of game technology, and in particular to a method and apparatus for constructing game scenes. Background Technology
[0002] In the gaming industry, game scene construction is an essential step. Current game scene construction is based on vector map tiles to obtain 2D screen building meshes, which are then stretched, textured, etc., to finally generate buildings and thus construct virtual game scenes. This method has the following problems: (1) It only generates simple, square building models, and because it cannot obtain building meshes for complex buildings, it is not suitable for generating complex buildings; (2) It cannot perform high-performance collision testing. Summary of the Invention
[0003] In view of the above problems, a method and apparatus for constructing a game scene are proposed to overcome or at least partially solve the above problems, comprising:
[0004] A method for constructing a game scene, the method comprising:
[0005] Obtain map tile data generated based on preset map data;
[0006] The map tile data is rasterized to obtain rasterized land cover data;
[0007] Pre-set game scene elements are placed based on the land cover data to construct the game scene.
[0008] Optionally, the surface cover data includes building layer data, the game scene elements include building elements, and the placement of preset game scene elements according to the surface attribute layer data includes:
[0009] Determine the target bounding box within one or more building bounding boxes of the building layer data;
[0010] Determine the target building element to be placed into the target bounding box;
[0011] Determine whether the target building element can be placed in the target bounding box based on the raster data of the target bounding box;
[0012] When it is determined that the target bounding box can hold the target building element, the target building element is placed in the target bounding box.
[0013] Optionally, determining the target building element to be placed into the target bounding box includes:
[0014] Determine the model bounding box of the pre-defined candidate building elements;
[0015] When the model bounding box and the target bounding box are successfully matched, the candidate building element is determined as the target building element to be placed into the target bounding box.
[0016] Optionally, the land cover data includes vegetation layer data, the game scene elements include vegetation elements, and the placement of preset game scene elements according to the land attribute layer data includes:
[0017] The first vegetation zone is determined based on the vegetation layer data;
[0018] Based on the first vegetation zone, a second vegetation zone is randomly generated;
[0019] The target vegetation area is obtained based on the first vegetation area and the second vegetation area;
[0020] Place pre-set vegetation elements in the target vegetation area.
[0021] Optionally, placing pre-set vegetation elements in the target vegetation area includes:
[0022] Determine the location information of the target vegetation area;
[0023] The location information is used to perform jitter processing to generate a location matrix;
[0024] Obtain the randomly generated rotation and scaling matrices;
[0025] Based on the position matrix, rotation matrix, and scaling matrix, generate the target matrix;
[0026] Arrange the pre-set vegetation elements according to the target matrix.
[0027] Optionally, it also includes:
[0028] When a virtual character moves in the game scene, determine the position to be moved by the virtual character;
[0029] The virtual character is moved according to the game scene elements placed at the location to be moved.
[0030] Optionally, the step of placing pre-set game scene elements according to the land cover data to construct a game scene includes:
[0031] Determine the first land cover data and the second land cover data from the land cover data;
[0032] Based on the first land cover data and the second land cover data, generate target land cover data;
[0033] Pre-set game scene elements are placed according to the target land cover data to construct the game scene.
[0034] Optionally, the land cover data may further include any one or more of the following:
[0035] Road layer data, water layer data.
[0036] A device for constructing a game scene, the device comprising:
[0037] The map tile data acquisition module is used to acquire map tile data generated based on preset map data;
[0038] The land cover data determination module is used to perform raster scanning on the map tile data to obtain rasterized land cover data;
[0039] The game scene construction module is used to place pre-set game scene elements according to the land cover data to construct the game scene.
[0040] A server includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the method for constructing a game scene as described above.
[0041] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the method for constructing a game scene as described above.
[0042] The embodiments of the present invention have the following advantages:
[0043] This invention, through obtaining map tile data generated based on pre-set map data, allows for raster scanning of the map tile data to obtain rasterized land cover data. This data can then be used to construct game scenes based on pre-set game scene elements within the land cover data. This enables rapid construction of game scenes from rasterized land cover data, allowing for the placement of complex game scene elements, such as irregular ancient buildings, and the rapid acquisition of game scene elements within the constructed scene, thereby achieving high-performance collision testing.
[0044] Furthermore, by scanning the bounding boxes of the building layer data, it is determined whether building elements already exist in the bounding boxes, thus avoiding clipping issues when directly creating buildings by raising them, and constructing suitable game scenes.
[0045] Furthermore, by obtaining rasterized ground cover data, vegetation can be placed based on vegetation layer data, making the game scene more realistic. Attached Figure Description
[0046] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0047] Figure 1a This is a flowchart illustrating the steps of a method for constructing a game scene according to an embodiment of the present invention;
[0048] Figure 1b This is a schematic diagram of a map tile provided in an embodiment of the present invention;
[0049] Figure 1c This is a schematic diagram of multiple grating layers on the same slice provided in an embodiment of the present invention;
[0050] Figure 1d This is a schematic diagram of raster data of map tile data provided in an embodiment of the present invention;
[0051] Figure 1e This is a rasterization process provided in one embodiment of the present invention;
[0052] Figure 2a This is a flowchart of the steps of another method for constructing a game scene according to an embodiment of the present invention;
[0053] Figure 2b This is a schematic diagram of bitwise operations for a query operation provided in an embodiment of the present invention;
[0054] Figure 3a This is a flowchart of the steps of another method for constructing a game scene according to an embodiment of the present invention;
[0055] Figure 3b This is a schematic diagram of a first vegetation zone provided in an embodiment of the present invention;
[0056] Figure 4 This is a flowchart of the steps of another method for constructing a game scene according to an embodiment of the present invention;
[0057] Figure 5 This is a schematic diagram of the structure of a game scene construction device provided in an embodiment of the present invention. Detailed Implementation
[0058] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0059] The following describes the terms used in the embodiments of this invention:
[0060] A game scene is a virtual game scene displayed (or provided) when an application runs on a terminal (mobile device, PC, cloud, etc.). This virtual game scene can be a simulation environment of the real world, a semi-simulated and semi-fictional environment, or a purely fictional environment. In this embodiment of the invention, a three-dimensional virtual game scene is used as an example for illustration.
[0061] Game scene elements are the people and objects in the game scene, such as game characters, ground, sky, water, mountains, flowers, grass, trees, stones, birds, beasts, insects, fish, vehicles, houses, etc. In this embodiment of the invention, these scene elements can refer to building elements, vegetation elements, road elements, water elements, etc.
[0062] Reference Figure 1a The diagram illustrates a flowchart of a method for constructing a game scene according to an embodiment of the present invention, which may specifically include the following steps:
[0063] Step 101: Obtain map tile data generated based on preset map data;
[0064] The preset map data can be real map data or pre-built virtual game map data.
[0065] When building a new game scene, pre-set map data can be obtained, and game map construction can begin based on this data. To quickly build the game scene, the map data can be segmented to obtain smaller map tile data. Specifically, the real map data can be unfolded into a planar map and then divided horizontally and vertically, with each tile being a block. Each tile stores three types of geometric information: points, lines, and polygons.
[0066] like Figure 1bThe diagram illustrates the process of tiling based on real map data. In level 1, the unfolded map is divided into four tiles numbered 0, 1, 2, and 3. In level 2, each tile is further divided into four smaller tiles. For example, tile numbered "2" in level 1 is divided into four tiles numbered 20, 21, 22, and 23 in level 2. In level 3, each tile is again divided into four smaller tiles. For example, tile numbered "13" in level 2 is divided into four tiles numbered 130, 131, 132, and 133 in level 3.
[0067] Step 102: Perform raster scanning on the map tile data to obtain rasterized land cover data;
[0068] In one embodiment of the present invention, the land cover data may include any one or more of the following: building layer data, vegetation layer data, water layer data, and road layer data.
[0069] After obtaining map tile data, raster scanning can be performed on the map tile data to obtain the corresponding rasterized land cover data according to the land cover objects in the preset map data. Rasterization is a process of converting geometric primitives into a two-dimensional image, that is, rasterizing geometric units (points, lines, and surfaces) onto a two-dimensional image.
[0070] In practical applications, pre-set map data can contain various land cover types, so after rasterization, each map tile data can obtain multiple raster layers, such as... Figure 1c The image shows the land cover data obtained after rasterizing the same map tile data. From left to right, the raster layers are building layer data, vegetation layer data, road layer data, and water layer data.
[0071] In one example, the map tile data of a raster layer can be constructed into a uint64 Buffer[4]
[256] data structure, that is, in each map tile data, each row contains 4 64-bit uint64 bytes, for a total of 256 rows, such as Figure 1d As shown.
[0072] like Figure 1e The triangle in the buffer can represent the area where a building is located in the preset map data. So, the positions of the three points of this triangle in the buffer are calculated first. Then, scan lines are obtained through the scan line algorithm. The scan line is ORed with the uint64 corresponding to the buffer, which is equivalent to rasterizing this row. This process is also the bit operation of the write operation.
[0073] In one example, the rasterization process in this invention can specifically be a soft raster scanning process. Soft raster refers to the rasterization process performed on the CPU side. Performing soft raster scanning can improve rasterization efficiency.
[0074] In this embodiment of the invention, the rasterization process for each map tile data can be completed in just 5-10ms, which can effectively reduce the performance pressure on the client and thus enable the 3D game scene to be displayed faster.
[0075] Step 103: Place the pre-set game scene elements according to the land cover data to construct the game scene.
[0076] After obtaining the land cover data, pre-set game scene elements can be placed according to the land cover data. For example, pre-set building elements can be placed according to the building layer data, water elements according to the water layer data, road elements according to the road layer data, and vegetation elements according to the vegetation layer data.
[0077] In practical applications, the process of arranging pre-defined game scene elements is actually the process of writing a game scene element into a raster layer via a write operation. After writing, the raster data is updated to obtain the raster layer data after arranging the game scene elements. This raster layer data can then be used to arrange other game scene elements or to conduct collision tests on virtual characters.
[0078] It should be noted that when placing game scene elements, different placement rules can be set according to the nature of different game scene elements, and the game scene elements can be placed according to the rules to construct a reasonable game scene. The placement rules may include the placement order of game scene elements, the area setting rules for different game scene elements, etc.
[0079] In one embodiment of the present invention, the land cover data includes first land cover data and second land cover data, and step 103 may include the following sub-steps:
[0080] Sub-step 1031: Determine the first land cover data and the second land cover data from the land cover data;
[0081] The first land cover data and the second land cover data can be any one or more of the following:
[0082] Building layer data, vegetation layer data, road layer data, and water layer data.
[0083] Sub-step 1032: Generate target land cover data based on the first land cover data and the second land cover data;
[0084] The target land cover data can be any of the following:
[0085] Building layer data, vegetation layer data, road layer data, and water layer data.
[0086] Sub-step 1033: Place preset game scene elements according to the target surface cover data to construct a game scene.
[0087] In practical applications, after rasterizing map tiles, multiple rasterized land cover data can be obtained. Game scene elements can be placed directly according to each rasterized land cover data, or new raster layer data can be generated by performing OR and / or NOT operations on multiple rasterized land cover data, and game scene elements can be placed according to the new raster layer data to construct the game scene.
[0088] The process of generating a new raster layer (i.e., target land cover data) can be specifically as follows: First land cover data and second land cover data are determined from the rasterized land cover data. OR and / or NOT operations are performed on the first and second land cover data to generate the target land cover data. After generating the new target land cover data, preset game scene elements can be placed; for example, if the generated target land cover data is building layer data, building elements are placed; if the generated target land cover data is vegetation, vegetation elements are placed, and so on.
[0089] It should be noted that the process of placing pre-set game scene elements based on the target land cover data can refer to the process of placing pre-set game scene elements directly according to the land cover data.
[0090] In practical applications, after obtaining multiple layers of raster data (such as buildings, vegetation, water, and roads) (land cover data), the raster data of each layer can be freely combined to create the new raster layer required.
[0091] For example, water layer data and building layer data can be merged into a new raster layer, which can be used as a basis for determining whether a virtual character is unwalkable, i.e., for conducting collision tests on virtual characters in game scenes.
[0092] For example, when you need to place game scene elements in an empty area on a map, you can perform an OR operation on all the raster layer data and then perform a NOT operation to obtain the raster layer data corresponding to the empty area.
[0093] For example, when you need to place game scene elements in the areas where vegetation and open space are located on the map, you can perform an OR operation on the building layer data, water layer data, and road layer data, and then perform a NOT operation to obtain the raster layer data formed by vegetation and open space.
[0094] In practical applications, 2D building grids can be obtained from vector map tiles of a map, which can then be stretched and textured to generate buildings. On this basis, vegetation, water, roads, etc. can be added one by one in non-building areas, which requires a lot of time to build the game scene.
[0095] In this embodiment of the invention, game scene elements can be placed according to rasterized ground cover data, thereby enabling faster placement of game scene elements to quickly construct game scenes. Furthermore, new raster layer data can be quickly generated by combining and calculating multiple raster layers according to user needs, thereby rapidly constructing more diverse game scenes.
[0096] In this embodiment of the invention, map tile data generated based on preset map data is obtained, and the map tile data can be rasterized to obtain rasterized land cover data. Then, game scene elements preset based on the land cover data can be used to construct a game scene. This realizes the construction of a game scene based on rasterized land cover data, which means that complex game scene elements can be placed and complex buildings can be set in the scene. It also allows for the rapid acquisition of game scene elements in the constructed game scene, thereby achieving high-performance collision testing.
[0097] Reference Figure 2a The diagram illustrates a flowchart of another method for constructing a game scene according to an embodiment of the present invention, which may specifically include the following steps:
[0098] Step 201: Obtain map tile data generated based on preset map data;
[0099] Step 202: Perform raster scanning on the map tile data to obtain rasterized land cover data; the land cover data includes building layer data, and the game scene elements include building elements;
[0100] Step 203: Determine the target bounding box within one or more building bounding boxes of the building layer data;
[0101] Bounding box algorithms are used to find the optimal bounding space for a discrete set of points. They approximate complex geometric objects by using a slightly larger, simpler geometric shape (called a bounding box). Bounding box algorithms can include AABB (Axis-aligned bounding box), bounding spheres, oriented bounding boxes, and fixed-direction convex hulls, etc. In this embodiment of the invention, an AABB bounding box is used as an example to explain the placement process of building elements.
[0102] After obtaining the building layer data, the building layer data can be composed of one or more building bounding boxes, each bounding box corresponding to a real building in the preset map data.
[0103] When placing buildings, you can select the target bounding box of the building to be placed from multiple building bounding boxes.
[0104] Step 204: Determine the target building element to be placed into the target bounding box;
[0105] After determining the target bounding box, you can select the target building element to be placed into the target bounding box from the preset building elements, that is, the target building element matches the target bounding box.
[0106] In one embodiment of the present invention, step 204 may specifically include the following sub-steps:
[0107] Sub-step 2041: Determine the model bounding box of the pre-set candidate building elements;
[0108] In practical applications, candidate building elements (i.e. building models) of different sizes and shapes can be pre-designed, and a corresponding two-dimensional model bounding box can be obtained for each candidate building element.
[0109] By pre-setting building elements, complex architectural elements, such as irregular ancient buildings, can be constructed in the game scene.
[0110] Sub-step 2042: When the model bounding box and the target bounding box are successfully matched, the candidate building element is determined as the target building element to be placed into the target bounding box.
[0111] After obtaining the 2D model bounding box, the target bounding box can be matched with the model bounding box. During the matching process, the target bounding box can be rotated to facilitate the matching between the bounding boxes. When the length and width of the bottom of the model bounding box are both less than or equal to the length and width of the target bounding box to be placed, the model bounding box and the target bounding box are successfully matched.
[0112] When the model bounding box successfully matches the target bounding box, the candidate bounding box corresponding to the target bounding box is determined as the target building element to be placed into the target bounding box. In other words, the target building element can theoretically be placed into the target bounding box.
[0113] In one example, target candidate elements can be determined by matching bounding boxes from candidate building elements. In this process, the degree of matching can be further set, such as determining the degree of matching between the model bounding box and the target bounding box based on the difference in length and width between them. The smaller the difference, the higher the degree of matching between the target bounding box and the model bounding box. Thus, the target building element that best matches the target bounding box can be determined.
[0114] Step 205: Determine whether the target building element can be placed in the target bounding box based on the raster data of the target bounding box;
[0115] The target bounding box is scanned, and combined with the raster data of the target bounding box, it is further determined whether the target bounding box can actually hold the target building elements.
[0116] For example, the target bounding box is scanned, and the scan lines traverse each Y value (Xmin~Xmax) of the target bounding box. The scan result is then ANDed with the raster data of the target bounding box. If the result is true (both the corresponding raster values in the scan result and raster data are 1), it means that a building element has already been placed along this scan line, and no other building elements can be placed. Otherwise, if all scan lines of the target bounding box pass the test, it can be determined that the target bounding box can be used to place building elements. Therefore, the target building elements to be placed are written into this buffer (raster data), such as... Figure 2b As shown in the figure, the triangle represents the target building element to be placed. The target bounding box is scanned by the scan line, and an AND operation is performed (i.e., the bitwise operation of the query operation). Based on the operation result, it can be determined that the target building element cannot be placed in the target bounding box.
[0117] Step 206: When it is determined that the target bounding box can hold the target building element, place the target building element in the target bounding box.
[0118] In one example, when a building is placed for the first time, none of the bounding boxes in the building layer data contain any building elements. Therefore, once the target bounding box is determined, the target building element can be placed directly into the target bounding box.
[0119] When placing a building is not the first time, some bounding boxes in the building layer data have already been filled with buildings. Therefore, after determining the target bounding box and the target building element, it is possible to further determine whether the target bounding box can hold the target building element. If it is determined that the target bounding box can hold the target building element, the target building element is placed, thereby avoiding the phenomenon of building clipping.
[0120] In one example, when a building element has already been placed in the target bounding box, it can also be determined that the target bounding box can be used to place the target building element when it is determined that the area where no building has been placed can be used to place the target building element.
[0121] In this embodiment of the invention, map tile data generated based on preset map data is obtained, and then the map tile data can be rasterized to obtain rasterized land cover data. Building elements are then placed according to the land cover data. By rasterizing the building bounding box before placing the target building element, it is determined whether the building bounding box can hold the building element, thus avoiding clipping when placing building elements.
[0122] Reference Figure 3a The diagram illustrates a flowchart of another method for constructing a game scene according to an embodiment of the present invention, which may specifically include the following steps:
[0123] Step 301: Obtain map tile data generated based on preset map data;
[0124] Step 302: Perform raster scanning on the map tile data to obtain rasterized land cover data; the land cover data includes vegetation layer data, and the game scene elements include vegetation elements;
[0125] In one embodiment of the present invention, the land cover data further includes any one or more of the following:
[0126] Road layer data, water layer data.
[0127] Step 303: Determine the first vegetation zone based on the vegetation layer data;
[0128] Vegetation layer data is determined from the obtained land cover data. The vegetation layer data is generated based on the areas covered by flowers, grasses and trees in the preset map data.
[0129] After determining the vegetation layer data, the first vegetation zone is determined based on the vegetation layer data. This can be done either by directly using the vegetation layer data as the first vegetation zone, or by combining it with other land cover data.
[0130] For example, in practical applications, different game scene elements have different placement orders. Usually, the building layer is placed first, followed by the water layer, the road layer, and finally the vegetation layer. After placing the building elements, water elements, and road elements in this order, the vegetation layer can be generated based on the previously placed game scene elements during the placement of vegetation elements.
[0131] Specifically, the building area, the non-vegetated road area, and the non-vegetated water area are all non-vegetated areas. Therefore, the operation "building|((~grass)&road)|((~grass)&water)" can be performed on the Buffer to obtain a new Buffer layer. Here, "building" can represent building layer data, "grass" can represent vegetation layer data, "road" can represent road layer data, and "water" can represent water layer data. Figure 3b As shown in the diagram, the white areas represent areas where vegetation cannot be planted in theory, and the black areas represent areas where vegetation can be planted in theory.
[0132] Step 304: Based on the first vegetation zone, randomly generate a second vegetation zone;
[0133] After obtaining the first vegetation zone, a second vegetation zone can be randomly generated based on the first vegetation zone.
[0134] Step 305: Obtain the target vegetation area based on the first vegetation area and the second vegetation area;
[0135] After obtaining the first and second vegetation areas, we can further determine the overlapping area between the first and second vegetation areas. This overlapping vegetation area is used as the target vegetation area for placing vegetation in the actual game scene. By randomly selecting another second vegetation area, we can effectively avoid filling the entire area with vegetation, thus making the final game scene visually better.
[0136] Step 306: Place the pre-set vegetation elements in the target vegetation area.
[0137] After determining the target vegetation area, the pre-set vegetation elements can be placed according to the target vegetation area, that is, the vegetation elements are instantiated.
[0138] In one embodiment of the present invention, step 306 may include the following sub-steps:
[0139] Sub-step 3061: Determine the location information of the target vegetation area;
[0140] In practical applications, after the target vegetation area is determined, the target vegetation area is composed of grids (i.e., 1 bit). During the placement of vegetation, the vegetation can be placed in the center of the grid by default. Moreover, the vegetation placed in each grid is of a fixed size and shape.
[0141] To achieve better vegetation effects, the location information of the target vegetation area can be determined first, that is, the location information of each grid in the target vegetation area can be determined, wherein the center coordinates of each grid are used as the location information of the grid.
[0142] Sub-step 3062: Perform jitter processing based on the position information to generate a position matrix;
[0143] After determining the location information, the obtained location information can be jittered according to a preset jitter level, so that the location information is randomly offset from the center position, and a location matrix is generated based on the jittered location information.
[0144] By using jittering, the location of vegetation in the grid is randomly distributed during instantiation.
[0145] Sub-step 3063: Obtain the randomly generated rotation matrix and scaling matrix;
[0146] Rotation matrices can be used to control the angle of vegetation. By using random rotation matrices, vegetation with different angles can be obtained, making the vegetation morphology more diverse.
[0147] Scaling matrices can be used to control the size of vegetation. By using random placement matrices, vegetation of different sizes can be obtained, making the vegetation morphology more diverse.
[0148] Sub-step 3064: Generate the target matrix based on the position matrix, rotation matrix, and scaling matrix;
[0149] Having obtained the position matrix, rotation matrix, and scaling matrix, a target matrix can be generated based on these three matrices. In the target matrix, each grid cell can contain position information, rotation information, and scaling information.
[0150] Sub-step 3065: Arrange the preset vegetation elements according to the target matrix.
[0151] After determining the target matrix, each grid cell is instantiated according to the target matrix, that is, the preset vegetation elements are placed.
[0152] In one example, during the placement process, instantiation can be performed on a grid-by-grid basis, or each map tile data can be divided into n×n blocks, and the information in each block can be encapsulated into a whole data set for instantiation, which improves the instantiation speed.
[0153] In this embodiment of the invention, map tile data generated based on preset map data is obtained, and then the map tile data can be rasterized to obtain rasterized land cover data. Then, vegetation elements are placed according to the land cover data, thus realizing the placement of vegetation elements in the game scene.
[0154] Reference Figure 4 The diagram illustrates a flowchart of another method for constructing a game scene according to an embodiment of the present invention, which may specifically include the following steps:
[0155] Step 401: Obtain map tile data generated based on preset map data;
[0156] Step 402: Perform raster scanning on the map tile data to obtain rasterized land cover data;
[0157] Step 403: Place the pre-set game scene elements according to the land cover data to construct the game scene.
[0158] Step 404: When the virtual character moves in the game scene, determine the position to be moved by the virtual character;
[0159] During actual gameplay, when a virtual character moves within the game scene, a collision test is required to determine if the character can move. For example, if the virtual character needs to move to a building location, a collision will occur, and the character cannot move to that location. However, if the virtual character moves to a road location, there will be no collision, and the character can move to that location.
[0160] After the game scene is constructed, the surface cover data of each layer in the game scene is updated according to the game scene elements placed on the grid.
[0161] When a virtual character moves in the game scene, the position to be moved can be determined so that a collision test can be performed based on the position to be moved. The collision test can include point collision, triangle collision and rectangle collision.
[0162] Step 405: Control the movement of the virtual character according to the game scene elements placed at the location to be moved.
[0163] When determining the location to be moved, a query operation is performed on the location to determine the game scene elements placed at the location, and then the query character is determined to move to the location based on the game scene elements.
[0164] In one example, when performing a collision test, if the object to be tested is treated as a point, it is a point collision; if the object to be tested is treated as a triangle, it is a triangle collision; and if the object to be tested is treated as a rectangle, it is a rectangle collision.
[0165] Taking a rectangular collision as an example, the region where the rectangle is located can be determined, the region can be scanned, the scanned data can be ANDed with the raster data of each layer in the region, the raster layer whose operation result is true can be determined, the game scene elements can be determined based on the raster layer, and then the virtual character can be moved based on the game scene elements.
[0166] In practical applications, for an already generated game scene, a new raster layer can be synthesized based on multiple raster layers of the game scene for collision testing. For example, building layer data and water layer data can be merged to obtain new raster layer data. Collision testing is then performed on the virtual character based on the new raster layer data, i.e., bitwise operations are performed for query operations, thereby determining whether the virtual character can move.
[0167] In this embodiment of the invention, after placing game scene elements according to rasterized ground cover data, a game scene is constructed. When the virtual character moves in the game scene, clipping is avoided, and high-performance collision testing can be performed.
[0168] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0169] Reference Figure 5 The diagram shows a structural schematic of a game scene construction device according to an embodiment of the present invention, which may specifically include the following modules:
[0170] The map tile data acquisition module 501 is used to acquire map tile data generated based on preset map data;
[0171] The land cover data determination module 502 is used to perform raster scanning on the map tile data to obtain rasterized land cover data;
[0172] The game scene construction module 503 is used to place preset game scene elements according to the land cover data to construct a game scene.
[0173] In one embodiment of the present invention, the land cover data includes building layer data, the game scene elements include building elements, and the game scene construction module 503 may include:
[0174] The target bounding box determination submodule is used to determine the target bounding box in one or more building bounding boxes of the building layer data;
[0175] The target building element determination submodule is used to determine the target building elements to be placed into the target bounding box;
[0176] The judgment submodule is used to determine whether the target building element can be placed in the target bounding box based on the raster data of the target bounding box.
[0177] The building placement submodule is used to place the target building element in the target bounding box when it is determined that the target bounding box can hold the target building element.
[0178] In one embodiment of the present invention, the building placement submodule may include:
[0179] Model bounding box determination unit, used to determine the model bounding box of a pre-defined candidate building element;
[0180] The placement unit is used to determine the candidate building element as the target building element to be placed into the target bounding box when the model bounding box and the target bounding box are successfully matched.
[0181] In one embodiment of the present invention, the land cover data includes vegetation layer data, the game scene elements include vegetation elements, and the game scene construction module 503 may further include:
[0182] The first vegetation zone determination submodule is used to determine the first vegetation zone based on the vegetation layer data;
[0183] The random vegetation zone generation submodule is used to randomly generate a second vegetation zone based on the first vegetation zone;
[0184] The target vegetation area determination submodule is used to obtain the target vegetation area based on the first vegetation area and the second vegetation area;
[0185] The vegetation construction submodule is used to place pre-set vegetation elements in the target vegetation area.
[0186] In one embodiment of the present invention, the vegetation construction submodule may include:
[0187] Location information determination unit, used to determine the location information of the target vegetation area;
[0188] A jitter unit is used to perform jitter processing based on the position information to generate a position matrix;
[0189] Rotation and scaling units are used to obtain randomly generated rotation and scaling matrices;
[0190] The target matrix determination unit is used to generate a target matrix based on the position matrix, rotation matrix, and scaling matrix;
[0191] An instantiation unit is used to place preset vegetation elements according to the target matrix.
[0192] In one embodiment of the present invention, the device may include:
[0193] The module for determining the position to be moved is used to determine the position to be moved of the virtual character when the virtual character moves in the game scene.
[0194] The collision test module is used to control the movement of the virtual character based on the game scene elements placed at the location to be moved.
[0195] In one embodiment of the present invention, the game scene construction module 503 may include:
[0196] A land cover data selection submodule is used to determine a first land cover data and a second land cover data from the land cover data;
[0197] The target land cover data generation submodule is used to generate target land cover data based on the first land cover data and the second land cover data;
[0198] The game scene construction submodule is used to place pre-set game scene elements according to the target surface coverage data to construct the game scene.
[0199] In one embodiment of the present invention, the land cover data further includes any one or more of the following:
[0200] Road layer data, water layer data.
[0201] In this embodiment of the invention, by acquiring map tile data generated based on preset map data, the map tile data can be rasterized to obtain rasterized land cover data. Then, preset game scene elements can be placed according to the land cover data to construct a game scene, thereby realizing rapid construction of game scenes and rapid acquisition of land surface attributes in the constructed game scene. This allows for high-performance collision testing of game characters in the game scene.
[0202] One embodiment of the present invention also provides a server, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the steps of the above-described game scene construction method.
[0203] An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the above-described method for constructing a game scene.
[0204] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0205] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0206] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0207] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, create means for implementing the functions specified in one or more blocks of the flowchart illustrations and / or one or more blocks of the block diagrams.
[0208] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0209] These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable terminal equipment, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0210] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.
[0211] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0212] The above provides a detailed description of a method and apparatus for constructing a game scene. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method of constructing a game scene, characterized by, The method includes: Obtain map tile data generated based on preset map data; The map tile data is rasterized to obtain rasterized land cover data; Based on the land cover data, pre-set game scene elements are placed to construct the game scene; The land cover data includes vegetation layer data, the game scene elements include vegetation elements, and the placement of pre-set game scene elements according to the land attribute layer data includes: The first vegetation zone is determined based on the vegetation layer data; Based on the first vegetation zone, a second vegetation zone is randomly generated; The target vegetation area is obtained based on the overlapping area between the first vegetation area and the second vegetation area; Place pre-set vegetation elements in the target vegetation area; The placement of pre-set vegetation elements in the target vegetation area includes: Determine the location information of the target vegetation area; The location information is used to perform jitter processing to generate a location matrix; Obtain the randomly generated rotation and scaling matrices; Based on the position matrix, rotation matrix, and scaling matrix, generate the target matrix; Arrange the pre-set vegetation elements according to the target matrix; Also includes: Multiple rasterized land cover data are combined and processed to generate new raster layer data; Based on the new raster layer data, pre-set game scene elements are placed to construct game scenes or conduct collision tests on virtual characters.
2. The method of claim 1, wherein, The land cover data includes building layer data, the game scene elements include building elements, and the placement of pre-set game scene elements according to the land attribute layer data includes: Determine the target bounding box within one or more building bounding boxes of the building layer data; Determine the target building element to be placed into the target bounding box; Determine whether the target building element can be placed in the target bounding box based on the raster data of the target bounding box; When it is determined that the target bounding box can hold the target building element, the target building element is placed in the target bounding box.
3. The method of claim 2, wherein, The process of determining the target building element to be placed into the target bounding box includes: Determine the model bounding box of the pre-defined candidate building elements; When the model bounding box and the target bounding box are successfully matched, the candidate building element is determined as the target building element to be placed into the target bounding box.
4. The method of claim 3, wherein, Also includes: When a virtual character moves in the game scene, determine the position to be moved by the virtual character; The virtual character is moved according to the game scene elements placed at the location to be moved.
5. The method according to claim 1 or 2 or 3, characterized in that, The step of placing pre-set game scene elements according to the land cover data to construct a game scene includes: Determine the first land cover data and the second land cover data from the land cover data; Based on the first land cover data and the second land cover data, generate target land cover data; Pre-set game scene elements are placed according to the target land cover data to construct the game scene.
6. The method of claim 1, wherein, The land cover data also includes any one or more of the following: Road layer data, water layer data.
7. A device for constructing a game scene, characterized in that, The device includes: The map tile data acquisition module is used to acquire map tile data generated based on preset map data; The land cover data determination module is used to perform raster scanning on the map tile data to obtain rasterized land cover data; The game scene construction module is used to place pre-set game scene elements according to the land cover data to construct the game scene; The land cover data includes vegetation layer data, the game scene elements include vegetation elements, and the game scene construction module includes: The first vegetation zone determination submodule is used to determine the first vegetation zone based on the vegetation layer data; The random vegetation zone generation submodule is used to randomly generate a second vegetation zone based on the first vegetation zone; The target vegetation area determination submodule is used to obtain the target vegetation area based on the first vegetation area and the second vegetation area; The vegetation construction submodule is used to place pre-set vegetation elements in the target vegetation area; The vegetation construction submodule includes: Location information determination unit, used to determine the location information of the target vegetation area; A jitter unit is used to perform jitter processing based on the position information to generate a position matrix; Rotation and scaling units are used to obtain randomly generated rotation and scaling matrices; The target matrix determination unit is used to generate a target matrix based on the position matrix, rotation matrix, and scaling matrix; An instantiation unit is used to place preset vegetation elements according to the target matrix; The device is also used to: combine and process multiple rasterized land cover data to generate new raster layer data; and place preset game scene elements based on the new raster layer data to construct a game scene or conduct collision tests on virtual characters.
8. A server, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the method for constructing a game scene as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the method for constructing a game scene as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Mesh object generation method and device
CN108171797A
Virtual model placing method and device
CN114782642A