CN109861965A - A kind of voxel Terrain Data Compression method and system - Google Patents
A kind of voxel Terrain Data Compression method and system Download PDFInfo
- Publication number
- CN109861965A CN109861965A CN201811478027.6A CN201811478027A CN109861965A CN 109861965 A CN109861965 A CN 109861965A CN 201811478027 A CN201811478027 A CN 201811478027A CN 109861965 A CN109861965 A CN 109861965A
- Authority
- CN
- China
- Prior art keywords
- data
- node
- voxel
- mask
- written
- 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
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Image Generation (AREA)
Abstract
A kind of voxel Terrain Data Compression method, comprising steps of each node of each Octree of recursive traversal, and intermediate data is generated in the node;Each of each Octree of the recursive traversal node, updates the intermediate data, and the data for needing to be packaged are written;The data of said write are compressed, wherein the intermediate data includes flag data, mask data and voxel data.The present invention also provides a kind of voxel Terrain Data Compression system, the decompression that the capacity compared to legacy data greatly reduces, and can be convenient can save data storage and take up space and bandwidth shared by network transmission.
Description
Technical field
The present invention relates to
Technical field, more particularly to a kind of voxel Terrain Data Compression method and system.
Background technique
In the online game of voxel type, entire landform can be separated into multiple voxel datas of 3d space.With game
Progress, player is more and more to the modification of voxel landform, and server needs the voxel data that saves also can be more and more.In number
According to achieving in network transmission process, require to use compressed terrain data, therefore how to carry out Efficient Compression is one
Extremely important problem.
Summary of the invention
In order to solve the shortcomings of the prior art, the purpose of the present invention is to provide a kind of voxel Terrain Data Compression sides
Method and system, the decompression that compressed binary data greatly reduces compared to the capacity of legacy data, and can be convenient,
Data storage can be saved to take up space and bandwidth shared by network transmission.
To achieve the above object, a kind of voxel Terrain Data Compression method provided by the invention, comprising the following steps:
Each node of recursive traversal Octree, and intermediate data is generated in the node;
Each of each Octree of the recursive traversal node, updates the intermediate data, and the number for needing to be packaged is written
According to;
The data of said write are compressed;
Wherein, the intermediate data includes flag data, mask data and voxel data.
Further, each node of the recursive traversal Octree, and the step of the node generates intermediate data,
Further comprise:
The each node of recursive traversal;
When present node is leaf node, the flag data is set as 0, the mask data is set as 1111;
When present node is that non-leaf nodes, the byte corresponding with the voxel data of all child nodes are consistent, by institute
It states mask data and is set as 1, corresponding voxel data is effective;
Present node is that non-leaf nodes, the byte corresponding with the voxel data of all child nodes are inconsistent, by institute
It states mask data and is set as 0, corresponding voxel data is invalid.
Further, each of each described Octree of recursive traversal node, updates the intermediate data, and
The step of data that write-in needs to be packaged, further comprise:
The each node of recursive traversal;
The mask data of the present node is updated according to the mask data of the father node of present node;
According to the flag data and updated mask data, the data for needing to be packaged are written.
Further, the mask data according to the father node of present node updates described in the present node
The step of mask data, further comprises:
When the digit of the father node corresponding with the position of the present node is 1, the digit of the present node is updated
It is 0, alternatively, when the digit of the father node corresponding with the position of the present node is 0, without change.
Further, described according to the flag data and updated mask data, be written what the needs were packaged
The step of data, further comprises:
When the present node is non-leaf nodes, the flag data of the present node and described updated is written
Mask data is only written and is with the updated mask data median alternatively, when the present node is leaf node
The 1 corresponding voxel data, and it is not written into the flag data and the updated mask data.
To achieve the above object, a kind of voxel Terrain Data Compression system provided by the invention, comprising:
Spider module carries out recursive traversal twice to each node of each Octree;
Data generation module, according to first time recursive traversal as a result, generating intermediate data, the intermediate data includes mediant
According to including flag data, mask data and voxel data;
Data update module updates the intermediate data of all nodes according to second of recursive traversal result;
Memory module, the data that updated intermediate data write-in needs to be packaged;And
Compression module compresses the data being written.
Further, the intermediate data includes that intermediate data is generated with binary data.
Further, the flag data is set as 0 when present node is leaf node by the data generation module,
The mask data is set as 1111,
When present node is non-leaf nodes, data generation module flag data according to its child node and described cover
Code data are configured.
Further, the data update module is 1 in the digit of the father node corresponding with the position of present node
When, the digit of the present node is updated to 0;When the digit of the father node corresponding with the position of the present node is 0,
Without change;
Further, the institute of the present node is written when the present node is non-leaf nodes in the memory module
State flag data and the updated mask data;When the present node is leaf node, it is only written and the update
Mask data median afterwards is the 1 corresponding voxel data, and is not written into the flag data and described updated
Mask data.
In the present invention, all nodes of recursive traversal and its Flag, Mask and Data is generated, wherein Flag and Mask
It is generated with binary data;It is updated according to the Mask of father node, the data for needing to compress is written according to result is updated, therefore compress
Binary data afterwards greatly reduces compared to the capacity of legacy data, and the decompression that can be convenient, and can save data
Storage takes up space and bandwidth shared by network transmission.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
It obtains it is clear that understand through the implementation of the invention.
Detailed description of the invention
Attached drawing is used to provide further understanding of the present invention, and constitutes part of specification, and with it is of the invention
Embodiment together, is used to explain the present invention, and is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is voxel Terrain Data Compression method flow diagram according to the present invention;
Fig. 2 is the schematic diagram that voxel Terrain Data Compression is carried out using binary tree;
Fig. 3 is voxel Terrain Data Compression system architecture diagram according to the present invention.
Specific embodiment
Hereinafter, preferred embodiments of the present invention will be described with reference to the accompanying drawings, it should be understood that preferred reality described herein
Apply example only for the purpose of illustrating and explaining the present invention and is not intended to limit the present invention.
Fig. 1 is voxel Terrain Data Compression method flow diagram according to the present invention, below with reference to Fig. 1, to of the invention
Voxel Terrain Data Compression method is described in detail.
In 3D voxel landform, for the ease of unified management, entire landform can be divided into an equal amount of multiple data
Block (Chunk), each chunk include n*n*n voxel data, and each voxel data includes 4 bytes, are respectively: material class
Type (Type), material ID(ID), material parameters (Param) and voxel value (Value).One is indicated with Octree in memory
All voxel datas of a chunk.
Firstly, in step 101, each node of first time recursive traversal Octree, and mediant is generated in each node
According to.Intermediate data includes this 3 parts of flag data (Flag), mask data (Mask) and voxel data (Data).Wherein,
Flag is 8bit, respectively indicates whether 8 children's (child node) are leaf nodes;Mask is 4bit, respectively indicates present node
Data corresponding 4 bytes in position it is whether effective;Data is 4byte, stores the voxel data of present node, if effectively
It is determined by Mask, Flag and Mask are with binary representation.In a step 101, the node of each Octree is traversed, if the node
It is leaf node, then Flag is set as 0, Mask is set as 1111;If the node is non-leaf nodes, by Flag according to it
(front has been explained, and Flag data indicate whether 8 child nodes are leaf nodes for the actual conditions setting of child node.Such as
8 children of fruit are not leaf nodes, i.e., all there are also children for child nodes, then Flag is set as (00000000);If 8 children
Son is all leaf node, then Flag is set as (11111111);If preceding 2 children are leaves, other children are not leaf sections
Point, then Flag is set as (11000000).), Mask and Data are waited after having traversed all child nodes, according to all child nodes
Data whether be unanimously arranged, specifically, will be with the Type byte pair if the Type byte of all child nodes is all consistent
The position Type of the Mask for the present node answered is set as 1, and corresponding Data is also set as corresponding Type data;If all child nodes
Type byte it is inconsistent, then the correspondence position of current Mask is set as 0, corresponding Data is invalid.In addition, in present embodiment
In, Mask corresponding with other voxel datas is configured also by same procedure.
It since binary tree is similar with the principle of Octree, illustrates more convenient, therefore is illustrated below with binary tree
The detailed process of the present embodiment building, Fig. 2 are the schematic diagram that voxel Terrain Data Compression is carried out using binary tree, as shown in Fig. 2,
In order to illustrate that conveniently, the byte number of voxel data is changed to 2 by 4.
Specifically, Flag is set as 11 since it is non-leaf nodes by traverse node 201;Traverse node 202A,
Since it is non-leaf nodes, Flag is set as 11;Traverse node 203a then sets Flag since it is leaf node
For 0, Mask is set as 11, Data is set as (1,7);Traverse node 203b sets Flag since it is non-leaf nodes
It is 11;Flag is set as 0 since it is leaf node by traverse node 204ba, and Mask is set as 11, Data is set as
(1,8);Flag is set as 0 since it is leaf node by traverse node 204bb, and Mask is set as 11, Data is set as
(1,9);Node 203b is returned to, since 204ba and 204bb node is all leaf node, Flag is still 11, due to node
204ba and the first character section of node 204bb data are all 1, therefore Mask is set as 10, and Data is set as (1,0);Return to section
Point 202A, since 203a is leaf, 203b is not leaf, therefore Flag is changed to 10, due to node 203a and node 203b data
First character section be all 1, therefore Mask is set as 10, Data is set as (1,0);Traverse node 202B, since it is leaf
Node, therefore Flag is set as 0, Mask is set as 11, Data is set as (2,9);Node 201 is returned to, since 202A is not leaf
Son, 202B is leaf, therefore Flag is changed to 01, and since the data of two child nodes 202A, 202B are inconsistent, Mask is set
It is 00, Data is set as (0,0).
In step 102, each node of second of recursive traversal Octree updates intermediate data, and is written and needs to be packaged
Data.In a step 102, each node of recursive traversal;The Mask of present node is updated according to the Mask of father node, specifically
Ground, if a certain position is 1 in the Mask of the father node of present node, by the corresponding digit of present node Mask (with father node
The position of corresponding present node) it is set as 0, otherwise without change;If present node is non-leaf nodes, prosthomere is worked as in write-in
The Flag and updated Mask of point, according to updated Mask, are only written in Data if present node is leaf node
Corresponding effective byte, and it is not written into the Flag and updated Mask of present node.In the present embodiment, present node
Corresponding position is invalid (digit of this is 0) in updated Mask, illustrates that corresponding byte data is protected in its father node
It deposits, therefore does not need to be written again.
Specifically, traverse node 201, write-in Flag are 11, and write-in Mask is 00, due to two byte datas of Mask label
It is all invalid, therefore it is not written into Data;It is 11 that Flag, which is written, in traverse node 202A, since its father node (node 201) Mask is 00,
Therefore Mask is updated to 10, Mask is written, the Type data 1 of the first byte are written;Traverse node 203a, due to father node
Mask is 10, therefore Mask is updated to 01, is only written the data 7 of second byte, and is not written into Flag and Mask;Traversal section
Point 203b, write-in Flag are 11, since the Mask of its father node is 10, Mask are updated to 00, Mask is written, without writing
Enter Data;Mask is updated to 01, is only written second word by traverse node 204ba since the Mask of its father node is 10
The data 8 of section, and it is not written into Flag and Mask;Traverse node 204bb, since the Mask of its father node is 10, by Mask
It is updated to 01, is only written the data 9 of second byte, and is not written into Flag and Mask;Node 203b is returned to, without operation;It returns
To node 202A, without operation;Mask is updated to 11, only since the Mask of its father node is 00 by traverse node 202B
The data (2,9) of two bytes are written, and are not written into Flag and Mask;Node 201 is returned to, without operation.
In step 103, data to be written is compressed.
What is illustrated in the present embodiment is compression method, and decompression procedure is with compression process on the contrary, parsing node is corresponding
Flag and Mask generates real octree nodes.
Fig. 3 is voxel Terrain Data Compression system architecture diagram according to the present invention.As described in Figure 3, voxel of the invention
Graphic data compressibility 300 includes: spider module 301, data generation module 302, data update module 303, memory module 304
And compression module 305.
Spider module 301 carries out recursive traversal to each node of each Octree.In the present embodiment, mould is traversed
Block 301 carries out recursive traversal twice.
Data generation module 302, according to first time recursive traversal as a result, generating intermediate data.Wherein, intermediate data packet
Include: intermediate data includes flag data (Flag), mask data (Mask) and voxel data (Data).Further, Flag is
8bit, respectively indicates whether 8 children's (child node) are leaf nodes;Mask is 4bit, respectively indicates the Data of present node
Corresponding 4 bytes in position it is whether effective;Data is 4byte, stores the voxel data of present node, if effectively by Mask
It determines, Flag and Mask are with binary representation.If present node is leaf node, data generation module 302 sets Flag
It is 0, Mask is set as 1111;If present node is non-leaf nodes, data generating section 302 is by Flag according to its child node
Actual conditions setting, Mask and Data waiting traversed all child nodes after, according to the data of all child nodes whether one
It causes to be arranged.It specifically, will present node corresponding with the Type byte if the Type byte of all child nodes is all consistent
The position Type of Mask be set as 1, corresponding Data is also set as corresponding Type data;If the Type byte of all child nodes is not
Unanimously, then the correspondence position of current Mask is set as 0, corresponding Data is invalid.In addition, in the present embodiment, with other voxels
The corresponding Mask of data is configured also by same procedure.
Data update module 303 updates the intermediate data of all nodes according to second of recursive traversal result.Specifically
Ground, if a certain position is 1 in the Mask of the father node of present node, data update module 303 is corresponding by present node Mask
Digit (position of present node corresponding with father node) be set as 0, otherwise without change.
Memory module 304, the data for needing to be packaged according to Flag and updated Mask write-in.If present node is
Non-leaf nodes, then the Flag and updated Mask of present node is written in memory module 304, if present node is leaf section
Point, then memory module 304 is only written corresponding effective byte in Data according to updated Mask, and is not written into current section
The Flag and updated Mask of point.In the present embodiment, invalid (position in corresponding position in the updated Mask of present node
Digit be 0), to illustrate that corresponding byte data is saved in its father node, therefore do not need to be written again.
Compression module 305 compresses the data being written.
In the present embodiment, all nodes of recursive traversal and generate its Flag, Mask and Data, wherein Flag and
Mask is generated with binary data;It is updated according to the Mask of father node, the data for needing to compress is written according to result is updated.Cause
This, compressed binary data greatly reduces compared to the capacity of legacy data, and the decompression that can be convenient, Ke Yijie
Data storage is saved to take up space and bandwidth shared by network transmission.
Those of ordinary skill in the art will appreciate that: the foregoing is only a preferred embodiment of the present invention, and does not have to
In the limitation present invention, although the present invention is described in detail referring to the foregoing embodiments, for those skilled in the art
For, still can to foregoing embodiments record technical solution modify, or to part of technical characteristic into
Row equivalent replacement.All within the spirits and principles of the present invention, any modification, equivalent replacement, improvement and so on should all include
Within protection scope of the present invention.
Claims (10)
1. a kind of voxel Terrain Data Compression method, which comprises the following steps:
Each node of recursive traversal Octree, and intermediate data is generated in the node;
Each of each Octree of the recursive traversal node, updates the intermediate data, and the number for needing to be packaged is written
According to;
The data of said write are compressed;
Wherein, the intermediate data includes flag data, mask data and voxel data.
2. voxel Terrain Data Compression method according to claim 1, which is characterized in that the recursive traversal Octree
Each node, and the step of the node generates intermediate data, further comprise:
The each node of recursive traversal;
When present node is leaf node, the flag data is set as 0, the mask data is set as 1111;
When present node is that non-leaf nodes, the byte corresponding with the voxel data of all child nodes are consistent, by institute
It states mask data and is set as 1, corresponding voxel data is effective;
Present node is that non-leaf nodes, the byte corresponding with the voxel data of all child nodes are inconsistent, by institute
It states mask data and is set as 0, corresponding voxel data is invalid.
3. voxel Terrain Data Compression method according to claim 1, which is characterized in that the recursive traversal is each described
Each of Octree node, updates the intermediate data, and the step of data for needing to be packaged are written, and further comprises:
The each node of recursive traversal;
The mask data of the present node is updated according to the mask data of the father node of present node;
According to the flag data and updated mask data, the data for needing to be packaged are written.
4. voxel Terrain Data Compression method according to claim 3, which is characterized in that the father according to present node
The step of mask data of node updates the mask data of the present node further comprises:
When the digit of the father node corresponding with the position of the present node is 1, the digit of the present node is updated
It is 0, alternatively, when the digit of the father node corresponding with the position of the present node is 0, without change.
5. voxel Terrain Data Compression method according to claim 4, which is characterized in that described according to the flag data
With updated mask data, be written it is described need be packaged data the step of, further comprise:
When the present node is non-leaf nodes, the flag data of the present node and described updated is written
Mask data is only written and is with the updated mask data median alternatively, when the present node is leaf node
The 1 corresponding voxel data, and it is not written into the flag data and the updated mask data.
6. a kind of voxel Terrain Data Compression system characterized by comprising
Spider module carries out recursive traversal twice to each node of each Octree;
Data generation module, according to first time recursive traversal as a result, generating intermediate data, the intermediate data includes mediant
According to including flag data, mask data and voxel data;
Data update module updates the intermediate data of all nodes according to second of recursive traversal result;
Memory module, the data that updated intermediate data write-in needs to be packaged;And
Compression module compresses the data being written.
7. according to claim 6 voxel Terrain Data Compression system, which is characterized in that
The intermediate data includes that intermediate data is generated with binary data.
8. according to claim 7 voxel Terrain Data Compression system, which is characterized in that
The flag data is set as 0 when present node is leaf node by the data generation module, by the mask data
It is set as 1111,
When present node is non-leaf nodes, data generation module flag data according to its child node and described cover
Code data are configured.
9. according to claim 7 voxel Terrain Data Compression system, which is characterized in that
The data update module described will work as prosthomere when the digit of the father node corresponding with the position of present node is 1
The digit of point is updated to 0;When the digit of the father node corresponding with the position of the present node is 0, without change.
10. according to claim 7 voxel Terrain Data Compression system, which is characterized in that the memory module works as prosthomere described
When point is non-leaf nodes, the flag data and the updated mask data of the present node is written;Described
When present node is leaf node, it is only written the corresponding number of voxels for being 1 with the updated mask data median
According to, and it is not written into the flag data and the updated mask data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811478027.6A CN109861965B (en) | 2018-12-05 | 2018-12-05 | Voxel terrain data compression method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811478027.6A CN109861965B (en) | 2018-12-05 | 2018-12-05 | Voxel terrain data compression method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109861965A true CN109861965A (en) | 2019-06-07 |
CN109861965B CN109861965B (en) | 2021-06-18 |
Family
ID=66890614
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811478027.6A Active CN109861965B (en) | 2018-12-05 | 2018-12-05 | Voxel terrain data compression method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109861965B (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104616345A (en) * | 2014-12-12 | 2015-05-13 | 浙江大学 | Octree forest compression based three-dimensional voxel access method |
US20160335299A1 (en) * | 2015-05-11 | 2016-11-17 | Apple Inc. | Hierarchical Data Storage |
CN106802927A (en) * | 2016-12-22 | 2017-06-06 | 上海大汉三通数据通信有限公司 | A kind of date storage method and querying method |
WO2018066242A1 (en) * | 2016-10-04 | 2018-04-12 | Sharp Kabushiki Kaisha | Systems and methods for adaptively clipping sample values |
CN108009979A (en) * | 2017-12-15 | 2018-05-08 | 湖北大学 | Three-dimensional point cloud compression and storage method and system based on space-time data fusion |
CN108053473A (en) * | 2017-12-29 | 2018-05-18 | 北京领航视觉科技有限公司 | A kind of processing method of interior three-dimensional modeling data |
-
2018
- 2018-12-05 CN CN201811478027.6A patent/CN109861965B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104616345A (en) * | 2014-12-12 | 2015-05-13 | 浙江大学 | Octree forest compression based three-dimensional voxel access method |
US20160335299A1 (en) * | 2015-05-11 | 2016-11-17 | Apple Inc. | Hierarchical Data Storage |
WO2018066242A1 (en) * | 2016-10-04 | 2018-04-12 | Sharp Kabushiki Kaisha | Systems and methods for adaptively clipping sample values |
CN106802927A (en) * | 2016-12-22 | 2017-06-06 | 上海大汉三通数据通信有限公司 | A kind of date storage method and querying method |
CN108009979A (en) * | 2017-12-15 | 2018-05-08 | 湖北大学 | Three-dimensional point cloud compression and storage method and system based on space-time data fusion |
CN108053473A (en) * | 2017-12-29 | 2018-05-18 | 北京领航视觉科技有限公司 | A kind of processing method of interior three-dimensional modeling data |
Non-Patent Citations (1)
Title |
---|
王鸿亮等: "基于双层次八叉树的STL模型体素化方法", 《计算机集成制造系统》 * |
Also Published As
Publication number | Publication date |
---|---|
CN109861965B (en) | 2021-06-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6184897B1 (en) | Compressed representation of changing meshes and method to decompress | |
US10270468B2 (en) | Method for file updating and version control for linear erasure coded and network coded storage | |
DE68907812T2 (en) | Method and device for encoding, decoding and transmitting data in compressed form. | |
DE102010046891B4 (en) | Hierarchical network quantization for memory-efficient raytracing | |
US6445389B1 (en) | Compression of polygonal models with low latency decompression | |
CN106815330B (en) | Method and system for generating block chain expanded along spatial dimension | |
CN107077479A (en) | Set up from row data storage storehouse is self adaptive based on query demand using discrete data storehouse system and update the migration based on sentence of column storage database | |
CN105302591B (en) | The communication means of Double MCUs Architecture system update program | |
CN107563949A (en) | Image guard method and device, image restoring method and device | |
CN110389848B (en) | Partial repetition code construction method based on block construction and fault node repair method | |
CN106484559A (en) | A kind of building method of check matrix and the building method of horizontal array correcting and eleting codes | |
CN105704028A (en) | Message processing method and message processing device | |
CN105608197B (en) | The acquisition methods and system of Memcache data under a kind of high concurrent | |
CN111221780A (en) | Server file safe storage method based on block chain | |
CN111768467A (en) | Image filling method, device, equipment and storage medium | |
CN109861965A (en) | A kind of voxel Terrain Data Compression method and system | |
CN111596862B (en) | Independent optimization method and system for block chain historical transaction data | |
CN112290953B (en) | Array encoding device and method, array decoding device and method for multi-channel data stream | |
CN105843663A (en) | Coding and decoding method applicable to ASN.1 recursive solution data structure description | |
CN116170527A (en) | Message editing method, message editing device, medium and electronic equipment | |
CN115982177A (en) | Data collection method, device, equipment and medium based on tree dimensionality | |
CN110569291A (en) | Key data query and acquisition method and device for digital currency wallet | |
CN111131015B (en) | Method for dynamically updating route based on PC-Trie | |
CN108959584A (en) | A kind of method and device of the processing diagram data based on community structure | |
CN105320684A (en) | Data exchange method of closed captions |
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 |