CN113724401A - Three-dimensional model cutting method and device, computer equipment and storage medium - Google Patents

Three-dimensional model cutting method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN113724401A
CN113724401A CN202111028730.9A CN202111028730A CN113724401A CN 113724401 A CN113724401 A CN 113724401A CN 202111028730 A CN202111028730 A CN 202111028730A CN 113724401 A CN113724401 A CN 113724401A
Authority
CN
China
Prior art keywords
coordinate
dimensional model
coordinates
triangle
distance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111028730.9A
Other languages
Chinese (zh)
Other versions
CN113724401B (en
Inventor
王玲
王波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Dianjinshi Information Technology Co ltd
Original Assignee
Guangzhou Dianjinshi Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Dianjinshi Information Technology Co ltd filed Critical Guangzhou Dianjinshi Information Technology Co ltd
Priority to CN202111028730.9A priority Critical patent/CN113724401B/en
Publication of CN113724401A publication Critical patent/CN113724401A/en
Application granted granted Critical
Publication of CN113724401B publication Critical patent/CN113724401B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T19/00Manipulating 3D models or images for computer graphics
    • G06T19/20Editing of 3D images, e.g. changing shapes or colours, aligning objects or positioning parts
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/20Finite element generation, e.g. wire-frame surface description, tesselation

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Graphics (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Geometry (AREA)
  • Architecture (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention relates to a three-dimensional model cutting method, a device, computer equipment and a storage medium, wherein the method comprises the following steps: obtaining a triangular coordinate forming the three-dimensional model and a second space coordinate and a direction coordinate forming the cutting plane; determining the positions of the cutting plane and each three-dimensional model to be in an upper side, lower side or intersection relationship through the first distance between the second space coordinate and the direction coordinate and the second distance between the triangular coordinate and the direction coordinate; acquiring coordinates of the intersection points in the intersection relation and connecting the coordinates to generate a cross section of the cutting plane on the three-dimensional model; storing the triangular coordinates in the upper side and lower side relation as the spatial grid coordinates of the upper and lower side three-dimensional models; and according to the space grid coordinates and the cross section of the upper and lower three-dimensional models, the three-dimensional models are stored again as the upper three-dimensional model and the lower three-dimensional model. The aim of cutting and separating any plane of the model can be achieved by non-professional three-dimensional model modeling personnel, and the problem of overhigh labor cost of cutting the model is solved.

Description

Three-dimensional model cutting method and device, computer equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of information processing, in particular to a three-dimensional model cutting method, a three-dimensional model cutting device, computer equipment and a storage medium.
Background
In a scenario of three-dimensional model creation in 3D modeling software, a point and a surface of a three-dimensional model are formed by stacking points and surfaces of a plurality of non-overlapping triangles, such as a cube. The three-dimensional model comprises the coordinates of all the points, the surfaces and the textures, and the modification and the decomposition of the model can be completed only based on the parameters corresponding to the triangular points and the surfaces.
In the prior art, if the effect of modifying and decomposing the model needs to be achieved, the model needs to be processed in advance in tool software such as 3Dmax and the like, the process is complicated, and after the processing of modeling workers is completed, other non-professionals cannot modify and decompose the three-dimensional model at will due to technical limitations, so that a lot of limitations exist.
Therefore, it is an urgent need to provide an effective and non-professional method for cutting a three-dimensional model.
Disclosure of Invention
The embodiment of the invention provides a three-dimensional model cutting method, a three-dimensional model cutting device, computer equipment and a storage medium, and aims to solve the problem that a non-professional technician cannot modify a three-dimensional model randomly in a three-dimensional model modification scene.
In a first aspect, an embodiment of the present invention provides a three-dimensional model cutting method, including:
acquiring a first space grid coordinate of the three-dimensional model; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates located in a spatial coordinate system;
receiving a cutting instruction for the three-dimensional model, and acquiring a second space coordinate and a direction coordinate of a cutting plane in the cutting instruction relative to the first space grid coordinate;
acquiring a first distance between the second space coordinate and the direction coordinate by calculating a dot product value between the second space coordinate and the direction coordinate;
acquiring a second distance between the triangular coordinate and the direction coordinate;
determining the position relation between each triangle and the cutting plane according to the size relation between the first distance and the second distance; the position relation comprises an upper side relation, a lower side relation and an intersection relation;
in the intersection relation, acquiring the coordinates of the intersection point of the triangle and the cutting plane;
connecting the coordinates of the intersection points in sequence by using a convex hull algorithm to generate a cross section of the cutting plane on the three-dimensional model;
acquiring a triangular coordinate positioned in the upper side relation, and storing the triangular coordinate as an upper side three-dimensional model space grid coordinate;
acquiring a triangular coordinate positioned in the lower side relation and storing the triangular coordinate as a spatial grid coordinate of the lower side three-dimensional model;
and according to the space grid coordinates of the upper three-dimensional model, the space grid coordinates of the lower three-dimensional model and the cross section, the three-dimensional model is stored as the upper three-dimensional model and the lower three-dimensional model again.
In a second aspect, an embodiment of the present invention further provides a three-dimensional model cutting device, where the three-dimensional model cutting device includes:
the first space grid coordinate acquisition module is used for acquiring a first space grid coordinate of the three-dimensional model; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates located in a spatial coordinate system;
the second space grid coordinate acquisition module is used for receiving a cutting instruction of the three-dimensional model and acquiring a second space coordinate and a direction coordinate of a cutting plane in the cutting instruction relative to the first space grid coordinate;
the first distance acquisition module is used for acquiring a first distance between the second space coordinate and the direction coordinate by calculating a point product value between the second space coordinate and the direction coordinate;
the second distance acquisition module is used for acquiring a second distance between the triangular coordinate and the direction coordinate;
the position relation obtaining module is used for determining the position relation between each triangle and the cutting plane according to the size relation between the first distance and the second distance; the position relation comprises an upper side relation, a lower side relation and an intersection relation;
the intersection point coordinate acquisition module is used for acquiring intersection point coordinates of the triangle and the cutting plane in the intersection relation;
the cross section generating module is used for sequentially connecting the intersection point coordinates by using a convex hull algorithm to generate the cross section of the cutting plane on the three-dimensional model;
the upper three-dimensional model space grid coordinate acquisition module is used for acquiring the triangular coordinates in the upper relation and storing the triangular coordinates as the upper three-dimensional model space grid coordinates;
the lower three-dimensional model space grid coordinate acquisition module is used for acquiring the triangular coordinates in the lower relationship and storing the triangular coordinates as the lower three-dimensional model space grid coordinates;
and the restoring module is used for restoring the three-dimensional model into the upper three-dimensional model and the lower three-dimensional model according to the space grid coordinates of the upper three-dimensional model, the space grid coordinates of the lower three-dimensional model and the cross section.
In a third aspect, an embodiment of the present invention further provides a computer device, where the computer device includes:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the three-dimensional model cutting method of any one of the first aspects.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the three-dimensional model cutting method according to any one of the first aspect.
In the embodiment, a first space grid coordinate of a three-dimensional model is obtained; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates located in a spatial coordinate system; receiving a cutting instruction for the three-dimensional model, and acquiring a second space coordinate and a direction coordinate of a cutting plane in the cutting instruction relative to the first space grid coordinate; acquiring a first distance between the second space coordinate and the direction coordinate by calculating a dot product value between the second space coordinate and the direction coordinate; acquiring a second distance between the triangular coordinate and the direction coordinate; determining the position relation between each triangle and the cutting plane according to the size relation between the first distance and the second distance; the position relation comprises an upper side relation, a lower side relation and an intersection relation; in the intersection relation, acquiring the coordinates of the intersection point of the triangle and the cutting plane; connecting the coordinates of the intersection points in sequence by using a convex hull algorithm to generate a cross section of the cutting plane on the three-dimensional model; acquiring a triangular coordinate positioned in the upper side relation, and storing the triangular coordinate as an upper side three-dimensional model space grid coordinate; acquiring a triangular coordinate positioned in the lower side relation and storing the triangular coordinate as a spatial grid coordinate of the lower side three-dimensional model; and according to the space grid coordinates of the upper three-dimensional model, the space grid coordinates of the lower three-dimensional model and the cross section, the three-dimensional model is stored as the upper three-dimensional model and the lower three-dimensional model again. The three-dimensional model is marked by the grid coordinates in the three-dimensional modeling engine, and the model is modified in the Unity3d scene, so that the aim that non-professional three-dimensional model modeling personnel can cut and separate any plane of the model is fulfilled, and the problems that the process of modifying the model by the modeling personnel is complicated and the model is limited after the modeling is finished are effectively solved.
Drawings
Fig. 1 is a flowchart of a three-dimensional model cutting method according to an embodiment of the present invention;
fig. 2A is a flowchart illustrating a three-dimensional model cutting method according to an embodiment of the present invention;
FIG. 2B is a diagram illustrating a three-dimensional model cutting principle according to an embodiment of the present invention;
FIG. 2C is a diagram illustrating a three-dimensional model cutting principle according to a first embodiment of the present invention;
fig. 3 is a schematic structural diagram of a three-dimensional model cutting device according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computer device according to a third embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
The noun explains:
Unity3D
a cross-platform game engine is a multi-platform comprehensive game development tool developed by Unity Technologies, which allows players to easily create interactive contents of types such as three-dimensional video games, building visualizations, real-time three-dimensional animations and the like, and is a fully integrated professional game engine.
Convex hull algorithm
From the properties of the convex hull point set, we can know the idea of the convex hull algorithm, construct the convex hull point set in order, and maintain it until the traversal of the points is completed. Firstly, adding the first two sorted points into the convex hull point set, then, taking the last two points out of the convex hull point set, and processing the next points by using an edge formed by the two points. And judging whether the point is positioned at the inner side of the edge or not through the vector in each processing, skipping the point if the point is positioned at the inner side, judging that the point is processed, and judging that the used edge is not the edge required by the convex hull if the point is positioned at the outer side, so that the last point of the current convex hull point set is abandoned, then taking the last two points, and carrying out iterative judgment until the point is added. Thus, the convex hull point set is generated after the traversal is finished.
Example one
Fig. 1 is a flowchart of a three-dimensional model cutting method according to an embodiment of the present invention, where the method may be executed by a three-dimensional model cutting apparatus, and the three-dimensional model cutting apparatus may be implemented by software and/or hardware, and may be configured in a computer device, for example, a server, a workstation, a personal computer, and the like, and specifically includes the following steps:
101, acquiring a first space grid coordinate of a three-dimensional model; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates in a spatial coordinate system.
In the embodiment of the invention, the actual three-dimensional model is modeled as follows: 1) the Constructive Solid Geometry expression method (CSG method for short) adopts Boolean algorithm (sum, sum and subtraction) to combine some simple three-dimensional geometric elements (such as cube, cylinder, ring and cone) and change them into complex three-dimensional model entity. The disadvantages of this method are that the algorithms available for generating and modifying entities are limited, the computational effort to construct the graph is large and time consuming. 2) Boundary Representation (Brep) accurately describes a three-dimensional model entity based on surfaces consisting of vertices, edges, and faces. The advantage of this method is that a stereo or wireframe model can be rendered quickly. The method has the disadvantages that the data is presented in a table form, the space occupation is large, the modification design is not as simple as that of the CGS method, for example, to modify a ruler spoon with a simple hole on a solid cube, the hole is deleted by filling, and then a new hole can be drawn; the resulting entity is not always truly valid, and can have false holes and inversion phenomena, and lack of uniqueness in description. 3) Parametric Representation (parametric Representation for free surfaces, which is difficult to describe with conventional geometric primitives, can be used. These methods describe a free-form surface by means of parameterized splines, bezier (ezier) curves and B-splines, each of its X, Y, Z coordinates being in parameterized form. The various parametric representation formats differ only in the level of control over the curve, i.e. the ability to modify the curve locally without affecting neighboring parts, and the ability to build a geometric model. 4) Cell Representation originated from analytical (e.g., finite element analysis) software in which it was required to discretize a surface into cells. The typical unit has a triangle, a square or a polygon, and the triangle approximation (converting a three-dimensional model into an STL format file) adopted in the rapid prototyping technology is an application form of the unit expression method in a three-dimensional surface.
As shown in fig. 2A, for simply modifying the three-dimensional model, it is advantageous to use cell representation points and faces in 3D modeling software (Unity3D) to represent the three-dimensional model, and points and faces with triangle as a main feature are simpler and more intuitive. For example, a cube is a point and a face composed of various triangles, and finally a three-dimensional model is formed. That is, when a three-dimensional model is expressed, the three-dimensional model is expressed using parallel slices in a space vector, where each slice is composed of different non-overlapping triangles, and the space coordinates of each triangle are defined as the space grid coordinates of the three-dimensional model, to accurately express the three-dimensional model. Therefore, the spatial grid coordinates of the three-dimensional model are obtained, and finally the spatial coordinates of the non-overlapping triangles forming the three-dimensional model surface are obtained.
In a specific application, as shown in fig. 2A, the three-dimensional model includes coordinates of points, faces and textures, and Unity3d stores the information of the model in Mesh (Mesh class). Wherein, Unity3d provides a Mesh class, allowing scripts to be created and modified, so that three-dimensional model space grid coordinates can be stored through the Mesh class for modification.
And 102, receiving a cutting instruction of the three-dimensional model, and acquiring a second space coordinate and a direction coordinate of a cutting plane in the cutting instruction relative to the first space grid coordinate.
In the embodiment of the invention, if a cutting operation is required to be performed on a three-dimensional model, a point is created in the Unity3D scene, and a cutting surface is made through the point.
Specifically, coordinate information of the three-dimensional model to be cut in the unity world coordinate system is obtained and is marked as pos1, and coordinate information of the slice in the unity world coordinate system is obtained and is marked as pos2 and the cutting direction (since the slice coordinate is only one point, there is a front-back cut, a top-bottom cut or a left-right cut with respect to the point).
The pos1 corresponds to a triangular coordinate system, and the pos2 is a spatial coordinate of the slice (cutting plane) in the unity world coordinate system.
Further, a new coordinate system is constructed by taking the three-dimensional model as a central point, the position of the slice relative to the new coordinate system and the cutting direction information are obtained, wherein in order to obtain a matrix with pos1 as an origin, transposition inversion operation is performed to obtain a new matrix, the cutting direction is transformed through the new matrix to obtain a unit vector normal of the new cutting direction, and the coordinate pos3 of the cut surface (slice) object under the three-dimensional model coordinate system is obtained through an inverse point transform function in unity. Where pos3 is the second coordinate and orientation coordinate of the slice relative to the three-dimensional model.
All vertexes, texture coordinates, normals and Mesh tangent information in a Mesh class under the three-dimensional model are obtained, wherein each datum is a one-dimensional array.
Step 103, obtaining a first distance between the second space coordinate and the direction coordinate by calculating a point product value between the second space coordinate and the direction coordinate.
In the embodiment of the present invention, using the slice direction normal and the slice position information pos3 obtained in the above steps, the first distance from pos3 to normal is obtained by dot multiplication according to formula (1):
distance1=Vector3.Dot(normal,pos3) (1)
and 104, acquiring a second distance between the triangular coordinate and the direction coordinate.
Preferably, in another embodiment of the present invention, the triangle coordinates include vertex coordinates, and step 104 may include:
and a substep a1 of obtaining a second distance by calculating a point product between the triangle vertex coordinates and the direction coordinates.
In the embodiment of the invention, the triangle vertex coordinates pos4 are obtained, the second distance2 from each vertex coordinate pos4 to normal is calculated by using point multiplication through formula (2), and the vertex coordinate on which side of the slice or on the slice can be obtained by judging the size relationship between the distance2 and the distance 1.
distance2=Vector3.Dot(m_normal,pos4) (2)
105, determining the position relation between each triangle and the cutting plane according to the size relation between the first distance and the second distance; the positional relationship includes an upper side relationship, a lower side relationship, and an intersecting relationship.
Specifically, as shown in fig. 2A, if three points of the triangle all fall on the same side of the cutting surface, or the cutting surface is parallel to one side of the triangle, or none of the points intersects the cutting surface, all the information of the triangle is saved directly according to which side of the cutting surface.
Preferably, in another embodiment of the present invention, the triangle coordinates include vertex coordinates, and step 105 may include:
sub-step B1, if the first distance is greater than the second distance, the triangle apex is in an upper or lower relationship with the cutting plane.
Specifically, the vertex coordinate pos4 of each triangle is acquired, the second distance from each vertex coordinate to normal is acquired by dot multiplication, and if distance2 is smaller than distance1, the triangle is not cut by the cutting plane, on the upper side or the lower side of the cutting plane.
Preferably, in another embodiment of the present invention, the triangle coordinates include vertex coordinates, and the sub-step B1 may include:
and a sub-step B11 of judging the relation between the three vertexes of the triangle and the cutting plane if the first distance is greater than the second distance.
Specifically, when the triangle is not cut by the cutting plane, the relative positions of the three vertices of the triangle and the cutting plane are determined.
Sub-step B12, if all three vertices of the triangle are on the cutting plane, the triangle vertices are in an upper side relationship with the cutting plane.
Specifically, as shown in fig. 2A, if three points of the triangle all fall on the same side of the cutting plane, the triangle is on the upper side of the cutting plane.
Sub-step B13, if one vertex of the triangle falls on the cutting plane and the other two vertices are on the upper or lower side of the cutting plane, the triangle vertex is in an upper or lower side relationship with the cutting plane.
Specifically, as shown in fig. 2A, if one vertex of the triangle is on the cut surface and the other two vertices are on the same side, then the triangle is on the upper or lower side of the cut surface.
Sub-step B14, if both vertices of the triangle are on the cutting plane and the other vertex is on the upper or lower side of the cutting plane, the triangle vertex is in an upper or lower side relationship with the cutting plane.
Specifically, as shown in fig. 2A, if two apexes of a triangle are on a cut surface and one point is on a certain side, then this triangle is on a certain side, i.e., the upper side or the lower side, of the cut surface.
Sub-step B2, if the first distance is smaller than the second distance, the triangle vertex is in an intersecting relationship with the cutting plane.
Specifically, if distance2 is greater than distance1, the triangle is in an intersecting relationship with the cutting plane.
And 106, acquiring the coordinates of the intersection point of the triangle and the cutting plane in the intersection relation.
In the embodiment of the invention, in the intersection relationship, an intersection is generated between a part of triangles and a part of new triangles, and intersection point coordinates generated by the intersection are obtained.
It can be understood that, as shown in fig. 2B, the triangle coordinates are stored in the Mesh class of Unity, and include not only the vertex coordinates of each triangle, but also texture coordinates based on the three-dimensional model of the triangle, normal coordinates, and Mesh tangent coordinates common to Unity, by which the points, lines, and faces of the triangle of each tangent plane of the cut surface and the three-dimensional model can be accurately located.
Preferably, in another embodiment of the present invention, the triangle coordinates further include triangle edge coordinates, and step 106 may include:
as shown in fig. 2B, according to the three-dimensional mathematical knowledge, if the intersection point of the triangle and the plane is P on a straight line, then a point P0 on the cutting plane and the normal of the cutting plane can be obtained:
(P-P0)·normal=0 (3)
for this intersection P-P0, if one knows a certain point L0 above the intersection and the direction L of the straight line, then:
P=L0+dL (4)
where d is the distance from L0 to intersection point P, then substituting equation (4) into equation (3) yields:
(L0+dL-P0)·normal=0 (5)
obtaining after transformation:
dL·normal+(L0-P0)·normal=0 (6)
the coordinates of intersection point P can be found by substituting d into equation (6), corresponding to the C # core code:
Figure BDA0003244364760000071
Figure BDA0003244364760000081
it can be seen from the codes that variables a and b are coordinates of any two points on a straight line, q is a coordinate of a point of intersection finally obtained, pl is a cut surface constructed by us, and includes a cutting direction and a distance from the cutting direction to a tangent plane, after the coordinate of the point of intersection is obtained, the point of intersection and vertexes on two sides of a slice are respectively reconstructed into a triangle, and the triangle is stored according to the side on the cut surface.
And 107, sequentially connecting the coordinates of the intersection points by using a convex hull algorithm to generate a cross section of the cutting plane on the three-dimensional model.
In the embodiment of the invention, after the intersection point coordinates are connected in sequence by using a convex hull algorithm, the plane where the intersection point coordinates are located is the cross section of the cutting plane on the three-dimensional model.
Preferably, in another embodiment of the present invention, the triangle coordinates further include texture coordinates and normal coordinates, and step 107 may include:
and a substep D1 of connecting the intersection point coordinates on the cutting plane by a convex hull algorithm in sequence to generate new tangent plane coordinates on the three-dimensional model.
Specifically, as shown in fig. 2A, after intersection coordinates obtained by intersection tests are performed on all line segments of the triangle, the cutting plane cuts the triangle on the original three-dimensional model into new triangles, and the intersection coordinates are connected by using a convex hull algorithm to produce new cross sections, wherein the new cross sections are formed by the newly cut triangles.
And a substep D2 of generating an upper and lower cross section of the cutting plane on the three-dimensional model and a plane normal according to the new tangent plane coordinate, the texture coordinate of the triangle and the normal coordinate.
Specifically, the new cross-plane, i.e., the new cross-plane coordinates and the new texture coordinates and normal coordinates on the triangle, are stored as the new upper and lower cross-planes and cross-plane normals.
It will be understood that the new upper and lower cross-sections are a plane, but when the two parts of the three-dimensional model after segmentation are moved, the upper and lower cross-sections are separate upper and lower cross-sections, which have the same triangular coordinates (plane parallel), normal coordinates and texture coordinates.
And step 108, acquiring the triangular coordinates in the upper side relation and storing the triangular coordinates as the spatial grid coordinates of the upper side three-dimensional model.
In the embodiment of the present invention, as shown in fig. 2B, triangles outside the intersection relationship may be on the upper side of the cutting surface, or may be on the lower side of the cutting surface, and the triangle is determined to be on the upper side or the lower side of the cutting surface by the triangle coordinates in the subclass slicedsub list stored in the triangle Mesh in the unity.
And newly building a Mesh type to store the coordinates of the triangle on the upper side of the cutting surface as the spatial grid coordinates of the three-dimensional model on the upper side.
And step 109, acquiring the triangle coordinates in the lower side relation, and storing the triangle coordinates as the spatial grid coordinates of the lower side three-dimensional model.
In the embodiment of the invention, similarly, a triangle positioned on the lower side of the cutting surface is newly built, and the coordinate of the triangle on the lower side is stored as the spatial grid coordinate of the three-dimensional model on the lower side.
And step 110, storing the three-dimensional model again into an upper three-dimensional model and a lower three-dimensional model according to the space grid coordinates of the upper three-dimensional model, the space grid coordinates of the lower three-dimensional model and the cross section.
In the embodiment of the invention, the three-dimensional model is divided into an upper part and a lower part through the space grid coordinate of the upper three-dimensional model and the space grid coordinate of the lower three-dimensional model, and the cutting section is taken as a new surface which comprises the texture coordinate of the new cutting surface. This completes the triangular cutting operation.
In the embodiment, a first space grid coordinate of a three-dimensional model is obtained; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates located in a spatial coordinate system; receiving a cutting instruction for the three-dimensional model, and acquiring a second space coordinate and a direction coordinate of a cutting plane in the cutting instruction relative to the first space grid coordinate; acquiring a first distance between the second space coordinate and the direction coordinate by calculating a dot product value between the second space coordinate and the direction coordinate; acquiring a second distance between the triangular coordinate and the direction coordinate; determining the position relation between each triangle and the cutting plane according to the size relation between the first distance and the second distance; in the intersection relation, acquiring the coordinates of the intersection point of the triangle and the cutting plane; connecting the coordinates of the intersection points in sequence by using a convex hull algorithm to generate a cross section of the cutting plane on the three-dimensional model; acquiring a triangular coordinate positioned in the upper side relation, and storing the triangular coordinate as an upper side three-dimensional model space grid coordinate; acquiring a triangular coordinate positioned in the lower side relation and storing the triangular coordinate as a spatial grid coordinate of the lower side three-dimensional model; and according to the space grid coordinates of the upper three-dimensional model, the space grid coordinates of the lower three-dimensional model and the cross section, the three-dimensional model is stored as the upper three-dimensional model and the lower three-dimensional model again. The three-dimensional model is marked by the grid coordinates in the three-dimensional modeling engine, and the model is modified in the Unity3d scene, so that the aim that non-professional three-dimensional model modeling personnel can cut and separate any plane of the model is fulfilled, and the problems that the process of modifying the model by the modeling personnel is complicated and the model is limited after the modeling is finished are effectively solved.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Example two
Fig. 3 is a structural block diagram of a three-dimensional model cutting device according to a second embodiment of the present invention, which may specifically include the following modules:
a first space grid coordinate obtaining module 201, configured to obtain a first space grid coordinate of the three-dimensional model; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates in a spatial coordinate system.
A second space grid coordinate obtaining module 202, configured to receive a cutting instruction for the three-dimensional model, and obtain a second space coordinate and a direction coordinate of the cutting plane in the cutting instruction, where the second space coordinate and the direction coordinate are relative to the first space grid coordinate.
A first distance obtaining module 203, configured to obtain a first distance between the second spatial coordinate and the direction coordinate by calculating a point product between the second spatial coordinate and the direction coordinate.
A second distance obtaining module 204, configured to obtain a second distance between the triangle coordinate and the direction coordinate.
A position relation obtaining module 205, configured to determine a position relation between each triangle and the cutting plane according to a size relation between the first distance and the second distance; the positional relationship includes an upper side relationship, a lower side relationship, and an intersecting relationship.
Preferably, in another embodiment of the present invention, the triangle coordinates include vertex coordinates, and the position relation obtaining module 205 is further configured to: if the first distance is greater than the second distance, the triangle vertex and the cutting plane are in an upper side relation or a lower side relation; and if the first distance is smaller than the second distance, the triangle top point and the cutting plane are in an intersecting relationship.
Preferably, in another embodiment of the present invention, the triangle coordinates include vertex coordinates, and the position relation obtaining module 205 is further configured to: if the first distance is larger than the second distance, judging the relation between three vertexes of the triangle and the cutting plane respectively; if all three vertices of the triangle are on the cutting plane, the triangle vertices are in an upper side relationship with the cutting plane; if one vertex of the triangle is on the cutting plane and the other two vertices are on the upper side or the lower side of the cutting plane, the vertex of the triangle is in an upper side relation or a lower side relation with the cutting plane; if both vertices of the triangle are on the cutting plane and the other vertex is on the upper or lower side of the cutting plane, the triangle vertices are in an upper or lower side relationship with the cutting plane.
An intersection coordinate obtaining module 206, configured to obtain intersection coordinates of the triangle and the cutting plane in the intersection relationship.
And a cross section generating module 207, configured to sequentially connect the coordinates of the intersection points by using a convex hull algorithm, and generate a cross section of the cutting plane on the three-dimensional model.
Preferably, in another embodiment of the present invention, the triangle coordinates further include texture coordinates and normal coordinates, and the cross-section generating module 207 is further configured to: sequentially connecting the intersection point coordinates on the cutting plane by using a convex hull algorithm to generate new tangent plane coordinates on the three-dimensional model; and generating an upper cross section and a lower cross section of the cutting plane on the three-dimensional model and a plane normal according to the new tangent plane coordinate, the texture coordinate of the triangle and the normal coordinate.
An upper three-dimensional model space grid coordinate obtaining module 208, configured to obtain a triangle coordinate located in the upper relationship, and store the triangle coordinate as an upper three-dimensional model space grid coordinate;
a lower three-dimensional model space grid coordinate obtaining module 209, configured to obtain a triangle coordinate located in the lower relationship, and store the triangle coordinate as a lower three-dimensional model space grid coordinate;
a restoring module 210, configured to restore the three-dimensional model into an upper three-dimensional model and a lower three-dimensional model according to the upper three-dimensional model space grid coordinates, the lower three-dimensional model space grid coordinates, and the cross section.
The three-dimensional model cutting device provided by the embodiment of the invention can execute the three-dimensional model cutting method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
EXAMPLE III
Fig. 4 is a schematic structural diagram of a computer device according to a third embodiment of the present invention. FIG. 4 illustrates a block diagram of an exemplary computer device 12 suitable for use in implementing embodiments of the present invention. The computer device 12 shown in FIG. 4 is only one example and should not bring any limitations to the functionality or scope of use of embodiments of the present invention.
As shown in FIG. 4, computer device 12 is in the form of a general purpose computing device. The components of computer device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Computer device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by computer device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)30 and/or cache memory 32. Computer device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, and commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Computer device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with computer device 12, and/or with any devices (e.g., network card, modem, etc.) that enable computer device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, computer device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via network adapter 20. As shown, network adapter 20 communicates with the other modules of computer device 12 via bus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with computer device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 16 executes various functional applications and data processing, such as implementing the three-dimensional model cutting method provided by the embodiment of the present invention, by executing a program stored in the system memory 28.
Example four
The fourth embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the three-dimensional model cutting method, and can achieve the same technical effect, and in order to avoid repetition, the detailed description is omitted here.
A computer readable storage medium may include, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A three-dimensional model cutting method, comprising:
acquiring a first space grid coordinate of the three-dimensional model; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates located in a spatial coordinate system;
receiving a cutting instruction for the three-dimensional model, and acquiring a second space coordinate and a direction coordinate of a cutting plane in the cutting instruction relative to the first space grid coordinate;
acquiring a first distance between the second space coordinate and the direction coordinate by calculating a dot product value between the second space coordinate and the direction coordinate;
acquiring a second distance between the triangular coordinate and the direction coordinate;
determining the position relation between each triangle and the cutting plane according to the size relation between the first distance and the second distance; the position relation comprises an upper side relation, a lower side relation and an intersection relation;
in the intersection relation, acquiring the coordinates of the intersection point of the triangle and the cutting plane;
connecting the coordinates of the intersection points in sequence by using a convex hull algorithm to generate a cross section of the cutting plane on the three-dimensional model;
acquiring a triangular coordinate positioned in the upper side relation, and storing the triangular coordinate as an upper side three-dimensional model space grid coordinate;
acquiring a triangular coordinate positioned in the lower side relation and storing the triangular coordinate as a spatial grid coordinate of the lower side three-dimensional model;
and according to the space grid coordinates of the upper three-dimensional model, the space grid coordinates of the lower three-dimensional model and the cross section, the three-dimensional model is stored as the upper three-dimensional model and the lower three-dimensional model again.
2. The method of claim 1, wherein the triangle coordinate comprises a vertex coordinate, and the obtaining a second distance between the triangle coordinate and the direction coordinate comprises:
and calculating a point product value between the vertex coordinate of the triangle and the direction coordinate to obtain a second distance.
3. The method of claim 2, wherein determining the positional relationship of each triangle to the cutting plane based on the magnitude relationship between the first distance and the second distance comprises:
if the first distance is greater than the second distance, the triangle vertex and the cutting plane are in an upper side relation or a lower side relation;
and if the first distance is smaller than the second distance, the triangle top point and the cutting plane are in an intersecting relationship.
4. The method of claim 1, wherein the triangle coordinates further include texture coordinates and normal coordinates, and the generating the cross-section of the cutting plane on the three-dimensional model by sequentially connecting the intersection coordinates using a convex hull algorithm comprises:
sequentially connecting the intersection point coordinates on the cutting plane by using a convex hull algorithm to generate new tangent plane coordinates on the three-dimensional model;
and generating an upper cross section and a lower cross section of the cutting plane on the three-dimensional model and a plane normal according to the new tangent plane coordinate, the texture coordinate of the triangle and the normal coordinate.
5. The method of claim 3, wherein if the first distance is greater than the second distance, the triangle apex is in an upper or lower relationship with the cutting plane, comprising:
if the first distance is larger than the second distance, judging the relation between three vertexes of the triangle and the cutting plane respectively;
if all three vertices of the triangle are on the cutting plane, the triangle vertices are in an upper side relationship with the cutting plane;
if one vertex of the triangle is on the cutting plane and the other two vertices are on the upper side or the lower side of the cutting plane, the vertex of the triangle is in an upper side relation or a lower side relation with the cutting plane;
if both vertices of the triangle are on the cutting plane and the other vertex is on the upper or lower side of the cutting plane, the triangle vertices are in an upper or lower side relationship with the cutting plane.
6. A three-dimensional model cutting apparatus, comprising:
the first space grid coordinate acquisition module is used for acquiring a first space grid coordinate of the three-dimensional model; the three-dimensional model consists of polygonal parallel sections; the polygonal parallel section consists of a plurality of non-overlapping triangles; the first spatial grid coordinates comprise the non-overlapping respective triangular coordinates located in a spatial coordinate system;
the second space grid coordinate acquisition module is used for receiving a cutting instruction of the three-dimensional model and acquiring a second space coordinate and a direction coordinate of a cutting plane in the cutting instruction relative to the first space grid coordinate;
the first distance acquisition module is used for acquiring a first distance between the second space coordinate and the direction coordinate by calculating a point product value between the second space coordinate and the direction coordinate;
the second distance acquisition module is used for acquiring a second distance between the triangular coordinate and the direction coordinate;
the position relation obtaining module is used for determining the position relation between each triangle and the cutting plane according to the size relation between the first distance and the second distance; the position relation comprises an upper side relation, a lower side relation and an intersection relation;
the intersection point coordinate acquisition module is used for acquiring intersection point coordinates of the triangle and the cutting plane in the intersection relation;
the cross section generating module is used for sequentially connecting the intersection point coordinates by using a convex hull algorithm to generate the cross section of the cutting plane on the three-dimensional model;
the upper three-dimensional model space grid coordinate acquisition module is used for acquiring the triangular coordinates in the upper relation and storing the triangular coordinates as the upper three-dimensional model space grid coordinates;
the lower three-dimensional model space grid coordinate acquisition module is used for acquiring the triangular coordinates in the lower relationship and storing the triangular coordinates as the lower three-dimensional model space grid coordinates;
and the restoring module is used for restoring the three-dimensional model into the upper three-dimensional model and the lower three-dimensional model according to the space grid coordinates of the upper three-dimensional model, the space grid coordinates of the lower three-dimensional model and the cross section.
7. The apparatus of claim 6, wherein the triangle coordinates comprise vertex coordinates, and the second distance acquisition module comprises:
and the second distance acquisition submodule is used for calculating a point multiplication value between the vertex coordinate of the triangle and the direction coordinate to obtain a second distance.
8. The apparatus of claim 6, wherein the positional relationship obtaining module is further configured to:
if the first distance is greater than the second distance, the triangle vertex and the cutting plane are in an upper side relation or a lower side relation;
and if the first distance is smaller than the second distance, the triangle top point and the cutting plane are in an intersecting relationship.
9. A computer device, characterized in that the computer device comprises:
one or more processors;
a memory for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the three-dimensional model cutting method of any one of claims 1-5.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out a three-dimensional model cutting method according to any one of claims 1 to 5.
CN202111028730.9A 2021-09-02 2021-09-02 Three-dimensional model cutting method and device, computer equipment and storage medium Active CN113724401B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111028730.9A CN113724401B (en) 2021-09-02 2021-09-02 Three-dimensional model cutting method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111028730.9A CN113724401B (en) 2021-09-02 2021-09-02 Three-dimensional model cutting method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113724401A true CN113724401A (en) 2021-11-30
CN113724401B CN113724401B (en) 2023-12-15

Family

ID=78681255

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111028730.9A Active CN113724401B (en) 2021-09-02 2021-09-02 Three-dimensional model cutting method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113724401B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114418836A (en) * 2022-03-11 2022-04-29 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium
CN114722688A (en) * 2022-06-07 2022-07-08 中国城市规划设计研究院(住房和城乡建设部遥感应用中心) Automatic layering method for three-dimensional building model
CN115659769A (en) * 2022-09-15 2023-01-31 深圳十沣科技有限公司 Model particle generation method, device, equipment and storage medium
CN116468825A (en) * 2023-06-09 2023-07-21 北京声影动漫科技有限公司 Curve shearing method, curve shearing device, curve shearing equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050253841A1 (en) * 2004-05-17 2005-11-17 Stefan Brabec Volume rendering processing distribution in a graphics processing unit
CN109360260A (en) * 2018-10-22 2019-02-19 南京科远自动化集团股份有限公司 A kind of cut-away restructing algorithm of triangle gridding threedimensional model
CN110555910A (en) * 2019-07-11 2019-12-10 北京云上作科技有限责任公司 grid cutting method, device, terminal and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050253841A1 (en) * 2004-05-17 2005-11-17 Stefan Brabec Volume rendering processing distribution in a graphics processing unit
CN109360260A (en) * 2018-10-22 2019-02-19 南京科远自动化集团股份有限公司 A kind of cut-away restructing algorithm of triangle gridding threedimensional model
CN110555910A (en) * 2019-07-11 2019-12-10 北京云上作科技有限责任公司 grid cutting method, device, terminal and storage medium

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114418836A (en) * 2022-03-11 2022-04-29 腾讯科技(深圳)有限公司 Data processing method, device, equipment and medium
CN114722688A (en) * 2022-06-07 2022-07-08 中国城市规划设计研究院(住房和城乡建设部遥感应用中心) Automatic layering method for three-dimensional building model
CN114722688B (en) * 2022-06-07 2022-08-26 中国城市规划设计研究院(住房和城乡建设部遥感应用中心) Automatic layering method for three-dimensional building model
CN115659769A (en) * 2022-09-15 2023-01-31 深圳十沣科技有限公司 Model particle generation method, device, equipment and storage medium
CN115659769B (en) * 2022-09-15 2023-11-03 深圳十沣科技有限公司 Model particle generation method, device, equipment and storage medium
CN116468825A (en) * 2023-06-09 2023-07-21 北京声影动漫科技有限公司 Curve shearing method, curve shearing device, curve shearing equipment and storage medium
CN116468825B (en) * 2023-06-09 2023-11-10 北京声影动漫科技有限公司 Curve shearing method, curve shearing device, curve shearing equipment and storage medium

Also Published As

Publication number Publication date
CN113724401B (en) 2023-12-15

Similar Documents

Publication Publication Date Title
CN113724401B (en) Three-dimensional model cutting method and device, computer equipment and storage medium
EP2808810B1 (en) Compression and decompression of 3d modeled object
US8175734B2 (en) Methods and system for enabling printing three-dimensional object models
CN112926119B (en) Building model compression processing method, device, equipment and medium
CN111581776B (en) Iso-geometric analysis method based on geometric reconstruction model
JP2005038219A (en) Method for generating volume data from boundary expression data and program therefor
CN107464286B (en) Method, device, equipment and readable medium for repairing holes in three-dimensional city model
CN109003333B (en) Interactive grid model cutting method and device based on texture and modeling equipment
US20220156430A1 (en) Topological message passing for three dimensional models in boundary representation format
KR101552827B1 (en) Method Of Dividing Three-dimensional Object Model
US10943037B2 (en) Generating a CAD model from a finite element mesh
US11605200B2 (en) System for optimizing a 3D mesh
Zhu et al. Analytical solutions for sketch-based convolution surface modeling on the GPU
CN116861023B (en) Method and system for determining same geometric objects in three-dimensional space
US7388584B2 (en) Method and program for determining insides and outsides of boundaries
CN118541730A (en) Low polygon mesh generation for three-dimensional models
US20070088531A1 (en) Methods For Generating Digital Or Visual Representations Of A Closed Tessellated Surface Geometry
Ćurković et al. Enhanced 3D parameterization for integrated shape synthesis by fitting parameter values to point sets
US11222467B2 (en) Methods and systems for extracting data from virtual representation of three-dimensional visual scans
US8031957B1 (en) Rewritable lossy compression of graphical data
CN114239094A (en) Revit model creating method, device, equipment and storage medium
CN109979007A (en) A kind of geometric modeling method and apparatus of building body
CN115690120B (en) Method, apparatus, device, medium and program product for generating three-dimensional grid
EP4202750A1 (en) 3d model generation
JP2007140976A (en) Cross section display program and cross section display device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
PE01 Entry into force of the registration of the contract for pledge of patent right

Denomination of invention: A 3D model cutting method, device, computer equipment, and storage medium

Granted publication date: 20231215

Pledgee: Bank of China Limited by Share Ltd. Guangzhou Tianhe branch

Pledgor: Guangzhou dianjinshi Information Technology Co.,Ltd.

Registration number: Y2024980041899