Research on Bounding Volume Boxes Collision Detection Algorithm in Virtual Reality Technology

## Publications

/ Export Citation / / / Text size:

#### International Journal of Advanced Network, Monitoring and Controls

Xi'an Technological University

Subject: Computer Science, Software Engineering

eISSN: 2470-8038

83
151
Visit(s)
0
Comment(s)
0
Share(s)

SEARCH WITHIN CONTENT

FIND ARTICLE

Volume / Issue / page

Archive
Volume 6 (2021)
Volume 5 (2020)
Volume 4 (2019)
Volume 3 (2018)
Volume 2 (2017)
Volume 1 (2016)
Related articles

VOLUME 3 , ISSUE 2 (May 2018) > List of articles

### Research on Bounding Volume Boxes Collision Detection Algorithm in Virtual Reality Technology

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

Published Online: 07-May-2018

### ARTICLE

#### ABSTRACT

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.

## I. INTRODUCTION

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 [1]. 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 [2].

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.

## II. BASIC PRINCIPLE OF 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 [3]. 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 ≤ in). Collision detection is to determine whether the i1-th object intersects the i2-th object, That is to determine whether Ci1Ci2 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 [4].

## III. HYBRID HIERARCHICAL BOUNDING BOX BASED ON SURROUNDING AND DIRECTED BOUNDING BOXES

### A. Bounding Box Technology

There are many kinds of bounding boxes. Some classical methods include Spheres, AABB (Aligned Axis Bounding Box), OBB (Oriented Bounding Box), etc [5]. This is the main introduction to Spheres and OBB.

#### 1) Spheres:

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 ||S1S2||2R1 + R2, Then two bounding balls intersected, otherwise, two bounding balls are not intersected. The detailed expression of this inequality is:

##### (1)
$(x1−x2)2+(y1−y2)2+(z1−z2)2≤(R1+R2)2$

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.

#### 2) OBB(Oriented Bounding Box):

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):

##### (2)
$μ=13n∑i=1n(ai+bi+ci)$
##### (3)
$Cjk=13n∑i=1n(ajiaki+bjibki+cjicki),1≤j,k≤3$

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.

### B. Model Constructing

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 [6].

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.

Texture Map.

### C. Construction of Hierarchical Encircling Box Tree

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 [7].

##### Figure 2.

System Running Process

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.

##### Figure 3.

The Top-down Bounding Box Tree.

It is considered whether it is built dynamically or in a static way when building a bounding box tree [8]. 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.

## IV. SYSTEM APPLICATION AND TEST RESULTS

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:

##### (4)
$T=Nv×Cv+Np×Cp+Nu×Cu$

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.

##### TABLE I.

TABLE COLLISION DETECTION TIME COMPARISON

##### Figure 4.

Time contrast diagram of algorithm collision detection

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 [9]. 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 [10], 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.

##### Figure 5.

The information window displayed after the collision

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.

## V. CONCLUSION

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.

## ACKNOWLEDGMENT

Fund support: Shaanxi Education Department Special Fund Project number: Shaanxi Education Finance (GSYSJ20170009).

## References

1. Tang Cui-Fang, Design and Implementation of Campus Roaming System Based on Virtual Reality Technology [J], Science and Technology Innovation Herald, 2016, 20, 87-88.
2. Han Lei, Research on Virtual Building Roaming and Collision Detection Based on Unity3D [J], Academic Exchange, 2016, 19, 194-195+197.
3. Wang Yu, Research and Application of Collision Detection in Virtual Roaming System [J], Electronic Design Engineering, 2016, 13, 155-156+160.
4. Wang Feng-Qin, Research on Virtual Training System of Rock Drilling Platform Based on Unity3D [D], Shijiazhuang Tiedao University, Shijazhuang, 2016.
5. Li Zhen, Research on Optimization Algorithm for Rigid Body Collision Detection in Virtual Scene [D], Jilin Agricultural University, Changchun, 2016.
6. Wang Shuang, Cheng Yong-Dang, Kong Fan-Jin, and Yang Bin, A Survey of Virtual Reality [J], Science & Technology Vision, 2016, 11, 129+153.
7. Zhang Shao-Bo, Research on Key Technology of Human-computer Interaction in Immersive Virtual Reality [D], Chongqing University of Posts and Telecommunications, Chongqi, 2016.
8. Zhang Jia-Jia, Optimization Simulation of Collision Detection in 3D Virtual Environment [J], Computer Simulation, 2016, 03, 359-362.
9. Lai Quan, Cha Mu-Ga, Jin Eerdemutu, and Jin Hugejiletu, Development and Research of 3D Visualized Campus System Based on Unity3D Platform [J], Sci-Tech Information Development & Economy, 2016, 01, 124-127.
10. Wang Lei, The Research of Collision Detection Technology Based on Hybrid Bounding Box and Its Application in Web3D Roaming [D]. Shanghai University, Shanghai, 2015.

### FIGURES & TABLES

Figure 1.

Texture Map.

Figure 2.

System Running Process

Figure 3.

The Top-down Bounding Box Tree.

Figure 4.

Time contrast diagram of algorithm collision detection

Figure 5.

The information window displayed after the collision

TABLE I.

TABLE COLLISION DETECTION TIME COMPARISON

### REFERENCES

1. Tang Cui-Fang, Design and Implementation of Campus Roaming System Based on Virtual Reality Technology [J], Science and Technology Innovation Herald, 2016, 20, 87-88.
2. Han Lei, Research on Virtual Building Roaming and Collision Detection Based on Unity3D [J], Academic Exchange, 2016, 19, 194-195+197.
3. Wang Yu, Research and Application of Collision Detection in Virtual Roaming System [J], Electronic Design Engineering, 2016, 13, 155-156+160.
4. Wang Feng-Qin, Research on Virtual Training System of Rock Drilling Platform Based on Unity3D [D], Shijiazhuang Tiedao University, Shijazhuang, 2016.
5. Li Zhen, Research on Optimization Algorithm for Rigid Body Collision Detection in Virtual Scene [D], Jilin Agricultural University, Changchun, 2016.
6. Wang Shuang, Cheng Yong-Dang, Kong Fan-Jin, and Yang Bin, A Survey of Virtual Reality [J], Science & Technology Vision, 2016, 11, 129+153.
7. Zhang Shao-Bo, Research on Key Technology of Human-computer Interaction in Immersive Virtual Reality [D], Chongqing University of Posts and Telecommunications, Chongqi, 2016.
8. Zhang Jia-Jia, Optimization Simulation of Collision Detection in 3D Virtual Environment [J], Computer Simulation, 2016, 03, 359-362.
9. Lai Quan, Cha Mu-Ga, Jin Eerdemutu, and Jin Hugejiletu, Development and Research of 3D Visualized Campus System Based on Unity3D Platform [J], Sci-Tech Information Development & Economy, 2016, 01, 124-127.
10. Wang Lei, The Research of Collision Detection Technology Based on Hybrid Bounding Box and Its Application in Web3D Roaming [D]. Shanghai University, Shanghai, 2015.