Virtual chess piece selection method and device, equipment, medium and product
By generating collision detection information on the screen plane and judging the three-dimensional virtual chess pieces based on the user's trigger operation, the latency problem caused by computational complexity in the existing technology is solved, and the user's control experience is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-11-12
- Publication Date
- 2026-05-12
AI Technical Summary
In existing technologies, the calculation method when players drag virtual chess pieces is complex, resulting in high calculation latency and affecting user experience.
By generating collision detection information for each 3D virtual chess piece on the screen plane and determining the user-selected 3D virtual chess piece based on the user's trigger operation and the first screen coordinates on the screen plane, complex calculations in 3D space are avoided.
It enables the rapid and accurate determination of the user's selected 3D virtual chess piece, improving the user's experience of controlling the virtual chessboard.
Smart Images

Figure CN122006237A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of human-computer interaction, and in particular to a method, apparatus, device, medium, and product for selecting virtual chess pieces. Background Technology
[0002] Auto Chess is a turn-based board game where players select one or more virtual pieces (or simply pieces) from newly purchased virtual pieces or those they already own and place them on a virtual board to battle against the opponent's virtual pieces. The virtual board itself becomes the battlefield for these virtual piece battles.
[0003] Players can arrange virtual pieces by dragging and dropping them to different positions on the virtual chessboard to implement different strategies, such as placing virtual pieces that are good at melee combat in the front row and virtual pieces that are good at ranged attacks in the back row.
[0004] In related technologies, when a player drags a virtual piece, they usually determine whether the ray emitted from the clicked position intersects with the bounding box surrounding the virtual piece. However, this method is relatively complex and has a high computational latency. Summary of the Invention
[0005] This application provides a method, apparatus, device, medium, and product for selecting virtual chess pieces, the technical solution of which is as follows:
[0006] According to one aspect of this application, a method for selecting virtual chess pieces is provided, the method comprising:
[0007] Display a virtual chessboard located in a three-dimensional virtual environment, the virtual chessboard including at least two virtual squares, and at least one three-dimensional virtual chess piece placed in at least one occupied virtual square of the virtual chessboard;
[0008] In response to a trigger operation on the virtual chessboard, collision detection information of the at least one three-dimensional virtual chess piece is obtained; and the first screen coordinates of the screen plane corresponding to the trigger operation are obtained; the collision detection information is used to indicate the collision detection area of the three-dimensional virtual chess piece in the screen plane;
[0009] Based on the at least one collision detection information and the first screen coordinates, the three-dimensional virtual chess piece selected by the triggering operation is determined.
[0010] According to one aspect of this application, a virtual chess piece selection device is provided, the device comprising:
[0011] The display module is used to display a virtual chessboard located in a three-dimensional virtual environment. The virtual chessboard includes at least two virtual squares, and at least one three-dimensional virtual chess piece is placed in at least one occupied virtual square of the virtual chessboard.
[0012] A response module is configured to, in response to a trigger operation on the virtual chessboard, acquire collision detection information of the at least one three-dimensional virtual chess piece; and acquire the first screen coordinates of the screen plane corresponding to the trigger operation; the collision detection information is used to indicate the collision detection area of the three-dimensional virtual chess piece in the screen plane;
[0013] The determination module is used to determine the three-dimensional virtual chess piece selected by the triggering operation based on the at least one collision detection information and the first screen coordinates.
[0014] According to one aspect of this application, a computer device is provided, the computer device including a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement a method for selecting virtual chess pieces.
[0015] According to one aspect of this application, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements a method for selecting virtual chess pieces.
[0016] According to one aspect of this application, a computer program product is provided, the computer program product comprising a computer program stored in a computer-readable storage medium; the computer program being read from and executed by a processor of a computer device from the computer-readable storage medium, causing the computer device to perform a method for selecting virtual chess pieces.
[0017] The beneficial effects of the technical solution provided in this application include at least the following:
[0018] By mapping 3D virtual chess pieces onto the screen plane to obtain collision detection information for each piece, and then determining the 3D virtual chess piece touched by the user based on the user's trigger operation's first planar coordinates on the screen plane and the collision detection information of each piece, this method identifies the 3D virtual chess piece touched by the user. Compared to methods based on bounding boxes in 3D space (i.e., determining which 3D virtual chess piece's bounding box the user's trigger operation intersects with), this method eliminates the need for 3D calculations, directly determining the piece in 2D. This reduces computational complexity and allows for faster results, enabling quick and accurate identification of the 3D virtual chess piece touched by the user, thus improving the user experience of controlling 3D virtual chess pieces on the virtual chessboard. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 An architectural diagram of a computer system provided in an exemplary embodiment of this application is shown;
[0021] Figure 2 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0022] Figure 3 A flowchart illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0023] Figure 4 A flowchart illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0024] Figure 5 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0025] Figure 6 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0026] Figure 7 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0027] Figure 8 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0028] Figure 9 A flowchart illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0029] Figure 10 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0030] Figure 11 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0031] Figure 12 This invention provides an overall flowchart of a virtual chess piece selection method according to an exemplary embodiment of the present application.
[0032] Figure 13 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0033] Figure 14 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0034] Figure 15 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0035] Figure 16 A schematic diagram illustrating a virtual chess piece selection method provided in an exemplary embodiment of this application is shown;
[0036] Figure 17 This invention illustrates a structural block diagram of a virtual chess piece selection device provided in an exemplary embodiment of this application;
[0037] Figure 18 A schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application is shown. Detailed Implementation
[0038] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0039] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0040] The terminology used in this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The singular forms “a,” “the,” and “the” as used in this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0041] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the settings and operation information involved in this application were obtained with full authorization.
[0042] It should be understood that although the terms first, second, etc., may be used in this disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, a first parameter may also be referred to as a second parameter without departing from the scope of this disclosure, and similarly, a second parameter may also be referred to as a first parameter. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0043] First, let me introduce the relevant terms used in this application:
[0044] Auto Chess: This is a general term for a type of electronic strategy turn-based board game. The basic rules are that players draw pieces, choose combinations from different types of pieces, and then place them on their own board. The system automatically battles against other players' pieces until only one player remains alive to win the round. The loser of each round loses a certain amount of health points, and this process is repeated until only one player survives.
[0045] Virtual chessboard: Refers to the area in the auto chess game interface used for preparing for and engaging in battle. It can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual chessboard. This application uses a three-dimensional virtual chessboard as an example, but this application does not limit it. The virtual chessboard is divided into a battle area and a preparation area. The battle area includes several identical battle squares used to place pieces that will engage in battle. The preparation area includes several preparation squares used to place reserve pieces. These reserve pieces do not participate in the battle but can be dragged and dropped into the battle area during the preparation phase. Players can sell, deploy, or retain pieces in the preparation area. The preparation area has a maximum capacity.
[0046] For example, regarding the arrangement of the chess pieces in the battle area, in one possible implementation, the battle area includes n (rows) × m (columns) battle chess pieces, where n is an integer multiple of 2, and adjacent rows of chess pieces are aligned, or adjacent rows of chess pieces are staggered. Furthermore, the battle area is divided into two parts by rows: the player's battle area and the opponent's battle area, and during the preparation phase, the user can only place chess pieces in their own battle area.
[0047] Virtual chess pieces: In auto chess games, virtual chess pieces are placed on the board, including playing virtual chess pieces and standby virtual chess pieces. Playing virtual chess pieces are located in the playing area, and standby virtual chess pieces are located in the standby area. Virtual chess pieces can be any of two-dimensional, 2.5-dimensional, or three-dimensional virtual chess pieces. This application uses three-dimensional virtual chess pieces as an example, but it is not limited thereto.
[0048] Camera Model: A virtual object that simulates the behavior and function of a real-world camera. Through a camera model, a virtual scene can be observed from different angles and perspectives. The settings and adjustments of the camera model can affect the visual effects of the rendered result, such as the resolution, image size, and viewpoint of the final rendered image. In some embodiments, the camera model can be called a virtual camera. Typically, the camera model is transparent, meaning it is not visible in the rendered image. Specifically, when determining the content of the virtual scene that the camera model can observe or capture, it is usually based on the view frustum of the camera model. The rendered image is an image obtained by computer equipment rendering the virtual scene.
[0049] The view frustum of a camera model: the visible space of the camera model. Generally speaking, the mesh models located within the view frustum and not occluded by other mesh models are what the camera model can capture and display on the screen. The view frustum of a camera model is similar to a pyramid with its top truncated. (The view frustum of a camera model can be referenced from...) Figure 2 The 3D model located within the view frustum of the camera model is situated within the visible space of the camera model. The size of the view frustum is adjustable and is typically related to the parameters of the camera model, which are set by the user or developer.
[0050] Virtual environment: This refers to the virtual environment displayed (or provided) by the client when running on the terminal. This virtual environment can be a simulation of the real world, a semi-simulated / semi-fictional environment, or a purely fictional environment. The virtual environment can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual environment; this application does not limit it to any particular type. The following embodiments use a three-dimensional virtual environment as an example.
[0051] Figure 1 A schematic diagram of a computer system provided in an exemplary embodiment of this application is shown. The computer system 100 may include: a first terminal 110, a server 120, and a second terminal 130.
[0052] The first terminal 110 has a first client 111 installed and running. The first client 111 is an application for turn-based chess games, such as auto chess games. The first terminal 110 is the terminal used by the first user 112. During the preparation and / or battle phases of the game, the first user 112 uses the first terminal 110 to purchase new virtual chess pieces or sell existing virtual chess pieces. Alternatively, during the preparation phase, the first user 112 uses the first terminal 110 to place virtual chess pieces in the battle area of the chessboard, such as dragging and dropping virtual chess pieces to place them on a virtual square of the virtual chessboard. During the battle phase, the first terminal 110 automatically controls the virtual chess pieces to engage in battle based on their attributes, skills, and layout in the battle area.
[0053] The second terminal 130 has a second client 131 installed and running. This second client 131 is an application for turn-based board games, such as auto-chess games. The second terminal 130 is used by the second user 132. During the preparation and / or gameplay phases, the second user 132 uses the second terminal 130 to purchase new virtual pieces or sell existing virtual pieces. Alternatively, during the preparation phase, the second user 132 uses the second terminal 130 to place virtual pieces in the gameplay area of the board, such as dragging and dropping virtual pieces onto a virtual square on the board. During the gameplay phase, the second terminal 130 automatically controls the virtual pieces to engage in combat based on their attributes, skills, and placement in the gameplay area.
[0054] Optionally, the first and second virtual pieces can belong to the same faction, team, organization, or have a friendly relationship. Optionally, the first and second virtual pieces can belong to different factions, teams, organizations, or have an adversarial relationship.
[0055] Optionally, the clients installed on the first terminal 110 and the second terminal 130 are the same, or the clients installed on the two terminals are the same type of client on different operating system platforms (Android or iOS). The first terminal 110 can refer to one of multiple terminals, and the second terminal 130 can refer to another of multiple terminals. This embodiment only uses the first terminal 110 and the second terminal 130 as examples. The device types of the first terminal 110 and the second terminal 130 may be the same or different, and these device types include at least one of the following: smartphones, tablets, e-book readers, MP3 players, MP4 players, laptops, and desktop computers.
[0056] Figure 1 Only two terminals are shown in the diagram, but in different embodiments, multiple other terminals 140 can access the server 120. Optionally, one or more terminals 140 may also be terminals corresponding to developers, on which a client development and editing platform is installed. Developers can edit and update the client on the terminal 140 and transmit the updated client installation package to the server 120 via wired or wireless network. The first terminal 110 and the second terminal 130 can download the client installation package from the server 120 to update the client.
[0057] The first terminal 110, the second terminal 130, and other terminals 140 are connected to the server 120 via a wireless or wired network. Optionally, when a terminal receives a user operation such as adding, adjusting, removing, or eliminating a virtual chess piece, it sends operation data to the server 120 based on the operation result corresponding to the user operation. The server 120 then updates the chess piece information of each virtual chess piece in the virtual chessboard. When a terminal receives a marking operation for a target virtual chess piece, it sends a chess piece information retrieval request to the server 120 to obtain the chess piece information and displays the target virtual chess piece on the virtual chessboard corresponding to the terminal based on the chess piece information.
[0058] Server 120 includes at least one of a single server, multiple servers, a cloud computing platform, and a virtualization center. Server 120 is used to provide background services for a turn-based board game application. Optionally, server 120 undertakes the main computing work, and the terminal undertakes the secondary computing work; or, server 120 undertakes the secondary computing work, and the terminal undertakes the main computing work; or, server 120 and the terminal use a distributed computing architecture for collaborative computing.
[0059] In an illustrative example, server 120 includes processor 122, user account database 123, battle service module 124, and user-facing input / output interface (I / O interface) 125. Processor 122 loads instructions stored in server 120 and processes data in user account database 123 and battle service module 124. User account database 123 stores user account data used by first terminal 110, second terminal 130, and other terminals 140. Battle service module 124 provides multiple battle rooms for users to play, such as 1V1, 3V3, 5V5, and 1V5 battles. User-facing I / O interface 125 establishes communication and exchanges data with first terminal 110 and / or second terminal 130 via wireless or wired network.
[0060] For example, such as Figure 2 As shown, the terminal uses camera model 140 to capture a 3D virtual environment 150 to display a virtual chessboard 151 located in the 3D virtual environment 150, and 3D virtual chess pieces 152 placed on virtual squares of the virtual chessboard 151 to the player. When the player manipulates the 3D virtual chess pieces through the display screen to change the virtual square where the 3D virtual chess piece 152 is located, the terminal needs to determine which 3D virtual chess piece the player wants to select. Especially when the size of the 3D virtual chess piece is large and exceeds the virtual square, or when the 3D virtual chess pieces are placed in a crowded manner, how to quickly and accurately determine the 3D virtual chess piece that the player wants to select is an important issue related to the player's experience. In this embodiment, a collision detection area is generated on the screen plane 160 for each 3D virtual chess piece, and the 3D virtual chess piece selected by the player through the trigger operation is determined based on the collision detection area in the screen plane 160 and the first screen position of the player's trigger operation on the display screen. Optionally, the screen plane refers to the plane where the near clipping plane of the camera model's frustum is located; or, the screen plane refers to the plane where the top surface of the camera model's frustum is located; or, the screen plane refers to the near clipping plane of the camera model's frustum; or, the screen plane refers to the top surface of the camera model's frustum. In some scenarios, the near clipping plane is the same as the top surface of the frustum. This example uses the near clipping plane of the camera model's frustum as the example, but this embodiment does not limit the scope of the application.
[0061] For example, for a 3D virtual chess piece 161 (2D image) on screen plane 160, there is a corresponding 3D virtual chess piece 152 (3D model) in 3D virtual environment 150. The terminal generates a collision detection area 162 on screen plane 160 for the 3D virtual chess piece 161 (2D image), and determines whether the player has selected the 3D virtual chess piece 161 (2D image) by determining whether the first screen coordinates of the player's trigger operation on the screen plane are located in the collision detection area 162.
[0062] Figure 3 A flowchart illustrating a method for selecting virtual chess pieces according to an exemplary embodiment of this application is shown. This method is executed by a terminal or client, the terminal being one described above. Figure 1 The first terminal shown in the diagram, the client can be one of the above. Figure 1 The first client is shown in the image. The method includes:
[0063] Step 210: Display a virtual chessboard located in a three-dimensional virtual environment. The virtual chessboard includes at least two virtual squares, and at least one three-dimensional virtual chess piece is placed in at least one occupied virtual square.
[0064] The display screen of the first terminal can display a virtual environment, which includes a virtual chessboard. The virtual environment is captured by a camera model. The virtual chessboard consists of at least two virtual squares. Each square allows the user to place three-dimensional virtual pieces. Users can place, move, and retrieve three-dimensional virtual pieces on the virtual chessboard within the virtual environment through the display screen of the first terminal (which is a touchscreen) or external interactive devices (such as a mouse, keyboard, stylus, or game controller).
[0065] Optionally, a virtual chessboard located in a virtual world is displayed; or, a virtual chessboard located in a three-dimensional virtual world is displayed, wherein at least one three-dimensional virtual chess piece is placed in at least one occupied virtual square of the virtual chessboard.
[0066] Optionally, an occupied virtual chess square refers to a virtual chess square on a virtual chessboard where a three-dimensional virtual chess piece is placed. Generally, one virtual chess square supports placing one three-dimensional virtual chess piece. However, in some special scenarios, it is allowed for multiple virtual chess squares to place the same three-dimensional virtual chess piece, or for one virtual chess square to place multiple three-dimensional virtual chess pieces. This application does not limit this.
[0067] Step 220: In response to a trigger operation on the virtual chessboard, acquire collision detection information of at least one 3D virtual chess piece; and acquire the first screen coordinates of the screen plane corresponding to the trigger operation; the collision detection information is used to indicate the collision detection area of the 3D virtual chess piece in the screen plane.
[0068] In response to a user's trigger operation on the virtual chessboard in the virtual environment screen, or in response to a user's trigger operation on a three-dimensional virtual chess piece in the virtual chessboard in the virtual environment screen, obtain collision detection information of at least one three-dimensional virtual chess piece; and obtain the first screen coordinates of the screen plane corresponding to the trigger operation.
[0069] Optionally, the triggering operation for the virtual chessboard includes at least one of the following: a user's selection operation for a three-dimensional virtual chess piece on the virtual chessboard; a user's placement operation for a three-dimensional virtual chess piece on the virtual chessboard; a user's placement operation for a three-dimensional virtual chess piece on a virtual chess square; a user's selection operation for a three-dimensional virtual chess piece placed on one or more virtual chess squares on the virtual chessboard; or a user's dragging operation for a three-dimensional virtual chess piece on the virtual chessboard.
[0070] Optionally, the screen plane refers to a plane parallel to the display screen; or, the screen plane refers to the plane where the virtual environment image captured by the camera model in the virtual environment is located; or, the screen plane refers to a plane parallel to the virtual environment image captured by the camera model in the virtual environment; or, the screen plane refers to the plane where the near clipping plane of the camera model's frustum is located; or, the screen plane refers to the plane where the top surface of the camera model's frustum is located; or, the screen plane refers to the near clipping plane of the camera model's frustum; or, the screen plane refers to the top surface of the camera model's frustum; or, the screen plane refers to a plane parallel to the near clipping plane of the camera model's frustum; or, the screen plane refers to a plane parallel to the top surface of the camera model's frustum.
[0071] Optionally, the collision detection information is used to indicate the collision detection area of the 3D virtual chess piece in the screen plane; or, the collision detection information is used to indicate the valid judgment area of the 3D virtual chess piece in the screen space, that is, the collision detection information can be called valid judgment information. The collision detection information and the collision detection area may also use other equivalent names, and this application embodiment does not limit them.
[0072] Optionally, the collision detection area represents the area within which, during collision detection, if the triggering operation occurs, the user is considered to have selected the corresponding 3D virtual chess piece; if the triggering operation does not occur within the collision detection area, the user is considered not to have selected the corresponding 3D virtual chess piece. The sensing area and valid selection area are similarly defined. That is, both the collision detection area and the valid determination area represent the determination area in screen space corresponding to the 3D virtual chess piece selected by the triggered operation.
[0073] Optionally, the collision detection information includes at least one of the following: the coordinates of each vertex of the collision detection region; the center coordinates of the collision detection region; the length of the collision detection region; the width of the collision detection region; the height of the collision detection region; the side length of the collision detection region; the parametric equation of the collision detection region; the edge vector of the collision detection region; the center coordinates of the collision detection region; the radius of the collision detection region; the matrix of the collision detection region; the implicit function of the collision detection region, and other parameter information related to the mathematical representation of regular or irregular shapes.
[0074] Optionally, the triggering operation for the virtual chessboard can also be understood as the triggering operation for the three-dimensional virtual chess pieces in the virtual chessboard. The triggering operation for the virtual chessboard includes, but is not limited to: click operation, long press operation, swipe operation, touch operation, button operation, gesture operation, motion control operation, and free combination of at least two of the above operations.
[0075] Among these, button operation refers to triggering the virtual chessboard using physical buttons such as keyboards, mice, and gamepads. Gesture operation refers to combinations of actions such as swiping, clicking, and long-pressing with one or more fingers on a touchscreen or touchpad, such as pinching with two fingers or swiping down with three fingers. It should be noted that gesture operation here can also be air gesture, that is, gesture operation determined by the user's hand movements captured by the terminal's camera. Motion control operation refers to a method of triggering the virtual chessboard through the user's actions. This is achieved by collecting or recognizing the user's actions through the terminal's gyroscope, motion sensors attached to the terminal, or actions recognized by the image captured by the terminal's camera, thereby determining whether to trigger the virtual chessboard based on the user's actions.
[0076] Optionally, "triggering the virtual chessboard" can be understood as selecting a three-dimensional virtual chess piece in the virtual chessboard; or placing a three-dimensional virtual chess piece on a virtual square in the virtual chessboard, etc.
[0077] Step 230: Based on at least one collision detection information and the first screen coordinates, determine the three-dimensional virtual chess piece touched and selected by the triggered operation.
[0078] Based on the collision detection area indicated by at least one collision detection information, determine the relative position of the first screen coordinates with the collision detection area, and identify the three-dimensional virtual chess piece touched and selected by the triggered operation.
[0079] Optionally, if the first screen coordinates are located within the collision detection area, the three-dimensional virtual chess piece corresponding to the collision detection area is determined to be the three-dimensional virtual chess piece touched and selected by the triggered operation.
[0080] In summary, the method provided in this application obtains collision detection information for each 3D virtual chess piece by mapping it onto the screen plane. Based on the user's trigger operation's first planar coordinates on the screen plane and the collision detection information of each 3D virtual chess piece, a judgment is made to determine the 3D virtual chess piece selected by the user through the trigger operation. Compared to methods based on bounding boxes in 3D space (i.e., determining which 3D virtual chess piece's bounding box the user's trigger operation intersects with), this method eliminates the need for 3D calculations, directly determining the 3D virtual chess piece in 2D. This reduces computational complexity and allows for faster determination of the 3D virtual chess piece selected by the user through the trigger operation, thereby improving the user's experience of controlling 3D virtual chess pieces on the virtual chessboard.
[0081] The following sections will introduce the methods for generating collision detection information for 3D virtual chess pieces, determining occupied virtual chess squares, and determining the 3D virtual chess pieces touched and selected by the triggered operation.
[0082] 1. Generation of collision detection information.
[0083] Based on Figure 3 In an alternative embodiment, such as Figure 4 As shown, step 220 can be implemented as steps 221 and 222.
[0084] Step 221: In response to a trigger operation on the virtual chessboard, obtain the second screen coordinates of at least one occupied virtual chess square.
[0085] Optionally, the second screen coordinates of at least one occupied virtual chess piece are pre-calculated and stored in the terminal; or, the second screen coordinates of at least one occupied virtual chess piece are stored in the terminal by the developer through configuration information; or, the second screen coordinates of at least one occupied virtual chess piece are calculated by the terminal; or, the second screen coordinates of at least one occupied virtual chess piece are calculated by the server and sent to the terminal.
[0086] Optionally, in response to a trigger operation on the virtual chessboard, the second screen coordinates of each occupied virtual square in at least one occupied virtual square are obtained.
[0087] Optionally, in response to a trigger operation on the virtual chessboard, the second screen coordinates of at least two virtual chess squares are obtained; or, in response to a trigger operation on the virtual chessboard, the second screen coordinates of each of the at least two virtual chess squares are obtained. Optionally, the method for obtaining the second screen coordinates of at least two virtual chess squares is similar to the method for obtaining the second screen coordinates of at least one occupied virtual chess square, and will not be described in detail here.
[0088] Optionally, taking a virtual chess square or an occupied virtual chess square as a rounded rectangle as an example, such as... Figure 5 As shown, the second screen coordinates of a virtual chess piece or an occupied virtual chess piece are the coordinates of vertex A, vertex B, vertex C, or vertex D of the virtual chess piece or the occupied virtual chess piece on the screen plane; or, the second screen coordinates of a virtual chess piece or an occupied virtual chess piece are the coordinates of the center O of the virtual chess piece or the occupied virtual chess piece on the screen plane; and so on. In this embodiment, the second screen coordinates of a virtual chess piece or an occupied virtual chess piece are the coordinates of the center of the virtual chess piece or the occupied virtual chess piece on the screen plane as an example for explanation.
[0089] Optionally, the second screen coordinates of the occupied virtual chess square are the second screen coordinates of the position of the 3D virtual chess piece on the occupied virtual chess square on the screen plane. The position refers to the location of the 3D virtual chess piece on the virtual chessboard. Specifically, based on the 3D coordinates of the position in the world coordinate system and the view matrix of the virtual camera, the 3D coordinates of the position in the world coordinate system are transformed into 3D coordinates in the camera space; then, through the projection matrix of the camera model, the 3D coordinates of the position in the camera space are transformed into second screen coordinates on the screen plane.
[0090] Step 222: Based on the second screen coordinates of at least one occupied virtual chess piece, determine the collision detection information of at least one three-dimensional virtual chess piece.
[0091] Optionally, collision detection information of a 3D virtual chess piece placed in each occupied virtual chess piece is determined based on the second screen coordinates of each occupied virtual chess piece in at least one occupied virtual chess piece.
[0092] Optionally, the second screen coordinates are used to assist in locating the collision detection area of the 3D virtual chess piece on the screen plane; or, the position information of the collision detection area indicated by the collision detection information on the screen plane is related to the second screen coordinates. For example, the center coordinates of the collision detection area are the second screen coordinates; or, the collision detection area is a circular area, and the center coordinates of the collision detection area are the second screen coordinates; or, the vertex coordinates of the collision detection area are the second screen coordinates; or, the second screen coordinates are located within the collision detection area on the screen plane.
[0093] In some embodiments, the collision detection information includes the location information, width, and height of the collision detection area; step 222 above includes: obtaining the model size of at least one three-dimensional virtual chess piece; and / or, obtaining the size of at least one occupied virtual chess square; determining the location information of the collision detection area of each three-dimensional virtual chess piece based on the second screen coordinates of the occupied virtual chess square where each three-dimensional virtual chess piece is located; and determining the width and height of the collision detection area of each three-dimensional virtual chess piece based on the second screen coordinates of at least one occupied virtual chess square, the size of the three-dimensional model of each three-dimensional virtual chess piece, and the size of the occupied virtual chess square where each three-dimensional virtual chess piece is located.
[0094] Optionally, the model size of the 3D virtual chess piece is the size of the 3D model of the 3D virtual chess piece; or, the model size of the 3D virtual chess piece includes at least one of the length, width, and height of the 3D virtual chess piece.
[0095] Optionally, the length and / or width and / or height of the 3D virtual chess piece are pre-stored in the terminal, such as the 3D model information of the 3D virtual chess piece including the dimensions of the 3D model, or at least one of the length, width, and height of the 3D virtual chess piece.
[0096] Optionally, the dimensions of the occupied virtual chess squares include at least one of the length, width, and height of the virtual chess square. For example, if the virtual chessboard is also a three-dimensional model, the virtual chess squares in the virtual chessboard can also be regarded as three-dimensional models, and thus can include the three attributes of length, width, and height; or, if the virtual chessboard is a two-dimensional model, the virtual chess squares in the virtual chessboard can also be regarded as two-dimensional models, then the dimensions of the virtual chess squares can include at least two of the length, width, and height.
[0097] Optionally, the position information of the collision detection area for each 3D virtual chess piece is determined based on the second screen coordinates of the occupied virtual chess squares where each 3D virtual chess piece is located. For example, the collision detection information of the 3D virtual chess piece placed in each occupied virtual chess square is determined based on the second screen coordinates of each occupied virtual chess square in at least one occupied virtual chess square. The position information of the collision detection area refers to the coordinates of the collision detection area on the screen plane. Optionally, the second screen coordinates are used to assist in locating the collision detection area of the 3D virtual chess piece on the screen plane; or, the position information of the collision detection area indicated by the collision detection information on the screen plane is related to the second screen coordinates. For example, the center coordinates of the collision detection area are the second screen coordinates; or, the collision detection area is a circular area, and the center coordinates of the collision detection area are the second screen coordinates; or, the vertex coordinates of the collision detection area are the second screen coordinates; or, the second screen coordinates are located within the collision detection area on the screen plane.
[0098] Optionally, the width and height of the collision detection region for each 3D virtual chess piece are determined based on at least one of the second screen coordinates of at least one occupied virtual chess square, the model size of each 3D virtual chess piece, and the size of the occupied virtual chess square in which each 3D virtual chess piece is located. For example, the width and height of the collision detection region for each 3D virtual chess piece placed on each virtual chess square in at least one occupied virtual chess square are determined based on the second screen coordinates of at least one occupied virtual chess square; or, the width and height of the collision detection region for each 3D virtual chess piece are determined based on the model size of each 3D virtual chess piece; or, the width and height of the collision detection region for each 3D virtual chess piece are determined based on the size of the occupied virtual chess square in which each 3D virtual chess piece is located; or, the width and height of the collision detection region for each 3D virtual chess piece are determined based on the second screen coordinates of at least one occupied virtual chess square and the model size of each 3D virtual chess piece. The width and height of the collision detection area of a 3D virtual chess piece placed in each occupied virtual chess piece are determined based on the second screen coordinates of at least one occupied virtual chess piece and the size of each occupied virtual chess piece; or, the width and height of the collision detection area of each 3D virtual chess piece are determined based on at least one of the model size of each 3D virtual chess piece and the size of the occupied virtual chess piece in which each 3D virtual chess piece is located; or, the width and height of the collision detection area of each 3D virtual chess piece are determined based on the second screen coordinates of at least one occupied virtual chess piece and the model size of each 3D virtual chess piece and the size of each occupied virtual chess piece.
[0099] The occupied virtual square where each three-dimensional virtual chess piece is located can be understood as each occupied virtual square in at least one occupied virtual square in which a three-dimensional virtual chess piece is placed, or, each occupied virtual square in at least one three-dimensional virtual chess piece in which a three-dimensional virtual chess piece is located.
[0100] For example, based on the model dimensions of each 3D virtual chess piece, the width and height of the collision detection region for each 3D virtual chess piece are determined. For instance, the model width of the 3D virtual chess piece can be used as the width of the collision detection region, and the model height can be used as the height of the collision detection region; or, the model length of the 3D virtual chess piece can be used as the width of the collision detection region, and the model height can be used as the height of the collision detection region. The model width is the width of the 3D virtual chess piece, the model length is the length of the 3D virtual chess piece, and the model height is the height of the 3D virtual chess piece. Based on the dimensions of the occupied virtual chess square where each 3D virtual chess piece is located, the width and height of the collision detection region for each 3D virtual chess piece are determined. For instance, the width of the occupied virtual chess square can be used as the width of the collision detection region, and the height of the occupied virtual chess square can be used as the height of the collision detection region. Based on at least one of the model size of each 3D virtual chess piece and the size of the occupied virtual chess square in which each 3D virtual chess piece is located, determine the width and height of the collision detection region of each 3D virtual chess piece. For example, the width of the occupied virtual chess square is used as the width of the collision detection region of the 3D virtual chess piece, and the model height of the 3D virtual chess piece is used as the height of the collision detection region.
[0101] In some embodiments, determining the width and height of the collision detection region of each 3D virtual chess piece based on at least one of the second screen coordinates of at least one occupied virtual chess square, the model size of each 3D virtual chess piece, and the size of the occupied virtual chess square where each 3D virtual chess piece is located includes: calculating a first difference in the horizontal direction between the second screen coordinates of the virtual chess square where each 3D virtual chess piece is located and the second screen coordinates of adjacent virtual chess squares; determining the width of the collision detection region of each 3D virtual chess piece as the first difference, wherein adjacent virtual chess squares are virtual chess squares that are horizontally adjacent to the virtual chess square where each 3D virtual chess piece is located; and determining the height of the 3D model of each 3D virtual chess piece as the height of the collision detection region of each 3D virtual chess piece.
[0102] That is, based on the second screen coordinates of at least one occupied virtual chess piece and the model size of each 3D virtual chess piece, the width and height of the collision detection area of each 3D virtual chess piece are determined, including: calculating the first difference in the horizontal direction between the second screen coordinates of the occupied virtual chess piece where each 3D virtual chess piece is located and the second screen coordinates of the adjacent virtual chess pieces; determining the width of the collision detection area of each 3D virtual chess piece as the first difference; the adjacent virtual chess pieces are the virtual chess pieces that are horizontally adjacent to the virtual chess piece where each 3D virtual chess piece is located; and determining the height of the 3D model of each 3D virtual chess piece as the height of the collision detection area of each 3D virtual chess piece.
[0103] Optionally, the width of the collision detection region for each 3D virtual chess piece is determined based on the second screen coordinates of at least one occupied virtual chess piece; and the height of the collision detection region for each 3D virtual chess piece is determined based on the model size of each 3D virtual chess piece.
[0104] Optionally, the second screen coordinates of each virtual square in the virtual chessboard are obtained. A first difference in the horizontal direction is calculated between the second screen coordinates of the occupied virtual square where each 3D virtual piece is located and the second screen coordinates of adjacent virtual squares. The width of the collision detection region for each 3D virtual piece is determined to be the absolute value of the first difference. For example, such as... Figure 6 As shown, Figure 6 The diagram shows a virtual chessboard displayed on a screen. Given the second screen coordinates (i.e., the two-dimensional coordinates of point O1) of an occupied virtual chess square 30 where a 3D virtual chess piece is placed, and the second screen coordinates (i.e., the two-dimensional coordinates of point O2) of an adjacent virtual chess square 31 adjacent to the occupied virtual chess square 30, a first difference is calculated as the difference between the horizontal coordinates of point O1 and point O2. The width 32 of the collision detection area for the 3D virtual chess piece placed in the occupied virtual chess square 30 is determined to be the absolute value of this first difference. It should be noted that the above example uses the horizontal direction corresponding to the horizontal coordinate as an example, but the vertical coordinate of the second screen coordinate can also be used as the horizontal direction for calculation. Furthermore, in the above example, the adjacent virtual chess square is defined as the virtual chess square adjacent to the right side of the occupied virtual chess square, but it could also be the virtual chess square adjacent to the left side of the occupied virtual chess square. Even depending on the definition of the horizontal direction, the adjacent virtual chess square could be the virtual chess square adjacent to the top or bottom of the occupied virtual chess square; this embodiment does not limit this.
[0105] Optionally, the height of the collision detection region of each 3D virtual chess piece is determined based on the model size of each 3D virtual chess piece. For example, the model height of each 3D virtual chess piece is determined as the height of the collision detection region of each 3D virtual chess piece.
[0106] It should be noted that in the above examples, the width of the collision detection area of the 3D virtual chess piece is calculated after mapping the virtual chess square to the screen plane. However, it can also be calculated directly using the width of the virtual chess square (i.e., the width of the 3D model of the virtual chess square), etc. This application embodiment does not limit this. Furthermore, regarding the above implementation method of "determining the width and height of the collision detection area of each 3D virtual chess piece based on at least one of the second screen coordinates of at least one occupied virtual chess square, the model size of each 3D virtual chess piece, and the size of the occupied virtual chess square in which each 3D virtual chess piece is located," this application embodiment only lists some implementation methods and their specific implementation details, but the protection scope of this application embodiment is not limited thereto.
[0107] In summary, the method provided in this application illustrates a method for generating collision detection information for at least one 3D virtual chess piece. By obtaining the second screen coordinates of at least one occupied virtual chess square, the virtual chessboard and 3D virtual chess piece are mapped onto the screen plane, and the screen coordinates corresponding to each virtual chess square in the virtual chessboard are stored, or only the second screen coordinates of the occupied virtual chess squares are stored. Determining the collision detection area by mapping it to the screen plane, and thus judging the 3D virtual chess piece selected by the player, reduces the computation in 3D space compared to the bounding box method. Furthermore, the screen coordinates can be pre-calculated and stored; that is, when the player performs a trigger operation, only the second screen coordinates need to be obtained for judgment, reducing the computational load in the response process to the trigger operation. This helps improve the efficiency of the 3D virtual chess piece selection process, reduces the selection latency of the 3D virtual chess piece, and allows for faster response and display to the user's trigger operation, thus improving the user experience.
[0108] Furthermore, this paper illustrates how to determine the location, width, and height of the collision detection information when the collision detection information includes the location, width, and height of the collision detection region. The location, width, and height of the collision detection region are determined using at least one of the following: the model size of the 3D virtual chess piece, the size of the occupied virtual chess square, and the second screen coordinates of the occupied chess square. This ensures that the collision detection region accurately reflects the size of the virtual chess square and the virtual model while minimizing the false positive rate. For example, bounding boxes are a common implementation with a high false positive rate. This is because bounding boxes typically generate a cube that completely encloses the 3D virtual chess piece. However, since the 3D model of a virtual chess piece is usually quite detailed and may have a prominent feature, using a bounding box will treat the area around that prominent feature as an invalid detection region, resulting in low accuracy. The method shown in this embodiment, which determines the collision detection region based on at least one of the model size of the 3D virtual chess piece, the size of the occupied virtual chess square, and the second screen coordinates of the occupied chess square, ensures the largest possible proportion of the effective detection region, thus improving accuracy.
[0109] Furthermore, a method is shown to determine the width of the collision detection area based on second screen coordinates and the height of the collision detection area based on the model height of the 3D virtual chess piece. Using second screen coordinates instead of the width of the virtual chess square is because different mapping methods of the virtual camera can cause the virtual chessboard displayed on the screen to exhibit a visual effect of appearing larger in the foreground and smaller in the background; that is, the virtual chess squares displayed on the screen may have different widths. Using second screen coordinates to determine the width of the collision detection area ensures that the determined collision detection area is closer to the width of the virtual chess squares displayed on the screen plane (i.e., the display screen), thereby minimizing detection failures caused by mapping distortion of the camera model. In addition, using the model height of the 3D virtual chess piece as the height of the collision detection area, instead of using the height of the virtual chess square, prevents some 3D virtual chess pieces whose height exceeds the virtual chess square from being considered invalid detection areas due to the collision detection area being too short, thus preventing collision detection failures when the user clicks on these extra parts, improving the accuracy of collision detection.
[0110] 2. Determining the occupied virtual chess squares.
[0111] In some embodiments, the method further includes: in response to a triggering operation on a virtual chessboard, determining first chessboard coordinates for the triggering operation, the first chessboard coordinates indicating the position of a predicted virtual square on the virtual chessboard corresponding to the triggering operation, the predicted virtual square being the virtual square closest to the triggering position of the triggering operation; and based on the first chessboard coordinates of the triggering operation, determining an occupied virtual square that is adjacent to the predicted virtual square and has a three-dimensional virtual piece placed on it. The triggering position refers to the position on the virtual chessboard where the triggering operation is triggered.
[0112] Optionally, each virtual square in the virtual chessboard corresponds to a chessboard coordinate, which is mainly used to indicate the position of the virtual square within at least two virtual squares on the virtual chessboard. For example, such as... Figure 7 As shown, Figure 7 The coordinates of each virtual square in the virtual chessboard are shown. For example, the first chessboard coordinates are (4, 3). Based on the first chessboard coordinates, occupied virtual squares are determined from the virtual squares adjacent to the virtual square corresponding to the first chessboard coordinates. Occupied virtual squares are those adjacent to the predicted virtual squares and on which 3D virtual pieces are placed. Furthermore, if a predicted virtual square also contains 3D virtual pieces, it is also determined as an occupied virtual square.
[0113] Optionally, the predicted virtual chess piece is the virtual chess piece that is closest to the first screen coordinates predicted based on the first screen coordinates of the triggering operation. Specifically, the first screen coordinates are converted into three-dimensional coordinates in the camera space of the camera model based on the projection matrix of the camera model; then, the three-dimensional coordinates in the camera space are converted into three-dimensional coordinates in the world coordinate system based on the view matrix of the camera model. The first chessboard coordinates of the triggering operation are determined based on the three-dimensional coordinates of the triggering operation in the world coordinate system.
[0114] For example, the process of determining the first chessboard coordinates of the triggering operation based on its three-dimensional coordinates in the world coordinate system is shown in the following formula.
[0115] The x-coordinate of the first chessboard coordinates = (3D x-coordinate in the world coordinate system - 3D x-coordinate of the initial virtual square in the virtual chessboard) / (width of the virtual square);
[0116] The vertical coordinate of the first chessboard is equal to (the three-dimensional vertical coordinate in the world coordinate system - the three-dimensional vertical coordinate of the initial virtual square in the virtual chessboard) / (the height of the virtual square).
[0117] Here, the three-dimensional horizontal coordinate is the horizontal coordinate in the world coordinate system, and the three-dimensional vertical coordinate is the vertical coordinate in the world coordinate system. Figure 7 Taking the corresponding diagram as an example, the initial virtual chess piece in the virtual chessboard is the virtual chess piece in the lower left corner of the virtual chessboard. The three-dimensional x-coordinate of the initial virtual chess piece is the same as its three-dimensional x-coordinate in the world coordinate system; the three-dimensional y-coordinate of the initial virtual chess piece is also the same as its three-dimensional y-coordinate in the world coordinate system. In the world coordinate system, that is, in the virtual environment, all virtual chess pieces have the same size.
[0118] Optionally, the vertical coordinate in the chessboard coordinate system can also be called the ordinate in the chessboard coordinate system. This is due to the different definition methods of two-dimensional and three-dimensional coordinate systems. Since the virtual chessboard is usually placed on a plane parallel to the xOz plane when it is constructed, the chessboard coordinates are defined in the form of (x, z) in the virtual chessboard, that is, the horizontal coordinate x and the vertical coordinate z in a generalized sense.
[0119] For example, the x-coordinate of the first chessboard coordinate is the ratio of the difference between the three-dimensional x-coordinate of the triggering operation in the world coordinate system and the three-dimensional x-coordinate of the initial virtual chess square to the width of the virtual chess square. The y-coordinate of the first chessboard coordinate is the ratio of the difference between the three-dimensional y-coordinate of the triggering operation in the world coordinate system and the three-dimensional y-coordinate of the initial virtual chess square to the height of the virtual chess square. Wherein, as... Figure 8As shown, the virtual chessboard 34 is illustrated using the example where the width is on the horizontal axis, the length is on the vertical axis, and the height is on the vertical axis. However, this can be changed depending on the world coordinate system used, i.e., the developer's habits, etc., and this embodiment does not limit this.
[0120] In summary, the method provided in this application sets the occupied virtual chess square as the predicted virtual chess square to be clicked by the player, and the virtual chess squares adjacent to the predicted virtual chess square containing 3D virtual chess pieces. That is, during collision detection, only the virtual chess square most likely to be clicked by the user and its surrounding virtual chess squares are considered, without needing to consider every virtual chess square containing 3D virtual chess pieces on the entire virtual chessboard. This reduces computational load, improves collision detection efficiency, and consequently reduces player feedback latency, enhancing the user experience.
[0121] 3. The method for determining the three-dimensional virtual chess piece touched and selected by the triggered operation.
[0122] Based on Figure 3 In an alternative embodiment, such as Figure 9 As shown, step 230 includes steps 231 and 232.
[0123] Step 231: Perform collision detection on the collision detection area of each three-dimensional virtual chess piece based on at least one collision detection information and the first screen coordinates.
[0124] Optionally, collision detection is performed on the collision detection region of each 3D virtual chess piece based on at least one collision detection information; or, based on at least one collision detection information, collision detection is performed on the collision detection region indicated by each of the at least one collision detection information; alternatively, collision detection is performed on each of the at least one 3D virtual chess pieces based on the collision detection information of at least one 3D virtual chess piece. Collision detection for 3D virtual chess pieces refers to collision detection on the collision detection region corresponding to each 3D virtual chess piece.
[0125] In some embodiments, step 231 includes: determining the third screen coordinates of at least two contour points of each collision detection region based on each collision detection information in at least one collision detection information, wherein the contour points are points on the contour of the collision detection region; and performing collision detection on at least one collision detection region based on the third screen coordinates and the first screen coordinates of the at least two contour points corresponding to the first collision detection region for the first collision detection region in at least one collision detection information.
[0126] Optionally, each collision detection information includes the position information (such as third screen coordinates or three-dimensional coordinates in the world coordinate system) of at least two contour points of the collision detection area, where the contour points are points on the contour of the collision detection area; or, each collision detection information includes at least one of the following: the center coordinates of the collision detection area; the parametric equation of the collision detection area; the edge vector of the collision detection area; the center coordinates of the collision detection area; the radius of the collision detection area; the implicit function of the collision detection area, etc., and other parameter information related to the mathematical representation of regular or irregular graphics. The terminal determines the third screen coordinates of at least two contour points of the collision detection area based on the collision detection information.
[0127] For example, if the collision detection area is a rectangle, and the collision detection information includes the center coordinates (screen coordinates in the screen plane) and the length and width of the collision detection area, the screen coordinates of each vertex of the collision detection area can be calculated, thus determining the third screen coordinates of any contour point on any side. As another example, if the collision detection area is a circle, and the collision detection information includes the center coordinates and radius of the collision detection area, the third screen coordinates of any contour point in the collision detection area can be determined (screen coordinates in the screen plane). If the center coordinates or circle coordinates of the collision detection area are three-dimensional coordinates in the world coordinate system, they can also be mapped to the screen plane using the method shown in "2. Determination of Occupied Virtual Chess Pieces" above, based on the projection matrix and view matrix of the camera model, to obtain the screen coordinates in the screen plane. As yet another example, if the collision detection area is a regular hexagon, and the collision detection information includes the center coordinates or coordinates of a vertex of the collision detection area and the side length, the screen coordinates of each vertex of the collision detection area can be calculated.
[0128] For example, the center coordinates of a regular hexagon (using screen coordinates as an example) are (h, k), and the side length is a. Therefore, each vertex of the regular hexagon lies on a circle with center (h, k) and radius a. Depending on the arrangement of the regular hexagon, the angle θ corresponding to each vertex is determined, where the angle difference between adjacent vertices is 60°. The formula for calculating the screen coordinates (x, y) of each vertex is as follows.
[0129] x = h + acosθ
[0130] y = k + asinθ
[0131] The angle θ of each vertex depends on its placement in screen space. For example, for... Figure 10The arrangement shown in part (1) has the following six vertices: vertex E1 has an angle θ of 0°, vertex E2 has an angle θ of 60°, vertex E3 has an angle θ of 120°, vertex E4 has an angle θ of 180°, vertex E5 has an angle θ of 240°, and vertex E6 has an angle θ of 300°; for Figure 10 The arrangement shown in part (2) of the document has the following six vertices: vertex F1 has an angle θ of 30°, vertex F2 has an angle θ of 90°, vertex F3 has an angle θ of 150°, vertex F4 has an angle θ of 210°, vertex F5 has an angle θ of 270°, and vertex F6 has an angle θ of 330°. This application will use... Figure 10 The arrangement shown in section (2) is used as an example for illustration, but is not limited thereto.
[0132] Optionally, for regular shapes, contour points are typically the vertices of the collision detection area. For irregular shapes, developers can define vertices (corner points or turning points on the shape), boundary points (points on the edges), intersection points (points where lines intersect), etc., as contour points, and this application embodiment does not limit this.
[0133] Optionally, for a first collision detection region in at least one collision detection information, collision detection is performed on the at least one collision detection region based on the third screen coordinates of at least two contour points corresponding to the first collision detection region and the first screen coordinates. For example, based on the third screen coordinates of at least two contour points, it is determined whether the first screen coordinates are located within the collision detection region corresponding to the at least two contour points. If the first screen coordinates are located within the first collision detection region, it is determined that the first collision detection region has passed the collision detection; if the first screen coordinates are located outside the first collision detection region, it is determined that the first collision detection region has failed the collision detection.
[0134] In some embodiments, the collision detection region is a regular hexagon; the collision detection region includes six contour points, which are vertices of the regular hexagon; for a first collision detection region based on at least one collision detection information, collision detection is performed on at least one collision detection region based on the third screen coordinates of at least two contour points corresponding to the first collision detection region and the first screen coordinates, including: determining a rectangular detection region and four triangular detection regions based on the third screen coordinates of the six contour points, wherein the rectangular detection region and the four triangular detection regions do not overlap; determining whether the first screen coordinates are located within the rectangular detection region based on the third screen coordinates of the four contour points corresponding to the rectangular detection region; determining whether the first screen coordinates are located within the triangular detection region based on the third screen coordinates of the two contour points corresponding to each of the four triangular detection regions; determining that the first collision detection region passes the collision detection if the first screen coordinates are located within any one of the rectangular detection region and the four triangular detection regions; determining that the first collision detection region fails the collision detection if the first screen coordinates are not located within either the rectangular detection region or the four triangular detection regions.
[0135] For example, such as Figure 11 As shown, based on the third screen coordinates of the six contour points, the collision detection area can be divided into a rectangular detection area 40 and four triangular detection areas, namely triangular detection areas 41, 42, 43, and 44. The rectangular detection area 40 does not overlap with the four triangular detection areas, and the four triangular detection areas also do not overlap with each other. This can be understood as determining two pairs of contour points from the six contour points where the vertical coordinates are equal and the difference between their horizontal coordinates is greater than the side length; connecting the contour points with equal vertical coordinates (F1 and F3, F4 and F6) and the two pairs of contour points with equal horizontal coordinates (F1 and F6, F3 and F4) respectively; or connecting the contour points with an angle difference of 120° and the contour points with an angle difference of 60° respectively; thus obtaining a rectangular detection area. After obtaining the rectangular detection region, each of the remaining two contour points (F2 and F5) is connected to the two vertices of the nearest rectangular detection region, and four triangular detection regions are obtained by drawing perpendicular lines from the contour points to the side length of the rectangular detection region.
[0136] For example, collision detection is first performed on the rectangular detection area to determine whether the first screen coordinates are located within the rectangular detection area. This involves comparing the first screen coordinates with the third screen coordinates of the four contour points (i.e., the four vertices of the rectangular detection area). If the third screen coordinates of the four contour points corresponding to the rectangular detection area are (a1, b1), (a1, b2), (a2, b1), and (a2, b2), and a1 < a2, b1 < b2, and the first screen coordinates are (x1, y1), then if a1 < x1 < a2 and b1 < y1 < b2, the first screen coordinates are located within the rectangular detection area; otherwise, the first screen coordinates are not located within the rectangular detection area. Alternatively, if the x-coordinate of the first screen coordinate is greater than the smaller of the x-coordinates of the third screen coordinates of the four contour points, and the x-coordinate of the first screen coordinate is less than the larger of the x-coordinates of the third screen coordinates of the four contour points, and the y-coordinate of the first screen coordinate is greater than the smaller of the y-coordinates of the third screen coordinates of the four contour points, and the y-coordinate of the first screen coordinate is less than the larger of the y-coordinates of the third screen coordinates of the four contour points, then the first screen coordinate is located within the rectangular detection area; otherwise, it is not located within the rectangular detection area.
[0137] For example, if the collision detection for the rectangular detection area fails, collision detection for each of the four triangular detection areas can be performed separately. The first step of the collision detection for the triangular detection areas is similar to that for the rectangular detection areas, which involves determining whether the first screen coordinates are located within the rectangle corresponding to the triangular detection area. Specifically, taking triangular detection area 41 as an example, if the third screen coordinates of the two contour points corresponding to the triangular detection area are (a1, b1) and (a2, b2), and a1 < a2, b1 < b2, and the first screen coordinates are (x1, y1), then if a1 < x1 < a2 and b1 < y1 < b2, the first screen coordinates are located within the rectangle corresponding to the triangular detection area, and the first step of the collision detection for the triangular detection area is passed; otherwise, the first screen coordinates are not located within the rectangle corresponding to the triangular detection area, and the first step of the collision detection for the triangular detection area is not passed. Alternatively, if the x-coordinate of the first screen coordinate is greater than the smaller of the x-coordinates of the third screen coordinates of the two contour points, and the x-coordinate of the first screen coordinate is less than the larger of the x-coordinates of the third screen coordinates of the two contour points, and the y-coordinate of the first screen coordinate is greater than the smaller of the y-coordinates of the third screen coordinates of the two contour points, and the y-coordinate of the first screen coordinate is less than the larger of the y-coordinates of the third screen coordinates of the two contour points, then the first screen coordinate is located within the rectangle corresponding to the triangle detection area and has passed the first step of collision detection in the triangle detection area; otherwise, it is not located within the rectangle corresponding to the triangle detection area and has not passed the first step of collision detection in the triangle detection area.
[0138] For example, the second step of collision detection in the triangle detection region determines which side of the line segment formed by the two contour points corresponding to the triangle detection region the first screen coordinates are located on. For instance, regarding... Figure 11 The triangle detection areas 41 and 43 shown are used to indicate that if the first screen coordinates are located to the left of the triangle detection areas, it means that the first screen coordinates are not located within the triangle detection areas; if the first screen coordinates are located to the right of the triangle detection areas, it means that the first screen coordinates are located within the triangle detection areas. For... Figure 11 The triangle detection areas 42 and 44 shown in the diagram are the opposite. If the first screen coordinate is located to the right of the triangle detection area, it means that the first screen coordinate is not located within the triangle detection area; if the first screen coordinate is located to the left of the triangle detection area, it means that the first screen coordinate is located within the triangle detection area. It should be noted that the terms left and right, top and bottom, etc., in the embodiments of this application are used as examples of the coordinate system settings shown in the embodiments themselves. The first side and the second side, as well as the third side and the fourth side, can also be used instead. The embodiments of this application do not limit this.
[0139] Step 232: Determine the 3D virtual chess piece corresponding to the collision detection area that passed the collision detection as the 3D virtual chess piece touched and selected by the triggered operation.
[0140] Optionally, the 3D virtual chess piece that passes the collision detection is identified as the 3D virtual chess piece selected by the triggered operation.
[0141] Optionally, the three-dimensional virtual chess piece touched and selected by the triggered operation is the three-dimensional virtual chess piece touched and selected by the player through the touch operation after collision detection; or it is the three-dimensional virtual chess piece that the terminal determines the player expects to select through this touch operation.
[0142] In some embodiments, each virtual square in the virtual chessboard has a priority; step 232 includes: when at least two collision detection areas corresponding to three-dimensional virtual pieces pass collision detection, determining the three-dimensional virtual piece with the highest priority in its virtual square as the three-dimensional virtual piece selected by the triggered operation, based on the priority of the virtual square in which each three-dimensional virtual piece is located. This method ensures that even when unavoidable overlap occurs in the collision detection areas, and the user's trigger position is located in the overlapping area, it can determine the three-dimensional virtual piece selected by the user, avoiding errors caused by overlap in the collision detection areas and improving reliability.
[0143] For example, the priority of each virtual square in the virtual chessboard is determined based on the coordinates of the square it corresponds to. A virtual square with a larger vertical coordinate has a higher priority. Alternatively, if both virtual square 1 and virtual square 2 pass touch detection, and the vertical coordinate of virtual square 1 is greater than that of virtual square 2, then virtual square 1 is determined to be the 3D virtual piece selected by the triggered operation.
[0144] Optionally, each three-dimensional virtual chess piece has a priority; step 232 includes: if there are at least two collision detection areas corresponding to three-dimensional virtual chess pieces that pass the collision detection, based on the priority of each three-dimensional virtual chess piece, determining the three-dimensional virtual chess piece with the highest priority as the three-dimensional virtual chess piece touched and selected by the triggered operation.
[0145] In some embodiments, the priority of a 3D virtual chess piece is related to the frequency with which a player uses it. For example, the higher the frequency of use of a 3D virtual chess piece, the more likely the player is to choose it, and therefore a higher priority is set. Conversely, the lower the frequency of use of a 3D virtual chess piece, the less likely the player is to choose it, and therefore a lower priority is set.
[0146] In summary, the method provided in this application illustrates how to determine a three-dimensional virtual chess piece triggered by being touched, based on collision detection information and first screen coordinates. By performing collision detection on the collision detection area indicated by the collision detection information, i.e., performing collision detection on the screen plane, compared to performing collision detection in three-dimensional space, the computational load is reduced, the execution efficiency of collision detection is improved, and the user experience is enhanced.
[0147] Furthermore, it is shown that the collision detection process is based on the third screen coordinates of the contour points of the collision detection area rather than the entire collision detection area, which further simplifies the collision detection judgment process, reduces the collision detection latency, and improves the execution efficiency of collision detection.
[0148] Furthermore, the paper demonstrates how to perform collision detection when the collision detection region is a regular hexagon. By partitioning its six contour points, the regular hexagon is divided into a rectangular detection region and four triangular detection regions, further improving the collision detection efficiency and computational cost.
[0149] It should be noted that the above-mentioned "1. Method for generating collision detection information", "2. Method for determining occupied virtual chess squares" and "3. Method for determining the three-dimensional virtual chess piece touched and selected by the triggered operation" can be implemented as independent embodiments or as combined embodiments. For example, while generating collision detection information using the method shown in "1. Method for Generating Collision Detection Information", the method for determining occupied virtual squares shown in "2. Method for Determining Occupied Virtual Squares" is also used; while generating collision detection information using the method shown in "1. Method for Generating Collision Detection Information", the method for determining the selected 3D virtual piece touched by the triggered operation is also used; while generating collision detection information using the method shown in "1. Method for Generating Collision Detection Information", the method for determining occupied virtual squares shown in "2. Method for Determining Occupied Virtual Squares" is also used; and the method for determining the selected 3D virtual piece touched by the triggered operation is also used.
[0150] In related technologies, there are two common methods for determining the selection or placement of 3D virtual chess pieces. Here, we will use selection as an example. One method is based on the chessboard grid, and the other is based on the bounding box surrounding the 3D virtual chess piece. For example, regarding... Figure 12 The virtual chessboard 80 shown contains two 3D virtual chess pieces, 81 and 82. Virtual chess piece 81 is smaller than 82. Therefore, when displayed on the screen, virtual chess piece 81 is entirely within the playing square 83, while virtual chess piece 82 is partially within the playing square 84, and partially within both 83 and 85. If a player clicks on area 86 to select virtual chess piece 82, but the clicked area is within the playing square 83, the system may mistakenly interpret this as a selection of virtual chess piece 81. This would prevent the player from quickly selecting the desired virtual chess piece, resulting in a poor user experience. Bounding box-based judgment requires first calculating the player's click position. After transforming to the 3D space of the virtual chessboard, it determines which bounding box the ray emanating from the click position intersects with first. Since the bounding box needs to completely enclose the 3D virtual piece to ensure accurate judgment, for some 3D virtual pieces with irregular overall shapes, the bounding box may have many gaps, such as... Figure 12As shown in bounding box 87, these gaps will cause the user to click on other pieces through the gaps, which will still be judged as selecting the piece, making it difficult to make accurate judgments in the bounding box-based judgment process.
[0151] Figure 13 This diagram illustrates an overall flowchart of a virtual chess piece selection method provided in an exemplary embodiment of this application. The method selects a 3D virtual chess piece by inputting first screen coordinates, determining the captured 3D virtual chess piece, and outputting the captured 3D virtual chess piece. Specifically, the method includes:
[0152] Step 1: Obtain all the three-dimensional virtual chess pieces in the virtual chessboard.
[0153] When a player clicks or touches the screen, triggering the drag-and-drop logic, the game logic module collects all clickable 3D virtual pieces on the virtual chessboard in the virtual environment and adds them to a collision queue (List). The virtual chessboard consists of at least two virtual squares, each with its own coordinates. 3D virtual pieces are then placed within these squares. Square coordinates are as follows: Figure 7 As shown, it will not be elaborated further here.
[0154] Step 2: Obtain the coordinates of the first chessboard based on the coordinates of the first screen, and remove redundant 3D virtual chess pieces.
[0155] Based on the player's initial screen coordinates (ScreenPos), the world coordinates (WorldPos) of the chessboard are converted using the interface provided by the editor. Then, based on the chessboard's world coordinates (starting coordinates BeginPos) and the width and height of the virtual chess squares (CellWidth, CellHigh), the first chessboard coordinates (CellPos) corresponding to the initial screen coordinates are calculated from the world coordinates (WorldPos).
[0156] The formula is roughly as follows:
[0157] The first chessboard coordinate X = (world coordinate x - starting coordinate x) / (grid width);
[0158] The first chessboard coordinate Z = (world coordinate z - starting coordinate z) / (grid height).
[0159] After obtaining the first chessboard coordinates (CellPos) of the player's click, iterate through the collision queue, retaining only all pieces surrounding the clicked first chessboard coordinates (CellPos), and removing all other 3D virtual pieces from the collision queue. For example... Figure 7In the example, if the first chessboard coordinates are (4, 3), then only the pieces in the surrounding 7 squares (4, 2)(5, 2)(3, 3)(4, 3)(5, 3)(4, 4)(5, 4) are retained. The 3D virtual pieces in other positions are discarded.
[0160] Step 3: Generate collision detection information for the three-dimensional virtual chess pieces.
[0161] Based on the position of the 3D virtual chess piece on the virtual chessboard (ChessCellPos), the position is converted into 3D coordinates in the world coordinate system (ChessWorldPos), and then projected onto the screen plane and converted into 2D coordinates (ChessPos) through an interface provided by the editor.
[0162] After obtaining the 2D coordinates, a collision detection data structure (BoxShapeInfo) is constructed based on the configured dimensions of the virtual chessboard and the height of the 3D virtual chess piece model. This structure contains key data such as width, height, and position coordinates (ChessPos), using a hexagonal shape as the basis for the collision model. For example... Figure 14 As shown.
[0163] To reduce the overlapping area of the left and right 3D virtual chess pieces, the width is calculated by converting the center points of the two floor positions to the screen plane and then calculating the difference. For example... Figure 6 As shown.
[0164] Because the height of the 3D virtual chess pieces varies, a fixed configuration parameter (i.e., the height of the 3D virtual chess piece model) is used here as the height of the collision detection area. For example... Figure 15 As shown, the height of the collision detection area varies for 3D virtual chess pieces of different sizes.
[0165] Step 4, collision detection.
[0166] Based on the collision detection data structure, collision detection is performed on the hexagon of the 3D virtual chess piece in the collision queue (List) and the first screen coordinate (ScreenPos) to determine whether the first screen coordinate is inside the hexagon.
[0167] The collision detection calculation method is as follows:
[0168] a. Calculate the positions of the six vertices (P0-P5) of the hexagon based on the width, height, and coordinates of the collision detection information (BoxShapeInfo).
[0169] b. Divide the hexagon into 5 rectangular regions, such as Figure 16 As shown. First, determine which region the first screen coordinates (ScreenPos) are in.
[0170] c. If the first screen coordinates (ScreenPos) are not in any of the above 5 areas, the collision detection is considered to have failed.
[0171] d. If the first screen coordinates (ScreenPos) are in region C, the collision is considered to have occurred.
[0172] e. If the first screen coordinate (ScreenPos) is in one of the four regions A, B, C, D, or E, then perform an intersection calculation between the point and the diagonal to determine which side of the line the point is on.
[0173] Step 5: Determine the three-dimensional virtual chess piece to be captured based on its priority.
[0174] If overlapping 3D virtual pieces exist, the priority of the overlapping parts is determined based on perspective, followed by the priority of the z-values of the virtual pieces' chessboard coordinates. Finally, the collision result is output, and the logical judgment of the player's selected piece is returned.
[0175] For example Figure 7 In the example, if the hexagonal judgment of the pieces at positions (4,3) and (4,2) both meet the collision judgment, then the Z-axis of the two pieces will be compared. The priority design prioritizes the piece at position (4,3) (3>2).
[0176] In summary, the method provided in this application demonstrates that the collision detection frame based on 2D hexagons offers a significant improvement in accuracy compared to the original 3D sphere or cuboid bounding box. Furthermore, the method effectively reduces the number of collision detection operations by selecting and removing pieces from the virtual chessboard.
[0177] Figure 17 This diagram illustrates a structural block diagram of a virtual chess piece selection device provided in an exemplary embodiment of this application. The device has the functionality to implement the virtual chess piece selection method example described above; the functionality can be implemented in hardware or by hardware executing corresponding software. The device can be the terminal described above, or it can be installed within a terminal. The device includes a display module 410, a response module 420, and a determination module 430.
[0178] Display module 410 is used to display a virtual chessboard located in a three-dimensional virtual environment. The virtual chessboard includes at least two virtual squares, and at least one three-dimensional virtual chess piece is placed in at least one occupied virtual square of the virtual chessboard.
[0179] The response module 420 is configured to, in response to a trigger operation on the virtual chessboard, acquire collision detection information of the at least one three-dimensional virtual chess piece; and acquire the first screen coordinates of the screen plane corresponding to the trigger operation; the collision detection information is used to indicate the collision detection area of the three-dimensional virtual chess piece in the screen plane;
[0180] The determination module 430 is used to determine the three-dimensional virtual chess piece touched and selected by the triggering operation based on the at least one collision detection information and the first screen coordinates.
[0181] In some embodiments, the response module 420 includes an acquisition submodule and a determination submodule.
[0182] The acquisition submodule is used to acquire the second screen coordinates of the at least one occupied virtual chess square in response to a trigger operation on the virtual chessboard.
[0183] The determination submodule is used to determine the collision detection information of the at least one three-dimensional virtual chess piece based on the second screen coordinates of the at least one occupied virtual chess piece.
[0184] In some embodiments, the collision detection information includes the position information, width, and height of the collision detection area; the determining submodule is further configured to obtain the model size of the at least one 3D virtual chess piece; and / or obtain the size of the occupied virtual chess square; determine the position information of the collision detection area of each 3D virtual chess piece based on the second screen coordinates of the occupied virtual chess square where each 3D virtual chess piece is located; and determine the width and height of the collision detection area of each 3D virtual chess piece based on at least one of the second screen coordinates of the at least one occupied virtual chess square, the model size of each 3D virtual chess piece, and the size of the occupied virtual chess square where each 3D virtual chess piece is located.
[0185] In some embodiments, the determining submodule is further configured to calculate a first difference in the horizontal direction between the second screen coordinates of the occupied virtual chess square where each 3D virtual chess piece is located and the second screen coordinates of the adjacent virtual chess square; determine the width of the collision detection area of each 3D virtual chess piece as the first difference; the adjacent virtual chess square is a virtual chess square that is horizontally adjacent to the occupied virtual chess square where each 3D virtual chess piece is located; and determine the model height of each 3D virtual chess piece as the height of the collision detection area of each 3D virtual chess piece.
[0186] In some embodiments, the device further includes a chessboard determination module.
[0187] The chessboard determination module is used to respond to a trigger operation on the virtual chessboard, determine the first chessboard coordinates of the trigger operation, the first chessboard coordinates are used to indicate the position of the predicted virtual chess square corresponding to the trigger operation in the virtual chessboard, the predicted virtual chess square is the virtual chess square closest to the trigger position of the trigger operation; based on the first chessboard coordinates of the trigger operation, determine the virtual chess square adjacent to the predicted virtual chess square and on which the three-dimensional virtual chess piece is placed as the occupied virtual chess square.
[0188] In some embodiments, the determining module 430 is further configured to perform collision detection on the collision detection area of each three-dimensional virtual chess piece based on the at least one collision detection information; and determine that the three-dimensional virtual chess piece corresponding to the collision detection area that passes the collision detection is the three-dimensional virtual chess piece touched and selected by the triggering operation.
[0189] In some embodiments, the determining module 430 is further configured to determine the third screen coordinates of at least two contour points of each collision detection region based on each collision detection information in the at least one collision detection information, wherein the contour points are points on the contour of the collision detection region; and to perform collision detection on the at least one collision detection region based on the at least two contour points corresponding to the first collision detection region and the first screen coordinates for the first collision detection region in the at least one collision detection information.
[0190] In some embodiments, the collision detection region is a regular hexagon; the collision detection region includes six contour points, which are the vertices of the regular hexagon; the determining module 430 is further configured to determine a rectangular detection region and four triangular detection regions based on the third screen coordinates of the six contour points, wherein the rectangular detection region and the four triangular detection regions do not overlap; determine whether the first screen coordinate is located within the rectangular detection region based on the third screen coordinates of the four contour points corresponding to the rectangular detection region; determine whether the first screen coordinate is located within the triangular detection region based on the third screen coordinates of the two contour points corresponding to each of the four triangular detection regions; determine that the first collision detection region passes the collision detection if the first screen coordinate is located within either the rectangular detection region or the four triangular detection regions; determine that the first collision detection region fails the collision detection if the first screen coordinate is not located within either the rectangular detection region or the four triangular detection regions.
[0191] In some embodiments, each virtual chess square in the virtual chessboard has a priority; the determining module 430 is further configured to, when there are at least two collision detection areas corresponding to three-dimensional virtual chess pieces that pass the collision detection, determine the three-dimensional virtual chess piece with the highest priority in the virtual chess square where each three-dimensional virtual chess piece is located as the three-dimensional virtual chess piece touched and selected by the triggering operation.
[0192] It should be noted that the specific limitations of the embodiments of the virtual chess piece selection device provided above can be found in the limitations of the virtual chess piece selection method above, and will not be repeated here. Each module of the above device can be implemented entirely or partially by software, hardware, or a combination thereof. Each module can be embedded in the processor of the computer device in hardware form or independent of the processor of the computer device, or it can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0193] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0194] This application also provides a computer device, which includes a processor and a memory. The memory stores at least one computer program, which is loaded and executed by the processor to implement the virtual chess piece selection method provided in the above-described method embodiments.
[0195] Figure 18 This illustration shows a structural block diagram of a computer device 800 provided in an exemplary embodiment of this application. The computer device 800 may be a portable mobile terminal, such as a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), or MP4 player (Moving Picture Experts Group Audio Layer IV). The computer device 800 may also be referred to as a user device, portable terminal, or other names. Typically, the computer device 800 includes a processor 801 and a memory 802.
[0196] Processor 801 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 801 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). Processor 801 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 801 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 801 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0197] The memory 802 may include one or more computer-readable storage media, which may be tangible and non-transitory. The memory 802 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 802 are used to store at least one instruction, which is executed by the processor 801 to implement the virtual chess piece selection method provided in the embodiments of this application.
[0198] In some embodiments, the computer device 800 may also optionally include a peripheral device interface 803 and at least one peripheral device. The processor 801, memory 802, and peripheral device interface 803 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 803 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of the following: a radio frequency circuit 804, a touch display screen 805, a camera assembly 806, an audio circuit 807, and a power supply 808.
[0199] Peripheral device interface 803 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 801 and memory 802. In some embodiments, processor 801, memory 802 and peripheral device interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 801, memory 802 and peripheral device interface 803 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0200] The radio frequency (RF) circuit 804 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 804 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 804 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or Wi-Fi (Wireless Fidelity) networks. In some embodiments, the RF circuit 804 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0201] The touch display screen 805 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. The touch display screen 805 also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to the processor 801 for processing. The touch display screen 805 is used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one touch display screen 805, located on the front panel of the computer device 800; in other embodiments, there may be at least two touch display screens, respectively located on different surfaces of the computer device 800 or in a folded design; in some embodiments, the touch display screen 805 may be a flexible display screen, located on a curved or folded surface of the computer device 800. Furthermore, the touch display screen 805 may be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. The touch display screen 805 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0202] The camera assembly 806 is used to acquire images or videos. Optionally, the camera assembly 806 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is used for video calls or selfies, and the rear-facing camera is used for taking photos or videos. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, and a wide-angle camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, and panoramic shooting and VR shooting by fusion of the main camera and the wide-angle camera. In some embodiments, the camera assembly 806 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash is a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0203] Audio circuitry 807 provides an audio interface between the user and computer device 800. Audio circuitry 807 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to processor 801 for processing, or input to radio frequency circuitry 804 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located at a different location within computer device 800. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from processor 801 or radio frequency circuitry 804 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, audio circuitry 807 may also include a headphone jack.
[0204] Power supply 808 is used to supply power to various components in computer device 800. Power supply 808 can be alternating current, direct current, a disposable battery, or a rechargeable battery. When power supply 808 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0205] In some embodiments, the computer device 800 further includes one or more sensors 809. The one or more sensors 809 include, but are not limited to, an accelerometer 810, a gyroscope 811, a pressure sensor 812, an optical sensor 813, and a proximity sensor 814.
[0206] Accelerometer 810 can detect the magnitude of acceleration on the three coordinate axes of a coordinate system established by computer device 800. For example, accelerometer 810 can be used to detect the components of gravitational acceleration on the three coordinate axes. Processor 801 can control touch screen 805 to display the user interface in landscape or portrait view based on the gravitational acceleration signal collected by accelerometer 810. Accelerometer 810 can also be used for games or to collect user motion data. Gyroscope 811 can detect the orientation and rotation angle of computer device 800. Gyroscope 811 can work in conjunction with accelerometer 810 to collect 3D movements of the user on computer device 800. Based on the data collected by gyroscope 811, processor 801 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0207] The pressure sensor 812 can be disposed on the side bezel of the computer device 800 and / or on the lower layer of the touch display screen 805. When the pressure sensor 812 is disposed on the side bezel of the computer device 800, it can detect the user's grip signal on the computer device 800 and perform left / right hand recognition or quick operation based on the grip signal. When the pressure sensor 812 is disposed on the lower layer of the touch display screen 805, it can control operable controls on the UI interface based on the user's pressure operation on the touch display screen 805. Operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0208] An optical sensor 813 is used to collect ambient light intensity. In one embodiment, the processor 801 can control the display brightness of the touch screen 805 based on the ambient light intensity collected by the optical sensor 813. Specifically, when the ambient light intensity is high, the display brightness of the touch screen 805 is increased; when the ambient light intensity is low, the display brightness of the touch screen 805 is decreased. In another embodiment, the processor 801 can also dynamically adjust the shooting parameters of the camera assembly 806 based on the ambient light intensity collected by the optical sensor 813.
[0209] A proximity sensor 814, also known as a distance sensor, is typically located on the front of the computer device 800. The proximity sensor 814 is used to detect the distance between the user and the front of the computer device 800. In one embodiment, when the proximity sensor 814 detects that the distance between the user and the front of the computer device 800 is gradually decreasing, the processor 801 controls the touchscreen display 805 to switch from a screen-on state to a screen-off state; when the proximity sensor 814 detects that the distance between the user and the front of the computer device 800 is gradually increasing, the processor 801 controls the touchscreen display 805 to switch from a screen-off state to a screen-on state.
[0210] Those skilled in the art will understand that the above structure does not constitute a limitation on the computer device 800, and may include more or fewer components than shown in the figure, or combine certain components, or use different component arrangements.
[0211] This application also provides a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to implement the virtual chess piece selection method provided in the above-described method embodiments.
[0212] This application also provides a computer program product, which includes at least one computer program stored in a computer-readable storage medium; the at least one computer program is read from and executed by a processor of a computer device from the computer-readable storage medium, causing the computer device to perform the virtual chess piece selection method provided in the above-described method embodiments.
[0213] It should be understood that "multiple" as used herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are merely illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this.
[0214] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0215] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent switching, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for selecting virtual chess pieces, characterized in that, The method includes: Display a virtual chessboard located in a three-dimensional virtual environment, the virtual chessboard including at least two virtual squares, and at least one three-dimensional virtual chess piece placed in at least one occupied virtual square of the virtual chessboard; In response to a trigger operation on the virtual chessboard, collision detection information of the at least one three-dimensional virtual chess piece is obtained; and the first screen coordinates of the screen plane corresponding to the trigger operation are obtained; the collision detection information is used to indicate the collision detection area of the three-dimensional virtual chess piece in the screen plane; Based on the at least one collision detection information and the first screen coordinates, the three-dimensional virtual chess piece selected by the triggering operation is determined.
2. The method according to claim 1, characterized in that, The step of obtaining collision detection information of the at least one three-dimensional virtual chess piece in response to a trigger operation on the virtual chessboard includes: In response to a trigger operation on the virtual chessboard, the second screen coordinates of the at least one occupied virtual chess square are obtained; Based on the second screen coordinates of the at least one occupied virtual chess piece, the collision detection information of the at least one three-dimensional virtual chess piece is determined.
3. The method according to claim 2, characterized in that, The collision detection information includes the location, width, and height of the collision detection area; The step of determining the collision detection information of the at least one 3D virtual chess piece based on the second screen coordinates of the at least one occupied virtual chess square includes: Obtain the model size of the at least one 3D virtual chess piece; and / or, obtain the size of the at least one occupied virtual chess square; Based on the second screen coordinates of the occupied virtual chess square where each three-dimensional virtual chess piece is located, the position information of the collision detection area of each three-dimensional virtual chess piece is determined; The width and height of the collision detection area of each three-dimensional virtual chess piece are determined based on at least one of the second screen coordinates of the at least one occupied virtual chess piece, the model size of each three-dimensional virtual chess piece, and the size of the occupied virtual chess piece in which each three-dimensional virtual chess piece is located.
4. The method according to claim 3, characterized in that, The step of determining the width and height of the collision detection area of each 3D virtual chess piece based on at least one of the second screen coordinates of the at least one occupied virtual chess square, the model size of each 3D virtual chess piece, and the size of the occupied virtual chess square in which each 3D virtual chess piece is located includes: Calculate the first difference in the horizontal direction between the second screen coordinates of the occupied virtual chess square where each three-dimensional virtual chess piece is located and the second screen coordinates of the adjacent virtual chess square, and determine the width of the collision detection area of each three-dimensional virtual chess piece as the first difference. The adjacent virtual chess square is the virtual chess square that is adjacent to the occupied virtual chess square where each three-dimensional virtual chess piece is located in the horizontal direction. The model height of each 3D virtual chess piece is determined to be the height of the collision detection area of each 3D virtual chess piece.
5. The method according to any one of claims 2 to 4, characterized in that, The method further includes: In response to a trigger operation on the virtual chessboard, first chessboard coordinates of the trigger operation are determined. The first chessboard coordinates are used to indicate the position of the predicted virtual square corresponding to the trigger operation on the virtual chessboard. The predicted virtual square is the virtual square closest to the trigger position of the trigger operation. Based on the first chessboard coordinates of the triggering operation, the virtual chess square adjacent to the predicted virtual chess square and on which the three-dimensional virtual chess piece is placed is determined to be an occupied virtual chess square.
6. The method according to any one of claims 1 to 5, characterized in that, The step of determining the three-dimensional virtual chess piece touched and selected by the triggering operation based on the at least one collision detection information and the first screen coordinates includes: Based on the at least one collision detection information and the first screen coordinates, collision detection is performed on the collision detection area of each three-dimensional virtual chess piece; The three-dimensional virtual chess piece corresponding to the collision detection area is determined to be the three-dimensional virtual chess piece touched and selected by the triggering operation.
7. The method according to claim 6, characterized in that, The step of performing collision detection on the collision detection region for each 3D virtual chess piece based on the at least one collision detection information and the first screen coordinates includes: Based on each of the at least one collision detection information, the third screen coordinates of at least two contour points of each collision detection region are determined, wherein the contour points are points on the contour of the collision detection region. For the first collision detection region in the at least one collision detection information, collision detection is performed on the at least one collision detection region based on at least two contour points corresponding to the first collision detection region and the first screen coordinates.
8. The method according to claim 7, characterized in that, The collision detection region is a regular hexagon; the collision detection region includes six contour points, which are the vertices of the regular hexagon; The step of performing collision detection on the at least one collision detection region based on the first collision detection region in the at least one collision detection information, and based on the third screen coordinates and the first screen coordinates of the at least two contour points corresponding to the first collision detection region, includes: Based on the third screen coordinates of the six contour points, a rectangular detection area and four triangular detection areas are determined, wherein the rectangular detection area and the four triangular detection areas do not overlap. Based on the third screen coordinates of the four contour points corresponding to the rectangular detection area, determine whether the first screen coordinates are located within the rectangular detection area. Based on the third screen coordinates of the two contour points corresponding to each of the four triangular detection regions, determine whether the first screen coordinates are located in the triangular detection region. If the first screen coordinates are located in any one of the rectangular detection area and the four triangular detection areas, it is determined that the first collision detection area passes the collision detection. If the first screen coordinates are not located within the rectangular detection area and the four triangular detection areas, it is determined that the first collision detection area has failed the collision detection.
9. The method according to any one of claims 6 to 8, characterized in that, Each virtual square in the virtual chessboard has a priority; The step of determining that the 3D virtual chess piece corresponding to the collision detection area is the 3D virtual chess piece selected by the triggering operation includes: If at least two 3D virtual chess pieces have collision detection regions that pass the collision detection, the 3D virtual chess piece with the highest priority in the virtual chess grid where each 3D virtual chess piece is located is determined as the 3D virtual chess piece selected by the triggering operation, based on the priority of the virtual chess grid where each 3D virtual chess piece is located.
10. A virtual chess piece selection device, characterized in that, The device includes: The display module is used to display a virtual chessboard located in a three-dimensional virtual environment. The virtual chessboard includes at least two virtual squares, and at least one three-dimensional virtual chess piece is placed in at least one occupied virtual square of the virtual chessboard. A response module is configured to, in response to a trigger operation on the virtual chessboard, acquire collision detection information of the at least one three-dimensional virtual chess piece; and acquire the first screen coordinates of the screen plane corresponding to the trigger operation; the collision detection information is used to indicate the collision detection area of the three-dimensional virtual chess piece in the screen plane; The determination module is used to determine the three-dimensional virtual chess piece selected by the triggering operation based on the at least one collision detection information and the first screen coordinates.
11. The apparatus according to claim 10, characterized in that, The response module includes: The acquisition submodule is used to acquire the second screen coordinates of the at least one occupied virtual chess square in response to a trigger operation on the virtual chessboard. The determination submodule is used to determine the collision detection information of the at least one three-dimensional virtual chess piece based on the second screen coordinates of the at least one occupied virtual chess piece.
12. The apparatus according to claim 11, characterized in that, The collision detection information includes the location, width, and height of the collision detection area; The determining submodule is further configured to obtain the model size of the at least one 3D virtual chess piece; and / or obtain the size of the occupied virtual chess square; determine the position information of the collision detection area of each 3D virtual chess piece based on the second screen coordinates of the occupied virtual chess square where each 3D virtual chess piece is located; and determine the width and height of the collision detection area of each 3D virtual chess piece based on at least one of the second screen coordinates of the at least one occupied virtual chess square, the model size of each 3D virtual chess piece, and the size of the occupied virtual chess square where each 3D virtual chess piece is located.
13. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program that is loaded and executed by the processor to implement the virtual chess piece selection method as described in any one of claims 1 to 9.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the virtual chess piece selection method as described in any one of claims 1 to 9.
15. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium; the computer program is read from and executed by a processor of a computer device, causing the computer device to perform the virtual piece selection method as described in any one of claims 1 to 9.