Bilkent University

Department of Computer Engineering

High Level Design Report

Dec 24, 2015

Senior Design Project

CardBoard : virtual reality pool game

Gözde Nur Güneşli 21201358 Derya Pelin Deniz 21001007 ​ Cansu Tüzmen 20901073 Efekan Kökcü 21101902 Caner Yıldırım 21100818

Supervisor: Selim AKSOY Jury Members: Uğur GÜDÜKBAY­ Özgür ULUSOY

This report is submitted to the Department of Computer Engineering of Bilkent University in partial fulfillment of the requirements of the Senior Design Project course CS491

Table Of Content

1. Introduction 3 1.1 Purpose of the system 3 1.2 Design goals 3 1.3 Definitions, acronyms, and abbreviations 4 1.4 Overview 5 2. Current software architecture 6 3. Proposed software architecture 7 3.1 Overview 7 3.2 Subsystem decomposition 7 3.3 Hardware/software mapping 8 3.4 Persistent data management 9 3.5 Access control and security 9 3.6 Global software control 9 3.7 Boundary conditions 9 4. Subsystem services 11 Game Subsystem 11 User Subsystem 11 Settings Subsystem 12 User Interface Subsystem 12 Input Management Subsystem 13 5. Glossary 13 6. References 14

1 LIST OF FIGURES Figure 1 ­ VR Pool ScreenShot Taken from Google Play Store 6 ​ Figure 2 ­ Subsystem Decomposition UML Diagram 7 ​ Figure 3 ­ Hardware/Software Mapping Diagram 8 Figure 4 ­ Game Subsystem Diagram 11 Figure 5 ­ User Subsystem Diagram 11 Figure 6 ­ Settings Subsystem Diagram 12 Figure 7 ­ Input Management Subsystem Diagram 12 Figure 8 ­ User Interface Subsystem Diagram 13

2 1. Introduction

1.1 Purpose of the System Taking computer applications under consideration, people started building and using mobile applications for educational and joy purposes. For pool games, there appeared many desktop and mobile applications that people play on fake boards and train on them. After the virtual and augmented reality based applications emerged, some billiard applications started to be based on them, too. In virtual and augmented reality systems, real board can be part of the game and users can play with their actual billiard and with a real game performance. With the help of Google Cardboard, user can see billiard pool as in 3D vision with cue ball's trajectory prediction. In this way, people can learn the pool game by using Cardboard Pool for using Training Mode. Besides, there will be a mode without trajectory lines. Doing so, user can play without help and statistical information can be kept. Furthermore, there is Match Mode. If user chooses, the application watch the flow of the game and it suggests the beneficial shooting styles to the user, according to specific purposes such as clearing all the balls in a sequence. Therefore, Cardboard Pool will be a satisfying augmented reality game for the billiard players and people who are eager to learn the game.

1.2 Design Goals High-performance: Cardboard Pool should perform in a user-acceptable time since it is necessary for ​ the user to see through Cardboard as a real time experience in order to enjoy using our application.

Accessibility: Cardboard Pool should be accessible to all Android Device [4].Users in Android Market as free.

Availability: Cardboard Pool should be available for all the users who plays billiard game and has

Android Phone and Cardboard.

User-friendliness: Cardboard Pool should have a user-friendly graphical user interface. ​ Modifiability: Cardboard Pool should be easy to modify in the future in order to make adding new ​ features and functions easy, such as Carom Billiard Option can be added besides the current 8ball billiard game option.

3 1.3 Definitions, Acronyms, and Abbreviations

Google Cardboard: It is a complete virtual reality platform. It was developed at the Google Cultural ​ Institute in Paris as one of those famous 20-percent time projects, and we first saw it at Google I/O ​ 2014. The hardware side of Google Cardboard uses low-cost viewers, with the reference design made ​ ​ of foldable cardboard (hence the name) 45mm plastic lenses, and a magnet or capacitive-taped lever to operate the screen. The viewer only needs to do two things — hold the phone in front of the lenses at the right distance, and provide a way to interact with the screen. [1]

C#: (pronounced "C sharp") is a programming language that is designed for building a variety of applications that run on the .NET Framework. C# is simple, powerful, type-safe, and object-oriented. The many innovations in C# enable rapid application development while retaining the expressiveness and elegance of C-style languages. [2]

Unity: Unity is a flexible and powerful development platform for creating multi platform 3D and 2D games and interactive experiences. It's a complete ecosystem for anyone who aims to build a business on creating high-end content and connecting to their most loyal and enthusiastic players and customers[3].

SQLite: SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed database engine in the world. The source code for SQLite is in the public domain[4].

Eight-ball: (8-ball) is a pool (pocket billiards) game popular in much of the world, and the subject of ​ ​ international professional and amateur competition. Played on a pool table with six pockets, the game is so universally known in some countries that beginners are often unaware of other pool games and believe the word "pool" itself refers to eight-ball. The game has numerous variations, including Alabama eight-ball, crazy eight, last pocket, misery, Missouri, 1 and 15 in the sides, eight ball, soft eight, and others[5].

Carom Billiard: is the overarching title of a family of billiards games generally played on cloth-covered, 1.5-by-3.0-metre (5 by 10 ft) pocketless tables, which often feature heated slate beds. In its simplest form, the object of the game is to score points or "counts" by caroming one's own cue ball off both the opponent's cue ball and the object ball(s) on a single shot. The invention as well as

4 the exact date of origin of carom billiards is somewhat obscure but is thought to be traceable to 18th-century France [6].

1.4 Overview Cardboard Pool is an android mobile application which users can experience an augmented pool game and learn how to be proficient in billiard by using Google Cardboard.

Cardboard Pool will be an application aiming to teach user how to play pool game, running on Android mobile phones or tablets with Google Cardboard placed on it. The view of camera will capture the pool table in a phone into based on a real pool table. The glass will show the user where to throw the ball by pushing which point of the white ball. There will appear trajectory lines showing how the balls will go after kicking the white. There will be training and examination options that will enable users to work on specific strategy and tactical methods. The user can rewatch which positions appeared after the game and share it with other users.

The program will detect position of balls with image analysis by using edge detection algorithms and recognize them according to colors & shapes. After getting their coordinates relative to the table, the application can use the information in 3 options:

• In training option, lines appear for where to throw the white ball and which ball to hit. Another additional information related to current strategy and tactical methods are shown on right side of the glass. The statistics of the users will be hold. • In examination option, the application will not help the user, there will be no trajectory lines, but the system will check whether the users are able to do the stroke or not, and assign the user a point standing for their success by checking the difference between the ideal trajectory and the trajectory that users’ shot created. The statistics of the user will be hold. • In match mode, the trajectory lines appear if user chooses and the application watch the follow of the game and if the user chooses, it suggests the user beneficial shooting styles according to specific purpose such as clearing all the balls in a sequence (or in general, providing you a good position after you shoot, there are pool games that you do not pot balls

5 such as 3 cushion), keeping the turn (shooting the ball with higher chance to be cleared), and not keeping the turn but leaving a very bad position for the opponent ().

2. Current Software Architecture

A similar system is built by Stanford University with lights showing how the balls will move with lines of lightning after kicking the white ball with current position of the stick. They also built a robotic arm that shoots the white ball according to their aim with best chance according to current ball positions.

Figure 1: VR Pool screenshot taken from Google Play Store

There are also Virtual Reality and augmented reality games billiard games for Google Cardboard such as VR Pool, people can play completely virtual billiard. Our project differs from those applications since in our project the , balls and the cue are real, it is a very different kind of 8-ball billiard experience.

6 3.Proposed Software Architecture 3.1 Overview In this section, detailed explanation of the proposed software architecture will be given. Implementation and design approach will be explained in detailed under the topics “Subsystem decomposition”, “Hardware/software mapping”, “Persistent data management”, “Access control and security”, “Global software control” and “Boundary conditions”. 3.2 Subsystem Decomposition MVC pattern will be used in our system which divides the system into three interconnected parts, in order to gain modifiability and decrease complexity of the system. View part which will be modified by model will handle the GUI part of the application, and includes all panel classes and CardBoard transformer class which transforms the generated image to show into two images for two eyes. Model part is the part which keeps important aspects of the current state of the application such as user data, user statistics, position of the balls and cue, mission or help trajectories for the balls, and some more important features. The model is of course will be modified by controller which handles input coming from user by transforming it into meaningful data for the model . You can see the general view of the system in figure 2 below:

Figure 2: Subsystem Decomposition UML Diagram

7

3.3 Hardware/Software Mapping Since our system will only work on one device with one actor, our deployment will be standalone system. Our deployment diagram of the system could be found below.

Figure 3: Standalone deployment diagram

Our aim is to build an Android application for Google CardBoard, so user should have a phone with Android operating system. As environment, Unity is chosen to build this project since it comes with a very nice physics engine which can be used in order to predict next positions of the balls after hit, and can generate an Android apk file. Thus we will use Unity’s database system called SQLite to store training levels, user information and settings. The version of Unity we will use requires Android 2.2 or a higher version, with OpenGL-ES2 [7] which is also required for Android 4.4. Hence, users will not have to build anything on their phone unless they have Android which is older than version 4.4. They need to set up OpenGL-ES2 otherwise. Finally, since our application is not a multiplayer application and does everything locally, no internet connection is needed.

8

3.4 Persistent Data Management We will use a serverless self-contained database to keep statistical records of the user and keep training mode trajectories. We will use SQLite to manage the data of the system because we will use Unity Game Engine to develop the application and SQLite is supported by Unity. SQLite can provide satisfied speed to our database aspect.

3.5 Access Control and Security

Cardboard Pool does not include any registration or login page in order to make the user experience as simple as possible. Moreover, our system does not need any registration or login process since we do not have any server communication and we do not store anything in the network, all of the database is stored in the user's own device.

3.6 Global Software Control

Cardboard Pool will not require any access control or login process to provide its features. Therefore, control of application will not be processed globally. Requests of the users will be handled in their device without any communication globally.

Cardboard Pool will be available to the Google Play Store and updates will be maintained through this channel.

3.7 Boundary Conditions Boundary conditions here are classified in 3 cases. Initialization: · User enters to Cardboard Pool by using android mobile phone. · User gets the main menu that asks user to either select profile or choose a profile. · After selecting a profile user gets the menu which provides application features which are the “Training Mode”, “Examination Mode” and “Match Mode”. User selects the mode he/she prefers.

9 · After selection, the application will be initialized. In this stage, user should put the device to the correct place in the Google Cardboard . Then, user can wear the Google Cardboard glasses and can start to play the real billiard game.

Termination: · Users will be able to terminate the application at any time. · Users will be able to terminate the current profile and change it at any time.

Failure: · A connection lost to the database will close application with an error message to restart. · If the failure is caused by an unexpected input, the system will give error messages to the user to indicate the source of the failure and the ways to correct it. For example, if user is using the application without a billiard table in the view of the camera, then system will show messages to the user saying that “Billiard Table is not recognized.”. · Termination may also happen because of a system failure in extreme cases. If the system fails in any way in the middle of a game all the information and statistics about that game will be lost.

10 4. Subsystem Services

Game Subsystem The subsystem which includes all important aspects of the game which user is playing, and has artificial intelligence class which generates either help or mission (for training and exam mode) trajectory for the user. You can see the general view of the subsystem in figure below:

Figure 4: Game Subsystem User Subsystem The subsystem which includes features of the user such as name, training statistics and exam statistics. You can see the general view of the subsystem in figure below:

Figure 5: User Subsystem

11 Settings Subsystem User will have options to change brightness of the view, change colors of mission and help trajectories. This subsystem store these information. You can see the general view of the subsystem in figure below:

Figure 6 : Settings Subsystem Controller: Input Management Subsystem The subsystem that handles the input by modifying the model according to it. Image and sensor processor classes, which also handles the input, are in this subsystem. You can see the general view of the subsystem in figure below:

Figure 7: Input Management Subsystem

12 View: User Interface Subsystem The subsystem that handles the GUI part of the application. For each state of the application, there is a different type of panel which is included in the GamePanel class. This subsystem also includes CardBoardTransformer which transform the image shown on the screen into a different image so that user would see it in 3D when he/she put Google cardboard on. You can see the general view of the subsystem in figure below:

Figure 8: User Interface Subsystem

5. Glossary MVC: (Model View Controller) A three-tier architectural style in which domain knowledge is ​ maintained by model objects, displayed by view object, and manipulated by control objects.

13

6. References [1] Google Cardboard. December 20, 2015. http://www.androidcentral.com/what-google-cardboard ​ [2] C#. Microsoft. December 20, 2015. https://msdn.microsoft.com/en-us/library/kx37x362.aspx ​ [3] Unity. December 20, 2015. https://unity3d.com/unity ​ [4] SQLite. December 20, 2015. https://www.sqlite.org/ [5] Eight-ball. Wikipedia. December 20, 2015. https://en.wikipedia.org/wiki/Eight-ball [6] Carom Billiards. Wikipedia. December 20, 2015. https://en.wikipedia.org/wiki/Carom_billiards ​ [7]Unity system requirements. December 20, 2015. https://unity3d.com/unity/system-requirements ​ ​ ​

14