CN115364480A - Game scene construction method and device - Google Patents

Game scene construction method and device Download PDF

Info

Publication number
CN115364480A
CN115364480A CN202211031592.4A CN202211031592A CN115364480A CN 115364480 A CN115364480 A CN 115364480A CN 202211031592 A CN202211031592 A CN 202211031592A CN 115364480 A CN115364480 A CN 115364480A
Authority
CN
China
Prior art keywords
data
game scene
target
vegetation
surface coverage
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211031592.4A
Other languages
Chinese (zh)
Inventor
林炎厚
唐忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202211031592.4A priority Critical patent/CN115364480A/en
Publication of CN115364480A publication Critical patent/CN115364480A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The embodiment of the invention provides a method and a device for constructing a game scene, wherein the method comprises the following steps: acquiring map slice data generated based on preset map data; raster scanning is carried out on the map slice data to obtain rasterized earth surface coverage data; and placing preset game scene elements according to the earth surface coverage data to construct a game scene. According to the embodiment of the invention, the game scene is constructed according to the rasterized earth surface coverage data, so that complex game scene elements such as irregular ancient buildings can be placed, the game scene elements in the constructed game scene can be rapidly acquired, and further, the high-performance collision test is realized.

Description

Game scene construction method and device
Technical Field
The invention relates to the technical field of games, in particular to a method and a device for constructing a game scene.
Background
In the field of games, game scene construction is an essential link. The current game scene construction is to obtain a building grid of a 2D screen based on vector map slicing, perform heightening processing, material pasting processing and the like, and finally generate a building, so as to construct a scene of a virtual game. In this method, there are the following problems: (1) Only a square and regular simple building model is generated, and the building grid of the complex building cannot be obtained, so that the method is not suitable for generating the complex building; (2) a high-performance collision test cannot be performed.
Disclosure of Invention
In view of the above, it is proposed to provide a method and apparatus for constructing a game scene that overcomes or at least partially solves the above problems, comprising:
a method of constructing a game scene, the method comprising:
acquiring map slice data generated based on preset map data;
raster scanning is carried out on the map slice data to obtain rasterized earth surface coverage data;
and placing preset game scene elements according to the earth surface coverage data to construct a game scene.
Optionally, the ground cover data includes building layer data, the game scene element includes a building element, and placing a preset game scene element according to the ground attribute layer data includes:
determining a target bounding box in one or more building bounding boxes of the building layer data;
determining a target building element to be placed in the target bounding box;
judging whether the target building elements can be placed in the target bounding box according to the grating data of the target bounding box;
and when the target bounding box is judged to be capable of placing the target building element, placing the target building element in the target bounding box.
Optionally, the determining a target building element to be placed in the target bounding box comprises:
determining a model bounding box of a preset candidate building element;
and when the model bounding box is successfully matched with the target bounding box, determining the candidate building elements as the target building elements to be placed in the target bounding box.
Optionally, the ground cover data includes vegetation layer data, the game scene element includes a vegetation element, and placing a preset game scene element according to the ground attribute layer data includes:
determining a first vegetation area according to the vegetation layer data;
randomly generating a second vegetation zone based on the first vegetation zone;
obtaining a target vegetation area according to the first vegetation area and the second vegetation area;
and placing preset vegetation elements in the target vegetation area.
Optionally, the placing of the preset vegetation elements in the target vegetation zone includes:
determining position information of a target vegetation area;
carrying out jitter processing according to the position information to generate a position matrix;
acquiring a randomly generated rotation matrix and a scaling matrix;
generating a target matrix based on the position matrix, the rotation matrix and the scaling matrix;
and placing preset vegetation elements according to the target matrix.
Optionally, the method further comprises:
when the virtual character moves in the game scene, determining the position to be moved of the virtual character;
and controlling the virtual character to move according to the game scene elements placed at the position to be moved.
Optionally, the placing preset game scene elements according to the ground surface coverage data to construct a game scene includes:
determining first and second surface coverage data from the surface coverage data;
generating target surface coverage data according to the first surface coverage data and the second surface coverage data;
and placing preset game scene elements according to the target earth surface coverage data to construct a game scene.
Optionally, the surface coverage data further comprises any one or more of:
road layer data and water layer data.
An apparatus for constructing a game scene, the apparatus comprising:
the map slice data acquisition module is used for acquiring map slice data generated based on preset map data;
the earth surface coverage data determining module is used for carrying out raster scanning on the map slice data to obtain rasterized earth surface coverage data;
and the game scene construction module is used for placing preset game scene elements according to the earth surface coverage data so as to construct a game scene.
A server comprising a processor, a memory and a computer program stored on the memory and capable of running on the processor, the computer program, when executed by the processor, implementing the method of constructing a game scene as described above.
A computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the method of constructing a game scene as described above.
The embodiment of the invention has the following advantages:
according to the embodiment of the invention, the map slice data generated based on the preset map data is obtained, so that raster scanning can be carried out on the map slice data to obtain the rasterized earth surface coverage data, and further the game scene elements preset according to the earth surface coverage data can be used for constructing the game scene, thereby realizing the rapid construction of the game scene according to the rasterized earth surface coverage data, namely the complex game scene elements such as irregular ancient buildings can be placed, and the game scene elements in the constructed game scene can be rapidly obtained, so that the high-performance collision test can be realized.
And moreover, whether the bounding box has the building elements is determined by scanning the bounding box of the building layer data, so that the phenomenon of die penetration when the building is directly formed by drawing high is avoided, and a proper game scene is constructed.
Furthermore, by obtaining the rasterized earth surface coverage data, the vegetation can be placed according to the vegetation layer data, so that the game scene is more real.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings required to be used in the description of the present invention will be briefly introduced below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings may be obtained according to the drawings without inventive labor.
FIG. 1a is a flowchart illustrating steps of a method for constructing a game scene according to an embodiment of the present invention;
FIG. 1b is a schematic view of a map slice provided by an embodiment of the present invention;
FIG. 1c is a diagram illustrating multiple grating layers in a same slice according to an embodiment of the present invention;
FIG. 1d is a diagram illustrating raster data of a map slice data according to an embodiment of the present invention;
FIG. 1e illustrates a rasterization process provided in accordance with one embodiment of the present invention;
FIG. 2a is a flow chart illustrating steps of a method for constructing another game scenario according to an embodiment of the present invention;
FIG. 2b is a schematic diagram illustrating a bit operation of a query operation according to an embodiment of the present invention;
FIG. 3a is a flow chart illustrating steps of a method for constructing another game scenario according to an embodiment of the present invention;
FIG. 3b is a schematic view of a first vegetation zone according to an embodiment of the present invention;
FIG. 4 is a flow chart of steps of a method for constructing another game scenario according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a game scene constructing apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention more comprehensible, the present invention is described in detail with reference to the accompanying drawings and the detailed description thereof. It is to be understood that the embodiments described are only a few embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The following describes terms involved in the embodiments of the present invention:
the game scene is a virtual game scene displayed (or provided) when the application program runs on the terminal (such as a mobile phone terminal, a pc terminal and a cloud terminal). The virtual game scene can be a simulation environment of a real world, a semi-simulation semi-fictional environment or a pure fictional environment, and the embodiment of the invention is exemplified by the game scene being a three-dimensional virtual game scene.
The game scene elements are people and objects in the game scene, such as game characters, the ground, the sky, water, mountains, flowers, grasses, trees, stones, birds, animals, insects, fish, vehicles, houses and the like.
Referring to fig. 1a, a flowchart illustrating steps of a method for constructing a game scene according to an embodiment of the present invention is shown, and specifically may include the following steps:
step 101, obtaining map slice data generated based on preset map data;
the preset map data may be real map data or constructed virtual game map data.
When a new game scene is built, preset map data can be acquired, game map building is started based on the preset map data, in order to build the game scene quickly, the map data can be divided to obtain map slice data with a smaller area, specifically, real map data can be expanded into a planar map, and then horizontal and vertical division is carried out, wherein each slice is a block. Three kinds of geometric information of points, lines and surfaces are stored in each slice.
The process based on real map data slices is shown in fig. 1 b. In level 1, the expanded map is divided into four slices numbered 0, 1, 2, 3, in level 2, division is performed again for each slice, each slice is divided into four small slices, such as the slice numbered "2" in level 1, and is divided into four slices numbered 20, 21, 22, 23 in level 2; in level 3, the division is performed again for each slice, and each slice is divided into four small slices, such as the slice numbered "13" in level 2, and four slices numbered 130, 131, 132, 133 in level 3.
Step 102, carrying out raster scanning on the map slice data to obtain rasterized earth surface coverage data;
in one embodiment of the present invention, the surface coverage data may include: any one or more of building layer data, vegetation layer data, water layer data and road layer data.
After the map slice data is obtained, raster scanning processing may be performed on the map slice data, and corresponding rasterized surface coverage data may be obtained according to a surface coverage object in preset map data. Rasterization is a process of converting a geometric primitive into a two-dimensional image, that is, rasterization of geometric units (points, lines, and surfaces) onto a two-dimensional image.
In practical applications, the preset map data may include multiple types of ground cover, so that after rasterization is performed, each map slice data may obtain multiple raster layers, as shown in fig. 1c, the ground cover data obtained by rasterization of the same map slice data is obtained, and the raster layers from left to right are building layer data, vegetation layer data, road layer data, and water layer data in sequence.
In one example, a certain map slice data of a raster layer may be constructed into a data structure of fluid 64 Buffer [4] [256], that is, in each map slice data, each line is 4 bits of fluid 64, and the total line is 256 lines, as shown in fig. 1 d.
For example, the triangle in fig. 1e may represent an area where a building is located in the preset map data, so that the corresponding positions of three points of the triangle in the Buffer are calculated first, and then a scan line is obtained through a scan line algorithm, and performing or operation on the scan line and the agent 64 corresponding to the Buffer is equivalent to rasterizing the line, and this process is also a bit operation of the write operation.
In an example, the rasterization process in the present invention may specifically be a process of using soft raster scanning, where the soft raster refers to a process of performing rasterization on a CPU side, and performing soft raster scanning may improve rasterization efficiency.
In the embodiment of the invention, the rasterization processing process of each map slice data can be completed only in 5-10ms, so that the performance pressure of a client can be effectively reduced, and a 3D game scene can be displayed more quickly.
And 103, placing preset game scene elements according to the earth surface coverage data to construct a game scene.
After the ground surface coverage data is obtained, preset game scene elements can be placed according to the ground surface coverage data, for example, preset building elements are placed according to building layer data, water elements are placed according to water layer data, road elements are placed according to road layer data, vegetation elements are placed according to vegetation layer data, and the like.
In practical application, a process of placing preset game scene elements is actually a process of writing a game scene element into a raster layer through writing operation, and after writing, raster data is updated to obtain raster layer data after the game scene element is placed, so that placement of other game scene elements can be performed based on the raster layer data, or collision test of virtual characters can be performed based on the raster layer data. .
It should be noted that, when placing game scene elements, different placing rules may be set according to the properties of different game scene elements, and the game scene elements are placed according to the rules, so as to construct a reasonable game scene, where the placing rules may include a placing order of the game scene elements, a region setting rule of different game scene elements, and the like.
In an embodiment of the present invention, the surface coverage data includes first surface coverage data and second surface coverage data, and the step 103 may include the following sub-steps:
substep 1031 of determining first and second surface coverage data from the surface coverage data;
the first surface coverage data and the second surface coverage data can be any one or more of the following items:
building layer data, vegetation layer data, road layer data and water layer data.
Substep 1032, generating target surface coverage data from the first surface coverage data and the second surface coverage data;
wherein, the target earth surface coverage data can be any one of the following items:
building layer data, vegetation layer data, road layer data and water layer data.
And a substep 1033 of placing preset game scene elements according to the target earth surface coverage data to construct a game scene.
In practical application, after rasterization is performed on a map slice, a plurality of rasterized ground surface coverage data can be obtained, so that a corresponding game scene element can be placed directly according to each rasterized ground surface coverage data, or new raster layer data can be generated after performing or operation and/or nor operation based on the rasterized ground surface coverage data, and the game scene element can be placed according to the new raster layer data to construct a game scene.
The process of generating a new grating layer (i.e. target surface coverage data) may specifically be: from the rasterized surface coverage data, first surface coverage data and second surface coverage data are determined. The first and second surface coverage data are subjected to an or operation and/or a nor operation, etc., to generate target surface coverage data. After the new target ground surface coverage data is generated, preset game scene elements can be placed, if the generated new target ground surface coverage data is building layer data, the building elements are placed, and if the generated target ground surface coverage data is vegetation, the vegetation elements are placed.
It should be noted that, in the process of placing preset game scene elements according to the target ground surface coverage data, reference may be made to a process of placing preset game scene elements directly according to the ground surface coverage data.
In practical application, after obtaining a plurality of layered (such as building, vegetation, water, road) grating data (ground cover data), each layer of grating data can be freely combined to combine a needed new grating layer.
For example, the water layer data and the building layer data can be combined into a new raster layer, and the raster layer can be used as a basis for the virtual character not to walk, that is, for performing a collision test of the virtual character in a game scene.
For example, when a game scene element needs to be placed in an area where an empty place is located in a map, or operation may be performed on all raster layer data, and then raster layer data corresponding to the empty place may be obtained by performing non-operation.
For example, when a game scene element is required to be placed in an area where vegetation and open space are located in a map, or operation can be performed on building layer data, water layer data and road layer data, and then non-operation is performed to obtain grating layer data formed by the vegetation and the open space.
In practical application, a 2D screen building grid can be obtained based on vector map slicing of a map, the building is generated through drawing-up processing, material pasting processing and the like, vegetation, water, roads and the like are added in a non-building area one by one on the basis, and therefore a large amount of time is needed when a game scene is built.
In the embodiment of the invention, the game scene elements can be placed according to the rasterized earth surface coverage data, so that the game scene elements can be placed more quickly to quickly construct a game scene, and new raster layer data can be quickly generated by performing combined operation on a plurality of raster layers according to the user requirements, so as to quickly construct more diversified game scenes.
In the embodiment of the invention, the map slice data generated based on the preset map data is obtained, so that raster scanning can be carried out on the map slice data to obtain the rasterized earth surface coverage data, and further the game scene elements preset according to the earth surface coverage data can be used for constructing the game scene, so that the game scene is constructed according to the rasterized earth surface coverage data, namely the complicated game scene elements can be placed, complicated buildings are arranged in the scene, the game scene elements in the constructed game scene can be rapidly obtained, and further the high-performance collision test is realized.
Referring to fig. 2a, a flowchart of steps of another game scene construction method provided in an embodiment of the present invention is shown, which specifically includes the following steps:
step 201, obtaining map slice data generated based on preset map data;
step 202, performing raster scanning on the map slice data to obtain rasterized earth surface coverage data; the ground surface coverage data comprises building layer data, and the game scene elements comprise building elements;
step 203, determining a target bounding box in one or more building bounding boxes of the building layer data;
bounding boxes are algorithms that solve the optimal bounding space of a discrete set of points by approximately replacing complex geometric objects with slightly larger and characteristically simpler geometries (called bounding boxes). In the embodiment of the present invention, the building element placing process is explained by taking the building bounding box as the AABB bounding box as an example.
After the building layer data is obtained, the building layer data may be composed of one or more building bounding boxes, each bounding box corresponding to a real building in the preset map data.
When a building is placed, a target bounding box of the building to be placed can be selected from the plurality of building bounding boxes.
Step 204, determining a target building element to be placed in the target bounding box;
after the target bounding box is determined, a target building element to be placed in the target bounding box may be determined among the preset building elements, i.e., the target building element is matched with the target bounding box.
In an embodiment of the present invention, the step 204 may specifically include the following sub-steps:
substep 2041, determining model bounding boxes of preset candidate building elements;
in practical application, candidate building elements (i.e. building models) with different sizes and forms can be designed in advance, and a corresponding two-dimensional model bounding box can be obtained for each candidate building element.
By presetting the building elements, complex building elements such as irregular ancient buildings and the like can be constructed in a game scene.
Sub-step 2042, when the matching between the model bounding box and the target bounding box is successful, determining the candidate building element as the target building element to be placed in the target bounding box.
After the two-dimensional model bounding box is obtained, the target bounding box and the model bounding box can be matched, the target bounding box can be rotated in the matching process so as to be convenient for matching the bounding boxes, and when the length and the width of the bottom of the model bounding box are both smaller than or equal to those of the target bounding box to be put, the model bounding box and the target bounding box are successfully matched.
When the model bounding box is successfully matched with the target bounding box, determining the candidate bounding box corresponding to the target bounding box as a target building element to be placed in the target bounding box, namely the target building element can be theoretically placed in the target bounding box.
In an example, the target candidate element may be determined by matching the bounding box from the candidate building elements, and in this process, the matching degree may be further set, for example, the matching degree of the model bounding box and the target bounding box is determined according to the length-width difference between the two bounding boxes, and when the difference is smaller, the matching degree of the target bounding box and the model bounding box is higher, so that the target building element which is most fit with the target bounding box may be determined.
Step 205, judging whether the target building element can be placed in the target bounding box according to the raster data of the target bounding box;
and scanning the target bounding box, and combining the raster data of the target bounding box to further judge whether the target bounding box can actually put the target building element.
For example, a target bounding box is scanned, a scanning line traverses Xmin to Xmax of each Y value of the target bounding box, and a sum operation is performed on the scanning result and raster data of the target bounding box, if the scanning result is true (the scanning result and the raster data corresponding to the raster data are both 1), it is indicated that a building element is already placed before the scanning line, and other building elements cannot be placed continuously, otherwise, when all scanning lines of the target bounding box pass a test, it can be determined that the building element can be placed in the target bounding box, so that a target building element to be placed is written in a Buffer (raster data), as shown in fig. 2b, a triangle in the diagram is the target building element to be placed, the target bounding box is scanned by the scanning line, and an operation process (i.e., a bit operation of an inquiry operation) is performed, and according to the operation result, it can be determined that the target building element cannot be placed in the target bounding box.
And step 206, placing the target building element in the target bounding box when the target bounding box is judged to be capable of placing the target building element.
In an example, when building placement is performed for the first time, no building element is placed in all bounding boxes in the building layer data at this time, so that the target building element can be directly placed into the target bounding box after the target bounding box is determined.
When the building is placed for the non-first time, a part of bounding boxes in the building layer data already place the building, so that after the target bounding box and the target building element are determined, whether the target bounding box can be placed with the target building element can be further judged, and the target building element is placed under the condition that the target bounding box can be placed with the target building element, so that the building penetration phenomenon is avoided.
In an example, when the target bounding box has the building elements placed therein, when it is determined that the target building elements can be placed in the area where no buildings are placed, it can also be determined that the target bounding box can place the target building elements.
In the embodiment of the invention, the map slice data generated based on the preset map data is acquired, so that raster scanning can be carried out on the map slice data to obtain rasterized ground surface coverage data, then the building elements are placed according to the ground surface coverage data, and whether the building elements can be placed in the building bounding box is judged by carrying out raster scanning on the building bounding box before the target building elements are placed, so that the phenomenon of mold penetration when the building elements are placed is avoided.
Referring to fig. 3a, a flowchart illustrating steps of another method for constructing a game scene according to an embodiment of the present invention is shown, which may specifically include the following steps:
step 301, obtaining map slice data generated based on preset map data;
step 302, performing raster scanning on the map slice data to obtain rasterized earth surface coverage data; the ground surface coverage data comprises vegetation layer data, and the game scene elements comprise vegetation elements;
in an embodiment of the invention, the surface coverage data further comprises any one or more of:
road layer data and water layer data.
Step 303, determining a first vegetation area according to the vegetation layer data;
and determining vegetation layer data in the obtained ground surface covering data, wherein the vegetation layer data is generated according to the area covered by flowers, plants and trees in the preset map data.
After determining vegetation layer data, a first vegetation zone is determined based on the vegetation layer data. The vegetation layer data can be directly used as the first vegetation area, and the first vegetation area can also be determined by combining with other earth surface coverage data.
For example, in practical applications, different game scene elements have different placing orders, usually building layers are first, then water layers, road layers, and finally vegetation layers, and after the building elements, the water elements, and the road elements are placed according to the placing orders, in the process of placing the vegetation elements, the vegetation layers can be generated based on the previously placed game scene elements to place the vegetation elements.
Specifically, the building area, the non-vegetation road area, and the non-vegetation water area are all non-vegetation areas, so that the "building | (-grass) & load) | (-grass) & water)" can be calculated for the Buffer to obtain a new layer of Buffer, where "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, as shown in fig. 3b, a white area in the graph can represent an area where vegetation cannot be theoretically planted, and a black area can represent an area where vegetation can be theoretically planted.
A step 304 of randomly generating a second vegetation area based on the first vegetation area;
after obtaining the first vegetation zone, a second vegetation zone can be randomly generated based on the first vegetation zone.
305, obtaining a target vegetation area according to the first vegetation area and the second vegetation area;
after obtaining first vegetation district and second vegetation district, can further confirm the region of first vegetation district and the coincidence of second vegetation district, regard this coincident vegetation district as the target vegetation district that is used for actually putting the vegetation in the recreation scene finally, can effectively avoid planting full vegetation through another random second vegetation district in addition, make the visual effect of the recreation scene that finally obtains better.
And step 306, placing preset vegetation elements in the target vegetation area.
After the target vegetation area is determined, the preset vegetation elements can be placed according to the target vegetation area, and instantiation of the vegetation elements is performed.
In an embodiment of the present invention, the step 306 may include the following sub-steps:
substep 3061, determining location information of the target vegetation zone;
in practical application, after the target vegetation area is determined, the target vegetation area is composed of grids (namely 1 bit), in the vegetation placing process, the vegetation can be placed at the center of the grids in a default mode, and the vegetation placed in each grid is in a fixed size and a fixed shape.
In order to achieve a better vegetation effect, the position information of the target vegetation area may be determined first, that is, the position information of each grid of the target vegetation area is determined, wherein the central position coordinate of each grid is used as the position information of the grid.
A substep 3062 of performing dithering process according to the position information to generate a position matrix;
after the position information is determined, the obtained position information may be dithered according to a preset dithering degree, so that the position information is shifted from the center position at random to a certain extent, and a position matrix is generated according to the dithered position information.
Through the dithering process, the position of the vegetation in the grid is randomly distributed in the instantiation process.
Substep 3063, obtaining a randomly generated rotation matrix and a scaling matrix;
the rotation matrix can be used for controlling the angle of the vegetation, and the vegetation presenting different angles randomly can be obtained through the random rotation matrix, so that the form of the vegetation is richer.
The scaling matrix can be used for controlling the size of the vegetation, and the vegetation with different sizes can be obtained through the random matrix, so that the form of the vegetation is richer.
Substep 3064, generating a target matrix based on the position matrix, the rotation matrix and the scaling matrix;
after obtaining the position matrix, the rotation matrix, and the scaling matrix, a target matrix may be generated based on the three matrices, and each grid in the target matrix may include position information, rotation information, and scaling information.
And a substep 3065 of placing preset vegetation elements according to the target matrix.
After the target matrix is determined, each grid is instantiated according to the target matrix, and the preset vegetation elements are placed.
In an example, in the placing process, instantiation can be performed according to each grid, or each piece of map slice data can be divided into small blocks of n × n, and information in each block is packaged into integral data to be instantiated, so that the instantiation speed is increased.
In the embodiment of the invention, the map slice data generated based on the preset map data is acquired, so that raster scanning can be performed on the map slice data to obtain rasterized ground surface coverage data, and then the vegetation elements are placed according to the ground surface coverage data, thereby realizing the placement of the vegetation elements in a game scene.
Referring to fig. 4, a flowchart illustrating steps of another method for constructing a game scene according to an embodiment of the present invention is shown, which may specifically include the following steps:
step 401, obtaining map slice data generated based on preset map data;
step 402, performing raster scanning on the map slice data to obtain rasterized earth surface coverage data;
and 403, placing preset game scene elements according to the earth surface coverage data to construct a game scene.
Step 404, when the virtual character moves in the game scene, determining the position to be moved of the virtual character;
in the actual running process of the game, when the virtual character moves in the game scene, a collision test needs to be performed on the virtual character, so as to determine whether the virtual character can move. For example, when the position where the virtual character needs to move corresponds to a building position, there is a collision, and the virtual character cannot move to the position.
After the game scene is constructed, the earth surface covering data of each layer in the game scene are updated according to the game scene elements arranged on the grids.
When the virtual character moves in the game scene, the position to be moved of the virtual character can be determined, so that a collision test can be performed according to the position to be moved, wherein the collision test can comprise a point collision, a triangular collision and a rectangular collision.
Step 405, controlling the virtual character to move according to the game scene element placed at the position to be moved.
When the position to be moved is determined, the position to be moved is inquired, the game scene elements placed at the position to be moved are determined, and then whether the inquiry role can move to the position to be moved or not is determined according to the game scene elements.
In one example, when performing the collision test, regarding the object to be tested as a point, the collision test is a point collision, regarding the object to be tested as a triangle, the triangle collision is a triangle collision, and regarding the object to be tested as a rectangle, the rectangle collision is a rectangle collision.
For example, a rectangular collision may be determined, an area where the rectangle is located may be determined, the area is determined to be scanned, the scanned data is computed with raster data of each layer of the area, a raster layer with a true computation result is determined, a game scene element is determined according to the raster layer, and then the virtual character is controlled to move according to the game scene element.
In practical application, for a game scene that has been generated, a new raster layer may be synthesized based on a plurality of raster layers of the game scene to perform a collision test, for example, building layer data and water layer data may be merged to combine to obtain new raster layer data, and a collision test, that is, a bit operation of an inquiry operation, is performed on a virtual character according to the new raster layer data to determine whether the virtual character can move.
In the embodiment of the invention, after the game scene elements are placed according to the rasterized earth surface coverage data, the game scene is constructed, when the virtual character moves in the game scene, the mode penetration is avoided, and the high-performance collision test can be carried out.
It should be noted that for simplicity of description, the method embodiments are shown as a series of combinations of acts, but those skilled in the art should understand that the embodiments are not limited by the described order of acts, as some steps can be performed in other orders or simultaneously according to the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 5, a schematic structural diagram of a game scene constructing apparatus according to an embodiment of the present invention is shown, which may specifically include the following modules:
a map slice data obtaining module 501, configured to obtain map slice data generated based on preset map data;
a ground surface coverage data determining module 502, configured to perform raster scanning on the map slice data to obtain rasterized ground surface coverage data;
and a game scene constructing module 503, configured to place preset game scene elements according to the ground surface coverage data to construct a game scene.
In an embodiment of the present invention, the surface coverage data includes building layer data, the game scene element includes a building element, and the game scene constructing module 503 may include:
a target bounding box determination sub-module to determine a target bounding box among the one or more building bounding boxes of the building layer data;
the target building element determining submodule is used for determining the target building elements to be placed in the target bounding boxes;
the judgment submodule is used for judging whether the target building elements can be placed in the target bounding box according to the grating data of the target bounding box;
and the building placing sub-module is used for placing the target building elements in the target bounding box when the target bounding box is judged to be capable of placing the target building elements.
In an embodiment of the present invention, the building placing sub-module may include:
the model bounding box determining unit is used for determining a model bounding box of a preset candidate building element;
and the placing unit is used for determining the candidate building elements as the target building elements to be placed in the target bounding box when the model bounding box is successfully matched with the target bounding box.
In an embodiment of the present invention, the surface coverage data includes vegetation layer data, the game scene element includes a vegetation element, and the game scene constructing module 503 may further include:
the first vegetation zone determining submodule is used for determining a first vegetation zone according to the vegetation layer data;
the random vegetation zone generation submodule is used for randomly generating a second vegetation zone based on the first vegetation zone;
the target vegetation zone determination submodule is used for obtaining a target vegetation zone according to the first vegetation zone and the second vegetation zone;
and the vegetation construction submodule is used for placing preset vegetation elements in the target vegetation area.
In an embodiment of the present invention, the vegetation construction sub-module may include:
the position information determining unit is used for determining the position information of the target vegetation area;
the dithering unit is used for carrying out dithering processing according to the position information to generate a position matrix;
a rotation and scaling unit for obtaining a randomly generated rotation matrix and scaling matrix;
a target matrix determination unit, configured to generate a target matrix based on the position matrix, the rotation matrix, and the scaling matrix;
and the instantiation unit is used for placing preset vegetation elements according to the target matrix.
In an embodiment of the present invention, the apparatus may include:
the position to be moved determining module is used for determining the position to be moved of the virtual character when the virtual character moves in the game scene;
and the collision test module is used for controlling the virtual character to move according to the game scene elements placed at the position to be moved.
In an embodiment of the present invention, the game scene constructing module 503 may include:
the earth surface coverage data selection submodule is used for determining first earth surface coverage data and second earth surface coverage data from the earth surface coverage data;
the target ground surface coverage data generation submodule is used for generating target ground surface coverage data according to the first ground surface coverage data and the second ground surface coverage data;
and the game scene constructing submodule is used for placing preset game scene elements according to the target earth surface coverage data so as to construct a game scene.
In an embodiment of the invention, the surface coverage data further comprises any one or more of:
road layer data and water layer data.
In the embodiment of the invention, the map slice data generated based on the preset map data is acquired, so that raster scanning can be performed on the map slice data to obtain the rasterized earth surface coverage data, and then the preset game scene elements can be placed according to the earth surface coverage data to construct the game scene, thereby realizing rapid construction of the game scene, rapidly acquiring the earth surface attribute in the constructed game scene, and further performing high-performance collision test on the game role in the game scene.
An embodiment of the present invention further 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, wherein the computer program, when executed by the processor, implements the steps of the method for constructing a game scene.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the method for constructing a game scene.
For the apparatus embodiment, since it is substantially similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for relevant points.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
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 flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "include", "including" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or terminal device including a series of elements includes not only those elements but also other elements not explicitly listed or inherent to such process, method, article, or terminal device. Without further limitation, an element defined by the phrases "comprising one of \ 8230; \8230;" does not exclude the presence of additional like elements in a process, method, article, or terminal device that comprises the element.
The construction method and apparatus for a game scene provided above are introduced in detail, and specific examples are applied herein to explain the principle and the implementation of the present invention, and the description of the above embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (11)

1. A method for constructing a game scene, the method comprising:
acquiring map slice data generated based on preset map data;
raster scanning is carried out on the map slice data to obtain rasterized earth surface coverage data;
and placing preset game scene elements according to the earth surface coverage data to construct a game scene.
2. The method of claim 1, wherein the surface coverage data comprises building layer data, wherein the game scene elements comprise building elements, and wherein placing preset game scene elements according to the surface property layer data comprises:
determining a target bounding box in one or more building bounding boxes of the building layer data;
determining a target building element to be placed in the target bounding box;
judging whether the target building elements can be placed in the target bounding box according to the grating data of the target bounding box;
when the target bounding box is judged to be capable of placing the target building elements, placing the target building elements in the target bounding box.
3. The method of claim 2, wherein the determining a target building element to be placed in the target bounding box comprises:
determining a model bounding box of a preset candidate building element;
and when the model bounding box is successfully matched with the target bounding box, determining the candidate building elements as the target building elements to be placed in the target bounding box.
4. The method of claim 1, 2 or 3, wherein the surface coverage data comprises vegetation layer data, wherein the game scene elements comprise vegetation elements, and wherein placing preset game scene elements according to the surface attribute layer data comprises:
determining a first vegetation area according to the vegetation layer data;
randomly generating a second vegetation zone based on the first vegetation zone;
obtaining a target vegetation area according to the first vegetation area and the second vegetation area;
and placing preset vegetation elements in the target vegetation area.
5. The method of claim 4, wherein the positioning of the preset vegetation elements in the target vegetation zone comprises:
determining position information of a target vegetation area;
carrying out dithering processing according to the position information to generate a position matrix;
acquiring a randomly generated rotation matrix and a scaling matrix;
generating a target matrix based on the position matrix, the rotation matrix and the scaling matrix;
and placing preset vegetation elements according to the target matrix.
6. The method of claim 5, further comprising:
when the virtual character moves in the game scene, determining the position to be moved of the virtual character;
and controlling the virtual character to move according to the game scene elements placed at the position to be moved.
7. The method according to claim 1, 2 or 3, wherein the placing preset game scene elements according to the ground surface coverage data to construct a game scene comprises:
determining first and second surface coverage data from the surface coverage data;
generating target earth surface coverage data according to the first earth surface coverage data and the second earth surface coverage data;
and placing preset game scene elements according to the target earth surface coverage data to construct a game scene.
8. The method of claim 4, wherein the surface coverage data further comprises any one or more of:
road layer data and water layer data.
9. An apparatus for constructing a game scene, the apparatus comprising:
the map slice data acquisition module is used for acquiring map slice data generated based on preset map data;
the earth surface coverage data determining module is used for carrying out raster scanning on the map slice data to obtain rasterized earth surface coverage data;
and the game scene construction module is used for placing preset game scene elements according to the earth surface coverage data so as to construct a game scene.
10. A server, comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the method of constructing a game scene according to any one of claims 1 to 8.
11. A computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the method of constructing a game scene according to any one of claims 1 to 8.
CN202211031592.4A 2022-08-26 2022-08-26 Game scene construction method and device Pending CN115364480A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211031592.4A CN115364480A (en) 2022-08-26 2022-08-26 Game scene construction method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211031592.4A CN115364480A (en) 2022-08-26 2022-08-26 Game scene construction method and device

Publications (1)

Publication Number Publication Date
CN115364480A true CN115364480A (en) 2022-11-22

Family

ID=84068405

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211031592.4A Pending CN115364480A (en) 2022-08-26 2022-08-26 Game scene construction method and device

Country Status (1)

Country Link
CN (1) CN115364480A (en)

Similar Documents

Publication Publication Date Title
CN107358649B (en) Processing method and device of terrain file
US8243065B2 (en) Image presentation method and apparatus for 3D navigation and mobile device including the apparatus
CN110088808B (en) System and method for program-generated object distribution in region of three-dimensional virtual environment
CN110163064A (en) A kind of recognition methods of Sign for road, device and storage medium
KR20080018404A (en) Computer readable recording medium having background making program for making game
CN112561788B (en) Two-dimensional unfolding method of BIM model and texture mapping method and device
DE112022004426T5 (en) Shifted microgrids for ray and path tracing
CN112169324A (en) Rendering method, device and equipment of game scene
Hammes Modeling of ecosystems as a data source for real-time terrain rendering
EP3932504A1 (en) Map generation method and apparatus, electronic device, and computer storage medium
US20180053343A1 (en) System and method for procedurally generated building graphics within a street network of a three-dimensional virtual environment
US20120268468A1 (en) System and method for stochastically generating maps of places in a virtual space
CN112052864B (en) Image drawing method and device, electronic equipment and readable storage medium
CN111494944A (en) Terrain texture loading method and related device
Greuter et al. Undiscovered worlds–towards a framework for real-time procedural world generation
CN115364480A (en) Game scene construction method and device
KR20180088876A (en) Image processing method and apparatus
Dam et al. Terrain generation based on real world locations for military training and simulation
CN111340941B (en) Oblique photography dynamic singleization method based on vector graphics under spherical coordinate system
US10553025B2 (en) Method and device for efficient building footprint determination
CN111354081A (en) Large-scale three-dimensional forest drawing method
CN111729303B (en) Large map baking and cutting method and restoration method
CN114404948A (en) Game map display method and device, electronic equipment and computer readable storage medium
CN113289334A (en) Game scene display method and device
Bender et al. HW3D: A tool for interactive real-time 3D visualization in GIS supported flood modelling

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination