Implementasi Augmented Reality Pada Alat Musik Dairi Menggunakan Metode Markerless Berbasis Android
49
LISTING PROGRAM
Event_Script.cs
using UnityEngine;
using System.Collections;
public class Event_Script : MonoBehaviour {
public void aktifstart (string startaktif) {
Application.LoadLevel (startaktif);
}
public void aktifinfo (string infoaktif) {
Application.LoadLevel (infoaktif);
}
public void aktifprofile (string profileaktif) {
Application.LoadLevel (profileaktif);
}
public void ExitApplication () {
ExitApplication ();
}
public void aktifaugmented (string augmentedaktif) {
Application.LoadLevel (augmentedaktif);
}
public void aktifview (string viewaktif) {
Application.LoadLevel (viewaktif);
}
public void aktifhome (string homeaktif) {
Application.LoadLevel (homeaktif);
}
public void aktifback (string backaktif) {
Application.LoadLevel (backaktif);
}
}
PinchZoom.cs
using UnityEngine;
using System.Collections;
public class PinchZoom : MonoBehaviour
{
private float scale_factor= 0.07f;
private float MAXSCALE = 6.0f, MIN_SCALE = 0.6f; //
zoom-in and zoom-out limits
private bool isMousePressed;
private Vector2 prevDist = new Vector2(0,0);
private Vector2 curDist = new Vector2(0,0);
private Vector2 midPoint = new Vector2(0,0);
private Vector2 ScreenSize;
Universitas Sumatera Utara
50
private Vector3 originalPos;
private GameObject parentObject;
void Start ()
{
// Game Object will be created and make current
object as its child (only because we can set virtual
anchor point of gameobject and can zoom in and zoom out
from particular position)
parentObject = new GameObject("ParentObject");
parentObject.transform.parent =
transform.parent;
parentObject.transform.position = new
Vector3(transform.position.x*-1, transform.position.y*-1,
transform.position.z);
transform.parent = parentObject.transform;
ScreenSize = Camera.main.ScreenToWorldPoint(new
Vector2(Screen.width,Screen.height));
originalPos = transform.position;
isMousePressed = false;
}
/*void Update ()
{
if(Input.GetMouseButtonDown(0))
isMousePressed = true;
else if(Input.GetMouseButtonUp(0))
isMousePressed = false;
// These lines of code will pan/drag the object
around untill the edge of the image
if(isMousePressed && Input.touchCount==1 &&
Input.GetTouch(0).phase == TouchPhase.Moved &&
(parentObject.transform.localScale.x > MIN_SCALE ||
parentObject.transform.localScale.y > MIN_SCALE))
{
Touch touch = Input.GetTouch(0);
Vector3 diff = touch.deltaPosition*0.1f;
Vector3 pos = transform.position + diff;
if(pos.x > ScreenSize.x *
(parentObject.transform.localScale.x-1))
pos.x = ScreenSize.x *
(parentObject.transform.localScale.x-1);
if(pos.x < ScreenSize.x *
(parentObject.transform.localScale.x-1)*-1)
pos.x = ScreenSize.x *
(parentObject.transform.localScale.x-1)*-1;
if(pos.y > ScreenSize.y *
(parentObject.transform.localScale.y-1))
pos.y = ScreenSize.y *
(parentObject.transform.localScale.y-1);
Universitas Sumatera Utara
51
if(pos.y < ScreenSize.y *
(parentObject.transform.localScale.y-1)*-1)
pos.y = ScreenSize.y *
(parentObject.transform.localScale.y-1)*-1;
transform.position = pos;
}
// On double tap image will be set at original
position and scale
else if(Input.touchCount==1 &&
Input.GetTouch(0).phase == TouchPhase.Began &&
Input.GetTouch(0).tapCount==2)
{
parentObject.transform.localScale =
Vector3.one;
parentObject.transform.position = new
Vector3(originalPos.x*-1, originalPos.y*-1,
originalPos.z);
transform.position = originalPos;
}
checkForMultiTouch();
}*/
// Following method check multi touch
private void checkForMultiTouch()
{
// These lines of code will take the distance
between two touches and zoom in - zoom out at middle
point between them
if (Input.touchCount == 2 &&
Input.GetTouch(0).phase == TouchPhase.Moved &&
Input.GetTouch(1).phase == TouchPhase.Moved)
{
midPoint = new
Vector2(((Input.GetTouch(0).position.x +
Input.GetTouch(1).position.x)/2),
((Input.GetTouch(0).position.y +
Input.GetTouch(1).position.y)/2));
midPoint =
Camera.main.ScreenToWorldPoint(midPoint);
curDist = Input.GetTouch(0).position Input.GetTouch(1).position; //current distance between
finger touches
prevDist = ((Input.GetTouch(0).position Input.GetTouch(0).deltaPosition) (Input.GetTouch(1).position Input.GetTouch(1).deltaPosition)); //difference in
previous locations using delta positions
float touchDelta = curDist.magnitude prevDist.magnitude;
// Zoom out
Universitas Sumatera Utara
52
if(touchDelta>0)
{
if(parentObject.transform.localScale.x < MAXSCALE &&
parentObject.transform.localScale.y < MAXSCALE)
{
Vector3 scale = new
Vector3(parentObject.transform.localScale.x +
scale_factor, parentObject.transform.localScale.y +
scale_factor, 1);
scale.x = (scale.x > MAXSCALE) ?
MAXSCALE : scale.x;
scale.y = (scale.y > MAXSCALE) ?
MAXSCALE : scale.y;
scaleFromPosition(scale,midPoint);
}
}
//Zoom in
else if(touchDelta MIN_SCALE
&& parentObject.transform.localScale.y > MIN_SCALE)
{
Vector3 scale = new
Vector3(parentObject.transform.localScale.x +
scale_factor*-1, parentObject.transform.localScale.y +
scale_factor*-1, 1);
scale.x = (scale.x < MIN_SCALE)
? MIN_SCALE : scale.x;
scale.y = (scale.y < MIN_SCALE)
? MIN_SCALE : scale.y;
scaleFromPosition(scale,midPoint);
}
}
}
HideShow.cs
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class HideShow : MonoBehaviour {
// Use this for initialization
Universitas Sumatera Utara
53
public GameObject Button1, Button2, Button3,
Button4, Button5, Button6, Button7, Button8;
public void Showbutton()
{
Button1.gameObject.SetActive (true);
Button2.gameObject.SetActive (true);
Button3.gameObject.SetActive (true);
Button4.gameObject.SetActive (true);
Button5.gameObject.SetActive (true);
Button6.gameObject.SetActive (true);
Button7.gameObject.SetActive (true);
Button8.gameObject.SetActive (true);
}
public void HideButton()
{
Button1.gameObject.SetActive (false);
Button2.gameObject.SetActive (false);
Button3.gameObject.SetActive (false);
Button4.gameObject.SetActive (false);
Button5.gameObject.SetActive (false);
Button6.gameObject.SetActive (false);
Button7.gameObject.SetActive (false);
Button8.gameObject.SetActive (false);
}
}
Universitas Sumatera Utara
54
CURRICULUM VITAE
Nama
: M. Hafis Ritonga
Tempat/ Tanggal Lahir : Medan/25 November 1991
Alamat
: Jl. Tuba III No. 104 A Medan
Jenis Kelamin
: Laki-laki
Agama
: Islam
Tinggi
: 169 cm
No. Telp/Hp
: 085358835491
Status
: Belum kawin
Email
: hafisritonga@gmail.com
No. HP
: 085358835491
PENDIDIKAN FORMAL
• Universitas Sumatera Utara D3 Teknik Informatika Fakultas MIPA USU Medan.
(Tahun Ajaran 2010 s/d 2013. Berijazah).
• Sekolah Menengah Kejuruan Swasta Dwiwarna 2 Medan. ( Tahun Ajaran 2007 s/d
2010. Berijazah).
• Sekolah Menengah Pertama Negeri 13 Medan. (Tahun Ajaran 2004 s/d 2007.
Berijazah).
• Sekolah Dasar Negeri 067241 Medan. (Tahun Ajaran 1998 s/d 2004. Berijazah).
SEMINAR
• Peserta Seminar Nasional Literasi Informasi 2014 Universitas Sumatera Utara.
PENGALAMAN KERJA
• Magang di Biro Keuangan Setdaprovsu Kantor Gubernur Tahun 2012.
DATA KEMAMPUAN
• Database : SQL server dan Mysql.
• Desain
: Adobe Photoshop, Blender 3D.
Universitas Sumatera Utara
LISTING PROGRAM
Event_Script.cs
using UnityEngine;
using System.Collections;
public class Event_Script : MonoBehaviour {
public void aktifstart (string startaktif) {
Application.LoadLevel (startaktif);
}
public void aktifinfo (string infoaktif) {
Application.LoadLevel (infoaktif);
}
public void aktifprofile (string profileaktif) {
Application.LoadLevel (profileaktif);
}
public void ExitApplication () {
ExitApplication ();
}
public void aktifaugmented (string augmentedaktif) {
Application.LoadLevel (augmentedaktif);
}
public void aktifview (string viewaktif) {
Application.LoadLevel (viewaktif);
}
public void aktifhome (string homeaktif) {
Application.LoadLevel (homeaktif);
}
public void aktifback (string backaktif) {
Application.LoadLevel (backaktif);
}
}
PinchZoom.cs
using UnityEngine;
using System.Collections;
public class PinchZoom : MonoBehaviour
{
private float scale_factor= 0.07f;
private float MAXSCALE = 6.0f, MIN_SCALE = 0.6f; //
zoom-in and zoom-out limits
private bool isMousePressed;
private Vector2 prevDist = new Vector2(0,0);
private Vector2 curDist = new Vector2(0,0);
private Vector2 midPoint = new Vector2(0,0);
private Vector2 ScreenSize;
Universitas Sumatera Utara
50
private Vector3 originalPos;
private GameObject parentObject;
void Start ()
{
// Game Object will be created and make current
object as its child (only because we can set virtual
anchor point of gameobject and can zoom in and zoom out
from particular position)
parentObject = new GameObject("ParentObject");
parentObject.transform.parent =
transform.parent;
parentObject.transform.position = new
Vector3(transform.position.x*-1, transform.position.y*-1,
transform.position.z);
transform.parent = parentObject.transform;
ScreenSize = Camera.main.ScreenToWorldPoint(new
Vector2(Screen.width,Screen.height));
originalPos = transform.position;
isMousePressed = false;
}
/*void Update ()
{
if(Input.GetMouseButtonDown(0))
isMousePressed = true;
else if(Input.GetMouseButtonUp(0))
isMousePressed = false;
// These lines of code will pan/drag the object
around untill the edge of the image
if(isMousePressed && Input.touchCount==1 &&
Input.GetTouch(0).phase == TouchPhase.Moved &&
(parentObject.transform.localScale.x > MIN_SCALE ||
parentObject.transform.localScale.y > MIN_SCALE))
{
Touch touch = Input.GetTouch(0);
Vector3 diff = touch.deltaPosition*0.1f;
Vector3 pos = transform.position + diff;
if(pos.x > ScreenSize.x *
(parentObject.transform.localScale.x-1))
pos.x = ScreenSize.x *
(parentObject.transform.localScale.x-1);
if(pos.x < ScreenSize.x *
(parentObject.transform.localScale.x-1)*-1)
pos.x = ScreenSize.x *
(parentObject.transform.localScale.x-1)*-1;
if(pos.y > ScreenSize.y *
(parentObject.transform.localScale.y-1))
pos.y = ScreenSize.y *
(parentObject.transform.localScale.y-1);
Universitas Sumatera Utara
51
if(pos.y < ScreenSize.y *
(parentObject.transform.localScale.y-1)*-1)
pos.y = ScreenSize.y *
(parentObject.transform.localScale.y-1)*-1;
transform.position = pos;
}
// On double tap image will be set at original
position and scale
else if(Input.touchCount==1 &&
Input.GetTouch(0).phase == TouchPhase.Began &&
Input.GetTouch(0).tapCount==2)
{
parentObject.transform.localScale =
Vector3.one;
parentObject.transform.position = new
Vector3(originalPos.x*-1, originalPos.y*-1,
originalPos.z);
transform.position = originalPos;
}
checkForMultiTouch();
}*/
// Following method check multi touch
private void checkForMultiTouch()
{
// These lines of code will take the distance
between two touches and zoom in - zoom out at middle
point between them
if (Input.touchCount == 2 &&
Input.GetTouch(0).phase == TouchPhase.Moved &&
Input.GetTouch(1).phase == TouchPhase.Moved)
{
midPoint = new
Vector2(((Input.GetTouch(0).position.x +
Input.GetTouch(1).position.x)/2),
((Input.GetTouch(0).position.y +
Input.GetTouch(1).position.y)/2));
midPoint =
Camera.main.ScreenToWorldPoint(midPoint);
curDist = Input.GetTouch(0).position Input.GetTouch(1).position; //current distance between
finger touches
prevDist = ((Input.GetTouch(0).position Input.GetTouch(0).deltaPosition) (Input.GetTouch(1).position Input.GetTouch(1).deltaPosition)); //difference in
previous locations using delta positions
float touchDelta = curDist.magnitude prevDist.magnitude;
// Zoom out
Universitas Sumatera Utara
52
if(touchDelta>0)
{
if(parentObject.transform.localScale.x < MAXSCALE &&
parentObject.transform.localScale.y < MAXSCALE)
{
Vector3 scale = new
Vector3(parentObject.transform.localScale.x +
scale_factor, parentObject.transform.localScale.y +
scale_factor, 1);
scale.x = (scale.x > MAXSCALE) ?
MAXSCALE : scale.x;
scale.y = (scale.y > MAXSCALE) ?
MAXSCALE : scale.y;
scaleFromPosition(scale,midPoint);
}
}
//Zoom in
else if(touchDelta MIN_SCALE
&& parentObject.transform.localScale.y > MIN_SCALE)
{
Vector3 scale = new
Vector3(parentObject.transform.localScale.x +
scale_factor*-1, parentObject.transform.localScale.y +
scale_factor*-1, 1);
scale.x = (scale.x < MIN_SCALE)
? MIN_SCALE : scale.x;
scale.y = (scale.y < MIN_SCALE)
? MIN_SCALE : scale.y;
scaleFromPosition(scale,midPoint);
}
}
}
HideShow.cs
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class HideShow : MonoBehaviour {
// Use this for initialization
Universitas Sumatera Utara
53
public GameObject Button1, Button2, Button3,
Button4, Button5, Button6, Button7, Button8;
public void Showbutton()
{
Button1.gameObject.SetActive (true);
Button2.gameObject.SetActive (true);
Button3.gameObject.SetActive (true);
Button4.gameObject.SetActive (true);
Button5.gameObject.SetActive (true);
Button6.gameObject.SetActive (true);
Button7.gameObject.SetActive (true);
Button8.gameObject.SetActive (true);
}
public void HideButton()
{
Button1.gameObject.SetActive (false);
Button2.gameObject.SetActive (false);
Button3.gameObject.SetActive (false);
Button4.gameObject.SetActive (false);
Button5.gameObject.SetActive (false);
Button6.gameObject.SetActive (false);
Button7.gameObject.SetActive (false);
Button8.gameObject.SetActive (false);
}
}
Universitas Sumatera Utara
54
CURRICULUM VITAE
Nama
: M. Hafis Ritonga
Tempat/ Tanggal Lahir : Medan/25 November 1991
Alamat
: Jl. Tuba III No. 104 A Medan
Jenis Kelamin
: Laki-laki
Agama
: Islam
Tinggi
: 169 cm
No. Telp/Hp
: 085358835491
Status
: Belum kawin
: hafisritonga@gmail.com
No. HP
: 085358835491
PENDIDIKAN FORMAL
• Universitas Sumatera Utara D3 Teknik Informatika Fakultas MIPA USU Medan.
(Tahun Ajaran 2010 s/d 2013. Berijazah).
• Sekolah Menengah Kejuruan Swasta Dwiwarna 2 Medan. ( Tahun Ajaran 2007 s/d
2010. Berijazah).
• Sekolah Menengah Pertama Negeri 13 Medan. (Tahun Ajaran 2004 s/d 2007.
Berijazah).
• Sekolah Dasar Negeri 067241 Medan. (Tahun Ajaran 1998 s/d 2004. Berijazah).
SEMINAR
• Peserta Seminar Nasional Literasi Informasi 2014 Universitas Sumatera Utara.
PENGALAMAN KERJA
• Magang di Biro Keuangan Setdaprovsu Kantor Gubernur Tahun 2012.
DATA KEMAMPUAN
• Database : SQL server dan Mysql.
• Desain
: Adobe Photoshop, Blender 3D.
Universitas Sumatera Utara