0% found this document useful (0 votes)
145 views5 pages

A New Method of Virtual Reality Based On Unity3D

This document discusses using the Unity3D game engine as a platform for virtual reality development. It presents a framework with three layers - presentation, logic, and data. Spatial and attribute data are collected and models are created in 3Ds Max and AutoCAD. These 3D models are then imported into Unity3D and programmed with JavaScript to create game objects and scenes. The scenes are integrated and published online for visitors to explore the virtual environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views5 pages

A New Method of Virtual Reality Based On Unity3D

This document discusses using the Unity3D game engine as a platform for virtual reality development. It presents a framework with three layers - presentation, logic, and data. Spatial and attribute data are collected and models are created in 3Ds Max and AutoCAD. These 3D models are then imported into Unity3D and programmed with JavaScript to create game objects and scenes. The scenes are integrated and published online for visitors to explore the virtual environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

A New Method of Virtual Reality Based on Unity3D

Sa Wang1,2*, Zhengli Mao2, Changhai Zeng2, Huili Gong1, Shanshan Li1, Beibei Chen1
1
The Key Lab of Resource Environment and GIS, Capital Normal University, Beijing, China
2
Department of Surveying and Urban Spatial Information, Henan University of Urban Construction, Pingdingshan, China
*
Corresponding author: [email protected]

Abstract—In the area of geographic information system, there which support databases, regular expressions, XML, file access
are always two methods to get 3D virtual reality, one is to use a and networking. Scripting is frequently thought of as limited
2D professional platform such as ArcGIS software to get the and slow, but in Unity3D scripts are compiled to native code
virtual reality by secondary development, the other is to use a 3D and run nearly as fast as C++. It is easy to get the fast iteration
or 2.5D software as a platform for development, such as the times and ease of use for someone who likes scripting
Skyline software. In this paper, we will use a different platform, languages. These three languages in game development
Unity3D, which is usually treated as game development software, projects can also be mixed-use.Unity3d also supports the
as a virtual reality development platform. Firstly, the Windows platform, C#, VB.net, VB6, Delphi and other
hierarchical approach of geographic information system is programming languages. The Unity3D game engine and the
adopted in the study area, and the area is divided into four Unity3D development environment are tight integrated, so it
layers: Terrain Layer, Building Layer, Transport Layer,
provides a very powerful visual editor and language levels of
Vegetation Layer, additionally, the raw data of Terrain Layer is
obtained by GPS measurements. Secondly, all the geographical
the network.
entities which related to different layers are converted to 3D In this research, we use Unity3D as the development
model by AutoCAD and 3dsMax software. Thirdly, the 3D platform for virtual reality. The study area is the campus of
models are imported into the Unity3D, and programming with Henan Institute of Urban Construction, Pingdingshan, China,
Javascript language in Visual Programming Language Editor in with an area of 1,066,667m 2, ranging from 33°46′11″N to
order to achieve Gameobjects and Scenes. Lastly, the Scenes are 33°46′42″N, 113°10′52″E to 113°11′36″E.
integrated and published on the network. The attribute data of
study area is stored by MySQL which is connected with Unity
game platform by external interface. Visitors can download the II. FRAMEWORK AND IMPLEMENTATION
ActiveX control to browse the study area, the scene is keep on
updating 60 times per second, the viewer will subconsciously A. Framework
input and immediately immersed in the virtual scene for Browser-Server three-tier architecture VR-based
spontaneous exploration and observation. With a full range of framework is designed in the research area and including 3
personalized mode of operation, the users can choose their own layers: presentation layer, logic layer and data layer [2].
way to browse and participate in the virtual reality, and give full
play to their imagination according to their own wishes without 1) Presentation layer is mainly used for interface display
affecting the others by using the designated keys on the and to achieve the user's query.
keyboard.
2) Logic layer consists of web server and application
Keywords-Virtual Reality; Unity3D; GIS server [3]. Workflow of Logic layer is as follows: a) Web
server receives the user’s Http request which send by the
browser; b) request is passed to the application server; c)
I. INTRODUCTION application server convert the Http requests into the statement
Virtual reality (VR) is a technology which allows a user to that database can identify; d) sending the request to query in
interact with a computer-simulated environment , Michael the database; e) When the query is complete, the query result
Heim(1994)identifies seven different concepts of virtual sets are returned to the application server; f) application server
reality[1]: simulation, interaction, artificiality, immersion, analyze and process the result sets; g) sent the result to web
telepresence, full-body immersion, and network browser by web servers; h) download the three-dimensional
communication. Now virtual reality is widely used in industry scene files that user requests from Presentation layer; i) show a
and public service with its intuitive visual and simple virtual three-dimensional scene by a plug-in which embedded
operation. in the browser.
Unity3D is one of the most famous virtual reality tools, it is 3) Data layer includes the related spatial data and
cross-platform game development software, and now besides attribute data, such as DEM data.
Mac OSX, Unity3D can fully support WindowsXP/Vista/7,
Unity3D supports three scripting languages: JavaScript, C#,
and a dialect of Python called Boo. All three are equally fast
and interoperate, and can use the underlying .NET libraries

Authorized licensed use limited to: UNIVERSIDAD AUTONOMA DE BUCARAMANGA (UNAB). Downloaded on August 03,2022 at 20:04:14 UTC from IEEE Xplore. Restrictions apply.
B. Implementation III. WORKS OUTSIDE UNITY3D
In this study , the hierarchical approach of geographic
information system is adopted, and the study area is divided A. Data Collection
into four layers: Terrain layer, Building layer, Transport layer There are two kinds of data we need in the study: spatial
and Vegetation layer. Figure 1 shows the details of the layers in data and attribute data. The data was collected from three
study area. sources:
• The terrain maps which scale is 1:500, obtained by
GPS.
• Two-dimensional maps of the study area including
architectural design maps and design sketch that the
research area previously saved.
• Texture of roads, lawns, trees, public facilities,
buildings taken by camera from different angles.

B. Modeling
Modeling is an important piece of the visual reality system.
The choice of modeling system dictates what type of geometry
will appear in the system. For the virtual reality system to be
successful, the modeling system is better to be completed and
in place early in the development process. The main tools for
Figure 1. The details of the layers in study area modeling are 3Ds Max and AutoCAD [4].
In the virtual reality system, Two-dimensional maps are The virtual reality environment consists of roads, lights,
used as base maps in 3D scenes to express the geographic traffic symbols, trees, buildings and so on. It is essential to
entity’s three-dimensional location information. 3DsMax and build fine, sophisticated models of every real object which will
other software are used to create three-dimensional models of be placed in a virtual field. The precise geographic location,
features in the study area. Three-dimensional models need to attribute information and models of geography entities are
add texture and attribute information. Textures which collected needed for achieving good quality objects of scenes [5].
through outdoor jobs can truly reflect the surface features of
geographic entities. After processing by tools such as 1) Terrain Layer: First of all, terrain information of
Photoshop, textures are imported into 3Ds Max to integrated geographic entities should be determined. As situations are
with models. All the models are placed on the Terrain Layer, different, different approaches are taken to get the information
and then, combined with geographical location and attribution about terrain. Figure 3 shows the Logical sequence to get
information to generate a complete virtual three-dimensional models of terrain layers.
scene. Unity3D is used to edit and optimize the scenes in order With the promotion and application of Google Earth, it
to have a realistic environment and to achieve the best visual provides a lot of high-precision images and elevation
display by minimize the amount of data. information.
Overall, there are two kinds of works: one is the works If the resolution in the study area meets the requirements of
outside unity3D, including models, animations, textures, the terrain, we can directly access the high resolution terrain
sounds and GUI graphics; the other is the works in unity3D, information from Google Earth by using a tool named Google
such as levels, scripts, physics, materials, shaders and GUI. SketchUp 6.0. With the help of Google SketchUp 6.0, the
Figure 2 shows the works outside Unity3D and the works in three-dimensional terrain information of study area can be
unity3D. saved as .3ds format, so as to communicate with 3Ds Max.
Else, if the resolution can’t meet the needs, we can get the
terrain information by field measurement. In this research, we
use GPS to measure and obtain high resolution terrain
information of the study area. Then the data obtained by GPS,
which format is .dat, imported into AutoCAD software to
generate a terrain map with the scale 1:500. After interpolation
and fitting in AutoCAD, the data also is saved as .3ds format so
as to communicate with 3Ds Max.
2) Transport layer: When the modeling work in Terrain
Layer is finished, roads and facilities in Transport layer will be
modeled according to the real location on the Terrain Layer. At
the same time, we edit textures, lights, materials and other
physical attributes by using MaxScript, a built-in scripting
Figure 2. Works outside and in Unity3D

Authorized licensed use limited to: UNIVERSIDAD AUTONOMA DE BUCARAMANGA (UNAB). Downloaded on August 03,2022 at 20:04:14 UTC from IEEE Xplore. Restrictions apply.
language in 3ds Max. The logical principle of editing work for dust trails, anything that we can imagine. During the process of
Transport Layer is similar to Terrain Layer. creating a scene, works in Unity3D are as follows:

A. Shading
Unity3D comes with 40 shaders ranging from the simple
(Diffuse, Glossy, etc.) to the very advanced (Self Illuminated
Bumped Specular, etc.) All the built-in shaders integrate
perfectly with any type of light, with cookies or without. If it is
not enough we can write our own shaders in Unity3D's
powerful ShaderLab language with Cg and GLSL. In the study,
besides the ordinary shaders, there are more requirements, so
we write our own shaders, such as MirrorReflection.shader. It
achieves a more realistic scenario results by using the shaders.

B. Programming
If we want to achieve some special functions of the scenes
and the functions are simple, we can use the script or editor of
unity3d. However, the most powerful editor is Visual Studio
[7], the scenes in Untiy3D can also compile with Visual Studio
by adding UnityEngine.dll.

C. Collision Detection
Unity contains the full capabilities of the Ageia PhysX
next—gen Physics Engine and is used in games like Unreal
Tournament 2007 and Ghost Recon 3. Unity3D supports full
Rigidbody physics. Rigidbodies act under forces, collide, and
work in joints with no scripting required. It makes the virtual
reality more true to our daily life. After writing scripts on a
Figure 3. The logical sequence to get models of terrain layers certain GameObject, users can press the mouse to determine
any display area, and then press keys on the keyboard to
3) Building layer: 3D building models are important in the choose where to go. The navigation person is endued with
virtual environment. The reproduction of the real building is an collision detection in the process of walking around, so, when
important aspect of final visual effect, which impacts the running into buildings, the navigation person will automatically
authenticity of scenes. Visual modeling tools (3Ds Max, etc.) return to the road, to ensure that the route of the road is not
are used to modeling the building. The raw data of the models affected by the nonlinear structure.
comes from building’s construction design maps. Liking
Terrain Layer and Transport Layer, we also need to pasting D. Showing Information by GUI Control
textures on models to show the true appearance of the building. Geographic entities are not only having spatial information
Textures are obtained by pictures from different angles of but also attribute information. If we want to get dynamic and
building’s surface [6]. real-time effects, we can use GUI controls to show the attribute
4) Vegetation layer: There is a powerful vegetation editor in information. All the attribute information is stored in
unity3D. The editor is easy to use, it is powerful and automatic database—MySQL data management system, parts of the code
animation (effects of wind etc.). So the vegetation models are is shown as fellow:
added directly in Unity3D. private static void openSqlConnection(string connectionString)
{
C. Export dbConnection=new MySqlConnection(connectionString);
When the modeling is completed, the 3D models are saved dbConnection.Open();
as the format .sbx so as to compatible with Unity3D. result = dbConnection.ServerVersion;
Animations, textures, scripts, and sounds are saved in the asset //Debug.Log("Connected to database."+result);
file in a Unity3D project; they are added as new Gameobjects }
// Disconnect from database
in the process of creating scene.
private static void closeSqlConnection() {
dbConnection.Close();
IV. WORKS IN UNITY3D dbConnection = null;
Unity3D has a highly optimized graphics pipeline for both //Debug.Log("Disconnected from database."+result);
DirectX and OpenGL. Animated meshes, particle systems, }
advanced lighting and shadows, all run blazing fast. It also
support individual operations for we can create rain, sparks,

Authorized licensed use limited to: UNIVERSIDAD AUTONOMA DE BUCARAMANGA (UNAB). Downloaded on August 03,2022 at 20:04:14 UTC from IEEE Xplore. Restrictions apply.
In this research, when the user clicks the object, the
information will show on GUI message box.

E. Publishing
If we want more persons to use the virtual reality system, we
can publish it online. Users can browse it by downloading a
small Unity Web Player Plug-in (about 3 MB). It auto-installs
without a browser restart, and already has an 8-digit
distribution. It works on all modern browsers including
Internet Explorer, Firefox, Safari, and most Mozilla-based
browsers.

F. Others Figure 4. The results of virtual reality based on Unity3D, a) looking at the
building from earth suface,b) sunshine effects on the ground
Sounds, animations, videos will be added in Unity3D by
GameObjects. Thus really enhance the user's immersion in the
virtual reality system [8].

G. Integrating
When all the works above are completed, we save the
scenes, scripts, audios, attribute data, pictures, textures etc. in a
Project in Unity3D. The asset in a Unity3D Project is
automatically and immediately imported upon save. Assets can
update at any moment, even while users visiting inside the
Editor. If the project is big, Unity Asset Sever could be used to
optimize the big Project.

V. RESULTS OF VIRTUAL REALITY BASED ON UNTIY3D


The purpose of all the work is to generate a virtual reality
system.Unity3D provides seven kinds of system by ‘build Figure 5. Sunshine effects and mirror reflection effects inside a building
settings’: Web Player, Web Player Stream, OS X Dashboard
Widget, Windows Standalone, OS X Universal Binary
VI. CONCLUSION
Standalone, OS X PPC Standalone and OS X Intel Standalone.
This study generates a virtual reality system based on
In this study, in order to publish online, the virtual reality Unity3D for taking a campus as an example. The virtual reality
system is generated by the first kind: Web Player. The project system is highly vivid, strongly interactive. Users can
generates the system by ‘build settings’ in File. We can also download a Plug-in to browse the study area online. With a full
generate other kinds of systems, such as Windows Standalone, range of personalized mode on operation, they can choose their
if we choose this kind of ‘build settings’, there will be an own way to browse and participate in the virtual reality, and
executable file and can set up in user’s computers. So, the give full play to their imagination according to their own
virtual reality system could be run in different purpose even wishes without affecting the others by using the designated
different operation system. keys on the keyboard. The scene keeps on updating 60 times
When files are modified, their status is updated instantly. per second, users will subconsciously input and immediately
Renaming and moving assets are handled elegantly. Updates, immersed in the virtual scene for spontaneous exploration and
commits, and graphical version comparisons are all performed observation. It shows that Unity3D not only can serve for game
inside the Unity Editor. development, but also can be used in real world. The virtual
reality system can also query information, about the research
Figure 4 illustrates the results of virtual reality based on area, and do some simple spatial analysis such as illumination
unity 3D. Objects in the virtual reality system can be seen from analysis and distance measurement.
any angle. According to the adjustment of sunshine, it can
achieve real-time sunshine effects both day and night. In In the area of geographic information system, there are
addition to sunshine effects, there are also mirror reflection always two methods to get 3D virtual reality, one is to use a 2D
effects (Figure 5). Besides mentioned above, Users can also professional platform such as ArcGIS software to get the
watch videos, listening music in the system, they can walk virtual reality by secondary development, the other is to use a
alone on the road or guided by an instructor. Therefore, 3D or 2.5D software as a platform for development, for
geographical entities in the system are more realistic. example Skyline software.
The system also has functions of illumination analysis, This is only the preliminary results of our study. The next
distances measurement, querying attribute information and so step is to Co-GIS software with the system together, so that it
on, which are similar to 3DGIS. will possess the sophisticated spatial analysis functions of GIS.

Authorized licensed use limited to: UNIVERSIDAD AUTONOMA DE BUCARAMANGA (UNAB). Downloaded on August 03,2022 at 20:04:14 UTC from IEEE Xplore. Restrictions apply.
This will not only increase the function of the virtual reality Journal of Advanced Manufacturing Technology, vol.19(5), pp. 377-
system, but also provide new ideas about the development of 383, 2002.
3DGIS. [5] Hongli Liu, Linlin Wang, “Application of virtual reality in ancient
buildings-take the summer palace for example,” Proceedings of First
International Conference on Modelling and Simulation, pp. 59-64, 2008.
REFERENCES [6] M. Dinsmore, N. Langrana, G. Burdea, and J. Ladeji, “Virtual reality
[1] Michael Heim, Virtual Realism[M], Oxford Univ. Press, 1998. training simulation for palpation of surface tumors,” IEEE VR Conf, pp.
54-60, 1997.
[2] Janus Liang, “Generation of a virtual reality-based automotive driving
training system for CAD education,” Computer Applications in [7] N. Adamo-Villani, E. Carpenter, and L. Arns, “3D sign language
Engineering Education,vol.17(2), pp. 148-166, 2009. mathematics in immersive environment,” Proc. of the 15th IASTED
International Conference, June, Rhodes, Greece, 2006.
[3] K. P. Beier, “Web-based virtual reality in design and manufacturing
applications,” Proceedings of the 1st International Euro Conference on [8] B. J. Gold, M. Pomplun, and N. J. Rice, “A new way to quantify the
Computer Applications and Information Technology in the Maritime fidelity of imitation: preliminary results with gesture sequences,”
Industries, COMPIT’2000, Potsdam, Germany, 2000. Experimental Brain Research, vol.187(1), pp. 139-152, 2008.
[4] A. C. K. Choi, D. S. K. Chan, and A. M. F. Yuen, “Application of
virtual assembly tools for improving product design,” The International

Authorized licensed use limited to: UNIVERSIDAD AUTONOMA DE BUCARAMANGA (UNAB). Downloaded on August 03,2022 at 20:04:14 UTC from IEEE Xplore. Restrictions apply.

You might also like