public override void _Ready() { VisualServer.SetDefaultClearColor(Color.Color8(0, 0, 0, 255)); AddChild(ARVROrigin = new ARVROrigin()); ARVROrigin.AddChild(ARVRCamera = new ARVRCamera() { Current = true, }); ARVROrigin.AddChild(LeftController = new ARVRController() { ControllerId = 1, }); LeftController.AddChild(GD.Load <PackedScene>("res://OQ_Toolkit/OQ_ARVRController/models3d/OculusQuestTouchController_Left.gltf").Instance()); ARVROrigin.AddChild(RightController = new ARVRController() { ControllerId = 2, }); RightController.AddChild(GD.Load <PackedScene>("res://OQ_Toolkit/OQ_ARVRController/models3d/OculusQuestTouchController_Right.gltf").Instance()); AddChild(new WorldEnvironment() { Environment = new Godot.Environment() { BackgroundColor = Color.Color8(0, 0, 0, 255), BackgroundMode = Godot.Environment.BGMode.Color, }, }); AddChild(DosScreen = new DosScreen() { GlobalTransform = new Transform(Basis.Identity, new Vector3(0, 0, -2)), }); DosScreen.Screen.WriteLine("Platform detected: " + OS.GetName()); switch (OS.GetName()) { case "Android": Path = "/storage/emulated/0/"; ARVRInterface = ARVRServer.FindInterface("OVRMobile"); State = PermissionsGranted ? LoadingState.DOWNLOAD_SHAREWARE : LoadingState.ASK_PERMISSION; break; default: ARVRInterface = ARVRServer.FindInterface("OpenVR"); State = LoadingState.DOWNLOAD_SHAREWARE; break; } if (ARVRInterface != null && ARVRInterface.Initialize()) { GetViewport().Arvr = true; } LeftController.Connect("button_pressed", this, nameof(ButtonPressed)); RightController.Connect("button_pressed", this, nameof(ButtonPressed)); }
public override void _Ready() { VisualServer.SetDefaultClearColor(BackgroundColor); AddChild(new WorldEnvironment() { Environment = new Godot.Environment() { BackgroundColor = BackgroundColor, BackgroundMode = Godot.Environment.BGMode.Color, }, }); AddChild(ARVROrigin = new ARVROrigin()); ARVROrigin.AddChild(ARVRCamera = new ARVRCamera() { Current = true, }); ARVROrigin.AddChild(LeftController = new ARVRController() { ControllerId = 1, }); ARVROrigin.AddChild(RightController = new ARVRController() { ControllerId = 2, }); LeftController.AddChild((Spatial)GD.Load <PackedScene>("res://OQ_Toolkit/OQ_ARVRController/models3d/OculusQuestTouchController_Left.gltf").Instance()); RightController.AddChild((Spatial)GD.Load <PackedScene>("res://OQ_Toolkit/OQ_ARVRController/models3d/OculusQuestTouchController_Right.gltf").Instance()); ARVRInterface = ARVRServer.FindInterface(OS.GetName().Equals("Android") ? "OVRMobile" : "OpenVR"); if (ARVRInterface != null && ARVRInterface.Initialize()) { GetViewport().Arvr = true; } AddChild(VirtualScreen = new VirtualScreen() { Transform = new Transform(Basis.Identity, new Vector3(0f, VirtualScreen.Height / 2f, -1f)), }); AddChild(Line3D = new Line3D() { Color = Color.Color8(255, 0, 0, 255), }); AddChild(Cube); }
public LoadingRoom(GameMap map) { Name = "LoadingRoom for map " + map.Number; Map = map; AddChild(ARVROrigin = new ARVROrigin()); ARVROrigin.AddChild(ARVRCamera = new FadeCamera() { Current = true, }); ARVROrigin.AddChild(LeftController = new ARVRController() { ControllerId = 1, }); ARVROrigin.AddChild(RightController = new ARVRController() { ControllerId = 2, }); if (Assets.LoadingPic is ImageTexture pic && pic != null) { ARVRCamera.AddChild(new MeshInstance() { Mesh = new QuadMesh() { Size = new Vector2(pic.GetWidth() * Assets.PixelWidth, pic.GetHeight() * Assets.PixelHeight), }, MaterialOverride = new SpatialMaterial() { AlbedoTexture = pic, FlagsUnshaded = true, FlagsDoNotReceiveShadows = true, FlagsDisableAmbientLight = true, FlagsTransparent = false, ParamsCullMode = SpatialMaterial.CullMode.Back, ParamsSpecularMode = SpatialMaterial.SpecularMode.Disabled, }, Transform = new Transform(Basis.Identity, Vector3.Forward * pic.GetWidth() * Assets.PixelWidth), }); AmbientTasks.Add(Task.Run(Loading)); } }