Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import sciview.lwjglNatives

Expand All @@ -17,8 +18,8 @@ plugins {
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

repositories {
Expand All @@ -44,7 +45,7 @@ dependencies {
exclude("org.lwjgl")
}

val sceneryVersion = "0.12.0"
val sceneryVersion = "1.0.0-beta-2"
api("graphics.scenery:scenery:$sceneryVersion") {
version { strictly(sceneryVersion) }
exclude("org.biojava.thirdparty", "forester")
Expand Down Expand Up @@ -130,6 +131,8 @@ dependencies {
// OME
implementation("ome:formats-bsd")
implementation("ome:formats-gpl")

implementation("org.mastodon:mastodon:1.0.0-beta-34")
}

//kapt {
Expand All @@ -147,9 +150,9 @@ tasks {
withType<KotlinCompile>().all {
val version = System.getProperty("java.version").substringBefore('.').toInt()
val default = if (version == 1) "21" else "$version"
kotlinOptions {
jvmTarget = project.properties["jvmTarget"]?.toString() ?: default
freeCompilerArgs += listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn")
compilerOptions {
jvmTarget.set(JvmTarget.fromTarget( project.properties["jvmTarget"]?.toString() ?: default))
freeCompilerArgs.addAll(listOf("-Xinline-classes", "-Xopt-in=kotlin.RequiresOptIn"))
}
// sourceCompatibility = project.properties["sourceCompatibility"]?.toString() ?: default
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.configuration-cache=true
#org.gradle.caching.debug=true
jvmTarget=21
#useLocalScenery=true
kotlinVersion=1.9.23
dokkaVersion=1.9.10
kotlinVersion=2.2.10
dokkaVersion=1.9.20
scijavaParentPOMVersion=40.0.0
version=0.4.1-SNAPSHOT

Expand Down
37 changes: 32 additions & 5 deletions src/main/kotlin/sc/iview/SciView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ class SciView : SceneryBase, CalibratedRealInterval<CalibratedAxis> {
* The primary camera/observer in the scene
*/
var camera: Camera? = null
set(value) {
field = value
setActiveObserver(field)
}
set(value) {
field = value
setActiveObserver(field)
}

lateinit var controls: Controls
val targetArcball: AnimatedCenteringBeforeArcBallControl
Expand Down Expand Up @@ -1709,12 +1709,25 @@ class SciView : SceneryBase, CalibratedRealInterval<CalibratedAxis> {
return renderer
}

private var originalFOV = camera?.fov

/**
* Enable VR rendering
*/
fun toggleVRRendering() {
var renderer = renderer ?: return

// Save camera's original settings if we switch from 2D to VR
if (!vrActive) {
originalFOV = camera?.fov
}

// If turning off VR, store the controls state before deactivating
if (vrActive) {
// We're about to turn off VR
controls.stashControls()
}

vrActive = !vrActive
val cam = scene.activeObserver as? DetachedHeadCamera ?: return
var ti: TrackerInput? = null
Expand Down Expand Up @@ -1750,6 +1763,15 @@ class SciView : SceneryBase, CalibratedRealInterval<CalibratedAxis> {
// Convert back to normal Camera
logger.info("Shutting down VR")
cam.tracker = null

// Reset FOV to original value when turning off VR
originalFOV?.let { camera?.fov = it }

// Restore controls after turning off VR
controls.restoreControls()

// Reset input controls to ensure proper camera behavior
inputSetup()
}

// Enable push mode if VR is inactive, and the other way round
Expand All @@ -1775,7 +1797,12 @@ class SciView : SceneryBase, CalibratedRealInterval<CalibratedAxis> {
if (hub.has(SceneryElement.HMDInput)) {
val hmd = hub.get(SceneryElement.HMDInput) as? OpenVRHMD
hmd?.close()
// TODO hub.remove(hmd)
// Get the actual key that was used to store this element
val keyToRemove = hub.elements.entries.find { it.value == hmd }?.key
keyToRemove?.let {
hub.elements.remove(it)
logger.info("Removed ${it.name} from hub.")
}
logger.debug("Closed HMD.")
}
}
Expand Down
Loading
Loading