CN102117501B - Method and device for rendering three-dimensional lines - Google Patents

Method and device for rendering three-dimensional lines Download PDF

Info

Publication number
CN102117501B
CN102117501B CN200910258952.2A CN200910258952A CN102117501B CN 102117501 B CN102117501 B CN 102117501B CN 200910258952 A CN200910258952 A CN 200910258952A CN 102117501 B CN102117501 B CN 102117501B
Authority
CN
China
Prior art keywords
dimentional
apex coordinate
value
polygonal
apex
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.)
Expired - Fee Related
Application number
CN200910258952.2A
Other languages
Chinese (zh)
Other versions
CN102117501A (en
Inventor
叶伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba China Co Ltd
Original Assignee
Xiamen Autonavi Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiamen Autonavi Software Co Ltd filed Critical Xiamen Autonavi Software Co Ltd
Priority to CN200910258952.2A priority Critical patent/CN102117501B/en
Publication of CN102117501A publication Critical patent/CN102117501A/en
Application granted granted Critical
Publication of CN102117501B publication Critical patent/CN102117501B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Generation (AREA)

Abstract

The invention provides a method and device for rendering three-dimensional lines. The method comprises the following steps of: projecting an (n-1)th three-dimensional vertex coordinate and an nth three-dimensional vertex coordinate in a preset three-dimensional vertex coordinate set to an XZ plane to obtain the (n-1)th two-dimensional vertex coordinate and the nth two-dimensional vertex coordinate; calculating four two-dimensional vertex coordinates of a polygon according to a given line width and an included angle between X-axis and a straight line formed between the (n-1)th two-dimensional vertex coordinate and the nth two-dimensional vertex coordinate; and reducing the four two-dimensional vertex coordinates of the polygon into four three-dimensional vertex coordinates, and filling the polygon formed by the four three-dimensional vertex coordinates to obtain an (n-1)th line segment, wherein n is a natural number larger than or equal to 2. The invention further provides a device for rendering the three-dimensional lines to realize the method. The three-dimensional line rendering technical scheme provided by the invention does not render lines in a screen two-dimensional space (an XY plane), but renders the lines based on real three-dimensional space coordinates, thereby finally making the rendered lines have a three-dimensional space perspective effect.

Description

A kind of 3D lines method for drafting and device
Technical field
The present invention relates to computer graphics disposal technology field, relate in particular to a kind of 3D lines method for drafting and device.
Background technology
Computer graphics (Computer Graphics, CG) be to develop in recent decades rapid, widely used new branch of science, how presentation graphic in computing machine of to the effect that research, and utilize computing machine to carry out calculating, processing and the demonstration of figure.
The development of computer graphics is mainly divided into two stages, and in a 2D (2-Dimensinal) the figure stage, another is 3D (3-Dimensinal) the figure stage.At present, DirectX and OpenGL are two 3D graphical development platforms of main flow, these two platforms realize virtual reality play up aspect performance all very outstanding, but be not but very desirable in effect aspect the drafting of 3D lines.
The existing 3D lines method for drafting based on DirectX mainly comprises the steps: given line width and one group of 3D coordinate, first calculate four apex coordinates of corresponding polygon (rectangle) according to first and second 3D coordinate and live width, then fill the polygon being formed by these four apex coordinates and form one section of line segment, then to second and the 3rd 3D coordinate, the 3rd and the 4th 3D coordinate, ..., n-1 is carried out same processing with n 3D coordinate, until handle last the 3D coordinate in above-mentioned 3D set of coordinates, obtain 3D lines.
The existing 3D lines method for drafting based on OpenGL is substantially identical with the scheme based on DirectX, in the time of draw line segments, not just filled polygon, but draw lines with " brush " that a width is live width, when line segment slope is [1,1] time, brush direction is vertical, and line segment slope is not [1,1], time, brush direction is level.
In the research and practice process to prior art, inventor finds the coordinate that polygonal four apex coordinates that the existing 3D lines method for drafting based on DirectX calculates according to given 3D coordinate are 2D space (XY spaces), and the polygon being made up of the apex coordinate in 2D space is planar graph, therefore, the lines that prior art is finally drawn out only have the plane effect in 2D space, and without the transparent effect of 3d space.And the lines that 3D lines method for drafting based on OpenGL is drawn out are not only without the transparent effect of 3d space, and lines have the inconsistent phenomenon of thickness.
Summary of the invention
The technical matters that the embodiment of the present invention will solve is to provide a kind of 3D lines method for drafting and device, can draw out the lines with 3d space transparent effect.
For solving the problems of the technologies described above, the object of the invention is to be achieved through the following technical solutions:
The embodiment of the present invention provides a kind of 3D lines method for drafting, and described method comprises:
By the n-1 in preset three-dimensional vertices set of coordinates and n three-dimensional vertices coordinate projection to XZ plane, obtain n-1 with the individual two-dimentional apex coordinate of n;
According to the straight line of n-1 and n two-dimentional apex coordinate formation and the angle of X-axis, and given live width, polygonal four two-dimentional apex coordinates calculated;
Described polygonal four two-dimentional apex coordinates are reduced to four three-dimensional vertices coordinates, fill the polygon being formed by four three-dimensional vertices coordinates, obtain n-1 article of line segment; Wherein, n is more than or equal to 2 natural number.
The embodiment of the present invention also provides a kind of 3D lines drawing apparatus, and described device comprises:
Two-dimensional coordinate projecting cell, for by the n-1 of preset three-dimensional vertices set of coordinates and n three-dimensional vertices coordinate projection to XZ plane, obtain n-1 with the individual two-dimentional apex coordinate of n;
Apex coordinate computing unit, for the straight line of and n two-dimentional apex coordinate formation individual according to n-1 and the angle of X-axis, and given live width, calculate polygonal four two-dimentional apex coordinates;
Three-dimensional coordinate reduction unit, for being reduced to four three-dimensional vertices coordinates by described polygonal four two-dimentional apex coordinates;
Lines drawing unit, for filling the polygon being made up of four three-dimensional vertices coordinates, obtains n-1 article of line segment; Wherein, n is more than or equal to 2 natural number.
Technique scheme has following beneficial effect:
The 3D lines rendering technique that the embodiment of the present invention provides, before filled polygon, polygonal four two-dimentional apex coordinates are reduced to four three-dimensional vertices coordinates, the polygon forming due to four three-dimensional vertices coordinates is no longer two-dimensional space figure but three dimensions figure, therefore, the technical scheme that the embodiment of the present invention provides is not to draw lines at screen two-dimensional space (XY plane), but draw lines based on true three-dimension volume coordinate, finally make the lines of drawing there is 3d space transparent effect.
Accompanying drawing explanation
The 3D lines method for drafting process flow diagram that Fig. 1 provides for the embodiment of the present invention;
The 3D lines drawing apparatus composition schematic diagram that Fig. 2 provides for the embodiment of the present invention;
The 3D lines design sketch that Fig. 3 draws for the 3D lines method for drafting that the employing embodiment of the present invention provides.
Embodiment
For making object, technical scheme and the advantage of the embodiment of the present invention clearer, the technical scheme embodiment of the present invention being provided referring to accompanying drawing is elaborated.
Referring to Fig. 1, is a kind of 3D lines method for drafting that the embodiment of the present invention provides, and the method comprises the steps:
Step 101: by n-1 three-dimensional vertices coordinate (x in preset three-dimensional vertices set of coordinates n-1, y n-1, z n-1) and n three-dimensional vertices coordinate (x n, y n, z n) project to XZ plane, obtain n-1 two-dimentional apex coordinate (x n-1, z n-1) and n two-dimentional apex coordinate (x n, z n), n is more than or equal to 2 natural number;
Wherein, three-dimensional vertices coordinate projection is referred to the y value of three-dimensional vertices coordinate is ignored or is made as zero to XZ plane.
Step 102: according to the straight line of n-1 and n two-dimentional apex coordinate formation and the angle of X-axis, and given live width, calculate polygonal four two-dimentional apex coordinates;
Step 103: described polygonal four two-dimentional apex coordinates are reduced to four three-dimensional vertices coordinates;
Wherein, described polygonal four two-dimentional apex coordinates being reduced to four three-dimensional vertices coordinates is specially: by the z of n-1 three-dimensional vertices coordinate n-1as according to the Z on polygonal two summits of its calculating, by the z of n three-dimensional vertices coordinate nas according to the Z on polygonal two summits of its calculating.
Such as, calculate polygonal first and second two-dimentional apex coordinate according to n-1 three-dimensional vertices coordinate, calculate polygonal the 3rd and the 4th two-dimentional apex coordinate according to n three-dimensional vertices coordinate, in the time reducing, by z n-1as the Z of first and second apex coordinate, by z nas the Z of the 3rd and the 4th apex coordinate.
Step 104: fill the polygon being formed by four three-dimensional vertices coordinates, obtain n-1 article of line segment.
The stuffing function that can call in DirectX/OpenGL in actual applications, is filled the polygon of four three-dimensional vertices coordinates formations and carries out anti-aliasing processing.
The 3D lines method for drafting providing for the embodiment of the present invention above, the method is reduced to four three-dimensional vertices coordinates by polygonal four two-dimentional apex coordinates before filled polygon, the polygon forming due to four three-dimensional vertices coordinates is no longer two-dimensional space figure but three dimensions figure, therefore, the technical scheme that the embodiment of the present invention provides is not to draw lines at screen two-dimensional space (XY plane), but draw lines based on true three-dimension volume coordinate, finally make the lines of drawing there is 3d space transparent effect.
The method embodiment of the present invention being provided below in conjunction with instantiation describes in detail.Suppose, in preset three-dimensional vertices set of coordinates, there is m three-dimensional vertices coordinate, first first and second three-dimensional vertices coordinate in three-dimensional vertices set of coordinates are processed according to method shown in Fig. 1, obtain Article 1 line segment, if also have coordinate in described set of coordinates, second and the 3rd three-dimensional vertices coordinate are processed according to method shown in Fig. 1 again, obtain Article 2 line segment, if also have coordinate in described set of coordinates, repeat method shown in Fig. 1, until handle coordinates all in set of coordinates, finally obtain a 3D line segment.
It should be noted that in the time that m is more than or equal to 3, can obtain at least two line segments, in order to make smooth connection between every line segment, in said method, may further include:
Fill the n-2 line segment and the n-1 article of polygon that four adjacent three-dimensional vertices coordinates of line segment form that have obtained, make n-2 line segment and n-1 article of line segment smooth connection.
Such as, obtain after Article 2 line segment, the polygon that Article 1 line segment four three-dimensional vertices adjacent with Article 2 line segment that filling has obtained form, obtain after Article 3 line segment, fill the polygon of four three-dimensional vertices coordinates formations that Article 2 line segment is adjacent with Article 3 line segment, ..., by that analogy.
Following according to the situation of n-1 and n two-dimentional apex coordinate and X-axis angle, the process of polygonal four the two-dimentional apex coordinates of described calculating is above described in detail.
Suppose that polygonal four two-dimentional summits are respectively (X 1, Z 1), (X 2, Z 2), (X 3, Z 3) and (X 4, Z 4), given live width is LineWidth,
The 1st kind, n-1 two-dimentional apex coordinate (x n-1, z n-1) and n two-dimentional apex coordinate (x n, z n) form straight line parallel in X-axis, i.e. z n-1=z n, calculate polygonal four two-dimentional apex coordinates and be specially:
X 1=x n-1,Z 1=z n-1+LineWidth/2;X 2=x n-1;,Z 2=z n-1-LineWidth/2;
X 3=x n,Z 3=z n-LineWidth/2;X 4=x n,Z 4=z n+LineWidth/2;
The 2nd kind, n-1 and n the straight line that two-dimentional apex coordinate forms be perpendicular to X-axis, i.e. x n-1=x n, calculate polygonal four two-dimentional apex coordinates and be specially:
X 1=x n-1-LineWidth/2,Z 1=z n-1;X 2=x n-1+LineWidth/2,Z 2=z n-1
X 3=x n+LineWidth/2,Z 3=z n;X 4=x n-LineWidth/2,Z 4=z n
The 3rd kind, the straight line of n-1 and n two-dimentional apex coordinate formation had both been not orthogonal to X-axis, was also not parallel to X-axis, calculated polygonal four two-dimentional apex coordinates and was specially:
Calculate the straight line of n-1 and n two-dimentional apex coordinate formation and the angle theta of X-axis;
In actual applications, angle theta can adopt following formula to calculate:
θ=atan[(z n-z n-1)/(x n-x n-1)], atan is the built-in function that can directly call.
Be multiplied by LineWidth/2 with the absolute value of sin θ, obtain X-axis side-play amount OffsetX;
Be multiplied by LineWidth/2 with the absolute value of cos θ, obtain Z axis side-play amount OffsetZ;
Judge the quadrant at angle theta place, according to the quadrant at angle theta place, n-1 and the individual two-dimentional apex coordinate of n and OffsetX and OffsetZ, calculate polygonal four two-dimentional apex coordinates.
If angle theta is first or third quadrant, i.e. 270 ° of 90 ° or 180 ° < angle theta < of 0 ° of < angle theta <, calculate polygonal four two-dimentional apex coordinates and are specially:
X 1=x n-1-OffsetX,Z 1=z n-1+OffsetZ;X 2=x n-1+OffsetX,Z 2=z n-1-OffsetZ;
X 3=x n-OffsetX,Z 3=z n+OffsetZ;X 4=x n+OffsetX;,Z 4=z n-OffsetZ;
If angle is second or fourth quadrant, i.e. 360 ° of 180 ° or 270 ° < angle theta < of 90 ° of < angle theta <, calculate polygonal four two-dimentional apex coordinates and are specially:
Judge whether n-1 be less than or equal to 1 with n the straight slope of two-dimentional apex coordinate structure, is more than or equal to and bears 1, if so,
X 1=x n-1+OffsetX,Z 1=z n-1+OffsetZ;X 2=x n-1-OffsetX,Z 2=z n-1-OffsetZ;
X 3=x n+OffsetX,Z 3=z n+OffsetZ;X 4=x n-OffsetX;,Z 4=z n-OffsetZ;
If not,
X 1=x n-1-OffsetX,Z 1=z n-1-OffsetZ;X 2=x n-1+OffsetX,Z 2=z n-1+OffsetZ;
X 3=x n-OffsetX,Z 3=z n-OffsetZ;X 4=x n+OffsetX;,Z 4=z n+OffsetZ。
The 3D lines the method for drafting above embodiment of the present invention being provided is described in detail, and the 3D lines drawing apparatus of the realizing said method embodiment of the present invention being provided below in conjunction with accompanying drawing describes in detail
Referring to Fig. 2, is the 3D lines drawing apparatus composition schematic diagram that the embodiment of the present invention provides, and this device comprises:
Two-dimensional coordinate projecting cell 201, for by the n-1 of preset three-dimensional vertices set of coordinates and n three-dimensional vertices coordinate projection to XZ plane, obtain n-1 with the individual two-dimentional apex coordinate of n;
Apex coordinate computing unit 202, for the straight line of and n two-dimentional apex coordinate formation individual according to n-1 and the angle of X-axis, and given live width, calculate polygonal four two-dimentional apex coordinates;
Three-dimensional coordinate reduction unit 203, for being reduced to four three-dimensional vertices coordinates by described polygonal four two-dimentional apex coordinates;
Lines drawing unit 204, for filling the polygon being made up of four three-dimensional vertices coordinates, obtains n-1 article of line segment; Wherein, n is more than or equal to 2 natural number.
It should be noted that in the time that m is more than or equal to 3, can obtain at least two line segments, in order to make smooth connection between every line segment, in said apparatus, may further include:
Connecting line segment drawing unit, for filling the n-2 line segment and the n-1 article of polygon that four adjacent three-dimensional vertices coordinates of line segment form that have obtained, makes n-2 line segment and n-1 article of line segment smooth connection.
The 3D lines drawing apparatus providing for the embodiment of the present invention above, below according to the situation of n-1 and n two-dimentional apex coordinate and X-axis angle, the specific implementation of described apex coordinate computing unit 202 is above described in detail.
The first, the straight line parallel of n-1 and n two-dimentional apex coordinate formation is in X-axis, and described apex coordinate computing unit 202 specifically comprises:
First and second summit computing unit, for being assigned to xn-1 polygonal first and second two-dimentional apex coordinate X 1and X 2; Use z n-1add LineWidth/2, obtain the Z of polygonal first two-dimentional apex coordinate 1; Use z n-1deduct LineWidth/2, obtain the Z of polygonal second two-dimentional apex coordinate 2;
Second and third summit computing unit, for by x nbe assigned to the X of polygonal the 3rd and the 4th two-dimentional apex coordinate 3and X 4; Use z nadd LineWidth/2, obtain the Z of polygonal the 3rd two-dimentional apex coordinate 3; Use z ndeduct LineWidth/2, obtain the Z of polygonal the 4th two-dimentional apex coordinate 4.
The second, the straight line of n-1 and n two-dimentional apex coordinate formation is perpendicular to X-axis, and described apex coordinate computing unit 202 specifically comprises:
First and second apex coordinate computing unit, for by z n-1value is assigned to the Z of polygonal first and second two-dimentional apex coordinate 1and Z 2, use x n-1add LineWidth/2, obtain the X of polygonal first two-dimentional apex coordinate 1, use x n-1deduct LineWidth/2, obtain the X of polygonal second two-dimentional apex coordinate 2;
Second and third apex coordinate computing unit, for by z nbe assigned to the Z of polygonal the 3rd and the 4th two-dimentional apex coordinate 3and Z 4, use x nadd LineWidth/2, obtain the X of polygonal the 3rd two-dimentional apex coordinate 3, use x ndeduct LineWidth/2, obtain the X of polygonal the 4th two-dimentional apex coordinate 4.
The third, the straight line of n-1 and n two-dimentional apex coordinate formation had both been not orthogonal to X-axis, was also not parallel to X-axis, and apex coordinate computing unit 202 specifically comprises:
Included angle of straight line computing unit, for calculating the straight line of n-1 and n two-dimentional apex coordinate formation and the angle theta of X-axis;
X-axis side-play amount computing unit, for be multiplied by the half of given live width with the absolute value of sin θ, obtains X-axis side-play amount OffsetX;
Z axis side-play amount computing unit, for be multiplied by the half of given live width with the absolute value of cos θ, obtains Z axis side-play amount OffsetZ;
Included angle of straight line quadrant judging unit, for judging the quadrant at angle theta place;
Apex coordinate computation subunit, for according to the quadrant at angle theta place, n-1 and n two-dimentional apex coordinate and X-axis side-play amount and Z axis side-play amount, calculate polygonal four two-dimentional apex coordinates.
Wherein, if the judgement of included angle of straight line quadrant judging unit obtains 270 ° of 90 ° or 180 ° < angle theta < of described 0 ° of < angle theta <, described apex coordinate computation subunit specifically comprises:
The first apex coordinate computing unit, for using x n-1deduct OffsetX, obtain the X of polygonal first two-dimentional apex coordinate 1, use z n-1add OffsetZ, obtain the Z of polygonal first two-dimentional apex coordinate 1;
The second apex coordinate computing unit, uses x n-1add OffsetX, obtain the X of polygonal second two-dimentional apex coordinate 2, use z n-1deduct OffsetZ, obtain the Z of polygonal first two-dimentional apex coordinate 2;
The 3rd apex coordinate computing unit, for using x ndeduct OffsetX, obtain the X of polygonal the 3rd two-dimentional apex coordinate 3, use z nadd OffsetZ, obtain the Z of polygonal the 3rd two-dimentional apex coordinate 3;
The 4th apex coordinate computing unit, for using x nadd OffsetX, obtain the X of polygonal the 4th two-dimentional apex coordinate 4; Use z ndeduct OffsetZ, obtain the Z of polygonal the 4th two-dimentional apex coordinate 4.
If the judgement of included angle of straight line quadrant judging unit obtains 360 ° of 180 ° or 270 ° < angle theta < of described 90 ° of < angle theta <, described apex coordinate computation subunit specifically comprises:
Straight slope judging unit.Judge that if be used for whether described n-1 be less than or equal to 1 with n the straight slope of two-dimentional apex coordinate structure, is more than or equal to negative 1;
The first apex coordinate computing unit 1, for being less than or equal to 1 at slope, is more than or equal at negative 1 o'clock, uses x n-1add OffsetX, obtain the X of polygonal first two-dimentional apex coordinate 1; Use z n-1add OffsetZ, obtain the Z of polygonal first two-dimentional apex coordinate 1;
The second apex coordinate computing unit 1, for being less than or equal to 1 at slope, is more than or equal at negative 1 o'clock, uses x n-1deduct OffsetX, obtain the X of polygonal second two-dimentional apex coordinate 2, use z n-1deduct OffsetZ, obtain the Z of polygonal first two-dimentional apex coordinate 2;
The 3rd apex coordinate computing unit 1, for being less than or equal to 1 at slope, is more than or equal at negative 1 o'clock, uses x nadd OffsetX, obtain the X of polygonal the 3rd two-dimentional apex coordinate 3, use z nadd OffsetZ, obtain the Z of polygonal the 3rd two-dimentional apex coordinate 3;
The 4th apex coordinate computing unit 1, for being less than or equal to 1 at slope, is more than or equal at negative 1 o'clock, uses x ndeduct OffsetX, obtain the X of polygonal the 4th two-dimentional apex coordinate 4, use z ndeduct OffsetZ, obtain the Z of polygonal the 4th two-dimentional apex coordinate 4;
The first apex coordinate computing unit 2, for being greater than 1 at slope, is less than at negative 1 o'clock, uses x n-1deduct OffsetX, obtain the X of polygonal first two-dimentional apex coordinate 1, use z n-1deduct OffsetZ, obtain the Z of polygonal first two-dimentional apex coordinate 1;
The second apex coordinate computing unit 2, for being greater than 1 at slope, is less than at negative 1 o'clock, uses x n-1add OffsetX, obtain the X of polygonal second two-dimentional apex coordinate 2, use z n-1add OffsetZ, obtain the Z of polygonal first two-dimentional apex coordinate 2;
The 3rd apex coordinate computing unit 2, for being greater than 1 at slope, is less than at negative 1 o'clock, uses x ndeduct OffsetX, obtain the X of polygonal the 3rd two-dimentional apex coordinate 3, use z ndeduct OffsetZ, obtain the Z of polygonal the 3rd two-dimentional apex coordinate 3;
The 4th apex coordinate computing unit 2, for being greater than 1 at slope, is less than at negative 1 o'clock, uses x nadd OffsetX, obtain the X of polygonal the 4th two-dimentional apex coordinate 4, use z nadd OffsetZ, obtain the Z of polygonal the 4th two-dimentional apex coordinate 4.
The 3D line drawing method and the device that provide for the embodiment of the present invention above, refer to Fig. 3 and be the 3D line drawing design sketch that adopts embodiment of the present invention technical scheme to obtain, and can see intuitively that lines have between 3D transparent effect section be smoothly connected from this figure.
Method for drafting to a kind of 3D lines provided by the present invention and device are described in detail above, for one of ordinary skill in the art, according to the thought of the embodiment of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.

Claims (10)

1. a 3D lines method for drafting, is characterized in that, described method comprises:
By the n-1 in preset three-dimensional vertices set of coordinates and n three-dimensional vertices coordinate projection to XZ plane, obtain n-1 with the individual two-dimentional apex coordinate of n;
According to the straight line of n-1 and n two-dimentional apex coordinate formation and the angle of X-axis, and given live width, polygonal four two-dimentional apex coordinates calculated; Wherein, the straight line of described n-1 and n two-dimentional apex coordinate formation comprises with the angle of X-axis: straight line is parallel with X-axis, straight line and straight line and X-axis both not parallel also out of plumb three kind situations vertical with X-axis; According to described three kinds of situations, respectively using live width as calculated factor, calculate corresponding coordinate skew, calculate four the two-dimentional apex coordinates of described polygon under corresponding conditions according to described coordinate offset;
Described polygonal four two-dimentional apex coordinates are reduced to four three-dimensional vertices coordinates, fill the polygon being formed by four three-dimensional vertices coordinates, obtain n-1 article of line segment; Wherein, n is more than or equal to 2 natural number.
2. the method for claim 1, is characterized in that, if the straight line parallel of n-1 and n two-dimentional apex coordinate formation is in X-axis, calculates polygonal four two-dimentional apex coordinates and specifically comprises:
The x value of n-1 two-dimentional apex coordinate is assigned to the X of polygonal first and second two-dimentional apex coordinate;
Add the half of given live width by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate;
Deduct the half of given live width by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal second two-dimentional apex coordinate;
The x value of n two-dimentional apex coordinate is assigned to the X of polygonal the 3rd and the 4th two-dimentional apex coordinate;
Add the half of given live width by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 3rd two-dimentional apex coordinate;
Deduct the half of given live width by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 4th two-dimentional apex coordinate.
3. the method for claim 1, is characterized in that, if the straight line of described n-1 and n two-dimentional apex coordinate formation is perpendicular to X-axis, calculates polygonal four two-dimentional apex coordinates and specifically comprises:
The z value of n-1 two-dimentional apex coordinate is assigned to the Z of polygonal first and second two-dimentional apex coordinate;
Add the half of given live width by the x value of n-1 two-dimentional apex coordinate, obtain the X value of polygonal first two-dimentional apex coordinate;
Deduct the half of given live width by the x value of n-1 two-dimentional apex coordinate, obtain the X value of polygonal second two-dimentional apex coordinate;
The z value of n two-dimentional apex coordinate is assigned to the Z of polygonal the 3rd and the 4th two-dimentional apex coordinate;
Add the half of given live width by the x value of n two-dimentional apex coordinate, obtain the X value of polygonal the 3rd two-dimentional apex coordinate;
Deduct the half of given live width by the x value of n two-dimentional apex coordinate, obtain the X value of polygonal the 4th two-dimentional apex coordinate.
4. the method for claim 1, is characterized in that, if the straight line of described n-1 and n two-dimentional apex coordinate formation had both been not orthogonal to X-axis, is also not parallel to X-axis, calculates polygonal four two-dimentional apex coordinates and specifically comprises:
Calculate the straight line of n-1 and n two-dimentional apex coordinate formation and the angle theta of X-axis;
Be multiplied by the half of given live width with the absolute value of sin θ, obtain X-axis side-play amount;
Be multiplied by the half of given live width with the absolute value of cos θ, obtain Z axis side-play amount;
Judge the quadrant at angle theta place, according to the quadrant at angle theta place, n-1 and the individual two-dimentional apex coordinate of n and X-axis side-play amount and Z axis side-play amount, calculate polygonal four two-dimentional apex coordinates.
5. method as claimed in claim 4, it is characterized in that, if <90 ° or 180 ° < angle theta <270 ° of 0 ° of < angle theta calculate polygonal four two-dimentional apex coordinates and specifically comprise:
Deduct X-axis side-play amount by the x value of n-1 two-dimentional apex coordinate, obtain the X of polygonal first two-dimentional apex coordinate;
Add Z axis side-play amount by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate;
Add X-axis side-play amount by the x value of n-1 two-dimentional apex coordinate, obtain the X value of polygonal second two-dimentional apex coordinate;
Deduct Z axis side-play amount by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate;
Deduct X-axis side-play amount by the x value of n two-dimentional apex coordinate, obtain the X of polygonal the 3rd two-dimentional apex coordinate;
Add Z axis side-play amount by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 3rd two-dimentional apex coordinate;
Add X-axis side-play amount by the x value of n two-dimentional apex coordinate, obtain the X value of polygonal the 4th two-dimentional apex coordinate;
Deduct Z axis side-play amount by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 4th two-dimentional apex coordinate.
6. method as claimed in claim 4, it is characterized in that, if <180 ° or 270 ° < angle theta <360 ° of 90 ° of < angle theta calculate polygonal four two-dimentional apex coordinates and specifically comprise:
Judge whether described n-1 be less than or equal to 1 with n the straight slope of two-dimentional apex coordinate structure, is more than or equal to and bears 1, if so,
Add X-axis side-play amount by the x value of n-1 two-dimentional apex coordinate, obtain the X of polygonal first two-dimentional apex coordinate;
Add Z axis side-play amount by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate;
Deduct X-axis side-play amount by the x value of n-1 two-dimentional apex coordinate, obtain the X value of polygonal second two-dimentional apex coordinate;
Deduct Z axis side-play amount by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate;
Add X-axis side-play amount by the x value of n two-dimentional apex coordinate, obtain the X of polygonal the 3rd two-dimentional apex coordinate;
Add Z axis side-play amount by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 3rd two-dimentional apex coordinate;
Deduct X-axis side-play amount by the x value of n two-dimentional apex coordinate, obtain the X value of polygonal the 4th two-dimentional apex coordinate;
Deduct Z axis side-play amount by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 4th two-dimentional apex coordinate;
If not,
Deduct X-axis side-play amount by the x value of n-1 two-dimentional apex coordinate, obtain the X of polygonal first two-dimentional apex coordinate;
Deduct Z axis side-play amount by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate;
Add X-axis side-play amount by the x value of n-1 two-dimentional apex coordinate, obtain the X value of polygonal second two-dimentional apex coordinate;
Add Z axis side-play amount by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate;
Deduct X-axis side-play amount by the x value of n two-dimentional apex coordinate, obtain the X value of polygonal the 3rd two-dimentional apex coordinate;
Deduct Z axis side-play amount by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 3rd two-dimentional apex coordinate;
Add X-axis side-play amount by the x value of n two-dimentional apex coordinate, obtain the X value of polygonal the 4th two-dimentional apex coordinate;
Add Z axis side-play amount by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 4th two-dimentional apex coordinate.
7. the method as described in any one claim in claim 1 to 6, is characterized in that, if n >=3 are obtaining after described n-1 article of line segment, described method further comprises:
Fill the n-2 line segment and the n-1 article of polygon that four adjacent three-dimensional vertices coordinates of line segment form that have obtained, make n-2 line segment and n-1 article of line segment smooth connection.
8. a 3D lines drawing apparatus, is characterized in that, described device comprises:
Two-dimensional coordinate projecting cell, for by the n-1 of preset three-dimensional vertices set of coordinates and n three-dimensional vertices coordinate projection to XZ plane, obtain n-1 with the individual two-dimentional apex coordinate of n;
Apex coordinate computing unit, for the straight line of and n two-dimentional apex coordinate formation individual according to n-1 and the angle of X-axis, and given live width, calculate polygonal four two-dimentional apex coordinates; Wherein, the straight line of described n-1 and n two-dimentional apex coordinate formation comprises with the angle of X-axis: straight line is parallel with X-axis, straight line and straight line and X-axis both not parallel also out of plumb three kind situations vertical with X-axis; According to described three kinds of situations, respectively using live width as calculated factor, calculate corresponding coordinate skew, calculate four the two-dimentional apex coordinates of described polygon under corresponding conditions according to described coordinate offset;
Three-dimensional coordinate reduction unit, for being reduced to four three-dimensional vertices coordinates by described polygonal four two-dimentional apex coordinates;
Lines drawing unit, for filling the polygon being made up of four three-dimensional vertices coordinates, obtains n-1 article of line segment; Wherein, n is more than or equal to 2 natural number.
9. device as claimed in claim 8, is characterized in that, if n >=3, described device further comprises:
Connecting line segment drawing unit, for filling the n-2 line segment and the n-1 article of polygon that four adjacent three-dimensional vertices coordinates of line segment form that have obtained, makes n-2 line segment and n-1 article of line segment smooth connection.
10. device as claimed in claim 8 or 9, is characterized in that, if n-1 and n the straight line parallel that two-dimentional apex coordinate forms in X-axis, described apex coordinate computing unit specifically comprises:
First and second summit computing unit, for being assigned to the x value of n-1 two-dimentional apex coordinate the X of polygonal first and second two-dimentional apex coordinate; Add the half of given live width by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal first two-dimentional apex coordinate; Deduct the half of given live width by the z value of n-1 two-dimentional apex coordinate, obtain the Z value of polygonal second two-dimentional apex coordinate;
Second and third summit computing unit, for being assigned to the x value of n two-dimentional apex coordinate the X of polygonal the 3rd and the 4th two-dimentional apex coordinate; Add the half of given live width by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 3rd two-dimentional apex coordinate; Deduct the half of given live width by the z value of n two-dimentional apex coordinate, obtain the Z value of polygonal the 4th two-dimentional apex coordinate.
CN200910258952.2A 2009-12-31 2009-12-31 Method and device for rendering three-dimensional lines Expired - Fee Related CN102117501B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910258952.2A CN102117501B (en) 2009-12-31 2009-12-31 Method and device for rendering three-dimensional lines

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910258952.2A CN102117501B (en) 2009-12-31 2009-12-31 Method and device for rendering three-dimensional lines

Publications (2)

Publication Number Publication Date
CN102117501A CN102117501A (en) 2011-07-06
CN102117501B true CN102117501B (en) 2014-06-11

Family

ID=44216253

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910258952.2A Expired - Fee Related CN102117501B (en) 2009-12-31 2009-12-31 Method and device for rendering three-dimensional lines

Country Status (1)

Country Link
CN (1) CN102117501B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102800119B (en) * 2012-06-13 2014-08-13 天脉聚源(北京)传媒科技有限公司 Animation display method and device of three-dimensional curve
CN104077790B (en) * 2013-03-29 2018-12-14 百度在线网络技术(北京)有限公司 The method for drafting and system of one mode line string
CN106846490B (en) 2017-02-09 2019-08-27 腾讯科技(深圳)有限公司 A kind of methods of exhibiting and device that cambered surface model is used to be shown in 3D scene
CN111784795A (en) * 2020-06-01 2020-10-16 北京像素软件科技股份有限公司 Processing method and device for line segment aliasing, electronic equipment and storage medium
CN112669410B (en) * 2020-12-30 2023-04-18 广东三维家信息科技有限公司 Line width adjusting method, line width adjusting device, computer equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1991915A (en) * 2005-12-28 2007-07-04 腾讯科技(深圳)有限公司 Interactive ink and wash style real-time 3D romance and method for realizing cartoon
CN101568943A (en) * 2006-12-28 2009-10-28 英特尔公司 Real-time collision detection using clipping

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1991915A (en) * 2005-12-28 2007-07-04 腾讯科技(深圳)有限公司 Interactive ink and wash style real-time 3D romance and method for realizing cartoon
CN101568943A (en) * 2006-12-28 2009-10-28 英特尔公司 Real-time collision detection using clipping

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Holmdel, New Jersey.Anti-aliased line drawing using brush extrusion.《SIGGRAPH "83 Proceedings of the 10th annual conference on Computer graphics and interactive techniques》.1983,第17卷(第3期),151-156. *
Roger W.Swanson,Larry J.Thayer.A fast shaded-polygon renderer.《SIGGRAPH "86 Proceedings of the 13th annual conference on Computer graphics and interactive techniques》.1986,第20卷(第4期),95-102. *

Also Published As

Publication number Publication date
CN102117501A (en) 2011-07-06

Similar Documents

Publication Publication Date Title
TWI552109B (en) A method, a non-transitory computer-readable storage medium and a system for conservative rasterization of primitives using an error term
CN102117501B (en) Method and device for rendering three-dimensional lines
CN104183016B (en) A kind of construction method of quick 2.5 dimension building model
JP6027100B2 (en) How to create 3D graphics
CN104898947B (en) A kind of method that GDI electronics map vector scaling and translation are realized based on mouse position
CN105574931A (en) Electronic map road drawing method and device
CN105913478A (en) 360-degree panorama display method and display module, and mobile terminal
WO2013184534A4 (en) Non-static 3d map views
CN102163340A (en) Method for labeling three-dimensional (3D) dynamic geometric figure data information in computer system
US20120229463A1 (en) 3d image visual effect processing method
CN109255832A (en) A kind of target light field creation method based on OpenGL
CN104157000B (en) The computational methods of model surface normal
CN111091620B (en) Map dynamic road network processing method and system based on graphics and computer equipment
CN104463937B (en) Animation producing method and device based on irregularly shaped object
CN104217461A (en) A parallax mapping method based on a depth map to simulate a real-time bump effect
TW201349173A (en) System and method for simulating object during 3D programming
US6677953B1 (en) Hardware viewport system and method for use in a graphics pipeline
US9299185B2 (en) Enhanced system and method for rendering visual surface
CN103729878A (en) Three-dimensional graph implementation method based on WPF and three-dimensional character implementation method based on WPF
CN102004832B (en) Realization of triangle rasterization based on horizontal line scanning
Nah et al. MobiRT: an implementation of OpenGL ES-based CPU-GPU hybrid ray tracer for mobile devices
She et al. An efficient method for rendering linear symbols on 3D terrain using a shader language
CN103310409A (en) Quick triangle partitioning method of Tile-based rendering architecture central processing unit (CPU)
KR101227155B1 (en) Graphic image processing apparatus and method for realtime transforming low resolution image into high resolution image
CN103440684A (en) Method for applying spherical harmonic lighting technology to surface rendering

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20200515

Address after: 310052 room 508, floor 5, building 4, No. 699, Wangshang Road, Changhe street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: Alibaba (China) Co.,Ltd.

Address before: 59 No. 701, 361008, hope road, Xiamen Software Park, Fujian, China

Patentee before: AUTONAVI SOFTWARE Co.,Ltd.

TR01 Transfer of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20140611

Termination date: 20201231

CF01 Termination of patent right due to non-payment of annual fee