Scaling methods for straight Spline tracks and SplineMesh
By generating straight spline component data and repeatedly calling the component generation method, the problem of the straight spline mesh not being able to scale was solved, and the scaling effect of the spline mesh being consistent with the trajectory of the target straight spline component was achieved.
Patent Information
- Application Number
- CN202210917305.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-01
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2042-08-01
AI Technical Summary
In existing technologies, straight-line SplineMesh cannot be scaled smoothly, resulting in a mismatch between the SplineMesh length and the Spline trajectory.
By acquiring the start and end point data of the target straight line, the data of the straight line spline component is generated, and the component generation method is called in a loop to generate a scaled SplineMesh component, ensuring that the scaled SplineMesh component is consistent with the trajectory of the target straight line spline component.
The scalability of the straight line splinemesh is achieved, and the scaled splinemesh component follows the same trajectory as the target straight line spline component.
Smart Images

Figure CN115239562B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, specifically to a scaling method for a straight-line Spline track (SplineMesh). Technical Background
[0002] A spline component is a path that can be used to define and use position data. It allows characters or other components in a scene to move along a spline, or to place a series of characters or other components along a spline. These can be edited directly in the Blueprint viewport and level editor, including adding, deleting, and copying spline points, changing tangent types, and even implementing frame-by-frame animation.
[0003] SplineMesh is the SplineMeshComponent in Unreal Engine. It can scale and stretch a saved StaticMesh model to a specified shape based on component properties. Currently, straight-line SplineMesh generated by the Spline track tool cannot be scaled smoothly. Forcing a scaling operation will result in a mismatch between the SplineMesh length and the Spline track. Summary of the Invention
[0004] To address the aforementioned constraints and limitations, this invention proposes a scaling method for arc-straight line spline tracks (SplineMesh). A scaled SplineMesh component is generated from a scaled spline component of a target straight line spline component using a component generation method. This achieves the scaling operation of the straight line splineMesh, and the scaled SplineMesh component matches the trajectory of the target straight line spline component.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] Step 1: Obtain the start point data and end point data of the target straight line, and obtain the first line component data based on the start point data and end point data;
[0007] The starting point data is a starting point Actor object, and the ending point data is an ending point Actor object;
[0008] Step 2: Create a line implementation blueprint object and set the world position of the line implementation blueprint object to the world position of the starting point of the target line;
[0009] Step 3: Generate all point data of the straight line spline component according to the target scaling ratio to obtain the second straight line spline component data;
[0010] Step 4: Based on the data of the second straight spline component, the component generation method is called repeatedly to generate a straight spline mesh component; the straight spline mesh component is a scaled spline mesh component;
[0011] The specific implementation steps of the component generation method include:
[0012] S1. Create the SplineMesh component;
[0013] S2. Call the AddSplineMeshComponent method to obtain the first temporary SplineMesh component;
[0014] S3. Call the SetStaticMesh method of the first temporary SplineMesh component to set the component properties of the first temporary SplineMesh component and obtain the second temporary SplineMesh component;
[0015] S4. Call the SetStartAndEnd method of the second temporary SplineMesh component to set the start and end point properties of the second temporary SplineMesh component, obtain the generated SplineMesh component, and add the generated SplineMesh component to the SplineMesh component list.
[0016] Compared with the prior art, the scaling method for straight Spline tracks (SplineMesh) provided by this invention has the following advantages:
[0017] (1) A scalable SplineMesh was generated using a straight spline component;
[0018] (2) The scaled SplineMesh component has the same trajectory from the start point to the end point as the target straight spline component.
[0019] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described in detail below with reference to the accompanying drawings. Attached Figure Description
[0020] Figure 1 A flowchart illustrating a scaling method for a straight Spline track (SplineMesh) provided in an embodiment of the present invention.
[0021] Figure 2 A diagram showing the linear positional relationship provided for an embodiment of the present invention.
[0022] Figure 3 A flowchart illustrating the implementation steps of the AddSplineMesh component generation method provided in this embodiment of the invention. Detailed Implementation
[0023] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. To further understand the present invention, the present invention will be further described in detail below with reference to the preferred embodiments.
[0024] The following are explanations of the terms used in the embodiments of this invention:
[0025] Spline: Spline component, also known as SplineComponent in Unreal Engine.
[0026] SplineMesh: also known as SplineMeshComponent in Unreal Engine, it can scale and stretch a saved StaticMesh model into a specified shape according to the component's properties; its main properties are: Static Mesh and Spline Mesh.
[0027] Actor: A data type in Unreal Engine.
[0028] The implementation of this invention will be described in detail below, using the aforementioned terminology:
[0029] The inventive point of this invention is to provide a scaling method for a straight line spline track splinemesh, which is used to generate a scaled splinemesh component from a target straight line spline component through a component generation method;
[0030] refer to Figure 1 As shown, the method includes the following steps:
[0031] Step 1: Obtain the start point data and end point data of the target line; the start point data is a start point Actor object, and the end point data is an end point Actor object; obtain the first line component data based on the start point data and end point data;
[0032] Step 2: Create a line implementation blueprint object and set the world position of the line implementation blueprint object to the world position of the starting point of the target line;
[0033] Step 3: Generate all point data of the line spline component according to the target scaling ratio SplineMeshScale to obtain the second line spline component data;
[0034] Step 4: Based on the data of the second straight spline component, the component generation method is called repeatedly to generate a straight spline mesh component; the straight spline mesh component is a scaled spline mesh component.
[0035] As one embodiment, step 1 includes the following steps:
[0036] Step 11: Obtain the Actor objects for the starting point and ending point of the target line;
[0037] Step 12: Call the GetActorLocation method to obtain the world locations of the starting point Actor object and the ending point Actor object, thus obtaining the world location StartLocation and the world location EndLocation.
[0038] Step 13: Generate the first line component data based on the world location StartLocation and the world location EndLocation.
[0039] The GetActorLocation method is used to obtain the current world position of an Actor. The input parameter is the target Actor object, and the output value is the world position of the target Actor object. The world position is an FVector vector data type. In step 12, the target Actor object parameters are the start point Actor object and the end point Actor object, respectively, to obtain the start point world position StartLocation and the end point world position EndLocation.
[0040] As one embodiment, step 2 includes the following steps:
[0041] Step 21: Create a line to implement the blueprint object;
[0042] Step 22: Call the SetActorLocation method to set the world position of the line implementation blueprint object to the world position StartLocation of the starting point.
[0043] The SetActorLocation method is used to set the world location of an Actor. The input parameters include: target Actor, new location parameter, whether to stop when blocked (Sweep parameter), and whether to transfer physical state (Teleport parameter). When the SetActorLocation method is called in step 23, the target Actor is the default current Actor (i.e., the line implementation blueprint object), the new location parameter is the world location StartLocation, and both the Sweep and Teleport parameters are False.
[0044] As one embodiment, step 3 includes the following steps:
[0045] Step 31: Call the ClearSplinePoints method to clear all point data in the first straight spline component data and obtain the first temporary spline component data;
[0046] Step 32: Add the world location of the first point to the first temporary spline component data to obtain the second temporary spline component data; the world location of the first point is the world location StartLocation obtained in step 12 above;
[0047] Step 33: Add the world position of the second point to the second temporary spline component to obtain the data of the second straight spline component.
[0048] The world position of the second point in step 33 is obtained in the following way:
[0049] (1) Call the GetActorLocation method, pass in the Actor object of the end point of the target line, and get the world position EndLoaction of the end point;
[0050] (2) Calculate the line vector VectorLine from the starting point to the ending point. The calculation method is as follows:
[0051] VectorLine=EndLocation-StartLocation;
[0052] (3) Calculate the relative vector SecondVector based on the target scaling ratio SplineMeshScale. The calculation method is as follows:
[0053] SecondVector=VectorLine / SplineMeshScale;
[0054] (4) Calculate the world position SecondLocation of the second point based on the world position StartLocation and the relative vector SecondVector. The calculation method is as follows:
[0055] SecondLocation=StartLocation+SecondVectorThe positional relationship of StartLocation, EndLoaction, VectorLine, SecondVector and SecondLocation is as follows Figure 2 As shown.
[0056] The ClearSplinePoints method is used to clear all point data in the SplineComponent. The input parameters include: the target spline component object (SplineComponent type) and whether to update the state (boolean value). When the ClearSplinePoints method is called in step 31, the target spline component object parameter is the data of the first straight spline component, and the whether to update the state parameter is True.
[0057] Adding the world position of the first point to the first temporary spline component data and adding the world position of the second point to the second temporary spline component data are both implemented using the AddSplinePoint method;
[0058] The AddSplinePoint method is used to add point data to a SplineComponent. The parameters passed in include: the target spline component object (SplineComponent type), the point position (Fvector vector type), the coordinate space (enumerated value), and whether to update the state (boolean value).
[0059] In step 32, when adding the world position of the first point to the first temporary spline component data, the target spline component object parameter of the AddSplinePoint method is passed to the first temporary spline component data, the point position parameter is passed to the world position of the first point, the coordinate space parameter is passed to "World", and the status update parameter is passed to True;
[0060] In step 33, when adding the world position of the second point to the second temporary spline component data, the target spline component object parameter of the AddSplinePoint method is passed to the second temporary spline component data, the point position parameter is passed to the world position of the second point, the coordinate space parameter is passed to "World", and the status update parameter is passed to True.
[0061] As one embodiment, step 4 includes the following steps:
[0062] Step 41: Create a SplineMesh component list SplineMeshCompList and call the DestroyComponent method to clear the SplineMesh component list;
[0063] Step 42: Set the current loop count (Index), the loop start index (FirstIndex), and the loop end index (LastIndex); the specific setting method is as follows:
[0064] The current loop count (Index) is set to 1; the loop start index (FirstIndex) is set to 1; the loop end index (LastIndex) is set to the number of points in the second line spline component data minus 1; the number of points in the spline component data is obtained by calling the GetNumberOfSplinePoints method.
[0065] Step 43: Repeatedly call the component generation method AddSplineMesh until the current loop count equals the loop end index LastIndex, then end the loop to obtain the SplineMesh component.
[0066] As one embodiment, the component generation method AddSplineMesh is used to generate a SplineMesh component based on the start and end points of the target straight line or curve, and save the generated SplineMesh component to the SplineMesh component list.
[0067] The AddSplineMesh component generation method takes as input parameters a start point number (integer) and an end point number (integer), and returns the generated SplineMesh component.
[0068] In step 43, the start point number parameter of AddSplineMesh is passed as Index-1, and the end point number parameter is passed as Index; Index is the current loop count.
[0069] refer to Figure 3 As shown, the component generation method AddSplineMesh includes the following steps:
[0070] S1. Create the SplineMesh component;
[0071] S2. Call the AddSplineMeshComponent method to obtain the first temporary SplineMesh component, FirstLocalSplineMesh;
[0072] S3. Call the SetStaticMesh method of FirstLocalSplineMesh to set the component properties of the first temporary SplineMesh component and obtain the second temporary SplineMesh component SecondLocalSplineMesh;
[0073] S4. Call the SetStartAndEnd method of SecondLocalSplineMesh to set the start and end point properties of the second temporary SplineMesh component SecondLocalSplineMesh, obtain the generated SplineMesh component LocalSplineMesh, and add LocalSplineMesh to the SplineMesh component list.
[0074] The AddSplineMeshComponent method takes two arguments: ManualAttachment (whether to attach the component manually or automatically, a boolean value) and RelativeTransform (the component's position, rotation, and scaling information, a transformation matrix). RelativeTransform has three sub-parameters: Location (XYZ position), Rotation (Pitch, Raw, and Roll rotation), and Scale (XYZ scaling). The AddSplineMeshComponent method outputs a SplineMesh component.
[0075] In the AddSplineMeshComponent method of S2, the ManualAttachment parameter is passed as False; the Location parameter is passed as (0,0,0); the Rotation parameter is passed as (0,0,0); and the Scale parameter is passed as (SplineMeshScale,SplineMeshScale,SplineMeshScale), where SplineMeshScale is the target scaling ratio.
[0076] The SetStaticMesh method is used to set the static mesh model used by the SplineMesh component. The parameters passed in are the target SplineMesh component object and the static mesh model.
[0077] In S3, the target SplineMesh component object parameter of the SetStaticMesh method is passed as the first temporary SplineMesh component FirstLocalSplineMesh; the static mesh model parameter is passed as the preset static mesh model.
[0078] The SetStartAndEnd method is used to set the start and end point properties of the SplineMesh component. The input parameters include the target component object, the start point position, the start point tangent, the end point position, the end point tangent, and whether to update the component state.
[0079] Table 1 shows the parameters passed to the SetStartAndEnd method in S4.
[0080] Table 1. Parameter values passed to the SetStartAndEnd method
[0081] parameter Input value target component object SecondLocalSplineMesh Starting point position LocalStartLocation Starting point tangent LocalStartTangent End point position LocalEndLocation End point tangent LocalEndTangent Update component status? True
[0082] In Table 1, the calculation methods for LocalStartLocation, LocalStartTangent, LocalEndLocation, and LocalEndTangent are as follows:
[0083] Call the GetLocationAndTangentAtSplinePoint method. The target object parameter of this method is passed to the data of the second line spline component, the point number parameter is passed to the starting point number parameter of the component generation method, and the coordinate space parameter is passed to "Local". The output values obtained are LocalStartLocation and LocalStartTangent, respectively.
[0084] The GetLocationAndTangentAtSplinePoint method is called. The target object parameter of this method is the data of the second line spline component, the point number parameter is the end point number parameter of the component generation method, and the coordinate space parameter is "Local". The output values obtained are LocalEndLocation and LocalEndTangent, respectively.
[0085] As one embodiment, the method described in this invention can be implemented in software and / or a combination of software and hardware, for example, using an application-specific integrated circuit (ASIC), a general-purpose computer, or any other similar hardware device.
[0086] The method described in this invention can be implemented as a software program, which can be executed by a processor to achieve the steps or functions described above. Similarly, the software program (including associated data structures) can be stored in a computer-readable recording medium, such as RAM memory, magnetic or optical drives, floppy disks, and similar devices.
[0087] In addition, some steps or functions of the method described in this invention can be implemented in hardware, for example, as a circuit that works with a processor to perform the various steps or functions.
[0088] Furthermore, a portion of the methods described in this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to this application through the operation of the computer. The program instructions invoking the methods described in this invention can be stored in a fixed or removable recording medium, and / or transmitted via a data stream in a broadcast or other signal carrying medium, and / or stored in the working memory of a computer device operating according to the program instructions.
[0089] As one embodiment, the present invention also provides an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the apparatus is triggered to run a method and / or technical solution based on the foregoing plurality of embodiments.
[0090] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0091] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0092] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A scaling method of a straight Spline track SplineMesh, characterized in that, Step 1, obtaining starting point data and ending point data of a target straight line, obtaining starting point world position and ending point world position by calling a GetActorLocation method, and obtaining first spline component data according to the starting point data and the ending point data; The starting point data is a starting point Actor object, and the ending point data is an ending point Actor object; Step 2, creating a straight line implementation blueprint object, and calling a SetActorLocation method to set the world position of the straight line implementation blueprint object to the starting point world position of the target straight line; Step 3, generating all point data of the straight spline component according to a target scaling ratio to obtain second straight spline component data; Specifically comprising the following steps: Step 31, emptying all default point data in the first spline component data to obtain first temporary spline component data; Step 32, adding a first point world position to the first temporary spline component data to obtain second temporary spline component data; the first point world position is the starting point world position; Step 33, adding a second point world position to the second temporary spline component to obtain second straight spline component data; the second point world position is a position obtained by adding a relative vector obtained by dividing a straight line vector from the starting point to the ending point by the target scaling ratio to the starting point world position; Step 4, generating a straight SplineMesh component according to the second straight spline component data by cyclically calling a component generation method; the straight SplineMesh component is a scaled SplineMesh component.
2. The method of claim 1, characterized in that, The second point world position is obtained by the following method: (1) obtaining an ending point world position; (2) calculating a straight line vector from a starting point to an ending point, the calculation method being: VectorLine=EndLocation-StartLocation Wherein, VectorLine is the straight line vector, EndLocation is the ending point world position, and StartLocation is the starting point world position; (3) calculating a relative vector according to a target scaling ratio, the calculation method being: SecondVector= VectorLine / SplineMeshScale Wherein, SecondVector is the relative vector, VectorLine is the straight line vector, and SplineMeshScale is the target scaling ratio; (4) calculating a second point world position, the calculation method being: SecondLocation=StartLocation+SecondVector, Wherein, SecondLocation is the second point world position, StartLocation is the starting point world position, and SecondVector is the relative vector.
3. The method of claim 1, wherein, Step 4 comprises the following steps: Step 41, create a SplineMesh component list and empty the SplineMesh component list; Step 42, set the current loop number, loop start index, loop end index; Step 43, loop call component generation method until the current loop number is equal to the loop end index, and get a straight line SplineMesh component.
4. The method of claim 3, wherein, The specific setting method of the current loop number, loop start index and loop end index is: The current loop number is set to 1; The loop start index is set to 1; The loop end index is set to the number of point array elements of the second straight line spline component data minus 1; the number of point array elements is obtained by calling the GetNumberOfSplinePoints method.
5. The method of claim 1, wherein, The component generation method is used to generate a SplineMesh component according to the starting point and the ending point of the target straight line, and save the generated SplineMesh component to the SplineMesh component list.
6. The method of claim 1, wherein, The transmission parameter of the component generation method includes a start point serial number and an end point serial number; The specific implementation steps of the component generation method include: S1, create a SplineMesh component; S2, call the AddSplineMeshComponent method to obtain a first temporary SplineMesh component; S3, call the SetStaticMesh method of the first temporary SplineMesh component to set the component properties of the first temporary SplineMesh component, and obtain a second temporary SplineMesh component; S4, call the SetStartAndEnd method of the second temporary SplineMesh component to set the starting point and ending point properties of the second temporary SplineMesh component, obtain a generated SplineMesh component, and add the generated SplineMesh component to the SplineMesh component list.
7. The method of claim 6, wherein, The first temporary SplineMesh component includes three component properties of Location, Rotation and Scale; The Location property is set to (0, 0, 0), the Rotation property is set to (0, 0, 0), and the Scale property is set to (SplineMeshScale, SplineMeshScale, SplineMeshScale), wherein SplineMeshScale is the target scaling ratio.
8. The method of claim 6, wherein , The second temporary SplineMesh component includes two start point attributes of a start point position and a start point tangent and two end point attributes of an end point position and an end point tangent; The start point position is set as LocalStartLocation; The start point tangent attribute is set as LocalStartTangent; and the end point position attribute is set as LocalEndLocation; The end point tangent attribute is set as LocalEndTangent; The calculation method of LocalStartLocation, LocalStartTangent, LocalEndLocation and LocalEndTangent is as follows: The GetLocationAndTangentAtSplinePoint method is called, the second straight line spline component data and the start point serial number are input, and the output values obtained are respectively LocalStartLocation and LocalStartTangent; The GetLocationAndTangentAtSplinePoint method is called, the second straight line spline component data and the end point serial number are input, and the output values obtained are respectively LocalEndLocation and LocalEndTangent.
Citation Information
Patent Citations
Method and device for rendering spline line in game scene, and equipment
CN113827965A