Model processing method and device, storage medium and electronic equipment
By performing ray collision detection in virtual scenes, the position of the guardrail model and the air wall is automatically adjusted, which solves the problem of low manual adjustment efficiency in the existing technology, and achieves more efficient model processing.
Patent Information
- Application Number
- CN202411654963.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-03-11
AI Technical Summary
The existing guardrail model has low fitting efficiency with air walls and requires manual adjustment to achieve fit, resulting in inefficiency.
By obtaining the coordinates of the target object model in the virtual scene, determining the starting point of the ray detection, and performing ray collision detection, determining the collision point of the reference model, thereby realizing the automatic fit and placement of the target object model and the reference model.
The fitting and placement efficiency of guardrail model and air wall is improved, and the overall efficiency of model processing is improved.
Smart Images

Figure CN119600197A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a model processing method, device, storage medium and electronic device. Background Art
[0002] With the rapid development of life and technology, people often use game applications for entertainment. In some games, it is usually necessary to set up air walls on the side of the road to ensure that players follow the established route and prevent players from deviating from the designated game area. Since the air wall is invisible to the player, in order to avoid affecting the player's gaming experience, the road guardrail model needs to be placed as close to the air wall as possible.
[0003] In the process of research and practice of existing technologies, it was found that the existing model processing method for fitting the guardrail model and the air wall often relies on human visual observation and judgment of the degree of fit between the guardrail model, the air wall model and the ground, and manually adjusting the guardrail model to make it fit the air wall and the ground, which makes the efficiency of placing the guardrail model in line with the air wall poor, thereby resulting in low model processing efficiency. Summary of the invention
[0004] The embodiments of the present application provide a model processing method, device, storage medium and electronic device, which can realize automatic fitting and placement of a target object model and a reference model, improve the efficiency of placing the target object model in line with the reference model, and thus improve the model processing efficiency.
[0005] The present application embodiment provides a model processing method, including:
[0006] Acquire a first coordinate of at least one target object model in a virtual scene;
[0007] Based on the first coordinates, determining a first ray detection starting point corresponding to the target object model;
[0008] Performing ray collision detection in the virtual scene based on the first ray detection starting point to determine a first collision point between the reference model of the virtual scene and the ray;
[0009] Based on the first collision point, the target object model is placed in alignment with the reference model.
[0010] Accordingly, an embodiment of the present application provides a model processing device, including:
[0011] A coordinate acquisition unit, used to acquire a first coordinate of at least one target object model in a virtual scene;
[0012] A first determining unit, configured to determine a first ray detection starting point corresponding to the target object model based on the first coordinate;
[0013] A second determining unit, configured to perform ray collision detection in the virtual scene based on the first ray detection starting point, and determine a first collision point between the reference model of the virtual scene and the ray;
[0014] A fitting and placement unit is used to fit the target object model to the reference model for placement based on the first collision point.
[0015] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and the computer program is suitable for loading by a processor to execute the steps in any model processing method provided in the embodiment of the present application.
[0016] In addition, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores an application, and the processor is used to run the application in the memory to implement the model processing method provided in the embodiment of the present application.
[0017] An embodiment of the present application also provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps in the model processing method provided in the embodiment of the present application.
[0018] The embodiment of the present application obtains the first coordinate of at least one target object model in the virtual scene; based on the first coordinate, determines the first ray detection starting point corresponding to the target object model; based on the first ray detection starting point, performs ray collision detection in the virtual scene to determine the first collision point between the reference model of the virtual scene and the ray; based on the first collision point, places the target object model in line with the reference model. In this way, by determining the first ray detection starting point corresponding to the target object model, and performing ray collision detection in the virtual scene according to the first ray detection starting point, the first collision point between the ray emitted by the first ray detection starting point and the reference model placed in the virtual scene is determined, and thus, according to the first collision point, the target object model is placed in line with the reference model, thereby achieving automatic fitting and placement of the target object model and the reference model, improving the efficiency of placing the target object model in line with the reference model, and further improving the model processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 It is a schematic diagram of an implementation scenario of a model processing method provided in an embodiment of the present application;
[0021] Figure 2 It is a flow chart of a model processing method provided in an embodiment of the present application;
[0022] Figure 3a It is a schematic diagram of a target object model of a model processing method provided in an embodiment of the present application;
[0023] Figure 3b It is a schematic diagram of model placement of a model processing method provided in an embodiment of the present application;
[0024] Figure 3c It is a simplified schematic diagram of model placement of a model processing method provided in an embodiment of the present application;
[0025] Figure 3d It is a reference model schematic diagram of a model processing method provided in an embodiment of the present application;
[0026] Figure 3e It is a schematic diagram of the fitting and placement of a model processing method provided in an embodiment of the present application;
[0027] Figure 4a It is another schematic diagram of fitting and placement of a model processing method provided in an embodiment of the present application;
[0028] Figure 4b It is a rotation placement schematic diagram of a model processing method provided in an embodiment of the present application;
[0029] Figure 4c It is a schematic diagram of continuity correction of a model processing method provided in an embodiment of the present application;
[0030] Figure 4d It is a schematic diagram of model fitting and placement of a model processing method provided in an embodiment of the present application;
[0031] Figure 4e It is another schematic diagram of model fitting and placement of a model processing method provided in an embodiment of the present application;
[0032] Figure 4f It is a ground fitting schematic diagram of a model processing method provided in an embodiment of the present application;
[0033] Figure 4g This is a data transmission relationship diagram of a model processing method provided in an embodiment of the present application;
[0034] Figure 5 is a structural schematic diagram of a model processing device provided in an embodiment of the present application;
[0035] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0037] The embodiment of the present application provides a model processing method, device, storage medium and electronic device. The model processing device can be integrated in an electronic device, which can be a server, a terminal or other device.
[0038] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals may include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Terminals and servers can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.
[0039] See also Figure 1 , taking the integration of the model processing device into an electronic device as an example, Figure 1 A schematic diagram of an implementation scenario of the model processing method provided in an embodiment of the present application, wherein the electronic device can be a terminal or a server, and the electronic device can obtain a first coordinate of at least one target object model in a virtual scene; based on the first coordinate, determine a first ray detection starting point corresponding to the target object model; based on the first ray detection starting point, perform ray collision detection in the virtual scene to determine a first collision point between a reference model of the virtual scene and the ray; based on the first collision point, place the target object model in alignment with the reference model.
[0040] It should be noted that Figure 1 The implementation environment scenario diagram of the model processing method shown is only an example. The implementation environment scenario of the model processing method described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0041] The solutions provided by the embodiments of the present application are specifically described by the following embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0042] This embodiment will be described from the perspective of a model processing device. The model processing device may be integrated into an electronic device. The electronic device may be a terminal and / or a server, and this application does not limit this.
[0043] See also Figure 2 , Figure 2 : is a flow chart of the model processing method provided in the embodiment of the present application. The model processing method includes:
[0044] In step 101, first coordinates of at least one target object model in a virtual scene are obtained.
[0045] The virtual scene may be a simulation environment of the real world, or a semi-simulation and semi-fictional virtual environment, or a purely fictional virtual environment, etc. The target object model may be a three-dimensional model placed in the virtual scene, for example, a guardrail model placed along the road, or a stone model or a vegetation model to be placed against a wall or a curb, etc. The first coordinate may be a world coordinate of the target object model.
[0046] For example, taking the target object model as a guardrail model, please refer to Figure 3a , Figure 3a It is a schematic diagram of a target object model of a model processing method provided in an embodiment of the present application. A corresponding local coordinate system may be set on the target object model, that is, the model coordinate system of the target object model. The origin of the local coordinate system may be on the target object model, for example, it may be at the lower left corner of the target object model, wherein the Y-axis in the local coordinate system may be defined as the front direction of the guardrail model, that is, the direction pointed by the green arrow, the X-axis in the local coordinate system may be defined as the left direction of the guardrail model, that is, the direction pointed by the red arrow, and the Z-axis in the local coordinate system may be defined as the upward direction of the guardrail model, that is, the direction pointed by the blue arrow.
[0047] In step 102, based on the first coordinate, a first ray detection starting point corresponding to the target object model is determined.
[0048] The first ray detection starting point may be the starting point for ray collision detection in the target object model, that is, the position in the target object model for emitting rays, which may be used to detect the position of the reference model in the virtual scene. The reference model may be a model that the target object model needs to fit, for example, the reference model may be an air wall, a wall, or other models.
[0049] There are many ways to determine the starting point of the first ray detection corresponding to the target object model based on the first coordinate. For example, in order to avoid the situation where the bottom of the target object model is close to the bottom of the reference model, the ray collision detection may be missed due to the existence of floating point errors, and the position of the reference model may not be detected, the height of the target object model may be obtained, and the first coordinate may be adjusted according to the height of the target object model to obtain the coordinate of the starting point of the first ray detection. For example, the first coordinate may be offset by half the height along the z-axis direction as the coordinate of the starting point of the first ray detection for ray collision detection, which is recorded as (Xs, Ys, Zs), that is,
[0050]
[0051] Among them, (Xi, Yi, Zi) represents the first coordinate, Hi represents the height of the target object model, Represents the direction vector of the z-axis in the local coordinate system of the target object model.
[0052] In a specific embodiment, the position acquisition function (GetWorldLocation) can be used to obtain the world coordinates of the target object model, that is, the first coordinate, the size acquisition function (GetLocalBounds*RelativeScale3D) can be used to obtain the real size (height, thickness, length) of the target object model, and the direction acquisition function (GetForwardVector) can be used to obtain the direction vector of the z-axis of the target object model in the local coordinate system, so that the coordinates of the starting point of the first ray detection can be determined.
[0053] Optionally, there may be multiple ways to determine the first ray detection starting point corresponding to the target object model based on the first coordinate. For example, the position corresponding to the first coordinate in the target object model may be directly determined as the first ray detection starting point.
[0054] In step 103, ray collision detection is performed in the virtual scene based on the first ray detection starting point to determine the first collision point between the reference model of the virtual scene and the ray.
[0055] The first collision point may be a collision point between a ray emitted from the starting point of the first ray detection and a reference model in the virtual scene, and may be used as a fitting point for the target object model and the reference model to fit together. The ray collision detection may refer to emitting a ray, extending from the starting point along a specific direction, and determining whether the ray intersects with an object in the virtual scene. If the ray intersects with the object, it indicates that a collision has occurred, otherwise, it indicates that no collision has occurred.
[0056] Among them, ray collision detection is performed in the virtual scene based on the first ray detection starting point, and there can be multiple ways to determine the first collision point between the reference model of the virtual scene and the ray. For example, ray collision detection can be performed in the virtual scene along the positive and negative directions of the first ray detection direction based on the first ray detection starting point, and the first ray detection direction points to the reference model in the virtual scene; if the collision point of the ray with the reference model of the virtual scene is detected in both the positive and negative directions, the position distance between each collision point and the target object model is obtained; based on the position distance, the first collision point between the reference model of the virtual scene and the ray is determined in the collision point.
[0057] The first ray detection direction may be a direction pointing to a reference model placed in the virtual scene, and the position distance may be a distance between each collision point and the target object model.
[0058] Among them, there can be multiple ways to determine the first collision point between the reference model of the virtual scene and the ray among the collision points based on the position distance. For example, based on the position distance, the collision point that is closer to the target object model can be determined as the first collision point between the reference model of the virtual scene and the ray.
[0059] For example, take the target object model as the guardrail model and the reference model as the air wall model. Figure 3b , Figure 3b It is a model placement diagram of a model processing method provided in an embodiment of the present application. A set (H) consisting of multiple continuous target object models can be placed around a reference model (Ms). By adopting the model processing method provided in an embodiment of the present application, the target object model and the reference model are placed in a fit.
[0060] The set H can be traversed starting from i=1 to obtain relevant information of each target object model, so as to fit the target object model with the reference model:
[0061] Get the first coordinate (Xi, Yi, Zi) of each target object model Hi in the set H, and record it in the i-th position in the position set (iniPos);
[0062] Get the left vector in the model coordinate system of each target object model Count it into the i-th position in the left vector set (iniDirLeft);
[0063] Get the forward vector in the model coordinate system of each target object model Count it into the i-th position in the forward vector set (iniDirFront);
[0064] Get the up vector in the model coordinate system of each target object model Count the i-th position in the upward vector set (iniDirUp);
[0065] Get the length, width and height (Li, Wi, Hi) of each target object model and add them to the i-th position in the size set (iniSize).
[0066] In order to facilitate the description of the model processing method provided in the embodiment of the present application, the reference model is simplified into a simple continuous surface, and the target object model is simplified into a simple rectangular parallelepiped model. For example, please refer to Figure 3c , Figure 3c It is a simplified schematic diagram of model placement of a model processing method provided by an embodiment of the present application. Each target object model in the set H is provided with a corresponding model coordinate system, wherein the blue ray is the left vector of each target object model in the model coordinate system, for example, it can correspond to the x-axis direction vector, the red ray is the forward vector of each target object model in the model coordinate system, for example, it can correspond to the y-axis direction vector, and the green ray is the upward vector of each target object model in the model coordinate system, for example, it can correspond to the z-axis direction vector. The starting point of the three rays can be the world coordinates (Xi, Yi, Zi) of the target object model, that is, the first coordinate.
[0067] Optionally, in order to accurately and quickly obtain the position of the reference model in the virtual scene, the reference model can be preprocessed to mark the reference model, so that the position of the reference model can be accurately and quickly obtained in the virtual scene during ray collision detection. For example, a dedicated material can be configured for the reference model, so that the position of the reference model can be determined according to the material of the model.
[0068] For example, the reference model may have a target material, and the target material may identify the reference model as the model that the target object model needs to fit in the virtual scene. Optionally, in the virtual scene, only the reference model may have the target material, so that the reference model may be uniquely identified based on the target material, so that the position of the reference model may be accurately and quickly obtained in the virtual scene.
[0069] For example, taking the air wall model as the reference model, the material of the air wall model can be replaced with a specific target material (MI_BlockWallPreview_Adjusted). The material can be an unlit translucent material. In its material properties, the two-sided property (TwoSide) and the wireframe property (WireFrame) can be checked, and green can be used as the emissive color (EmissiveColor). For example, please refer to Figure 3d , Figure 3d It is a reference model schematic diagram of a model processing method provided in an embodiment of the present application. By replacing the material of the air wall model with the target material, the air wall model can be updated from an opaque effect to a double-sided model showing a green wireframe and translucent material. The air wall model with the target material can be more conducive to observing the interlacing of the air wall and the guardrail model. At the same time, the air wall model can also be identified by replacing the target material, so that the position of the reference model in the virtual scene can be accurately and quickly determined during ray collision detection, thereby improving the model processing efficiency.
[0070] Optionally, in order to ensure that the reference model can be accurately detected during the ray collision detection process, the reference model can be set to a double-sided model. For example, the double-sided property (bDoubleSidedGeometry) of the reference model can be set to enabled through the property setting function (SetEditorProperty) to enable the double-sided property (DoubleSidedGeometry) option of the reference model to ensure that the reference model can be absolutely detected during the subsequent ray collision detection process.
[0071] Among them, there can be multiple ways to perform ray collision detection in the virtual scene based on the first ray detection starting point, and determine the first collision point between the reference model of the virtual scene and the ray. For example, ray collision detection can be performed in the virtual scene based on the first ray detection starting point to obtain a first candidate collision point between the ray and a virtual object with a target material in the virtual scene; the first candidate collision point is determined as the first collision point between the reference model of the virtual scene and the ray.
[0072] Among them, the first candidate collision point can be the collision point between the ray and the virtual object with the target material in the virtual scene. The virtual object can be an object placed in the virtual scene. In this way, the reference model is marked by replacing the material of the reference model with the target material. Based on the target material of the reference model, the position of the reference model can be accurately and quickly detected during ray collision detection, so as to fit the target object model to the reference model, thereby improving the model processing efficiency.
[0073] In a specific embodiment, the first ray detection starting point can be used as the starting point of the ray collision detection, 5 meters as the detection length, the positive direction of the x-axis in the model coordinate system as the ray detection direction, and the ray detection function (MuliLineTraceForObject) is used to detect whether the marked reference model is collided. If it is detected that the reference model is collided, the Boolean variable LeftHit can be set to true (True), and the coordinates of the collision point are LeftImpactPoint. Then, the ray collision detection can be performed again, with the negative direction of the x-axis in the model coordinate system as the ray detection direction. If it is detected that the reference model is collided, the Boolean variable RightHit can be set to True, and the coordinates of the collision point are RightImpactPoint. In this way, if only LeftHit is True, LeftImpactPoint is taken as the first collision point, if only RightHit is True, RightImpactPoint is taken as the first collision point, and if both LeftHit and RightHit are True, the distance from the first coordinate of the target object model to the two collision points is compared, and the collision point with a closer distance is determined as the first collision point.
[0074] Optionally, if the collision point between the ray and the reference model of the virtual scene is detected only in the positive direction or the negative direction, the detected collision point may be determined as the first collision point between the ray and the reference model in the virtual scene.
[0075] Optionally, if no collision point between the ray and the reference model of the virtual scene is detected in either the positive direction or the negative direction, the detection conditions of the ray collision detection can be adjusted to facilitate detection of the collision point between the ray and the reference model of the virtual scene. For example, the length of the ray emitted by the ray collision detection can be increased, that is, the detection length of the ray collision detection can be increased, so as to solve the problem that the reference model placed in the virtual scene is far away from the target object model and cannot be detected, thereby increasing the probability of detecting the collision point with the reference model of the virtual scene.
[0076] In step 104, based on the first collision point, the target object model is placed in alignment with the reference model.
[0077] In this way, the first collision point is used as the point where the target object model and the reference model fit together, and the target object model is moved to the position of the first collision point on the reference model to achieve fitting placement of the target object model and the reference model.
[0078] Among them, there can be many ways to place the target object model in line with the reference model based on the first collision point. For example, the displacement vector corresponding to the target object model can be determined based on the coordinates of the first collision point and the coordinates of the starting point of the first ray detection; the target object model can be moved based on the displacement vector to place the target object model in line with the reference model.
[0079] The displacement vector may be a vector indicating the moving distance and moving direction of the target object model.
[0080] Optionally, the position setting function (SetActorLocation) can be used to move the position of the target object model so that the position of the first ray detection starting point on the target object model coincides with the position of the first collision point on the reference model, thereby achieving a preliminary fit between the target object model and the reference model.
[0081] After the target object model is moved based on the displacement vector, the coordinates of each vertex in the target object model can be expressed as: the starting coordinates of the vertex + (the coordinates of the first collision point – the coordinates of the starting point of the first ray detection). For example, assuming that the starting point of the first ray detection is (Xs, Ys, Zs), and the direction of the first ray detection is By emitting rays to the reference model Ms for detection, and marking the coordinates of the first collision point between the ray and the reference model as (Xc, Yc, Zc), and subtracting it from the first ray detection starting point, we can obtain the displacement vector that each vertex in the target object model should move when fitting the target object model to the first collision point of the reference model. Right now The coordinates of each vertex in the target object model can then be compared to Add to initially fit the target object model to the reference model, for example, refer to Figure 3e , Figure 3e It is a schematic diagram of fitting and placement of a model processing method provided in an embodiment of the present application. By traversing the above steps for all target object models in the set H, the effect shown in the figure can be obtained, and each target object model is preliminarily fitted with the reference model Ms in terms of position.
[0082] In one embodiment, in order to more accurately fit the target object model and the reference model, the target object model may be rotated so that the target object model and the reference model are further fitted. For example, there may be multiple target object models. After the target object model is placed in line with the reference model based on the first collision point, the following may be included: obtaining the second coordinates of each target object model after being placed based on the first collision point; calculating the rotation direction vector corresponding to each target object model based on the second coordinates; determining the rotation matrix corresponding to each target object model based on the rotation direction vector; and rotating each target object model based on the rotation matrix corresponding to each target object model so that the target object model is placed in line with and parallel to the reference model.
[0083] Among them, the second coordinate can be the world coordinate of each target object model after it is placed together based on the first collision point, the rotation direction vector can refer to the vector of the direction in which each target object model needs to be rotated in order to make the target object model more closely fit the reference model, and the rotation matrix can be a matrix used to rotate the target object model based on the rotation direction vector.
[0084] There are multiple ways to calculate the rotation direction vector corresponding to each target object model based on the second coordinate. For example, based on the placement order of the target object models and the second coordinates of any adjacent target object models, the first direction vector of the front target object model among the adjacent target object models can be calculated, wherein the first direction vector points from the front target object model to the back target object model; for the last target object model in the placement order, the second direction vector corresponding to the target object model is determined based on the second coordinate and size information of the target object model; and the rotation direction vector corresponding to each target object model is determined based on the first direction vector and the second direction vector.
[0085] The placement order may be the order in which the target object models are placed in the virtual scene, and the placement order of each target object model in the virtual scene may be determined along the trend of the reference model. The first direction vector may be a rotation direction vector corresponding to the preceding target object model among adjacent target object models, and the second direction vector may be a rotation direction vector corresponding to the last target object model in the placement order. The size information may be information describing the size of the target object model, and the size may include information such as length, height, and width.
[0086] There are multiple ways to calculate the first direction vector of the target object model in front of the adjacent target object models based on the placement order of the target object models and the second coordinates of any adjacent target object models. For example, the second coordinate of the target object model in front of the adjacent target object models can be subtracted from the second coordinate of the target object model in the back and normalized to obtain the first direction vector of the target object model in front.
[0087] For example, please refer to Figure 3e , from left to right, the first target object model on the left can be determined as the first placed target object model H1, the second target object model on the left can be determined as the second placed target object model H2, the third target object model on the left can be determined as the third placed target object model H3, the last target object model on the right can be determined as the fourth placed target object model H4, etc., which can be set specifically according to actual conditions, and the embodiments of the present application are not limited here. In this way, H1 and H2 are adjacent target object models, wherein H1 is the target object model in front, the second coordinate of H1 is subtracted from the second coordinate of H2 to obtain the first direction vector corresponding to H1, H2 and H3 are adjacent target object models, wherein H2 is the target object model in front, the second coordinate of H2 is subtracted from the second coordinate of H3 to obtain the first direction vector corresponding to H2, H3 and H4 are adjacent target object models, wherein H3 is the target object model in front, the second coordinate of H3 is subtracted from the second coordinate of H4 to obtain the first direction vector corresponding to H3, and the second direction vector is the rotation direction vector corresponding to H4.
[0088] For example, for the target object model in the set H, the new coordinate after the first collision point is aligned, that is, the second coordinate, can be recorded as (X i 2. Y i 2. Z i 2) Record the i-th position in the position set secPos. For the coordinates in the position set secPos, we can normalize the i+1th position to the i-th position and get the first direction vector in, As the position set secPos is traversed, the first direction vector calculated bit by bit is Put it into the vector set secFront, and stop when executing to the last element of secPos. Therefore, the length of the set secFront will be one less than secPos. To this end, the last vector element of the vector set iniDirFront can be added to secFront to preliminarily obtain the direction in which each target object model should rotate. Subsequently, the second direction vector corresponding to the last target object model can be calculated to obtain the rotation direction vector of each target object model. For example, please refer to Figure 4a , Figure 4a This is another fitting placement schematic diagram of a model processing method provided in an embodiment of the present application, in which the rotation direction vector corresponding to each target object model in secFront can be displayed in the figure as a red ray.
[0089] Among them, for the last target object model in the placement order, there can be multiple ways to determine the second direction vector corresponding to the target object model based on the second coordinates and size information of the target object model. For example, for the last target object model in the placement order, based on the second coordinates and size information of the target object model, the second ray detection starting point corresponding to the target object model can be calculated; based on the second ray detection starting point, ray collision detection is performed in the virtual scene to determine the second collision point between the reference model of the virtual scene and the ray corresponding to the second ray detection starting point; based on the second collision point and the second ray detection starting point, the second direction vector corresponding to the target object model is determined.
[0090] Among them, the second ray detection starting point can be a ray detection starting point for determining the rotation direction vector of the last target object model, the second collision point can be a collision point between the ray emitted from the second ray detection starting point and the reference model, or can be another fitting point between the last target object model and the reference model.
[0091] Among them, there are many ways to calculate the second ray detection starting point corresponding to the target object model based on the second coordinate and size information of the target object model. For example, based on the size information, the length and height of the target object model can be obtained, and the y component corresponding to the forward direction in the second coordinate of the target object model is offset by the length of the target object model, and the z component corresponding to the upward direction in the second coordinate of the target object model is offset by half the height of the target object model. The offset coordinates are the coordinates of the second ray detection starting point corresponding to the target object model.
[0092] For example, the second coordinate + half height of the real size of the target object model can be set as the second ray detection starting point TraceStartPoint, and the direction vector acquisition function (GetRightVector) is used to obtain the direction vector of the y axis in the model coordinate system of the target object model, that is, the forward vector Along the forward vector The point is the length of the actual size of the target object model in the direction of the target object model. At this time, the point is the half-height coordinate point of the tail of the target object model, which serves as the starting point of the second ray detection of the last target object model.
[0093] After calculating the second ray detection starting point corresponding to the target object model based on the second coordinate and size information of the target object model, ray collision detection can be performed in the virtual scene based on the second ray detection starting point to determine the second collision point between the reference model of the virtual scene and the ray corresponding to the second ray detection starting point. There are multiple ways to perform ray collision detection in the virtual scene based on the second ray detection starting point to determine the second collision point between the reference model of the virtual scene and the ray corresponding to the second ray detection starting point. For example, the second ray detection starting point can be used as the starting point of the ray collision detection, and the ray collision detection can be performed in the virtual scene with the first ray detection direction as the detection direction, so that the second collision point between the reference model of the virtual scene and the ray corresponding to the second ray detection starting point can be determined.
[0094] After performing ray collision detection in the virtual scene based on the second ray detection starting point and determining the second collision point between the reference model of the virtual scene and the ray corresponding to the second ray detection starting point, the second direction vector corresponding to the target object model can be determined based on the second collision point and the second ray detection starting point. There are multiple ways to determine the second direction vector corresponding to the target object model based on the second collision point and the second ray detection starting point. For example, the coordinates of the second ray detection starting point can be subtracted from the coordinates of the second collision point and normalized to obtain the second direction vector corresponding to the target object model.
[0095] For example, if the last vector in secFront is copied directly from iniDirFront, the direction of the last vector of secFront needs to be corrected to fit the reference model Ms. The correction can be based on the second coordinate and size information of the last target object model. The second coordinate of the last target object model is the last bit of the set secPos. Similar to calculating the starting point of the first ray detection, the upward vector of the model coordinate system can be used. The direction is offset by the half-height of the last target object model, and then along the forward vector of the model coordinate system. The length of the target object model is offset in the direction, which is used as the correction starting point, that is, the starting point of the second ray detection, and can be recorded as (Xe, Ye, Ze), which can be specifically expressed as:
[0096]
[0097] Among them, secPos[-1] can represent the last element in the set secPos, and Li can represent the length of the last target object model.
[0098] Thus, the second ray detection starting point (Xe, Ye, Ze) can be used as the starting point, and the model coordinate system of the last target object model can be used as the starting point. Direction and Direction is the ray detection direction. Two ray collision detections are performed on the reference model Ms. The coordinates of the second collision point are recorded as (Xec, Yec, Zec). Subtract (Xe, Ye, Zec) from it and normalize it to get the second direction vector It can be expressed as:
[0099]
[0100] Then, the second direction vector can be Replace the last vector in secFront At this time, the vector in secFront is the rotation direction vector of the direction in which each target object model should be rotated to fit the reference model.
[0101] After calculating the rotation direction vector corresponding to each target object model based on the second coordinate, the rotation matrix corresponding to each target object model can be determined according to the rotation direction vector. There are many ways to determine the rotation matrix corresponding to each target object model according to the rotation direction vector. For example, the rotation direction vector can be used as the direction vector on the first coordinate axis of the spatial coordinate system to calculate the first vector and the second vector corresponding to the rotation direction vector on the second coordinate axis and the third coordinate axis in the spatial coordinate system; construct a first transformation matrix based on the rotation direction vector, the first vector and the second vector; construct a second transformation matrix based on the direction vectors of the first coordinate axis, the second coordinate axis and the third coordinate axis in the model coordinate system corresponding to each target object model; calculate the rotation matrix corresponding to each target object model according to the first transformation matrix and the second transformation matrix.
[0102] Among them, the first coordinate axis may be the y coordinate axis in the spatial coordinate system, the second coordinate axis may be the x coordinate axis in the spatial coordinate system, the third coordinate axis may be the z coordinate axis in the spatial coordinate system, the first vector may be the direction vector of the second coordinate axis, and the second vector may be the direction vector of the third coordinate axis. The first transformation matrix may be a transformation matrix constructed based on the rotation direction vector, the first vector, and the second vector, and the second transformation matrix may be a transformation matrix constructed based on the direction vectors of the first coordinate axis, the second coordinate axis, and the third coordinate axis in the model coordinate system corresponding to each target object model.
[0103] Among them, there are many ways to calculate the first vector and the second vector corresponding to the rotation direction vector on the second coordinate axis and the third coordinate axis in the spatial coordinate system, using the rotation direction vector as the direction vector on the first coordinate axis of the spatial coordinate system. For example, it can be assumed that the second vector of the third coordinate axis is a standard unit vector, and the rotation direction vector is cross-multiplied with the standard unit vector, and the cross product result is negative to obtain the first vector. Then, the cross product of the rotation direction vector and the first vector can be calculated to obtain the second vector.
[0104] For example, obtain the rotation direction vector of each target object model from secFront, recorded as Then, we can assume that the second vector of the third coordinate axis is a standard unit vector, for example (0, 1, 0), cross-multiply the rotation direction vector with the standard unit vector, and negate the cross-multiplication result to obtain the first vector, which is recorded as Then multiply the rotation direction vector by the first vector to get the true second vector, which is recorded as It can be expressed as:
[0105]
[0106] Among them, Cross() can represent the cross multiplication symbol.
[0107] For each target object model, the left vector of each target object model can be obtained from iniDirLeft Get the forward vector of each target object model from iniDirFront Get the up vector of each target object model from iniDirUp The 3x3 transformation matrix Mi of the initial state is constructed with these three vectors, that is, the second transformation matrix, which can be expressed as:
[0108]
[0109] Accordingly, a 3x3 transformation matrix when each target object model fits the reference model can be constructed based on the rotation direction vector, the first vector and the second vector corresponding to each target object model, that is, the first transformation matrix Mj, which can be expressed as:
[0110]
[0111] Thus, based on the transformation matrices Mi and Mj of the two states, the 3x3 rotation matrix Mr of each target object model from the initial state to the rotation fit state can be calculated, which can be expressed as:
[0112] Mr=Mj*Mi -1
[0113] There are many ways to rotate each target object model based on the rotation matrix corresponding to each target object model. For example, for each target object model, based on the rotation matrix Mr and the second coordinates (Xi2, Yi2, Zi2), each vertex constituting the target object model can be updated in combination with the rotation matrix Mr. The coordinates of each vertex in the target object model are recorded as (Xs, Ys, Zs). After rotation based on the rotation matrix, the new coordinates of each vertex in the target object model are (Xt, Yt, Zt), which can be specifically expressed as:
[0114] (Xt, Yt, Zt)=((Xs, Ys, Zs)-(Xi2, Yi2, Zi2))*Mr+(Xi2, Yi2, Zi2)
[0115] In this way, the target object model is moved based on the new coordinates (Xt, Yt, Zt) of each vertex in the target object model to achieve rotational alignment of all target object models with the reference model. For example, please refer to Figure 4b , Figure 4b It is a rotation and placement diagram of a model processing method provided in an embodiment of the present application. After each target object model is rotated based on the rotation matrix, each target object model is parallel to the reference model, further improving the degree of fit between the target object model and the reference model.
[0116] In one embodiment, in order to further improve the degree of fit between the target object model and the reference model, the target object model after rotation can be corrected for continuity so that the target object models are closely connected. For example, after rotating each target object model based on the rotation matrix corresponding to each target object model, the position coordinates of each vertex in the rotated target object model can be obtained; based on the second coordinates, position coordinates and rotation direction vector corresponding to the target object model, the corrected length corresponding to each vertex in the target object model is calculated; and the target object model is scaled according to the corrected length and the second coordinate so that the target object models are closely connected.
[0117] The position coordinates may be the coordinates of each vertex on the target object model after the target object model is rotated, and the correction length may indicate the distance the vertex moves in the rotation direction vector, that is, the length of the extension or contraction of the target object model.
[0118] Among them, based on the second coordinate, position coordinate and rotation direction vector corresponding to the target object model, the correction length corresponding to each vertex in the target object model is calculated, and the target object model is scaled according to the correction length and the second coordinate, so that there are multiple ways to fit the target object models. For example, for the second coordinate in the position set secPos, the i+1th bit - the ith bit can be used to obtain the vector of the second coordinate of the current target object model pointing to the second coordinate of the next target object model, and its length is taken and divided by the original length L of the target object model. j , we can get the scale value of the target object model, recorded as L i , which can be specifically expressed as:
[0119] L i =Length((Xi+12, Yi+12, Zi+12)-(Xi2, Yi2, Zi2)) / L j
[0120] As the position set secPos is traversed, the L calculated bit by bit can be i Put it into the floating point set secL, and stop when the execution reaches the last element of secPos. Therefore, the length of the set secL will be one less than secPos. You can add floating point data (1.0) to the last position of secL to make up the length of the set. Then, you can get the direction vector from the current target object model to the next target object model from the vector set secFront The second coordinate of the target object model is (Xi2, Yi2, Zi2), the coordinate of each vertex of the target object model is (Xs2, Ys2, Zs2), and the corrected new coordinate is (Xt2, Yt2, Zt2), which can be specifically expressed as:
[0121]
[0122] in,
[0123]
[0124] It can be expressed as the corrected length corresponding to the target object model.
[0125] Optionally, a floating point control factor A can be introduced to control the degree of close connection between target object models according to actual conditions. i =L i *A. The specific value of A can be determined according to the actual required degree of close connection between the target object models.
[0126] In this way, the vertices in the target object model can be moved according to the corrected new coordinates to extend or shorten the target object model, so as to achieve the connection between the end of each target object model. For example, please refer to Figure 4c , Figure 4c It is a schematic diagram of continuity correction of a model processing method provided in an embodiment of the present application. By traversing the target object models in the set H point by point, the continuity between multiple target object models can be corrected after the target object model is fitted to the reference model Ms, thereby further improving the fitting effect.
[0127] Optionally, if the first ray detection starting point is located at the half-width position of the bottom of the target object model, based on the above model processing method provided in the embodiment of the present application, the center of the target object model can be aligned with the reference model. For example, please refer to Figure 4d , Figure 4d This is a schematic diagram of model fitting placement of a model processing method provided in an embodiment of the present application, but it still needs to be offset in the direction of the reference model by half the width of the target object model to make the target object model just outside the reference model. To this end, the x-axis or -x-axis direction in the model coordinate system of each target object model can be obtained, and half of its width in the actual size can be offset in this direction to obtain a target object model that fits the surface of the reference model. For example, please refer to Figure 4e , Figure 4e This is another schematic diagram of model fitting and placement of a model processing method provided in an embodiment of the present application. At this time, the target object model fits the surface of the reference model.
[0128] In one embodiment, the target object model and the ground model may be placed in close proximity, and the ground model may be a model or component of the ground in the virtual scene. Specifically, based on the first coordinate, the third ray detection starting point corresponding to the target object model may be determined; based on the third ray detection starting point, ray collision detection may be performed in the virtual scene in accordance with the second ray detection direction to determine the third collision point between the ground model of the virtual scene and the ray; based on the third collision point, the target object model may be placed in close proximity to the ground model.
[0129] The third ray detection starting point may be a ray detection starting point for detecting a ground model, for example, the third ray detection starting point may be a first coordinate. The second ray detection direction may be a direction pointing to a ground model of a virtual scene, for example, the z-axis direction in a model coordinate system of a target object model. The third collision point may be a collision point between a ray emitted from the third ray detection starting point and the ground model.
[0130] In order to quickly and accurately detect the ground model and obtain the position of the ground model, the ground model can be preprocessed to mark the ground model. Since the materials of the ground and terrain are configured by the scene art and cannot be changed at will, the ground model can be marked by adding tags. For example, the ground model can have a target tag, which can identify the ground model as the model that the target object model needs to fit in the virtual scene.
[0131] For example, the tag named as the target tag (FitFenceTarget) in the virtual scene can be removed first, and then a tag named as the target tag (FitFenceTarget) can be added to it to mark the ground model, and at the same time, duplicate tags can be avoided.
[0132] Among them, there are many ways to determine the third collision point between the ground model of the virtual scene and the ray by performing ray collision detection in the virtual scene based on the third ray detection starting point and in the second ray detection direction. For example, ray collision detection can be performed in the virtual scene based on the second ray detection starting point and in the second ray detection direction to obtain a second candidate collision point between the ray and the virtual object with the target label in the virtual scene; the second candidate collision point is determined as the third collision point between the ground model of the virtual scene and the ray.
[0133] For example, see Figure 4f , Figure 4f It is a ground fitting schematic diagram of a model processing method provided in an embodiment of the present application. Through the third collision point, the bottom of the target object model can be fitted with the top of the ground model to achieve fitting and placement of the target object model and the ground model.
[0134] In the existing racing game production process, it is usually necessary to set up air walls on both sides of the track to ensure that players drive along the established route and prevent players from running off the track. For the guardrail models on both sides of the track, they need to be placed as close to the outside of the air wall as possible. Among them, the air wall is invisible to the player, and the closeness of the guardrail and the air wall is crucial: if the guardrail is too close to the center of the road, the player's vehicle may intersect with the guardrail model, destroying the immersion; if the guardrail is too far outside, the player may not touch the guardrail but may rub against it and slow down, destroying the player's gaming experience. A route may have hundreds or thousands of guardrail models. Manually checking and adjusting them one by one with the degree of fit with the air wall and the ground will consume a lot of time and energy. In addition, when iterating the route design, planners will frequently adjust the local convexity and concavity of the air wall, which will cause the guardrail model of this section to fit the air wall again. In addition, when iterating the route design, the ups and downs of the road surface will be adjusted, which will cause the guardrail section to be adjusted accordingly to avoid being inserted or floating on the ground, resulting in poor efficiency in the fit and placement of the guardrail model with the air wall and the ground.
[0135] To this end, the model processing method provided in the embodiment of the present application can determine the first ray detection starting point corresponding to the guardrail model, and perform ray collision detection in the virtual scene according to the first ray detection starting point to determine the first collision point between the ray emitted from the first ray detection starting point and the air wall model placed in the virtual scene, so that the guardrail model is placed in line with the air wall model according to the first collision point, so as to achieve automatic fitting and placement of the guardrail model and the air wall model. Then, the rotation matrix corresponding to each guardrail model can be calculated, and each guardrail model can be rotated to fit the air wall model more closely according to the rotation matrix, so that the guardrail model and the air wall model are rotated and fit together. Then, the correction length corresponding to each vertex in each guardrail model can be calculated, so as to extend or shorten the guardrail model according to the correction length, so that each guardrail model fits together front and back, so as to achieve continuity correction of the guardrail model. In addition, ray collision detection can be performed in the up and down directions to obtain the collision point between the ray and the ground model, so as to fit the bottom of the guardrail model with the top of the ground model according to the collision point, so as to improve the efficiency of fitting the guardrail model to the air wall model and placing the ground model.
[0136] In one embodiment, the model processing method provided in the embodiment of the present application can achieve the goal of how to fit several continuous models as closely as possible onto a curved surface, and still maintain continuity after fitting to avoid interlacing or separation. The model processing method can be integrated into a blueprint tool [BP_FitFenceToAirwall] in Unreal Engine 4 (UE4), through which the position and rotation of target object models such as guardrail models can be automatically adjusted in batches to make them fit closely to the air wall model and the ground model. Specifically, the tool can first pre-process the air wall model and the ground placed in the virtual scene, and add additional identification information to them as the target of ray collision detection. Then, the user can select all guardrail models to perform the batch fitting function, or select some guardrail models for fitting: for each guardrail model, the tool can determine the position where it should fit and the rotation it should perform through multiple ray collision detections in different directions, so as to automatically fit the guardrail model to the air wall model and the ground.
[0137] Specifically, the tool can provide multiple functions such as fitting air walls, pre-treating air walls, left-biased guardrails, right-biased guardrails, fitting the ground, and pre-treating the ground. Figure 4g , Figure 4g It is a data transmission relationship diagram of a model processing method provided in an embodiment of the present application. Based on the various function buttons displayed on the control panel provided in UE4, the corresponding functions can be executed by clicking various function buttons. For example, the guardrail model, air wall model and ground can be preprocessed, and then the guardrail model, air wall model and ground are fitted in position, and the guardrail model and air wall model are rotated and fitted and continuity corrected, so that the guardrail model, air wall model and ground model can be closely fitted, and the guardrail model, air wall and ground model are accurately fitted in UE4, which improves the production efficiency of the game and the player experience. Through air wall and ground preprocessing and intelligent ray detection, the tool can automatically adjust the position and rotation of the guardrail model to ensure that it fits the air wall and the ground tightly, reducing the tediousness and errors of manual adjustment. In addition, the user-friendly interface of the tool allows non-technical users to operate easily, speeds up the iteration speed and improves the accuracy of guardrail fitting, saves a lot of manpower and time costs, and enhances the immersion and realism of the game, providing game developers with an efficient, accurate and easy-to-use guardrail fitting solution.
[0138] As can be seen from the above, the embodiment of the present application obtains the first coordinate of at least one target object model in the virtual scene; based on the first coordinate, determines the first ray detection starting point corresponding to the target object model; based on the first ray detection starting point, performs ray collision detection in the virtual scene to determine the first collision point between the reference model of the virtual scene and the ray; based on the first collision point, places the target object model in line with the reference model. In this way, by determining the first ray detection starting point corresponding to the target object model, and performing ray collision detection in the virtual scene according to the first ray detection starting point, the first collision point between the ray emitted by the first ray detection starting point and the reference model placed in the virtual scene is determined, and thus according to the first collision point, the target object model is placed in line with the reference model, thereby achieving automatic fitting and placement of the target object model and the reference model, improving the efficiency of placing the target object model in line with the reference model, and thereby improving the efficiency of model processing.
[0139] In order to better implement the above method, an embodiment of the present invention further provides a model processing device, which can be integrated in an electronic device, and the electronic device can be a terminal or a server.
[0140] For example, Figure 5 As shown, it is a schematic diagram of the structure of the model processing device provided in an embodiment of the present application. The model processing device may include a coordinate acquisition unit 201, a first determination unit 202, a second determination unit 203 and a fitting placement unit 204, as follows:
[0141] A coordinate acquisition unit 201 is used for acquiring first coordinates of at least one target object model in a virtual scene;
[0142] A first determining unit 202 is used to determine a first ray detection starting point corresponding to the target object model based on the first coordinate;
[0143] A second determining unit 203 is used to perform ray collision detection in the virtual scene based on the first ray detection starting point, and determine a first collision point between the reference model of the virtual scene and the ray;
[0144] The fitting and placing unit 204 is used to fit the target object model to the reference model for placement based on the first collision point.
[0145] In some embodiments, the reference model has a target material, and the target material identifies the reference model as a model that the target object model needs to fit in the virtual scene.
[0146] In some embodiments, the second determining unit 203 is configured to:
[0147] Performing ray collision detection in the virtual scene based on the first ray detection starting point to obtain a first candidate collision point between the ray and a virtual object having a target material in the virtual scene;
[0148] The first candidate collision point is determined as the first collision point between the reference model of the virtual scene and the ray.
[0149] In some embodiments, the second determining unit 203 is configured to:
[0150] Based on the first ray detection starting point, ray collision detection is performed in the virtual scene along the positive direction and the negative direction of the first ray detection direction, and the first ray detection direction points to the reference model in the virtual scene;
[0151] If the collision points between the ray and the reference model of the virtual scene are detected in both the positive direction and the negative direction, the position distance between each collision point and the target object model is obtained;
[0152] Based on the position distance, a first collision point between the reference model of the virtual scene and the ray is determined in the collision point.
[0153] In some embodiments, the fitting placement unit 204 is used to:
[0154] Determine a displacement vector corresponding to the target object model based on the coordinates of the first collision point and the coordinates of the first ray detection starting point;
[0155] The target object model is moved based on the displacement vector to place the target object model in line with the reference model.
[0156] In some embodiments, the number of target object models is multiple, and the model processing device further includes:
[0157] An acquisition unit, used for acquiring a second coordinate of each target object model after being placed based on the first collision point;
[0158] A calculation unit, used for calculating the rotation direction vector corresponding to each target object model based on the second coordinate;
[0159] A determination unit, used to determine the rotation matrix corresponding to each target object model according to the rotation direction vector;
[0160] The rotation unit is used to rotate each target object model based on the rotation matrix corresponding to each target object model, so as to place the target object model in a manner that is aligned with and parallel to the reference model.
[0161] In some embodiments, the computing unit comprises:
[0162] A first calculation subunit is used to calculate a first direction vector of a front target object model among adjacent target object models based on the placement order of the target object models and the second coordinates of any adjacent target object models, wherein the first direction vector points from the front target object model to the back target object model;
[0163] A second calculation subunit is used to determine, for the last target object model in the placement order, a second direction vector corresponding to the target object model based on the second coordinates and size information of the target object model;
[0164] The vector determination subunit is used to determine the rotation direction vector corresponding to each target object model according to the first direction vector and the second direction vector.
[0165] In some embodiments, the second computing subunit is configured to:
[0166] For the last target object model in the placement order, based on the second coordinate and size information of the target object model, calculate the second ray detection starting point corresponding to the target object model;
[0167] Performing ray collision detection in the virtual scene based on the second ray detection starting point to determine a second collision point between a reference model of the virtual scene and the ray corresponding to the second ray detection starting point;
[0168] Based on the second collision point and the second ray detection starting point, a second direction vector corresponding to the target object model is determined.
[0169] In some embodiments, the determining unit is configured to:
[0170] Taking the rotation direction vector as the direction vector on the first coordinate axis of the spatial coordinate system, calculating the first vector and the second vector corresponding to the rotation direction vector on the second coordinate axis and the third coordinate axis in the spatial coordinate system;
[0171] Constructing a first transformation matrix based on the rotation direction vector, the first vector and the second vector;
[0172] Constructing a second transformation matrix based on the direction vectors of the first coordinate axis, the second coordinate axis, and the third coordinate axis in the model coordinate system corresponding to each target object model;
[0173] The rotation matrix corresponding to each target object model is calculated according to the first transformation matrix and the second transformation matrix.
[0174] In some embodiments, the model processing device further includes a continuity correction unit, which is used to:
[0175] Get the position coordinates of each vertex in the target object model after rotation;
[0176] Calculate the corrected length corresponding to each vertex in the target object model based on the second coordinate, the position coordinate, and the rotation direction vector corresponding to the target object model;
[0177] The target object model is scaled according to the corrected length and the second coordinate so that the target object models fit together.
[0178] In some embodiments, the model processing device further includes:
[0179] A third ray detection starting point determining unit, used to determine a third ray detection starting point corresponding to the target object model based on the first coordinate;
[0180] A third collision point determination unit is used to perform ray collision detection in the virtual scene based on the third ray detection starting point according to the second ray detection direction to determine a third collision point between the ground model of the virtual scene and the ray, wherein the second ray detection direction is a direction pointing to the ground model of the virtual scene;
[0181] The ground fitting unit is used to fit the target object model to the ground model for placement based on the third collision point.
[0182] In some embodiments, the ground model has a target tag, and the target tag identifies the ground model as a model that the target object model needs to fit in the virtual scene.
[0183] In some embodiments, the third collision point determination unit is configured to:
[0184] Based on the second ray detection starting point, ray collision detection is performed in the virtual scene according to the second ray detection direction to obtain a second candidate collision point between the ray and the virtual object with the target label in the virtual scene;
[0185] The second candidate collision point is determined as the third collision point between the ground model of the virtual scene and the ray.
[0186] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0187] As can be seen from the above, the embodiment of the present application obtains the first coordinates of at least one target object model in the virtual scene through the coordinate acquisition unit 201; the first determination unit 202 determines the first ray detection starting point corresponding to the target object model based on the first coordinate; the second determination unit 203 performs ray collision detection in the virtual scene based on the first ray detection starting point, and determines the first collision point between the reference model of the virtual scene and the ray; the fitting and placement unit 204 places the target object model in line with the reference model based on the first collision point. In this way, by determining the first ray detection starting point corresponding to the target object model, and performing ray collision detection in the virtual scene according to the first ray detection starting point, the first collision point between the ray emitted by the first ray detection starting point and the reference model placed in the virtual scene is determined, so that according to the first collision point, the target object model is placed in line with the reference model, thereby realizing automatic fitting and placement of the target object model and the reference model, improving the efficiency of placing the target object model in line with the reference model, and thus improving the model processing efficiency.
[0188] The present application also provides an electronic device, such as Figure 6 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present application, and the electronic device may be a terminal or a server. Specifically:
[0189] The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0190] The processor 301 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device 300, executes various functions of the electronic device 300 and processes data by running or loading software programs and / or modules stored in the memory 302, and calling data stored in the memory 302, thereby monitoring the electronic device 300 as a whole.
[0191] In the embodiment of the present application, the processor 301 in the electronic device 300 will load instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions:
[0192] Acquire a first coordinate of at least one target object model in a virtual scene;
[0193] Based on the first coordinate, determining a first ray detection starting point corresponding to the target object model;
[0194] Performing ray collision detection in the virtual scene based on the first ray detection starting point to determine a first collision point between the reference model of the virtual scene and the ray;
[0195] Based on the first collision point, the target object model is placed in line with the reference model.
[0196] This solution can be achieved by obtaining the first coordinate of at least one target object model in the virtual scene; based on the first coordinate, determining the first ray detection starting point corresponding to the target object model; performing ray collision detection in the virtual scene based on the first ray detection starting point to determine the first collision point between the reference model of the virtual scene and the ray; and placing the target object model in line with the reference model based on the first collision point. In this way, by determining the first ray detection starting point corresponding to the target object model, and performing ray collision detection in the virtual scene based on the first ray detection starting point, determining the first collision point between the ray emitted by the first ray detection starting point and the reference model placed in the virtual scene, the target object model is placed in line with the reference model based on the first collision point, thereby achieving automatic fitting and placement of the target object model and the reference model, improving the efficiency of placing the target object model in line with the reference model, and thereby improving the efficiency of model processing.
[0197] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0198] Optional, such as Figure 6 As shown, the electronic device 300 further includes: a touch screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307, respectively. Those skilled in the art can understand that Figure 6 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0199] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 303 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 301, and can receive the command sent by the processor 301 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 301 to determine the type of touch event, and then the processor 301 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 303 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 303 can also be used as a part of the input unit 306 to realize the input function.
[0200] The radio frequency circuit 304 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
[0201] The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 305 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 305 and converted into audio data, and then the audio data is output to the processor 301 for processing, and then sent to another electronic device through the radio frequency circuit 304, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earplug jack to provide communication between an external headset and the electronic device.
[0202] The input unit 306 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0203] The power supply 307 is used to supply power to various components of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 307 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0204] although Figure 6 Not shown, the electronic device 300 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0205] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. It should be noted that the electronic device provided in the embodiment of the present application and the model processing method in the above embodiment belong to the same concept. The specific implementation process is detailed in the above method embodiment, which will not be repeated here.
[0206] As can be seen from the above, the electronic device provided by the embodiment of the present application can obtain the first coordinate of at least one target object model in the virtual scene; based on the first coordinate, determine the first ray detection starting point corresponding to the target object model; based on the first ray detection starting point, perform ray collision detection in the virtual scene to determine the first collision point between the reference model of the virtual scene and the ray; based on the first collision point, place the target object model in line with the reference model. In this way, by determining the first ray detection starting point corresponding to the target object model, and performing ray collision detection in the virtual scene according to the first ray detection starting point, determine the first collision point between the ray emitted by the first ray detection starting point and the reference model placed in the virtual scene, so that according to the first collision point, the target object model is placed in line with the reference model, thereby realizing automatic fitting and placement of the target object model and the reference model, improving the efficiency of placing the target object model in line with the reference model, and thus improving the model processing efficiency.
[0207] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by a computer program, or by controlling related hardware through a computer program. The computer program may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0208] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any model processing method provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0209] Acquire a first coordinate of at least one target object model in a virtual scene;
[0210] Based on the first coordinate, determining a first ray detection starting point corresponding to the target object model;
[0211] Performing ray collision detection in the virtual scene based on the first ray detection starting point to determine a first collision point between the reference model of the virtual scene and the ray;
[0212] Based on the first collision point, the target object model is placed in line with the reference model.
[0213] This solution can be achieved by obtaining the first coordinate of at least one target object model in the virtual scene; based on the first coordinate, determining the first ray detection starting point corresponding to the target object model; performing ray collision detection in the virtual scene based on the first ray detection starting point to determine the first collision point between the reference model of the virtual scene and the ray; and placing the target object model in line with the reference model based on the first collision point. In this way, by determining the first ray detection starting point corresponding to the target object model, and performing ray collision detection in the virtual scene based on the first ray detection starting point, determining the first collision point between the ray emitted by the first ray detection starting point and the reference model placed in the virtual scene, the target object model is placed in line with the reference model based on the first collision point, thereby achieving automatic fitting and placement of the target object model and the reference model, improving the efficiency of placing the target object model in line with the reference model, and thereby improving the efficiency of model processing.
[0214] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0215] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0216] Since the computer program stored in the computer-readable storage medium can execute the steps in any one of the model processing methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the model processing methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0217] Among them, according to one aspect of the present application, a computer program product is provided, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the methods provided in the various optional implementations provided in the above embodiments.
[0218] The above is a detailed introduction to a model processing method, device, storage medium and electronic device provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A model processing method, characterized in that: include: Acquire a first coordinate of at least one target object model in a virtual scene; Based on the first coordinates, determining a first ray detection starting point corresponding to the target object model; Performing ray collision detection in the virtual scene based on the first ray detection starting point to determine a first collision point between the reference model of the virtual scene and the ray; Based on the first collision point, the target object model is placed in alignment with the reference model.
2. The model processing method according to claim 1, characterized in that: The reference model has a target material, and the target material identifies the reference model as a model that the target object model needs to fit in the virtual scene.
3. The model processing method according to claim 2, characterized in that: The performing ray collision detection in the virtual scene based on the first ray detection starting point to determine a first collision point between the reference model of the virtual scene and the ray includes: Performing ray collision detection in the virtual scene based on the first ray detection starting point to obtain a first candidate collision point between the ray and a virtual object having a target material in the virtual scene; The first candidate collision point is determined as a first collision point between the reference model of the virtual scene and the ray.
4. The model processing method according to claim 1, characterized in that: The performing ray collision detection in the virtual scene based on the first ray detection starting point to determine a first collision point between the reference model of the virtual scene and the ray includes: Based on the first ray detection starting point, performing ray collision detection in the virtual scene along a positive direction and a negative direction of a first ray detection direction, wherein the first ray detection direction points to a reference model in the virtual scene; If collision points between the ray and the reference model of the virtual scene are detected in both the positive direction and the negative direction, obtaining the position distance between each collision point and the target object model; Based on the position distance, a first collision point between the reference model of the virtual scene and the ray is determined in the collision point.
5. The model processing method according to claim 1, characterized in that: The placing of the target object model in alignment with the reference model based on the first collision point includes: Determining a displacement vector corresponding to the target object model based on the coordinates of the first collision point and the coordinates of the first ray detection starting point; The target object model is moved based on the displacement vector to place the target object model in close proximity to the reference model.
6. The model processing method according to any one of claims 1 to 5, characterized in that: There are multiple target object models, and after placing the target object model in accordance with the reference model based on the first collision point, the method further includes: Acquire second coordinates of each target object model after being placed based on the first collision point; Based on the second coordinate, calculating the rotation direction vector corresponding to each of the target object models; Determine the rotation matrix corresponding to each target object model according to the rotation direction vector; Each of the target object models is rotated based on the rotation matrix corresponding to each of the target object models, so as to fit the target object model and place it parallel to the reference model.
7. The model processing method according to claim 6, characterized in that: The calculating, based on the second coordinate, a rotation direction vector corresponding to each of the target object models includes: Based on the placement order of the target object models and the second coordinates of any adjacent target object models, calculating a first direction vector of a front target object model among the adjacent target object models, wherein the first direction vector points from the front target object model to the back target object model; For the last target object model in the placement order, determining a second direction vector corresponding to the target object model based on the second coordinates and size information of the target object model; A rotation direction vector corresponding to each of the target object models is determined according to the first direction vector and the second direction vector.
8. The model processing method according to claim 7, characterized in that: The step of determining, for the last target object model in the placement order, a second direction vector corresponding to the target object model based on the second coordinates and size information of the target object model, includes: For the last target object model in the placement sequence, based on the second coordinates and size information of the target object model, calculating a second ray detection starting point corresponding to the target object model; Performing ray collision detection in the virtual scene based on the second ray detection starting point to determine a second collision point between a reference model of the virtual scene and the ray corresponding to the second ray detection starting point; Based on the second collision point and the second ray detection starting point, a second direction vector corresponding to the target object model is determined.
9. The model processing method according to claim 6, characterized in that: Determining the rotation matrix corresponding to each of the target object models according to the rotation direction vector includes: Taking the rotation direction vector as the direction vector on the first coordinate axis of the spatial coordinate system, calculating the first vector and the second vector corresponding to the rotation direction vector on the second coordinate axis and the third coordinate axis respectively in the spatial coordinate system; Constructing a first transformation matrix based on the rotation direction vector, the first vector and the second vector; Constructing a second transformation matrix based on the direction vectors of the first coordinate axis, the second coordinate axis, and the third coordinate axis in the model coordinate system corresponding to each of the target object models; The rotation matrix corresponding to each of the target object models is calculated according to the first transformation matrix and the second transformation matrix.
10. The model processing method according to claim 6, characterized in that: After rotating each of the target object models based on the rotation matrix corresponding to each of the target object models, the method further includes: Obtaining the position coordinates of each vertex in the target object model after rotation; Calculating a corrected length corresponding to each vertex in the target object model based on the second coordinate corresponding to the target object model, the position coordinate, and the rotation direction vector; The target object model is scaled according to the corrected length and the second coordinate so that the target object models fit together.
11. The model processing method according to any one of claims 1 to 5, characterized in that: The method further comprises: Based on the first coordinates, determining a third ray detection starting point corresponding to the target object model; Based on the third ray detection starting point, ray collision detection is performed in the virtual scene according to a second ray detection direction to determine a third collision point between the ground model of the virtual scene and the ray, wherein the second ray detection direction is a direction pointing to the ground model of the virtual scene; Based on the third collision point, the target object model is placed in conformity with the ground model.
12. The model processing method according to claim 11, characterized in that: The ground model has a target tag, and the target tag identifies the ground model as a model that the target object model needs to fit in the virtual scene.
13. The model processing method according to claim 12, characterized in that: The performing ray collision detection in the virtual scene based on the third ray detection starting point according to the second ray detection direction to determine the third collision point between the ground model of the virtual scene and the ray includes: Based on the second ray detection starting point, ray collision detection is performed in the virtual scene according to the second ray detection direction to obtain a second candidate collision point between the ray and the virtual object with the target label in the virtual scene; The second candidate collision point is determined as a third collision point between the ground model of the virtual scene and the ray.
14. A model processing device, characterized in that: include: A coordinate acquisition unit, used to acquire a first coordinate of at least one target object model in a virtual scene; A first determining unit, configured to determine a first ray detection starting point corresponding to the target object model based on the first coordinate; A second determining unit, configured to perform ray collision detection in the virtual scene based on the first ray detection starting point, and determine a first collision point between the reference model of the virtual scene and the ray; A fitting and placement unit is used to fit the target object model to the reference model for placement based on the first collision point.
15. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 13.
16. A computer-readable storage medium, characterized in that: The method comprises a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any one of the methods of claims 1 to 13.