A multi-model path dynamic programming motion method based on UE4
By implementing dynamic planning motion for multiple model paths through blueprint nodes on the UE4 platform, the problems of discontinuous model motion and unreasonable posture are solved, the service quality of 3D model motion is improved, and collisions are avoided.
Patent Information
- Application Number
- CN202411857860.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2044-12-17
AI Technical Summary
The problems of inconsistent model motion and unreasonable motion posture in existing technologies result in insufficient quality of 3D model motion services.
By using blueprint nodes in the UE4 platform, continuous movement of multiple model paths is achieved through data acquisition, processing, and classification. When a model is about to collide, its flight attitude and speed are adjusted to ensure that the model moves along the preset path.
It achieves the continuity of model motion and the rationality of posture, improves the service quality of 3D model motion, avoids model collisions, and reduces time overhead.
Smart Images

Figure CN119720572B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application relates to the technical field of 3D system simulation, and is a multi-model path dynamic programming motion method based on UE4. BACKGROUND
[0002] Unreal 4 engine is a game development engine launched by Epic Games Company, compared with other engines, Unreal engine is not only efficient, all-purpose, but also can directly preview the development effect, and gives the developer stronger ability. Unreal Engine 4 in the Demo demonstration, its powerful function is brought into full play.
[0003] Blueprint is a powerful new technology introduced in Unreal Engine 4.
[0004] Simply put, Blueprint is a way to create new UClasses, through which no code needs to be written or compiled. When creating a Blueprint, you can choose to inherit from a 'native' C++ class or from another Blueprint class. Then, you can add, arrange, and customize components, implement custom logic using a visual scripting language, react to events and interactions, define custom variables, handle input, and create a completely custom object type.
[0005] Each Blueprint has a 'Construction Script', similar to a constructor in C++, which runs when an object is created. This script can dynamically construct the Actor instance based on a number of factors. In this sense, Blueprints can also be thought of as a very powerful instantiation system.
[0006] In UE4, static meshes can do a lot of things, such as changing their textures or materials during gameplay, or moving them around the level using Matinee. Regardless of how a static mesh is behaving in the level, it may not be desirable for it to be able to pass through or shoot through the mesh. In this case, you would want to set up collision on the static mesh. By default, meshes are not set up with any collision. If there is no collision, Actors will be able to pass through the mesh, and if the mesh is simulating physics, it will fall through the floor of the scene as soon as it is run.
[0007] The aircraft model motion technology involves adjusting the flight attitude of the aircraft frame by frame during the motion of the model, adjusting the current position of the aircraft, and bringing an immersive and shocking experience to the user.
[0008] Based on C++, Unreal Engine 4 provides a large number of blueprints written by functions, for example, the node for changing position in Unreal Engine 4 is SetActorLocation, which is instantaneously moved from point A to point B, and there is no node for continuous motion of the model. SUMMARY
[0009] In view of the deficiencies of the prior art, the application provides a multi-model path dynamic programming motion method based on UE4, the method is realized by using the blueprint node of the Unreal Engine, and the problems of incoherent model motion and unreasonable model motion posture are solved; meanwhile, the method does not need large time consumption, can effectively improve the current model motion problem, and better meets the motion service quality problem in the motion process of the current 3D model.
[0010] The application provides the following technical scheme:
[0011] A multi-model path dynamic programming motion method based on UE4, the method comprises the following steps:
[0012] Step 1: communicate with external data through the UE4 platform, select a file in a resource browser to obtain multi-model path node data, including model motion trajectory coordinates and speed data;
[0013] Step 2: classify and extract the obtained data, and put the data into a corresponding data structure, so that a group of nodes correspond to a model one by one, and a preset path is obtained;
[0014] Step 3: use the blueprint in the UE4 platform to perform continuous motion of the multi-model based on the preset path, decompose a group of nodes into a plurality of node pairs, and realize continuous motion of the multi-model;
[0015] Step 4: judge and adjust the orientation angle of the model in continuous motion, so that the model always faces the destination node in the motion process;
[0016] Step 5: change the running speed before and after the moment when the model is about to collide, so that the time for the model to reach the destination coordinate is consistent.
[0017] Preferably, the step 1 is specifically:
[0018] In the UE4, a UClass is created and named as OpenWindowsFile, and an openwindows function is used in Visual Studio to pop up a resource manager, select a file, and output the file path of the file; a custom C++ class of the UE4 is used to write C++ code, and an open() function in an ifstream class is used to read the file path output by the OpenWindowsFile function to obtain related data in the file.
[0019] Preferably, the step 2 is specifically:
[0020] In the UE4 editor, create a structure consistent with the external file and create a data table with it, so that the data in the data table is consistent with the data in the external file, and use the branches and judgments of the blueprint to make the model name and path and speed one-to-one corresponding.
[0021] Preferably, the step 3 is specifically:
[0022] Step 3.1: encapsulate the initial coordinates A and destination coordinates B of the aircraft;
[0023] a 2 +b 2 =c 2
[0024] Calculate the flight distance S between the initial coordinates and the destination coordinates of the aircraft, and calculate the flight time T according to the flight speed V of the aircraft;
[0025] Step 3.2: set the flown time TT, the initial amount is 0:
[0026] S=VT
[0027] The number of frames n required for the aircraft to fly from the initial position to the destination B is fixed, so the distance the aircraft advances each frame is fixed and is 1 / n of the total distance S; then the aircraft increases TT by 1 / n every frame, until TT=1;
[0028] Step 3.3: when flying to the Kth frame, use the lerp function:
[0029] P=1-Q
[0030] Based on the flown time TT, linear interpolation is performed on the initial coordinates and the destination coordinates to obtain a vector, which is set as the current position of the aircraft;
[0031] When the aircraft flies to the destination coordinates B, reset the flown time;
[0032] Step 3.4: according to the flight data of the aircraft, set the current coordinates of the aircraft as the initial coordinates A, and set the next destination coordinates as B, and repeat the above process.
[0033] Preferably, the step 4 is specifically:
[0034] When the aircraft flies from the initial coordinates A to the destination coordinates B, it needs to adjust its flight angle, obtain the current coordinates and the destination coordinates of the aircraft, calculate the flight angle it should face through the findlookatrotation node, and set the flight angle through the setActorRotation.
[0035] Preferably, the step 5 is specifically:
[0036] Adding components to the model, each model is added to the transparent ellipse surrounding the model, using the OnComponentHit event for collision detection; when the two ellipses collide, it is determined that the two models will collide, and a warning is issued. The ID of the model that will collide is compared, and the speed of the model with the smaller ID is reduced by 50% using the setmaxspeed node for 2 seconds:
[0037] speed = speed / 2
[0038] When the "collision" problem warning is removed, the speed of the model is increased by 3 times using the setmaxspeed node for 2 seconds:
[0039] speed = speed x 3
[0040] After 2 seconds, the speed is restored to normal using the setmaxspeed node:
[0041] speed = 2speed / 3
[0042] Preferably, the flight angle it should face is calculated by the findlookatrotation node, and its flight attitude is dynamically calculated.
[0043] A multi-model path dynamic programming motion system based on UE4, the system comprises:
[0044] A data acquisition module, which communicates with external data through the UE4 platform, selects files in the resource browser to obtain multi-model path node data, including model motion trajectory coordinates and speed data;
[0045] A data processing module, which classifies and extracts the acquired data and puts them into corresponding data structures, so that a group of nodes correspond to a model one by one, and a preset path is obtained;
[0046] A motion module, which uses the blueprint in the UE4 platform to perform continuous motion of multiple models based on the preset path, and realizes continuous motion of multiple models by decomposing a group of nodes into several node pairs;
[0047] An adjustment module, which judges and adjusts the heading angle of the model in continuous motion, so that it always faces the destination node during motion;
[0048] A maintenance module, which changes the running speed of the model before and after the collision moment when the model is about to collide, so that the time for the model to reach the destination coordinate is consistent.
[0049] A computer readable storage medium, having stored thereon a computer program, the program being executed by a processor for implementing a UE4-based multi-model path dynamic programming motion method.
[0050] A computer device, comprising a memory and a processor, the memory storing a computer program, and the processor implementing a UE4-based multi-model path dynamic programming motion method when executing the computer program.
[0051] The present application has the following beneficial effects:
[0052] Compared with the prior art, the present application has the following advantages:
[0053] The present application solves the problem of incoherent model motion of an aircraft. The specific positioning and flight attitude of the aircraft are calculated in real time by calculating the flight time of the aircraft and combining the inherent characteristics of Unreal 4. The flight trajectory of the aircraft is determined by the lerp function.
[0054] After the aircraft flies from the initial coordinates to the destination coordinates, the data read from the external file according to the data table structure provided by Unreal Engine is used to change the next flight destination, and the flight process is repeated. After the aircraft flies from the initial coordinates to the destination coordinates, the progress of the flight is dynamically controlled by changing the flight time.
[0055] During the flight, the flight angle that the aircraft should face is calculated by the findlookatrotation node according to the current coordinates and the destination coordinates of the aircraft, and the flight attitude is dynamically calculated.
[0056] The present application is implemented by using the blueprint node provided by Unreal Engine, and solves the problems of incoherent model motion and unreasonable model motion attitude. At the same time, the method does not require a large time overhead, can effectively improve the current model motion problem, and better meets the motion service quality problem in the motion process of the 3D model. BRIEF DESCRIPTION OF DRAWINGS
[0057] In order to more clearly illustrate the specific embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or prior art description. Obviously, the drawings described below are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0058] Fig. 1 A flowchart showing step 3 of the present application is shown.
[0059] Fig. 2 A flowchart showing step 5 of the present application is shown. DETAILED DESCRIPTION
[0060] The application will be described in detail below in connection with specific embodiments. Embodiment one:
[0062] According to Figs. 1-2 The specific optimization technical scheme adopted by the application to solve the above technical problems is: the application relates to a multi-model path dynamic programming motion method based on UE4.
[0063] A multi-model path dynamic programming motion method based on UE4, the method comprises the following steps:
[0064] Step 1: communicate with external data through the UE4 platform, select a file in the resource browser to obtain multi-model path node data, including model motion trajectory coordinates and speed data;
[0065] Step 2: classify and extract the obtained data, and put them into corresponding data structures, so that a group of nodes correspond to a model one by one, and a preset path is obtained;
[0066] Step 3: use the blueprint in the UE4 platform to perform continuous motion of multiple models based on the preset path, and realize the continuous motion of multiple models by decomposing a group of nodes into a plurality of node pairs;
[0067] Step 4: judge and adjust the heading angle of the model in continuous motion, so that it always faces the destination node during the motion process;
[0068] Step 5: change the running speed before and after the moment when the model is about to collide, so that the time for the model to reach the destination coordinate remains consistent.
[0069] The application solves the problem of incoherent motion of the aircraft model. The specific positioning and flight attitude of the aircraft are calculated in real time by calculating the flight time of the aircraft in combination with the inherent characteristics of Unreal 4. The flight trajectory of the aircraft is determined by the lerp function.
[0070] After the aircraft flies from the initial coordinates to the destination coordinates, the data read from the external file according to the data table structure of the Unreal Engine is used to change the next flight destination, and the flight process is repeated. After the aircraft flies from the initial coordinates to the destination coordinates, the progress of the flight is dynamically controlled by changing the flight time.
[0071] During the flight process, the flight angle that the aircraft should face is calculated by the findlookatrotation node according to the current coordinates and the destination coordinates of the aircraft, and the flight attitude is dynamically calculated. Embodiment two:
[0073] The only difference between Embodiment 2 and Embodiment 1 of this application is that:
[0074] Step 1 specifically involves:
[0075] In UE4, create a UClass named OpenWindowsFile. In Visual Studio, use the openwindows function to open the file explorer, select a file, and output its file path. Using a custom C++ class in UE4, write C++ code to use the open() function in the ifstream class to read the file path output by the OpenWindowsFile function and obtain the relevant data in the file. Specific Implementation Example 3:
[0077] The only difference between Embodiment 3 and Embodiment 2 of this application is that:
[0078] Step 2 specifically involves:
[0079] Create a structure in the UE4 editor that is consistent with the external file, and use it to create a data table. Make the data in the data table consistent with the data in the external file. Use blueprint branches and judgments to make the model name correspond to the path and speed one by one. Specific Implementation Example 4:
[0081] The only difference between Embodiment 4 and Embodiment 3 of this application is that:
[0082] Step 3 specifically involves:
[0083] Step 3.1: Seal the initial coordinates A and destination coordinates B of the aircraft;
[0084] a 2 +b 2 =c 2
[0085] Calculate the flight distance S between the initial coordinates and the destination coordinates of the aircraft, and calculate the flight time T based on the aircraft's flight speed V;
[0086] Step 3.2: Set the flight time TT, with an initial value of 0:
[0087] S=VT
[0088] If the number of frames n required for the aircraft to travel from its initial position to its destination B is fixed, then the distance traveled by the aircraft in each frame is fixed and is 1 / n of the total distance S; therefore, TT increases by 1 / n for each frame the aircraft flies, until TT = 1.
[0089] Step 3.3: When flying to the Kth frame, use the lerp function:
[0090] P = 1 - Q
[0091] Based on the time of flight TT, linear interpolation is performed on the initial coordinates and the destination coordinates to obtain a vector, which is set as the current position of the aircraft;
[0092] When the aircraft flies to the destination coordinate B, the time of flight is reset;
[0093] Step 3.4: According to the flight data of the aircraft, the current coordinates of the aircraft are set as the initial coordinates A, and the next destination coordinates are set as B, and the above process is repeated. Specific embodiment five:
[0095] The difference between the embodiment five and the embodiment four is only that:
[0096] The step 4 is specifically:
[0097] When the aircraft flies from the initial coordinates A to the destination coordinates B, the flight angle of the aircraft needs to be adjusted, the current coordinates and the destination coordinates of the aircraft are obtained, the flight angle that the aircraft should face is calculated through the findlookatrotation node, and the flight angle is set through the setActorRotation. Specific embodiment six:
[0099] The difference between the embodiment six and the embodiment five is only that:
[0100] The step 5 is specifically:
[0101] Components are added to the model, and a transparent ellipse is added to surround the model, and collision detection is performed by using the OnComponentHit event; when the two ellipses collide, it is determined that the two models will have a “collision” problem, a warning is issued, and the ID of the model that will have a collision is compared, and the speed speed of the model with a smaller ID is reduced by 50% for 2 seconds by using the node setmaxspeed:
[0102] speed=speed / 2
[0103] When the “collision” problem warning is removed, the speed of the model is increased by 3 times for 2 seconds by using the node setmaxspeed:
[0104] speed=speed×3
[0105] After 2 seconds, the speed is restored to normal by using the node setmaxspeed:
[0106] speed=2speed / 3 Specific embodiment seven:
[0108] Embodiment seven of the present application differs from embodiment six only in that:
[0109] The flight angle that it should face is calculated by the findlookatrotation node, and its flight attitude is dynamically calculated. Specific embodiment eight:
[0111] Embodiment eight of the present application differs from embodiment seven only in that:
[0112] The present application provides a kind of based on UE4's multi-model path dynamic programming motion system, the system includes:
[0113] Data acquisition module, the data acquisition module is communicated with external data by UE4 platform, selects the file in resource browser and obtains multi-model path node data, including the motion trajectory coordinates of model, speed data;
[0114] Data processing module, the data processing module is classified, extracted processing to the data obtained, is placed in corresponding data structure, so that a group of nodes are one-to-one with model, obtains preset path;
[0115] Motion module, the motion module adopts blueprint in UE4 platform, carries out multi-model continuous motion based on preset path, realizes the continuous motion of multi-model by a group of nodes are decomposed into several node pairs;
[0116] Adjustment module, the adjustment module judges and adjusts the orientation angle of model in continuous motion, so that it is always oriented to destination node in the process of motion;
[0117] Maintaining module, the maintaining module changes running speed before and after the moment when collision is about to occur when model is about to collide, so that the time when model reaches destination coordinate is consistent. Specific embodiment nine:
[0119] Embodiment nine of the present application differs from embodiment eight only in that:
[0120] The present application provides a kind of computer readable storage medium, it has computer program on it, the program is executed by processor, to be used for realizing a kind of based on UE4's multi-model path dynamic programming motion method. Specific embodiment ten:
[0122] Embodiment ten of the present application differs from embodiment nine only in that:
[0123] The present application provides a kind of computer equipment, including memory and processor, the memory is stored with computer program, the processor realizes a kind of based on UE4's multi-model path dynamic programming motion method when the computer program is executed. Specific embodiment eleven:
[0125] Embodiment eleven of the present application differs from embodiment ten only in that:
[0126] The present application provides a method for setting the attitude adjustment of an aircraft model, which is realized by using the blueprint node of Unreal Engine, solves the problems of incoherent model movement and unreasonable model movement attitude, and does not require excessive time consumption, can effectively improve the current model movement problem, and better meets the quality of service in the movement process of the current 3D model.
[0127] The present application is realized through the following scheme:
[0128] A multi-model path dynamic programming movement method based on UE4, the matching method comprising the following steps:
[0129] Step 1: UE4 platform communicates with external data, selects files in the resource browser to obtain multi-model path node data, including model movement trajectory coordinates and speed data.
[0130] Step 2: classify and extract the data in step 1, and put them into the corresponding data structure, so that a group of nodes correspond to a model, and the models are distinguished by unique and non-repetitive ID names.
[0131] Step 3: use the blueprint in the UE4 platform to perform continuous movement of multiple models based on the preset path imported in step 2, decompose a group of nodes into a plurality of node pairs, and realize continuous movement of multiple models.
[0132] Step 4: judge and adjust the orientation angle of the model in continuous movement in step 3, so that it always faces the destination node during movement.
[0133] Step 5: considering the model "collision" problem that will occur in the process of multiple model movement according to path planning in step 4, based on collision detection, change the running speed before and after the moment when the collision is about to occur, so that the time for the model to reach the destination coordinate remains the same. Ensure that multiple models run continuously while following path planning, and avoid possible "collision" problems.
[0134] The step 1 is specifically: creating a UClass named OpenWindowsFile in UE4, and using the openwindows function in Visual Studio to pop up the resource manager, selecting the file to output its file path. Using the custom C++ class of UE4, writing C++ code, using the open() function in the ifstream class to read the file path output by the OpenWindowsFile function to obtain the related data in the file.
[0135] The step 2 is specifically: creating a structure in UE4 editor that is consistent with the external file and creating a data table with it, so that the data of the data table is consistent with the data in the external file. The branches and judgments of the blueprint make the model name and path, speed one-to-one corresponding.
[0136] The step 3 is specifically:
[0137] ① Package the initial coordinates A and destination coordinates B of the aircraft.
[0138] ② From
[0139] a 2 +b 2 =c 2
[0140] Calculate the flight distance S between the initial coordinates and the destination coordinates of the aircraft, and calculate the flight time T according to the flight speed V of the aircraft.
[0141] ③ Set the flown time TT, the initial amount is 0. From
[0142] S=VT
[0143] The number of frames n required for the aircraft to fly from the initial position to the destination B is fixed, so the distance the aircraft advances each frame is fixed and is 1 / n of the total distance S. Then the aircraft increases TT by 1 / n every frame, until TT=1.
[0144] ④ When flying to the Kth frame, use the lerp function, from
[0145] P=1-Q
[0146] Based on the flown time TT, a linear interpolation is made between the initial coordinates and the destination coordinates to obtain a vector, which is set as the current position of the aircraft.
[0147] ⑤ When the aircraft flies to the destination coordinates B, reset the flown time.
[0148] ⑥ According to the flight data of the aircraft, set the current coordinates of the aircraft as the initial coordinates A, and set the next destination coordinates as B, and repeat the above process.
[0149] The step 4 is specifically: when the aircraft flies from the initial coordinates A to the destination coordinates B, it needs to adjust its flight angle. At this time, the current coordinates and destination coordinates of the aircraft need to be obtained, and the flight angle it should face is calculated through the findlookatrotation node, and the flight angle is set through the setActorRotation.
[0150] The step 5 is specifically adding components to the model, adding a transparent ellipse around the model, and using the OnComponentHit event for collision detection. When the two ellipses collide, it is determined that the two models will collide, a warning is issued, and the ID of the model to be collided is compared. The speed of the model with smaller ID is reduced by 50% for 2 seconds using the node setmaxspeed.
[0151] speed = speed / 2
[0152] When the "collision" problem warning is removed, the speed of the model is increased by 3 times using the node setmaxspeed for 2 seconds.
[0153] speed = speed*3
[0154] After 2 seconds, the speed is restored to normal using the node setmaxspeed.
[0155] speed = 2speed / 3 Specific embodiment twelve:
[0157] Radar jamming scenario:
[0158] In the radar jamming scenario, the jamming UAV passes through the radar station from the initial point to the destination. In this process, the jamming UAV mainly performs the following steps:
[0159] Step 1: UE4 platform communicates with external data, selects files in the resource browser to obtain multi-model path node data, including model motion trajectory coordinates and speed data.
[0160] Step 2: classify and extract the data in step 1, and put it into the corresponding data structure, so that a group of nodes correspond to a model, and the models are distinguished by unique and non-repetitive ID names.
[0161] Step 3: use the blueprint in the UE4 platform to continuously move multiple models based on the preset path imported in step 2, and realize the continuous movement of multiple models by decomposing a group of nodes into several node pairs.
[0162] Step 4: judge and adjust the heading angle of the model in step 3 to make it always face the destination node during movement.
[0163] Step 5: Considering the model "collision" problem that will occur in the process of path planning motion of multiple models in step 4, based on collision detection, the running speed before and after the moment when the collision is about to occur is changed, so that the time for the model to reach the destination coordinate remains unchanged. Ensure that the multiple models continue to run while following the path planning, and avoid the possible "collision" problem.
[0164] The step 1 is specifically: create a UC class named OpenWindowsFile in UE4, and use the openwindows function in Visual Studio to pop up the resource manager, select the file and output its file path. Use the custom C++ class of UE4 to write C++ code, and use the open() function in the ifstream class to read the file path output by the OpenWindowsFile function to get the related data in the file.
[0165] The step 2 is specifically: create a structure that is always the same as the external file in the UE4 editor and create a data table based on it, so that the data of the data table is consistent with the data in the external file. Use the branches and judgments of blueprints to make the model name and path, speed one-to-one correspondence.
[0166] The step 3 is specifically:
[0167] ① Encapsulate the initial coordinates A and destination coordinates B of the aircraft.
[0168] ② Calculate the flight distance S between the initial coordinates and the destination coordinates of the aircraft, and calculate the flight time T according to the flight speed V of the aircraft.
[0169] ③ Set the flown time TT, the initial value is 0. From S=VT, the number of frames n required for the aircraft to fly from the initial position to the destination B is fixed, then the distance of the aircraft in each frame is fixed, and it is 1 / n of the total distance S. Then the aircraft flies a frame, TT increases by 1 / n, until TT=1.
[0170] ④ At the K-th frame of flight, use the lerp function, P=1-Q, based on the flown time TT, do linear interpolation on the initial coordinates and the destination coordinates to get a vector, and set it as the current position of the aircraft.
[0171] When the aircraft flies to the destination coordinate B, reset the flown time.
[0172] ⑥ According to the flight data of the aircraft, set the current coordinate of the aircraft as the initial coordinate A, and set the next destination coordinate as B, and repeat the above process.
[0173] The step 4 is specifically: the aircraft needs to adjust its flight angle when flying from the initial coordinate A to the destination coordinate B. At this time, the current coordinate and the destination coordinate of the aircraft need to be obtained, the flight angle it should face is calculated through the findlookatrotation node, and the flight angle is set through the setActorRotation.
[0174] The step 5 is specifically: adding components to the model, adding a transparent ellipse to surround the model, and using the OnComponentHit event for collision detection. When the two ellipses collide, it is determined that the two models will have a “collision” problem, a warning is issued, and the ID of the model about to collide is compared. The speed of the model with smaller ID is reduced by 50% for 2 seconds by using the setmaxspeed node.
[0175] When the “collision” problem warning is removed, the speed of the model is increased by 3 times for 2 seconds by using the setmaxspeed node.
[0176] After 2 seconds, the speed is restored to normal by using the setmaxspeed node.
[0177] Example XIII
[0178] Multi-UAV wide area reconnaissance, in the process of multi-UAV wide area reconnaissance, first set the initial coordinate and flight trajectory coordinate data table of each UAV according to the external CSV file. In the UAV wide area reconnaissance scene, the UAV needs to be close to the communication radiation source and the data link radiation source and away from the interference radiation source.
[0179] After setting, enter the simulation process of UAV flight, and the UAV first reaches the first destination coordinate according to the following steps:
[0180] Step 1: UE4 platform communicates with external data, selects file in resource browser to get multi-model path node data, including model motion trajectory coordinates and speed data.
[0181] Step 2: classify and extract the data in step 1, put it into the corresponding data structure, so that a group of nodes correspond to a model, and the models are distinguished by unique and non-repetitive ID names.
[0182] Step 3: use the blueprint in the UE4 platform to continuously move the multi-model based on the preset path imported in step 2, and realize the continuous movement of the multi-model by decomposing a group of nodes into several node pairs.
[0183] Step 4: judge and adjust the heading angle of the model in step 3 continuous movement, so that it always faces the destination node during movement.
[0184] Step 5: Considering the model "collision" problem that will occur in the process of path planning motion of multiple models in step 4, based on collision detection, the running speed before and after the time when the collision will occur is changed, so that the time for the model to reach the destination coordinate remains unchanged. Ensure that the multiple models continue to run while following the path planning, and avoid the possible "collision" problem.
[0185] Said step 1 is specifically: create a UC class named OpenWindowsFile in UE4, and use the openwindows function in Visual Studio to pop up the resource manager, select the file and output its file path. Use the custom C++ class of UE4 to write C++ code, and use the open() function in the ifstream class to read the file path output by the OpenWindowsFile function to get the related data in the file.
[0186] Said step 2 is specifically: create a structure that is always the same as the external file in the UE4 editor and create a data table based on it, so that the data in the data table is consistent with the data in the external file. Use the branches and judgments of Blueprints to make the model name and path, speed one-to-one correspondence.
[0187] Said step 3 is specifically:
[0188] ① Encapsulate the initial coordinates A and destination coordinates B of the aircraft.
[0189] ② Calculate the flight distance S between the initial coordinates and the destination coordinates of the aircraft, and calculate the flight time T according to the flight speed V of the aircraft.
[0190] ③ Set the flown time TT, the initial value is 0. From S=VT, the number of frames n required for the aircraft to fly from the initial position to the destination B is fixed, then the distance of the aircraft in each frame is fixed, and it is 1 / n of the total distance S. Then the aircraft flies one frame, TT increases by 1 / n, until TT=1.
[0191] ④ When flying to the Kth frame, use the lerp function, P=1-Q, based on the flown time TT, do linear interpolation on the initial coordinates and the destination coordinates to get a vector, and set it as the current position of the aircraft.
[0192] ⑤ When the aircraft flies to the destination coordinate B, reset the flown time.
[0193] ⑥ According to the flight data of the aircraft, set the current coordinates of the aircraft as the initial coordinates A, and set the next destination coordinates as B, and repeat the above process.
[0194] The step 4 is specifically: the aircraft needs to adjust its flight angle when flying from the initial coordinate A to the destination coordinate B. At this time, the current coordinate and the destination coordinate of the aircraft need to be obtained, the flight angle that it should face is calculated through the findlookatrotation node, and the flight angle is set through the setActorRotation.
[0195] The step 5 is specifically: components are added to the model, and a transparent ellipse is added to surround the model. Collision detection is performed by using the OnComponentHit event. When the two ellipses collide, it is determined that the two models will have a “collision” problem, a warning is issued, and the ID of the model about to collide is compared. The speed speed of the model with the smaller ID is reduced by 50% for 2 seconds by using the setmaxspeed node.
[0196] When the “collision” problem warning is removed, the speed of the model is increased by 3 times for 2 seconds by using the setmaxspeed node.
[0197] After 2 seconds, the speed is restored to normal by using the setmaxspeed node.
[0198] The above is only a preferred embodiment of the UE4-based multi-model path dynamic planning motion method, and the protection scope of the UE4-based multi-model path dynamic planning motion method is not limited to the above-mentioned embodiments. Any technical solution that belongs to the idea of the present application is within the protection scope of the present application. It should be noted that, for those skilled in the art, some improvements and changes without departing from the principles of the present application are also considered to be within the protection scope of the present application.
Claims
1. A method for multi-model path dynamic programming motion based on UE4, characterized in that: The method comprises the following steps: Step 1: Select a file in the resource browser to obtain multi-model path node data, including model motion trajectory coordinates and speed data, by communicating with external data through the UE4 platform; Step 2: Classify and extract the obtained data, and place them in corresponding data structures, so that a group of nodes correspond to a model one by one, to obtain a preset path; Step 3: Use the blueprint in the UE4 platform to perform continuous motion of multiple models based on the preset path, and realize the continuous motion of multiple models by decomposing a group of nodes into a plurality of node pairs; The step 3 is specifically: Step 3.1: Encapsulate the initial coordinates A and the destination coordinates B of the aircraft; Calculate the flight distance S between the initial coordinates and the destination coordinates of the aircraft, and calculate the flight time T according to the flight speed V of the aircraft; Step 3.2: Set the flown time TT, which is initially 0: The number of frames n required for the aircraft to fly from the initial position to the destination B is fixed, so the distance the aircraft advances each frame is fixed and is 1 / n of the total distance S; then the aircraft increases TT by 1 / n each frame until TT=1; Step 3.3: At the Kth frame, use the lerp function: Based on the flown time TT, a linear interpolation is performed on the initial coordinates and the destination coordinates to obtain a vector, which is set as the current position of the aircraft; When the aircraft flies to the destination coordinates B, reset the flown time; Step 3.4: According to the flight data of the aircraft, set the current coordinates of the aircraft as the initial coordinates A, and set the next destination coordinates as B, and repeat the above process; Step 4: Judge and adjust the orientation angle of the model in continuous motion, so that it always faces the destination node during the motion; The step 4 is specifically: The aircraft needs to adjust its flight angle when flying from the initial coordinates A to the destination coordinates B, obtain the current coordinates and the destination coordinates of the aircraft, calculate the flight angle it should face through the findlookatrotation node, and set the flight angle through the setActorRotation; Step 5: Change the running speed before and after the moment when the model is about to collide, so that the model reaches the destination coordinates at the same time; The step 5 is specifically: Add components to the model, and add a transparent elliptical surrounding model to each model to detect collisions using the OnComponentHit event; when the two ellipses collide, it is determined that the two models will collide, a warning is issued, and the IDs of the models that will collide are compared, and the speed speed of the model with the smaller ID is reduced by 50% for 2 seconds using the setmaxspeed node: When the "collision" warning is removed, the speed of the model is increased by 3 times for 2 seconds using the setmaxspeed node: After 2 seconds, the speed is restored to normal using the setmaxspeed node: 。 2. The method of claim 1, wherein: The step 1 is specifically: In UE4, create a UCass named OpenWindowsFile, and in Visual Studio, use the openwindows function to pop up the resource manager, and output the file path after selecting the file; use the custom C++ class of UE4 to write C++ code, and use the open() function in the ifstream class to read the file path output by the OpenWindowsFile function to get the relevant data in the file.
3. The method of claim 2, wherein: The step 2 is specifically: In the UE4 editor, create a structure that is consistent with the external file and create a data table based on the structure, so that the data in the data table is consistent with the data in the external file, and use the branches and judgments of the blueprint to make the model name and path and speed one-to-one corresponding.
4. The method of claim 3, wherein: The findlookatrotation node is used to calculate the flight angle that the model should face, and the flight attitude is dynamically calculated.
5. A UE4-based multi-model path dynamic programming motion system, the system is based on the UE4-based multi-model path dynamic programming motion method of claim 1, characterized in that: The system comprises: A data acquisition module, which communicates with external data through the UE4 platform, selects a file in the resource browser to obtain multi-model path node data, including model motion trajectory coordinates and speed data; A data processing module, which classifies and extracts the acquired data and puts them into corresponding data structures, so that a group of nodes correspond to a model one by one, and a preset path is obtained; A motion module, which uses the blueprint in the UE4 platform to perform continuous motion of multiple models based on the preset path, and realizes the continuous motion of multiple models by decomposing a group of nodes into a plurality of node pairs; An adjustment module, which judges and adjusts the orientation angle of the model in continuous motion, so that the model always faces the destination node during the motion process; A maintaining module, which changes the running speed before and after the moment when the model is about to collide, so that the time for the model to reach the destination coordinate remains consistent.
6. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by a processor for implementing the method of any one of claims 1-4.
7. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that: The processor executes the computer program to implement the method of any one of claims 1-4. The processor executes the computer program to implement the method of any one of claims 1-4.
Citation Information
Patent Citations
Simulation operation control method and system based on unreal engine
CN117032895A