Method and device for controlling placement of object in game, electronic equipment and storage medium
By using mask generation technology in construction games, dynamically generate base maps matching objects, solving the problem that objects with different shapes and sizes need to generate grid base maps separately, and dynamic generation of parameters of base maps is realized, reducing data processing volume and storage overhead.
Patent Information
- Application Number
- CN202411930509.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-02-28
Smart Images

Figure CN119524405A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for controlling the placement of objects in a game. Background Art
[0002] In some construction games, players can place objects in the scenes provided by the game to create customized game scenes. In order to reasonably occupy the scene space, objects can be placed in reasonable positions. Usually, when dragging objects into the scene, a grid base map corresponding to the objects can be generated to represent the area occupied by the objects, so as to determine whether the objects can be accurately placed in a certain position based on the grid map.
[0003] Currently, a method of making textures is generally adopted to make grid base maps corresponding to different objects.
[0004] However, the objects that need to be placed have different shapes and sizes. For objects of different shapes and sizes, corresponding maps need to be generated separately, which increases the amount of data processing. Summary of the invention
[0005] The purpose of the present application is to provide a method, device, electronic device and storage medium for controlling the placement of objects in a game, so as to realize the technology of parameterized adaptive generation of object base maps.
[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0007] In a first aspect, an embodiment of the present application provides a method for controlling the placement of objects in a game, wherein a terrain scene and a plurality of virtual objects for placing objects are provided on a user interface of a terminal, and the method comprises:
[0008] In response to a trigger operation for placing a target object among the multiple virtual objects, mask information is acquired; the mask information includes: a first direction coordinate parameter and a second direction coordinate parameter of a pixel point, wherein the coordinate parameter includes an adjustable parameter, and the adjustable parameter is related to a texture coordinate;
[0009] Generating a target base map matching the target object according to the texture coordinate information of the target object and the mask information;
[0010] According to the placement trigger operation, the target object to be placed is displayed in the terrain scene, and the target base map is displayed in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
[0011] In a second aspect, an embodiment of the present application further provides a device for controlling the placement of objects in a game, wherein a terrain scene and a plurality of virtual objects for placing objects are provided on a user interface of a terminal, and the device comprises: an acquisition module, a generation module, and a processing module;
[0012] The acquisition module is used to acquire mask information in response to a placement trigger operation for a target object among the multiple virtual objects; the mask information includes: a first direction coordinate parameter and a second direction coordinate parameter of a pixel point, wherein the coordinate parameters include an adjustable parameter, and the adjustable parameter is related to the texture coordinate;
[0013] The generating module is used to generate a target base map matching the target object according to the texture coordinate information of the target object and the mask information;
[0014] The processing module is used to display the target object to be placed in the terrain scene according to the placement trigger operation, and to display the target base map in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the method for controlling the placement of objects in the game as provided in the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for controlling the placement of objects in a game as provided in the first aspect is executed.
[0017] The beneficial effects of this application are:
[0018] The present application provides a method, device, electronic device and storage medium for controlling the placement of objects in a game, including: obtaining mask information in response to a placement trigger operation for a target object among multiple virtual objects; generating a target base map matching the target object according to the texture coordinate information and mask information of the target object; displaying the target object to be placed in the terrain scene according to the placement trigger operation, and displaying the target base map in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map. This solution uses the texture coordinate parameters of the object and the mask generation technology to generate general parameter-adjustable mask information, and binds the mask information to the corresponding face of the object. Therefore, when placing the object, the mask information bound to the object can be obtained, and the texture coordinates of the object are used as input parameters to adjust the mask information to generate a base map matching the object. Thus, a parameter-adjustable base map dynamic generation technology is realized. In this way, all objects can use the same mask information. During the running of the game, by collecting the texture coordinate information of the object in real time, the mask information matching the object can be generated in real time and dynamically. There is no need to pre-generate the corresponding base map for each object, reducing the package and memory overhead.
[0019] In addition, by setting the color parameter information, a base map of the desired color can be adaptively generated according to user needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 A schematic diagram of a flow chart of a method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0022] Figure 2 A schematic diagram of a user interface provided in an embodiment of the present application;
[0023] Figure 3 A schematic diagram of a flow chart of another method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0024] Figure 4 A schematic diagram of a flow chart of another method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0025] Figure 5 A schematic diagram of a mask image provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of a flow chart of another method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0027] Figure 7 A schematic diagram of a flow chart of another method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0028] Figure 8 A schematic diagram of a flow chart of another method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0029] Fig. 9 A schematic diagram of a flow chart of another method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0030] Fig.10 A schematic diagram of a flow chart of another method for controlling the placement of objects in a game provided in an embodiment of the present application;
[0031] Fig.11 A schematic diagram showing a base map provided in an embodiment of the present application;
[0032] Fig.12 A schematic diagram of a device for controlling the placement of objects in a game provided by an embodiment of the present application;
[0033] Fig.13 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.
[0035] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0036] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.
[0037] In some construction games, players are usually provided with a space area in the game interface to start the construction mode, and the objects to be built are usually irregular in size. When indicating whether these objects can be built, some grid-like square or rectangular base maps are usually placed at the bottom of the object to indicate the area occupied by the object, so as to judge whether the object can be placed in the corresponding position in the game scene based on the base map of the object.
[0038] In the existing game development process, when generating a base map representing the area occupied by an object, a method of making corresponding textures is generally used to make different base map sizes.
[0039] Although making textures can produce the corresponding effects, once it involves objects of different shapes and sizes, you cannot scale the texture size to match them, which will stretch the texture. In this case, you must make textures corresponding to the objects. If there are too many types of objects, a large number of textures will be generated, increasing the cost of the package and memory, and increasing the workload.
[0040] Based on this, this solution provides a method for controlling the placement of objects in a game. Through the texture coordinate parameters of the object, a mask generation technology is used to generate general parameter-adjustable mask information, and the mask information is bound to the corresponding face of the object. Therefore, when placing the object, the mask information bound to the object can be obtained, and the texture coordinates of the object are used as input parameters to adjust the mask information to generate a base map that matches the object. Thus, a parameter-adjustable base map dynamic generation technology is realized. As a result, all objects can use the same mask information. During the game running process, by collecting the texture coordinate information of the object in real time, the mask information matching the object can be generated in real time and dynamically, without the need to pre-generate the corresponding base map for each object, reducing the package and memory overhead.
[0041] Figure 1A flow chart of a method for controlling the placement of objects in a game provided in an embodiment of the present application; the executor of the method may be a terminal device, and a terrain scene and multiple virtual objects for placing objects may be provided on the user interface of the terminal, and players may drag virtual objects to corresponding positions in the terrain scene to construct the scene.
[0042] like Figure 1 As shown, the method may include:
[0043] S101. In response to a placement triggering operation on a target object among multiple virtual objects, obtain mask information.
[0044] The mask information includes: first direction coordinate parameters and second direction coordinate parameters of the pixel point, the coordinate parameters include adjustable parameters, and the adjustable parameters are related to the texture coordinates.
[0045] When building, the player can select a target object at a time from multiple virtual objects provided in the interface for placement.
[0046] The placement trigger operation can be a drag operation, and the player can trigger the placement of the selected target object into the terrain scene by dragging. In response to the player's placement trigger operation, the mask information bound to the target object can be obtained.
[0047] Of course, the placement trigger operation may also be a click operation, and the player may click on the target object to trigger the placement of the target object.
[0048] In this embodiment, the mask information may include coordinate parameters of each pixel constituting the mask, and the coordinate parameters may include adjustable parameters. That is, the mask information includes values that need to be determined in real time according to actual input, and when no data is input, the specific values corresponding to the adjustable parameters are unknown.
[0049] Optionally, the adjustable parameter may be a parameter related to texture coordinates. In a game, texture coordinates refer to texture coordinates of a model or a virtual object, and the texture coordinates of each object may be pre-generated in a game engine.
[0050] S102: Generate a target base map matching the target object according to the texture coordinate information and mask information of the target object.
[0051] Optionally, since the mask information includes adjustable parameters related to texture coordinates, the mask information can be dynamically adjusted according to the texture coordinate information of the object.
[0052] Optionally, texture coordinate information of the target object may be obtained, so that the general mask information with adjustable parameters is adjusted according to the texture coordinate information of the target object to generate a target base map matching the target object.
[0053] Since the texture coordinate information of each object is unique and related to the object itself, a target base map matching the target object can be generated based on the texture coordinate information of the target object.
[0054] S103. According to the placement trigger operation, the target object to be placed is displayed in the terrain scene, and the target base map is displayed in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
[0055] Optionally, according to the placement trigger operation, the target object can be displayed in the terrain scene, and the target base map associated with the target object can be displayed.
[0056] By displaying the target base map associated with the target object, the size of the terrain area occupied by the target object in the terrain scene can be determined, and thus, based on the size of the terrain area occupied by the target terrain, it can be determined whether the target object can be successfully placed at the required position in the terrain area.
[0057] Exemplarily, assuming that the occupied terrain area indicated by the target base map of the target object is 2 squares, and the player wants to place the target object between object 1 and object 2, and the free terrain area between object 1 and object 2 is 3 squares, then it can be determined that the target object can be successfully placed between object 1 and object 2, and if the free terrain area between object 1 and object 2 is 1 square, the target object cannot be placed between object 1 and object 2.
[0058] Figure 2 A user interface diagram provided in an embodiment of the present application. Figure 2 As shown, a game scene is displayed in the user interface, and the game scene includes a terrain scene and multiple virtual objects. In this embodiment, the terrain scene can be a grid terrain scene, and multiple virtual objects are displayed below the terrain scene. Players can display the target object in the terrain scene by dragging or clicking the target object. At the same time, according to the placement trigger operation, the base map of the target object can be generated in real time according to the above scheme. Therefore, while displaying the target object in the terrain scene, the base map showing the target object can also be associated. The base map can clearly show the number of terrain grids occupied by the target object, so that combined with the grid terrain scene, it can be judged whether the target object can be successfully placed in the desired position, and when it is judged that it can be placed, the target object is dragged and moved to the desired position.
[0059] In summary, the object placement control method provided by this embodiment includes: in response to the placement trigger operation for the target object among multiple virtual objects, obtaining mask information; generating a target base map matching the target object according to the texture coordinate information and mask information of the target object; according to the placement trigger operation, displaying the target object to be placed in the terrain scene, and displaying the target base map associated with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map. This scheme uses the texture coordinate parameters of the object and the mask generation technology to generate general parameter-adjustable mask information, and binds the mask information to the corresponding face of the object. Therefore, when placing the object, the mask information bound to the object can be obtained, and the texture coordinates of the object are used as input parameters to adjust the mask information to generate a base map matching the object. Thus, a parameter-adjustable base map dynamic generation technology is realized. In this way, all objects can use the same mask information. During the running of the game, by collecting the texture coordinate information of the object in real time, the mask information matching the object can be generated in real time and dynamically. There is no need to pre-generate the corresponding base map for each object, reducing the package and memory overhead.
[0060] Figure 3 A flowchart of another method for controlling the placement of objects in a game provided by an embodiment of the present application; optionally, in step S101, in response to a trigger operation for placing a target object, before obtaining mask information, the following may also be included:
[0061] S201. Generate mask information, and input the mask information into a material node to obtain a target material.
[0062] Generic mask information can be generated in advance and input into a material node to obtain a target material.
[0063] Among them, the material can include multiple attribute nodes, and different attribute nodes are used to provide a type of material attribute, such as: color attribute, map size, transparency attribute, etc. The mask information can be input into the opacity mask node of the material to obtain the target material.
[0064] S202 , binding the target material to a target patch of the target object, where the target patch is used to represent the bottom surface of the target object.
[0065] Next, the target material needs to be set on the target object. It is worth noting that all objects that need to generate a base map through this method need to be pre-bound to the target material.
[0066] Optionally, the target material can be dragged onto the target face of the target object. Since the base map of the target object is generated, only the bottom texture coordinate information of the target object needs to be referred to to adaptively generate the base map. Therefore, the target material can be dragged onto the bottom surface of the target object, that is, the target material is bound to the bottom surface of the target object.
[0067] Figure 4 A flowchart of another method for controlling the placement of objects in a game provided by an embodiment of the present application; Optionally, in step S201, generating mask information may include:
[0068] S301 , creating a first unit vector in a first direction and a second unit vector in a second direction.
[0069] First, we can build an object boundary algorithm that returns a scalar value equal to the x and y directions of the object, and compare it to the input scalar value to get a width value.
[0070] The first direction may be the x direction, and the second direction may be the y direction. First, a first unit vector float1(1, 0, 0) in the x direction may be created, and then a second unit vector float2(0, 1, 0) in the y direction may be created.
[0071] S302: Determine a first vector according to the first unit vector, the second unit vector and preset border width information, where the first vector is used to represent the border width information in the first direction and the border width information in the second direction in the world space coordinate system.
[0072] The preset border width information refers to the border width of the mask image to be generated. The mask image is constructed based on the generated mask information. The mask image is essentially an image composed of a data set, which contains multiple pixels. Therefore, the mask image corresponds to the mask information. The mask image is another form of expression of the mask information.
[0073] The vector float3 can be set according to the preset border width information, that is, float3 is a vector set according to the preset border width information. Thus, according to the above float1, float2 and float3, the first vector can be determined, assuming that the first vector is float4.
[0074] S303: Determine a target vector according to the first vector and texture coordinate parameters.
[0075] Next, a mask image in the x and y directions can be calculated using texture coordinates combined with an object boundary algorithm. The data representation corresponding to this mask image is the mask information mentioned above.
[0076] Optionally, the texture coordinate parameters may be scaled and moved according to the generated first vector in combination with the texture coordinate parameters to generate a target vector, and the target vector is used to represent the width information of the mask image.
[0077] S304: Generate mask information according to texture coordinate parameters and target vector.
[0078] Then, according to the texture coordinate parameters and the target vector, the mask information can be generated, that is, a mask image with width information is generated.
[0079] Figure 5 A schematic diagram of a mask image provided in an embodiment of the present application, Figure 5 The displayed mask image has the border width set above.
[0080] Figure 6 A flowchart of another method for controlling the placement of objects in a game provided by an embodiment of the present application; Optionally, in step S302, determining the first vector according to the first unit vector, the second unit vector and preset border width information may include:
[0081] S401. Convert the first unit vector and the second unit vector to the world scene space respectively to obtain a converted first unit vector and a converted second unit vector.
[0082] Optionally, the first unit vector float1 may be converted from the local space to the world scene space to obtain the converted first unit vector float5; the local space here may refer to the space where the object is located, that is, the local coordinates of the object are converted to the world coordinates.
[0083] Similarly, the second unit vector float2 is also converted from the local space to the world scene space to obtain the converted second unit vector float6.
[0084] S402, determine the vector length from the first unit vector to the origin after conversion, obtain scalar information of the first direction in the world scene space, and determine the vector length from the second unit vector to the origin after conversion, obtain scalar information of the second direction in the world scene space.
[0085] Next, calculate the vector length from the first unit vector float5 to the origin (0,0,0) after conversion to obtain scalar information 1 in the x direction in the world space.
[0086] Similarly, calculate the vector length from the converted second unit vector float6 to the origin (0,0,0) to obtain scalar information 1 in the y direction in the world space.
[0087] S403: Generate a second vector according to the scalar information of the first direction and the scalar information of the second direction.
[0088] The scalar information 1 in the x direction and the scalar information 1 in the y direction are combined into a new vector, that is, the second vector float6(1, 1).
[0089] S404: Create a corresponding third vector according to preset border width information.
[0090] According to the preset border width information, the third vector is set to obtain, that is, the above-mentioned float3 is obtained.
[0091] S405: Determine the first vector according to the second vector and the third vector.
[0092] Then, the third vector float3 is divided by the combined second vector float6 to obtain the first vector float4, where the first vector represents the width information in the x and y directions in the world space.
[0093] Figure 7 A flowchart of another method for controlling the placement of objects in a game provided by an embodiment of the present application; Optionally, in step S303, determining the target vector according to the first vector and the texture coordinate parameter may include:
[0094] S501. Determine a fourth vector according to the first vector and the first preset vector.
[0095] Optionally, the first vector float4 may be added to the first preset vector float7 to obtain a fourth vector float8, wherein the first preset vector float7 may be float7(1,1).
[0096] S502: Generate a fifth vector according to the fourth vector and texture coordinate parameters.
[0097] The fifth vector C can be obtained by multiplying the fourth vector float8 and the texture coordinate parameter uv.
[0098] It is worth noting that the texture coordinate parameter here is not a texture coordinate with a specific value, but a coordinate parameter without a value, so the generated fifth vector is a vector containing an adjustable parameter, and the adjustable parameter is the texture coordinate parameter.
[0099] Because adjustable parameters such as texture coordinate parameters are introduced in the process of generating mask information, when applying the mask information, the texture coordinate information of the virtual object of the base map to be generated can be substituted as the specific value of the texture coordinate parameter to solve the base map matched by the virtual object.
[0100] S503: Determine a sixth vector according to the first vector and the second preset vector.
[0101] The first vector float4 may be divided by the second preset vector float10 to obtain a sixth vector D.
[0102] The second preset vector float10 may be float10(2,2).
[0103] S504: Determine a seventh vector according to the fifth vector and the sixth vector.
[0104] By adding the fifth vector C and the sixth vector D, the seventh vector E can be obtained.
[0105] S505. Perform a fractional function operation on the seventh vector to obtain a target vector.
[0106] Then, the operation frac(E) is performed on the seventh vector E to obtain the target vector F.
[0107] Figure 8 A flowchart of another method for controlling the placement of objects in a game provided by an embodiment of the present application; Optionally, in step S304, generating mask information according to texture coordinate parameters and target vectors may include:
[0108] S601. Subtract the texture coordinate parameter from the target vector to obtain a mask coordinate parameter in a first direction and a mask coordinate parameter in a second direction.
[0109] Next, subtract the target vector F from the texture coordinate parameter uv to obtain the mask coordinate parameters in the x direction and the mask coordinate parameters in the y direction.
[0110] The mask coordinate parameters in the x direction are used to characterize the coordinate parameters of each point in the mask information to be generated in the x direction; the mask coordinate parameters in the y direction are used to characterize the coordinate parameters of each point in the mask information to be generated in the y direction.
[0111] S602: Obtain mask information according to the mask coordinate parameters in the first direction and the mask coordinate parameters in the second direction.
[0112] Then, the mask information can be represented as: (mask coordinate parameter in the first direction, mask coordinate parameter in the second direction).
[0113] Optionally, in step S102, generating a target base map matching the target object according to texture coordinate information and mask information of the target object may include: generating a target base map matching the target object according to texture coordinate information and mask information of each vertex on a target patch of the target object.
[0114] In some embodiments, when the placement of the target object is triggered, the mask information bound to the target patch of the target object can be obtained, so that the texture coordinate information of each vertex on the target patch of the target object can be obtained, and the texture coordinate information of each vertex on the target patch is used as input to adjust the mask information to generate a target base map that matches the target object.
[0115] Fig. 9 A flowchart of another method for controlling the placement of objects in a game provided by an embodiment of the present application; optionally, in the above steps, generating a target base map matching the target object according to the texture coordinate information and mask information of each vertex on the target face of the target object may include:
[0116] S701: Use texture coordinate information of each vertex as an adjustable parameter in mask information, and determine first direction coordinate values and second direction coordinate values of pixel points corresponding to each vertex in a target base map according to the mask information.
[0117] Based on the mask information obtained above (mask coordinate parameters in the first direction, mask coordinate parameters in the second direction), since the mask coordinate parameters in the first direction and the mask coordinate parameters in the second direction both contain adjustable parameters, and based on the generation process of the mask information, it can be known that the adjustable parameters are related to the texture coordinate parameters, then, by taking the texture coordinate information of each vertex on the target face as input, the adjustable parameters in the mask information can be assigned, thereby calculating the mask coordinate information in the first direction corresponding to each vertex and the mask coordinate information in the second direction corresponding to each vertex.
[0118] The mask coordinate information of the first direction corresponding to each vertex can be used as the first direction coordinate value of each pixel point in the target base map to be generated, and the mask coordinate information of the second direction corresponding to each vertex can be used as the second direction coordinate value of each pixel point in the target base map to be generated.
[0119] S702: Taking the maximum value of the first direction coordinate value and the second direction coordinate value of the pixel point as the pixel value of the pixel point.
[0120] If there is a negative number in the first direction coordinate value or the second direction coordinate value of the pixel point, the absolute value of the coordinate value of the pixel point can be taken first. Then, for a pixel point, the first direction coordinate value of the pixel point is compared with the second direction coordinate value of the pixel point, and the maximum value of the two coordinate values is taken as the pixel value of the pixel point.
[0121] S703: Generate a target base map that matches the target object according to the pixel values of the pixel points corresponding to each vertex in the target base map.
[0122] Since the image itself is composed of multiple pixels, then based on the pixel value of each pixel, an image composed of each pixel can be generated, and the image can be used as a target base map that matches the target object.
[0123] refer to Figure 2 The gray base map at the bottom of the target object is the generated target base map that matches the target object, and the size of the target base map is obtained by dynamically adjusting the mask information through the texture coordinate information of the target object.
[0124] Fig.10 A flowchart of another method for controlling the placement of objects in a game provided in an embodiment of the present application; optionally, the method of the present application may further include:
[0125] S801. In response to a placement triggering operation of a target object, obtain color parameter information.
[0126] The target base map generated based on the above method is a black and white image. In order to make the target base map more clearly distinguishable from the terrain in the game scene, the color parameter information can also be set to parameterize the base map of the desired color.
[0127] Optionally, you can set a color parameter information to be input into the material's Emissive Color node.
[0128] Then, after responding to the placement trigger operation of the target object, the color parameter information can also be obtained from the target material bound to the target object. The color parameter information here is a parameter without a specific value.
[0129] S802: Adjust the color parameter information according to the input target color information to generate the target color of the target base map.
[0130] By assigning values to the color parameter information according to the input target color information, a target base map with the target color can be generated.
[0131] Fig.11 A schematic diagram of a base map display provided in an embodiment of the present application shows three base maps, and the sizes of different base maps are different, and the sizes of different base maps are generated according to the texture coordinate information of the corresponding objects. The width of the light yellow border on the edge of the base map is generated by setting the preset border width information.
[0132] In addition, the color of each base map is yellow, which is generated by inputting data of color parameter information.
[0133] In summary, the object placement control method provided by this embodiment includes: in response to the placement trigger operation for the target object among multiple virtual objects, obtaining mask information; generating a target base map matching the target object according to the texture coordinate information and mask information of the target object; according to the placement trigger operation, displaying the target object to be placed in the terrain scene, and displaying the target base map associated with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map. This scheme uses the texture coordinate parameters of the object and the mask generation technology to generate general parameter-adjustable mask information, and binds the mask information to the corresponding face of the object. Therefore, when placing the object, the mask information bound to the object can be obtained, and the texture coordinates of the object are used as input parameters to adjust the mask information to generate a base map matching the object. Thus, a parameter-adjustable base map dynamic generation technology is realized. In this way, all objects can use the same mask information. During the running of the game, by collecting the texture coordinate information of the object in real time, the mask information matching the object can be generated in real time and dynamically. There is no need to pre-generate the corresponding base map for each object, reducing the package and memory overhead.
[0134] In addition, by setting the color parameter information, a base map of the desired color can be adaptively generated according to user needs.
[0135] The following describes the devices, equipment, storage media, etc. used to execute the method for controlling the placement of objects in the game provided by this application. The specific implementation process and technical effects are described above and will not be repeated below.
[0136] Fig.12 A schematic diagram of a device for controlling the placement of objects in a game provided in an embodiment of the present application. The functions implemented by the device for controlling the placement of objects in the game correspond to the steps performed by the above method. The device can be understood as the above-mentioned computer device, or server, or a processor of a server, or can also be understood as a component independent of the above-mentioned server or processor that implements the functions of the present application under the control of the server, such as Fig.12 As shown, the device may include: an acquisition module 110, a generation module 120 and a processing module 130;
[0137] The acquisition module 110 is used to acquire mask information in response to a placement trigger operation for a target object among the multiple virtual objects; the mask information includes: a first direction coordinate parameter and a second direction coordinate parameter of a pixel point, wherein the coordinate parameter includes an adjustable parameter, and the adjustable parameter is related to the texture coordinate;
[0138] A generating module 120, for generating a target base map matching the target object according to the texture coordinate information and mask information of the target object;
[0139] The processing module 130 is used to display the target object to be placed in the terrain scene according to the placement trigger operation, and to display the target base map associated with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
[0140] Optionally, the generating module 120 is further used to generate mask information, and input the mask information into the material node to obtain the target material;
[0141] Bind the target material to the target patch of the target object, where the target patch is used to represent the bottom surface of the target object.
[0142] Optionally, the generating module 120 is specifically configured to create a first unit vector in a first direction and a second unit vector in a second direction;
[0143] Determine a first vector according to the first unit vector, the second unit vector and the preset border width information, where the first vector is used to represent the border width information in the first direction and the border width information in the second direction in the world space coordinate system;
[0144] Determine a target vector according to the first vector and the texture coordinate parameter;
[0145] Generate mask information based on texture coordinate parameters and target vector.
[0146] Optionally, the generating module 120 is specifically used to convert the first unit vector and the second unit vector into the world scene space respectively to obtain the converted first unit vector and the converted second unit vector;
[0147] Determine the vector length from the first unit vector to the origin after the conversion, obtain the scalar information of the first direction in the world scene space, and determine the vector length from the second unit vector to the origin after the conversion, obtain the scalar information of the second direction in the world scene space;
[0148] Generate a second vector according to the scalar information of the first direction and the scalar information of the second direction;
[0149] According to the preset border width information, create a corresponding third vector;
[0150] The first vector is determined according to the second vector and the third vector.
[0151] Optionally, the generating module 120 is specifically configured to determine a fourth vector according to the first vector and the first preset vector;
[0152] Generate a fifth vector according to the fourth vector and the texture coordinate parameter;
[0153] Determine a sixth vector according to the first vector and the second preset vector;
[0154] Determine a seventh vector according to the fifth vector and the sixth vector;
[0155] Perform a fractional function operation on the seventh vector to obtain the target vector.
[0156] Optionally, the generating module 120 is specifically configured to subtract the texture coordinate parameter from the target vector to obtain a mask coordinate parameter in the first direction and a mask coordinate parameter in the second direction;
[0157] The mask information is obtained according to the mask coordinate parameter of the first direction and the mask coordinate parameter of the second direction.
[0158] Optionally, the generating module 120 is specifically configured to generate a target base map matching the target object according to texture coordinate information of each vertex on a target patch of the target object and mask information.
[0159] Optionally, the generating module 120 is specifically used to use the texture coordinate information of each vertex as an adjustable parameter in the mask information, and determine the first direction coordinate value and the second direction coordinate value of the pixel point corresponding to each vertex in the target base map according to the mask information;
[0160] The maximum value of the first direction coordinate value and the second direction coordinate value of the pixel point is used as the pixel value of the pixel point;
[0161] According to the pixel values of the pixels corresponding to each vertex in the target base map, a target base map matching the target object is generated.
[0162] Optionally, the generating module 120 is further configured to obtain color parameter information in response to a placement triggering operation of the target object;
[0163] According to the input target color information, the color parameter information is adjusted to generate the target color of the target base map.
[0164] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0165] The above modules can be connected or communicated with each other via a wired connection or a wireless connection. The wired connection may include a metal cable, an optical cable, a hybrid cable, etc., or any combination thereof. The wireless connection may include a connection in the form of a LAN, a WAN, Bluetooth, a ZigBee, or NFC, or any combination thereof. Two or more modules may be combined into a single module, and any one module may be divided into two or more units. Those skilled in the art will clearly understand that for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application.
[0166] Fig.13 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application includes: a processor 801, a storage medium 802 and a bus 803, wherein the storage medium 802 stores machine-readable instructions executable by the processor 801. When the electronic device runs a method for controlling the placement of objects in a game in the embodiment, the processor 801 communicates with the storage medium 802 via the bus 803, and a terrain scene and multiple virtual objects for placing objects are provided on the user interface of the terminal; the processor 801 executes the machine-readable instructions to perform the following steps:
[0167] In response to a trigger operation for placing a target object among the multiple virtual objects, mask information is obtained; the mask information includes: a first direction coordinate parameter and a second direction coordinate parameter of the pixel point, the coordinate parameter includes an adjustable parameter, and the adjustable parameter is related to the texture coordinate;
[0168] Generate a target base map matching the target object according to the texture coordinate information and mask information of the target object;
[0169] According to the placement trigger operation, the target object to be placed is displayed in the terrain scene, and the target base map is displayed in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
[0170] In a feasible implementation, before executing the placement trigger operation in response to the target object and obtaining the mask information, the processor 801 is further used to: generate the mask information and input the mask information into the material node to obtain the target material;
[0171] Bind the target material to the target patch of the target object, where the target patch is used to represent the bottom surface of the target object.
[0172] In a feasible implementation, when executing the generation of mask information, the processor 801 is specifically configured to: create a first unit vector in a first direction and a second unit vector in a second direction;
[0173] Determine a first vector according to the first unit vector, the second unit vector and the preset border width information, where the first vector is used to represent the border width information in the first direction and the border width information in the second direction in the world space coordinate system;
[0174] Determine a target vector according to the first vector and the texture coordinate parameter;
[0175] Generate mask information based on texture coordinate parameters and target vector.
[0176] In a feasible implementation manner, when the processor 801 determines the first vector according to the first unit vector, the second unit vector and the preset border width information, it is specifically used to: convert the first unit vector and the second unit vector to the world scene space respectively to obtain the converted first unit vector and the converted second unit vector;
[0177] Determine the vector length from the first unit vector to the origin after the conversion, obtain the scalar information of the first direction in the world scene space, and determine the vector length from the second unit vector to the origin after the conversion, obtain the scalar information of the second direction in the world scene space;
[0178] Generate a second vector according to the scalar information of the first direction and the scalar information of the second direction;
[0179] According to the preset border width information, create a corresponding third vector;
[0180] The first vector is determined according to the second vector and the third vector.
[0181] In a feasible implementation, when the processor 801 determines the target vector according to the first vector and the texture coordinate parameter, it is specifically used to: determine the fourth vector according to the first vector and the first preset vector;
[0182] Generate a fifth vector according to the fourth vector and the texture coordinate parameter;
[0183] Determine a sixth vector according to the first vector and the second preset vector;
[0184] Determine a seventh vector according to the fifth vector and the sixth vector;
[0185] Perform a fractional function operation on the seventh vector to obtain the target vector.
[0186] In a feasible implementation, when the processor 801 generates mask information according to the texture coordinate parameter and the target vector, it is specifically used to: subtract the texture coordinate parameter from the target vector to obtain the mask coordinate parameter in the first direction and the mask coordinate parameter in the second direction;
[0187] The mask information is obtained according to the mask coordinate parameter of the first direction and the mask coordinate parameter of the second direction.
[0188] In a feasible implementation scheme, when the processor 801 generates a target base map that matches the target object based on the texture coordinate information and mask information of the target object, it is specifically used to: generate a target base map that matches the target object based on the texture coordinate information and mask information of each vertex on the target patch of the target object.
[0189] In a feasible implementation scheme, when the processor 801 generates a target base map matching the target object according to the texture coordinate information of each vertex on the target face of the target object and the mask information, it is specifically used to: use the texture coordinate information of each vertex as an adjustable parameter in the mask information, and determine the first direction coordinate value and the second direction coordinate value of the pixel point corresponding to each vertex in the target base map according to the mask information;
[0190] The maximum value of the first direction coordinate value and the second direction coordinate value of the pixel point is used as the pixel value of the pixel point;
[0191] According to the pixel values of the pixels corresponding to each vertex in the target base map, a target base map matching the target object is generated.
[0192] In a feasible implementation, the processor 801 is further configured to execute: in response to a placement triggering operation of the target object, obtaining color parameter information;
[0193] According to the input target color information, the color parameter information is adjusted to generate the target color of the target base map.
[0194] Among them, the storage medium 802 stores program code. When the program code is executed by the processor 801, the processor 801 executes various steps in the method for controlling the placement of objects in the game according to various exemplary embodiments of the present application described in the above "Exemplary Method" section of this specification.
[0195] Processor 801 can be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor (DigitalSignal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as a hardware processor to be executed, or a combination of hardware and software modules in the processor can be executed.
[0196] Storage medium 802, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), programmable read-only memory (Programmable Read Only Memory, PROM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic memory, disk, optical disk, etc. The memory is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The storage medium 802 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0197] Optionally, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor performs the following steps:
[0198] In response to a trigger operation for placing a target object among the multiple virtual objects, mask information is obtained; the mask information includes: a first direction coordinate parameter and a second direction coordinate parameter of the pixel point, the coordinate parameter includes an adjustable parameter, and the adjustable parameter is related to the texture coordinate;
[0199] Generate a target base map matching the target object according to the texture coordinate information and mask information of the target object;
[0200] According to the placement trigger operation, the target object to be placed is displayed in the terrain scene, and the target base map is displayed in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
[0201] In a feasible implementation, before executing the placement trigger operation in response to the target object and obtaining the mask information, the processor 801 is further used to: generate the mask information and input the mask information into the material node to obtain the target material;
[0202] Bind the target material to the target patch of the target object, where the target patch is used to represent the bottom surface of the target object.
[0203] In a feasible implementation, when executing the generation of mask information, the processor 801 is specifically configured to: create a first unit vector in a first direction and a second unit vector in a second direction;
[0204] Determine a first vector according to the first unit vector, the second unit vector and the preset border width information, where the first vector is used to represent the border width information in the first direction and the border width information in the second direction in the world space coordinate system;
[0205] Determine a target vector according to the first vector and the texture coordinate parameter;
[0206] Generate mask information based on texture coordinate parameters and target vector.
[0207] In a feasible implementation manner, when the processor 801 determines the first vector according to the first unit vector, the second unit vector and the preset border width information, it is specifically used to: convert the first unit vector and the second unit vector to the world scene space respectively to obtain the converted first unit vector and the converted second unit vector;
[0208] Determine the vector length from the first unit vector to the origin after the conversion, obtain the scalar information of the first direction in the world scene space, and determine the vector length from the second unit vector to the origin after the conversion, obtain the scalar information of the second direction in the world scene space;
[0209] Generate a second vector according to the scalar information of the first direction and the scalar information of the second direction;
[0210] According to the preset border width information, create a corresponding third vector;
[0211] The first vector is determined according to the second vector and the third vector.
[0212] In a feasible implementation, when the processor 801 determines the target vector according to the first vector and the texture coordinate parameter, it is specifically used to: determine the fourth vector according to the first vector and the first preset vector;
[0213] Generate a fifth vector according to the fourth vector and the texture coordinate parameter;
[0214] Determine a sixth vector according to the first vector and the second preset vector;
[0215] Determine a seventh vector according to the fifth vector and the sixth vector;
[0216] Perform a fractional function operation on the seventh vector to obtain the target vector.
[0217] In a feasible implementation, when the processor 801 generates mask information according to the texture coordinate parameter and the target vector, it is specifically used to: subtract the texture coordinate parameter from the target vector to obtain the mask coordinate parameter in the first direction and the mask coordinate parameter in the second direction;
[0218] The mask information is obtained according to the mask coordinate parameter of the first direction and the mask coordinate parameter of the second direction.
[0219] In a feasible implementation scheme, when the processor 801 generates a target base map that matches the target object based on the texture coordinate information and mask information of the target object, it is specifically used to: generate a target base map that matches the target object based on the texture coordinate information and mask information of each vertex on the target patch of the target object.
[0220] In a feasible implementation scheme, when the processor 801 generates a target base map matching the target object according to the texture coordinate information of each vertex on the target face of the target object and the mask information, it is specifically used to: use the texture coordinate information of each vertex as an adjustable parameter in the mask information, and determine the first direction coordinate value and the second direction coordinate value of the pixel point corresponding to each vertex in the target base map according to the mask information;
[0221] The maximum value of the first direction coordinate value and the second direction coordinate value of the pixel point is used as the pixel value of the pixel point;
[0222] According to the pixel values of the pixels corresponding to each vertex in the target base map, a target base map matching the target object is generated.
[0223] In a feasible implementation, the processor 801 is further configured to execute: in response to a placement triggering operation of the target object, obtaining color parameter information;
[0224] According to the input target color information, the color parameter information is adjusted to generate the target color of the target base map.
[0225] In the embodiment of the present application, the computer program can also execute other machine-readable instructions when run by the processor to execute other methods described in the embodiment. For the specific execution method steps and principles, please refer to the description of the embodiment, which will not be repeated here.
[0226] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0227] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0228] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0229] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.
Claims
1. A method for placing and controlling objects in a game, characterized in that: A terrain scene and a plurality of virtual objects for placing objects are provided on a user interface of the terminal, and the method includes: In response to a trigger operation for placing a target object among the multiple virtual objects, mask information is acquired; the mask information includes: a first direction coordinate parameter and a second direction coordinate parameter of a pixel point, wherein the coordinate parameter includes an adjustable parameter, and the adjustable parameter is related to a texture coordinate; Generating a target base map matching the target object according to the texture coordinate information of the target object and the mask information; According to the placement trigger operation, the target object to be placed is displayed in the terrain scene, and the target base map is displayed in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
2. The method according to claim 1, characterized in that: In response to the triggering operation of placing the target object, before obtaining the mask information, the method further includes: Generate the mask information, and input the mask information into a material node to obtain a target material; The target material is bound to a target patch of the target object, where the target patch is used to represent a bottom surface of the target object.
3. The method according to claim 2, characterized in that The generating the mask information comprises: Creating a first unit vector in a first direction and a second unit vector in a second direction; Determine a first vector according to the first unit vector, the second unit vector and preset border width information, where the first vector is used to represent the border width information in the first direction and the border width information in the second direction in the world space coordinate system; Determine a target vector according to the first vector and texture coordinate parameters; The mask information is generated according to the texture coordinate parameters and the target vector.
4. The method according to claim 3, characterized in that The determining the first vector according to the first unit vector, the second unit vector and preset border width information includes: The first unit vector and the second unit vector are respectively converted to the world scene space to obtain a converted first unit vector and a converted second unit vector; Determine the vector length from the first unit vector after the conversion to the origin, and obtain the scalar information of the first direction in the world scene space; and determine the vector length from the second unit vector after the conversion to the origin, and obtain the scalar information of the second direction in the world scene space; Generate a second vector according to the scalar information of the first direction and the scalar information of the second direction; Creating a corresponding third vector according to the preset border width information; The first vector is determined according to the second vector and the third vector.
5. The method according to claim 3, characterized in that: The step of determining a target vector according to the first vector and the texture coordinate parameter comprises: Determine a fourth vector according to the first vector and the first preset vector; Generate a fifth vector according to the fourth vector and the texture coordinate parameter; Determine a sixth vector according to the first vector and the second preset vector; Determine a seventh vector according to the fifth vector and the sixth vector; A fractional function operation is performed on the seventh vector to obtain the target vector.
6. The method according to claim 3, characterized in that The step of generating the mask information according to the texture coordinate parameter and the target vector includes: Subtracting the texture coordinate parameter from the target vector to obtain a mask coordinate parameter in the first direction and a mask coordinate parameter in the second direction; The mask information is obtained according to the mask coordinate parameter of the first direction and the mask coordinate parameter of the second direction.
7. The method according to claim 2, characterized in that The step of generating a target base map matching the target object according to the texture coordinate information of the target object and the mask information includes: A target base map matching the target object is generated according to the texture coordinate information of each vertex on the target surface of the target object and the mask information.
8. The method according to claim 7, characterized in that The step of generating a target base map matching the target object according to the texture coordinate information of each vertex on the target face of the target object and the mask information comprises: Using the texture coordinate information of each vertex as an adjustable parameter in the mask information, and determining the first direction coordinate value and the second direction coordinate value of the pixel point corresponding to each vertex in the target base map according to the mask information; Taking the maximum value of the first direction coordinate value and the second direction coordinate value of the pixel point as the pixel value of the pixel point; A target base map matching the target object is generated according to the pixel values of the pixel points corresponding to each vertex in the target base map.
9. The method according to claim 1, characterized in that: The method further comprises: In response to a placement triggering operation of a target object, obtaining color parameter information; The color parameter information is adjusted according to the input target color information to generate the target color of the target base map.
10. A device for controlling the placement of objects in a game, characterized in that: A terrain scene and a plurality of virtual objects for placing objects are provided on the user interface of the terminal, and the device comprises: an acquisition module, a generation module and a processing module; The acquisition module is used to acquire mask information in response to a placement trigger operation for a target object among the multiple virtual objects; the mask information includes: a first direction coordinate parameter and a second direction coordinate parameter of a pixel point, wherein the coordinate parameters include an adjustable parameter, and the adjustable parameter is related to the texture coordinate; The generating module is used to generate a target base map matching the target object according to the texture coordinate information of the target object and the mask information; The processing module is used to display the target object to be placed in the terrain scene according to the placement trigger operation, and to display the target base map in association with the target object, so as to indicate the size of the terrain area occupied by the target object in the terrain scene when the target object is placed in the terrain scene through the target base map.
11. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the electronic device is running, the processor and the storage medium communicate via the bus, and the processor executes the program instructions to execute the method for placing objects in a game as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the method for controlling the placement of objects in the game as described in any one of claims 1 to 9 is executed.
