Disclosure of Invention
An object of the present application is to provide a ground reconnaissance visibility deciding method, a terminal device and a computer-readable storage medium, so as to solve the problems in the background art.
The first embodiment of the invention discloses a ground reconnaissance sight adjudication method, which comprises the following steps:
determining an instruction chess piece, and determining at least one enemy chess piece within the sight range of the instruction chess piece according to the instruction chess piece, wherein the instruction chess piece is a ground reconnaissance chess piece;
inquiring whether the communication data of the instruction chess piece and the first enemy chess piece exist in the communication record table, if so, directly using the instruction chess piece and the first enemy chess piece; if not, the command chess piece is taken as the original point, a ray is emitted to the first enemy chess piece, whether the ray collides with the first enemy chess piece or not is judged, and a judgment result is obtained, wherein the judgment result is the communication data of the command chess piece and the first enemy chess piece;
and storing the obtained communication data of the instruction chess piece and the first enemy chess piece in the communication record table.
Preferably, before the determining the instruction chess piece and determining at least one enemy chess piece within the sight range of the instruction chess piece according to the instruction chess piece, the method further comprises the following steps:
establishing a three-dimensional coordinate system, and generating a hexagonal grid with terrain attributes in the three-dimensional coordinate system;
determining basic information data corresponding to each grid, wherein the basic information data comprise coordinate positions, elevations and sheltering ground objects in the grids;
correspondingly, the determining of the instruction chess piece determines the enemy chess piece within the sight range of the instruction chess piece according to the instruction chess piece, and specifically comprises the following steps:
determining the grids to which the command chess pieces belong, determining the enemy chess pieces in the sight range of the command chess pieces according to the command chess pieces, and determining the grids to which the enemy chess pieces belong.
Preferably, the step of using the instruction chess piece as an origin to emit a ray to the enemy chess piece to judge whether the ray collides with the enemy chess piece specifically comprises the steps of:
taking the grid to which the command chess piece belongs as an original point, and transmitting a ray to the grid to which the enemy chess piece belongs;
judging whether a shielding ground object exists in the grid of the ray passing path, if so, judging whether the ray collides with the shielding ground object, and if so, determining that the command chess piece is invisible with the enemy chess piece; and if not, continuously judging whether the ray collides with the enemy chessman or not.
Preferably, judging whether the ray collides with the sheltered ground object, specifically:
and performing linear search on the ray, wherein if two points on two opposite sides of the shielding ground object are found, the ray collides with the shielding ground object.
Preferably, after the ray collides with the shielding ground object if two points on two opposite sides of the shielding ground object are found, the method further includes:
and performing dichotomy search between two points on two opposite sides of the sheltered ground object to determine a specific collision point.
Preferably, the determining whether the ray collides with the enemy chessman specifically includes:
and judging whether the ray collides with the enemy chessman or not by using a slab collision detection method, if so, enabling the instruction chessman to be in communication with the enemy chessman, and if not, disabling the communication.
A second embodiment of the present invention discloses a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method when executing the computer program.
A third embodiment of the invention discloses a computer-readable storage medium, which stores a computer program that, when executed by a processor, implements the steps of the above-described method.
Compared with the prior art, the ground reconnaissance and visibility deciding method, the terminal equipment and the computer readable storage medium have the following beneficial effects:
the invention solves the problems of slow through calculation and low efficiency in the traditional war game deduction, reduces the calculation times, saves the time, can obtain the through result of the chess pieces in a shorter time, and improves the calculation efficiency and the accuracy; meanwhile, the method is simple in overall operation, and reduces the CPU resource consumption and the memory occupation of the intelligent equipment.
Before the command chess piece needs to judge whether to communicate with the enemy chess piece, the invention can search whether the communication data of the command chess piece and the enemy chess piece exist from the communication record table, if so, the communication data in the record can be directly reused without calculating again, thereby improving the efficiency.
According to the method, the chess pieces are manufactured in a three-dimensional scene according to the principle of diffuse reflection and light transmission along a straight line, the emitted rays are used for simulation, and the chess pieces are found when the rays collide with enemy chess pieces, so that the purpose of chess piece communication is achieved.
The invention brings great improvement to the execution efficiency of the military chess visual system and the accuracy of the visual result. A three-dimensional engine technology is used for simulating and constructing a battlefield environment, and a three-dimensional ray form is used for simulating the diffuse reflection effect of light, so that a more real battlefield reconnaissance effect is achieved. The reconnaissance instruction in the chess can be reflected more perfectly, and the effect that all the chess pieces can be reconnaissance completed instantly is achieved.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
The present invention will be described in detail with reference to examples, but the present invention is not limited to these examples.
The precondition of visual detection, optical detection and thermal imaging detection needs the communication between a detection unit and a detected unit, and the radar detection and the electronic detection do not need the communication judgment. When the head-up display is judged, a straight line needs to be connected from the center of the hexagonal grid where the unit of the own party is located to the center of the hexagonal grid where the target is located, and whether the head-up display is displayed or not is determined by judging the shielding effect of the hexagonal grid terrain passing through the straight line on the head-up display.
FIG. 1 is a flow chart of a ground reconnaissance inspection and decision method of the present invention.
The ground reconnaissance sight adjudication method comprises the following steps:
step 1, determining an instruction chess piece, determining at least one enemy chess piece within the visual range of the instruction chess piece according to the instruction chess piece, wherein the instruction chess piece is a ground reconnaissance chess piece;
step 2, inquiring whether the communication record table has communication data of the instruction chess piece and the first enemy chess piece, if so, directly using the instruction chess piece and the first enemy chess piece; if not, the command chess piece is taken as the original point, a ray is emitted to the first enemy chess piece, whether the ray collides with the first enemy chess piece or not is judged, and a judgment result is obtained, wherein the judgment result is the communication data of the command chess piece and the first enemy chess piece; a plan view of the command chess piece and the enemy chess piece is shown in figure 2; a plan view of the command chess piece and the enemy chess piece which are invisible is shown in figure 3; in FIG. 2, squares represent elevation of the command chess piece and enemy chess pieces, triangles represent elevation changes, and triangles are all below a connecting line, representing two-point communication. In FIG. 3, a square shape indicates the elevation of the command chess piece and the enemy chess piece, a triangle indicates the elevation change, and a triangle is connected above a connecting line to indicate that two points are invisible.
And 3, storing the obtained communication data of the instruction chess pieces and the enemy chess pieces in a communication record table.
Before the command chess piece needs to judge whether to communicate with the enemy chess piece, the invention can search whether the communication data of the command chess piece and the enemy chess piece exist from the communication record table, if so, the communication data in the record can be directly reused without calculating again, thereby improving the efficiency.
Before step 1, the method further comprises the following steps:
establishing a three-dimensional coordinate system, and generating a hexagonal grid with a terrain attribute in the three-dimensional coordinate system;
determining basic information data corresponding to each grid, wherein the basic information data comprise coordinate positions, elevations and sheltering ground objects in the grids;
correspondingly, confirm the instruction piece, confirm the enemy piece in its sight range according to the instruction piece, specifically:
determining the grid to which the command chessman belongs, determining the enemy chessman in the sight range of the command chessman according to the command chessman, and determining the grid to which the enemy chessman belongs.
Use the instruction piece as the initial point in step 2 of this application, to enemy's piece transmission ray, judge whether ray collides the enemy piece, specifically do:
using the grid to which the command chessman belongs as an original point, and transmitting a ray to the grid to which the enemy chessman belongs;
judging whether a shielding ground object exists in the grid of the path traveled by the ray, if so, judging whether the ray collides with the shielding ground object, and if so, determining that the command chess piece is invisible with the enemy chess piece; if not, whether the ray collides with the enemy chessman or not is continuously judged.
Wherein, judge whether ray and shelter from ground object collision, specifically do:
and performing linear search on the ray, wherein if two points on two opposite sides of the shielding ground object are found, the ray collides with the shielding ground object, and otherwise, the ray does not collide.
In this embodiment, instead of detecting the collision between the ray and the grid, collision detection may be performed between the ray and the height map to detect the collision between the ray and the grid, and after this step, to further determine the collision point, a dichotomy search may be performed between two points on opposite sides of the shaded feature to determine a specific collision point. Whether a specific collision point needs to be acquired or not is determined according to actual needs. If not, the step of acquiring the collision point is not executed.
According to the method and the device, when a program runs, data of all pieces of both enemy and my can be obtained, the distance between all pieces of the enemy and the instruction piece is calculated only once, the pieces of the enemy smaller than the sight range are within the sight range of the pieces, and the pieces of the enemy are all pieces of the enemy which are screened out.
This application is judged whether ray and enemy's piece bump specifically do: and judging whether the ray collides with the enemy chessman or not by using a slab collision detection method, if so, enabling the instruction chessman to be in communication with the enemy chessman, and if not, disabling the communication.
Whether a ray collides with an enemy chessman or not can be detected, the problem that the ray collides with an AABB (Axially Aligned Bounding Box) can be solved by using a collision detection algorithm of the slab, the slab refers to a space between two parallel planes, the basic idea is that a cube or a sphere completely wraps a 3D object, and the AABB Box in the 3D space is regarded as an intersection of the slabs in 3 directions formed by 3 groups of parallel planes of the AABB.
If the ray does not coincide with the intersected line segments of the 3 slabs, the line segments cannot exist in the 3 slabs simultaneously, and the line segments cannot exist in an AABB box, and whether the ray collides with the chess pieces can be quickly calculated by using the method.
As shown in fig. 4, the present application uses a 2D graph to explain the slab algorithm.
According to the collision detection algorithm of the slab, introducing the concept of a candidate face: in 3D space, three faces facing the Ray are determined first, that is, three candidate faces can be determined by somehow ignoring the back of the AABB with respect to the Ray. These three candidate faces are the nearest faces that are likely to intersect with Ray.
According to this definition, the following three conclusions can be drawn:
the property one is as follows: if a point is in AABB, then this point must be in these 3 slabs at the same time.
Property II: if a ray intersects an AABB, then the intersection of the ray with 3 slabs must have an overlap.
Property III: when a Ray intersects one of the three candidate surfaces, the Ray has its origin at a longer distance from the surface than from the other surfaces.
It is easier to understand that if the ray does not coincide with the 3 slab intersection segments, then these segments cannot exist in 3 slabs at the same time, and cannot be in the AABB box.
In FIG. 4, the ray is shot in the lower right corner and in the upper left corner, and the ray passes through a point A, where the candidate faces are the y1 face and the x2 face. From the above properties, it can be seen that point a is simultaneously in 2 slabs in 2D space; furthermore, according to property two, because the ray intersects a plane, then the intersection of this ray with the slab must have an overlap, because the a point is on the ray and in the plane, then max (t1, t2) < = tA < = min (t3, t4) can be obtained; according to the third property: when crossed, it can be seen that t2> t 1. Similarly, the above verification process can be generalized to three dimensions. In the three-dimensional space, assuming that distances from the ray to the 3 candidate surfaces are t1, t2, and t3, respectively, and distances from the ray to the surfaces corresponding to the candidate surfaces are t4, t5, and t6, respectively, then according to property two, the condition that the ray collides with the AABB is max (t1, t2, t3) < = min (t4, t5, t 6); if intersection occurs, then the distance of the ray to the nearest intersection plane is max according to property three (t1, t2, t 3).
Based on the above properties, determining whether a ray intersects with an AABB requires three steps:
1. how to determine candidate faces: if the plane equation is substituted into the equation of the Ray, the t values of the two planes are obtained, and then the smaller t value naturally crosses the Ray first, it is indicated as a candidate plane. The ray can be represented by parametric equations as R (t) = P0 + t.d, (where P0 is the ray origin and d is the ray's direction vector)
2. Equation of how to determine candidate faces: the plane is given by the implicit definition equation X · n = D, (where X is the point on the plane, n is the plane normal vector, and D is the distance from the origin to the plane). Since the slab plane of the AABB is parallel to two coordinate axes, and the normal of its surface always has two components of 0 and the other component always is 1, we use the normal of 1 for a certain axis component consistently. If the above equation represents the left face of the AABB box, then n in the equation represents (1,0,0), but when the above equation represents the right face of the AABB box, the value represented by n is still (1,0, 0).
3. How to judge whether the intersection is on the AABB box: judging from the property two that the condition for the ray to collide with the AABB is max (t1, t2, t3) < = min (t4, t5, t 6).
From this, a uniform t-value formula can be derived:
when the candidate plane is perpendicular to both planes of the x axis, t = (D-Px)/dx.
When the candidate plane is perpendicular to both planes of the y-axis, t = (D-Py)/dy.
When the candidate plane is perpendicular to both planes of the z axis, t = (D-Pz)/dz.
When the enemy chessman is positioned in the ground object with the shielding function, such as the residential area and the forest element, the invention usually influences the communication. Generally, the target can be completely shielded in the residential area and the jungle, so when a shielding ground object is instructed to be arranged between the chess pieces and the enemy chess pieces, the height of the shielding ground object needs to be increased in the original landform height during reconnaissance judgment, for example, the height of a sparse residential area is generally 10 meters, and the height of a medium residential area is 20 meters. The height of the specific object is detailed in the ground form table of the chess. Under the condition of communication, chessmen in hexagonal lattices at the edge of a residential area or a jungle area can still be detected by other units, and the detection finding rate is reduced only due to the shielding effect of the residential area or the jungle area.
According to the reconnaissance rule, a three-dimensional scene is built in the three-dimensional terrain, an elevation and a shielding ground object in a grid are added, an enemy chessman queue is built, enemy chessmen in a reconnaissance range are added into the queue, rays are emitted to the enemy chessmen in the queue from the command chessmen one by one, and if the rays are not shielded by the elevation and the shielding ground object and collide with the chessmen in the reconnaissance range, the command chessmen and the enemy chessmen are considered to be in communication.
A second embodiment of the invention discloses a terminal device comprising a memory, a processor and a computer program, such as a software development program, stored in the memory and executable on the processor, the steps of the method being implemented when the processor executes the computer program.
Illustratively, a computer program may be partitioned into one or more modules/units, which are stored in a memory and executed by a processor to implement the present invention. One or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of a computer program in a terminal device. For example, the computer program may be divided into an acquisition module, an execution module, and the like.
The terminal device can be a desktop computer, a notebook computer, a palm computer, a cloud server and other computing devices. The terminal device may include, but is not limited to, a processor, a memory.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory may be an internal storage unit of the terminal device, such as a hard disk or a memory of the terminal device. The memory may also be an external storage device of the terminal device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the terminal device. Further, the memory may also include both an internal storage unit of the terminal device and an external storage device. The memory is used for storing computer programs and other programs and data required by the terminal device. The memory may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the above embodiments may be implemented by a computer program, which may be stored in a computer-readable storage medium, to instruct related hardware.
A third embodiment of the invention discloses a computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of the above-mentioned method. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
Although the present application has been described with reference to a few embodiments, it should be understood that various changes, substitutions and alterations can be made herein without departing from the spirit and scope of the application as defined by the appended claims.