CN114782606A - Voxel model texture map unfolding method and device, electronic device and medium - Google Patents
Voxel model texture map unfolding method and device, electronic device and medium Download PDFInfo
- Publication number
- CN114782606A CN114782606A CN202210515659.5A CN202210515659A CN114782606A CN 114782606 A CN114782606 A CN 114782606A CN 202210515659 A CN202210515659 A CN 202210515659A CN 114782606 A CN114782606 A CN 114782606A
- Authority
- CN
- China
- Prior art keywords
- texture map
- voxel model
- map
- pixel grid
- target
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/005—General purpose rendering architectures
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T17/00—Three dimensional [3D] modelling, e.g. data description of 3D objects
- G06T17/10—Constructive solid geometry [CSG] using solid primitives, e.g. cylinders, cubes
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Geometry (AREA)
- Computer Graphics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Image Generation (AREA)
Abstract
Description
技术领域technical field
本申请涉及计算机技术领域,特别是涉及体素模型的纹理贴图展开方法及装置、电子设备、介质。The present application relates to the field of computer technology, and in particular, to a texture map expansion method and device for a voxel model, an electronic device, and a medium.
背景技术Background technique
三维物体(例如三维游戏角色)的制作可以分为模型制作和渲染过程,其中,模型制作过程又分为:构建三维物体的三维模型、纹理贴图展开(也称拆分纹理贴图)和贴图制作过程。The production of 3D objects (such as 3D game characters) can be divided into model production and rendering processes. Among them, the model production process is further divided into: constructing 3D models of 3D objects, texture map expansion (also called split texture maps), and map production processes .
构建的三维物体的三维模型可以是体素模型,而体素模型是由多个立方体组成的三维模型,对体素模型进行纹理贴图展开,要求得到的展开纹理贴图中的纹理贴图网格的大小等于像素网格图的一个像素的大小,其中,组成体素模型的立方体的每个四边面对应的纹理贴图面块即为一个纹理贴图网格。The three-dimensional model of the constructed three-dimensional object can be a voxel model, and the voxel model is a three-dimensional model composed of multiple cubes. The texture map of the voxel model is expanded, and the size of the texture map grid in the expanded texture map is required to be obtained. It is equal to the size of one pixel of the pixel grid image, wherein the texture map surface block corresponding to each four-sided surface of the cube constituting the voxel model is a texture map grid.
相关技术中,对体素模型进行纹理贴图展开包括如下步骤:步骤1、手动选择体素模型的边缘,进行分割,以得到体素模型各个面的纹理贴图图像;步骤2、手动将各个面的纹理贴图图像进行横平竖直地摆放,确定每个纹理贴图图像包含的纹理贴图网格的数量;步骤3、人工评估体素模型所需的贴图大小,并基于评估结果确定贴图的背景大小,手动将各个纹理贴图图像摆放到确定好的像素网格图中,并使得每个纹理贴图网格对应像素网格图中的一个像素,以得到体素模型的展开纹理贴图。In the related art, the texture map expansion of the voxel model includes the following steps: Step 1, manually select the edge of the voxel model, and segment it to obtain the texture map image of each face of the voxel model; Step 2, manually The texture map images are placed horizontally, horizontally and vertically, and the number of texture map grids contained in each texture map image is determined; Step 3: Manually evaluate the size of the texture map required by the voxel model, and determine the background size of the texture map based on the evaluation results. Manually place each texture map image into the determined pixel grid map, and make each texture map grid correspond to a pixel in the pixel grid map, so as to obtain the expanded texture map of the voxel model.
可见,相关技术对体素模型进行纹理贴图展开的步骤繁琐,制作时间长,并且需要人工评估使用的像素网格图大小,容易出错导致返工等问题。It can be seen that the related art has cumbersome steps to expand the texture map of the voxel model, takes a long time to make, and requires manual evaluation of the size of the pixel grid used, which is prone to errors and causes problems such as rework.
需要说明的是,在上述背景技术部分公开的信息仅用于加强对本公开的背景的理解,因此可以包括不构成对本领域普通技术人员已知的现有技术的信息。It should be noted that the information disclosed in the above Background section is only for enhancement of understanding of the background of the present disclosure, and therefore may contain information that does not form the prior art that is already known to a person of ordinary skill in the art.
发明内容SUMMARY OF THE INVENTION
鉴于上述问题,提出了本申请以便提供克服上述问题或者至少部分地解决上述问题的体素模型的纹理贴图展开方法及装置、电子设备、介质,包括:In view of the above problems, the present application is proposed to provide a texture map expansion method and apparatus, electronic device, and medium for a voxel model that overcome the above problems or at least partially solve the above problems, including:
一种体素模型的纹理贴图展开方法,所述方法包括:A texture map expansion method for a voxel model, the method comprising:
获取待处理的体素模型的外表面包含的目标四边面;Obtain the target quadrilateral surface contained in the outer surface of the voxel model to be processed;
根据所述目标四边面在所述体素模型中的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标;According to the three-dimensional coordinates of the target quadrilateral surface in the voxel model, determine the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map;
基于所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标和所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成所述体素模型的外表面分别对应的纹理贴图图像;Based on the texture map coordinates of the texture map surface block in the expanded texture map and the orientation of the target quadrilateral surface on the voxel model, the texture map surface blocks corresponding to the target four-sided surface with the same orientation are spliced into the Texture map images corresponding to the outer surface of the voxel model;
将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图,其中,所述纹理贴图图像中的每个纹理贴图面块对应所述像素网格图中的一个像素。Arranging the texture map image into a pixel grid map to obtain an expanded texture map of the voxel model, wherein each texture map surface block in the texture map image corresponds to the pixel grid map of one pixel.
可选地,所述体素模型由多个立方体组成,每个立方体具有六个四边面,所述获取待处理的体素模型的外表面包含的目标四边面,包括:Optionally, the voxel model is composed of a plurality of cubes, and each cube has six quadrilateral surfaces, and the acquiring the target quadrilateral surface contained in the outer surface of the voxel model to be processed includes:
将立方体的四边面中不与其他立方体的四边面重合的四边面确定为组成所述体素模型外表面的目标四边面;Determining the four-sided faces that do not coincide with the four-sided faces of other cubes among the four-sided faces of the cube as the target four-sided faces composing the outer surface of the voxel model;
或者,or,
将多个立方体之间重合的四边面剔除,以得到组成所述体素模型外表面的目标四边面。The four-sided surfaces that overlap among the plurality of cubes are culled to obtain the target four-sided surfaces composing the outer surface of the voxel model.
可选地,所述根据所述目标四边面在所述体素模型中的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,包括:Optionally, according to the three-dimensional coordinates of the target quadrilateral surface in the voxel model, determining the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map, including:
获取所述目标四边面的几何顶点的三维坐标;obtaining the three-dimensional coordinates of the geometric vertices of the target quadrilateral;
根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。According to the three-dimensional coordinates of the geometric vertices, the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map are determined.
可选地,所述根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,包括:Optionally, the determining, according to the three-dimensional coordinates of the geometric vertices, the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map, including:
将所述几何顶点的三维坐标换算成浮点数坐标,并基于所述浮点数坐标确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。The three-dimensional coordinates of the geometric vertices are converted into floating point coordinates, and the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map are determined based on the floating point coordinates.
可选地,所述基于所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标和所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成所述体素模型的外表面分别对应的纹理贴图图像,包括:Optionally, based on the texture map coordinates of the texture map surface block in the expanded texture map and the orientation of the target quadrilateral on the voxel model, map the texture map corresponding to the target quadrilateral with the same orientation. The surface blocks are spliced into texture map images corresponding to the outer surfaces of the voxel model, including:
根据所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标,对所述纹理贴图面块进行排序,得到所述纹理贴图面块的序号;According to the texture map coordinates of the texture map surface block in the expanded texture map, sort the texture map surface blocks to obtain the serial number of the texture map surface block;
根据所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块划分到同一个集合中;According to the orientation of the target quadrilateral face on the voxel model, the texture map surface blocks corresponding to the target quadrilateral face with the same orientation are divided into the same set;
对每个集合中的纹理贴图面块,根据所述纹理贴图面块的序号对同一个集合中的纹理贴图面块进行拼接,得到纹理贴图图像。For the texture map surface blocks in each set, the texture map surface blocks in the same set are spliced according to the serial numbers of the texture map surface blocks to obtain a texture map image.
可选地,所述方法还包括:Optionally, the method further includes:
根据所述体素模型的纹理贴图面块的数量确定像素网格图,所述像素网格图的像素数量不小于所述纹理贴图面块的数量。A pixel grid map is determined according to the number of texture map surface blocks of the voxel model, and the pixel number of the pixel grid map is not less than the number of texture map surface blocks.
可选地,所述将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图;包括:Optionally, arranging the texture map image into a pixel grid map to obtain an expanded texture map of the voxel model; including:
获取第一像素网格图;Get the first pixel grid image;
当所述第一像素网格图的像素数量小于所述纹理贴图面块的数量时,从像素网格图库中获取第二像素网格图,并将所述纹理贴图图像排布到所述第二像素网格图中,以得到所述体素模型的展开纹理贴图;所述第二像素网格图的像素数量不小于所述纹理贴图面块的数量;When the number of pixels of the first pixel grid image is less than the number of texture map surface blocks, acquire a second pixel grid image from the pixel grid library, and arrange the texture map image to the first pixel grid image. In a two-pixel grid map, to obtain an expanded texture map of the voxel model; the number of pixels in the second pixel grid map is not less than the number of texture map surface blocks;
当所述第一像素网格图的像素数量不小于所述纹理贴图面块的数量时,将所述纹理贴图图像排布到所述第一像素网格图中。When the number of pixels of the first pixel grid map is not less than the number of the texture map surface blocks, the texture map image is arranged in the first pixel grid map.
可选地,所述将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图;包括:Optionally, arranging the texture map image into a pixel grid map to obtain an expanded texture map of the voxel model; including:
将所述纹理贴图图像按照指定间隔排布到像素网格图中,以得到所述体素模型的展开纹理贴图。Arranging the texture map images into a pixel grid map at specified intervals to obtain an expanded texture map of the voxel model.
一种体素模型的纹理贴图展开装置,所述装置包括:A texture map expansion device for a voxel model, the device includes:
目标四边面获取模块,用于获取待处理的体素模型的外表面包含的目标四边面;The target quadrilateral surface acquisition module is used to acquire the target quadrilateral surface contained in the outer surface of the voxel model to be processed;
纹理贴图面块生成模块,用于根据所述目标四边面在所述体素模型中的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标;a texture map surface block generation module, configured to determine the texture map coordinates of the texture map surface block corresponding to the target four-sided surface in the expanded texture map according to the three-dimensional coordinates of the target four-sided surface in the voxel model;
纹理贴图图像生成模块,用于基于所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标和所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成所述体素模型的外表面分别对应的纹理贴图图像;The texture map image generation module is used for, based on the texture map coordinates of the texture map surface block in the expanded texture map and the orientation of the target quadrilateral on the voxel model, the target quadrilateral corresponding to the same orientation The texture map surface blocks are spliced into texture map images corresponding to the outer surfaces of the voxel model respectively;
展开纹理贴图生成模块,用于将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图,其中,所述纹理贴图图像中的每个纹理贴图面块对应所述像素网格图中的一个像素。An expanded texture map generation module, configured to arrange the texture map image into a pixel grid map to obtain an expanded texture map of the voxel model, wherein each texture map surface block in the texture map image Corresponds to a pixel in the pixel grid.
可选地,所述体素模型由多个立方体组成,每个立方体具有六个四边面,所述目标四边面获取模块,用于将立方体的四边面中不与其他立方体的四边面重合的四边面确定为组成所述体素模型外表面的目标四边面;或者,用于将多个立方体之间重合的四边面剔除,以得到组成所述体素模型外表面的目标四边面。Optionally, the voxel model is composed of a plurality of cubes, and each cube has six four-sided surfaces, and the target four-sided surface acquisition module is used to obtain the four-sided surfaces of the four-sided surfaces of the cube that do not overlap with the four-sided surfaces of other cubes. The surface is determined as the target quadrilateral surface composing the outer surface of the voxel model; or, used for culling the coincident quadrilateral surfaces among multiple cubes to obtain the target quadrilateral surface composing the outer surface of the voxel model.
可选地,所述纹理贴图面块生成模块,包括:Optionally, the texture map surface block generation module includes:
第一获取模块,用于获取所述目标四边面的几何顶点的三维坐标;The first acquisition module is used to acquire the three-dimensional coordinates of the geometric vertices of the four-sided surface of the target;
纹理贴图坐标确定模块,用于根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。The texture map coordinate determination module is configured to determine the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map according to the three-dimensional coordinates of the geometric vertices.
可选地,所述纹理贴图坐标确定模块,用于将所述几何顶点的三维坐标换算成浮点数坐标,并基于所述浮点数坐标确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。Optionally, the texture map coordinate determination module is configured to convert the three-dimensional coordinates of the geometric vertices into floating-point coordinates, and determine, based on the floating-point coordinates, that the texture map surface block corresponding to the target quadrilateral surface is being expanded. Texture map coordinates in the texture map.
可选地,所述纹理贴图图像生成模块,包括:Optionally, the texture map image generation module includes:
排序模块,用于根据所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标,对所述纹理贴图面块进行排序,得到所述纹理贴图面块的序号;a sorting module, configured to sort the texture map surface blocks according to the texture map coordinates of the texture map surface blocks in the expanded texture map to obtain the serial number of the texture map surface blocks;
分类模块,用于根据所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块划分到同一个集合中;A classification module, configured to divide the texture map face blocks corresponding to the target quadrilateral faces with the same orientation into the same set according to the orientation of the target quadrilateral face on the voxel model;
拼接模块,用于对每个集合中的纹理贴图面块,根据所述纹理贴图面块的序号对同一个集合中的纹理贴图面块进行拼接,得到纹理贴图图像。The splicing module is used for splicing the texture map surface blocks in the same set according to the serial numbers of the texture map surface blocks to obtain a texture map image.
可选地,所述装置还包括:Optionally, the device further includes:
网格图确定模块,用于根据所述体素模型的纹理贴图面块的数量确定像素网格图,所述像素网格图的像素数量不小于所述纹理贴图面块的数量。A grid map determination module, configured to determine a pixel grid map according to the number of texture map surface blocks of the voxel model, where the number of pixels of the pixel grid map is not less than the number of texture map surface blocks.
可选地,所述展开纹理贴图生成模块,包括:Optionally, the expanded texture map generation module includes:
网格图获取模块,用于获取第一像素网格图;a grid image acquisition module, used to acquire the first pixel grid image;
第一生成模块,用于当所述第一像素网格图的像素数量小于所述纹理贴图面块的数量时,从像素网格图库中获取第二像素网格图,并将所述纹理贴图图像排布到所述第二像素网格图中,以得到所述体素模型的展开纹理贴图;所述第二像素网格图的像素数量不小于所述纹理贴图面块的数量;The first generation module is configured to obtain a second pixel grid image from the pixel grid library when the number of pixels of the first pixel grid image is less than the number of the texture map surface blocks, and use the texture map to obtain a second pixel grid image. The images are arranged in the second pixel grid map to obtain the expanded texture map of the voxel model; the number of pixels in the second pixel grid map is not less than the number of texture map surface blocks;
第二生成模块,用于当所述第一像素网格图的像素数量不小于所述纹理贴图面块的数量时,将所述纹理贴图图像排布到所述第一像素网格图中。A second generating module, configured to arrange the texture map image into the first pixel grid map when the number of pixels of the first pixel grid map is not less than the number of the texture map surface blocks.
可选地,所述展开纹理贴图生成模块,用于将所述纹理贴图图像按照指定间隔排布到像素网格图中,以得到所述体素模型的展开纹理贴图。Optionally, the expanded texture map generation module is configured to arrange the texture map images into a pixel grid map according to a specified interval, so as to obtain the expanded texture map of the voxel model.
一种电子设备,包括处理器、存储器及存储在所述存储器上并能够在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如上所述的体素模型的纹理贴图展开方法的步骤。An electronic device comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program implementing the above-described voxel model when executed by the processor The steps of the texture map unwrapping method.
一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现如上所述的体素模型的纹理贴图展开方法的步骤。A computer-readable storage medium stores a computer program on the computer-readable storage medium, and when the computer program is executed by a processor, implements the steps of the above-described texture map expansion method for a voxel model.
本申请具有以下优点:This application has the following advantages:
在本申请实施例中,通过获取待处理的体素模型的外表面包含的目标四边面,根据目标四边面在体素模型中的三维坐标,确定目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,结合目标四边面在体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成体素模型的外表面分别对应的纹理贴图图像,最后将纹理贴图图像按照每个纹理贴图面块对应像素网格图中的一个像素的方式排布到像素网格图中,得到体素模型的展开纹理贴图;可以实现自动生成体素模型的展开纹理贴图,同时由于本申请实施例在生成体素模型的展开纹理贴图的过程中,先得到用于组成体素模型外表面的目标四边面对应的纹理贴图面块,再通过拼接得到纹理贴图图像,因此,还可以确保纹理贴图图像中的纹理贴图面块的一致性,解决了现有技术通过人工手动分割得到的纹理贴图面块不一致、通过人工手动摆放纹理贴图面块来得到展开纹理贴图,导致展开纹理贴图不准确且效率低的问题,本申请实施例提高了生成展开纹理贴图的效率和准确性。In this embodiment of the present application, by acquiring the target quadrilateral included in the outer surface of the voxel model to be processed, and according to the three-dimensional coordinates of the target quadrilateral in the voxel model, it is determined that the texture map surface block corresponding to the target quadrilateral is being expanded. The texture map coordinates in the texture map, combined with the orientation of the target four-sided surface on the voxel model, spliced the texture map surface blocks corresponding to the target four-sided surface with the same orientation into the texture map images corresponding to the outer surface of the voxel model, and finally The texture map image is arranged in the pixel grid map in the way that each texture map surface block corresponds to one pixel in the pixel grid map, and the expanded texture map of the voxel model is obtained; the expanded texture map of the voxel model can be automatically generated. At the same time, in the process of generating the expanded texture map of the voxel model in the embodiment of the present application, the texture map surface block corresponding to the target four-sided surface used to form the outer surface of the voxel model is first obtained, and then the texture map image is obtained by splicing, Therefore, the consistency of the texture map patches in the texture map image can also be ensured, and the inconsistency of the texture map patches obtained by manual segmentation in the prior art is solved, and the expanded texture map is obtained by manually placing the texture map patches. This leads to the problem of inaccuracy and low efficiency of the unfolded texture map. The embodiments of the present application improve the efficiency and accuracy of generating the unfolded texture map.
附图说明Description of drawings
为了更清楚地说明本申请的技术方案,下面将对本申请的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the present application more clearly, the following briefly introduces the drawings used in the description of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, which are of great significance to the art. For those of ordinary skill, other drawings can also be obtained from these drawings without creative labor.
图1为本申请实施例的一种体素模型的纹理贴图展开方法的步骤流程图;FIG. 1 is a flowchart of steps of a texture map expansion method for a voxel model according to an embodiment of the present application;
图2为本申请实施例中的待处理的体素模型的示意图;2 is a schematic diagram of a voxel model to be processed in an embodiment of the present application;
图3是图2所示的体素模型的目标四边面进行纹理贴图展开后,得到的纹理贴图面块的示意图;Fig. 3 is the schematic diagram of the texture map surface block obtained after the target quadrilateral surface of the voxel model shown in Fig. 2 is expanded by texture map;
图4是对纹理贴图面块进行拼接,得到纹理贴图图像的示意图;Fig. 4 is a schematic diagram of splicing texture map surface blocks to obtain a texture map image;
图5是图2所示的体素模型的展开纹理贴图示意图;Fig. 5 is the expanded texture map schematic diagram of the voxel model shown in Fig. 2;
图6为本申请实施例的一种体素模型的纹理贴图展开装置的结构框图。FIG. 6 is a structural block diagram of an apparatus for expanding a texture map of a voxel model according to an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的上述目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本申请作进一步详细的说明。显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the above objects, features and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are some, but not all, embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
体素模型,是采用大量规则体素(如立方体)的有序组合来表示三维物体的模型。体素模型的制作过程中,涉及到纹理贴图展开的过程,纹理贴图即UV纹理贴图,UV是UV纹理贴图坐标的简称,与空间模型的X,Y,Z轴类似,它定义了纹理贴图上每个点的位置信息,并且这些点与体素模型是相互联系的,以决定表面纹理贴图的位置,UV将纹理贴图上每一个点精确对应到体素模型的表面。相关技术在对体素模型进行纹理贴图展开的过程,需要人工手动进行分割边缘的选择,得到体素模型的各个面的纹理贴图图像,然后,通过人工操作,确定每个纹理贴图图像包含的纹理贴图面块(也称纹理贴图网格),并评估体素模型所需的贴图大小,以确定贴图的像素网格图大小,其中,像素网格图是由表示一个像素大小的黑色和白色格子交错生成的棋盘格底图,也成为贴图背景;最后,再通过手动将各个纹理贴图图像摆放到确定的像素网格图中,摆放过程中,确保纹理贴图图像中的每个纹理贴图面块对应像素网格图中的一个像素,以得到体素模型的展开纹理贴图。整个过程繁琐,制作时间长,并且需要人工评估使用的贴图大小,容易出错导致返工等问题。A voxel model is a model that uses an ordered combination of a large number of regular voxels (such as cubes) to represent three-dimensional objects. In the process of making a voxel model, it involves the process of texture map expansion. Texture map is UV texture map. UV is the abbreviation of UV texture map coordinates. It is similar to the X, Y, and Z axes of the space model. The position information of each point, and these points are related to the voxel model to determine the position of the surface texture map, and UV accurately corresponds each point on the texture map to the surface of the voxel model. In the related art, in the process of expanding the texture map of the voxel model, it is necessary to manually select the edge of the segmentation to obtain the texture map image of each face of the voxel model, and then determine the texture contained in each texture map image through manual operation. Texture patch (also called texture map grid), and evaluate the texture size required by the voxel model to determine the texture's pixel grid size, where the pixel grid is composed of black and white grids representing the size of one pixel The checkerboard basemap generated by interleaving also becomes the texture background; finally, each texture map image is manually placed into the determined pixel grid map. During the placement process, ensure that each texture map surface in the texture map image is placed. A block corresponds to a pixel in the pixel grid to get the unwrapped texture map of the voxel model. The whole process is cumbersome, takes a long time to make, and requires manual evaluation of the size of the texture used, which is prone to errors and rework.
鉴于此,本申请实施例提供了一种体素模型的纹理贴图展开方法,通过确定用于组成体素模型外表面的目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,再根据目标四边面组成体素模型外表面的朝向以及纹理贴图面块在展开纹理贴图中的纹理贴图坐标,对纹理贴图面块进行拼接,以得到体素模型各个外表面对应的纹理贴图图像,最后将纹理贴图图像按照一个纹理贴图面块对应像素网格图的一个像素的要求排布到像素网格图中,得到体素模型的展开纹理贴图;实现自动对体素模型进行纹理贴图展开,提高了体素模型纹理贴图展开的效率和准确性。In view of this, an embodiment of the present application provides a texture map expansion method for a voxel model. , and then according to the orientation of the outer surface of the voxel model composed of the target four sides and the texture map coordinates of the texture map surface block in the expanded texture map, the texture map surface blocks are spliced to obtain the texture map image corresponding to each outer surface of the voxel model. , and finally arrange the texture map image into the pixel grid map according to the requirements of one pixel of the pixel grid map corresponding to a texture map surface block, and obtain the expanded texture map of the voxel model; realize the automatic texture map expansion of the voxel model , which improves the efficiency and accuracy of texture map expansion for voxel models.
本申请实施例提供的体素模型的纹理贴图展开方法可以应用于电子设备中,在需要拆分体素模型的纹理贴图时,可以自动得到体素模型的展开纹理贴图。其中,电子设备可以是硬件,也可以是软件。当电子设备为硬件时,可以实现成多个服务器或终端设备组成的集群,也可以实现单个服务器或单个终端设备。当电子设备是软件时,可以安装在上述列举的硬件设备中。The texture map expansion method of the voxel model provided by the embodiment of the present application can be applied to electronic devices, and when the texture map of the voxel model needs to be split, the expanded texture map of the voxel model can be automatically obtained. The electronic device may be hardware or software. When the electronic device is hardware, it can be implemented as a cluster composed of multiple servers or terminal devices, or can be implemented as a single server or a single terminal device. When the electronic device is software, it can be installed in the above-listed hardware devices.
参照图1,示出了本申请一实施例提供的一种体素模型的纹理贴图展开方法的步骤流程图,在本申请实施例中,该方法可以包括如下步骤:Referring to FIG. 1 , a flowchart of steps of a texture map expansion method for a voxel model provided by an embodiment of the present application is shown. In the embodiment of the present application, the method may include the following steps:
步骤101,获取待处理的体素模型的外表面包含的目标四边面;
步骤102,根据所述目标四边面在所述体素模型中的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标;
步骤103,基于所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标和所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成所述体素模型的外表面分别对应的纹理贴图图像;
步骤104,将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图,其中,所述纹理贴图图像中的每个纹理贴图面块对应所述像素网格图中的一个像素。Step 104: Arrange the texture map image into a pixel grid map to obtain an expanded texture map of the voxel model, wherein each texture map surface block in the texture map image corresponds to the pixel grid A pixel in the grid.
本申请实施例通过获取待处理的体素模型的外表面包含的目标四边面,根据目标四边面在体素模型中的三维坐标,确定目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,结合目标四边面在体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成体素模型的外表面分别对应的纹理贴图图像,最后将纹理贴图图像按照每个纹理贴图面块对应像素网格图中的一个像素的方式排布到像素网格图中,得到体素模型的展开纹理贴图;可以实现自动生成体素模型的展开纹理贴图,同时由于本申请实施例在生成体素模型的展开纹理贴图的过程中,先得到用于组成体素模型外表面的目标四边面对应的纹理贴图面块,再通过拼接得到纹理贴图图像,因此,还可以确保纹理贴图图像中的纹理贴图面块的一致性,解决了现有技术通过人工手动分割得到的纹理贴图面块不一致、通过人工手动摆放纹理贴图面块来得到展开纹理贴图,导致展开纹理贴图不准确且效率低的问题,本申请实施例提高了生成展开纹理贴图的效率和准确性。In this embodiment of the present application, the target quadrilateral surface included in the outer surface of the voxel model to be processed is obtained, and the texture map surface block corresponding to the target quadrilateral surface is determined in the expanded texture map according to the three-dimensional coordinates of the target quadrilateral surface in the voxel model. The texture map coordinates of the target four-sided surface on the voxel model are combined with the orientation of the target four-sided surface on the voxel model, the texture map surface blocks corresponding to the target four-sided surface with the same orientation are spliced into the texture map image corresponding to the outer surface of the voxel model, and finally the texture map image According to the way that each texture map surface block corresponds to one pixel in the pixel grid map, it is arranged in the pixel grid map to obtain the expanded texture map of the voxel model; the expanded texture map of the voxel model can be automatically generated. In the process of generating the unfolded texture map of the voxel model in the embodiment of the present application, the texture map surface blocks corresponding to the target four-sided surface used to form the outer surface of the voxel model are obtained first, and then the texture map image is obtained by splicing. It can ensure the consistency of the texture map surface blocks in the texture map image, and solves the problem that the texture map surface blocks obtained by manual manual segmentation in the prior art are inconsistent, and the texture map surface blocks are manually placed to obtain the expanded texture map, resulting in expanded textures. For the problem of inaccurate mapping and low efficiency, the embodiments of the present application improve the efficiency and accuracy of generating an unfolded texture map.
下面,将对本示例性实施例中体素模型的纹理贴图展开方法作进一步地说明。Next, the texture map expansion method of the voxel model in this exemplary embodiment will be further described.
在步骤101中,获取待处理的体素模型的外表面包含的目标四边面。In
在本实施例中,待处理的体素模型是指需要拆分纹理贴图的体素模型,该待处理的体素模型可以是一个,也可以是多个,当待处理的体素模型为多个时,分别对每个体素模型执行如后续步骤相同的处理过程,以得到每个体素模型对应的展开纹理贴图。需要说明说明的是,多个体素模型可以采用并行的方式同时处理,也可以采用串行的方式依次处理,本申请实施例对此不作限制。In this embodiment, the voxel model to be processed refers to a voxel model that needs to split texture maps. The voxel model to be processed may be one or multiple. When there are multiple voxel models to be processed For each voxel model, the same processing process as the subsequent steps is performed respectively to obtain the unfolded texture map corresponding to each voxel model. It should be noted that, multiple voxel models may be processed simultaneously in a parallel manner, or may be processed sequentially in a serial manner, which is not limited in this embodiment of the present application.
体素模型是由立方体组成的,每个立方体具有六个四边面,体素模型的外表面包括多个平面,因此,体素模型的每个平面都包含至少一个四边面。如图2所示为本申请一实施例中的待处理的体素模型,该体素模型的外表面包含多个平面,每个平面由至少一个四边面组成。为了便于理解,对图2所示的体素模型中的其中一个平面进行标识,以及对已标识的平面中的一个四边面进行标识,本申请实施例中,将用于组成体素模型的外表面的四边面定义为目标四边面,以区别于立方体中处于体素模型内部的四边面。The voxel model is composed of cubes, each cube has six quadrilateral faces, and the outer surface of the voxel model includes a plurality of planes, so each plane of the voxel model contains at least one quadrilateral face. FIG. 2 shows a voxel model to be processed in an embodiment of the present application. The outer surface of the voxel model includes a plurality of planes, and each plane is composed of at least one four-sided plane. In order to facilitate understanding, one of the planes in the voxel model shown in FIG. 2 is identified, and one four-sided plane in the identified plane is identified. The quadrilaterals of the surface are defined as the target quadrilaterals to distinguish them from the quadrilaterals inside the voxel model in the cube.
示例性地,在电子设备处理器上执行相关应用程序时,可以在电子设备的显示屏上渲染得到图形用户界面,图形用户界面中可以显示一个或多个体素模型;响应于用户针对图形用户界面显示的体素模型的选择操作,将选择操作选中的体素模型确定为待处理的体素模型。若待处理的体素模型中的多个立方体在组成体素模型时已经进行合并,即组成体素模型的多个立方体之间重合的四边面已经剔除,只保留组成体素模型的外表面的四边面,则可以直接获取待处理的体素模型的目标四边面。Exemplarily, when the relevant application program is executed on the electronic device processor, a graphical user interface can be rendered on the display screen of the electronic device, and one or more voxel models can be displayed in the graphical user interface; The selection operation of the displayed voxel model determines the voxel model selected by the selection operation as the voxel model to be processed. If multiple cubes in the voxel model to be processed have been merged when forming the voxel model, that is, the overlapping four-sided surfaces between the multiple cubes forming the voxel model have been eliminated, and only the outer surface of the voxel model is retained. Four-sided surface, the target four-sided surface of the voxel model to be processed can be directly obtained.
若待处理的体素模型中的多个立方体在组成体素模型时没有进行合并,即组成体素模型的各个立方体的六个面均保留,则在本申请一可选实施例中,上述获取待处理的体素模型的过程,包括:If the multiple cubes in the voxel model to be processed are not combined when forming the voxel model, that is, the six faces of each cube forming the voxel model are reserved, then in an optional embodiment of the present application, the above acquisition The process of the voxel model to be processed, including:
将立方体的四边面中不与其他立方体的四边面重合的四边面确定为组成所述体素模型外表面的目标四边面。Among the four-sided faces of the cube, the four-sided faces that do not overlap with the four-sided faces of other cubes are determined as the target four-sided faces composing the outer surface of the voxel model.
本实施例中,获取待处理的体素模型,可以获取组成体素模型的所有立方体,针对每个立方体的每个四边面,可以判断该四边面是否与其他立方体的四边面重合,若重合,则说明该四边面位于体素模型的内部,若不重合,则说明该四边面位于体素模型的外部;当判断结果为不重合时,确定该四边面是组成体素模型的外表面的其中一个目标四边面,并获取该目标四边面。通过上述方式,可以将各个立方体的四边面中不与其他立方体的四边面重合四边面确定为组成体素模型外表面的目标四边面。In this embodiment, to obtain the voxel model to be processed, all cubes constituting the voxel model can be obtained, and for each four-sided surface of each cube, it can be determined whether the four-sided surface overlaps with the four-sided surface of other cubes. Then it means that the quadrilateral surface is located inside the voxel model. If they do not overlap, it means that the quadrilateral surface is located outside the voxel model. When the judgment result is that they do not overlap, it is determined that the quadrilateral surface is one of the outer surfaces of the voxel model. A target quadrilateral, and get the target quadrilateral. In the above manner, the four-sided surfaces of the four-sided surfaces of each cube that do not overlap with the four-sided surfaces of other cubes can be determined as the target four-sided surfaces constituting the outer surface of the voxel model.
在本申请一可选实施例中,体素模型由多个立方体组成,每个立方体具有六个四边面,上述获取待处理的体素模型的过程,包括:In an optional embodiment of the present application, the voxel model is composed of multiple cubes, and each cube has six four-sided faces. The above-mentioned process of acquiring the voxel model to be processed includes:
将多个立方体之间重合的四边面剔除,以得到组成所述体素模型外表面的目标四边面。The four-sided surfaces that overlap among the plurality of cubes are culled to obtain the target four-sided surfaces composing the outer surface of the voxel model.
本实施例中,可以获取组成体素模型的所有立方体,每个立方体具有六个四边面,根据立方体在体素模型中的位置,可以确定每个立方体的各个四边面的位置信息,进而根据每个四边面的位置信息,将位置信息相同的四边面确定为重合的四边面;将重合的四边面剔除,得到的剩余的四边面即为组成体素模型外表面的目标四边面。In this embodiment, all cubes constituting the voxel model can be obtained, and each cube has six four-sided faces. According to the position of the cube in the voxel model, the position information of each four-sided face of each The four-sided surfaces with the same position information are determined as the overlapping four-sided surfaces; the overlapping four-sided surfaces are eliminated, and the remaining four-sided surfaces obtained are the target four-sided surfaces composing the outer surface of the voxel model.
在步骤102中,根据所述目标四边面在所述体素模型中的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。In
在本实施例中,在获取到体素模型的目标四边面后,结合目标四边面在体素模型中的三维坐标,可以确定目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,纹理贴图坐标对应的图形即为纹理贴图面块,即生成每个目标四边面对应的纹理贴图面块。In this embodiment, after the target quadrilateral surface of the voxel model is obtained, the texture of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map can be determined in combination with the three-dimensional coordinates of the target quadrilateral surface in the voxel model. Map coordinates, the graphics corresponding to the texture map coordinates is the texture map surface block, that is, the texture map surface block corresponding to each target four-sided surface is generated.
示例性地,可以基于maxscript(3ds Max内置脚本语言)来实现生成目标四边面对应的纹理贴图面块。基于maxscript来实现生成目标四边面对应的纹理贴图面块,在生成目标四边面对应的纹理贴图面块之前,需要检查纹理贴图通道是否开启,当检查到纹理贴图通道未开启时,自动开启纹理贴图通道,其中,纹理贴图通道可以用于调整或存储模型纹理贴图相关的信息。Exemplarily, the texture map surface block corresponding to the target quadrilateral surface can be generated based on maxscript (3ds Max built-in scripting language). Based on maxscript, the texture map surface block corresponding to the target four-sided surface is generated. Before generating the texture map surface block corresponding to the target four-sided surface, it is necessary to check whether the texture map channel is enabled. When it is checked that the texture map channel is not enabled, it is automatically enabled. Texture map channel, where the texture map channel can be used to adjust or store information related to model texture maps.
如图3所示,图3是图2所示的体素模型的目标四边面进行纹理贴图展开后,得到的多个纹理贴图面块。需要说明的是,由于体素模型是由多个立方体组成,因此,体素模型的面法线存在6个朝向,并且存在三对朝向相反的面法线,面法线朝向相反的目标四边面对应的纹理贴图面块可能会出现重叠的现象。As shown in FIG. 3 , FIG. 3 is a plurality of texture map surface blocks obtained after the target four-sided surface of the voxel model shown in FIG. 2 is expanded by texture map. It should be noted that since the voxel model is composed of multiple cubes, the surface normals of the voxel model have 6 orientations, and there are three pairs of oppositely oriented surface normals, and the surface normals face the opposite target quadrilateral faces The corresponding texture map patches may overlap.
需要说明的是,图3所示的体素模型的目标四边面对应的纹理贴图面块的示意图可以展示在图形用户界面中,也可以不展示在图形用户界面中。一般地,在一键生成体素模型的展开纹理贴图的应用方式中,用户只需要选择待处理的体素模型,并触发生成该体素模型对应的展开纹理贴图的纹理贴图展开请求,即可直接向用户返回体素模型对应的展开纹理贴图,因此,图3所示的示意图一般不在图形用户界面中展示。而在按步骤生成体素模型的展开纹理贴图的应用方式中,即在生成体素模型的展开纹理贴图的过程中,需要用户多次触发相应的请求,以基于一次触发请求执行相对应的一个处理步骤,因此,图3所示的示意图可以展示在图形用户界面中。It should be noted that the schematic diagram of the texture map surface block corresponding to the target quadrilateral surface of the voxel model shown in FIG. 3 may be displayed in the graphical user interface, or may not be displayed in the graphical user interface. Generally, in the application method of generating an expanded texture map of a voxel model with one click, the user only needs to select the voxel model to be processed, and trigger the texture map expansion request to generate the expanded texture map corresponding to the voxel model, The expanded texture map corresponding to the voxel model is directly returned to the user. Therefore, the schematic diagram shown in FIG. 3 is generally not displayed in the GUI. In the application method of generating the expanded texture map of the voxel model in steps, that is, in the process of generating the expanded texture map of the voxel model, the user needs to trigger the corresponding request multiple times to execute the corresponding one based on one trigger request. The processing steps, therefore, the schematic diagram shown in Figure 3 can be presented in a graphical user interface.
在本申请一可选实施例中,上述根据所述目标四边面在所述体素模型中的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标的过程,可以包括:In an optional embodiment of the present application, according to the three-dimensional coordinates of the target quadrilateral surface in the voxel model, the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map are determined process, which can include:
获取所述目标四边面的几何顶点的三维坐标;obtaining the three-dimensional coordinates of the geometric vertices of the target quadrilateral;
根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。According to the three-dimensional coordinates of the geometric vertices, the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map are determined.
在本实施例中,可以通过获取目标四边面的几何顶点的三维坐标来确定对应的纹理贴图面块中与几何顶点对应位置的纹理贴图坐标,进而可以确定纹理贴图面块的纹理贴图坐标,纹理贴图面块的纹理贴图坐标包括组成纹理贴图面块的各个点的纹理贴图坐标,纹理贴图坐标表征纹理贴图面块在展开纹理贴图中的标识。优选的,目标四边面可以是规则的正方形,据此提高获取目标四边面的几何顶点的三维坐标的效率。示例性地,目标四边面也可以是不规则的四边形。In this embodiment, the three-dimensional coordinates of the geometric vertices of the target quadrilateral surface can be obtained to determine the texture map coordinates of the positions corresponding to the geometric vertices in the corresponding texture map surface block, and then the texture map coordinates of the texture map surface block can be determined. The texture map coordinates of the texture map block include texture map coordinates of each point constituting the texture map block, and the texture map coordinates represent the identifier of the texture map block in the expanded texture map. Preferably, the target quadrilateral surface may be a regular square, thereby improving the efficiency of obtaining the three-dimensional coordinates of the geometric vertices of the target quadrilateral surface. Exemplarily, the target quadrilateral surface may also be an irregular quadrilateral.
示例性地,可以建立体素模型的空间直角坐标系,以确定每个目标四边面的四个几何顶点在空间直角坐标系中的三维坐标,对三维坐标进行纹理贴图坐标转换,可以得到目标四边面的四个顶点对应的顶点纹理贴图坐标,进而确定目标四边面对应的纹理贴图面块,根据纹理贴图面块在纹理贴图坐标中的位置信息,可以确定纹理贴图面块的纹理贴图坐标。Exemplarily, a space rectangular coordinate system of the voxel model can be established to determine the three-dimensional coordinates of the four geometric vertices of each target quadrilateral surface in the space rectangular coordinate system, and the three-dimensional coordinates are subjected to texture mapping coordinate transformation, and the target four sides can be obtained. The vertex texture map coordinates corresponding to the four vertices of the surface, and then determine the texture map surface block corresponding to the target four-sided surface. According to the position information of the texture map surface block in the texture map coordinates, the texture map coordinates of the texture map surface block can be determined.
本实施例通过目标四边面的几何顶点的三维坐标来确定纹理贴图面块的纹理贴图坐标,可以减少计算量,提高纹理贴图面块生成效率。In this embodiment, the three-dimensional coordinates of the geometric vertices of the target quadrilateral surface are used to determine the texture map coordinates of the texture map surface block, which can reduce the amount of calculation and improve the generation efficiency of the texture map surface block.
在本申请另一可选实施例中,上述根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,包括:In another optional embodiment of the present application, determining the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map according to the three-dimensional coordinates of the geometric vertices includes:
将所述几何顶点的三维坐标换算成浮点数坐标,并基于所述浮点数坐标确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。The three-dimensional coordinates of the geometric vertices are converted into floating point coordinates, and the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map are determined based on the floating point coordinates.
本实施例在上述根据目标四边面的几何顶点的三维坐标来确定纹理贴图面块的纹理贴图坐标的基础上,在确定纹理贴图面块的纹理贴图坐标的过程中,将目标四边面的几何顶点的三维坐标先换算成对应的浮点数坐标,进而基于浮点数坐标来确定目标四边面对应的纹理贴图面块,以及纹理贴图面块的纹理贴图坐标。优选地,将目标四边面的几何顶点的三维坐标换算称0到1的浮点数坐标,利用0到1的浮点数坐标,可以使相应的程序代码在不同的像素背景中平滑过渡,从而提高兼容性。In this embodiment, on the basis of determining the texture map coordinates of the texture map surface block according to the three-dimensional coordinates of the geometric vertices of the target four-sided surface, in the process of determining the texture map coordinates of the texture map surface block, the geometric vertices of the target four-sided surface are The three-dimensional coordinates of , are first converted into corresponding floating point coordinates, and then based on the floating point coordinates, the texture map surface block corresponding to the target four-sided surface and the texture map coordinates of the texture map surface block are determined. Preferably, the three-dimensional coordinates of the geometric vertices of the target quadrilateral face are converted into floating-point coordinates from 0 to 1. Using the floating-point coordinates from 0 to 1, the corresponding program code can be smoothly transitioned in different pixel backgrounds, thereby improving compatibility. sex.
进一步地,在本申请一些可选实施例中,上述根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标之前,还可以包括:Further, in some optional embodiments of the present application, before the texture map coordinates in the texture map are expanded to determine the texture map surface block corresponding to the target quadrilateral surface according to the three-dimensional coordinates of the geometric vertices, the method may further include: :
根据目标四边面在体素模型中的位置关系对目标四边面进行排序,基于目标四边面的序号确定对应纹理贴图面块的序号;Sort the target quadrilateral faces according to their positional relationship in the voxel model, and determine the sequence number of the corresponding texture map block based on the sequence number of the target quadrilateral face;
上述根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,可以包括:The determination of the texture map coordinates in the expanded texture map of the texture map surface block corresponding to the target quadrilateral surface according to the three-dimensional coordinates of the geometric vertices may include:
按照序号依次根据目标四边面的几何顶点的三维坐标,确定对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。The texture map coordinates of the corresponding texture map surface block in the expanded texture map are determined according to the three-dimensional coordinates of the geometric vertices of the target quadrilateral surface in sequence according to the serial number.
本实施例在根据目标四边面的几何顶点的三维坐标确定纹理贴图面块的纹理贴图坐标之前,先对目标四边面和纹理贴图面块进行排序,以按照序号的先后顺序依次确定纹理贴图面块的纹理贴图坐标,可以降低脚本编写难度,提高系统运行的效率。In this embodiment, before determining the texture map coordinates of the texture map surface block according to the three-dimensional coordinates of the geometric vertices of the target four-sided surface, the target four-sided surface and the texture map surface block are sorted first, so as to sequentially determine the texture map surface blocks according to the sequence of the serial numbers The texture map coordinates can reduce the difficulty of scripting and improve the efficiency of system operation.
步骤103,基于所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标和所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成所述体素模型的外表面分别对应的纹理贴图图像。
根据目标四边面在体素模型上的朝向,可以确定对应的纹理贴图面块的朝向。其中,目标四边面的朝向可以通过目标四边面的面法线来确定。具体地,在本申请实施例中,体素模型是由多个立方体组成的,每个立方体包括6个四边面,即目标四边面的面法线是6个朝向中的一个,且对应轴向的法线分量值的模长均为1。可以将目标四边面的面法线的朝向作为对应的纹理贴图面块的朝向。将朝向相同的纹理贴图面块,按照纹理贴图面块的纹理贴图坐标进行拼接,得到至少一个纹理贴图图像,可以理解一个纹理贴图图像包含至少一个纹理贴图面块,纹理贴图图像用于表示体素像素中外表面的平面。According to the orientation of the target quadrilateral on the voxel model, the orientation of the corresponding texture map surface block can be determined. The orientation of the target quadrilateral can be determined by the surface normal of the target quadrilateral. Specifically, in the embodiment of the present application, the voxel model is composed of a plurality of cubes, and each cube includes 6 four-sided surfaces, that is, the surface normal of the target four-sided surface is one of the six orientations, and corresponds to the axial direction. The modulo length of the normal component value of is 1. The orientation of the face normal of the target quadrilateral can be used as the orientation of the corresponding texture map surface block. The texture map surface blocks with the same orientation are spliced according to the texture map coordinates of the texture map surface blocks to obtain at least one texture map image. It can be understood that a texture map image contains at least one texture map surface block, and the texture map image is used to represent voxels The plane of the outer surface in the pixel.
如图4所示,图4是对图3所示的纹理贴图面块中,进行拼接后,得到纹理贴图图像的示意图,其中,图4中的粗线标识部分用于表示不同纹理贴图图像之间的分割线,粗线框内部的纹理贴图面块进行拼接得到一个纹理贴图图像。需要说明的是,图4仅对部分的分割线进行标示,为了方便理解,在图4中标识出了图2已标识的平面对应的纹理贴图图像。As shown in FIG. 4, FIG. 4 is a schematic diagram of obtaining a texture map image after splicing the texture map surface block shown in FIG. 3, wherein the thick line identification part in FIG. 4 is used to indicate the difference between different texture map images. A texture map image is obtained by splicing the texture map surface blocks inside the thick line frame. It should be noted that FIG. 4 only marks part of the dividing line. For the convenience of understanding, the texture map image corresponding to the plane marked in FIG. 2 is marked in FIG. 4 .
还需要说明的是,图4所示的拼接后得到的纹理贴图图像可以展示在图形用户界面中,也可以不展示在图形用户界面中。一般地,在一键生成体素模型的展开纹理贴图的方式中,图4所示的示意图一般不在图形用户界面中展示;在按步骤生成体素模型的展开纹理贴图的方式中,图4所示的示意图可以展示在图形用户界面中。It should also be noted that the texture map image obtained after splicing as shown in FIG. 4 may be displayed in the graphical user interface, or may not be displayed in the graphical user interface. Generally, in the method of generating the expanded texture map of the voxel model with one click, the schematic diagram shown in FIG. 4 is generally not displayed in the GUI; in the method of generating the expanded texture map of the voxel model by steps, the schematic diagram shown in FIG. The schematic diagram shown can be displayed in a graphical user interface.
在本申请一可选实施例中,上述基于所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标和所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成所述体素模型的外表面分别对应的纹理贴图图像的过程,可以包括:In an optional embodiment of the present application, based on the texture map coordinates of the texture map surface block in the expanded texture map and the orientation of the target quadrilateral surface on the voxel model, the target quadrilateral surfaces with the same orientation are The process of splicing the corresponding texture map surface blocks into texture map images corresponding to the outer surfaces of the voxel model may include:
根据所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标,对所述纹理贴图面块进行排序,得到所述纹理贴图面块的序号;According to the texture map coordinates of the texture map surface block in the expanded texture map, sort the texture map surface blocks to obtain the serial number of the texture map surface block;
根据所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块划分到同一个集合中;According to the orientation of the target quadrilateral face on the voxel model, the texture map surface blocks corresponding to the target quadrilateral face with the same orientation are divided into the same set;
对每个集合中的纹理贴图面块,根据所述纹理贴图面块的序号对同一个集合中的纹理贴图面块进行拼接,得到纹理贴图图像。For the texture map surface blocks in each set, the texture map surface blocks in the same set are spliced according to the serial numbers of the texture map surface blocks to obtain a texture map image.
在本实施例中,结合纹理贴图面块的序号对同朝向的纹理贴图面块进行拼接,可以确保拼接结果的准确性,且易于实现,即可以降低对应的脚本编写难度。In this embodiment, the texture map patches of the same orientation are spliced together with the serial numbers of the texture map patches, which can ensure the accuracy of the splicing result, and is easy to implement, that is, it can reduce the difficulty of corresponding script writing.
其中,对多个纹理贴图面块进行排序,得到纹理贴图面块的序号的过程,可以根据目标四边面在体素模型中的位置进行排序,确定对应纹理贴图面块的序号,也可以根据纹理贴图面块在展开纹理贴图中的纹理贴图坐标,对纹理贴图面块进行排序,得到纹理贴图面块的序号,该序号用于区分组成体素模型外表面的同一个平面的不同目标四边面对应的纹理贴图面块,以及用于决定拼接处理的顺序。Among them, the process of sorting multiple texture map surface blocks to obtain the serial number of the texture map surface block can be sorted according to the position of the target quadrilateral surface in the voxel model to determine the serial number of the corresponding texture map surface block, or according to the texture The texture map coordinates of the texture surface block in the expanded texture map, sort the texture map surface blocks, and obtain the serial number of the texture map surface block, which is used to distinguish the four sides of different targets of the same plane that make up the outer surface of the voxel model. The corresponding texture map patch, and used to determine the order of stitching processing.
在本实施例中,可以根据目标四边面的朝向,将朝向相同的目标四边面对应的纹理贴图面块划分到同一个集合中,对于每个集合中的纹理贴图面块,根据纹理贴图面块的序号,以及纹理贴图面块的纹理贴图坐标,确定任意两个纹理贴图面块重合的纹理贴图边缘,将重合的纹理贴图边缘进行拼接,当所有重合的纹理贴图边缘都拼接完毕后,得到的拼接后的图像即为纹理贴图图像。In this embodiment, the texture map surface blocks corresponding to the same target four-sided surface may be divided into the same set according to the orientation of the target four-sided surface, and for the texture map surface blocks in each set, according to the texture map surface The serial number of the block, and the texture map coordinates of the texture map surface block, determine the texture map edge of any two texture map surface blocks that overlap, and splicing the overlapping texture map edges. When all the overlapping texture map edges are spliced, we get The stitched image is the texture map image.
需要说明的是,纹理贴图面块的顺序并不会对拼接结果造成影响,因此,本申请实施例中,对纹理贴图面块的顺序的确定过程不作限制。It should be noted that the order of the texture map surface blocks does not affect the splicing result. Therefore, in the embodiment of the present application, the process of determining the order of the texture map surface blocks is not limited.
步骤104,将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图,其中,所述纹理贴图图像中的每个纹理贴图面块对应所述像素网格图中的一个像素。Step 104: Arrange the texture map image into a pixel grid map to obtain an expanded texture map of the voxel model, wherein each texture map surface block in the texture map image corresponds to the pixel grid A pixel in the grid.
本申请实施例中,将多个纹理贴图图像排布到像素网格图中,即多个纹理贴图图像在像素网格图中不重叠。纹理贴图图像中的每个纹理贴图面块对应像素网格图中的一个像素,即每个纹理贴图面块与像素网格图中的一个与之对应的像素重合,完成对体素模型的纹理贴图展开,也就是说,本步骤得到的在像素网格图中排布的多个纹理贴图图像,即为体素模型的展开纹理贴图。In this embodiment of the present application, multiple texture map images are arranged in the pixel grid map, that is, the multiple texture map images do not overlap in the pixel grid map. Each texture map surface block in the texture map image corresponds to a pixel in the pixel grid map, that is, each texture map surface block coincides with a corresponding pixel in the pixel grid map to complete the texture of the voxel model. Map expansion, that is to say, the multiple texture map images arranged in the pixel grid image obtained in this step are the expanded texture maps of the voxel model.
在本申请一些可选实施例中,在上述将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图之前,该方法还可以包括:In some optional embodiments of the present application, before the above-mentioned arranging the texture map image into the pixel grid map to obtain the expanded texture map of the voxel model, the method may further include:
根据所述体素模型的纹理贴图面块的数量确定像素网格图,所述像素网格图的像素数量不小于所述纹理贴图面块的数量。A pixel grid map is determined according to the number of texture map surface blocks of the voxel model, and the pixel number of the pixel grid map is not less than the number of texture map surface blocks.
本实施例可以根据体素模型的纹理贴面块的数量确定像素网格图,其中,像素网格图的像素数量不小于纹理贴图面块的数量,需要满足体素模型的纹理贴图图像可以按照一个纹理贴图面块与一个像素重合,且一个像素至多对应一个纹理贴图面块的要求排布到像素网格图中,得到体素模型的展开纹理贴图。In this embodiment, the pixel grid map may be determined according to the number of texture surface blocks of the voxel model, wherein the number of pixels of the pixel grid map is not less than the number of texture map surface blocks, and the texture map image that needs to satisfy the voxel model can be One texture map surface block coincides with one pixel, and one pixel corresponds to at most one texture map surface block and is arranged in the pixel grid map to obtain the expanded texture map of the voxel model.
在本申请一些可选实施例中,上述将多个纹理贴图图像排布到像素网格图中,可以包括:In some optional embodiments of the present application, the above-mentioned arrangement of multiple texture map images into a pixel grid map may include:
获取第一像素网格图;Get the first pixel grid image;
当所述第一像素网格图的像素数量小于所述纹理贴图面块的数量时,从像素网格图库中获取第二像素网格图,并将所述纹理贴图图像排布到所述第二像素网格图中,以得到所述体素模型的展开纹理贴图;所述第二像素网格图的像素数量不小于所述纹理贴图面块的数量;When the number of pixels of the first pixel grid image is less than the number of texture map surface blocks, acquire a second pixel grid image from the pixel grid library, and arrange the texture map image to the first pixel grid image. In a two-pixel grid map, to obtain an expanded texture map of the voxel model; the number of pixels in the second pixel grid map is not less than the number of texture map surface blocks;
当所述第一像素网格图的像素数量不小于所述纹理贴图面块的数量时,将所述纹理贴图图像排布到所述第一像素网格图中。When the number of pixels of the first pixel grid map is not less than the number of the texture map surface blocks, the texture map image is arranged in the first pixel grid map.
本实施例将多个纹理贴图图像排布到像素网格图中,可以先获取第一像素网格图,当第一像素网格图的像素数量小于体素模型的纹理贴图面块的数量时,可以认为体素模型的纹理贴图图像无法按照一个纹理贴图面块与一个像素重合,且一个像素至多对应一个纹理贴图面块的要求排布到第一像素网格图,此时从像素网格图库中,选择第二像素网格图,第二像素网格图的像素数量不小于纹理贴图面块的数量,第二像素网格图需要满足体素模型的纹理贴图图像可以按照一个纹理贴图面块与一个像素重合,且一个像素至多对应一个纹理贴图面块的要求排布到第二像素网格图中,得到体素模型的展开纹理贴图。当第一像素网格图的像素数量不小于体素模型的纹理贴图面块的数量时,也即体素模型的纹理贴图图像可以按照一个纹理贴图面块与一个像素重合,且一个像素至多对应一个纹理贴图面块的要求排布到第一像素网格图中时,可以直接将纹理贴图图像排布到第一像素网格图中,得到体素模型的展开纹理贴图;从而实现无需人工评估、手动更改像素网格图的效果。In this embodiment, multiple texture map images are arranged in a pixel grid map, and the first pixel grid map may be obtained first. When the number of pixels in the first pixel grid map is less than the number of texture map surface blocks of the voxel model , it can be considered that the texture map image of the voxel model cannot be arranged to the first pixel grid map according to the requirements of one texture map surface block and one pixel, and one pixel corresponds to at most one texture map surface block. In the library, select the second pixel grid image. The number of pixels in the second pixel grid image is not less than the number of texture map surface blocks. The second pixel grid map needs to meet the texture map image of the voxel model. The texture map image can be based on a texture map surface. The block coincides with one pixel, and one pixel corresponds to at most one texture map surface block and is arranged in the second pixel grid map to obtain the expanded texture map of the voxel model. When the number of pixels of the first pixel grid image is not less than the number of texture map surface blocks of the voxel model, that is, the texture map image of the voxel model can coincide with one pixel according to one texture map surface block, and one pixel corresponds to at most one pixel. When the requirements of a texture map surface block are arranged in the first pixel grid map, the texture map image can be directly arranged in the first pixel grid map to obtain the expanded texture map of the voxel model; thus, no manual evaluation is required. , to manually change the effect of the pixel grid image.
其中,第一像素网格图可以指当前使用的、用于排布纹理贴图图像的像素网格图。在一示例中,像素网格图库中可以按照像素网格图的尺寸,对存储的像素网格图按照尺寸从小到大的顺序排序,当当前像素网格图无法使得体素模型的纹理贴图图像按照一个纹理贴图面块与一个像素重合,且一个像素至多对应一个纹理贴图面块的要求排布时,根据当前像素网格图的排序顺序,将当前像素网格图更新为与其相邻的下一个排序顺序的像素网格图。当然,像素网格图库中的像素网格图也可以按照尺寸从大到小的顺序排序,当当前像素网格图排布不下时,根据当前像素网格图的排序顺序,将当前像素网格图更新为与其相邻的上一个排序顺序的像素网格图,继续执行将纹理贴图图像排布到当前像素网格图中的步骤。首次确定的当前像素网格图的尺寸可以由用户自定义设置,也可以由系统默认设置。The first pixel grid image may refer to a currently used pixel grid image for arranging texture map images. In an example, the pixel grid library can sort the stored pixel grid images in descending order of size according to the size of the pixel grid image. When the current pixel grid image cannot make the texture map image of the voxel model When one texture map surface block coincides with one pixel, and one pixel corresponds to at most one texture map surface block, according to the sorting order of the current pixel grid map, update the current pixel grid map to the next adjacent pixel map. A sorted pixel grid map. Of course, the pixel grid images in the pixel grid gallery can also be sorted in descending order of size. When the current pixel grid images cannot be arranged, the current pixel grid images are sorted according to the sorting order of the current pixel grid images. The map is updated to the pixel grid map of the last sorted order adjacent to it, continuing with the steps of arranging the texture map image into the current pixel grid map. The size of the current pixel grid image determined for the first time can be set by the user, and can also be set by the system by default.
示例性地,可以在图形用户界面中显示像素网格图尺寸的设置窗口,响应于针对像素网格图尺寸的设置操作,将设置操作对应的尺寸确定为当前像素网格图尺寸,并执行将多个纹理贴图图像排布到当前像素网格图中的过程,当排布不下时,即当前像素网格图无法使得体素模型的纹理贴图图像按照一个纹理贴图面块与一个像素重合,且一个像素至多对应一个纹理贴图面块的要求排布时,则从像素网格图库中,选择比当前像素网格图大一尺寸的像素网格图,并将选择的像素网格图确定为当前像素网格图,继续执行将多个纹理贴图图像排布到当前像素网格图中的过程。可选地,当像素网格图尺寸的设置窗口在指定时间内没有接收到用户的相关操作时,则可以采用系统默认设置的像素网格图,该系统默认设置的像素网格图可以是像素网格图库中尺寸最小的像素网格图;也可以是用户上一次自定义设置的像素网格图,例如,用户上一次自定义设置的像素网格图尺寸为128*128像素,则当用户再次执行对体素模型进行纹理贴图展开的触发操作时,此时,当前像素网格图的尺寸为128*128像素;还可以是上一次使用的像素网格图,上一次使用的像素网格图具体可以理解为在对上一个体素模型进行纹理贴图展开时,最终使用的像素网格图。还可以通过计算需要排布的多个纹理贴图图像所包含的纹理贴图面块的总数,确定像素网格图库中,像素比纹理贴图面块的总数多的像素网格图集合,并从该像素网格图集合中选择尺寸最小的像素网格图作为系统默认设置的像素网格图。Exemplarily, a setting window for the pixel grid image size may be displayed in the graphical user interface, and in response to the setting operation for the pixel grid image size, the size corresponding to the setting operation is determined as the current pixel grid image size, and the The process of arranging multiple texture map images into the current pixel grid map, when the current pixel grid map cannot make the texture map image of the voxel model coincide with a pixel according to a texture map surface block, and When one pixel corresponds to at most one texture map surface block, select a pixel grid image one size larger than the current pixel grid image from the pixel grid library, and determine the selected pixel grid image as the current pixel grid image. Pixel grid, continuing the process of arranging multiple texture map images into the current pixel grid. Optionally, when the setting window of the pixel grid image size does not receive a relevant operation from the user within the specified time, the pixel grid image set by default by the system can be used, and the pixel grid image set by default by the system can be pixel grid image. The pixel grid image with the smallest size in the grid library; it can also be the pixel grid image customized by the user last time. When the triggering operation to expand the texture map of the voxel model is performed again, at this time, the size of the current pixel grid is 128*128 pixels; it can also be the last used pixel grid, the last used pixel grid The image can be specifically understood as the pixel grid image that is finally used when the texture map of the previous voxel model is expanded. It is also possible to determine the set of pixel grids in the pixel grid library with more pixels than the total number of texture map blocks by calculating the total number of texture map blocks contained in multiple texture map images that need to be arranged, and from this pixel Select the pixel grid image with the smallest size in the grid image collection as the default pixel grid image of the system.
示例性地,也可以不显示像素网格图大小的设置窗口,直接采用系统默认设置的像素网格图。该系统默认设置的像素网格图可以是像素网格图库中尺寸最小的像素网格图,或者尺寸最大的像素网格图;也可以是上一次使用的像素网格图;还可以通过计算需要排布的多个纹理贴图图像所包含的纹理贴图面块的总数,即根据体素模型的纹理贴图面块的数量,从像素网格图库中,获取像素数量比纹理贴图面块的总数多的像素网格图作为系统默认设置的像素网格图。或者,根据体素模型的纹理贴图面块的数量,从像素网格图库中,获取像素数量比纹理贴图面块的数量多的像素网格图集合,并从该像素网格图集合中选择尺寸最小的像素网格图作为系统默认设置的像素网格图。Exemplarily, the setting window for the size of the pixel grid image may not be displayed, and the pixel grid image set by default by the system may be directly used. The pixel grid image set by default by the system can be the smallest pixel grid image in the pixel grid library, or the largest pixel grid image; it can also be the pixel grid image used last time; it can also be calculated as required The total number of texture map surface blocks contained in multiple texture map images arranged, that is, according to the number of texture map surface blocks of the voxel model, from the pixel grid library, the number of pixels obtained is more than the total number of texture map surface blocks. Pixel grid image as the default pixel grid image of the system. Or, according to the number of texture map patches of the voxel model, from the pixel grid library, obtain a pixel grid map set with more pixels than the number of texture map patches, and select a size from the pixel grid map set The smallest pixel grid image is used as the system default pixel grid image.
进一步地,为了防止纹理贴图展开得到的展开纹理贴图在后续进行贴图制作过程中出现溢色的情况,在本申请一可选实施例中,上述将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图的过程,包括:Further, in order to prevent the expanded texture map obtained by expanding the texture map from overflowing in the subsequent map making process, in an optional embodiment of the present application, the above-mentioned texture map image is arranged in the pixel grid map. , to obtain the unwrapped texture map of the voxel model, including:
将所述纹理贴图图像按照指定间隔排布到像素网格图中,以得到所述体素模型的展开纹理贴图。Arranging the texture map images into a pixel grid map at specified intervals to obtain an expanded texture map of the voxel model.
其中,指定间隔可以由用户自定义设置,也可以由系统默认设置。示例性地,可以在图形用户界面中显示指定间隔的设置窗口,响应于用户针对指定间隔的设置操作,将设置操作对应的像素确定为指定间隔,以将多个纹理贴图图像按照指定间隔排布到像素网格图中,得到体素模型的展开纹理贴图。示例性地,当指定间隔的设置窗口在预设显示时间内没有接收到用户的相关操作时,则可以采用系统默认设置的间隔作为指定间隔;其中,系统默认设置的间隔可以是一个固定的值,例如,系统默认设置的间隔可以是1个像素、3个像素、4个像素等;也可以是动态的值,该动态的值可以为上一次采用的指定间隔,该上一次采用的指定间隔可以是用户上一次自定义设置的指定间隔。The specified interval can be set by the user, or can be set by the system by default. Exemplarily, a setting window with a specified interval may be displayed in the graphical user interface, and in response to a user's setting operation for the specified interval, the pixels corresponding to the setting operation are determined as the specified interval, so as to arrange the plurality of texture map images according to the specified interval. To the pixel grid map, get the unwrapped texture map of the voxel model. Exemplarily, when the setting window of the specified interval does not receive the relevant operation of the user within the preset display time, the interval set by the system default can be used as the specified interval; wherein, the interval set by the system default can be a fixed value. , for example, the default interval set by the system can be 1 pixel, 3 pixels, 4 pixels, etc.; it can also be a dynamic value, the dynamic value can be the specified interval used last time, the specified interval used last time Can be the specified interval of the user's last custom setting.
示例性地,也可以不显示指定间隔的设置窗口,直接采用系统默认设置的指定间隔。系统默认设置的间隔可以是一个固定的值;也可以是动态的值,该动态的值可以为上一次采用的指定间隔,该上一次采用的指定间隔可以是用户上一次自定义设置的指定间隔。如图5所示,图5为图2所示的体素模型对应的展开纹理贴图,需要说明的是,图5未显示像素网格图中的像素网格;图5中标识出的纹理贴图图像即为图2中标识的平面对应的纹理贴图图像。体素模型对应的展开纹理贴图中,各个纹理贴图面块不重叠,大小与像素网格图的一个像素大小相等,并且展开纹理贴图中的各纹理贴图图像之间保持一定的间隔,以避免后续进行贴图制作过程中出现溢色的情况。Exemplarily, the setting window for the specified interval may not be displayed, and the specified interval set by the default system is directly used. The default interval set by the system can be a fixed value; it can also be a dynamic value, the dynamic value can be the specified interval used last time, and the specified interval used last time can be the specified interval set by the user last time. . As shown in Figure 5, Figure 5 is the expanded texture map corresponding to the voxel model shown in Figure 2. It should be noted that Figure 5 does not show the pixel grid in the pixel grid diagram; the texture map identified in Figure 5 The image is the texture map image corresponding to the plane identified in Figure 2. In the expanded texture map corresponding to the voxel model, each texture map surface block does not overlap, and the size is equal to the size of one pixel of the pixel grid map, and a certain interval is maintained between each texture map image in the expanded texture map to avoid subsequent Color overflow occurs in the process of map making.
本申请实施例通过获取待处理的体素模型的外表面包含的目标四边面,根据目标四边面在体素模型中的三维坐标,确定目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标,结合目标四边面在体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成体素模型的外表面分别对应的纹理贴图图像,最后将纹理贴图图像按照每个纹理贴图面块对应像素网格图中的一个像素的方式排布到像素网格图中,得到体素模型的展开纹理贴图;可以实现自动生成体素模型的展开纹理贴图,同时由于本申请实施例在生成体素模型的展开纹理贴图的过程中,先得到用于组成体素模型外表面的目标四边面对应的纹理贴图面块,再通过拼接得到纹理贴图图像,因此,还可以确保纹理贴图图像中的纹理贴图面块的一致性,解决了现有技术通过人工手动分割得到的纹理贴图面块不一致、通过人工手动摆放纹理贴图面块来得到展开纹理贴图,导致展开纹理贴图不准确且效率低的问题,本申请实施例提高了生成展开纹理贴图的效率和准确性。In this embodiment of the present application, the target quadrilateral surface included in the outer surface of the voxel model to be processed is obtained, and the texture map surface block corresponding to the target quadrilateral surface is determined in the expanded texture map according to the three-dimensional coordinates of the target quadrilateral surface in the voxel model. The texture map coordinates of the target four-sided surface on the voxel model are combined with the orientation of the target four-sided surface on the voxel model, the texture map surface blocks corresponding to the target four-sided surface with the same orientation are spliced into the texture map image corresponding to the outer surface of the voxel model, and finally the texture map image According to the way that each texture map surface block corresponds to one pixel in the pixel grid map, it is arranged in the pixel grid map to obtain the expanded texture map of the voxel model; the expanded texture map of the voxel model can be automatically generated. In the process of generating the unfolded texture map of the voxel model in the embodiment of the present application, the texture map surface blocks corresponding to the target four-sided surface used to form the outer surface of the voxel model are obtained first, and then the texture map image is obtained by splicing. It can ensure the consistency of the texture map surface blocks in the texture map image, and solve the inconsistency of the texture map surface blocks obtained by manual manual segmentation in the prior art. For the problem of inaccurate mapping and low efficiency, the embodiments of the present application improve the efficiency and accuracy of generating an unfolded texture map.
需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请实施例并不受所描述的动作顺序的限制,因为依据本申请实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本申请实施例所必须的。It should be noted that, for the sake of simple description, the method embodiments are expressed as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited by the described action sequence, because According to the embodiments of the present application, certain steps may be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
参照图6,示出了本申请的一种体素模型的纹理贴图展开装置实施例的结构框图,与上述体素模型的纹理贴图展开方法实施例相对应,该体素模型的纹理贴图展开装置,可以包括如下模块:Referring to FIG. 6, there is shown a structural block diagram of an embodiment of a texture map expansion device for a voxel model of the present application. Corresponding to the above-mentioned embodiment of the texture map expansion method for a voxel model, the texture map expansion device of the voxel model , which can include the following modules:
目标四边面获取模块601,用于获取待处理的体素模型的外表面包含的目标四边面;The target quadrilateral
纹理贴图面块生成模块602,用于根据所述目标四边面在所述体素模型中的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标;A texture map surface
纹理贴图图像生成模块603,用于基于所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标和所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块拼接成所述体素模型的外表面分别对应的纹理贴图图像;The texture map
展开纹理贴图生成模块604,用于将所述纹理贴图图像排布到像素网格图中,以得到所述体素模型的展开纹理贴图,其中,所述纹理贴图图像中的每个纹理贴图面块对应所述像素网格图中的一个像素。The expanded texture
在本申请一可选实施例中,所述体素模型由多个立方体组成,每个立方体具有六个四边面,所述目标四边面获取模块601,用于将立方体的四边面中不与其他立方体的四边面重合的四边面确定为组成所述体素模型外表面的目标四边面;或者,用于将多个立方体之间重合的四边面剔除,以得到组成所述体素模型外表面的目标四边面。In an optional embodiment of the present application, the voxel model is composed of a plurality of cubes, each cube has six four-sided surfaces, and the target four-sided
在本申请一可选实施例中,所述纹理贴图面块生成模块602,包括:In an optional embodiment of the present application, the texture map
第一获取模块,用于获取所述目标四边面的几何顶点的三维坐标;The first acquisition module is used to acquire the three-dimensional coordinates of the geometric vertices of the four-sided surface of the target;
纹理贴图坐标确定模块,用于根据所述几何顶点的三维坐标,确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。The texture map coordinate determination module is configured to determine the texture map coordinates of the texture map surface block corresponding to the target quadrilateral surface in the expanded texture map according to the three-dimensional coordinates of the geometric vertices.
在本申请一可选实施例中,所述纹理贴图坐标确定模块,用于将所述几何顶点的三维坐标换算成浮点数坐标,并基于所述浮点数坐标确定所述目标四边面对应的纹理贴图面块在展开纹理贴图中的纹理贴图坐标。In an optional embodiment of the present application, the texture map coordinate determination module is configured to convert the three-dimensional coordinates of the geometric vertices into floating-point coordinates, and determine the corresponding four-sided surface of the target based on the floating-point coordinates. Texture map coordinates of the texture map patch in the unwrapped texture map.
在本申请一可选实施例中,所述纹理贴图图像生成模块603,包括:In an optional embodiment of the present application, the texture map
排序模块,用于根据所述纹理贴图面块在展开纹理贴图中的纹理贴图坐标,对所述纹理贴图面块进行排序,得到所述纹理贴图面块的序号;a sorting module, configured to sort the texture map surface blocks according to the texture map coordinates of the texture map surface blocks in the expanded texture map to obtain the serial number of the texture map surface blocks;
分类模块,用于根据所述目标四边面在所述体素模型上的朝向,将相同朝向的目标四边面对应的纹理贴图面块划分到同一个集合中;A classification module, configured to divide the texture map face blocks corresponding to the target quadrilateral faces with the same orientation into the same set according to the orientation of the target quadrilateral face on the voxel model;
拼接模块,用于对每个集合中的纹理贴图面块,根据所述纹理贴图面块的序号对同一个集合中的纹理贴图面块进行拼接,得到纹理贴图图像。The splicing module is used for splicing the texture map surface blocks in the same set according to the serial numbers of the texture map surface blocks to obtain a texture map image.
在本申请一可选实施例中,所述装置还包括:In an optional embodiment of the present application, the device further includes:
网格图确定模块,用于根据所述体素模型的纹理贴图面块的数量确定像素网格图,所述像素网格图的像素数量不小于所述纹理贴图面块的数量。A grid map determination module, configured to determine a pixel grid map according to the number of texture map surface blocks of the voxel model, where the number of pixels of the pixel grid map is not less than the number of texture map surface blocks.
在本申请一可选实施例中,所述展开纹理贴图生成模块604,包括:In an optional embodiment of the present application, the expanded texture
网格图获取模块,用于获取第一像素网格图;a grid image acquisition module, used to acquire the first pixel grid image;
第一生成模块,用于当所述第一像素网格图的像素数量小于所述纹理贴图面块的数量时,从像素网格图库中获取第二像素网格图,并将所述纹理贴图图像排布到所述第二像素网格图中,以得到所述体素模型的展开纹理贴图;所述第二像素网格图的像素数量不小于所述纹理贴图面块的数量;The first generation module is configured to obtain a second pixel grid image from the pixel grid library when the number of pixels of the first pixel grid image is less than the number of the texture map surface blocks, and use the texture map to obtain a second pixel grid image. The images are arranged in the second pixel grid map to obtain the expanded texture map of the voxel model; the number of pixels in the second pixel grid map is not less than the number of texture map surface blocks;
第二生成模块,用于当所述第一像素网格图的像素数量不小于所述纹理贴图面块的数量时,将所述纹理贴图图像排布到所述第一像素网格图中。A second generating module, configured to arrange the texture map image into the first pixel grid map when the number of pixels of the first pixel grid map is not less than the number of the texture map surface blocks.
在本申请一可选实施例中,所述展开纹理贴图生成模块604,用于将所述纹理贴图图像按照指定间隔排布到像素网格图中,以得到所述体素模型的展开纹理贴图。In an optional embodiment of the present application, the expanded texture
对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。As for the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for related parts.
本申请实施例还公开了电子设备,包括处理器、存储器及存储在所述存储器上并能够在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行时实现如上所述的体素模型的纹理贴图展开方法的步骤。The embodiment of the present application also discloses an electronic device, including a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program being executed by the processor to achieve the above-mentioned The steps of the texture map unwrapping method of the voxel model.
本申请实施例还公开了计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现如上所述的体素模型的纹理贴图展开方法的步骤。Embodiments of the present application further disclose 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 steps of the above-described texture map expansion method for a voxel model are implemented.
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same and similar parts between the various embodiments may be referred to each other.
本领域内的技术人员应明白,本申请实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本申请实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the embodiments of the present application may be provided as methods, apparatuses, or computer program products. Accordingly, the embodiments of the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请实施例是参照根据本申请实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The embodiments of the present application are described with reference to the flowcharts and/or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing terminal equipment to produce a machine that causes the instructions to be executed by the processor of the computer or other programmable data processing terminal equipment Means are created for implementing the functions specified in the flow or flows of the flowcharts and/or the blocks or blocks of the block diagrams.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal equipment to operate in a particular manner, such that the instructions stored in the computer readable memory result in an article of manufacture comprising instruction means, the The instruction means implement the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing terminal equipment, so that a series of operational steps are performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby executing on the computer or other programmable terminal equipment The instructions executed on the above provide steps for implementing the functions specified in the flowchart or blocks and/or the block or blocks of the block diagrams.
尽管已描述了本申请实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请实施例范围的所有变更和修改。Although the preferred embodiments of the embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once the basic inventive concepts are known. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications that fall within the scope of the embodiments of the present application.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。Finally, it should also be noted that in this document, relational terms such as first and second are used only to distinguish one entity or operation from another, and do not necessarily require or imply these entities or that there is any such actual relationship or sequence between operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion such that a process, method, article or terminal device that includes a list of elements includes not only those elements, but also a non-exclusive list of elements. other elements, or also include elements inherent to such a process, method, article or terminal equipment. Without further limitation, an element defined by the phrase "comprises a..." does not preclude the presence of additional identical elements in the process, method, article or terminal device comprising said element.
以上对本申请所提供的一种体素模型的纹理贴图展开方法及装置、电子设备和存储介质,进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The above provides a detailed introduction to a texture map expansion method and device for a voxel model, an electronic device and a storage medium provided by the present application. Specific examples are used in this paper to illustrate the principles and implementations of the present application. The above implementation The description of the example is only used to help understand the method of the present application and its core idea; meanwhile, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific embodiment and the scope of application. As stated, the contents of this specification should not be construed as limiting the application.
Claims (11)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210515659.5A CN114782606B (en) | 2022-05-12 | 2022-05-12 | Texture mapping expansion method and device for voxel model, electronic equipment, and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210515659.5A CN114782606B (en) | 2022-05-12 | 2022-05-12 | Texture mapping expansion method and device for voxel model, electronic equipment, and medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114782606A true CN114782606A (en) | 2022-07-22 |
CN114782606B CN114782606B (en) | 2025-06-24 |
Family
ID=82437716
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210515659.5A Active CN114782606B (en) | 2022-05-12 | 2022-05-12 | Texture mapping expansion method and device for voxel model, electronic equipment, and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114782606B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118627166A (en) * | 2024-06-12 | 2024-09-10 | 北京工业大学 | Method, device and program product for automatic generation of two-dimensional geological finite element model grid |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110234583A1 (en) * | 2010-01-04 | 2011-09-29 | Reuven Bakalash | Method and apparatus for parallel ray-tracing employing modular space division |
US20140015834A1 (en) * | 2012-07-09 | 2014-01-16 | Samsung Electronics Co., Ltd. | Graphics processing unit, image processing apparatus including graphics processing unit, and image processing method using graphics processing unit |
CN111727461A (en) * | 2018-01-16 | 2020-09-29 | 索尼公司 | Information processing apparatus and method |
CN113643191A (en) * | 2020-04-27 | 2021-11-12 | 北京蓝亚盒子科技有限公司 | Smoothing method and device for voxel model and electronic equipment |
CN113947657A (en) * | 2021-10-18 | 2022-01-18 | 网易(杭州)网络有限公司 | Target model rendering method, device, equipment and storage medium |
-
2022
- 2022-05-12 CN CN202210515659.5A patent/CN114782606B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110234583A1 (en) * | 2010-01-04 | 2011-09-29 | Reuven Bakalash | Method and apparatus for parallel ray-tracing employing modular space division |
US8189001B2 (en) * | 2010-01-04 | 2012-05-29 | Adshir Ltd. | Method and apparatus for parallel ray-tracing employing modular space division |
US20140015834A1 (en) * | 2012-07-09 | 2014-01-16 | Samsung Electronics Co., Ltd. | Graphics processing unit, image processing apparatus including graphics processing unit, and image processing method using graphics processing unit |
CN111727461A (en) * | 2018-01-16 | 2020-09-29 | 索尼公司 | Information processing apparatus and method |
CN113643191A (en) * | 2020-04-27 | 2021-11-12 | 北京蓝亚盒子科技有限公司 | Smoothing method and device for voxel model and electronic equipment |
CN113947657A (en) * | 2021-10-18 | 2022-01-18 | 网易(杭州)网络有限公司 | Target model rendering method, device, equipment and storage medium |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118627166A (en) * | 2024-06-12 | 2024-09-10 | 北京工业大学 | Method, device and program product for automatic generation of two-dimensional geological finite element model grid |
Also Published As
Publication number | Publication date |
---|---|
CN114782606B (en) | 2025-06-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110443893B (en) | Large-scale building scene rendering acceleration method, system, device and storage medium | |
CN104574501B (en) | A kind of high-quality texture mapping method for complex three-dimensional scene | |
CN110838129A (en) | Three-dimensional building model contour characteristic line extraction method based on oblique photogrammetry | |
CN111133472B (en) | Method and apparatus for infrastructure design using 3D reality data | |
CN104504760B (en) | The method and system of real-time update 3-D view | |
CN114241151B (en) | Three-dimensional model simplification method, three-dimensional model simplification device, computer equipment and computer storage medium | |
US11579466B2 (en) | Method, device, apparatus and computer readable storage medium of simulating volumetric 3D display | |
CN106127743B (en) | The method and system of automatic Reconstruction bidimensional image and threedimensional model accurate relative location | |
CN111273877A (en) | Linkage display platform and linkage method for live-action three-dimensional data and two-dimensional grid picture | |
CN113034688B (en) | Three-dimensional map model generation method and device | |
CN111815788A (en) | Three-dimensional map processing method, device, equipment and storage medium | |
CN113129420B (en) | A ray tracing rendering method based on depth buffer acceleration | |
CN101271588B (en) | Reconstructable Geometry Shadow Map Method | |
CN114782606A (en) | Voxel model texture map unfolding method and device, electronic device and medium | |
US6518964B1 (en) | Apparatus, system, and method for simplifying annotations on a geometric surface | |
CN111080760B (en) | Oblique photogrammetry data optimization method and system | |
CN117557740B (en) | Three-dimensional model segmentation level switching method and device, electronic equipment and storage medium | |
JP7368950B2 (en) | Method and apparatus for efficient building footprint identification | |
CN116704098B (en) | Method, device, electronic device and storage medium for generating directed distance field | |
CN111773710A (en) | Texture image processing method and device, electronic equipment and storage medium | |
CN115131513B (en) | A three-dimensional terrain clipping method, device, equipment and readable storage medium | |
CN115690299A (en) | Cultural relic scanning model type tape map topological method and system | |
US9734579B1 (en) | Three-dimensional models visual differential | |
CN108171784A (en) | A kind of rendering intent and terminal | |
CN120236018B (en) | A method, device and storage medium for displaying three-dimensional illustrations |
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 |