Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Windows.ApplicationModel.Core;
- using Urho;
- using Urho.SharpReality;
- using Urho.Shapes;
- using Urho.Gui;
- namespace HelloWorld
- {
- internal class Program
- {
- [MTAThread]
- static void Main() => CoreApplication.Run(
- new UrhoAppViewSource<HelloWorldApplication>(
- new ApplicationOptions("Data")));
- }
- public class HelloWorldApplication : StereoApplication
- {
- //membuat Node yang digunakan selama berjalannya program
- Node spotNode;
- Node yawNode;
- //ga perlu pake, bisa langsung kok
- //float yaw; //variabel publik ini mendefinisikan yaw rightcamera hololens
- //deklarasi yawText
- Text3D yawText;
- public HelloWorldApplication(ApplicationOptions opts) : base(opts) { }
- protected override void Start()
- {
- // base.Start() creates a basic scene
- base.Start();
- //mendefinisikan spotNode sebagai child dari Scene
- spotNode = Scene.CreateChild();
- //menentukan posisi spotNode dan skala
- spotNode.Position = new Vector3(0, 0, 1);
- spotNode.SetScale(0.005f);
- //mendefinisikan bentuk objek dan teksturnya
- var spotFisik = spotNode.CreateComponent<Sphere>();
- spotFisik.SetMaterial(Material.FromImage("Textures/Moon.jpg"));
- //mendefiniskan yawNode sebagai child Scene
- yawNode = Scene.CreateChild();
- //mendefinisikan posisi dan skala yawNode
- yawNode.Position = new Vector3(0, -0.05f, 1);
- yawNode.SetScale(0.1f); // 1cm
- //membuat komponen text3D untuk menampilkan variable yaw
- //deklarasi yawTextnya pindah ke atas
- yawText = yawNode.CreateComponent<Text3D>();
- yawText.HorizontalAlignment = HorizontalAlignment.Center;
- yawText.VerticalAlignment = VerticalAlignment.Center;
- yawText.Text = "0"; //value default
- yawText.SetFont(CoreAssets.Fonts.AnonymousPro, 30);
- yawText.SetColor(Color.White);
- }
- //membuat fungsi OnUpdate agar fungsi aktif ketika ada update terjadi
- protected override void OnUpdate(float timeStep)
- {
- //mengambil nilai yaw dari rightcamera hololens
- //ga perlu pake, bisa langung gini aja
- //yaw = RightCamera.Node.WorldRotation.YawAngle;
- //update valuenya
- //bisa pake Rotation atau World Rotation
- //yawText.Text = RightCamera.Node.WorldRotation.YawAngle;
- yawText.Text = RightCamera.Node.Rotation.YawAngle;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement