CN109783842B - Ray detection method and system based on voxel data - Google Patents

Ray detection method and system based on voxel data Download PDF

Info

Publication number
CN109783842B
CN109783842B CN201811478030.8A CN201811478030A CN109783842B CN 109783842 B CN109783842 B CN 109783842B CN 201811478030 A CN201811478030 A CN 201811478030A CN 109783842 B CN109783842 B CN 109783842B
Authority
CN
China
Prior art keywords
intersection point
value
voxel
far
ray
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.)
Active
Application number
CN201811478030.8A
Other languages
Chinese (zh)
Other versions
CN109783842A (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.)
Suzhou Snail Digital Technology Co Ltd
Original Assignee
Suzhou Snail Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Snail Digital Technology Co Ltd filed Critical Suzhou Snail Digital Technology Co Ltd
Priority to CN201811478030.8A priority Critical patent/CN109783842B/en
Publication of CN109783842A publication Critical patent/CN109783842A/en
Application granted granted Critical
Publication of CN109783842B publication Critical patent/CN109783842B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

A method of ray detection based on voxel data, comprising the steps of: determining a voxel square with a Value larger than 0 at the intersection point of the ray and the voxel square; generating a virtual square according to a quadrant of the intersection point with the Value larger than 0, and acquiring the Value values of a near intersection point and a far intersection point of the ray and the virtual square; judging whether the near intersection point and the far intersection point meet the specified conditions or not; the coordinates with Value equal to 128 are calculated and retrieved. The invention also provides a ray detection system based on the voxel data, which can quickly and accurately perform ray detection.

Description

Ray detection method and system based on voxel data
Technical Field
The invention relates to the technical field of ray detection, in particular to a ray detection method and system based on voxel data.
Background
In the network game of the 3D voxel terrain, the ray detection has wide application scenes, such as the acquisition of the position of a contact, the detection of the collision of a movable object and the like. At the client, ray detection is usually performed by determining whether a ray intersects a triangular surface of a mesh generated from the topographic voxel data. On the other hand, since there is no terrain mesh data at the server, only voxel data itself, it is necessary to provide a ray detection method at the server.
Disclosure of Invention
In order to solve the defects in the prior art, the invention aims to provide a ray detection method and system based on voxel data, which can quickly and accurately perform ray detection.
In order to achieve the above object, the present invention provides a ray detection method based on voxel data, comprising the following steps:
1) acquiring a voxel square where a ray starting point is positioned, and determining the voxel square with the Value of the intersection point of the ray and the voxel square larger than 0;
2) generating a virtual square grid according to a quadrant where the intersection point with the Value larger than 0 is located, and acquiring Value values of a near intersection point and a far intersection point of the ray and the virtual square grid;
3) judging whether the near intersection point and the far intersection point meet the specified conditions or not;
4) the coordinates with Value equal to 128 are calculated and retrieved.
Further, the step 1) further comprises:
if the Value of the current voxel square is 0, then the ray continues to step toward the next adjacent square.
Further, the step 2) further comprises:
generating a virtual square grid according to the quadrant shift half voxel where the near intersection point of the ray and the voxel square grid is located;
and carrying out intersection detection on the current virtual grid and the ray to obtain Value values of a near intersection point and a far intersection point of the current virtual grid.
Further, the step of detecting the intersection of the current virtual grid and the ray to obtain the Value of the near intersection point and the far intersection point further includes:
according to the Value of the vertex of the surface of the virtual square where each intersection point exists, performing planar linear interpolation on the near intersection point and the far intersection point to respectively obtain the Value values after interpolation of the two intersection points,
the 8 vertices of the virtual grid are the centers of 8 real voxel tiles, respectively, which represent 8 Value values.
Further, the step 3) further comprises:
judging whether the Value of the far intersection point is larger than 128;
judging whether the Value of the near intersection point is less than 128;
if the Value of the far intersection point is more than 128 and the Value of the near intersection point is less than 128, then the next step is carried out; if the Value of the far intersection point is less than 128 and the far intersection point is in the bounding box of the current real voxel square, continuing stepping the next virtual square according to the ray direction and returning to the previous step; if the Value of the far intersection point is less than 128 and the far intersection point is outside the bounding box of the current real voxel square, returning to the step of determining the voxel square with the Value of the intersection point of the ray and the voxel square being greater than 0; if the Value of the far intersection is greater than 128 and the Value of the near intersection is greater than 128, the test is ended.
Still further, the step 4) further comprises:
the coordinates with Value equal to 128 are interpolated between the far and near intersections.
In order to achieve the above object, the present invention provides a ray detection system based on voxel data, including:
the data acquisition module is used for acquiring voxel data of each voxel square, including Value values, and acquiring intersection points of rays and the voxel squares;
the generating module generates a virtual square according to a quadrant of an intersection point with a Value larger than 0;
the calculation module is used for calculating Value values of a near intersection point and a far intersection point of the ray and the virtual grid;
and the judging module is used for judging whether the near intersection point and the far intersection point meet the specified conditions, and if the near intersection point and the far intersection point meet the specified conditions, the calculating module calculates and acquires the coordinates of which the Value is equal to 128 according to the Value of the far intersection point and the near intersection point through an interpolation method.
Further, the 8 vertices of the virtual grid are the centers of 8 real voxel bins, respectively, which represent 8 Value values,
and the calculation module performs plane linear interpolation on the near intersection point and the far intersection point according to the Value of the vertex of the surface of the virtual grid in each intersection point to respectively obtain the Value after interpolation of the two intersection points.
Further, the prescribed condition is that the Value of the far intersection is greater than 128 and the Value of the near intersection is less than 128.
Further, the calculation module interpolates coordinates with a Value equal to 128 between the far and near intersections.
According to the ray detection method and the ray detection system, ray detection is carried out according to the Value of each voxel grid and the principle that the grid is generated by the MC algorithm, so that the ray detection can be carried out quickly and accurately.
The ray detection method and the ray detection system of the invention calculate the Value through plane linear interpolation, thus being capable of plane linear interpolation.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention and not to limit the invention. In the drawings:
FIG. 1 is a flow chart of a radiation detection method according to the present invention;
FIG. 2 is a detailed flow chart of a radiation detection method according to the present invention;
FIG. 3 is a schematic diagram illustrating a radiation detection method of the present invention;
fig. 4 is a diagram of a radiation detection system architecture according to the present invention.
Detailed Description
The preferred embodiments of the present invention will be described in conjunction with the accompanying drawings, and it will be understood that they are described herein for the purpose of illustration and explanation and not limitation.
Fig. 1 is a flowchart of a radiation detection method according to the present invention, fig. 2 is a detailed flowchart of the radiation detection method according to the present invention, and the radiation detection method according to the present invention will be described in detail with reference to fig. 1 and fig. 2.
In a 3D voxel terrain, in order to facilitate uniform management, the entire terrain is divided into a plurality of data blocks (chunks) of the same size, each Chunk contains n × n voxel data, each voxel data contains 4 bytes, which are: material Type (Type), material ID (ID), material parameter (Param), and voxel Value (Value).
The Marching Cubes (MC) algorithm is a classical algorithm in the surface rendering algorithm, which is a voxel level reconstruction method proposed by w. The MC algorithm is also known as the "iso-surface extraction" algorithm.
As mentioned above, Value in voxel data occupies one byte, so the Value range is 0-255. When the client generates mesh data, an isosurface of value =128 is generated according to the MC algorithm. The ray detection method is based on the principle of the MC algorithm, and the intersection point of the isosurface on the ray, which is approximately equal to 128 of the Value, is calculated according to the Value of the voxel data.
First, in step S1, a voxel grid is determined in which the Value of the intersection of the ray and the voxel grid is greater than 0. Specifically, step S1 includes the following steps. In step S11, a voxel grid where the ray start point is located is acquired; in step S12, it is determined whether the Value of the current voxel grid is greater than 0, and if the Value is greater than 0, the next step is performed, and if Value =0, the step S13 is performed. In step S13, the stepping toward the next adjacent cell in the ray direction is continued (no in step S12), and the process returns to step S12.
In step S2, a virtual box is generated from the quadrant of the intersection point whose Value is greater than 0, and Value values of the near and far intersection points of the ray and the virtual box are acquired. Specifically, step S2 includes the following steps. In step S21, a virtual grid is generated by shifting half a voxel according to the quadrant at which the near intersection of the ray and the voxel grid is located; in step S22, intersection detection is performed on the current virtual grid and the ray, and Value values of the near intersection point and the far intersection point are obtained. Wherein, 8 vertexes of the virtual grid are the centers of 8 real voxel grids respectively, and the 8 vertexes represent 8 Value values. In the present embodiment, the intersection point is an intersection point closer to the starting point of the ray among intersection points of the ray and the voxel grid, and the intersection point is an intersection point farther from the starting point of the ray among intersection points of the ray and the voxel grid.
In step S22, planar linear interpolation is performed on the near intersection and the far intersection based on the Value of the vertex of the surface of the virtual square where each intersection exists, and the Value obtained by interpolation of the two intersections is obtained.
In step S3, it is determined whether the near intersection and the far intersection satisfy a predetermined condition. Specifically, step S3 includes the steps of: in step S31, it is determined whether the Value of the far intersection is greater than 128; in step S32, it is determined whether the Value of the near intersection is less than 128; in step S33, it is determined whether the far intersection point is within the bounding box of the current real voxel square. If the Value of the far intersection point is more than 128 and the Value of the near intersection point is less than 128, then the next step is carried out; if the Value of the far intersection point is less than 128 and the far intersection point is in the bounding box of the current real voxel square, continuing stepping the next virtual square according to the ray direction (step S34) and returning to step S22; if the Value of the far intersection point is less than 128 and the far intersection point is outside the bounding box of the current real voxel square, returning to the step S13; if the Value of the far intersection is greater than 128 and the Value of the near intersection is greater than 128, the test is ended.
In step S4, the coordinates with Value equal to 128 are calculated and acquired. Specifically, in step S41, coordinates with a Value equal to 128 are interpolated between the far intersection and the near intersection.
Fig. 3 is a schematic diagram illustrating a radiation detection method of the present invention. Next, embodiments of the present invention are illustrated in further detail in a 2D plane manner. As shown in fig. 3, the voxel grids 311, 312, 313, 314 are adjacent to each other, and the ray 331 intersects the voxel grids 311, 312, 313 from the voxel grid 311 in the direction of the arrow. The Value of the voxel squares 311 and 312 is 0, and the Value of the voxel square 313 is 255.
First, a voxel grid, i.e., voxel grid 311, is obtained where the start point of the ray 331 is located.
Then, since the Value of voxel square 311 is 0, step is continued to voxel square 312; stepping is continued again to voxel grid 313 since the Value of voxel grid 312 is 0.
Then, since the Value of the voxel grid 313 is 255 (greater than 0) and the near intersection 313a of the ray 331 and the voxel grid 313 is located in the upper right quadrant, the virtual grid 321 is generated. Where the 4 vertices of the virtual square 321 correspond to the 4 real voxel squares 311, 312, 313, 314, respectively.
Then, the intersection detection is performed on the virtual grid 321 and the ray 331, and a near intersection point 321a and a far intersection point 321b are obtained. The near intersection 321a is located on the upper side of the virtual square 321, and therefore its Value is the Value interpolation of the voxel square 311 and the voxel square 312, and since both Value values are 0, the Value of the near intersection 321a is 0. Similarly, distant intersection point 321b is located on the left side, and therefore has a Value of Value interpolated for voxel grid 312 and voxel grid 313, and since the Value of voxel grid 312 is 0 and the Value of voxel grid 313 is 255, it is assumed that distant intersection point 321b is located from above to below 4/5 on the left side, and therefore has a Value of 204 (Value =0+0.8 (255-0)).
Then, since the Value of the far intersection 321b is greater than 128 and it is located in the voxel grid 313, the Value of the near intersection 321a is 0 (less than 128), and thus an equal Value point is interpolated. The ratio of the distance of the equivalent point from the near intersection 321a to the distance of the far intersection 321b from the near intersection 321a is (128-0)/(204-0) = 0.62.
Fig. 4 is an architecture diagram of a ray detection system 400 according to the present invention, as shown in fig. 4, the ray detection system 400 based on voxel data includes: a data acquisition module 401, a generation module 402, a calculation module 403 and a judgment module 404.
A data acquisition module 401 that acquires voxel data including Value values for each voxel square and acquires intersections of the rays and the voxel squares.
A generation module 402 that generates a virtual grid from quadrants of intersections having Value values greater than 0. Wherein, 8 vertexes of the virtual grid are the centers of 8 real voxel grids respectively, and the 8 vertexes represent 8 Value values.
A calculation module 403, which calculates Value of the near and far intersection points of the ray with the virtual grid. Specifically, the calculation module 403 performs planar linear interpolation on the near intersection point and the far intersection point according to the Value of the vertex of the surface of the virtual square where each intersection point exists, so as to obtain the Value values after interpolation of the two intersection points respectively.
And a judging module 404 for judging whether the near intersection point and the far intersection point meet the specified condition. If the Value of the far intersection point is greater than 128 and the Value of the near intersection point is less than 128, the calculation module 403 calculates and obtains a coordinate with a Value equal to 128 by an interpolation method according to the Value of the far intersection point and the near intersection point, and specifically, interpolates a coordinate with a Value equal to 128 between the far intersection point and the near intersection point; if the Value of the far intersection point is less than 128 and the far intersection point is in the bounding box of the current real voxel square, the data acquisition module 401 continues to step the next virtual square according to the ray direction, and the calculation module 403 calculates the Value of the intersection point of the ray and the next virtual square and sends the Value to the judgment module 404 for judgment; if the Value of the far intersection point is less than 128 and the far intersection point is outside the bounding box of the current real voxel square, the returning module 401 obtains the intersection point of the ray and the next voxel square and continues to perform detection; if the Value of the far intersection is greater than 128 and the Value of the near intersection is greater than 128, the detection is ended.
According to this embodiment, the ray detection is performed by the MC method based on the Value of each voxel square. Therefore, the radiation detection can be performed quickly and accurately.
According to the present embodiment, the Value is calculated by planar linear interpolation. Therefore, planar linear interpolation is enabled.
Those of ordinary skill in the art will understand that: although the present invention has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that changes may be made in the embodiments and/or equivalents thereof without departing from the spirit and scope of the invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (9)

1. A method of ray detection based on voxel data, comprising the steps of:
1) acquiring a voxel square where a ray starting point is positioned, and determining the voxel square with the Value of the intersection point of the ray and the voxel square larger than 0;
2) generating a virtual square grid according to a quadrant where the intersection point with the Value larger than 0 is located, and acquiring Value values of a near intersection point and a far intersection point of the ray and the virtual square grid;
3) judging whether the near intersection point and the far intersection point meet the specified conditions or not;
4) calculating and acquiring coordinates with Value equal to 128;
the step 3) further comprises the following steps:
judging whether the Value of the far intersection point is larger than 128;
judging whether the Value of the near intersection point is less than 128;
if the Value of the far intersection point is more than 128 and the Value of the near intersection point is less than 128, the next step is carried out; if the Value of the far intersection point is less than 128 and the far intersection point is in the bounding box of the current real voxel square, continuously stepping the next virtual square according to the ray direction and returning to the previous step; if the Value of the far intersection point is less than 128 and the far intersection point is outside the bounding box of the current real voxel square, returning to the step of determining the voxel square with the Value of the intersection point of the ray and the voxel square being greater than 0; if the Value of the far intersection is greater than 128 and the Value of the near intersection is greater than 128, the detection is ended.
2. The method for ray detection based on voxel data according to claim 1, wherein the step 1) further comprises:
if the Value of the current voxel square is 0, then the ray continues to step toward the next adjacent square.
3. The method for ray detection based on voxel data according to claim 1, wherein the step 2) further comprises:
generating a virtual square grid according to the quadrant shift half voxel where the near intersection point of the ray and the voxel square grid is located;
and carrying out intersection detection on the current virtual grid and the ray to obtain Value values of a near intersection point and a far intersection point of the current virtual grid.
4. The method for ray detection based on voxel data according to claim 3, wherein the step of performing intersection detection on the current virtual grid and the ray to obtain Value values of its near intersection point and far intersection point further comprises:
according to the Value of the vertex of the surface of the virtual square where each intersection point exists, performing planar linear interpolation on the near intersection point and the far intersection point to respectively obtain the Value values after interpolation of the two intersection points,
the 8 vertices of the virtual grid are the centers of 8 real voxel tiles, respectively, which represent 8 Value values.
5. The method for detecting rays based on voxel data according to claim 1, wherein the step 4) further comprises:
a coordinate with Value equal to 128 is interpolated between the far and near intersections.
6. A system for ray detection based on voxel data, comprising:
the data acquisition module is used for acquiring voxel data of each voxel square, including Value values, and acquiring intersection points of rays and the voxel squares;
the generating module generates a virtual square according to a quadrant of an intersection point with a Value larger than 0;
the calculation module is used for calculating Value values of a near intersection point and a far intersection point of the ray and the virtual grid;
and the judging module is used for judging whether the near intersection point and the far intersection point meet the specified conditions, and if the near intersection point and the far intersection point meet the specified conditions, the calculating module calculates and acquires the coordinates of which the Value is equal to 128 according to the Value of the far intersection point and the near intersection point through an interpolation method.
7. The voxel data-based ray detection system of claim 6,
the 8 vertices of the virtual grid, which are the centers of the 8 true voxel bins, respectively, represent 8 Value values,
and the calculation module performs plane linear interpolation on the near intersection point and the far intersection point according to the Value of the vertex of the surface of the virtual grid in each intersection point to respectively obtain the Value after interpolation of the two intersection points.
8. The voxel data-based ray detection system of claim 6 wherein the prescribed condition is that a Value of a far intersection is greater than 128 and a Value of an near intersection is less than 128.
9. The voxel data-based ray detection system of claim 6 wherein the computation module interpolates coordinates having a Value equal to 128 between a far intersection and a near intersection.
CN201811478030.8A 2018-12-05 2018-12-05 Ray detection method and system based on voxel data Active CN109783842B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811478030.8A CN109783842B (en) 2018-12-05 2018-12-05 Ray detection method and system based on voxel data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811478030.8A CN109783842B (en) 2018-12-05 2018-12-05 Ray detection method and system based on voxel data

Publications (2)

Publication Number Publication Date
CN109783842A CN109783842A (en) 2019-05-21
CN109783842B true CN109783842B (en) 2022-07-15

Family

ID=66496647

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811478030.8A Active CN109783842B (en) 2018-12-05 2018-12-05 Ray detection method and system based on voxel data

Country Status (1)

Country Link
CN (1) CN109783842B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111921202B (en) * 2020-09-16 2021-01-08 成都完美天智游科技有限公司 Data processing method, device and equipment for virtual scene and readable storage medium
CN116027341B (en) * 2021-10-25 2024-05-03 珠海一微半导体股份有限公司 Grid and voxel positioning method based on laser observation direction, robot and chip
CN116954265B (en) * 2023-09-20 2023-12-05 天津云圣智能科技有限责任公司 Method and device for rescheduling local motion trail and electronic equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103529959B (en) * 2013-01-21 2016-06-29 Tcl集团股份有限公司 Based on the frame choosing method of key point ray collision detection, system and electronic equipment
CN107300645B (en) * 2017-06-06 2019-07-23 华中科技大学 A kind of quick ray-tracing procedure and system

Also Published As

Publication number Publication date
CN109783842A (en) 2019-05-21

Similar Documents

Publication Publication Date Title
CN109783842B (en) Ray detection method and system based on voxel data
US9959670B2 (en) Method for rendering terrain
CN111161428B (en) Three-dimensional map vector tile data generation method, storage medium and terminal
KR20170068462A (en) 3-Dimensional Model Generation Using Edges
CN111932669A (en) Deformation monitoring method based on slope rock mass characteristic object
CN113012063B (en) Dynamic point cloud repairing method and device and computer equipment
CN111881985B (en) Stereo matching method, device, terminal and storage medium
CN115375823A (en) Three-dimensional virtual clothing generation method, device, equipment and storage medium
Pfeifer A subdivision algorithm for smooth 3D terrain models
CN108564604B (en) Binocular vision stereo matching method and device based on plane constraint and triangulation
CN111260714B (en) Flood disaster recovery assessment method, device and equipment and computer storage medium
CN116310060A (en) Method, device, equipment and storage medium for rendering data
CN112991525B (en) Digital surface model generation method for image space and object space mixed matching primitive
CN113763558A (en) Information processing method and device, equipment and storage medium
CN114596195A (en) Topographic data processing method, system, device and computer storage medium
CN110120058B (en) Method for generating compact outer boundary by using high scatter points
CN111105453B (en) Method for obtaining disparity map
CN108830924B (en) Scene model display method and terminal
CN105844703A (en) Three-dimensional terrain simplified algorithm based on high precision DEM data
CN114019532A (en) Project progress checking method and device
CN116246069B (en) Method and device for self-adaptive terrain point cloud filtering, intelligent terminal and storage medium
KR102061835B1 (en) How to implement LOD in non-square Grid data with NaN
CN111415414B (en) Three-dimensional space information processing method, equipment and storage medium thereof
Dou et al. A Unified LOD Model for River Network and DEM Based on an Improved 3D_DP Algorithm
Hoppe et al. Adaptive meshing and detail-reduction of 3D-point clouds from laser scans

Legal Events

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

Denomination of invention: A method and system of ray detection based on voxel data

Effective date of registration: 20221217

Granted publication date: 20220715

Pledgee: Agricultural Bank of China Limited Suzhou Industrial Park sub branch

Pledgor: Suzhou Snail Digital Technology Co.,Ltd.

Registration number: Y2022320010815

PE01 Entry into force of the registration of the contract for pledge of patent right