Arch bridge generation method, arch bridge generation device, program product, and electronic device
By obtaining and offsetting the start and end points in the game to generate splines and placing the bridge deck model based on the spline, the problems of monotony and poor fusion of bridge models in the prior art are solved, and diversified arch bridge model generation and efficient rendering are achieved.
Patent Information
- Application Number
- CN202510527246.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-06-10
AI Technical Summary
It is difficult for the existing technology to generate diverse bridge models, especially in strategy or big world games. The traditional hand-swing model method cannot adapt to the needs of frequent data iterations, and the generated bridge models are often monotonous and cannot effectively integrate the bridge ends and terrain.
By obtaining the starting point and the end point and shifting the distance between them to obtain the bridge start point, the bridge end point, the bridge first inflection point and the bridge second inflection point, a target spline corresponding to the target arch bridge is generated. The bridge deck model is then placed based on the spline and batch rendering is performed to generate the arch bridge model.
A diversified arch bridge model was achieved, solving the problem of monotony of the bridge model and poor integration of the bridge ends with the terrain. At the same time, the rendering efficiency is improved through batch rendering and reducing performance pressure.
Smart Images

Figure CN120125772A_ABST
Abstract
Description
Background Art
[0002] In strategy games or large world games, bridges are abundant as connections for passable roads. When the number of required bridge models is large, the traditional method of manually placing models is not practical and cannot adapt to the frequent iteration of data.
[0003] To solve the above technical problems, a solution for generating a bridge model between a starting point and an ending point based on a spline is introduced in the related art, that is, a bridge model can be generated by only inputting the starting point and the ending point of the bridge. However, using this method can only achieve the effect of generating a relatively monotonous flat bridge, and it is impossible to achieve a good fusion between the ends of the bridge and the terrain. Summary of the Invention
[0004] The present disclosure provides a method for generating an arch bridge to at least to some extent solve the problems in the related art of monotonous bridge generation effect and the inability of the ends of the bridge to fuse with the terrain.
[0005] According to a first aspect of the present disclosure, there is provided a method for generating an arch bridge, the method comprising:
[0006] Obtain a starting point and an ending point, offset the starting point and the ending point by a first distance to obtain a bridge starting point and a bridge ending point, and offset the starting point and the ending point by a second distance to obtain a first bridge inflection point and a second bridge inflection point;
[0007] Generate a target spline corresponding to the target arch bridge according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point;
[0008] Obtain a bridge deck model, place the bridge deck model based on the target spline to obtain an arch bridge model, and perform batching rendering on the arch bridge model to obtain the target arch bridge.
[0009] According to a second aspect of the present disclosure, there is provided an arch bridge generation device, the device comprising:
[0010] A position determination module, configured to obtain a starting point and an ending point, offset the starting point and the ending point by a first distance to obtain a bridge starting point and a bridge ending point, and offset the starting point and the ending point by a second distance to obtain a first bridge inflection point and a second bridge inflection point;
[0011] A spline generation module, configured to generate a target spline corresponding to the target arch bridge according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point;
[0012] An arch bridge generation module, configured to obtain a bridge deck model, place the bridge deck model based on the target spline to obtain an arch bridge model, and perform batching rendering on the arch bridge model to obtain the target arch bridge.
[0013] According to a third aspect of the present disclosure, there is provided a computer program product including a computer program which, when executed by a processor, implements the method of the first aspect and its possible implementations as described above.
[0014] According to a fourth aspect of the present disclosure, there is provided an electronic device including: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method of the first aspect and its possible implementations by executing the executable instructions.
[0015] A method for generating an arch bridge provided by an embodiment of the present disclosure includes: obtaining a starting point and an ending point, offsetting the starting point and the ending point by a first distance to obtain a bridge starting point and a bridge ending point, offsetting the starting point and the ending point by a second distance to obtain a first bridge inflection point and a second bridge inflection point; generating a target spline corresponding to a target arch bridge according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point; obtaining a bridge deck model, placing the bridge deck model based on the target spline to obtain an arch bridge model, and performing batch rendering on the arch bridge model to obtain the target arch bridge. On the one hand, after obtaining the starting point and the ending point, offsetting the starting point and the ending point by a first distance to obtain the bridge starting point and the bridge ending point, and offsetting the starting point and the ending point by a second distance to obtain the positions of the first bridge inflection point and the second bridge inflection point, that is, interpolating between the starting point and the ending point, and generating a target spline according to the interpolation points, realizing different high and low trends of the spline, solving the problem in the related art that only a flat bridge can be generated, and realizing the fusion of the bridge end and the terrain through the interpolation points; on the other hand, after generating the target spline, placing the bridge deck model based on the target spline, generating an arch bridge model through the placed bridge deck model, and performing batch rendering on the bridge deck model in the arch bridge model, reducing the performance pressure and improving the rendering efficiency. Description of the Drawings
[0016] Figure 1 A schematic diagram showing a flat bridge generated in a related art in an exemplary embodiment of the present disclosure;
[0017] Figure 2 A flowchart showing a method for generating an arch bridge in an exemplary embodiment of the present disclosure;
[0018] Figure 3 A flowchart showing a method for offsetting the starting point and the ending point by a first distance to obtain a bridge starting point and a bridge ending point in an exemplary embodiment of the present disclosure;
[0019] Figure 4 A flowchart showing a method for offsetting the starting point and the ending point by a second distance to obtain a first bridge inflection point and a second bridge inflection point in an exemplary embodiment of the present disclosure;
[0020] Figure 5 Schematic diagram showing a bridge starting point, a bridge ending point, a first bridge inflection point, and a second bridge inflection point in this exemplary embodiment;
[0021] Figure 6 Schematic diagram showing a bridge starting point, a bridge ending point, a first bridge inflection point, and a second bridge inflection point in this exemplary embodiment;
[0022] Figure 7 Flowchart showing a method of placing the bridge deck model based on the target spline to obtain an arch bridge model in this exemplary embodiment;
[0023] Figure 8 Flowchart showing a method of placing the bridge deck model in each of the target segments to obtain the arch bridge model in this exemplary embodiment;
[0024] Figure 9 Flowchart showing a method of placing the bridge deck model in this exemplary embodiment;
[0025] Figure 10 Flowchart showing a method of determining the position of the bridge deck model according to the extended target segment and placing the bridge deck model according to the position of the bridge deck model in this exemplary embodiment;
[0026] Figure 11 Schematic diagram showing that the length of the last target segment is less than the length of the bridge deck model in this exemplary embodiment;
[0027] Figure 12 Schematic diagram showing a target arch bridge in this exemplary embodiment;
[0028] Figure 13 Schematic diagram showing an arch bridge generation device in this exemplary embodiment;
[0029] Figure 14 Schematic diagram showing the structure of an electronic device in this exemplary embodiment. Detailed implementation manners
[0030] The exemplary embodiments of the present disclosure will be described more comprehensively below with reference to the accompanying drawings.
[0031] The accompanying drawings are schematic illustrations of the present disclosure and are not necessarily drawn to scale. Some of the block diagrams shown in the accompanying drawings may be functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software form, or in hardware modules or integrated circuits, or in networks, processors, or microcontrollers. The embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein. The features, structures, or characteristics described in the present disclosure can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present disclosure. However, those skilled in the art should be aware that one or more of the specific details may be omitted when implementing the technical solutions of the present disclosure, or other methods, components, devices, steps, etc. may be used to replace one or more of the specific details.
[0032] In strategy games or large world games, bridges are abundant as connections for passable roads. When the number of bridge models required is large, the traditional method of manually placing models is not practical and cannot adapt to the frequent iteration of data.
[0033] To solve the above technical problems, a solution for generating a bridge model based on a spline between a starting point and an ending point was introduced in the related art, that is, a bridge model can be generated by simply inputting the starting point and the ending point of the bridge. However, using this method can only achieve the effect of generating a relatively monotonous flat bridge, as Figure 1 shown, and it is impossible to achieve a good fusion between the ends of the bridge and the terrain.
[0034] In view of the above problems, an exemplary embodiment of the present disclosure provides a method for generating an arch bridge. Referring to Figure 2 shown, the method for generating an arch bridge may include the following steps:
[0035] Step S210. Obtain a starting point and an ending point, offset the starting point and the ending point by a first distance to obtain a bridge starting point and a bridge ending point, and offset the starting point and the ending point by a second distance to obtain a first bridge inflection point and a second bridge inflection point;
[0036] Step S220. Generate a target spline corresponding to the target arch bridge according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point;
[0037] Step S230. Obtain a bridge deck model, place the bridge deck model based on the target spline to obtain an arch bridge model, and perform batch rendering on the arch bridge model to obtain the target arch bridge.
[0038] In the above arch bridge generation method, a starting point and an ending point are obtained, the starting point and the ending point are offset by a first distance to obtain a bridge starting point and a bridge ending point, and the starting point and the ending point are offset by a second distance to obtain a first bridge inflection point and a second bridge inflection point; according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point, a target spline corresponding to the target arch bridge is generated; a bridge deck model is obtained, the bridge deck model is placed based on the target spline to obtain an arch bridge model, and the arch bridge model is batch-rendered to obtain the target arch bridge. On the one hand, after the starting point and the ending point are obtained, the starting point and the ending point are offset by a first distance to obtain the bridge starting point and the bridge ending point, and the starting point and the ending point are offset by a second distance to obtain the positions of the first bridge inflection point and the second bridge inflection point. That is, interpolation is performed between the starting point and the ending point, and a target spline is generated according to the interpolation points, realizing different high and low trends of the spline, solving the problem in the related art that only a flat bridge can be generated, and realizing the fusion of the bridge end and the terrain through the interpolation points; on the other hand, after the target spline is generated, the bridge deck model is placed based on the target spline, an arch bridge model is generated through the placed bridge deck model, and the bridge deck model in the arch bridge model is batch-rendered, reducing the performance pressure and improving the rendering efficiency.
[0039] Hereinafter, steps S210 to S230 will be further explained and described.
[0040] In step S210, a starting point and an ending point are obtained, the starting point and the ending point are offset by a first distance to obtain a bridge starting point and a bridge ending point, and the starting point and the ending point are offset by a second distance to obtain a first bridge inflection point and a second bridge inflection point.
[0041] Among them, after the starting point and the ending point are obtained, interpolation points can be added between the starting point and the ending point. Specifically, the starting point and the ending point can be offset. The first offset distance can be the distance that the end is vertically pressed downwards, and the second distance can be the horizontal distance of the inflection point relative to the starting point and the ending point. The starting point can be represented as input_pos_0, and the ending point can be represented as input_pos_1.
[0042] In an exemplary embodiment, referring to Figure 3 as shown, the offsetting the starting point and the ending point by the first distance to obtain a bridge starting point and a bridge ending point includes:
[0043] Step S310. In world space, offset the starting point along the negative Z-axis by the first distance to obtain the bridge starting point of the target arch bridge;
[0044] Step S320. In world space, offset the ending point along the negative Z-axis by the first distance to obtain the bridge ending point of the target arch bridge.
[0045] Next, steps S310 and S320 will be further explained and described. Specifically, after obtaining the starting point Input_Pos_0 and the ending point Input_Pos_1, the starting point can be offset by a first distance Z_Bend_Distance along the negative Z-axis of the world space to obtain the bridge starting point Spline_Pt_0 of the target arch bridge. The bridge starting point can be expressed as Spline_Pt_0 = Input_Pos_0 - (0, 0, Z_Bend_Distance). After obtaining the bridge starting point of the target arch bridge, the type of the bridge starting point of the target arch bridge can also be set to Curve. The ending point can also be offset by the first distance Z_Bend_Distance along the negative Z-axis of the world space to obtain the bridge ending point Spline_Pt_3 of the target arch bridge. The bridge ending point of the target arch bridge can be expressed as Spline_Pt_3 = Input_Pos_1 - (0, 0, Z_Bend_Distance). After obtaining the bridge ending point of the target arch bridge, the type of the bridge ending point of the target arch bridge can also be set to Curve. The first distance Z_Bend_Distance for offsetting the starting point and the ending point can be determined according to the terrain parameters in the actual game scene, and no specific limitation is made on the first distance in this exemplary embodiment. In this embodiment, by offsetting the starting point and the ending point along the negative Z-axis of the world space by the first distance respectively, the effect of the bridge end pressing down is generated, so that the ends of the target arch bridge can be better integrated with the terrain.
[0046] In an exemplary embodiment, referring to Figure 4 as shown, the offsetting the starting point and the ending point by a second distance to obtain a first bridge inflection point and a second bridge inflection point includes:
[0047] Step S410. Obtain a first direction vector pointing from the starting point to the ending point, and a second direction vector pointing from the ending point to the starting point;
[0048] Step S420. Based on the first direction vector, offset the starting point by the second distance to obtain the first bridge inflection point of the target arch bridge;
[0049] Step S430. Based on the second direction vector, offset the ending point by the second distance to obtain the second bridge inflection point of the target arch bridge.
[0050] The following will further explain and illustrate steps S410 - S430. Specifically, the first inflection point and the second inflection point on the target arch bridge should be connected to the starting point Input_Pos_0 and the ending point Input_Pos_1 by a straight line to ensure that the character behaves correctly when walking on the bridge surface of the target arch bridge. Therefore, the starting point and the ending point can be offset respectively according to the first direction vector pointing from the starting point to the ending point and the second direction vector pointing from the ending point to the starting point. Among them, the first direction vector pointing from the starting point to the ending point can be expressed as V_Dir_1 = Normalize(Vector(Input_Pos_1) - Vector(Input_Pos_0)), and the second direction vector pointing from the ending point to the starting point can be expressed as V_Dir_2 = Normalize(Vector(Input_Pos_1) - Vector(Input_Pos_0)). After obtaining the first direction vector and the second direction vector, the starting point can be offset by a second distance based on the first direction vector to obtain the first inflection point of the target arch bridge, which can be expressed as: Spline_Pt_1 = Spline_Pt_0 + V_Dir_1 * Offset_Value, where Offset_Value is the second distance, which is the horizontal distance of the inflection point relative to the starting point and the ending point. This second distance can be equal to the length of the bridge deck model or greater than the length of the bridge deck model. In this exemplary embodiment, the length of the second distance is not specifically limited, and those skilled in the art can determine this second distance according to the actual size of the model. After obtaining the first inflection point of the bridge, the type of this first inflection point of the bridge can be set to Curve. Also, the ending point can be offset by a second distance based on the second direction vector to obtain the second inflection point of the target arch bridge, which can be expressed as: Spline_Pt_2 = Input_Pos_1 - V_Dir_2 * Offset_Value. Among them, Offset_Value is the second distance, which is the horizontal distance of the inflection point relative to the starting point and the ending point. This second distance can be equal to the length of the bridge deck model or greater than the length of the bridge deck model. In this exemplary embodiment, the length of the second distance is not specifically limited, and those skilled in the art can determine this second distance according to the actual size of the model. After obtaining the second inflection point of the bridge, the type of this second inflection point of the bridge can be set to Curve.
[0051] Exemplarily, through Figure 5 and Figure 6 further illustrate the starting point, the ending point, the starting point of the bridge, the ending point of the bridge, the first inflection point of the bridge and the second inflection point of the bridge. In Figure 5In it, the starting point input_pos_0 and the ending point input_pos_1 have the same height in the world space. By offsetting the starting point and the ending point along the negative Z-axis by Z_Bend_Distance, the bridge starting point Spline_Pt_0 and the bridge ending point Spline_Pt_3 are obtained, and the bridge starting point and the bridge ending point are at the same height in the world space. The starting point is offset by Offset_Value in the direction from the starting point to the ending point to obtain the first bridge inflection point Spline_Pt_1, and the ending point is offset by Offset_Value in the direction from the ending point to the starting point to obtain the second bridge inflection point Spline_Pt_2. The first bridge inflection point and the second bridge inflection point are also at the same height in the world space.
[0052] In Figure 6 it, the starting point input_pos_0 and the ending point input_pos_1 have different heights in the world space. By offsetting the starting point and the ending point along the negative Z-axis by Z_Bend_Distance, the bridge starting point Spline_Pt_0 and the bridge ending point Spline_Pt_3 are obtained, and the bridge starting point and the bridge ending point have different heights in the world space. The starting point is offset by Offset_Value in the direction from the starting point to the ending point to obtain the first bridge inflection point Spline_Pt_1, and the ending point is offset by Offset_Value in the direction from the ending point to the starting point to obtain the second bridge inflection point Spline_Pt_2. The first bridge inflection point and the second bridge inflection point also have different heights in the world space.
[0053] In step S220, according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point, a target spline corresponding to the target arch bridge is generated.
[0054] After obtaining the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point of the target arch bridge, a target spline corresponding to the target arch bridge can be generated in the UE blueprint based on these points.
[0055] In an exemplary embodiment, the generating a target spline corresponding to the target arch bridge according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point includes:
[0056] Obtain two default points in the spline, and modify the two default points to any two of the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point;
[0057] Add two points to the spline, and modify the added two points by using the remaining two points to obtain a target spline corresponding to the target arch bridge.
[0058] Specifically, a spline is already included in the bridge blueprint, and two default points are included in the spline. Therefore, in the bridge blueprint, any two of the bridge start point, bridge end point, first bridge inflection point, and second bridge inflection point can be used to modify the two default points in the spline. After the modification of the two default points included in the spline is completed, two points can be added to the spline, and the remaining two of the bridge start point, bridge end point, first bridge inflection point, and second bridge inflection point can be used to modify the newly added two points to obtain a target spline corresponding to the target arch bridge. Among them, the two default points in the spline can be modified through the Set Location at Spline Point node, and new points can be added to the spline through the Add Spline Point at Index node.
[0059] In step S230, a bridge deck model is obtained, the bridge deck model is placed based on the target spline to obtain an arch bridge model, and the arch bridge model is batch-rendered to obtain the target arch bridge.
[0060] Among them, after determining the four control points of the bridge start point, bridge end point, first bridge inflection point, and second bridge inflection point, and updating the spline according to the four control points to generate a target spline, the bridge deck model can be scattered along the target spline to obtain an arch bridge model. Specifically, a function named HISMSettings can be created, and the function can be used to implement the function of scattering the bridge deck model along the target spline.
[0061] In one exemplary embodiment, as shown in Figure 7 the placing of the bridge deck model based on the target spline to obtain an arch bridge model includes:
[0062] Step S710. Obtain the length of the target spline and the length of the bridge deck model, and divide the target spline into multiple target segments according to the length of the bridge deck model;
[0063] Step S720. Place the bridge deck model in each of the target segments to obtain the arch bridge model.
[0064] Next, steps S710 and S720 will be further explained and described. Specifically, the length of the target spline and the length of the bridge deck model are obtained, the length of the target spline is divided by the length of the bridge deck model, and the number of target segments included in the target spline is determined based on the obtained value. The value obtained by dividing the length of the target spline by the length of the bridge deck model can be an integer or not an integer. When it is an integer, it means that the lengths of each target segment among multiple target segments are equal. When it is not an integer, the value is rounded up, and the obtained numerical value is the number of target segments included in the target spline, and the length of the last target segment among multiple target segments is less than the length of the bridge deck model. When the length of the last target segment is less than the length of the bridge deck model, the length of the last target segment can be extended, and the bridge deck model is placed in the extended target segment to obtain the arch bridge model.
[0065] In an exemplary embodiment, referring to Figure 8 as shown, placing the bridge deck model in each of the target segments to obtain the arch bridge model includes:
[0066] Step S810. Determine the position of the bridge deck model according to the starting position and the ending position of the target segment;
[0067] Step S820. Determine the rotation angle of the bridge deck model according to the starting position and the ending position of the target segment, and place the bridge deck model according to the position and the rotation angle of the bridge deck model to obtain the arch bridge model.
[0068] The following will further explain and illustrate steps S810 and S820. Specifically, after determining the target segment, the world coordinates of the start point and end point of each target segment can be obtained through "get location at distance along spline", that is, the start position and end position of the target segment are obtained. For each target segment, in the target spline, the length between the start point of the target segment and the start point of the target spline is index * length, and the length between the end point of the target segment and the start point of the target spline is (index + 1) * length, where index is the serial number of the bridge deck model and length is the length of the bridge deck model. After obtaining the start position and end position of the target segment corresponding to the bridge deck model, the position of the bridge deck model can be determined according to the start position and end position of the target segment. The position of the bridge deck model in the target spline is at the average value of the start position and the end position; among them, the obtained position of the bridge deck model is the position of the center point of the bridge deck model in the world space. After determining the position of the bridge deck model, the rotation angle of the bridge deck model can also be determined according to the start point and end point of the target segment. After determining the rotation angle, the bridge deck model can be placed according to the position and rotation angle of the bridge deck model to obtain the arch bridge model.
[0069] In an exemplary embodiment, the determining the rotation angle of the bridge deck model according to the start position and end position of the target segment includes:
[0070] Obtaining the rotation vector of the bridge deck model according to the start position and end position of the target segment;
[0071] Determining the rotation angle of the bridge deck model according to the rotation vector.
[0072] Specifically, subtracting the start position of the target segment from the end position of the target segment to obtain the rotation vector of the bridge deck model. After obtaining the rotation vector, use the "To Quaternion" node to calculate the rotation angle that the bridge deck model needs to rotate to the direction of this rotation vector.
[0073] In an exemplary embodiment, after obtaining the position and rotation angle of the bridge deck model, the bridge deck model can be added to the HIS called Bridge_HISM through the addinstance node. HIS is the abbreviation of Hierarchical Instanced Static Mesh. In game development and Unreal Engine, HIS is a function that can efficiently render and manage a large number of static mesh instances. Through HIS, multiple instances of the same static mesh can be efficiently rendered with a single draw call, thereby reducing processing overhead and improving performance. The static mesh of Bridge_HISM is the static mesh of the bridge deck model.
[0074] In an exemplary embodiment, when the length of the last target segment of the target spline is less than the length of the bridge deck model, refer to Figure 9 as shown, placing the bridge deck model includes:
[0075] Step S910. Determine the extension length according to the length of the bridge deck model and the length of the last target segment;
[0076] Step S920. Obtain the position of the bridge end point and the starting position of the last target segment, and determine the extension direction;
[0077] Step S930. Extend the last target segment of the target spline according to the extension length and the extension direction, determine the position of the bridge deck model according to the extended target segment, and place the bridge deck model according to the position of the bridge deck model.
[0078] Hereinafter, steps S910 - S930 will be further explained and described. Specifically, when the length of the last target segment of the target spline is less than the length of the bridge deck model, it is necessary to extend the length of the last target segment so that the length of the extended bridge deck model is equal to the length of the bridge deck model. Among them, the extension length can be determined according to the difference between the length of the bridge deck model and the length of the last target segment, and the extension direction can also be determined according to the end position and the starting position of the last target segment. Specifically, the end position of the last target segment can be subtracted from the starting position of the last target segment to obtain a direction vector, and the extension direction can be determined according to this direction vector. After determining the extension length and the extension direction, the length of the last target segment is extended, and the position of the bridge deck model is determined according to the extended target segment, and the bridge deck model is placed according to the position of the bridge deck model.
[0079] In an exemplary embodiment, refer to Figure 10As shown, determining the position of the bridge deck model according to the extended target segment and placing the bridge deck model according to the position of the bridge deck model includes:
[0080] Step S1010. Obtain the extended end position of the extended target segment, and determine the position of the bridge deck model according to the extended end position and the starting position of the last target segment;
[0081] Step S1020. Determine the rotation vector of the bridge deck model according to the extended end position and the starting position of the last target segment;
[0082] Step S1030. Determine the rotation angle of the bridge deck model according to the rotation vector, and place the bridge deck model according to the position and the rotation angle of the bridge deck model.
[0083] Hereinafter, steps S1010 - S1030 will be further explained and described. Specifically, obtain the extended end position of the extended target segment, obtain the midpoint position between the extended end position and the starting position of the last target segment, and determine this midpoint position as the position of the bridge deck model. It is also possible to determine the rotation vector of the bridge deck model according to the extended end position and the starting position of the last target segment. Specifically, subtract the starting position of the last target segment from the extended end position, and the resulting vector is the rotation vector. After obtaining the rotation vector, use the To Quaternion node to calculate the rotation angle by which the front panel model should rotate to this rotation vector. After obtaining the position and rotation angle of the bridge deck model, place the last bridge deck model according to the position and rotation angle of this bridge deck model to obtain the arch bridge model.
[0084] Exemplarily, when the length of the target spline is 12, the length between the bridge starting point and the first inflection point of the bridge is 2, and the length of the bridge deck model is 2, first, the target spline can be divided into 6 target segments by using the length of the bridge deck model, and the length of each target segment in the 6 target segments is equal to the length of the bridge deck model. For each of the 6 target segments, the length between the starting point of each target segment and the starting point of the target spline is index * 2, and the length between the ending point of the target segment and the starting point of the target spline is (index + 1) * 2, where index is the serial number of the bridge deck model. After determining the target segment corresponding to the bridge deck model, the starting point position and the ending point position of the target segment where each bridge deck model is located are obtained through the get location at distance along spline node, the position of the point in the middle of the starting point position and the ending point position is determined as the position of the bridge deck model, and the rotation vector of the bridge deck model is obtained by subtracting the starting point position from the ending point position of the target segment. The rotation angle corresponding to the rotation vector is obtained by using To Quaternion, and the bridge deck model is placed according to the position and rotation angle of the bridge deck model.
[0085] Exemplarily, referring to Figure 11As shown, the upper line is the target spline, and the line below the target spline is the generated arch bridge model. When the length of the target spline is 11, the length between the starting point of the bridge and the first inflection point of the bridge is 3, and the length of the bridge deck model is 2, first, the target spline can be divided into 6 target segments by using the length of the bridge deck model. Among these 6 target segments, the lengths of the first 5 target segments are equal to the length of the bridge deck model, and the length of the last target segment is 1, which is less than the length of the bridge deck model. For the 5 target segments, the length between the starting point of each target segment and the starting point of the target spline is index * 2, and the length between the ending point of the target segment and the starting point of the target spline is (index + 1) * 2, where index is the serial number of the bridge deck model. After determining the target segment corresponding to the bridge deck model, the starting position and the ending position of each of the first 5 target segments are obtained through the get location at distancealong spline node. The position of the point in the middle of the starting position and the ending position is determined as the position of the bridge deck model, and the rotation vector of the bridge deck model is obtained by subtracting the starting position from the ending position of the target segment. The rotation angle corresponding to the rotation vector is obtained by using To Quaternion. The bridge deck model is placed according to the position and the rotation angle of the bridge deck model. For the last target segment, since the length of this target segment is 1, which is less than the length of the bridge deck model, therefore, it is necessary to extend the length of this target segment. When extending this last target segment, the extending direction is determined according to the ending position and the starting position of this last target segment, and this last target segment is extended by 1 according to the extending direction, so that the length of the last target segment is equal to the length of the bridge deck model. After extending the last target segment, the position and the rotation angle of the bridge deck model are determined according to the extended ending position and the starting position of the last target segment, and the bridge deck model is placed according to this position and the rotation angle.
[0086] In an exemplary embodiment, after obtaining the target arch bridge, the bridge deck models included in the target arch bridge are all stored in Bridge_HISM. Therefore, the bridge deck models in Bridge_HISM can be batched and rendered to obtain the target arch bridge. By batching and rendering the bridge deck models, the number of draw calls is reduced, and the rendering performance is improved. The rendered target arch bridge can be referred to Figure 12 as shown.
[0087] The arch bridge generation method provided by the exemplary embodiments of the present disclosure has at least the following advantages: On the one hand, after obtaining the starting point and the ending point, the starting point and the ending point are offset by a first distance to obtain the bridge starting point and the bridge ending point, and the starting point and the ending point are offset by a second distance to obtain the first inflection point position and the second inflection point position of the bridge. That is, interpolation is performed between the starting point and the ending point, and a target spline is generated according to the interpolation points, realizing different high and low trends of the spline, solving the problem in the related art that only a flat bridge can be generated, and realizing the fusion of the bridge end and the terrain through the interpolation points. On the other hand, after generating the target spline, a bridge deck model is placed based on the target spline, an arch bridge model is generated through the placed bridge deck model, and the bridge deck models in the arch bridge model are batched and rendered, reducing the performance pressure and improving the rendering efficiency.
[0088] The exemplary embodiments of the present disclosure also provide an arch bridge generation device. Refer to Figure 13 As shown, the arch bridge generation device includes the following:
[0089] A position determination module 1310, configured to obtain a starting point and an ending point, offset the starting point and the ending point by a first distance to obtain a bridge starting point and a bridge ending point, and offset the starting point and the ending point by a second distance to obtain a first inflection point and a second inflection point of the bridge;
[0090] A spline generation module 1320, configured to generate a target spline corresponding to the target arch bridge according to the bridge starting point, the bridge ending point, the first inflection point, and the second inflection point of the bridge;
[0091] An arch bridge generation module 1330, configured to obtain a bridge deck model, place the bridge deck model based on the target spline to obtain an arch bridge model, and batch-render the arch bridge model to obtain the target arch bridge.
[0092] In an exemplary embodiment, the position determination module includes:
[0093] A bridge starting point determination module, configured to offset the starting point in the negative Z-axis direction by the first distance in the world space to obtain the bridge starting point of the target arch bridge;
[0094] A bridge ending point determination module, configured to offset the ending point in the negative Z-axis direction by the first distance in the world space to obtain the bridge ending point of the target arch bridge.
[0095] In an exemplary embodiment, the position determination module includes:
[0096] An offset vector determination module, configured to obtain a first direction vector pointing from the starting point to the ending point and a second direction vector pointing from the ending point to the starting point;
[0097] The first bridge inflection point determination module is configured to offset the starting point by the second distance based on the first direction vector to obtain the first bridge inflection point of the target arch bridge;
[0098] The second bridge inflection point determination module is configured to offset the ending point by the second distance based on the second direction vector to obtain the second bridge inflection point of the target arch bridge.
[0099] In an exemplary embodiment, the spline generation module includes:
[0100] The default point modification module is configured to obtain two default points in the spline and modify the two default points to any two points among the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point;
[0101] The point addition module is configured to add two points to the spline and modify the added two points using the remaining two points to obtain a target spline corresponding to the target arch bridge.
[0102] In an exemplary embodiment, the arch bridge generation module includes:
[0103] The target segment determination module is configured to obtain the length of the target spline and the length of the bridge deck model, and divide the target spline into multiple target segments according to the length of the bridge deck model;
[0104] The bridge deck model placement module is configured to place the bridge deck model in each target segment to obtain the arch bridge model.
[0105] In an exemplary embodiment, the bridge deck model placement module includes:
[0106] The placement position determination module is configured to determine the position of the bridge deck model according to the starting position and the ending position of the target segment;
[0107] The placement module is configured to determine the rotation angle of the bridge deck model according to the starting position and the ending position of the target segment, and place the bridge deck model according to the position and the rotation angle of the bridge deck model to obtain the arch bridge model.
[0108] In an exemplary embodiment, the placement module includes:
[0109] The rotation vector determination module is configured to obtain the rotation vector of the bridge deck model according to the starting position and the ending position of the target segment;
[0110] The rotation angle determination module is configured to determine the rotation angle of the bridge deck model according to the rotation vector.
[0111] In an exemplary embodiment, when the length of the last target segment of the target spline is less than the length of the bridge deck model, the arch bridge generation module includes:
[0112] An extension length determination module, configured to determine an extension length according to the length of the bridge deck model and the length of the last target segment;
[0113] An extension direction determination module, configured to obtain the position of the bridge end point and the starting position of the last target segment, and determine the extension direction;
[0114] A target segment extension module, configured to extend the last target segment of the target spline according to the extension length and the extension direction, determine the position of the bridge deck model according to the extended target segment, and place the bridge deck model according to the position of the bridge deck model.
[0115] In an exemplary embodiment, the target segment extension module includes:
[0116] A position determination module, configured to obtain the extension end position of the extended target segment, and determine the position of the bridge deck model according to the extension end position and the starting position of the last target segment;
[0117] A rotation direction determination module, configured to determine the rotation vector of the bridge deck model according to the extension end position and the starting position of the last target segment;
[0118] An extended segment placement module, configured to determine the rotation angle of the bridge deck model according to the rotation vector, and place the bridge deck model according to the position of the bridge deck model and the rotation angle.
[0119] The specific details of each part in the above device have been described in detail in the implementation manner of the method part. The details not disclosed can be referred to the implementation manner content of the method part, and thus will not be repeated.
[0120] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the exemplary embodiments of the present disclosure, the features and functions of the two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0121] In addition, although the steps of the methods in the present invention are described in a specific order in the accompanying drawings, this does not require or imply that these steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.
[0122] In an exemplary embodiment of the present invention, an electronic device capable of implementing the above method is also provided.
[0123] Those skilled in the art can understand that various aspects of the present invention can be implemented as a system, a method, or a program product. Therefore, various aspects of the present invention can be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or an implementation combining hardware and software aspects, which can be collectively referred to herein as "circuitry", "module", or "system".
[0124] The following refers to Figure 14 to describe the electronic device 1400 according to this embodiment of the present invention. Figure 14 The electronic device 1400 shown is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present invention.
[0125] As Figure 14 shown, the electronic device 1400 is presented in the form of a general-purpose computing device. The components of the electronic device 1400 may include, but are not limited to: at least one of the above-mentioned processing units 1410, at least one of the above-mentioned storage units 1420, a bus 1430 connecting different system components (including the storage unit 1420 and the processing unit 1410), and a display unit 1440.
[0126] Among them, the storage unit stores program code, and the program code can be executed by the processing unit 1410, so that the processing unit 1410 executes the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification. For example, the processing unit 1410 can execute steps S210 shown in Figure 2 : Obtain a starting point and an ending point, offset the starting point and the ending point by a first distance to obtain a bridge starting point and a bridge ending point, offset the starting point and the ending point by a second distance to obtain a first bridge inflection point and a second bridge inflection point; S220: Generate a target spline corresponding to the target arch bridge according to the bridge starting point, the bridge ending point, the first bridge inflection point, and the second bridge inflection point; S230: Obtain a bridge deck model, place the bridge deck model based on the target spline to obtain an arch bridge model, and perform batch rendering on the arch bridge model to obtain the target arch bridge.
[0127] The storage unit 1420 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 14201 and / or a cache storage unit 14202, and may further include a read-only storage unit (ROM) 14203.
[0128] The storage unit 1420 may also include a program / utility 14204 having a set (at least one) of program modules 14205. Such program modules 14205 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment.
[0129] The bus 1430 may represent one or more of several types of bus structures, including a storage unit bus or storage unit controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of a variety of bus structures.
[0130] The electronic device 1400 may also communicate with one or more external devices 1500 (such as a keyboard, a pointing device, a Bluetooth device, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1400, and / or may communicate with any device that enables the electronic device 1400 to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication may be carried out through an input / output (I / O) interface 1450. Also, the electronic device 1400 may communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 1460. As shown in the figure, the network adapter 1360 communicates with other modules of the electronic device 1400 through the bus 1430. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID (Redundant Arrays of Independent Disks) systems, tape drives, and data backup storage systems, etc.
[0131] Through the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described herein can be implemented by software or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (such as a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present invention.
[0132] In an exemplary embodiment of the present invention, there is also provided a computer-readable storage medium having stored thereon a program product capable of implementing the above-described method of this specification. In some possible embodiments, various aspects of the present invention can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification.
[0133] The program product for implementing the above method according to the embodiments of the present invention can be a portable compact disc read-only memory (CD-ROM) and includes program code, and can run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0134] The program product can adopt any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium can, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0135] A computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which readable program code is carried. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The readable signal medium may also be any readable medium other than a readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.
[0136] The program code contained on the readable medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF (Radio Frequency), etc., or any suitable combination of the foregoing.
[0137] The program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., by using an Internet service provider to connect through the Internet).
[0138] In addition, the above drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present invention, and are not for limiting purposes. It is easy to understand that the processes shown in the above drawings do not indicate or limit the chronological order of these processes. Additionally, it is also easy to understand that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0139] Those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention herein. This application is intended to cover any variations, uses, or adaptations of the present invention, which follow the general principles of the present invention and include well-known knowledge or conventional technical means in the technical field not invented by the present invention. The specification and embodiments are only to be regarded as exemplary, and the true scope and spirit of the present invention are pointed out by the claims.
Claims
1. A method for generating an arch bridge, characterized in that: include: Obtain a starting point and an end point, offset the starting point and the end point by a first distance to obtain a bridge starting point and a bridge end point, offset the starting point and the end point by a second distance to obtain a bridge first inflection point and a bridge second inflection point; Generate a target spline corresponding to a target arch bridge according to the starting point of the bridge, the end point of the bridge, the first inflection point of the bridge, and the second inflection point of the bridge; A bridge deck model is obtained, and the bridge deck model is placed based on the target spline to obtain an arch bridge model. The arch bridge model is batch rendered to obtain the target arch bridge.
2. The method according to claim 1, characterized in that The offsetting the starting point and the end point by a first distance to obtain a bridge starting point and a bridge end point comprises: In the world space, the starting point is offset by the first distance along the negative direction of the Z axis to obtain the starting point of the target arch bridge; In the world space, the end point is offset by the first distance along the negative direction of the Z axis to obtain a bridge end point corresponding to the target arch bridge.
3. The method according to claim 1, characterized in that: The offsetting the starting point and the end point by a second distance to obtain a first inflection point of the bridge and a second inflection point of the bridge comprises: Obtain a first direction vector pointing from the starting point to the end point, and a second direction vector pointing from the end point to the starting point; Based on the first direction vector, the starting point is offset by the second distance to obtain a first inflection point of the target arch bridge; Based on the second direction vector, the end point is offset by the second distance to obtain a second inflection point of the target arch bridge.
4. The method according to claim 1, characterized in that: The step of generating a target spline corresponding to a target arch bridge according to the bridge starting point, the bridge end point, the bridge first inflection point, and the bridge second inflection point comprises: Obtain two default points in the spline, and modify the two default points to any two points among the starting point of the bridge, the end point of the bridge, the first inflection point of the bridge, and the second inflection point of the bridge; Two points are added to the spline, and the remaining two points are used to modify the two added points to obtain a target spline corresponding to the target arch bridge.
5. The method according to claim 1, characterized in that Placing the bridge deck model based on the target spline to obtain an arch bridge model includes: Acquire the length of the target spline and the length of the bridge deck model, and divide the target spline into a plurality of target segments according to the length of the bridge deck model; The bridge deck model is placed in each of the target segments to obtain the arch bridge model.
6. The method according to claim 5, characterized in that Placing the bridge deck model in each target segment to obtain the arch bridge model comprises: Determining the position of the bridge deck model according to the starting position and the ending position of the target segment; The rotation angle of the bridge deck model is determined according to the starting position and the end position of the target segment, and the bridge deck model is placed according to the position of the bridge deck model and the rotation angle to obtain the arch bridge model.
7. The method according to claim 6, characterized in that Determining the rotation angle of the bridge deck model according to the starting position and the ending position of the target segment includes: Obtaining a rotation vector of the bridge deck model according to the starting position and the ending position of the target segment; The rotation angle of the bridge deck model is determined according to the rotation vector.
8. The method according to claim 5, characterized in that When the length of the last target segment of the target spline is less than the length of the bridge deck model, placing the bridge deck model includes: Determine the extension length according to the length of the bridge deck model and the length of the last target segment; Obtaining the position of the end point of the bridge and the starting point of the last target segment to determine the extension direction; According to the extension length and the extension direction, the last target segment of the target spline is extended, the position of the bridge deck model is determined according to the extended target segment, and the bridge deck model is placed according to the position of the bridge deck model.
9. The method according to claim 8, characterized in that The step of determining the position of the bridge deck model according to the extended target segment, and placing the bridge deck model according to the position of the bridge deck model comprises: Acquire the extension end position of the extended target segment, and determine the position of the bridge deck model according to the extension end position and the starting position of the last target segment; Determining a rotation vector of the bridge deck model according to the extension end position and the starting position of the last target segment; The rotation angle of the bridge deck model is determined according to the rotation vector, and the bridge deck model is placed according to the position of the bridge deck model and the rotation angle.
10. An arch bridge generating device, characterized in that: include: A position determination module is used to obtain a starting point and an end point, offset the starting point and the end point by a first distance to obtain a bridge starting point and a bridge end point, and offset the starting point and the end point by a second distance to obtain a bridge first inflection point and a bridge second inflection point; A spline generation module, used for generating a target spline corresponding to a target arch bridge according to the starting point of the bridge, the end point of the bridge, the first inflection point of the bridge, and the second inflection point of the bridge; The arch bridge generation module is used to obtain a bridge deck model, place the bridge deck model based on the target spline to obtain an arch bridge model, and batch render the arch bridge model to obtain the target arch bridge.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
12. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 9 by executing the executable instructions.