CN108744520B - Method and device for determining placement position of game model and electronic equipment - Google Patents
Method and device for determining placement position of game model and electronic equipment Download PDFInfo
- Publication number
- CN108744520B CN108744520B CN201810574364.9A CN201810574364A CN108744520B CN 108744520 B CN108744520 B CN 108744520B CN 201810574364 A CN201810574364 A CN 201810574364A CN 108744520 B CN108744520 B CN 108744520B
- Authority
- CN
- China
- Prior art keywords
- game model
- target
- convex hull
- game
- vertex data
- 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.)
- Active
Links
Images
Classifications
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/60—Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/60—Methods for processing data by generating or executing the game program
- A63F2300/6009—Methods for processing data by generating or executing the game program for importing or creating game content, e.g. authoring tools during game development, adapting content to different platforms, use of a scripting language to create content
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Processing Or Creating Images (AREA)
Abstract
The embodiment of the invention provides a method, a device and electronic equipment for determining the placement position of a game model, wherein the method comprises the following steps: obtaining vertex data of a game model; calculating a convex hull of the game model in world space based on the vertex data; dividing a preset game editor scene into grids, wherein the grids comprise a plurality of grid points; determining a target grid point inside the game model according to a convex hull of the game model in a world space; and determining the placing position of the game model according to the target grid points. According to the embodiment, the game model is uploaded to the game editor, the specific placing position of the game model in a scene can be automatically, efficiently and accurately calculated by the game editor, other preprocessing on the game model is not needed, the efficiency of determining the position of the game model is improved, and the accuracy of position calculation is also improved.
Description
Technical Field
The present invention relates to the field of game technologies, and in particular, to a method for determining a placement position of a game model, an apparatus for determining a placement position of a game model, and an electronic device.
Background
A game editor is a tool that provides a player with free editing of game content or scenes. The game editor also provides various types of editor models such as characters, flowers, trees, etc. By rendering the above models in a game editor, a player can design a game according to his own thinking.
In order to prevent the objects in the finally generated game scene from overlapping, before rendering the models, the placement positions of the models in the game editor need to be determined. Currently, the determination of the placement position of the model in the prior art is mainly achieved by the following several ways. Firstly, the center of the model is determined according to the coordinates of each vertex of the model, and then the size of the model is marked by determining a rectangle or a circle which can completely surround the model according to the center, so that the placing position of the model is determined. Secondly, the size of the model is calculated by a game player or a designer in a mode of manually drawing the model, and then the placing position of the model is determined. However, both of the above methods require the size of the model to be determined first, and the model cannot be dynamically added to the game editor. Moreover, when the model is in a special shape such as a triangle, the first method is also prone to waste of space. On the other hand, the second placing mode can avoid the waste of space, but needs to manually use an extra painting and brushing tool to carefully trace each model, which is time-consuming and labor-consuming.
Disclosure of Invention
In view of the above problems, embodiments of the present invention are provided to provide a method for determining a pose position of a game model, an apparatus for determining a pose position of a game model, and a corresponding electronic device, which overcome or at least partially solve the above problems.
In order to solve the above problem, an embodiment of the present invention discloses a method for determining a placement position of a game model, including:
obtaining vertex data of a game model;
calculating a convex hull of the game model in world space based on the vertex data;
dividing a preset game editor scene into grids, wherein the grids comprise a plurality of grid points;
determining a target grid point inside the game model according to a convex hull of the game model in a world space;
and determining the placing position of the game model according to the target grid points.
Optionally, the step of obtaining vertex data of the game model includes:
obtaining a game model file;
and analyzing the game model file to obtain vertex data in a local space.
Optionally, the step of calculating the convex hull of the game model in the world space based on the vertex data comprises:
performing height removal processing on the vertex data in the local space to generate target vertex data;
calculating a convex hull of the game model in the local space by adopting the target vertex data;
and calculating the convex hull of the game model in the world space based on the convex hull in the local space.
Optionally, the step of calculating the convex hull of the game model in the local space by using the target vertex data includes:
extracting the target vertex with the maximum and minimum horizontal coordinate values in the target vertex data;
connecting the target vertexes with the maximum and minimum horizontal coordinate values to generate a target straight line;
dividing a plurality of target vertexes into a positive direction point set and a negative direction point set based on the target straight lines;
and calculating the convex hull in the local space according to the positive direction point set and the negative direction point set.
Optionally, the step of calculating the convex hull of the game model in the world space based on the convex hull in the local space comprises:
determining a world space matrix of the game model in the world space;
multiplying coordinate values of a plurality of target vertices by the world space matrix to obtain a convex hull in the world space.
Optionally, the step of dividing the preset game editor scene into grids includes:
determining the division precision of the grid, wherein the division precision is less than or equal to the minimum size of the game model;
and dividing the preset game editor scene into a plurality of grids according to the division precision.
Optionally, the step of determining target grid points inside the game model according to the convex hull of the game model in the world space comprises:
for any grid point, generating rays by taking the grid point as an end point and taking the X-axis direction as a direction;
determining a number of intersections of the ray with a convex hull in the world space;
and extracting the grid points with odd times of intersection as target grid points.
Optionally, the step of determining the placement position of the game model according to the target grid point includes:
determining whether the target grid point is occupied by other game models;
and if the target grid point is not occupied by other game models, determining the position corresponding to the target grid point as the placing position of the game model.
In order to solve the above problem, an embodiment of the present invention discloses a device for determining a placement position of a game model, including:
the vertex data acquisition module is used for acquiring vertex data of the game model;
the convex hull calculation module is used for calculating the convex hull of the game model in the world space based on the vertex data;
the system comprises a grid division module, a game editing module and a display module, wherein the grid division module is used for dividing a preset game editor scene into grids, and each grid comprises a plurality of grid points;
the target grid point determining module is used for determining target grid points in the game model according to the convex hull of the game model in the world space;
and the placing position determining module is used for determining the placing position of the game model according to the target grid points.
Optionally, the vertex data obtaining module includes:
the game model file acquisition submodule is used for acquiring a game model file;
and the game model file analysis submodule is used for analyzing the game model file to obtain vertex data in a local space.
Optionally, the convex hull computation module includes:
the target vertex data generating submodule is used for performing height removal processing on the vertex data in the local space to generate target vertex data;
the local space convex hull calculating submodule is used for calculating the convex hull of the game model in the local space by adopting the target vertex data;
and the world space convex hull calculation sub-module is used for calculating the convex hull of the game model in the world space based on the convex hull in the local space.
Optionally, the local spatial convex hull computation submodule includes:
the target vertex extraction unit is used for extracting target vertices with the maximum and minimum horizontal coordinate values in the target vertex data;
the target straight line generating unit is used for connecting the target vertexes with the maximum and minimum horizontal coordinate values to generate a target straight line;
the target vertex dividing unit is used for dividing a plurality of target vertexes into a positive direction point set and a negative direction point set based on the target straight line;
and the local space convex hull calculating unit is used for calculating the convex hull in the local space according to the positive direction point set and the negative direction point set.
Optionally, the world space convex hull computation submodule includes:
a world space matrix determination unit for determining a world space matrix of the game model in the world space;
a world space convex hull calculation unit for multiplying coordinate values of a plurality of target vertices by the world space matrix to obtain a convex hull in the world space.
Optionally, the meshing module includes:
the division precision determining submodule is used for determining the division precision of the grids, and the division precision is smaller than or equal to the minimum size of the game model;
and the grid division submodule is used for dividing the preset game editor scene into a plurality of grids according to the division precision.
Optionally, the target grid point determining module includes:
the ray generation submodule is used for generating rays for any grid point by taking the grid point as an end point and taking the X-axis direction as a direction;
an intersection number determination submodule for determining the number of intersections of the ray with a convex hull in the world space;
and the target grid point extracting submodule is used for extracting the grid points with odd times of intersection as target grid points.
Optionally, the placement position determining module includes:
a target grid point occupation determination submodule for determining whether the target grid point is occupied by other game models;
and the game model placing position determining submodule is used for determining the position corresponding to the target grid point as the placing position of the game model if the target grid point is not occupied by other game models.
In order to solve the above problem, an embodiment of the present invention discloses an apparatus for determining a game model placement position, including a memory, and one or more programs, where the one or more programs are stored in the memory, and the one or more programs configured to be executed by the one or more processors include instructions for:
obtaining vertex data of a game model;
calculating a convex hull of the game model in world space based on the vertex data;
dividing a preset game editor scene into grids, wherein the grids comprise a plurality of grid points;
determining a target grid point inside the game model according to a convex hull of the game model in a world space;
and determining the placing position of the game model according to the target grid points.
In order to solve the above problem, an embodiment of the present invention discloses an electronic device, which includes a processor, a memory, and a computer program stored in the memory and configured to run on the processor, and when the computer program is executed by the processor, the steps of the method for determining the placement position of the game model are implemented as described above.
Compared with the background art, the embodiment of the invention has the following advantages:
according to the embodiment of the invention, by acquiring the vertex data of the game model, the convex hull of the game model in the world space can be calculated based on the vertex data, and after a preset game editor scene is divided into grids to obtain a plurality of grid points, the target grid points in the game model can be determined according to the convex hull of the game model in the world space, and then the placing position of the game model can be determined according to the target grid points. According to the embodiment, the game model is uploaded to the game editor, the specific placing position of the game model in a scene can be automatically, efficiently and accurately calculated by the game editor, other preprocessing on the game model is not needed, the problems that a large amount of placing space is wasted when the placing position of the model is calculated and the size of the model needs to be defined in advance in the prior art are solved, the efficiency of determining the position of the game model is improved, and the accuracy of position calculation is also improved.
Drawings
FIG. 1 is a flow chart illustrating the steps of a method for determining a placement of a game model according to one embodiment of the present invention;
FIG. 2 is a flow chart illustrating steps of another method for determining a placement of a game model according to one embodiment of the invention;
fig. 3 is a schematic block diagram of an apparatus for determining a placement position of a game model according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Referring to fig. 1, a schematic flow chart illustrating steps of a method for determining a placement position of a game model according to an embodiment of the present invention may specifically include the following steps:
the game model may be a three-dimensional model, and various game elements such as characters, trees, and stones in the 3D game can be presented by uploading the model to a game editor and rendering the model by a GPU.
Generally, after models which are overlapped or partially overlapped in a game editor scene are rendered, corresponding objects presented in an actual game scene are overlapped, so that game visual effects are influenced. Therefore, in order to avoid overlap between different models, the placement positions of the game models need to be determined one by one.
In determining the placement position of the game, vertex data of each game model may be acquired first.
In the embodiment of the invention, the game model can be an object which is manufactured in a certain scene and has a specific shape. For example, a certain 3D game model may be composed of a small triangle, and the coordinate value of the vertex of each triangle in the coordinate system is the vertex data of the game model.
Typically, the vertex data for the game model may be obtained by parsing the game model file.
102, calculating a convex hull of the game model in the world space based on the vertex data;
generally, each game model is created in a certain space, and the space for creating the game model can be regarded as a partial space.
For local space, the center point of the game model can be generally used as the coordinate origin of the local space. In the local space, spatial information of the game model itself is recorded.
When a game model is placed in a game editor, the scene space corresponding to the game editor may be referred to as world space.
In the embodiment of the invention, after the vertex data of the game model is obtained, the convex hull of the game model in the world space can be calculated based on the vertex data.
The Convex Hull (Convex Hull) is a concept in computational geometry (graphics), and in a real vector space V, the intersection S of all Convex sets containing X for a given set X is called the Convex Hull of X.
In a specific implementation, the convex hull of the game model in the local space can be calculated based on the vertex data of the game model, and then the convex hull of the game model in the world space can be calculated based on the convex hull.
Of course, those skilled in the art can calculate the convex hull of the game model in the world space by using an appropriate method according to actual needs, which is not limited in this embodiment.
in the embodiment of the present invention, in order to determine the specific placement position of the game model in the game editor, the scene space of the game editor may be divided into a plurality of grids, and a plurality of grid points may be obtained. The grid points described above may be used to divide the intersection between any two straight lines of the game editor scene.
In particular implementations, the accuracy of dividing the game editor scene may be less than or equal to the minimum size of the game model.
For example, if the bounding box size of a game model is 0.4 x 0.4, in order to more accurately determine which of the meshes the game model occupies includes, the game editor scene should be divided with an accuracy of not more than 0.4 x 0.4.
104, determining a target grid point in the game model according to the convex hull of the game model in the world space;
in general, the convex hull of the game model in the world space is generally an irregular polygon, and the grid points in the world space are not necessarily all inside the game model. Therefore, after the game editor scene is divided into grids and a plurality of grid points are obtained, the target grid points positioned in the game model can be further extracted.
Euclidean space theorem has demonstrated that when a ray crosses a polygon boundary an even number of times, all even (including last) passes are outages and, correspondingly, all odd (including first) passes are onsets. Thus, in a particular implementation, it may be determined which grid points belong to a target grid point within the model based on euclidean space theorem.
That is, when a certain grid point is taken as a ray and the number of times that the certain grid point crosses the convex hull boundary in a certain direction is an odd number of times, the grid point can be considered as a target grid point inside the model.
And 105, determining the placing position of the game model according to the target grid point.
In the embodiment of the present invention, after all target grid points located inside a game model are found, it may be determined whether the target grid points are occupied by other game models in a game editor scene space, and if all the target grid points are not occupied by other game models, a position corresponding to the target grid points may be used as a placement position of the game model.
In the embodiment of the invention, by obtaining the vertex data of the game model, then the convex hull of the game model in the world space can be calculated based on the vertex data, and after a preset game editor scene is divided into grids to obtain a plurality of grid points, the target grid points in the game model can be determined according to the convex hull of the game model in the world space, and then the placing position of the game model can be determined according to the target grid points. According to the embodiment, the game model is uploaded to the game editor, the specific placing position of the game model in a scene can be automatically, efficiently and accurately calculated by the game editor, other preprocessing on the game model is not needed, the problems that a large amount of placing space is wasted when the placing position of the model is calculated and the size of the model needs to be defined in advance in the prior art are solved, the efficiency of determining the position of the game model is improved, and the accuracy of position calculation is also improved.
Referring to fig. 2, a schematic flow chart illustrating steps of another method for determining a placement position of a game model according to an embodiment of the present invention may specifically include the following steps:
in an embodiment of the present invention, a game model file may be used to record various information of the game model. The game model may be a three-dimensional model, and a game player or a game designer may design a game at his or her will by uploading the model to a game editor.
in the embodiment of the present invention, the local space may refer to a space for making the game model, and the local space generally takes the central point of the game model as the coordinate origin of the space. The coordinate value of each vertex of the game model in the local space is the vertex data of the game model in the local space.
It should be noted that the game model can be divided into two types, i.e. with animation (i.e. dynamic model) and without animation (i.e. static model). For a game model without animation, the vertex data does not change in the local space. In the case of a game model with animation, the vertices may change, and therefore, the vertex data of the game model with animation may refer to the initial vertex data of each vertex of the object corresponding to the model in the static state.
Typically, but typically, for animated game models, the change in the apex of the small arc is within the error range of the model placement. Therefore, as long as the vertices of the game model placed in the game editor do not overlap with each other, the objects do not overlap with each other in the game interface presented to the player after rendering. Therefore, in order to avoid overlap between different models, vertex data of each game model can be acquired, and the placement positions of the game models can be determined one by one according to the vertex data.
In a specific implementation, the vertex data of the game model is generally recorded in a Mesh file of the model, and the vertex data of each vertex of the game model can be obtained by analyzing the data structure of the Mesh file.
in the embodiment of the invention, the vertex data of the three-dimensional game model in the local space should also be three-dimensional data, including values such as length, width and the like. Therefore, after obtaining the vertex data of the game model in the local space, the vertex data may be subjected to a height removal process to generate target vertex data.
In the game field, the height data is generally data of an intermediate position of three-dimensional coordinate values. For example, if the vertex data of a vertex is (3,9,4), the target vertex data obtained after the height removal processing is (3,0, 4).
after the embodiment of the invention, the target vertex data after the height removing processing only comprises data in two directions of length and width. Therefore, when the convex hull of the game model in the local space is calculated using the target vertex data, it can be considered that the convex hull of the game model in the two-dimensional space is calculated using the data.
In specific implementation, the target vertices with the maximum and minimum abscissa values in the target vertex data may be extracted first, a target straight line may be generated by connecting the target vertices with the maximum and minimum abscissa values, and based on the target straight line, the plurality of target vertices may be divided into a positive direction point set and a negative direction point set, and then the convex hull in the local space may be calculated according to the positive direction point set and the negative direction point set.
For example, all target vertices may be first arranged in the abscissa direction (i.e., the X-axis direction) from small to large. According to the properties of the convex hull, the points with the maximum and minimum abscissa values are always on the convex hull. Assuming that the two target vertices with the largest and smallest abscissa values are a (x1, y1) and b (x2, y2), respectively, a straight line connecting the two points ab can divide all the target vertices into two parts, namely a positive direction and a negative direction.
Assuming that point c (c3, y3) is present, if the counterclockwise direction is the positive direction and point a is the motionless point, vector ab rotates counterclockwise to point c, which sweeps inside the parallelogram formed by vector ac and vector ab. Then the determinant of the parallelogram (cross product of vector ac and vector ab) is positive. I.e. the value of area is positive in the following formula:
area=x1*y2+x3*y1+x2*y3-x3*y2-x2*y1-x1*y3
calculating the area value of any target vertex, and if the area value is positive, the point is a positive direction point set; if the area value is negative, the point is a set of negative direction points.
For the positive direction point set, the point farthest from the straight line ab (i.e. the point with the largest area value) is found, and it is known from the property of the convex hull that the point in the triangle formed by anb points cannot be the point on the convex hull, so the straight line an and nb partitions take the positive direction point set, recursion is performed on the above steps, and the same processing is performed on the negative direction point set, so the convex hull of the game model in the local space can be calculated.
after the convex hull of the game model in the local space is calculated, the convex hull of the game model in the world space can be further calculated on the basis of the convex hull.
In a specific implementation, a world space matrix of the game model in the world space may be first determined, and then coordinate values of the plurality of target vertices may be multiplied by the world space matrix to obtain a convex hull in the world space.
The local space matrix of the game model in the local space records the occupation information of the model in the local space, and can be directly obtained by analyzing the game model file. On the basis, after the game model is placed in a scene, the local space matrix is used for carrying out processing such as translation, rotation, scaling and the like, and finally, a world space matrix is generated. Then, the coordinate value of each vertex is multiplied by the world space matrix to obtain the convex hull of the game model in the world space.
in an embodiment of the present invention, before dividing a game editor scene into meshes, the division accuracy of the meshes may be determined first.
Generally, the partition accuracy of the mesh should be less than or equal to the minimum size of the game model, which may refer to the minimum area size of the bounding box of the game model.
For example, if the bounding box size of the game model is 0.4 x 0.4, then the partitioning accuracy should not be greater than 0.4 x 0.4.
After the specific division precision is determined, a preset game editor scene can be divided into a plurality of grids according to the division precision, and a plurality of grid points are obtained.
in general, the convex hull of the game model in the world space is generally an irregular polygon, and the grid points in the world space are not necessarily all inside the game model. Therefore, after the game editor scene is divided into grids and a plurality of grid points are obtained, the target grid points positioned in the game model can be further extracted.
In the embodiment of the present invention, for any grid point, a ray may be generated with the grid point as an end point and the X-axis direction as a direction, and then the number of intersections of the ray with a convex hull in the world space is determined, so that a grid point whose number of intersections is odd may be extracted as a target grid point.
in the embodiment of the present invention, after determining which grid points belong to target grid points in the model, it is further required to determine whether the target grid points are occupied by other game models.
If all the grid points are not occupied by any other game model, the position corresponding to the target grid point can be used for placing the current game model.
In the embodiment of the present invention, after the game model is placed at the position corresponding to the target grid point, the grid point occupied by the game model may be marked as occupied, so as to prohibit other game models from being placed at the grid point.
It should be noted that, if the placed game model is moved or otherwise manipulated, so that the placement position of the game model changes, the occupation mark of the grid point occupied by the game model before may be deleted, so that other models may be placed at the grid point.
In the embodiment of the invention, the vertex data of the game model in the local space can be obtained by analyzing the game model file, and after the vertex data is subjected to height removal processing, the two-dimensional convex hull of the game model in the local space can be calculated according to the vertex data, so that the convex hull of the game model in the world space corresponding to the scene space of the game editor can be obtained. After a game editor scene is divided into grids according to a certain division precision, which grid points are positioned in a game model can be determined according to convex hulls in a world space, if the grid points positioned in the game model are not occupied by other game models, the grid points are in an empty state, and the game model can be placed at the position. According to the method and the device, the specific placing position of the game model in the scene is automatically calculated through the game editor, other preprocessing is not needed to be carried out on the game model, the efficiency of determining the position of the game model is improved, and the accuracy of position calculation is also improved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. 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. 3, a schematic block diagram of an apparatus for determining a placement position of a game model according to an embodiment of the present invention is shown, which may specifically include the following modules:
a vertex data obtaining module 301, configured to obtain vertex data of a game model;
a convex hull calculation module 302, configured to calculate a convex hull of the game model in the world space based on the vertex data;
a mesh dividing module 303, configured to divide a preset game editor scene into meshes, where a mesh may include multiple mesh points;
a target grid point determining module 304, configured to determine a target grid point inside the game model according to a convex hull of the game model in a world space;
and a placing position determining module 305, configured to determine a placing position of the game model according to the target grid point.
In this embodiment of the present invention, the vertex data obtaining module 301 may specifically include the following sub-modules:
the game model file acquisition submodule is used for acquiring a game model file;
and the game model file analysis submodule is used for analyzing the game model file to obtain vertex data in a local space.
In this embodiment of the present invention, the convex hull calculation module 302 may specifically include the following sub-modules:
the target vertex data generating submodule is used for performing height removal processing on the vertex data in the local space to generate target vertex data;
the local space convex hull calculating submodule is used for calculating the convex hull of the game model in the local space by adopting the target vertex data;
and the world space convex hull calculation sub-module is used for calculating the convex hull of the game model in the world space based on the convex hull in the local space.
In this embodiment of the present invention, the local spatial convex hull calculation sub-module specifically includes the following units:
the target vertex extraction unit is used for extracting target vertices with the maximum and minimum horizontal coordinate values in the target vertex data;
the target straight line generating unit is used for connecting the target vertexes with the maximum and minimum horizontal coordinate values to generate a target straight line;
the target vertex dividing unit is used for dividing a plurality of target vertexes into a positive direction point set and a negative direction point set based on the target straight line;
and the local space convex hull calculating unit is used for calculating the convex hull in the local space according to the positive direction point set and the negative direction point set.
In the embodiment of the present invention, the world space convex hull calculation sub-module may specifically include the following units:
a world space matrix determination unit for determining a world space matrix of the game model in the world space;
a world space convex hull calculation unit for multiplying coordinate values of a plurality of target vertices by the world space matrix to obtain a convex hull in the world space.
In this embodiment of the present invention, the mesh division module 303 may specifically include the following sub-modules:
the division precision determining submodule is used for determining the division precision of the grids, and the division precision is smaller than or equal to the minimum size of the game model;
and the grid division submodule is used for dividing the preset game editor scene into a plurality of grids according to the division precision.
In this embodiment of the present invention, the target grid point determining module 304 may specifically include the following sub-modules:
the ray generation submodule is used for generating rays for any grid point by taking the grid point as an end point and taking the X-axis direction as a direction;
an intersection number determination submodule for determining the number of intersections of the ray with a convex hull in the world space;
and the target grid point extracting submodule is used for extracting the grid points with odd times of intersection as target grid points.
In this embodiment of the present invention, the placement position determining module 305 may specifically include the following sub-modules:
a target grid point occupation determination submodule for determining whether the target grid point is occupied by other game models;
and the game model placing position determining submodule is used for determining the position corresponding to the target grid point as the placing position of the game model if the target grid point is not occupied by other game models.
The invention also discloses a device for determining the placing position of the game model, which comprises a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs are configured to be executed by one or more processors and comprise instructions for: obtaining vertex data of a game model; calculating a convex hull of the game model in world space based on the vertex data; dividing a preset game editor scene into grids, wherein the grids comprise a plurality of grid points; determining a target grid point inside the game model according to a convex hull of the game model in a world space; and determining the placing position of the game model according to the target grid points.
Optionally, the one or more programs are also configured to be executed by the one or more processors to include instructions for: obtaining a game model file; and analyzing the game model file to obtain vertex data in a local space.
Optionally, the one or more programs are also configured to be executed by the one or more processors to include instructions for: performing height removal processing on the vertex data in the local space to generate target vertex data; calculating a convex hull of the game model in the local space by adopting the target vertex data; and calculating the convex hull of the game model in the world space based on the convex hull in the local space.
Optionally, the one or more programs are also configured to be executed by the one or more processors to include instructions for: extracting the target vertex with the maximum and minimum horizontal coordinate values in the target vertex data; connecting the target vertexes with the maximum and minimum horizontal coordinate values to generate a target straight line; dividing a plurality of target vertexes into a positive direction point set and a negative direction point set based on the target straight lines; and calculating the convex hull in the local space according to the positive direction point set and the negative direction point set.
Optionally, the one or more programs are also configured to be executed by the one or more processors to include instructions for: determining a world space matrix of the game model in the world space; multiplying coordinate values of a plurality of target vertices by the world space matrix to obtain a convex hull in the world space.
Optionally, the one or more programs are also configured to be executed by the one or more processors to include instructions for: determining the division precision of the grid, wherein the division precision is less than or equal to the minimum size of the game model; and dividing the preset game editor scene into a plurality of grids according to the division precision.
Optionally, the one or more programs are also configured to be executed by the one or more processors to include instructions for: for any grid point, generating rays by taking the grid point as an end point and taking the X-axis direction as a direction; determining a number of intersections of the ray with a convex hull in the world space; and extracting the grid points with odd times of intersection as target grid points.
Optionally, the one or more programs are also configured to be executed by the one or more processors to include instructions for: determining whether the target grid point is occupied by other game models; and if the target grid point is not occupied by other game models, determining the position corresponding to the target grid point as the placing position of the game model.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The invention also discloses an electronic device comprising a processor, a memory and a computer program stored on the memory and configured to run on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for determining the placement position of the game model as described above.
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 terminal 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, herein, relational terms such as first and second, and the like may be 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 "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method for determining the placement position of the game model, the device for determining the placement position of the game model and the electronic device provided by the invention are described in detail, specific examples are applied in the text to explain the principle and the implementation mode of the invention, and the description of the above examples is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (6)
1. A method for determining a placement position of a game model, comprising:
obtaining vertex data of a game model;
calculating a convex hull of the game model in world space based on the vertex data;
dividing a preset game editor scene into grids, wherein the grids comprise a plurality of grid points;
determining a target grid point inside the game model according to a convex hull of the game model in a world space;
determining the placing position of the game model according to the target grid points;
wherein the step of determining target mesh points inside the game model from the convex hull of the game model in world space comprises:
for any grid point, generating rays by taking the grid point as an end point and taking the X-axis direction as a direction;
determining a number of intersections of the ray with a convex hull in the world space;
extracting the grid points with odd times of intersection as target grid points;
wherein the step of obtaining vertex data of the game model comprises:
obtaining a game model file;
analyzing the game model file to obtain vertex data in a local space;
wherein the step of calculating the convex hull of the game model in world space based on the vertex data comprises:
performing height removal processing on the vertex data in the local space to generate target vertex data;
calculating a convex hull of the game model in the local space by adopting the target vertex data;
calculating a convex hull of the game model in world space based on the convex hull in the local space;
wherein the step of calculating the convex hull of the game model in the local space using the target vertex data comprises:
extracting the target vertex with the maximum and minimum horizontal coordinate values in the target vertex data;
connecting the target vertexes with the maximum and minimum horizontal coordinate values to generate a target straight line;
dividing a plurality of target vertexes into a positive direction point set and a negative direction point set based on the target straight lines;
calculating a convex hull in the local space according to the positive direction point set and the negative direction point set;
wherein the step of calculating the convex hull of the game model in world space based on the convex hull in the local space comprises:
determining a world space matrix of the game model in the world space;
multiplying coordinate values of a plurality of target vertices by the world space matrix to obtain a convex hull in the world space.
2. The method of claim 1, wherein the step of dividing the preset game editor scene into a grid comprises:
determining the division precision of the grid, wherein the division precision is less than or equal to the minimum size of the game model;
and dividing the preset game editor scene into a plurality of grids according to the division precision.
3. The method of claim 1, wherein the step of determining the placement of the game model based on the target grid points comprises:
determining whether the target grid point is occupied by other game models;
and if the target grid point is not occupied by other game models, determining the position corresponding to the target grid point as the placing position of the game model.
4. An apparatus for determining a placement position of a game model, comprising:
the vertex data acquisition module is used for acquiring vertex data of the game model;
the convex hull calculation module is used for calculating the convex hull of the game model in the world space based on the vertex data;
the system comprises a grid division module, a game editing module and a display module, wherein the grid division module is used for dividing a preset game editor scene into grids, and each grid comprises a plurality of grid points;
the target grid point determining module is used for determining target grid points in the game model according to the convex hull of the game model in the world space;
the placing position determining module is used for determining the placing position of the game model according to the target grid points;
wherein the target grid point determining module comprises:
the ray generation submodule is used for generating rays for any grid point by taking the grid point as an end point and taking the X-axis direction as a direction;
an intersection number determination submodule for determining the number of intersections of the ray with a convex hull in the world space;
the target grid point extracting submodule is used for extracting the grid points with odd times of intersection as target grid points;
wherein, the vertex data obtaining module comprises:
the game model file acquisition submodule is used for acquiring a game model file;
the game model file analysis submodule is used for analyzing the game model file to obtain vertex data in a local space;
wherein the convex hull computation module comprises:
the target vertex data generating submodule is used for performing height removal processing on the vertex data in the local space to generate target vertex data;
the local space convex hull calculating submodule is used for calculating the convex hull of the game model in the local space by adopting the target vertex data;
a world space convex hull calculation submodule for calculating a convex hull of the game model in the world space based on the convex hull in the local space;
wherein the local spatial convex hull computation submodule comprises:
the target vertex extraction unit is used for extracting target vertices with the maximum and minimum horizontal coordinate values in the target vertex data;
the target straight line generating unit is used for connecting the target vertexes with the maximum and minimum horizontal coordinate values to generate a target straight line;
the target vertex dividing unit is used for dividing a plurality of target vertexes into a positive direction point set and a negative direction point set based on the target straight line;
the local space convex hull calculating unit is used for calculating a convex hull in the local space according to the positive direction point set and the negative direction point set;
wherein the world space convex hull computation submodule comprises:
a world space matrix determination unit for determining a world space matrix of the game model in the world space;
a world space convex hull calculation unit for multiplying coordinate values of a plurality of target vertices by the world space matrix to obtain a convex hull in the world space.
5. An apparatus for determining a pose location of a game model, comprising a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured for execution by one or more processors, the one or more programs comprising instructions for:
obtaining vertex data of a game model;
calculating a convex hull of the game model in world space based on the vertex data;
dividing a preset game editor scene into grids, wherein the grids comprise a plurality of grid points;
determining a target grid point inside the game model according to a convex hull of the game model in a world space;
determining the placing position of the game model according to the target grid points;
wherein the step of determining target mesh points inside the game model from the convex hull of the game model in world space comprises:
for any grid point, generating rays by taking the grid point as an end point and taking the X-axis direction as a direction;
determining a number of intersections of the ray with a convex hull in the world space;
extracting the grid points with odd times of intersection as target grid points;
wherein the step of obtaining vertex data of the game model comprises:
obtaining a game model file;
analyzing the game model file to obtain vertex data in a local space;
wherein the step of calculating the convex hull of the game model in world space based on the vertex data comprises:
performing height removal processing on the vertex data in the local space to generate target vertex data;
calculating a convex hull of the game model in the local space by adopting the target vertex data;
calculating a convex hull of the game model in world space based on the convex hull in the local space;
wherein the step of calculating the convex hull of the game model in the local space using the target vertex data comprises:
extracting the target vertex with the maximum and minimum horizontal coordinate values in the target vertex data;
connecting the target vertexes with the maximum and minimum horizontal coordinate values to generate a target straight line;
dividing a plurality of target vertexes into a positive direction point set and a negative direction point set based on the target straight lines;
calculating a convex hull in the local space according to the positive direction point set and the negative direction point set;
wherein the step of calculating the convex hull of the game model in world space based on the convex hull in the local space comprises:
determining a world space matrix of the game model in the world space;
multiplying coordinate values of a plurality of target vertices by the world space matrix to obtain a convex hull in the world space.
6. An electronic device comprising a processor, a memory, and a computer program stored on the memory and configured to run on the processor, the computer program, when executed by the processor, implementing the steps of the method of determining a pose of a game model according to any one of claims 1 to 3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810574364.9A CN108744520B (en) | 2018-06-05 | 2018-06-05 | Method and device for determining placement position of game model and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810574364.9A CN108744520B (en) | 2018-06-05 | 2018-06-05 | Method and device for determining placement position of game model and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108744520A CN108744520A (en) | 2018-11-06 |
CN108744520B true CN108744520B (en) | 2022-02-22 |
Family
ID=63999998
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810574364.9A Active CN108744520B (en) | 2018-06-05 | 2018-06-05 | Method and device for determining placement position of game model and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108744520B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109920023B (en) * | 2019-03-28 | 2024-01-26 | 网易(杭州)网络有限公司 | Method and device for placing models in game |
CN112057854B (en) * | 2020-09-10 | 2024-07-12 | 网易(杭州)网络有限公司 | Game object processing method, game object processing device, electronic equipment and computer readable medium |
CN113808238A (en) * | 2021-09-24 | 2021-12-17 | 北京有竹居网络技术有限公司 | Animation rendering method and device, readable medium and electronic equipment |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103258345A (en) * | 2013-04-18 | 2013-08-21 | 中国林业科学研究院资源信息研究所 | Method for extracting parameters of tree branches based on ground laser radar three-dimensional scanning |
CN103295216A (en) * | 2012-02-24 | 2013-09-11 | 富士通株式会社 | Method and equipment for identifying space in three-dimensional model and image processing system |
CN103885788A (en) * | 2014-04-14 | 2014-06-25 | 焦点科技股份有限公司 | Dynamic WEB 3D virtual reality scene construction method and system based on model componentization |
CN104112017A (en) * | 2014-07-21 | 2014-10-22 | 无锡梵天信息技术股份有限公司 | Method of realizing script model exporting based on 3D MAX (Three-dimensional Studio Max) |
CN104700433A (en) * | 2015-03-24 | 2015-06-10 | 中国人民解放军国防科学技术大学 | Vision-based real-time general movement capturing method and system for human body |
CN105931296A (en) * | 2016-04-19 | 2016-09-07 | 中山大学 | Fast layout method of 3D printed object based on contour and device thereof |
CN106373184A (en) * | 2016-08-30 | 2017-02-01 | 苏州紫金港智能制造装备有限公司 | Three-dimensional printing model placing required support amount rapid estimation method |
CN106918311A (en) * | 2017-01-20 | 2017-07-04 | 山东科技大学 | Isolated tree crown mapping area automatic calculating method based on vehicle-mounted laser cloud data |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109791442B (en) * | 2016-10-05 | 2023-04-18 | 奇跃公司 | Surface modeling system and method |
-
2018
- 2018-06-05 CN CN201810574364.9A patent/CN108744520B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103295216A (en) * | 2012-02-24 | 2013-09-11 | 富士通株式会社 | Method and equipment for identifying space in three-dimensional model and image processing system |
CN103258345A (en) * | 2013-04-18 | 2013-08-21 | 中国林业科学研究院资源信息研究所 | Method for extracting parameters of tree branches based on ground laser radar three-dimensional scanning |
CN103885788A (en) * | 2014-04-14 | 2014-06-25 | 焦点科技股份有限公司 | Dynamic WEB 3D virtual reality scene construction method and system based on model componentization |
CN104112017A (en) * | 2014-07-21 | 2014-10-22 | 无锡梵天信息技术股份有限公司 | Method of realizing script model exporting based on 3D MAX (Three-dimensional Studio Max) |
CN104700433A (en) * | 2015-03-24 | 2015-06-10 | 中国人民解放军国防科学技术大学 | Vision-based real-time general movement capturing method and system for human body |
CN105931296A (en) * | 2016-04-19 | 2016-09-07 | 中山大学 | Fast layout method of 3D printed object based on contour and device thereof |
CN106373184A (en) * | 2016-08-30 | 2017-02-01 | 苏州紫金港智能制造装备有限公司 | Three-dimensional printing model placing required support amount rapid estimation method |
CN106918311A (en) * | 2017-01-20 | 2017-07-04 | 山东科技大学 | Isolated tree crown mapping area automatic calculating method based on vehicle-mounted laser cloud data |
Non-Patent Citations (1)
Title |
---|
Unity3D游戏之创建基本游戏场景一;feng;《https://gameinstitute.qq.com/community/detail/118582》;20171020;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN108744520A (en) | 2018-11-06 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11574438B2 (en) | Generating three-dimensional virtual scene | |
JP6787661B2 (en) | Simulation of machining of workpieces | |
JP6159807B2 (en) | Computer graphics method for rendering a three-dimensional scene | |
CN103761397B (en) | Three-dimensional model slice for surface exposure additive forming and projection plane generating method | |
CN102779358B (en) | Method and device for designing a geometrical three-dimensional modeled object | |
US8749588B2 (en) | Positioning labels in an engineering drawing | |
CN108744520B (en) | Method and device for determining placement position of game model and electronic equipment | |
CN111145356B (en) | Cutting method based on Unity3D model | |
JP2019032820A (en) | Data set for learning functions with image as input | |
CN104504760B (en) | The method and system of real-time update 3-D view | |
CN113724401B (en) | Three-dimensional model cutting method and device, computer equipment and storage medium | |
US8587586B2 (en) | Electronic device and method for meshing curved surface | |
US10650586B2 (en) | Automated mesh generation | |
CN113034688B (en) | Three-dimensional map model generation method and device | |
CN108090953B (en) | Region-of-interest reconstruction method, system and computer-readable storage medium | |
US8952968B1 (en) | Wave modeling for computer-generated imagery using intersection prevention on water surfaces | |
WO2024072703A1 (en) | Spatial test of bounding volumes for rasterization | |
CN110738719A (en) | Web3D model rendering method based on visual range hierarchical optimization | |
US9761046B2 (en) | Computing device and simulation method for processing an object | |
CN108553900B (en) | Method capable of being repeatedly used by overlapping storage based on UE engine | |
CN114691116A (en) | Method, system, device and readable storage medium for realizing 3D pie chart | |
CN107393019B (en) | Particle-based cloth simulation method and device | |
Weier et al. | Generating and rendering large scale tiled plant populations | |
CN112435322A (en) | Rendering method, device and equipment of 3D model and storage medium | |
CN104036547A (en) | Method and device for three-dimensional brush to generate network module in real time based on Leap Motion control |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |