CPC G06T 17/00 (2013.01) [G06T 7/13 (2017.01); G06T 7/60 (2013.01); G06T 15/04 (2013.01)] | 6 Claims |
1. A method for adaptively rendering a fan-shaped image to a 3D model, comprising the following steps:
S10: importing a 3D model and a fan-shaped image;
S20: setting UV coordinates of top-left, bottom-left, top-right and bottom-right vertices of a sampling area based on the fan-shaped image;
S30: based on the UV coordinates of the four vertices of the sampling area, fitting two concentric circles corresponding to upper and lower arcs of the fan-shaped image, and obtaining the UV coordinates of a center O of the two concentric circles;
S40: based on the UV coordinates of the four vertices of the sampling area, fitting two left and right side line segments of the fan-shaped image in the sampling area, and denoting them as left_line and right_line respectively;
S50: selecting any triangular facet in a rendering area of the 3D model as a traversal starting triangle, and starting from the traversal starting triangle to traverse all triangular facets in the rendering area through an edge traversal method;
S60: traversing triangular facet in a triangle queue and executing a vertex to UV point mapping algorithm for the 3D model, i.e., for each vertex V(xi,yi,zi) of triangular facet, locating a corresponding UV mapping point V′(xi′,yi′,zi′) on the fan-shaped image, to obtain UV texture coordinate data of the 3D model mapped onto the fan-shaped image; and
S70: sending the UV texture coordinate data to the rendering area of the 3D model to obtain an actual rendering effect of the fan-shaped image in the 3D model;
the S60 comprises:
S61: determining upper and lower edges of the rendering area of the 3D model to calculate a height of the rendering area; locating upper and lower intersection points where the upper and lower edges intersect with a seam line, wherein the two intersection points are respectively named as an upper starting point of rendering and a lower starting point of rendering;
S62: selecting any rendering starting point to determine a side length of the left_line, i.e., a height of the sampling area; defining coordinates S (x0,y0,z0) of a rendering starting point S in a rectangular coordinate system of a three-dimensional cone;
S63: calculating a height scaling ratio k between the rendering area and the sampling area, wherein k=the height of the sampling area/the height of the rendering area;
S64: creating a circular section perpendicular to a central axis of the 3D model through the upper starting point S, and intersecting the central axis at a point O′ to obtain a vector O'S;
S65: creating a circular section perpendicular to the central axis of the 3D model through the vertex V(xi, yi, zi), and intersecting the central axis at a point O″ to obtain a vector O″V;
S66: rotating the vector O'S to be parallel to the point O″V to obtain a vector O'S′, wherein a point S′ is a point on an outer surface of the 3D model;
S67: based on a cross product of the vector O'S and the vector O″V, calculating an angle θ at which the vector O'S rotates to the vector O'S′;
S68: based on the calculated angle θ, calculating spatial coordinates S′ (x′, y′, z′) of the point S′, and then calculating a spatial length d from the point S′ to the vertex V(xi, yi, zi); and
S69: based on the height scaling ratio k and the spatial length d, calculating the UV mapping point V′ of the vertex V on the fan-shaped image.
|