CN104700413A - Real-time dynamic drawing method for vegetation in three-dimensional virtual scene - Google Patents

Real-time dynamic drawing method for vegetation in three-dimensional virtual scene Download PDF

Info

Publication number
CN104700413A
CN104700413A CN201510126037.3A CN201510126037A CN104700413A CN 104700413 A CN104700413 A CN 104700413A CN 201510126037 A CN201510126037 A CN 201510126037A CN 104700413 A CN104700413 A CN 104700413A
Authority
CN
China
Prior art keywords
vegetation
chunk
vegflag
jth
value
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.)
Pending
Application number
CN201510126037.3A
Other languages
Chinese (zh)
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.)
Academy of Armored Forces Engineering of PLA
Original Assignee
Academy of Armored Forces Engineering of PLA
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 Academy of Armored Forces Engineering of PLA filed Critical Academy of Armored Forces Engineering of PLA
Priority to CN201510126037.3A priority Critical patent/CN104700413A/en
Publication of CN104700413A publication Critical patent/CN104700413A/en
Pending legal-status Critical Current

Links

Abstract

The invention provides a real-time dynamic drawing method for the vegetation in a three-dimensional virtual scene. The method comprises the steps of carrying out space division on a terrain scene through a Q-Tree; dividing the scene into layered space node on a two-dimension plane; on this basis, taking a chunk as a unit, and controlling vegetation generating areas and types according to the specific value of the body size of the vegetation and the chunk of a viewpoint distance, so as to ensure that the visually perceptible vegetation can be generated in an area corresponding to a vegetation distribution drawing. The real-time dynamic drawing method provided by the invention can be applicable to different terrain generating algorithms, the controllable generation and real-time drawing of various vegetations in a large area can be realized, and the better balance between the sense of reality and the instantaneity of the large area of vegetation drawn can be realized.

Description

A kind of real-time dynamic drafting method of vegetation of three-dimensional virtual scene
Technical field
The invention belongs to 3 D complex scene real-time drafting field, particularly relate to vegetation real-time rendering in three-dimensional scenic.
Background technology
In 3 D complex scene real-time drafting, the real-time rendering of large-scale outdoor scene is widely used in generalized information system, flight simulation system, VR system and Virtual Battlefield.An outstanding three-dimensional outdoor scene not only needs to ensure real-time, also need to create natural scene very true to nature, wherein the real-time rendering of large area vegetation is most important, vegetation is the important component part of natural scene on the one hand, and it is the basis of guaranteeing three-dimensional scenic verisimilitude that vegetation true to nature is drawn; The kind of occurring in nature vegetation is many on the other hand, quantity large, complex structure, and the drafting of large area vegetation can consume a large amount of computational resources, causes serious impact to the real-time of system.The real-time rendering of large area vegetation is the Focal point and difficult point of 3 D complex scene real-time drafting area research always.
At present in the sense of reality, the drafting for single vegetation can show in details with dynamically and reach good effect; In real-time rendering, rendering technique for dense vegetation on a large scale also has a lot of algorithm, these algorithms generally adopt multi-level method of drawing, namely large-area vegetation distinguished closely, middle distance, carry out the drafting of different details at a distance, when many times ensure that real-time, have ignored the demand of the sense of reality.The vegetation of occurring in nature comes in every shape, and type body size varies, and being merely according to drawing at many levels, can not embodying the specific diversity of vegetation and the stereovision of distribution, making the overall verisimilitude of scene not high with distance.
Summary of the invention
For solving the problem, the invention provides the real-time dynamic drafting method of vegetation of three-dimensional virtual scene, be applicable to different terrain generation algorithm, multiple types, the controlled generation of large area vegetation and real-time rendering can be realized, between the sense of reality of drawing large area vegetation and real-time, obtain good equilibrium.
The real-time dynamic drafting method of vegetation of three-dimensional virtual scene of the present invention, is characterized in that, comprising:
Step 1: form vegetation distribution gray-scale map according to the distribution of vegetation in three-dimensional virtual scene, and utilize the distribution of the form of layer to described vegetation to mark in the mode of the corresponding a kind of vegetation pattern of layer, set up described vegetation and described vegetation simultaneously and to distribute the corresponding relation of pixel value byte position in gray-scale map;
Step 2: with terrain scene whole in three-dimensional virtual scene for root node, split step by step, until the size of the bottom leaf node of tree reaches the size of the smallest partition terrain block Chunk specified, sets up the Quadtree Partition structure of three-dimensional virtual scene; And the Chunk represented for each bottom leaf node adds an array VegFlag [n], wherein n is the byte number that in described vegetation distribution gray-scale map, pixel color is corresponding;
Described VegFlag [i] represents that the vegetation example of i-th kind of vegetation in current C hunk generates state, and vegetation example is all individual collections of certain class vegetation, concrete:
VegFlag [i]=0 represents that the vegetation example of i-th kind of vegetation in current C hunk not yet generates;
VegFlag [i]=1 represents that the vegetation example of i-th kind of vegetation in current C hunk generates, and is in active state;
VegFlag [i]=2 represents that the vegetation example of i-th kind of vegetation in current C hunk is in memory buffer state, is temporarily stored in internal memory;
VegFlag [i]=3 represents that the vegetation example of i-th kind of vegetation in current C hunk is in external memory buffer status, described external memory buffer status refers to that the vegetation example of i-th kind of vegetation in current C hunk empties from internal memory, but the relevant information of vegetation example has been kept at outside temporary file, the vegetation example that outside temporary file regenerates i-th kind of vegetation in current C hunk when needing, directly can be loaded;
Step 3: travel through all Chunk, in units of Chunk, dynamically generates the vegetation example of corresponding types in real time according to described vegetation distribution gray-scale map:
Step 31: top-down traversal is carried out to the quad-tree structure of described three-dimensional virtual scene, judge the validity of all Chunk, so-called validity refers to that Chunk is positioned at three-dimensional scenic camera within sweep of the eye: the Chunk of the scope that comes into view has validity, performs step 32; Exit the Chunk of field range without validity, and judge whether the vegetation example of i-th kind of vegetation generates according to the value of VegFlag [i], if VegFlag [i]=1, VegFlag [i]=2 is set, perform step 33; If VegFlag [i]=2, directly perform step 33; If VegFlag [i]=0, without the need to operation; If VegFlag [i]=3, without the need to operation;
Step 32: traversing operation is carried out to all Chunk, in units of Chunk, carry out the dynamic generation of vegetation example:
Step 321, for a jth Chunk, according to the volume coordinate on its four summits according to w = α × ( x - x 0 ) h = α × ( y - y 0 ) Be pixel coordinate by space coordinate conversion, obtain the corresponding area grayscale figure of a jth Chunk in described vegetation distribution gray-scale map according to pixel coordinate; Wherein x 0for jth Chunk minimum value on world coordinate system x direction, y 0for jth Chunk minimum value on world coordinate system y direction, α is mark precision, represents and can identify the least unit that vegetation distributes, and (w, h) is the pixel coordinate of vegetation distribution gray-scale map;
Step 322, carries out by pixel traversal to this area grayscale figure, for the i-th byte position, if a jth Chunk existence value is the pixel of 1, then illustrates that i-th kind of vegetation exists in a jth Chunk, performs step 323; If there is no value is the pixel of 1, then illustrate that i-th kind of vegetation does not exist in a jth Chunk, without the need to process;
Step 323: for the i-th kind of vegetation existed in a jth Chunk, according to β i=h i/ D ratio calculated β i, h ibe the height of i-th kind of vegetation, D is the distance of jth between Chunk and viewpoint, and judges: if β ibe greater than appointment threshold value, then illustrate that i-th kind of vegetation exists and visible in a jth Chunk, execution step 324; If β ibe less than the threshold value of specifying, then illustrate that i-th kind of vegetation exists but invisible in a jth Chunk, execution step 325;
Step 324: exist and visible i-th kind of vegetation for a jth Chunk, judge whether the vegetation example of i-th kind of vegetation generates in a jth Chunk according to the value of VegFlag [i], if VegFlag [i]=1, then without the need to process; If VegFlag [i]=2, then all vegetation examples of i-th kind of vegetation in a jth Chunk in enabled memory, arrange VegFlag [i]=1; If VegFlag [i]=3, then load all vegetation examples that outside temporary file regenerates i-th kind of vegetation in a jth Chunk, and VegFlag [i]=1 is set; If VegFlag [i]=0, then perform the vegetation example of i-th kind of vegetation at a jth Chunk dynamically generated operations; By above process, in a jth Chunk, the vegetation example of i-th kind of vegetation dynamically generates complete;
Step 325: exist and sightless i-th kind of vegetation in a jth Chunk, judge whether the vegetation example of i-th kind of vegetation generates in a jth Chunk according to the value of VegFlag [i], if VegFlag [i]=1, VegFlag [i]=2 is set, and to arrange surge time be 0, perform step 33; If VegFlag [i]=2, directly perform step 33; If VegFlag [i]=0, without the need to operation; If VegFlag [i]=3, without the need to operation;
Step 33, the vegetation example namely VegFlag [i]=2 being in i-th kind of vegetation of interior buffer status in a jth Chunk carries out surge time accumulation calculating, if the surge time under interior buffer status is greater than given threshold value, the buffer culture whether existed about i-th kind of vegetation in a jth Chunk is searched in outside temporary file, if existed, then direct all vegetation examples of i-th kind of vegetation in a jth Chunk to be deleted; If there is no, then by the quantity of all vegetation examples of i-th kind of vegetation in a jth Chunk, volume coordinate, direction, size write buffer culture, then delete, and VegFlag [i]=3 is set;
Step 4: the drafting of vegetation: travel through all Chunk, judges the value of VegFlag [i] one by one, wherein i=0 in units of Chunk, 2 ... n-1, if VegFlag [i]=0 or VegFlag [i]=3, illustrates that vegetation example does not exist, do not need process; If VegFlag [i]=2, the vegetation example of i-th kind of vegetation is directly set to invisible; If VegFlag [i]=1, the process of observability redundancy is carried out to the vegetation example of i-th kind of vegetation, the process of so-called observability redundancy is that original visible vegetation example pressure part being positioned at visible range border is set to invisible, and when vegetation example is drawn, the visibility of vegetation example is reduced the catercorner length of a Chunk, the transitional zone of at least one Chunk is produced between vegetation example generates and draws, for the Chunk beyond transitional zone, directly in units of Chunk, all vegetation examples of i-th kind of vegetation are set to visible; For the Chunk in transitional zone, with single vegetation example for object reference figure API application programming interface carries out visibility judge, the result according to judging is drawn for visible vegetation example, does not draw for sightless vegetation example.
Further, the method that in described step 324, the vegetation example of i-th kind of vegetation dynamically generates at a jth Chunk is as follows:
Step a, according to a jth Chunk in the locus of whole terrain scene, calculate coordinate, the size and Orientation of i-th kind of all example of vegetation respectively, its coordinates computed formula is as follows:
x 1 , j = x min , j + ( rand [ 0,1 ] - 0.5 ) × d i y 1 , j = y min , j + ( rand [ 0,1 ] - 0.5 ) × d i · · · x n , j = x n - 1 , j + ( rand [ 0,1 ] - 0.5 ) × d i y m , j = y m - 1 , j + ( rand [ 0,1 ] - 0.5 ) × d i n j = x max , j - x min , j m j = y max , j - y min , j
Wherein: x min, j, x max, j, y min, j, y max, jbe respectively the minimum minimum value of jth Chunk x coordinate, y coordinate in whole terrain scene; d ifor the distribution density of vegetation i; Rand [0,1] represents the random number between 0 to 1.
Step b, carries out combination of two by the value of x and y of calculating, can obtain m × n group coordinate ) each organizes the position that coordinate represents a vegetation example, successively each group coordinate is utilized to the volume coordinate image rotation element coordinate formula in step 321, obtain the gray-scale value of this locus pixel coordinate corresponding in vegetation distribution gray-scale map, if the value of the i-th byte position of gray-scale value is 0, illustrate that this locus is not in distributed areas, do not do any process; If value is 1, illustrate that this locus is positioned at distributed areas, need an example of generation i-th kind of vegetation;
Step c, calculated direction and size, formula is as follows:
S = s i + ( rand [ 0,1 ] - 0.5 ) × var i γ = rand [ 0,1 ] × 2 π
Wherein: s iit is the mean size of i-th kind of vegetation; var iit is the size variation burst length of i-th kind of vegetation;
Steps d, inquiry topographic database, obtains { x k, y lthe height value z of place's landform kl, { x in terrain scene k, y l, z klplace generates the vegetation example of i-th kind of vegetation that a size is S, direction is γ.
Beneficial effect
The real-time dynamic drafting method of vegetation of three-dimensional virtual scene of the present invention extracts vegetation distribution plan in the mode of layer, set up the mapping relations of shaped area and vegetation pattern based on this, achieved any mixed distribution of variety classes vegetation by the superposition between layer, embody the random character of vegetation distribution.
With quaternary tree (Q-Tree), compartition is carried out to terrain scene, two dimensional surface is the space nodes of stratification scene partitioning, on this basis, with block (Chunk) for unit, according to the ratio of the body size of vegetation and the size of view distance Chunk, the region generate vegetation and kind control, and guarantee only corresponding at the vegetation distribution plan perceptible vegetation of Area generation vision.
Making that the size of vegetation, direction, color and position distribution have certain randomness by introducing stochastic variable, realizing the scrambling of vegetation in form and distribution.
The generation of vegetation and visibility judge adopt asynchronous pattern, the generation of vegetation is in units of Chunk and vegetation pattern, the visibility judge part of vegetation is in units of Chunk, part is in units of single vegetation example, both the high-level efficiency of the generation of a large amount of vegetation example and visibility judge had been guaranteed, also can avoid occurring in units of block because of vegetation or disappear and producing visual discontinuous sense, what realize that Vegetation trends in viewpoint moving process upgrades is efficient and level and smooth.
In the generative process of vegetation, introducing vegetation in buffering solution viewpoint moving process and frequently generate and delete the consumption to computational resource, reducing by setting up memory buffer the probability that when viewpoint moves forward and backward, vegetation repeatedly generates and deletes; By setting up outer buffer memory, vegetation instance properties in Chunk is preserved, generate the extra calculated amount that Stochastic sum inquiry Terrain Elevation brings when avoiding the vegetation example in same Chunk repeatedly to create, twice, front and back vegetation also can be avoided to generate inconsistent phenomenon simultaneously.
Accompanying drawing explanation
Multiple vegetation distribution schematic diagram in Fig. 1 gray-scale map mark scene;
Fig. 2 final scene vegetation distribution gray-scale map;
Fig. 3 quaternary tree scene cut schematic diagram;
The Effective judgement schematic diagram of Fig. 4 Chunk;
Fig. 5 vegetation visibility judge schematic diagram;
Fig. 6 Chunk interplantation is generated schematic diagram;
Embodiment
The vegetation real-time dynamic drafting method concrete steps of three-dimensional virtual scene of the present invention are as follows:
Step 1: form vegetation distribution gray-scale map according to the distribution of vegetation in three-dimensional virtual scene.The distribution of form to vegetation of layer is used to mark, a corresponding a kind of vegetation of layer, as shown in Figure 1.
Concrete method is:
Step 11: create according to the size of landform that a width gray scale is 256 rank, resolution is the gray-scale map of W × H, wherein X is the length of landform, Y is the width of landform, and α is mark precision, represents and can identify the least unit that vegetation distributes, then meet following formula:
W/H=X/Y
X/W=α
The each pixel value of gray-scale map on 256 rank is represented by the byte of 8, every 1 a kind of vegetation pattern of correspondence in byte, adopt and in this way the distribution of vegetation is marked, the distribution situation of different types vegetation is described with minimum memory consumption, 256 rank gray-scale maps can mark at most the distribution situation of 8 kinds of vegetation, can increase in practical application and represent that the byte number of each pixel color is to increase the kind of vegetation, the such as image of RGBA four-way, each pixel is represented by 32 bit bytes, can prop up the distribution of expression 32 kinds of vegetation patterns.
Step 12: the corresponding relation setting up vegetation pattern and gray-scale map pixel value byte position, first sorts according to type body size to all vegetation patterns in scene, distinguishes the low level of corresponding grey scale pixel from low to high to high-order.According to the distribution of different types vegetation, be the byte position assignment of correspondence, 1 represents that locus corresponding to pixel exists the vegetation pattern of this byte position correspondence, 0 represents not exist, locus coordinate (x, y) is as follows with the transformational relation of pixel coordinate (w, h):
w=α×(x-x 0)
h=α×(y-y 0)
Wherein, x 0for terrain mesh minimum value on world coordinate system x direction, y 0for landform minimum value on world coordinate system y direction, the vegetation distribution gray-scale map of generation as shown in Figure 2.
Step 2: carry out Quadtree Partition to three-dimensional virtual scene, quaternary tree is that one sorts and grouped data structure very efficiently, can realize Nodes Retrieval and location fast.With whole terrain scene for root node, split step by step, until the size of the bottom leaf node of tree reaches the size of specifying, as shown in Figure 3, and the smallest partition terrain block (Chunk) represented for each bottom leaf node adds an array VegFlag [n], represent the generation state of certain vegetation in Chunk, wherein n represents vegetation distribution gray-scale map pixel color byte number in step 11.
Step 3: all Chunk are traveled through, in units of Chunk, dynamically generate the vegetation example of corresponding types in real time according to vegetation distribution gray-scale map in step 11, concrete steps are as follows:
The Effective judgement of step 31:Chunk.Top-down traversal is carried out to the quad-tree structure that step 2 builds, judge the validity of all Chunk, so-called validity refers to that Chunk is positioned at three-dimensional scenic camera within sweep of the eye: the Chunk of the scope that comes into view has validity, as the Chunk that grey in Fig. 4 is filled, performs step 32; Exit the Chunk of field range without validity, as Chunk unfilled in Fig. 4, judge whether the vegetation example of i-th kind of vegetation generates according to the value of VegFlag [i], if VegFlag [i]=1, VegFlag [i]=2 is set, performs step 33; If VegFlag [i]=2, directly perform step 33; If VegFlag [i]=0, without the need to operation; If VegFlag [i]=3, without the need to operation;
Step 32: traversing operation is carried out to all Chunk, in units of Chunk, carry out the dynamic generation of vegetation example:
Step 321, for a jth Chunk, according to the volume coordinate on its four summits according to w = α × ( x - x 0 ) h = α × ( y - y 0 ) Be pixel coordinate by space coordinate conversion, obtain the corresponding area grayscale figure of a jth Chunk in described vegetation distribution gray-scale map according to pixel coordinate; Wherein x 0for jth Chunk minimum value on world coordinate system x direction, y 0for jth Chunk minimum value on world coordinate system y direction, α is mark precision, represents and can identify the least unit that vegetation distributes, and (w, h) is the pixel coordinate of vegetation distribution gray-scale map;
Step 322, carries out by pixel traversal to this area grayscale figure, for the i-th byte position, if a jth Chunk existence value is the pixel of 1, then illustrates that i-th kind of vegetation exists in a jth Chunk, performs step 323; If there is no value is the pixel of 1, then illustrate that i-th kind of vegetation does not exist in a jth Chunk, without the need to process;
Step 323: for the i-th kind of vegetation existed in a jth Chunk, according to β i=h i/ D ratio calculated β i, h ibe the height of i-th kind of vegetation, D is the distance of jth between Chunk and viewpoint, and judges: if β ibe greater than appointment threshold value, then illustrate that i-th kind of vegetation exists and visible in a jth Chunk, execution step 324; If β ibe less than the threshold value of specifying, then illustrate that i-th kind of vegetation exists but invisible in a jth Chunk, execution step 325;
Step 324: exist and visible i-th kind of vegetation for a jth Chunk, judge whether the vegetation example of i-th kind of vegetation generates in a jth Chunk according to the value of VegFlag [i], if VegFlag [i]=1, then without the need to process; If VegFlag [i]=2, then all vegetation examples of i-th kind of vegetation in a jth Chunk in enabled memory, arrange VegFlag [i]=1; If VegFlag [i]=3, then load all vegetation examples that outside temporary file regenerates i-th kind of vegetation in a jth Chunk, and VegFlag [i]=1 is set; If VegFlag [i]=0, then perform the vegetation example of i-th kind of vegetation at a jth Chunk dynamically generated operations; By above process, in a jth Chunk, the vegetation example of i-th kind of vegetation dynamically generates complete;
Step 325: exist and sightless i-th kind of vegetation in a jth Chunk, judge whether the vegetation example of i-th kind of vegetation generates in a jth Chunk according to the value of VegFlag [i], if VegFlag [i]=1, VegFlag [i]=2 is set, and to arrange surge time be 0, perform step 33; If VegFlag [i]=2, directly perform step 33; If VegFlag [i]=0, without the need to operation; If VegFlag [i]=3, without the need to operation;
Step 33, the vegetation example namely VegFlag [i]=2 being in i-th kind of vegetation of interior buffer status in a jth Chunk carries out surge time accumulation calculating, if the surge time under interior buffer status is greater than given threshold value, the buffer culture whether existed about i-th kind of vegetation in a jth Chunk is searched in outside temporary file, if existed, then direct all vegetation examples of i-th kind of vegetation in a jth Chunk to be deleted; If there is no, then by the quantity of all vegetation examples of i-th kind of vegetation in a jth Chunk, volume coordinate, direction, size write buffer culture, then delete, and VegFlag [i]=3 is set;
Step 4: the drafting of vegetation: travel through all Chunk, judges the value of VegFlag [i] one by one, wherein i=0 in units of Chunk, 2 ... n-1, if VegFlag [i]=0 or VegFlag [i]=3, illustrates that vegetation example does not exist, do not need process, if VegFlag [i]=2, the vegetation example of i-th kind of vegetation is directly set to invisible, if VegFlag [i]=1, the process of observability redundancy is carried out to the vegetation example of i-th kind of vegetation, the process of so-called observability redundancy is that original visible vegetation example pressure part being positioned at visible range border is set to invisible, and when vegetation example is drawn, the visibility of vegetation example is reduced the catercorner length of a Chunk, the transitional zone of at least one Chunk is produced between vegetation example generates and draws, as shown in Figure 5, for the Chunk beyond transitional zone, directly in units of Chunk, all vegetation examples of i-th kind of vegetation are set to visible, for the Chunk in transitional zone, with single vegetation example for object reference figure API application programming interface carries out visibility judge, the result according to judging is drawn for visible vegetation example, does not draw for sightless vegetation example.
The method that in above-mentioned steps 324, the vegetation example of i-th kind of vegetation dynamically generates at a jth Chunk is as follows:
According to a jth Chunk in the locus of whole terrain scene, calculate coordinate, the size and Orientation of i-th kind of all example of vegetation respectively, its coordinates computed formula is as follows:
x 1 , j = x min , j + ( rand [ 0,1 ] - 0.5 ) × d i y 1 , j = y min , j + ( rand [ 0,1 ] - 0.5 ) × d i · · · x n , j = x n - 1 , j + ( rand [ 0,1 ] - 0.5 ) × d i y m , j = y m - 1 , j + ( rand [ 0,1 ] - 0.5 ) × d i n j = x max , j - x min , j m j = y max , j - y min , j
Wherein: x min, j, x max, j, y min, j, y max, jbe respectively the minimum minimum value of jth Chunk x coordinate, y coordinate in whole terrain scene; d ifor the distribution density of vegetation i; Rand [0,1] represents the random number between 0 to 1.
The value of x and y of calculating is carried out combination of two, m × n group coordinate { x can be obtained k, y l(k=1,2 ... n j; L=1,2 ... m j), each group coordinate represents the position of a vegetation example, successively each group coordinate is utilized to the volume coordinate image rotation element coordinate formula in step 321, obtain the gray-scale value of this locus pixel coordinate corresponding in vegetation distribution gray-scale map, if the value of the i-th byte position of gray-scale value is 0, illustrate that this locus is not in distributed areas, do not do any process; If value is 1, illustrate that this locus is positioned at distributed areas, need an example of generation i-th kind of vegetation, as shown in Figure 6, calculated direction and size, formula is as follows:
S = s i + ( rand [ 0,1 ] - 0.5 ) × var i γ = rand [ 0,1 ] × 2 π
Wherein: s iit is the mean size of i-th kind of vegetation; var iit is the size variation burst length of i-th kind of vegetation;
Inquiry topographic database, obtains { x k, y lthe height value z of place's landform kl, { x in terrain scene k, y l, z klplace generates the vegetation example of i-th kind of vegetation that a size is S, direction is γ.
Certainly, the present invention can also have other various embodiments, such as, in the three-dimensional virtual scene real-time dynamic drafting of a large amount of random scatter such as rubble, paper scrap object.When not deviating from the present invention's spirit and essence thereof, those of ordinary skill in the art can make various corresponding change and distortion according to the present invention, but these change accordingly and are out of shape the protection domain that all should belong to the claim appended by the present invention.

Claims (2)

1. the real-time dynamic drafting method of the vegetation of three-dimensional virtual scene, is characterized in that, comprising:
Step 1: form vegetation distribution gray-scale map according to the distribution of vegetation in three-dimensional virtual scene, and utilize the distribution of the form of layer to described vegetation to mark in the mode of the corresponding a kind of vegetation pattern of layer, set up described vegetation and described vegetation simultaneously and to distribute the corresponding relation of pixel value byte position in gray-scale map;
Step 2: with terrain scene whole in three-dimensional virtual scene for root node, split step by step, until the size of the bottom leaf node of tree reaches the size of the smallest partition terrain block Chunk specified, sets up the Quadtree Partition structure of three-dimensional virtual scene; And the Chunk represented for each bottom leaf node adds an array VegFlag [n], wherein n is the byte number that in described vegetation distribution gray-scale map, pixel color is corresponding;
Described VegFlag [i] represents that the vegetation example of i-th kind of vegetation in current C hunk generates state, and vegetation example is all individual collections of certain class vegetation, concrete:
VegFlag [i]=0 represents that the vegetation example of i-th kind of vegetation in current C hunk not yet generates;
VegFlag [i]=1 represents that the vegetation example of i-th kind of vegetation in current C hunk generates, and is in active state;
VegFlag [i]=2 represents that the vegetation example of i-th kind of vegetation in current C hunk is in memory buffer state, is temporarily stored in internal memory;
VegFlag [i]=3 represents that the vegetation example of i-th kind of vegetation in current C hunk is in external memory buffer status, described external memory buffer status refers to that the vegetation example of i-th kind of vegetation in current C hunk empties from internal memory, but the relevant information of vegetation example has been kept at outside temporary file, the vegetation example that outside temporary file regenerates i-th kind of vegetation in current C hunk when needing, directly can be loaded;
Step 3: travel through all Chunk, in units of Chunk, dynamically generates the vegetation example of corresponding types in real time according to described vegetation distribution gray-scale map:
Step 31: top-down traversal is carried out to the quad-tree structure of described three-dimensional virtual scene, judge the validity of all Chunk, so-called validity refers to that Chunk is positioned at three-dimensional scenic camera within sweep of the eye: the Chunk of the scope that comes into view has validity, performs step 32; Exit the Chunk of field range without validity, and judge whether the vegetation example of i-th kind of vegetation generates according to the value of VegFlag [i], if VegFlag [i]=1, VegFlag [i]=2 is set, perform step 33; If VegFlag [i]=2, directly perform step 33; If VegFlag [i]=0, without the need to operation; If VegFlag [i]=3, without the need to operation;
Step 32: traversing operation is carried out to all Chunk, in units of Chunk, carry out the dynamic generation of vegetation example:
Step 321, for a jth Chunk, according to the volume coordinate on its four summits according to w = α × ( x - x 0 ) h = α × ( y - y 0 ) Be pixel coordinate by space coordinate conversion, obtain the corresponding area grayscale figure of a jth Chunk in described vegetation distribution gray-scale map according to pixel coordinate; Wherein x 0for jth Chunk minimum value on world coordinate system x direction, y 0for jth Chunk minimum value on world coordinate system y direction, α is mark precision, represents and can identify the least unit that vegetation distributes, and (w, h) is the pixel coordinate of vegetation distribution gray-scale map;
Step 322, carries out by pixel traversal to this area grayscale figure, for the i-th byte position, if a jth Chunk existence value is the pixel of 1, then illustrates that i-th kind of vegetation exists in a jth Chunk, performs step 323; If there is no value is the pixel of 1, then illustrate that i-th kind of vegetation does not exist in a jth Chunk, without the need to process;
Step 323: for the i-th kind of vegetation existed in a jth Chunk, according to β i=h i/ D ratio calculated β i, h ibe the height of i-th kind of vegetation, D is the distance of jth between Chunk and viewpoint, and judges: if β ibe greater than appointment threshold value, then illustrate that i-th kind of vegetation exists and visible in a jth Chunk, execution step 324; If β ibe less than the threshold value of specifying, then illustrate that i-th kind of vegetation exists but invisible in a jth Chunk, execution step 325;
Step 324: exist and visible i-th kind of vegetation for a jth Chunk, judge whether the vegetation example of i-th kind of vegetation generates in a jth Chunk according to the value of VegFlag [i], if VegFlag [i]=1, then without the need to process; If VegFlag [i]=2, then all vegetation examples of i-th kind of vegetation in a jth Chunk in enabled memory, arrange VegFlag [i]=1; If VegFlag [i]=3, then load all vegetation examples that outside temporary file regenerates i-th kind of vegetation in a jth Chunk, and VegFlag [i]=1 is set; If VegFlag [i]=0, then perform the vegetation example of i-th kind of vegetation at a jth Chunk dynamically generated operations; By above process, in a jth Chunk, the vegetation example of i-th kind of vegetation dynamically generates complete;
Step 325: exist and sightless i-th kind of vegetation in a jth Chunk, judge whether the vegetation example of i-th kind of vegetation generates in a jth Chunk according to the value of VegFlag [i], if VegFlag [i]=1, VegFlag [i]=2 is set, and to arrange surge time be 0, perform step 33; If VegFlag [i]=2, directly perform step 33; If VegFlag [i]=0, without the need to operation; If VegFlag [i]=3, without the need to operation;
Step 33, the vegetation example namely VegFlag [i]=2 being in i-th kind of vegetation of interior buffer status in a jth Chunk carries out surge time accumulation calculating, if the surge time under interior buffer status is greater than given threshold value, the buffer culture whether existed about i-th kind of vegetation in a jth Chunk is searched in outside temporary file, if existed, then direct all vegetation examples of i-th kind of vegetation in a jth Chunk to be deleted; If there is no, then by the quantity of all vegetation examples of i-th kind of vegetation in a jth Chunk, volume coordinate, direction, size write buffer culture, then delete, and VegFlag [i]=3 is set;
Step 4: the drafting of vegetation: travel through all Chunk, judges the value of VegFlag [i] one by one, wherein i=0 in units of Chunk, 2 ... n-1, if VegFlag [i]=0 or VegFlag [i]=3, illustrates that vegetation example does not exist, do not need process; If VegFlag [i]=2, the vegetation example of i-th kind of vegetation is directly set to invisible; If VegFlag [i]=1, the process of observability redundancy is carried out to the vegetation example of i-th kind of vegetation, the process of so-called observability redundancy is that original visible vegetation example pressure part being positioned at visible range border is set to invisible, and when vegetation example is drawn, the visibility of vegetation example is reduced the catercorner length of a Chunk, the transitional zone of at least one Chunk is produced between vegetation example generates and draws, for the Chunk beyond transitional zone, directly in units of Chunk, all vegetation examples of i-th kind of vegetation are set to visible; For the Chunk in transitional zone, with single vegetation example for object reference figure API application programming interface carries out visibility judge, the result according to judging is drawn for visible vegetation example, does not draw for sightless vegetation example.
2. the real-time dynamic drafting method of vegetation of three-dimensional virtual scene as claimed in claim 1, it is characterized in that, the method that in described step 324, the vegetation example of i-th kind of vegetation dynamically generates at a jth Chunk is as follows:
Step a, according to a jth Chunk in the locus of whole terrain scene, calculate coordinate, the size and Orientation of i-th kind of all example of vegetation respectively, its coordinates computed formula is as follows:
x 1 , j = x min , j + ( rand [ 0,1 ] - 0.5 ) × d i y 1 , j = y min , j + ( rand [ 0,1 ] - 0.5 ) × d i . . . x n , j = x n - 1 , j + ( rand [ 0,1 ] - 0.5 ) × d i y m , j = y m - 1 , j + ( rand [ 0,1 ] - 0.5 ) × d i n j = x max , j - x min , j m j = y max , j - y min , j
Wherein: x min, j, x max, j, y min, j, y max, jbe respectively the minimum minimum value of jth Chunk x coordinate, y coordinate in whole terrain scene; d ifor the distribution density of vegetation i; Rand [0,1] represents the random number between 0 to 1.
Step b, carries out combination of two by the value of x and y of calculating, can obtain m × n group coordinate { x k, y l(k=1,2 ... n j; L=1,2 ... m j), each group coordinate represents the position of a vegetation example, successively each group coordinate is utilized to the volume coordinate image rotation element coordinate formula in step 321, obtain the gray-scale value of this locus pixel coordinate corresponding in vegetation distribution gray-scale map, if the value of the i-th byte position of gray-scale value is 0, illustrate that this locus is not in distributed areas, do not do any process; If value is 1, illustrate that this locus is positioned at distributed areas, need an example of generation i-th kind of vegetation;
Step c, calculated direction and size, formula is as follows:
S = s i + ( rand [ 0,1 ] - 0.5 ) × var i γ = rand [ 0,1 ] × 2 π
Wherein: s iit is the mean size of i-th kind of vegetation; var iit is the size variation burst length of i-th kind of vegetation;
Steps d, inquiry topographic database, obtains { x k, y lthe height value z of place's landform kl, { x in terrain scene k, y l, z klplace generates the vegetation example of i-th kind of vegetation that a size is S, direction is γ.
CN201510126037.3A 2015-03-20 2015-03-20 Real-time dynamic drawing method for vegetation in three-dimensional virtual scene Pending CN104700413A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510126037.3A CN104700413A (en) 2015-03-20 2015-03-20 Real-time dynamic drawing method for vegetation in three-dimensional virtual scene

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510126037.3A CN104700413A (en) 2015-03-20 2015-03-20 Real-time dynamic drawing method for vegetation in three-dimensional virtual scene

Publications (1)

Publication Number Publication Date
CN104700413A true CN104700413A (en) 2015-06-10

Family

ID=53347495

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510126037.3A Pending CN104700413A (en) 2015-03-20 2015-03-20 Real-time dynamic drawing method for vegetation in three-dimensional virtual scene

Country Status (1)

Country Link
CN (1) CN104700413A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105913476A (en) * 2016-06-14 2016-08-31 腾讯科技(深圳)有限公司 Rendering method and device of vegetation image
CN108543311A (en) * 2018-04-20 2018-09-18 苏州蜗牛数字科技股份有限公司 A method of automatically generating scene vegetation system
CN108549581A (en) * 2018-04-02 2018-09-18 郑州云海信息技术有限公司 A kind of layer-stepping real-time drawing rendering intent and system
CN108665414A (en) * 2018-05-10 2018-10-16 上海交通大学 Natural scene picture generation method
CN110838162A (en) * 2019-11-26 2020-02-25 网易(杭州)网络有限公司 Vegetation rendering method and device, storage medium and electronic equipment
CN116524133A (en) * 2023-06-30 2023-08-01 腾讯科技(深圳)有限公司 Virtual vegetation generation method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0923449A (en) * 1995-07-05 1997-01-21 Hitachi Ltd Actual-photographic picture and three-dimensional model composing device
JP2001126085A (en) * 1999-08-16 2001-05-11 Mitsubishi Electric Corp Image forming system, image display system, computer- readable recording medium recording image forming program and image forming method
CN102074049A (en) * 2011-03-01 2011-05-25 哈尔滨工程大学 Wide-range terrain scheduling simplifying method based on movement of viewpoint
CN102855661A (en) * 2012-08-22 2013-01-02 浙江工业大学 Large-scale forest scene quick generation method based on space similarity

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0923449A (en) * 1995-07-05 1997-01-21 Hitachi Ltd Actual-photographic picture and three-dimensional model composing device
JP2001126085A (en) * 1999-08-16 2001-05-11 Mitsubishi Electric Corp Image forming system, image display system, computer- readable recording medium recording image forming program and image forming method
CN102074049A (en) * 2011-03-01 2011-05-25 哈尔滨工程大学 Wide-range terrain scheduling simplifying method based on movement of viewpoint
CN102855661A (en) * 2012-08-22 2013-01-02 浙江工业大学 Large-scale forest scene quick generation method based on space similarity

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
司毅博: "地理影像导航应用技术研究", 《中国优秀硕士学位论文全文数据库 基础科学辑》 *
姚凡凡 等: "基于Vega Prime的三维虚拟战场大地形动态生成研究", 《系统仿真学报》 *
张立强 等: "网络环境下三维可视化信息系统的方法研究", 《中国科学(D辑:地球科学)》 *
杜君 等: "虚拟战场环境程序化地形细节生成方法", 《装甲兵工程学院学报》 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105913476A (en) * 2016-06-14 2016-08-31 腾讯科技(深圳)有限公司 Rendering method and device of vegetation image
CN108549581A (en) * 2018-04-02 2018-09-18 郑州云海信息技术有限公司 A kind of layer-stepping real-time drawing rendering intent and system
CN108549581B (en) * 2018-04-02 2019-10-29 郑州云海信息技术有限公司 A kind of layer-stepping real-time drawing rendering method and system
CN108543311A (en) * 2018-04-20 2018-09-18 苏州蜗牛数字科技股份有限公司 A method of automatically generating scene vegetation system
CN108665414A (en) * 2018-05-10 2018-10-16 上海交通大学 Natural scene picture generation method
CN110838162A (en) * 2019-11-26 2020-02-25 网易(杭州)网络有限公司 Vegetation rendering method and device, storage medium and electronic equipment
CN110838162B (en) * 2019-11-26 2023-11-28 网易(杭州)网络有限公司 Vegetation rendering method and device, storage medium and electronic equipment
CN116524133A (en) * 2023-06-30 2023-08-01 腾讯科技(深圳)有限公司 Virtual vegetation generation method, device, equipment and storage medium
CN116524133B (en) * 2023-06-30 2024-04-02 腾讯科技(深圳)有限公司 Virtual vegetation generation method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN104700413A (en) Real-time dynamic drawing method for vegetation in three-dimensional virtual scene
CN105336003B (en) The method for drawing out three-dimensional terrain model with reference to the real-time smoothness of GPU technologies
CN102722885B (en) Method for accelerating three-dimensional graphic display
CN104463948A (en) Seamless visualization method for three-dimensional virtual reality system and geographic information system
CN103927424B (en) Simplify the method for building three-dimensional model structure using volume mesh
CN108537869B (en) Cone tracking dynamic global illumination method based on cascade texture
CN107993279B (en) Scene accurate expression method
CN111127615A (en) Data scheduling method and device of three-dimensional model and electronic equipment
CN110322547B (en) Reservoir self-adaptive tetrahedral subdivision method
CN114359500B (en) Three-dimensional modeling and visualization method for landslide hazard range prediction
CN110717967A (en) Large-scene-model-oriented web-side dynamic rendering LOD processing method
CN105913475A (en) Dynamic visualized method of space-time change process
CN110400366B (en) Real-time flood disaster visualization simulation method based on OpenGL
CN107679150A (en) Magnanimity three-dimensional data fast dispatch method
CN108986212B (en) Three-dimensional virtual terrain LOD model generation method based on crack elimination
CN113484909B (en) Method for establishing fracture-cavity reservoir based on geometric gridding and parameter distribution
CN106780693B (en) Method and system for selecting object in three-dimensional scene through drawing mode
Hsiung et al. Accelerating arts
JP3724006B2 (en) High speed rendering method and apparatus
CN117237503B (en) Geographic element data accelerated rendering and device
CN104680568A (en) Dynamic generation method for vehicle ruts in three-dimensional virtual scene
shiyun Level of detail optimization for real-time terrain
CN115937438B (en) City three-dimensional model light weight method, system, electronic equipment and storage medium
CN104102792B (en) A kind of Simulation Methods of filling mining
Ying et al. Implementation of a fast simulation algorithm for terrain based on Dynamic LOD

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20150610