SEARCH WITHIN CONTENT
Citation Information : International Journal of Advanced Network, Monitoring and Controls. Volume 3, Issue 2, Pages 84-88, DOI: https://doi.org/10.21307/ijanmc-2018-041
License : (CC-BY-NC-ND-4.0)
Published Online: 07-May-2018
This paper take the development of virtual campus roaming system as an example. Aiming at the defects of the different kinds of bounding boxes collision detection technology, analyzes the advantages of the hybrid hierarchical bounding box collision detection algorithm based on spheres and oriented bounding box, and described the way to construct it. Finally, the algorithm is tested in the VC and Unity3d engine, a good result is obtained.
Virtual reality (VR) is a comprehensive technology integrating computer graphics, multimedia technology and many other technologies. Its purpose is to simulate the scene in reality. As an open platform, it has three characteristics: interactivity, conceptualization, and immersion . In order to ensure the sense of the environment, the objects in the scene must have the corresponding physical properties. At the same time, the user will not penetrate the object in various operations, and can truly feel the occurrence of a collision. So collision detection technology has a very important position in the VR technology .
Collision detection technology is developing continuously, and some classic collision detection algorithms are widely used. Such as AABB (Aligned Axis Bounding Box), Spheres, OBB (Oriented Bounding Box), etc. these methods are applicable to objects with different geometric features, so their simplicity of detection is not ideal. Some scholars have proposed a hybrid bounding box algorithm for the reason. An algorithm similar to OBB-Spheres is formed. In continuous collision detection, some scholars proposed a subspace based algorithm, which effectively improved the speed and accuracy of continuous collision detection.
The construction of virtual campus roaming system uses collision detection technology, real-time rendering technology, environment modeling technology, etc. The collision detection technology ensures the true sense of the whole system, and constitutes the basis of the user experience, which gives the user a sense of immersion in the virtual scene.
Collision detection technology is to increase the impact body on the object in the scene, increase the sense of authenticity, prevents the appearance of the characters through the wall. The overlap of a part of a person and the object in a scene are obviously incompatible with the logic in real life . The basic principles can be defined as follows: In a virtual three-dimensional space with n objects. Its three-dimensional geometric coordinate system and time variable constitute a four dimensional coordinate system, which is represented as Cw. The path formed by the motion of the i-th object constitutes a subset of Cw. It marked as Ci(1 ≤ i ≤n). Collision detection is to determine whether the i1-th object intersects the i2-th object, That is to determine whether Ci1 ∩ Ci2 is empty.
For the detection of object collision, Unity provides a good test platform that you can create two virtual geometries in it, give them a collision device, and then detect the collision effect between them. It is also possible to create two empty objects, add two specific colliders to them, test the collisions between different colliders directly, In addition you can create an object and a ray of light that simulates the impact of light cast on an object. These correspond to the three kinds of collision detection strategy in Unity, they called basic collision detection, trigger collision detection, light projection .
There are many kinds of bounding boxes. Some classical methods include Spheres, AABB (Aligned Axis Bounding Box), OBB (Oriented Bounding Box), etc . This is the main introduction to Spheres and OBB.
Bounding sphere (Spheres) is a relatively simple but poor tightness bounding box. It will produce too much redundant space for more concave objects as an outer sphere of the geometric object. So there is a phenomenon that the collision occurs when the collision is not touched and the ball is encircled. In order to illustrate the construction process, it is assumed that the geometric object is E, The representation of all the most basic geometric elements (such as triangles and circles) in the object with SE. The calculation method of the encircling ball is simpler than that of the other bounding boxes: The average value of three sets of coordinates all the elements in the SE (triangle angle bisector intersection coordinate, circle center coordinates value) is centre of Bounding sphere, denoted by C (x, y, z). Then compare the distance between center and each basic geometric element in the object E, maximum value is that the radius of the bounding sphere, denoted by R. Thus, the parameter required to record a ball is much less than that of the other encircling boxes, Coordinates a sphere just to give the center (3 parameters) and the radius (1 Parameters). The intersecting test method between the bounding balls is relatively simple. It is only necessary to compare the distance between the two spheres and the sum of their radius. The specific methods are as follows: Assuming the center and the radius of the two surrounding spheres are s1(x1, y1, z1), R1 and s2(x2, y2, z2), R2. If ||S1 − S2||2 ≤ R1 + R2, Then two bounding balls intersected, otherwise, two bounding balls are not intersected. The detailed expression of this inequality is:
As the sphere rotates in that direction, the parameters that express its attributes will not change, So no matter the surrounding geometric objects rotates any angles, it will not run out of the ball. Therefore, when a fixed shape object moves, the encircling ball need not recalculate the radius, but only need to translate the center coordinates accordingly. But you need to recalculation the center and the radius of the object ball for a shape changing object. Therefore, the real-time and continuity of the encircling ball collision detection algorithm is poor.
It is a minimum rectangular body that contains a geometric object and has any direction in a coordinate system. How to find the best direction of the long cube when constructing OBB and determine the minimum number of reachable length and width is the key to the construction. Compared with the encircling ball, the construction of OBB seems very difficult, and the concrete construction method of OBB is as follows:
Given a geometric object, in order to distinguish the E mentioned earlier, here is G. Similarly, the SG is used to represent the set of all the most basic geometric elements in the object, such as the triangle and the circle. For the sake of simplicity, all the basic elements of the object are assumed to be triangles, It is set to have n triangles in which the three vertices of the i-th (i >0) triangle are recorded as ai, bi, and ci, The values of the mean of the set SG(denoted by μ) and the evaluation method of covariance C are as follows (ai, bi, ci are all one-dimensional vectors):
In which the μ is a one - dimensional vector, Cjk is a value, and the symmetric matrix composed of the matrix element Cjk is recorded as C. The obtained matrix C is a real symmetric matrix and has three different eigenvalues. Therefore, the eigenvectors corresponding to the three eigenvalues are orthogonal to each other. The unit processing of the three eigenvectors obtained is also given a set of base, The group also forms the three axis of the OBB, so that the best direction of the OBB is determined. The rest is to determine the minimum length and width of the OBB. To find the three smallest numbers, we only need to map the vertices of each basic geometric element in SG on the three axis of the axis just obtained. The minimum value on each axis is the required length and width.
According to the description of the above construction method, we can know that the structure of OBB is very complicated, The description of a OBB is also very troublesome, with more parameters needed. A total of 15 numbers need to be described, of which 9 numbers are used to describe three axes, each axis is represented by one dimension vector consisting of three parameters. The remaining 6 numbers represent the length and the corresponding axis of OBB length and width.
The OBB constructed by the above method has high tightness due to its arbitrariness of the substrate, and it can follow the shape change of the object to make the change of the direction length quickly and do not need to recalculate.
The three-dimensional modeling of the virtual campus is the three-dimensional modeling of the terrain, roads, buildings, plants and other objects around the campus. The main work of 3D modeling is to collect, collate, classify and pretreat the basic geographic information for the objects that need to be modeled. The underlying technologies involved are polygonal modeling and texture mapping .
In the traditional 3D scene building method, various objects in the scene have various geometric representation methods because of their different shapes and precision requirements, the most used model at present are Surface model and polygon mesh model. In the campus roaming system, the polygon mesh model is often used because the objects in the scene are mostly edges and corners. Polygonal models form the shape of the models from the most basic points and lines, then give the corresponding material to the surface of the object, and add the illumination model to increase the reality of the object. Texture mapping technology is used for material additions, a two-dimensional image that represents the surface texture of an object is mapped to the surface of a three-dimensional object. The basic idea is to map the coordinates of the texture patterns to the geometric coordinates of the vertices of the 3D models in a certain way, and then map the points on the geometric objects onto the screen, and finally display them. As shown in Figure 1.
The roaming system is a continuous cycle process that draws every frame that is displayed to the user through logical judgment, As shown in Figure 2. In order to improve the speed and real-time performance of collision detection, the traditional bounding box collision detection algorithm can not get the desired result, and the hybrid bounding box algorithm solves this problem .
A hierarchical encircling box tree is a tree structure composed of tree nodes composed of encircling boxes. According to the previous introduction, the OBB bounding box algorithm has a better compact type, and the speed is faster when the object is displaced or rotated, But the intersecting test is difficult, and the speed is slow. While the encircling ball algorithm is poor in tightness, but the intersection test is simple and fast, and it has faster update speed than the OBB algorithm. In combination with the advantages of the two algorithms, these two algorithms are selected here.
The bounding ball algorithm can be used as the root node of the bounding box tree because of the simple speed of intersecting test. It can be used to eliminate a large number of disjoint objects which are easily judged. There are two main methods used to construct encircling box trees. One bottom-up way is to form a basic geometric element of an object as a leaf node, then recursively, and gradually form the final root node, another is the top - down method, which is completely the opposite, it recursive partition from the root node, and finally to the leaf node. A top-down method is used to construct a hierarchical encircling box tree here because of the maturity of the current construction technology and the breadth of use, as shown in Figure 3.
It is considered whether it is built dynamically or in a static way when building a bounding box tree . When the static structure is built, it is necessary to rebuild the bounding box tree once the shape changes or moves. Otherwise, when the dynamic structure is used, it does not need to be rebuilt with the change of the object. Although the dynamic structure is better than the static structure, it needs to modify the node data in real time, and the stability is weak. The real-time performance of the update is difficult to solve. We use the static structure with high stability to build the bounding box tree because the objects in the virtual campus roaming system are mostly static objects, they will not change when they collide.
In order to verify that the algorithm can realize the collision detection between different geometric features well, the initial test is carried out. A teapot and a cylinder are used for a collision test. The teapot is made up of 8680 triangles and 17500 vertices, and the cylinder is made up of 8064 triangles and 16256 vertices. Its complexity can meet the test requirements. A double encircling box is constructed on the vertex of two objects surrounded by two forked trees. The outer layer of the node constructs the encircling ball, and the inner layer of the node constructs the OBB and the sphere bounding box respectively. Compare it with the collision detection algorithm based on the OBB bounding box, RAPID. According to the evaluation function of collision detection algorithm:
The algorithm and the RAPID algorithm are compared and analyzed.
On the premise of obtaining the same and correct detection results, the experiment compares the collision detection time between the two algorithms in the same collision scene. According to the collision detection evaluation function, when the two algorithms are used for collision detection, the number of basic geometric primitives pairs involved (Np) is the same, and the cost of a pair of geometric primitives (Cp) is the same. The same scene is used in the contrast experiment. The motion track of the object is the same. The number of nodes needed to be updated by the two algorithms after the motion of the object is the same as the number of Nu. This algorithm updates the cost of a double bounding box (Cu), which is the cost of updating an inner bounding box. Therefore, the total cost of the two algorithms (T) is related to the cost Nv*Cv of the bounding box overlap test and the cost Cu of updating a bounding box.
The algorithm constructs sphere and OBB for the inner layer of the two forked tree node of the teapot and the cylinder. The intersecting test of sphere and OBB is similar to the OBB algorithm, but the test is more rapid and simple, at most only three times. The sphere bounding box is less expensive to update than OBB, so the algorithm is less expensive to update a bounding box than the RAPID algorithm. The experimental results of the two algorithms are shown in Table 1, and the efficiency comparison of the algorithm is shown in Figure 4.
The experimental results show that when the number of triangle overlaps is the same, the algorithm reduces the collision detection time and the collision response between objects faster than the RAPID algorithm. it improved the reality of the scene when the object collides in real time.
With all kinds of collision bounding box collision detection algorithm is developed based on the Unity3d engine development, software developers only need to add different colliders to objects can complete the corresponding collision detection test algorithm, without the need to write the corresponding collision detection algorithm, which effectively improves the efficiency of software development . In Unity, there are mainly static colliders such as Box Collider, Sphere Collider, Capsule Collider, Wheel Collider, and rigid body colliders for dynamic objects. In this system, a rigid body collider is added to the roaming role, and various static colliders are added to the objects, such as buildings, flowers and trees, and the ground. The information processing of collision is realized through collision occurrence, collision vanishing and collision maintaining function in script , and a function of pop-up GUI interface is added to trigger the specific GUI interface in collision occurrence function. This algorithm can also test the collision function of the system through the Game interface in Unity.
When a character collides with a building, the script will trigger a collision event due to adding a collision body to a specific building attachment. Then a pop-up information window will be introduced to the corresponding building, and the result is shown in Figure 5.
We can know that the mixed level bounding box collision detection algorithm based on encircling ball and OBB bounding box has also achieved very good results in developing the system. It not only enhances the reality of the scene, but also completes the trigger of the window pop-up event through the detection of collision events, which enhances the interactivity and makes the system more humanized.
This paper studies virtual campus roaming system based on Virtual Reality Technology, Through the whole development process of the system, the implementation principle of the collision detection technology and the hybrid bounding box algorithm based on the encircling ball and the directed bounding box are emphasized.