diff --git a/.gitignore b/.gitignore index 03507b6786..6bed74f10e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ **/.classpath **/.settings **/.project +**/.vscode **/out/ /.gradle/ /.nb-gradle/ @@ -18,12 +19,15 @@ *.jnilib *.dylib *.iml +*.class +*.jtxt .gradletasknamecache .DS_Store /jme3-core/src/main/resources/com/jme3/system/version.properties /jme3-*/build/ +/jme3-*/bin/ /jme3-bullet-native/bullet3.zip -/jme3-bullet-native/bullet3-2.86.1/ +/jme3-bullet-native/bullet3-*/ /jme3-bullet-native/src/native/cpp/com_jme3_bullet_*.h /jme3-android-native/openal-soft/ /jme3-android-native/OpenALSoft.zip @@ -38,9 +42,11 @@ !/jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib !/jme3-bullet-native/libs/native/linux/x86/libbulletjme.so !/jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so +/jme3-examples/private/ !/jme3-vr/src/main/resources/**/*.dylib !/jme3-vr/src/main/resources/**/*.so !/jme3-vr/src/main/resources/**/*.so.dbg !/jme3-vr/src/main/resources/**/*.dll !/jme3-vr/src/main/resources/**/*.pdb /buildMaven.bat + diff --git a/.travis.yml b/.travis.yml index fc586f6397..c0e3bd6e9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,9 @@ sudo: true branches: only: - master - - v3.1 - - /^v3.2.0-.*$/ + - /^v3.3.*$/ + - v3.2 + - /^v3.2.*$/ matrix: include: @@ -13,8 +14,8 @@ matrix: jdk: oraclejdk8 env: UPLOAD=true UPLOAD_NATIVE=true - os: linux - jdk: openjdk7 - dist: precise + jdk: openjdk11 + dist: xenial - os: osx osx_image: xcode9.3 env: UPLOAD_NATIVE=true @@ -73,7 +74,6 @@ deploy: repo: jMonkeyEngine/jmonkeyengine tags: true - # before_install: # required libs for android build tools # sudo apt-get update @@ -82,6 +82,4 @@ deploy: # newest Android NDK # wget http://dl.google.com/android/ndk/android-ndk-r10c-linux-x86_64.bin -O ndk.bin # 7z x ndk.bin -y > /dev/null - # export ANDROID_NDK=`pwd`/android-ndk-r10c - - + # export ANDROID_NDK=`pwd`/android-ndk-r10c \ No newline at end of file diff --git a/README.md b/README.md index b87abb2037..d6f6517589 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ jMonkeyEngine [![Build Status](https://travis-ci.org/jMonkeyEngine/jmonkeyengine.svg?branch=master)](https://travis-ci.org/jMonkeyEngine/jmonkeyengine) -jMonkeyEngine is a 3D game engine for adventurous Java developers. It’s open-source, cross-platform, and cutting-edge. 3.2.0 is the latest stable version of the jMonkeyEngine 3 SDK, a complete game development suite. We'll release 3.2.x updates until the major 3.3 release arrives. +jMonkeyEngine is a 3D game engine for adventurous Java developers. It’s open-source, cross-platform, and cutting-edge. 3.2.2 is the latest stable version of the jMonkeyEngine 3 SDK, a complete game development suite. We'll release 3.2.x updates until the major 3.3 release arrives. The engine is used by several commercial game studios and computer-science courses. Here's a taste: @@ -15,12 +15,13 @@ The engine is used by several commercial game studios and computer-science cours - [Copod](http://herebeben.com/copod) - [Attack of the Gelatinous Blob](http://attackofthegelatinousblob.com/) - [Chaos](http://4realms.net/) - - [Mythruna](https://mythruna.com/) + - [Mythruna](http://mythruna.com/) - [PirateHell](http://www.desura.com/games/piratehell) - [3089 (on steam)](http://store.steampowered.com/app/263360/) - [3079 (on steam)](http://store.steampowered.com/app/259620/) - [Lightspeed Frontier](http://www.lightspeedfrontier.com/) - [Skullstone](http://www.skullstonegame.com/) + - [Spoxel](https://store.steampowered.com/app/746880/Spoxel/) ## Getting started diff --git a/appveyor.yml b/appveyor.yml index 036db80012..00c9d5c265 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,10 +3,13 @@ version: 1.0.{build}.{branch} branches: only: - master + - v3.2 only_commits: files: - jme3-bullet-native/ + - appveyor.yml + - gradle.properties skip_tags: true @@ -34,7 +37,7 @@ build_script: cache: - C:\Users\appveyor\.gradle\caches - C:\Users\appveyor\.gradle\wrapper -- jme3-bullet-native\bullet3.zip +- jme3-bullet-native\bullet3.zip -> gradle.properties test: off deploy: off diff --git a/common.gradle b/common.gradle index c396df30a3..80b22904d7 100644 --- a/common.gradle +++ b/common.gradle @@ -8,7 +8,7 @@ apply plugin: 'maven' group = 'org.jmonkeyengine' version = jmePomVersion -sourceCompatibility = '1.7' +sourceCompatibility = '1.8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' repositories { @@ -24,7 +24,7 @@ repositories { dependencies { // Adding dependencies here will add the dependencies to each subproject. testCompile group: 'junit', name: 'junit', version: '4.12' - testCompile group: 'org.mockito', name: 'mockito-core', version: '2.0.28-beta' + testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19' testCompile group: 'org.easytesting', name: 'fest-assert-core', version: '2.0M10' } @@ -43,6 +43,8 @@ javadoc { options.header = "jMonkeyEngine ${jmeMainVersion} ${project.name}" options.author = "true" options.use = "true" + options.charSet = "UTF-8" + options.encoding = "UTF-8" //disable doclint for JDK8, more quiet output if (JavaVersion.current().isJava8Compatible()){ options.addStringOption('Xdoclint:none', '-quiet') diff --git a/gradle.properties b/gradle.properties index 000bf69308..38b86a10f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ jmeMainVersion = 3.3 # Version addition pre-alpha-svn, Stable, Beta jmeVersionTag = SNAPSHOT # Increment this each time jmeVersionTag changes but jmeVersion stays the same -jmeVersionTagID = 0 +jmeVersionTagID = 2 # specify if JavaDoc should be built buildJavaDoc = true @@ -16,11 +16,11 @@ buildAndroidExamples = false # Path to android NDK for building native libraries #ndkPath=/Users/normenhansen/Documents/Code-Import/android-ndk-r7 -ndkPath = /opt/android-ndk-r10c +ndkPath = /opt/android-ndk-r16b # Path for downloading native Bullet -bulletUrl = https://github.com/bulletphysics/bullet3/archive/2.86.1.zip -bulletFolder = bullet3-2.86.1 +bulletUrl = https://github.com/bulletphysics/bullet3/archive/2.87.zip +bulletFolder = bullet3-2.87 bulletZipFile = bullet3.zip # POM settings @@ -38,3 +38,4 @@ POM_INCEPTION_YEAR=2009 # Bintray settings to override in $HOME/.gradle/gradle.properties or ENV or commandline bintray_user= bintray_api_key= + diff --git a/jme3-android-examples/src/main/java/jme3test/android/TestAndroidResources.java b/jme3-android-examples/src/main/java/jme3test/android/TestAndroidResources.java index 7484b1ec89..68e5897792 100644 --- a/jme3-android-examples/src/main/java/jme3test/android/TestAndroidResources.java +++ b/jme3-android-examples/src/main/java/jme3test/android/TestAndroidResources.java @@ -1,15 +1,9 @@ package jme3test.android; import com.jme3.app.SimpleApplication; -import com.jme3.light.AmbientLight; -import com.jme3.light.PointLight; import com.jme3.material.Material; -import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; -import com.jme3.scene.shape.Sphere; -import com.jme3.util.TangentBinormalGenerator; /** * Test case to look for images stored in the Android drawable and mipmap directories. Image files are diff --git a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java index bd75be6e37..907dd4e6ac 100644 --- a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java +++ b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/JmeFragment.java @@ -1,16 +1,12 @@ package org.jmonkeyengine.jme3androidexamples; import android.os.Bundle; -import android.util.Log; import com.jme3.app.AndroidHarnessFragment; - import java.util.logging.Level; import java.util.logging.LogManager; -import static org.jmonkeyengine.jme3androidexamples.MainActivity.*; - /** - * A placeholder fragment containing a the jME GLSurfaceView. + * A placeholder fragment containing a jME GLSurfaceView. */ public class JmeFragment extends AndroidHarnessFragment { diff --git a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/MainActivity.java b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/MainActivity.java index 83a378ef8b..81cb3f8568 100644 --- a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/MainActivity.java +++ b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/MainActivity.java @@ -1,6 +1,5 @@ package org.jmonkeyengine.jme3androidexamples; -import android.app.Activity; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.os.Bundle; diff --git a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/TestActivity.java b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/TestActivity.java index 918bce4c05..70e7075705 100644 --- a/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/TestActivity.java +++ b/jme3-android-examples/src/main/java/org/jmonkeyengine/jme3androidexamples/TestActivity.java @@ -1,9 +1,8 @@ package org.jmonkeyengine.jme3androidexamples; import android.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; import android.os.Bundle; -import android.util.Log; +import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; diff --git a/jme3-android-native/decode.gradle b/jme3-android-native/decode.gradle index 50209172c3..f5ab90a00a 100644 --- a/jme3-android-native/decode.gradle +++ b/jme3-android-native/decode.gradle @@ -3,6 +3,7 @@ String stbiUrl = 'https://raw.githubusercontent.com/nothings/stb/master/stb_imag // Working directories for the ndk build. String decodeBuildDir = "${buildDir}" + File.separator + 'decode' +String decodeClassesBuildDir = "${buildDir}" + File.separator + 'decode_classes' String decodeBuildJniDir = decodeBuildDir + File.separator + 'jni' String decodeBuildLibsDir = decodeBuildDir + File.separator + 'libs' @@ -44,13 +45,20 @@ task copyTremorFiles(type: Copy) { into outputDir } -// Generate headers via javah +// Generate headers via javac -h task generateJavahHeaders(type: Exec) { - executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah') - args '-d', decodeSourceDir - args '-classpath', project.projectClassPath - args "com.jme3.audio.plugins.NativeVorbisFile" - args "com.jme3.texture.plugins.AndroidNativeImageLoader" + def files0 = fileTree("src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files1 = fileTree("src/common/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files2 = fileTree("../jme3-core/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files3 = fileTree("../jme3-core/src/plugins/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files4 = fileTree("../jme3-core/src/tools/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files5 = fileTree("../jme3-terrain/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def filesList = "\"" + files0.join("\"\n\"") + "\"\n\"" + files1.join("\"\n\"") + "\"\n\"" + files2.join("\"\n\"") + "\"\n\"" + files3.join("\"\n\"") + "\"\n\"" + files4.join("\"\n\"") + "\"\n\"" + files5.join("\"\n\"") + "\"" + new File("$projectDir/java_classes.jtxt").text = filesList.replaceAll(java.util.regex.Pattern.quote("\\"), java.util.regex.Matcher.quoteReplacement("/")) + executable org.gradle.internal.jvm.Jvm.current().getExecutable('javac') + args '-h', decodeSourceDir + args "@$projectDir/java_classes.jtxt" + args '-d', decodeClassesBuildDir } // Copy jME Android native files to jni directory diff --git a/jme3-android-native/openalsoft.gradle b/jme3-android-native/openalsoft.gradle index 5ae9ec3d7f..ed4eeacfdb 100644 --- a/jme3-android-native/openalsoft.gradle +++ b/jme3-android-native/openalsoft.gradle @@ -9,6 +9,7 @@ String openALSoftFolder = 'openal-soft-e5016f8' //Working directories for the ndk build. String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft' +String openalsoftClassesBuildDir = "${buildDir}" + File.separator + 'openalsoft_classes' String openalsoftBuildJniDir = openalsoftBuildDir + File.separator + 'jni' String openalsoftBuildLibsDir = openalsoftBuildDir + File.separator + 'libs' @@ -73,12 +74,18 @@ task copyJmeOpenALSoft(type: Copy, dependsOn:copyOpenALSoft) { } task generateOpenAlSoftHeaders(type:Exec, dependsOn: copyJmeOpenALSoft) { - executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah') - args '-d', openalsoftJmeAndroidPath - args '-classpath', project.projectClassPath - args "com.jme3.audio.android.AndroidAL" - args "com.jme3.audio.android.AndroidALC" - args "com.jme3.audio.android.AndroidEFX" + def files0 = fileTree("src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files1 = fileTree("src/common/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files2 = fileTree("../jme3-core/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files3 = fileTree("../jme3-core/src/plugins/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files4 = fileTree("../jme3-core/src/tools/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files5 = fileTree("../jme3-terrain/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def filesList = "\"" + files0.join("\"\n\"") + "\"\n\"" + files1.join("\"\n\"") + "\"\n\"" + files2.join("\"\n\"") + "\"\n\"" + files3.join("\"\n\"") + "\"\n\"" + files4.join("\"\n\"") + "\"\n\"" + files5.join("\"\n\"") + "\"" + new File("$projectDir/java_classes.jtxt").text = filesList.replaceAll(java.util.regex.Pattern.quote("\\"), java.util.regex.Matcher.quoteReplacement("/")) + executable org.gradle.internal.jvm.Jvm.current().getExecutable('javac') + args '-h', openalsoftJmeAndroidPath + args "@$projectDir/java_classes.jtxt" + args '-d', openalsoftClassesBuildDir } task buildOpenAlSoftNativeLib(type: Exec, dependsOn: generateOpenAlSoftHeaders) { diff --git a/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java b/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java index 142a23d98e..5ca059e9a7 100644 --- a/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java +++ b/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java @@ -3,7 +3,6 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; -import android.content.pm.ActivityInfo; import android.graphics.drawable.Drawable; import android.graphics.drawable.NinePatchDrawable; import android.opengl.GLSurfaceView; diff --git a/jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java b/jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java index fed2d88631..7b2bf180f2 100644 --- a/jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java +++ b/jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -125,7 +125,7 @@ public class AndroidHarnessFragment extends Fragment implements /** * Set the maximum resolution for the surfaceview in either the * width or height screen direction depending on the screen size. - * If the surfaceview is retangular, the longest side (width or height) + * If the surfaceview is rectangular, the longest side (width or height) * will have the resolution set to a maximum of maxResolutionDimension. * The other direction will be set to a value that maintains the aspect * ratio of the surfaceview.
@@ -276,17 +276,17 @@ public void onCreate(Bundle savedInstanceState) { } /** - * Called by the system to create the View hierchy associated with this + * Called by the system to create the View hierarchy associated with this * Fragment. For jME, this is a FrameLayout that contains the GLSurfaceView * and an overlaying SplashScreen Image (if used). The View that is returned - * will be placed on the screen within the boundries of the View borders defined + * will be placed on the screen within the boundaries of the View borders defined * by the Activity's layout parameters for this Fragment. For jME, we also * update the application reference to the new view. * * @param inflater * @param container * @param savedInstanceState - * @return + * @return the new view */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java b/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java index 306887910d..1308b08ddc 100644 --- a/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java +++ b/jme3-android/src/main/java/com/jme3/app/DefaultAndroidProfiler.java @@ -135,6 +135,11 @@ public void appStep(AppStep appStep) { } } + @Override + public void appSubStep(String... additionalInfo) { + + } + public void vpStep(VpStep vpStep, ViewPort vp, RenderQueue.Bucket bucket) { if (androidApiLevel >= 18) { switch (vpStep) { diff --git a/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java b/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java index 47d0e36ca5..f89a49879d 100644 --- a/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java +++ b/jme3-android/src/main/java/com/jme3/app/state/VideoRecorderAppState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -123,7 +123,6 @@ public VideoRecorderAppState(File file) { * This constructor allows you to specify the output file of the video as well as the quality * @param file the video file * @param quality the quality of the jpegs in the video stream (0.0 smallest file - 1.0 largest file) - * @param framerate the frame rate of the resulting video, the application will be locked to this framerate */ public VideoRecorderAppState(File file, float quality) { this.file = file; diff --git a/jme3-android/src/main/java/com/jme3/asset/plugins/AndroidLocator.java b/jme3-android/src/main/java/com/jme3/asset/plugins/AndroidLocator.java index cb102e582c..7c7200bb92 100644 --- a/jme3-android/src/main/java/com/jme3/asset/plugins/AndroidLocator.java +++ b/jme3-android/src/main/java/com/jme3/asset/plugins/AndroidLocator.java @@ -6,7 +6,6 @@ import com.jme3.system.android.JmeAndroidSystem; import java.io.IOException; import java.io.InputStream; -import java.util.logging.Level; import java.util.logging.Logger; public class AndroidLocator implements AssetLocator { diff --git a/jme3-android/src/main/java/com/jme3/input/android/AndroidGestureProcessor.java b/jme3-android/src/main/java/com/jme3/input/android/AndroidGestureProcessor.java index 2c03679463..e905a852b5 100644 --- a/jme3-android/src/main/java/com/jme3/input/android/AndroidGestureProcessor.java +++ b/jme3-android/src/main/java/com/jme3/input/android/AndroidGestureProcessor.java @@ -36,7 +36,6 @@ import android.view.MotionEvent; import android.view.ScaleGestureDetector; import com.jme3.input.event.TouchEvent; -import java.util.logging.Level; import java.util.logging.Logger; /** diff --git a/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java b/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java index 9f4729c668..b52cad7d2e 100644 --- a/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java +++ b/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler.java @@ -42,7 +42,6 @@ import com.jme3.input.JoyInput; import com.jme3.input.TouchInput; import com.jme3.system.AppSettings; -import java.util.logging.Level; import java.util.logging.Logger; /** diff --git a/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler14.java b/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler14.java index 59df7c26c0..ad11cd9343 100644 --- a/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler14.java +++ b/jme3-android/src/main/java/com/jme3/input/android/AndroidInputHandler14.java @@ -37,7 +37,6 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; -import java.util.logging.Level; import java.util.logging.Logger; /** diff --git a/jme3-android/src/main/java/com/jme3/input/android/AndroidTouchInput14.java b/jme3-android/src/main/java/com/jme3/input/android/AndroidTouchInput14.java index 617a4b719e..7b5e987b59 100644 --- a/jme3-android/src/main/java/com/jme3/input/android/AndroidTouchInput14.java +++ b/jme3-android/src/main/java/com/jme3/input/android/AndroidTouchInput14.java @@ -36,7 +36,6 @@ import com.jme3.input.event.TouchEvent; import com.jme3.math.Vector2f; import java.util.HashMap; -import java.util.logging.Level; import java.util.logging.Logger; /** diff --git a/jme3-android/src/main/java/com/jme3/renderer/android/RendererUtil.java b/jme3-android/src/main/java/com/jme3/renderer/android/RendererUtil.java index f43dd2d570..5f9c842927 100644 --- a/jme3-android/src/main/java/com/jme3/renderer/android/RendererUtil.java +++ b/jme3-android/src/main/java/com/jme3/renderer/android/RendererUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ import javax.microedition.khronos.egl.EGL11; /** - * Utility class used by the {@link OGLESShaderRenderer renderer} and sister + * Utility class used by the OGLESShaderRenderer and sister * classes. * * @author Kirill Vainer diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderContext.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderContext.java index c96807ed03..fea54f13b7 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderContext.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -304,10 +304,7 @@ public T getHelper(Class clazz) { * * @param oldMemoryAddress * the address of the feature - * @param featureName - * the name of the feature - * @param structure - * the filled structure of the feature + * @param featureDataType * @param feature * the feature we want to store */ @@ -330,7 +327,7 @@ public void addLoadedFeatures(Long oldMemoryAddress, LoadedDataType featureDataT * @param oldMemoryAddress * the address of the feature * @param loadedFeatureDataType - * the type of data we want to retreive it can be either filled + * the type of data we want to retrieve it can be either filled * structure or already converted feature * @return loaded feature or null if it was not yet loaded */ @@ -497,7 +494,7 @@ public Structure popParent() { } /** - * This method retreives the structure at the top of the parent's stack but + * This method retrieves the structure at the top of the parent's stack but * does not remove it. * * @return the structure from the top of the stack @@ -754,7 +751,7 @@ public Map getActions() { } /** - * This enum defines what loaded data type user wants to retreive. It can be + * This enum defines what loaded data type user wants to retrieve. It can be * either filled structure or already converted data. * * @author Marcin Roguski (Kaelthas) diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderLoader.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderLoader.java index f519cb9b53..b7d9df8412 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderLoader.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -220,7 +220,7 @@ public Spatial load(AssetInfo assetInfo) throws IOException { } catch (BlenderFileException e) { throw new IOException(e.getLocalizedMessage(), e); } catch (Exception e) { - throw new IOException("Unexpected importer exception occured: " + e.getLocalizedMessage(), e); + throw new IOException("Unexpected importer exception occurred: " + e.getLocalizedMessage(), e); } finally { this.clear(assetInfo); } @@ -245,16 +245,18 @@ private Node toScene(Structure structure, BlenderContext blenderContext) throws Structure objectStructure = pObject.fetchData().get(0); Object object = objectHelper.toObject(objectStructure, blenderContext); - if (object instanceof LightNode) { - result.addLight(((LightNode) object).getLight());// FIXME: check if this is needed !!! - result.attachChild((LightNode) object); - } else if (object instanceof Node) { + if (object instanceof Node) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "{0}: {1}--> {2}", new Object[] { ((Node) object).getName(), ((Node) object).getLocalTranslation().toString(), ((Node) object).getParent() == null ? "null" : ((Node) object).getParent().getName() }); } + if (((Node) object).getParent() == null) { result.attachChild((Spatial) object); } + + if(object instanceof LightNode) { + result.addLight(((LightNode) object).getLight()); + } } } } diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/Constraint.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/Constraint.java index f2268199c5..d96a1f2ce9 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/Constraint.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/Constraint.java @@ -48,8 +48,6 @@ public abstract class Constraint { * the constraint's structure (bConstraint clss in blender 2.49). * @param ownerOMA * the old memory address of the constraint owner - * @param ownerType - * the type of the constraint owner * @param influenceIpo * the ipo curve of the influence factor * @param blenderContext diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java index 6d3058ed27..eb253396a4 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/ConstraintHelper.java @@ -153,7 +153,7 @@ public void loadConstraints(Structure objectStructure, BlenderContext blenderCon * the blender context * @return constraint object for the required type * @throws BlenderFileException - * thrown when problems with blender file occured + * thrown when problems with blender file occurred */ private Constraint createConstraint(String dataType, Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException { if (dataType == null || "Mesh".equalsIgnoreCase(dataType) || "Camera".equalsIgnoreCase(dataType) || "Lamp".equalsIgnoreCase(dataType)) { @@ -197,7 +197,7 @@ public void bakeConstraints(BlenderContext blenderContext) { } /** - * The method retreives the transform from a feature in a given space. + * The method retrieves the transform from a feature in a given space. * * @param oma * the OMA of the feature (spatial or armature node) @@ -205,7 +205,7 @@ public void bakeConstraints(BlenderContext blenderContext) { * the feature's subtarget (bone in a case of armature's node) * @param space * the space the transform is evaluated to - * @return thensform of a feature in a given space + * @return the transform of a feature in a given space */ public Transform getTransform(Long oma, String subtargetName, Space space) { Spatial feature = (Spatial) blenderContext.getLoadedFeature(oma, LoadedDataType.FEATURE); diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderFileException.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderFileException.java index 4c25a52da3..9deeb8fa77 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderFileException.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderFileException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,7 @@ public BlenderFileException() { /** * Constructor. Creates an exception containing the given message. * @param message - * the message describing the problem that occured + * the message describing the problem that occurred */ public BlenderFileException(String message) { super(message); @@ -58,7 +58,7 @@ public BlenderFileException(String message) { /** * Constructor. Creates an exception that is based upon other thrown object. It contains the whole stacktrace then. * @param throwable - * an exception/error that occured + * an exception/error that occurred */ public BlenderFileException(Throwable throwable) { super(throwable); @@ -67,9 +67,9 @@ public BlenderFileException(Throwable throwable) { /** * Constructor. Creates an exception with both a message and stacktrace. * @param message - * the message describing the problem that occured + * the message describing the problem that occurred * @param throwable - * an exception/error that occured + * an exception/error that occurred */ public BlenderFileException(String message, Throwable throwable) { super(message, throwable); diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderInputStream.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderInputStream.java index 94a84cd5e4..01d1037532 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderInputStream.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/BlenderInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -93,7 +93,7 @@ public BlenderInputStream(InputStream inputStream) throws BlenderFileException { try { this.readStreamToCache(bufferedInputStream); } catch (IOException e) { - throw new BlenderFileException("Problems occured while caching the file!", e); + throw new BlenderFileException("Problems occurred while caching the file!", e); } finally { try { inputStream.close(); @@ -144,7 +144,7 @@ private void decompressFile() { gis = new GZIPInputStream(new ByteArrayInputStream(cachedBuffer)); this.readStreamToCache(gis); } catch (IOException e) { - throw new IllegalStateException("IO errors occured where they should NOT! " + "The data is already buffered at this point!", e); + throw new IllegalStateException("IO errors occurred where they should NOT! " + "The data is already buffered at this point!", e); } finally { try { if (gis != null) { diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/Field.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/Field.java index 81cfdcde85..88c33467fd 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/Field.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/file/Field.java @@ -27,7 +27,7 @@ class Field implements Cloneable { /** This variable indicates the level of the pointer. */ public int pointerLevel; /** - * This variable determines the sizes of the array. If the value is null the n the field is not an array. + * This variable determines the sizes of the array. If the value is null then the field is not an array. */ public int[] tableSizes; /** This variable indicates if the field is a function pointer. */ @@ -52,7 +52,7 @@ public Field(String name, String type, BlenderContext blenderContext) throws Ble /** * Copy constructor. Used in clone method. Copying is not full. The value in the new object is not set so that we - * have a clead empty copy of the filed to fill with data. + * have a clean empty copy of the field to fill with data. * @param field * the object that we copy */ @@ -73,7 +73,7 @@ public Object clone() throws CloneNotSupportedException { } /** - * This method fills the field wth data read from the input stream. + * This method fills the field with data read from the input stream. * @param blenderInputStream * the stream we read data from * @throws BlenderFileException @@ -264,9 +264,9 @@ private void removeCharacter(StringBuilder text, char toRemove) { } /** - * This method removes all whitespaces from the text. + * This method removes all whitespace from the text. * @param text - * the text we remove whitespaces from + * the text we remove whitespace from */ private void removeWhitespaces(StringBuilder text) { for (int i = 0; i < text.length(); ++i) { @@ -306,7 +306,7 @@ public String toString() { StringBuilder result = new StringBuilder(); result.append(this.getFullName()); - // insert appropriate amount of spaces to format the output corrently + // insert appropriate number of spaces to format the output corrently int nameLength = result.length(); result.append(' ');// at least one space is a must for (int i = 1; i < NAME_LENGTH - nameLength; ++i) {// we start from i=1 because one space is already added diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/materials/MaterialContext.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/materials/MaterialContext.java index b8c5925a91..42da1c9d28 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/materials/MaterialContext.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/materials/MaterialContext.java @@ -102,7 +102,7 @@ public final class MaterialContext implements Savable { long flag = ((Number)structure.getFieldValue("flag")).longValue(); if((flag & FLAG_TRANSPARENT) != 0) { // veryfying if the transparency is present - // (in blender transparent mask is 0x10000 but its better to verify it because blender can indicate transparency when + // (in blender transparent mask is 0x10000 but it's better to verify it because blender can indicate transparency when // it is not required boolean transparent = false; if (diffuseColor != null) { diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Matrix.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Matrix.java index 29550f23b6..0b05f2f1f5 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Matrix.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Matrix.java @@ -186,11 +186,8 @@ public DQuaternion toRotationQuat() { } /** - * Retreives the scale vector from the matrix and stores it into a given + * Retrieves the scale vector from the matrix and stores it into a given * vector. - * - * @param the - * vector where the scale will be stored */ public Vector3d toScaleVector() { Vector3d result = new Vector3d(); @@ -199,11 +196,10 @@ public Vector3d toScaleVector() { } /** - * Retreives the scale vector from the matrix and stores it into a given + * Retrieves the scale vector from the matrix and stores it into a given * vector. * - * @param the - * vector where the scale will be stored + * @param vector the vector where the scale will be stored */ public void toScaleVector(Vector3d vector) { double scaleX = Math.sqrt(this.get(0, 0) * this.get(0, 0) + this.get(1, 0) * this.get(1, 0) + this.get(2, 0) * this.get(2, 0)); diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Vector3d.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Vector3d.java index db9b883044..92453cfa37 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Vector3d.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/math/Vector3d.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -116,8 +116,8 @@ public Vector3d(double x, double y, double z) { /** * Constructor instantiates a new Vector3d that is a copy * of the provided vector - * @param copy - * The Vector3d to copy + * @param vector3f + * The Vector3f to copy */ public Vector3d(Vector3f vector3f) { this(vector3f.x, vector3f.y, vector3f.z); diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java index 5890ad234f..009e3c9085 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java @@ -306,7 +306,7 @@ public TriangulationWarning triangulate() { } } } catch (BlenderFileException e) { - LOGGER.log(Level.WARNING, "Errors occured during face triangulation: {0}. The face will be triangulated with the most direct algorithm, but the results might not be identical to blender.", e.getLocalizedMessage()); + LOGGER.log(Level.WARNING, "Errors occurred during face triangulation: {0}. The face will be triangulated with the most direct algorithm, but the results might not be identical to blender.", e.getLocalizedMessage()); warning = TriangulationWarning.UNKNOWN; } if(warning != TriangulationWarning.NONE) { diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java index 4fcab87233..6a86ffecfa 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -140,11 +140,11 @@ public boolean isBMeshCompatible(Structure meshStructure) { } /** - * This method returns the vertices. + * This method returns the vertices: a list of vertex positions and a list + * of vertex normals. * * @param meshStructure * the structure containing the mesh data - * @return a list of two - element arrays, the first element is the vertex and the second - its normal * @throws BlenderFileException * this exception is thrown when the blend file structure is somehow invalid or corrupted */ @@ -247,7 +247,7 @@ public LinkedHashMap> loadUVCoordinates(Structure meshStr } } } else { - // in this case UV's are assigned to faces (the array has the same legnth as the faces count) + // in this case UV's are assigned to faces (the array has the same length as the faces count) Structure facesData = (Structure) meshStructure.getFieldValue("fdata"); Pointer pFacesDataLayers = (Pointer) facesData.getFieldValue("layers"); if (pFacesDataLayers.isNotNull()) { diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java index 0416237bb5..1b42b0c39e 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java @@ -198,8 +198,7 @@ public Collection getAdjacentFaces(Integer index) { } /** - * @param the - * edge of the mesh + * @param edge the edge of the mesh * @return a list of faces that contain the given edge or an empty list */ public Collection getAdjacentFaces(Edge edge) { @@ -212,8 +211,7 @@ public Collection getAdjacentFaces(Edge edge) { } /** - * @param the - * index of the mesh + * @param index the index of the mesh * @return a list of edges that contain the index */ public Collection getAdjacentEdges(Integer index) { @@ -223,8 +221,7 @@ public Collection getAdjacentEdges(Integer index) { /** * Tells if the given edge is a boundary edge. The boundary edge means that it belongs to a single * face or to none. - * @param the - * edge of the mesh + * @param edge the edge of the mesh * @return true if the edge is a boundary one and false otherwise */ public boolean isBoundary(Edge edge) { @@ -289,8 +286,9 @@ public TemporalMesh clone() { /** * The method rebuilds the mappings between faces and edges. Should be called after * every major change of the temporal mesh done outside it. - * @note I will remove this method soon and make the mappings to be done automatically - * when the mesh is modified. + *

+ * Note: I will remove this method soon and cause the mappings to be done + * automatically when the mesh is modified. */ public void rebuildIndexesMappings() { indexToEdgeMapping.clear(); diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/UserUVCollection.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/UserUVCollection.java index 083e5f50de..ea276af56c 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/UserUVCollection.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/UserUVCollection.java @@ -62,7 +62,7 @@ public void addUV(int materialIndex, String uvSetName, Vector2f uv, int jmeVerte * the name of the UV set * @param vertexIndex * the vertex index corresponds to the index in jme mesh and not the original one in blender - * @return + * @return a pre-existing coordinate vector */ public Vector2f getUVForVertex(String uvSetName, int vertexIndex) { return uvsMap.get(uvSetName).get(vertexIndex); diff --git a/jme3-bullet-native-android/build.gradle b/jme3-bullet-native-android/build.gradle index 499330a9e4..1058ef3225 100644 --- a/jme3-bullet-native-android/build.gradle +++ b/jme3-bullet-native-android/build.gradle @@ -104,7 +104,8 @@ task copyJmeAndroid(type: Copy) { into outputDir } -task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, copyJmeCpp, copyBullet]) { +//dependsOn ':jme3-bullet:generateNativeHeaders' +task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:generateNativeHeaders', copyJmeCpp, copyBullet]) { // args 'TARGET_PLATFORM=android-9' // println "buildBulletNativeLib ndkWorkingPath: " + ndkWorkingPath // println "buildBulletNativeLib rootProject.ndkCommandPath: " + rootProject.ndkCommandPath diff --git a/jme3-bullet-native-android/libs/arm64-v8a/libbulletjme.so b/jme3-bullet-native-android/libs/arm64-v8a/libbulletjme.so index 0aff124f85..e64b52ba1b 100755 Binary files a/jme3-bullet-native-android/libs/arm64-v8a/libbulletjme.so and b/jme3-bullet-native-android/libs/arm64-v8a/libbulletjme.so differ diff --git a/jme3-bullet-native-android/libs/armeabi-v7a/libbulletjme.so b/jme3-bullet-native-android/libs/armeabi-v7a/libbulletjme.so index a57b41067e..7e2aad17b7 100755 Binary files a/jme3-bullet-native-android/libs/armeabi-v7a/libbulletjme.so and b/jme3-bullet-native-android/libs/armeabi-v7a/libbulletjme.so differ diff --git a/jme3-bullet-native-android/libs/armeabi/libbulletjme.so b/jme3-bullet-native-android/libs/armeabi/libbulletjme.so index 0750264f69..f54710e4a7 100755 Binary files a/jme3-bullet-native-android/libs/armeabi/libbulletjme.so and b/jme3-bullet-native-android/libs/armeabi/libbulletjme.so differ diff --git a/jme3-bullet-native-android/libs/mips/libbulletjme.so b/jme3-bullet-native-android/libs/mips/libbulletjme.so index 90dd9f57ca..adc7fa1aa7 100755 Binary files a/jme3-bullet-native-android/libs/mips/libbulletjme.so and b/jme3-bullet-native-android/libs/mips/libbulletjme.so differ diff --git a/jme3-bullet-native-android/libs/mips64/libbulletjme.so b/jme3-bullet-native-android/libs/mips64/libbulletjme.so index d79b0d9b7d..094ae8478d 100755 Binary files a/jme3-bullet-native-android/libs/mips64/libbulletjme.so and b/jme3-bullet-native-android/libs/mips64/libbulletjme.so differ diff --git a/jme3-bullet-native-android/libs/x86/libbulletjme.so b/jme3-bullet-native-android/libs/x86/libbulletjme.so index 66b1b67aeb..1089c838e7 100755 Binary files a/jme3-bullet-native-android/libs/x86/libbulletjme.so and b/jme3-bullet-native-android/libs/x86/libbulletjme.so differ diff --git a/jme3-bullet-native-android/libs/x86_64/libbulletjme.so b/jme3-bullet-native-android/libs/x86_64/libbulletjme.so index 59c6a2ef90..2f26225794 100755 Binary files a/jme3-bullet-native-android/libs/x86_64/libbulletjme.so and b/jme3-bullet-native-android/libs/x86_64/libbulletjme.so differ diff --git a/jme3-bullet-native-android/src/native/android/Android.mk b/jme3-bullet-native-android/src/native/android/Android.mk index b46f8ec29c..1a1e64b89c 100644 --- a/jme3-bullet-native-android/src/native/android/Android.mk +++ b/jme3-bullet-native-android/src/native/android/Android.mk @@ -54,12 +54,23 @@ LOCAL_C_INCLUDES := $(BULLET_PATH)/\ $(BULLET_PATH)/vectormath/sse\ $(BULLET_PATH)/vectormath/neon -LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) +#ARM mode more performant than thumb for old armeabi +ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), armeabi)) +LOCAL_ARM_MODE := arm +endif + +#Enable neon for armv7 +ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), armeabi-v7a)) +LOCAL_ARM_NEON := true +endif + +LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -ldl -lm -llog FILE_LIST := $(wildcard $(LOCAL_PATH)/*.cpp) FILE_LIST += $(wildcard $(LOCAL_PATH)/**/*.cpp) FILE_LIST += $(wildcard $(LOCAL_PATH)/**/**/*.cpp) +FILE_LIST := $(filter-out $(wildcard $(LOCAL_PATH)/Bullet3OpenCL/**/*.cpp), $(FILE_LIST)) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) -include $(BUILD_SHARED_LIBRARY) \ No newline at end of file +include $(BUILD_SHARED_LIBRARY) diff --git a/jme3-bullet-native-android/src/native/android/Application.mk b/jme3-bullet-native-android/src/native/android/Application.mk index 34f65f6e89..44c5c842e5 100644 --- a/jme3-bullet-native-android/src/native/android/Application.mk +++ b/jme3-bullet-native-android/src/native/android/Application.mk @@ -1,4 +1,7 @@ APP_OPTIM := release APP_ABI := all -#APP_ABI := armeabi-v7a +APP_STL := stlport_static +# gnustl_static or stlport_static APP_MODULES := bulletjme +APP_CFLAGS += -funroll-loops -Ofast + diff --git a/jme3-bullet-native/build.gradle b/jme3-bullet-native/build.gradle index 55273f09e9..558940173f 100644 --- a/jme3-bullet-native/build.gradle +++ b/jme3-bullet-native/build.gradle @@ -21,6 +21,10 @@ task cleanHeaders(type: Delete) { task cleanUnzipped(type: Delete) { delete bulletFolder } +// clean up the downloaded archive +task cleanZipFile(type: Delete) { + delete bulletZipFile +} model { components { @@ -37,13 +41,21 @@ model { source { srcDir 'src/native/cpp' srcDir bulletSrcPath + exclude 'Bullet3Collision/**' + exclude 'Bullet3Dynamics/**' + exclude 'Bullet3Geometry/**' exclude 'Bullet3OpenCL/**' + exclude 'Bullet3Serialize/**' include '**/*.cpp' } exportedHeaders { srcDir 'src/native/cpp' srcDir bulletSrcPath + exclude 'Bullet3Collision/**' + exclude 'Bullet3Dynamics/**' + exclude 'Bullet3Geometry/**' exclude 'Bullet3OpenCL/**' + exclude 'Bullet3Serialize/**' include '**/*.h' } } @@ -208,7 +220,7 @@ task unzipBulletIfNeeded { } unzipBulletIfNeeded.dependsOn { - if (buildNativeProjects == "true" && !file(bulletFolder).isDirectory()) { + if (buildNativeProjects == "true") { unzipBullet } } diff --git a/jme3-bullet-native/libs/native/linux/x86/libbulletjme.so b/jme3-bullet-native/libs/native/linux/x86/libbulletjme.so index 9aa3d7a26c..d0ea174f71 100755 Binary files a/jme3-bullet-native/libs/native/linux/x86/libbulletjme.so and b/jme3-bullet-native/libs/native/linux/x86/libbulletjme.so differ diff --git a/jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so b/jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so index ae2e70eb0b..8cad657b2a 100755 Binary files a/jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so and b/jme3-bullet-native/libs/native/linux/x86_64/libbulletjme.so differ diff --git a/jme3-bullet-native/libs/native/osx/x86/libbulletjme.dylib b/jme3-bullet-native/libs/native/osx/x86/libbulletjme.dylib index 953b2eade2..d85332e863 100755 Binary files a/jme3-bullet-native/libs/native/osx/x86/libbulletjme.dylib and b/jme3-bullet-native/libs/native/osx/x86/libbulletjme.dylib differ diff --git a/jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib b/jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib index 1a9432c8dc..62733e513d 100755 Binary files a/jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib and b/jme3-bullet-native/libs/native/osx/x86_64/libbulletjme.dylib differ diff --git a/jme3-bullet-native/libs/native/windows/x86/bulletjme.dll b/jme3-bullet-native/libs/native/windows/x86/bulletjme.dll index f4556c5ad5..f826da28f7 100755 Binary files a/jme3-bullet-native/libs/native/windows/x86/bulletjme.dll and b/jme3-bullet-native/libs/native/windows/x86/bulletjme.dll differ diff --git a/jme3-bullet-native/libs/native/windows/x86_64/bulletjme.dll b/jme3-bullet-native/libs/native/windows/x86_64/bulletjme.dll index 8a4ac5c807..9468e84681 100755 Binary files a/jme3-bullet-native/libs/native/windows/x86_64/bulletjme.dll and b/jme3-bullet-native/libs/native/windows/x86_64/bulletjme.dll differ diff --git a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_PhysicsSpace.cpp b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_PhysicsSpace.cpp index 3ecf7fd6b3..4e143cb4a6 100644 --- a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_PhysicsSpace.cpp +++ b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_PhysicsSpace.cpp @@ -46,16 +46,21 @@ extern "C" { * Signature: (FFFFFFI)J */ JNIEXPORT jlong JNICALL Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace - (JNIEnv * env, jobject object, jfloat minX, jfloat minY, jfloat minZ, jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphase, jboolean threading) { + (JNIEnv * env, jobject object, jfloat minX, jfloat minY, jfloat minZ, + jfloat maxX, jfloat maxY, jfloat maxZ, jint broadphase, + jboolean threading) { jmeClasses::initJavaClasses(env); + jmePhysicsSpace* space = new jmePhysicsSpace(env, object); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space has not been created."); return 0; } - space->createPhysicsSpace(minX, minY, minZ, maxX, maxY, maxZ, broadphase, threading); - return reinterpret_cast(space); + + space->createPhysicsSpace(minX, minY, minZ, maxX, maxY, maxZ, + broadphase, threading); + return reinterpret_cast (space); } /* @@ -64,8 +69,9 @@ extern "C" { * Signature: (JFIF)V */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_stepSimulation - (JNIEnv * env, jobject object, jlong spaceId, jfloat tpf, jint maxSteps, jfloat accuracy) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); + (JNIEnv * env, jobject object, jlong spaceId, jfloat tpf, jint maxSteps, + jfloat accuracy) { + jmePhysicsSpace* space = reinterpret_cast (spaceId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -81,8 +87,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addCollisionObject (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btCollisionObject* collisionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btCollisionObject* collisionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -93,7 +99,7 @@ extern "C" { env->ThrowNew(newExc, "The collision object does not exist."); return; } - jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer(); + jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer(); userPointer -> space = space; space->getDynamicsWorld()->addCollisionObject(collisionObject); @@ -106,8 +112,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeCollisionObject (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btCollisionObject* collisionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btCollisionObject* collisionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -119,7 +125,7 @@ extern "C" { return; } space->getDynamicsWorld()->removeCollisionObject(collisionObject); - jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer(); + jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer(); userPointer -> space = NULL; } @@ -130,8 +136,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addRigidBody (JNIEnv * env, jobject object, jlong spaceId, jlong rigidBodyId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btRigidBody* collisionObject = reinterpret_cast(rigidBodyId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btRigidBody* collisionObject = reinterpret_cast (rigidBodyId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -142,7 +148,7 @@ extern "C" { env->ThrowNew(newExc, "The collision object does not exist."); return; } - jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer(); + jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer(); userPointer -> space = space; space->getDynamicsWorld()->addRigidBody(collisionObject); } @@ -154,8 +160,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeRigidBody (JNIEnv * env, jobject object, jlong spaceId, jlong rigidBodyId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btRigidBody* collisionObject = reinterpret_cast(rigidBodyId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btRigidBody* collisionObject = reinterpret_cast (rigidBodyId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -166,7 +172,7 @@ extern "C" { env->ThrowNew(newExc, "The collision object does not exist."); return; } - jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer(); + jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer(); userPointer -> space = NULL; space->getDynamicsWorld()->removeRigidBody(collisionObject); } @@ -178,8 +184,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addCharacterObject (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btCollisionObject* collisionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btCollisionObject* collisionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -190,12 +196,12 @@ extern "C" { env->ThrowNew(newExc, "The collision object does not exist."); return; } - jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer(); + jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer(); userPointer -> space = space; space->getDynamicsWorld()->addCollisionObject(collisionObject, btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter | btBroadphaseProxy::DefaultFilter - ); + ); } /* @@ -205,8 +211,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeCharacterObject (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btCollisionObject* collisionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btCollisionObject* collisionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -217,7 +223,7 @@ extern "C" { env->ThrowNew(newExc, "The collision object does not exist."); return; } - jmeUserPointer *userPointer = (jmeUserPointer*)collisionObject->getUserPointer(); + jmeUserPointer *userPointer = (jmeUserPointer*) collisionObject->getUserPointer(); userPointer -> space = NULL; space->getDynamicsWorld()->removeCollisionObject(collisionObject); } @@ -229,8 +235,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addAction (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btActionInterface* actionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btActionInterface* actionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -251,8 +257,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeAction (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btActionInterface* actionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btActionInterface* actionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -273,8 +279,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addVehicle (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btActionInterface* actionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btActionInterface* actionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -295,8 +301,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeVehicle (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btActionInterface* actionObject = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btActionInterface* actionObject = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -317,8 +323,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addConstraint (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btTypedConstraint* constraint = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btTypedConstraint* constraint = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -339,8 +345,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_addConstraintC (JNIEnv * env, jobject object, jlong spaceId, jlong objectId, jboolean collision) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btTypedConstraint* constraint = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btTypedConstraint* constraint = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -361,8 +367,8 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_removeConstraint (JNIEnv * env, jobject object, jlong spaceId, jlong objectId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); - btTypedConstraint* constraint = reinterpret_cast(objectId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); + btTypedConstraint* constraint = reinterpret_cast (objectId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -383,7 +389,7 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setGravity (JNIEnv * env, jobject object, jlong spaceId, jobject vector) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); @@ -391,6 +397,7 @@ extern "C" { } btVector3 gravity = btVector3(); jmeBulletUtil::convert(env, vector, &gravity); + space->getDynamicsWorld()->setGravity(gravity); } @@ -411,13 +418,13 @@ extern "C" { */ JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_finalizeNative (JNIEnv * env, jobject object, jlong spaceId) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); if (space == NULL) { return; } delete(space); } - + JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_rayTest_1native (JNIEnv * env, jobject object, jobject from, jobject to, jlong spaceId, jobject resultlist, jint flags) { @@ -465,13 +472,12 @@ extern "C" { resultCallback.resultlist = resultlist; resultCallback.m_flags = flags; space->getDynamicsWorld()->rayTest(native_from, native_to, resultCallback); + return; } - - JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_sweepTest_1native - (JNIEnv * env, jobject object, jlong shapeId, jobject from, jobject to, jlong spaceId, jobject resultlist, jfloat allowedCcdPenetration) { + (JNIEnv * env, jobject object, jlong shapeId, jobject from, jobject to, jlong spaceId, jobject resultlist, jfloat allowedCcdPenetration) { jmePhysicsSpace* space = reinterpret_cast (spaceId); if (space == NULL) { @@ -489,7 +495,7 @@ extern "C" { struct AllConvexResultCallback : public btCollisionWorld::ConvexResultCallback { - AllConvexResultCallback(const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) { + AllConvexResultCallback(const btTransform& convexFromWorld, const btTransform & convexToWorld) : m_convexFromWorld(convexFromWorld), m_convexToWorld(convexToWorld) { } jobject resultlist; JNIEnv* env; @@ -500,17 +506,16 @@ extern "C" { btVector3 m_hitPointWorld; virtual btScalar addSingleResult(btCollisionWorld::LocalConvexResult& convexResult, bool normalInWorldSpace) { - if (normalInWorldSpace) { - m_hitNormalWorld = convexResult.m_hitNormalLocal; - } - else { - m_hitNormalWorld = convexResult.m_hitCollisionObject->getWorldTransform().getBasis() * convexResult.m_hitNormalLocal; - } - m_hitPointWorld.setInterpolate3(m_convexFromWorld.getBasis() * m_convexFromWorld.getOrigin(), m_convexToWorld.getBasis() * m_convexToWorld.getOrigin(), convexResult.m_hitFraction); + if (normalInWorldSpace) { + m_hitNormalWorld = convexResult.m_hitNormalLocal; + } else { + m_hitNormalWorld = convexResult.m_hitCollisionObject->getWorldTransform().getBasis() * convexResult.m_hitNormalLocal; + } + m_hitPointWorld.setInterpolate3(m_convexFromWorld.getBasis() * m_convexFromWorld.getOrigin(), m_convexToWorld.getBasis() * m_convexToWorld.getOrigin(), convexResult.m_hitFraction); - jmeBulletUtil::addSweepResult(env, resultlist, &m_hitNormalWorld, &m_hitPointWorld, convexResult.m_hitFraction, convexResult.m_hitCollisionObject); + jmeBulletUtil::addSweepResult(env, resultlist, &m_hitNormalWorld, &m_hitPointWorld, convexResult.m_hitFraction, convexResult.m_hitCollisionObject); - return 1.f; + return 1.f; } }; @@ -528,16 +533,16 @@ extern "C" { space->getDynamicsWorld()->convexSweepTest((btConvexShape *) shape, native_from, native_to, resultCallback, native_allowed_ccd_penetration); return; } - + JNIEXPORT void JNICALL Java_com_jme3_bullet_PhysicsSpace_setSolverNumIterations (JNIEnv *env, jobject object, jlong spaceId, jint value) { - jmePhysicsSpace* space = reinterpret_cast(spaceId); + jmePhysicsSpace* space = reinterpret_cast (spaceId); if (space == NULL) { jclass newExc = env->FindClass("java/lang/NullPointerException"); env->ThrowNew(newExc, "The physics space does not exist."); return; } - + space->getDynamicsWorld()->getSolverInfo().m_numIterations = value; } diff --git a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_PhysicsCollisionObject.cpp b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_PhysicsCollisionObject.cpp index e3852c76a4..0c7f0161ae 100644 --- a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_PhysicsCollisionObject.cpp +++ b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_PhysicsCollisionObject.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -143,6 +143,42 @@ extern "C" { } } + /* + * Class: com_jme3_bullet_collision_PhysicsCollisionObject + * Method: getCollisionFlags + * Signature: (J)I + */ + JNIEXPORT jint JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_getCollisionFlags + (JNIEnv *env, jobject object, jlong objectId) { + btCollisionObject* collisionObject = reinterpret_cast (objectId); + if (collisionObject == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return 0; + } + + jint result = collisionObject->getCollisionFlags(); + return result; + } + + /* + * Class: com_jme3_bullet_collision_PhysicsCollisionObject + * Method: setCollisionFlags + * Signature: (JI)V + */ + JNIEXPORT void JNICALL Java_com_jme3_bullet_collision_PhysicsCollisionObject_setCollisionFlags + (JNIEnv *env, jobject object, jlong objectId, jint desiredFlags) { + btCollisionObject* collisionObject = reinterpret_cast (objectId); + if (collisionObject == NULL) { + jclass newExc = env->FindClass("java/lang/NullPointerException"); + env->ThrowNew(newExc, "The native object does not exist."); + return; + } + + collisionObject->setCollisionFlags(desiredFlags); + } + + #ifdef __cplusplus } #endif diff --git a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_HullCollisionShape.cpp b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_HullCollisionShape.cpp index e3878d01ed..604f5a0e9b 100644 --- a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_HullCollisionShape.cpp +++ b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_collision_shapes_HullCollisionShape.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,6 +60,8 @@ extern "C" { shape->addPoint(vect); } + + shape->optimizeConvexHull(); return reinterpret_cast(shape); } diff --git a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_HingeJoint.cpp b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_HingeJoint.cpp index 48ba90f374..351be3ffa3 100644 --- a/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_HingeJoint.cpp +++ b/jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_HingeJoint.cpp @@ -85,7 +85,7 @@ extern "C" { env->ThrowNew(newExc, "The native object does not exist."); return 0; } - return joint->getMotorTargetVelosity(); + return joint->getMotorTargetVelocity(); } /* diff --git a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp index 485dffffe4..953511a713 100644 --- a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp +++ b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,17 +74,16 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, btBroadphaseInterface* broadphase; switch (broadphaseId) { - case 0: + case 0: // SIMPLE broadphase = new btSimpleBroadphase(); break; - case 1: + case 1: // AXIS_SWEEP_3 broadphase = new btAxisSweep3(min, max); break; - case 2: - //TODO: 32bit! - broadphase = new btAxisSweep3(min, max); + case 2: // AXIS_SWEEP_3_32 + broadphase = new bt32BitAxisSweep3(min, max); break; - case 3: + case 3: // DBVT broadphase = new btDbvtBroadphase(); break; } @@ -150,8 +149,8 @@ void jmePhysicsSpace::createPhysicsSpace(jfloat minX, jfloat minY, jfloat minZ, dynamicsWorld->getPairCache()->setOverlapFilterCallback(new jmeFilterCallback()); dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::preTickCallback, static_cast (this), true); dynamicsWorld->setInternalTickCallback(&jmePhysicsSpace::postTickCallback, static_cast (this)); - if (gContactProcessedCallback == NULL) { - gContactProcessedCallback = &jmePhysicsSpace::contactProcessedCallback; + if (gContactStartedCallback == NULL) { + gContactStartedCallback = &jmePhysicsSpace::contactStartedCallback; } } @@ -183,11 +182,10 @@ void jmePhysicsSpace::postTickCallback(btDynamicsWorld *world, btScalar timeStep } } -bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, void *body1) { - // printf("contactProcessedCallback %d %dn", body0, body1); - btCollisionObject* co0 = (btCollisionObject*) body0; +void jmePhysicsSpace::contactStartedCallback(btPersistentManifold* const &pm) { + const btCollisionObject* co0 = pm->getBody0(); + const btCollisionObject* co1 = pm->getBody1(); jmeUserPointer *up0 = (jmeUserPointer*) co0 -> getUserPointer(); - btCollisionObject* co1 = (btCollisionObject*) body1; jmeUserPointer *up1 = (jmeUserPointer*) co1 -> getUserPointer(); if (up0 != NULL) { jmePhysicsSpace *dynamicsWorld = (jmePhysicsSpace *)up0->space; @@ -197,18 +195,18 @@ bool jmePhysicsSpace::contactProcessedCallback(btManifoldPoint &cp, void *body0, if (javaPhysicsSpace != NULL) { jobject javaCollisionObject0 = env->NewLocalRef(up0->javaCollisionObject); jobject javaCollisionObject1 = env->NewLocalRef(up1->javaCollisionObject); - env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_addCollisionEvent, javaCollisionObject0, javaCollisionObject1, (jlong) & cp); + for(int i=0;igetNumContacts();i++){ + env->CallVoidMethod(javaPhysicsSpace, jmeClasses::PhysicsSpace_addCollisionEvent, javaCollisionObject0, javaCollisionObject1, (jlong) & pm->getContactPoint(i)); + if (env->ExceptionCheck()) { + env->Throw(env->ExceptionOccurred()); + } + } env->DeleteLocalRef(javaPhysicsSpace); env->DeleteLocalRef(javaCollisionObject0); env->DeleteLocalRef(javaCollisionObject1); - if (env->ExceptionCheck()) { - env->Throw(env->ExceptionOccurred()); - return true; - } } } } - return true; } btDynamicsWorld* jmePhysicsSpace::getDynamicsWorld() { diff --git a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h index 7a61e4e1ff..72c49b23cf 100644 --- a/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h +++ b/jme3-bullet-native/src/native/cpp/jmePhysicsSpace.h @@ -62,5 +62,5 @@ class jmePhysicsSpace { JNIEnv* getEnv(); static void preTickCallback(btDynamicsWorld*, btScalar); static void postTickCallback(btDynamicsWorld*, btScalar); - static bool contactProcessedCallback(btManifoldPoint &, void *, void *); + static void contactStartedCallback(btPersistentManifold* const &); }; \ No newline at end of file diff --git a/jme3-bullet/build.gradle b/jme3-bullet/build.gradle index 075d30163c..404e6cb002 100644 --- a/jme3-bullet/build.gradle +++ b/jme3-bullet/build.gradle @@ -2,6 +2,8 @@ if (!hasProperty('mainClass')) { ext.mainClass = '' } +String classBuildDir = "${buildDir}" + File.separator + 'classes' + sourceSets { main { java { @@ -17,52 +19,21 @@ dependencies { } task generateNativeHeaders(type: Exec, dependsOn: classes) { - def classes = " \ - com.jme3.bullet.PhysicsSpace, \ - \ - com.jme3.bullet.collision.PhysicsCollisionEvent, \ - com.jme3.bullet.collision.PhysicsCollisionObject,\ - com.jme3.bullet.objects.PhysicsCharacter, \ - com.jme3.bullet.objects.PhysicsGhostObject, \ - com.jme3.bullet.objects.PhysicsRigidBody, \ - com.jme3.bullet.objects.PhysicsVehicle, \ - com.jme3.bullet.objects.VehicleWheel, \ - com.jme3.bullet.objects.infos.RigidBodyMotionState, \ - \ - com.jme3.bullet.collision.shapes.CollisionShape, \ - com.jme3.bullet.collision.shapes.BoxCollisionShape, \ - com.jme3.bullet.collision.shapes.CapsuleCollisionShape, \ - com.jme3.bullet.collision.shapes.CompoundCollisionShape, \ - com.jme3.bullet.collision.shapes.ConeCollisionShape, \ - com.jme3.bullet.collision.shapes.CylinderCollisionShape, \ - com.jme3.bullet.collision.shapes.GImpactCollisionShape, \ - com.jme3.bullet.collision.shapes.HeightfieldCollisionShape, \ - com.jme3.bullet.collision.shapes.HullCollisionShape, \ - com.jme3.bullet.collision.shapes.MeshCollisionShape, \ - com.jme3.bullet.collision.shapes.PlaneCollisionShape, \ - com.jme3.bullet.collision.shapes.SimplexCollisionShape, \ - com.jme3.bullet.collision.shapes.SphereCollisionShape, \ - \ - com.jme3.bullet.joints.PhysicsJoint, \ - com.jme3.bullet.joints.ConeJoint, \ - com.jme3.bullet.joints.HingeJoint, \ - com.jme3.bullet.joints.Point2PointJoint, \ - com.jme3.bullet.joints.SixDofJoint, \ - com.jme3.bullet.joints.SixDofSpringJoint, \ - com.jme3.bullet.joints.SliderJoint, \ - com.jme3.bullet.joints.motors.RotationalLimitMotor, \ - com.jme3.bullet.joints.motors.TranslationalLimitMotor, \ - \ - com.jme3.bullet.util.NativeMeshUtil, \ - com.jme3.bullet.util.DebugShapeFactory" - + def files0 = fileTree("src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files1 = fileTree("src/common/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files2 = fileTree("../jme3-core/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files3 = fileTree("../jme3-core/src/plugins/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files4 = fileTree("../jme3-core/src/tools/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files + def files5 = fileTree("../jme3-terrain/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files def classpath = sourceSets.main.runtimeClasspath.asPath def nativeIncludes = new File(project(":jme3-bullet-native").projectDir, "src/native/cpp") - - executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah') - args "-d", nativeIncludes - args "-classpath", classpath - args classes.split(",").collect { it.trim() } + def filesList = "\"" + files0.join("\"\n\"") + "\"\n\"" + files1.join("\"\n\"") + "\"\n\"" + files2.join("\"\n\"") + "\"\n\"" + files3.join("\"\n\"") + "\"\n\"" + files4.join("\"\n\"") + "\"\n\"" + files5.join("\"\n\"") + "\"" + new File("$projectDir/java_classes.jtxt").text = filesList.replaceAll(java.util.regex.Pattern.quote("\\"), java.util.regex.Matcher.quoteReplacement("/")) + executable org.gradle.internal.jvm.Jvm.current().getExecutable('javac') + args "-h", nativeIncludes + args "@$projectDir/java_classes.jtxt" + args '-d', classBuildDir + args "-encoding", "UTF-8" } assemble.dependsOn(generateNativeHeaders) \ No newline at end of file diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/BoneLink.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/BoneLink.java new file mode 100644 index 0000000000..730b1b1708 --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/BoneLink.java @@ -0,0 +1,493 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.anim.Joint; +import com.jme3.bullet.collision.shapes.CollisionShape; +import com.jme3.bullet.joints.SixDofJoint; +import com.jme3.bullet.objects.PhysicsRigidBody; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.export.Savable; +import com.jme3.math.Matrix3f; +import com.jme3.math.Quaternion; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; +import com.jme3.scene.Spatial; +import com.jme3.util.clone.Cloner; +import java.io.IOException; +import java.util.logging.Logger; + +/** + * Link an animated bone in a skeleton to a jointed rigid body in a ragdoll. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on KinematicRagdollControl by Normen Hansen and Rémy Bouquet (Nehon). + */ +public class BoneLink extends PhysicsLink { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final public static Logger logger2 + = Logger.getLogger(BoneLink.class.getName()); + /** + * local copy of {@link com.jme3.math.Matrix3f#IDENTITY} + */ + final private static Matrix3f matrixIdentity = new Matrix3f(); + // ************************************************************************* + // fields + + /** + * bones managed by this link, in a pre-order, depth-first traversal of the + * skeleton, starting with the linked bone + */ + private Joint[] managedBones = null; + /** + * submode when kinematic + */ + private KinematicSubmode submode = KinematicSubmode.Animated; + /** + * local transform of each managed bone from the previous update + */ + private Transform[] prevBoneTransforms = null; + /** + * local transform of each managed bone at the start of the most recent + * blend interval + */ + private Transform[] startBoneTransforms = null; + // ************************************************************************* + // constructors + + /** + * No-argument constructor needed by SavableClassUtil. Do not invoke + * directly! + */ + public BoneLink() { + } + + /** + * Instantiate a purely kinematic link between the named skeleton bone and + * the specified rigid body. + * + * @param control the control that will manage this link (not null, alias + * created) + * @param bone the linked bone (not null, alias created) + * @param collisionShape the desired shape (not null, alias created) + * @param linkConfig the link configuration (not null) + * @param localOffset the location of the body's center (in the bone's local + * coordinates, not null, unaffected) + */ + BoneLink(DacLinks control, Joint bone, CollisionShape collisionShape, + float mass, Vector3f localOffset) { + super(control, bone, collisionShape, mass, localOffset); + } + // ************************************************************************* + // new methods exposed + + /** + * Add a physics joint to this link and configure its range of motion. Also + * initialize the link's parent and its array of managed bones. + * + * @param parentLink (not null, alias created) + */ + void addJoint(PhysicsLink parentLink) { + assert parentLink != null; + assert getJoint() == null; + + setParent(parentLink); + + Transform parentToWorld = parentLink.physicsTransform(null); + parentToWorld.setScale(1f); + Transform worldToParent = parentToWorld.invert(); + + Transform childToWorld = physicsTransform(null); + childToWorld.setScale(1f); + + Transform childToParent = childToWorld.clone(); + childToParent.combineWithParent(worldToParent); + + Spatial transformer = getControl().getTransformer(); + Vector3f pivotMesh = getBone().getModelTransform().getTranslation(); + Vector3f pivotWorld = transformer.localToWorld(pivotMesh, null); + + PhysicsRigidBody parentBody = parentLink.getRigidBody(); + PhysicsRigidBody childBody = getRigidBody(); + Vector3f pivotParent + = parentToWorld.transformInverseVector(pivotWorld, null); + Vector3f pivotChild + = childToWorld.transformInverseVector(pivotWorld, null); + Matrix3f rotParent = childToParent.getRotation().toRotationMatrix(); + Matrix3f rotChild = matrixIdentity; + // TODO try HingeJoint or ConeJoint + SixDofJoint joint = new SixDofJoint(parentBody, childBody, pivotParent, + pivotChild, rotParent, rotChild, true); + super.setJoint(joint); + + String name = boneName(); + RangeOfMotion rangeOfMotion = getControl().getJointLimits(name); + rangeOfMotion.setupJoint(joint); + + joint.setCollisionBetweenLinkedBodys(false); + + assert managedBones == null; + managedBones = getControl().listManagedBones(name); + + int numManagedBones = managedBones.length; + startBoneTransforms = new Transform[numManagedBones]; + for (int i = 0; i < numManagedBones; ++i) { + startBoneTransforms[i] = new Transform(); + } + } + + /** + * Begin blending this link to a purely kinematic mode. + * + * @param submode enum value (not null) + * @param blendInterval the duration of the blend interval (in seconds, + * ≥0) + */ + public void blendToKinematicMode(KinematicSubmode submode, + float blendInterval) { + super.blendToKinematicMode(blendInterval); + + this.submode = submode; + /* + * Save initial bone transforms for blending. + */ + int numManagedBones = managedBones.length; + for (int mbIndex = 0; mbIndex < numManagedBones; ++mbIndex) { + Transform transform; + if (prevBoneTransforms == null) { // this link not updated yet + Joint managedBone = managedBones[mbIndex]; + transform = managedBone.getLocalTransform().clone(); + } else { + transform = prevBoneTransforms[mbIndex]; + } + startBoneTransforms[mbIndex].set(transform); + } + } + // ************************************************************************* + // PhysicsLink methods + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned link into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this link (not null) + * @param original the instance from which this link was shallow-cloned + * (unused) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + super.cloneFields(cloner, original); + + managedBones = cloner.clone(managedBones); + prevBoneTransforms = cloner.clone(prevBoneTransforms); + startBoneTransforms = cloner.clone(startBoneTransforms); + } + + /** + * Update this link in Dynamic mode, setting the linked bone's transform + * based on the transform of the rigid body. + */ + @Override + protected void dynamicUpdate() { + assert !getRigidBody().isKinematic(); + + Transform transform = localBoneTransform(null); + getBone().setLocalTransform(transform); + + for (Joint managedBone : managedBones) { + managedBone.updateModelTransforms(); + } + } + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new instance + */ + @Override + public BoneLink jmeClone() { + try { + BoneLink clone = (BoneLink) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * Update this link in blended Kinematic mode. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ + @Override + protected void kinematicUpdate(float tpf) { + assert tpf >= 0f : tpf; + assert getRigidBody().isKinematic(); + + Transform transform = new Transform(); + for (int mbIndex = 0; mbIndex < managedBones.length; ++mbIndex) { + Joint managedBone = managedBones[mbIndex]; + switch (submode) { + case Animated: + transform.set(managedBone.getLocalTransform()); + break; + case Frozen: + transform.set(prevBoneTransforms[mbIndex]); + break; + default: + throw new IllegalStateException(submode.toString()); + } + + if (kinematicWeight() < 1f) { // not purely kinematic yet + /* + * For a smooth transition, blend the saved bone transform + * (from the start of the blend interval) + * into the goal transform. + */ + Transform start = startBoneTransforms[mbIndex]; + Quaternion startQuat = start.getRotation(); + Quaternion endQuat = transform.getRotation(); + if (startQuat.dot(endQuat) < 0f) { + endQuat.multLocal(-1f); + } + transform.interpolateTransforms( + startBoneTransforms[mbIndex].clone(), transform, + kinematicWeight()); + } + /* + * Update the managed bone. + */ + managedBone.setLocalTransform(transform); + managedBone.updateModelTransforms(); + } + + super.kinematicUpdate(tpf); + } + + /** + * Unambiguously identify this link by name, within its DynamicAnimControl. + * + * @return a brief textual description (not null, not empty) + */ + @Override + public String name() { + String result = "Bone:" + boneName(); + return result; + } + + /** + * Copy animation data from the specified link, which must have the same + * name and the same managed bones. + * + * @param oldLink the link to copy from (not null, unaffected) + */ + void postRebuild(BoneLink oldLink) { + int numManagedBones = managedBones.length; + assert oldLink.managedBones.length == numManagedBones; + + super.postRebuild(oldLink); + if (oldLink.isKinematic()) { + submode = oldLink.submode; + } else { + submode = KinematicSubmode.Frozen; + } + + if (prevBoneTransforms == null) { + prevBoneTransforms = new Transform[numManagedBones]; + for (int i = 0; i < numManagedBones; ++i) { + prevBoneTransforms[i] = new Transform(); + } + } + for (int i = 0; i < numManagedBones; ++i) { + prevBoneTransforms[i].set(oldLink.prevBoneTransforms[i]); + startBoneTransforms[i].set(oldLink.startBoneTransforms[i]); + } + } + + /** + * De-serialize this link, for example when loading from a J3O file. + * + * @param im importer (not null) + * @throws IOException from importer + */ + @Override + public void read(JmeImporter im) throws IOException { + super.read(im); + InputCapsule ic = im.getCapsule(this); + + Savable[] tmp = ic.readSavableArray("managedBones", null); + if (tmp == null) { + managedBones = null; + } else { + managedBones = new Joint[tmp.length]; + for (int i = 0; i < tmp.length; ++i) { + managedBones[i] = (Joint) tmp[i]; + } + } + + submode = ic.readEnum("submode", KinematicSubmode.class, + KinematicSubmode.Animated); + prevBoneTransforms = RagUtils.readTransformArray(ic, + "prevBoneTransforms"); + startBoneTransforms = RagUtils.readTransformArray(ic, + "startBoneTransforms"); + } + + /** + * Immediately put this link into dynamic mode and update the range of + * motion of its joint. + * + * @param uniformAcceleration the uniform acceleration vector (in + * physics-space coordinates, not null, unaffected) + */ + @Override + public void setDynamic(Vector3f uniformAcceleration) { + getControl().verifyReadyForDynamicMode("put link into dynamic mode"); + + super.setDynamic(uniformAcceleration); + + String name = boneName(); + RangeOfMotion preset = getControl().getJointLimits(name); + preset.setupJoint((SixDofJoint) getJoint()); + } + + /** + * Internal callback, invoked once per frame during the logical-state + * update, provided the control is added to a scene. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ + @Override + void update(float tpf) { + assert tpf >= 0f : tpf; + + if (prevBoneTransforms == null) { + /* + * On the first update, allocate and initialize + * the array of previous bone transforms, if it wasn't + * allocated in blendToKinematicMode(). + */ + int numManagedBones = managedBones.length; + prevBoneTransforms = new Transform[numManagedBones]; + for (int mbIndex = 0; mbIndex < numManagedBones; ++mbIndex) { + Joint managedBone = managedBones[mbIndex]; + Transform boneTransform + = managedBone.getLocalTransform().clone(); + prevBoneTransforms[mbIndex] = boneTransform; + } + } + + super.update(tpf); + /* + * Save copies of the latest bone transforms. + */ + for (int mbIndex = 0; mbIndex < managedBones.length; ++mbIndex) { + Transform lastTransform = prevBoneTransforms[mbIndex]; + Joint managedBone = managedBones[mbIndex]; + lastTransform.set(managedBone.getLocalTransform()); + } + } + + /** + * Serialize this link, for example when saving to a J3O file. + * + * @param ex exporter (not null) + * @throws IOException from exporter + */ + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + OutputCapsule oc = ex.getCapsule(this); + + oc.write(managedBones, "managedBones", null); + oc.write(submode, "submode", KinematicSubmode.Animated); + oc.write(prevBoneTransforms, "prevBoneTransforms", new Transform[0]); + oc.write(startBoneTransforms, "startBoneTransforms", new Transform[0]); + } + // ************************************************************************* + // private methods + + /** + * Calculate the local bone transform to match the physics transform of the + * rigid body. + * + * @param storeResult storage for the result (modified if not null) + * @return the calculated bone transform (in local coordinates, either + * storeResult or a new transform, not null) + */ + private Transform localBoneTransform(Transform storeResult) { + Transform result + = (storeResult == null) ? new Transform() : storeResult; + Vector3f location = result.getTranslation(); + Quaternion orientation = result.getRotation(); + Vector3f scale = result.getScale(); + /* + * Start with the rigid body's transform in physics/world coordinates. + */ + PhysicsRigidBody body = getRigidBody(); + body.getPhysicsLocation(result.getTranslation()); + body.getPhysicsRotation(result.getRotation()); + result.setScale(body.getCollisionShape().getScale()); + /* + * Convert to mesh coordinates. + */ + Transform worldToMesh = getControl().meshTransform(null).invert(); + result.combineWithParent(worldToMesh); + /* + * Convert to the bone's local coordinate system by factoring out the + * parent bone's transform. + */ + Joint parentBone = getBone().getParent(); + RagUtils.meshToLocal(parentBone, result); + /* + * Subtract the body's local offset, rotated and scaled. + */ + Vector3f parentOffset = localOffset(null); + parentOffset.multLocal(scale); + orientation.mult(parentOffset, parentOffset); + location.subtractLocal(parentOffset); + + return result; + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/DacConfiguration.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/DacConfiguration.java new file mode 100644 index 0000000000..ea03107b6b --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/DacConfiguration.java @@ -0,0 +1,565 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.anim.Armature; +import com.jme3.anim.Joint; +import com.jme3.bullet.control.AbstractPhysicsControl; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.export.Savable; +import com.jme3.math.Vector3f; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.ViewPort; +import com.jme3.scene.Spatial; +import com.jme3.util.clone.Cloner; +import java.io.IOException; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Configure a DynamicAnimControl and access its configuration. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on KinematicRagdollControl by Normen Hansen and Rémy Bouquet (Nehon). + */ +abstract public class DacConfiguration extends AbstractPhysicsControl { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final public static Logger logger2 + = Logger.getLogger(DacConfiguration.class.getName()); + /** + * name for the ragdoll's torso, must not be used for any bone + */ + final public static String torsoName = ""; + // ************************************************************************* + // fields + + /** + * viscous damping ratio for new rigid bodies (0→no damping, + * 1→critically damped, default=0.6) + */ + private float damping = 0.6f; + /** + * minimum applied impulse for a collision event to be dispatched to + * listeners (default=0) + */ + private float eventDispatchImpulseThreshold = 0f; + /** + * mass for the torso + */ + private float torsoMass = 1f; + /** + * map linked bone names to masses + */ + private Map blConfigMap = new HashMap<>(50); + /** + * map linked bone names to ranges of motion for createSpatialData() + */ + private Map jointMap = new HashMap<>(50); + /** + * gravitational acceleration vector for ragdolls (default is 9.8 in the -Y + * direction, approximating Earth-normal in MKS units) + */ + private Vector3f gravityVector = new Vector3f(0f, -9.8f, 0f); + // ************************************************************************* + // constructors + + /** + * Instantiate an enabled control without any linked bones (torso only). + */ + DacConfiguration() { + } + // ************************************************************************* + // new methods exposed + + /** + * Count the linked bones. + * + * @return count (≥0) + */ + public int countLinkedBones() { + int count = blConfigMap.size(); + + assert count == jointMap.size(); + assert count >= 0 : count; + return count; + } + + /** + * Count the links. + * + * @return count (≥0) + */ + public int countLinks() { + int result = countLinkedBones() + 1; + return result; + } + + /** + * Read the damping ratio for new rigid bodies. + * + * @return the viscous damping ratio (0→no damping, 1→critically + * damped) + */ + public float damping() { + assert damping >= 0f : damping; + return damping; + } + + /** + * Read the event-dispatch impulse threshold of this control. + * + * @return the threshold value (≥0) + */ + public float eventDispatchImpulseThreshold() { + assert eventDispatchImpulseThreshold >= 0f; + return eventDispatchImpulseThreshold; + } + + /** + * Access the nominal range of motion for the joint connecting the named + * linked bone to its parent in the hierarchy. + * + * @param boneName the name of the linked bone (not null, not empty) + * @return the pre-existing instance (not null) + */ + public RangeOfMotion getJointLimits(String boneName) { + if (!hasBoneLink(boneName)) { + String msg = "No linked bone named " + boneName; + throw new IllegalArgumentException(msg); + } + RangeOfMotion result = jointMap.get(boneName); + + assert result != null; + return result; + } + + /** + * Copy this control's gravitational acceleration for Ragdoll mode. + * + * @param storeResult storage for the result (modified if not null) + * @return an acceleration vector (in physics-space coordinates, either + * storeResult or a new vector, not null) + */ + public Vector3f gravity(Vector3f storeResult) { + Vector3f result = (storeResult == null) ? new Vector3f() : storeResult; + result.set(gravityVector); + return result; + } + + /** + * Test whether a BoneLink exists for the named bone. + * + * @param boneName the name of the bone (may be null) + * @return true if found, otherwise false + */ + public boolean hasBoneLink(String boneName) { + boolean result; + if (boneName == null) { + result = false; + } else { + result = blConfigMap.containsKey(boneName); + } + + return result; + } + + /** + * Link the named bone using the specified mass and range of motion. + *

+ * Allowed only when the control is NOT added to a spatial. + * + * @param boneName the name of the bone to link (not null, not empty) + * @param mass the desired mass of the bone (>0) + * @param rom the desired range of motion (not null) + * @see #setJointLimits(java.lang.String, + * com.jme3.bullet.animation.RangeOfMotion) + */ + public void link(String boneName, float mass, RangeOfMotion rom) { + verifyNotAddedToSpatial("link a bone"); + if (hasBoneLink(boneName)) { + logger2.log(Level.WARNING, "Bone {0} is already linked.", boneName); + } + + jointMap.put(boneName, rom); + blConfigMap.put(boneName, mass); + } + + /** + * Enumerate all bones with bone links. + * + * @return a new array of bone names (not null, may be empty) + */ + public String[] listLinkedBoneNames() { + int size = countLinkedBones(); + String[] result = new String[size]; + Collection names = blConfigMap.keySet(); + names.toArray(result); + + return result; + } + + /** + * Read the mass of the named bone/torso. + * + * @param boneName the name of the bone/torso (not null) + * @return the mass (in physics units, >0) + */ + public float mass(String boneName) { + float mass; + if (torsoName.equals(boneName)) { + mass = torsoMass; + } else { + mass = blConfigMap.get(boneName); + } + return mass; + } + + /** + * Alter the viscous damping ratio for new rigid bodies. + * + * @param dampingRatio the desired damping ratio (non-negative, 0→no + * damping, 1→critically damped, default=0.6) + */ + public void setDamping(float dampingRatio) { + damping = dampingRatio; + } + + /** + * Alter the event-dispatch impulse threshold of this control. + * + * @param threshold the desired threshold (≥0) + */ + public void setEventDispatchImpulseThreshold(float threshold) { + eventDispatchImpulseThreshold = threshold; + } + + /** + * Alter this control's gravitational acceleration for Ragdoll mode. + * + * @param gravity the desired acceleration vector (in physics-space + * coordinates, not null, unaffected, default=0,-9.8,0) + */ + public void setGravity(Vector3f gravity) { + gravityVector.set(gravity); + } + + /** + * Alter the range of motion of the joint connecting the named BoneLink to + * its parent in the link hierarchy. + * + * @param boneName the name of the BoneLink (not null, not empty) + * @param rom the desired range of motion (not null) + */ + public void setJointLimits(String boneName, RangeOfMotion rom) { + if (!hasBoneLink(boneName)) { + String msg = "No linked bone named " + boneName; + throw new IllegalArgumentException(msg); + } + + jointMap.put(boneName, rom); + } + + /** + * Alter the mass of the named bone/torso. + * + * @param boneName the name of the bone, or torsoName (not null) + * @param mass the desired mass (>0) + */ + public void setMass(String boneName, float mass) { + if (torsoName.equals(boneName)) { + torsoMass = mass; + } else if (hasBoneLink(boneName)) { + blConfigMap.put(boneName, mass); + } else { + String msg = "No bone/torso named " + boneName; + throw new IllegalArgumentException(msg); + } + } + + /** + * Calculate the ragdoll's total mass. + * + * @return the total mass (>0) + */ + public float totalMass() { + float totalMass = torsoMass; + for (float mass : blConfigMap.values()) { + totalMass += mass; + } + + return totalMass; + } + + /** + * Unlink the BoneLink of the named bone. + *

+ * Allowed only when the control is NOT added to a spatial. + * + * @param boneName the name of the bone to unlink (not null, not empty) + */ + public void unlinkBone(String boneName) { + if (!hasBoneLink(boneName)) { + String msg = "No linked bone named " + boneName; + throw new IllegalArgumentException(msg); + } + verifyNotAddedToSpatial("unlink a bone"); + + jointMap.remove(boneName); + blConfigMap.remove(boneName); + } + // ************************************************************************* + // new protected methods + + /** + * Add unlinked descendants of the specified bone to the specified + * collection. Note: recursive. + * + * @param startBone the starting bone (not null, unaffected) + * @param addResult the collection of bone names to append to (not null, + * modified) + */ + protected void addUnlinkedDescendants(Joint startBone, + Collection addResult) { + for (Joint childBone : startBone.getChildren()) { + String childName = childBone.getName(); + if (!hasBoneLink(childName)) { + addResult.add(childBone); + addUnlinkedDescendants(childBone, addResult); + } + } + } + + /** + * Find the manager of the specified bone. + * + * @param startBone the bone (not null, unaffected) + * @return a bone/torso name (not null) + */ + protected String findManager(Joint startBone) { + String managerName; + Joint bone = startBone; + while (true) { + String boneName = bone.getName(); + if (hasBoneLink(boneName)) { + managerName = boneName; + break; + } + bone = bone.getParent(); + if (bone == null) { + managerName = torsoName; + break; + } + } + + assert managerName != null; + return managerName; + } + + /** + * Create a map from bone indices to the names of the bones that manage + * them. + * + * @param skeleton (not null, unaffected) + * @return a new array of bone/torso names (not null) + */ + protected String[] managerMap(Armature skeleton) { + int numBones = skeleton.getJointCount(); + String[] managerMap = new String[numBones]; + for (int boneIndex = 0; boneIndex < numBones; ++boneIndex) { + Joint bone = skeleton.getJoint(boneIndex); + managerMap[boneIndex] = findManager(bone); + } + + return managerMap; + } + // ************************************************************************* + // AbstractPhysicsControl methods + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned control into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this control (not null, modified) + * @param original the control from which this control was shallow-cloned + * (not null, unaffected) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + super.cloneFields(cloner, original); + + blConfigMap = cloner.clone(blConfigMap); + jointMap = cloner.clone(jointMap); + gravityVector = cloner.clone(gravityVector); + } + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new instance + */ + @Override + public DacConfiguration jmeClone() { + try { + DacConfiguration clone + = (DacConfiguration) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * De-serialize this control, for example when loading from a J3O file. + * + * @param im importer (not null) + * @throws IOException from importer + */ + @Override + public void read(JmeImporter im) throws IOException { + super.read(im); + InputCapsule ic = im.getCapsule(this); + + damping = ic.readFloat("damping", 0.6f); + eventDispatchImpulseThreshold + = ic.readFloat("eventDispatchImpulseThreshold", 0f); + + jointMap.clear(); + blConfigMap.clear(); + String[] linkedBoneNames = ic.readStringArray("linkedBoneNames", null); + Savable[] linkedBoneJoints + = ic.readSavableArray("linkedBoneJoints", null); + float[] blConfigs = ic.readFloatArray("blConfigs", null); + for (int i = 0; i < linkedBoneNames.length; ++i) { + String boneName = linkedBoneNames[i]; + RangeOfMotion rom = (RangeOfMotion) linkedBoneJoints[i]; + jointMap.put(boneName, rom); + blConfigMap.put(boneName, blConfigs[i]); + } + + torsoMass = ic.readFloat("torsoMass", 1f); + gravityVector = (Vector3f) ic.readSavable("gravity", null); + } + + /** + * Render this control. Invoked once per view port per frame, provided the + * control is added to a scene. Should be invoked only by a subclass or by + * the RenderManager. + * + * @param rm the render manager (not null) + * @param vp the view port to render (not null) + */ + @Override + public void render(RenderManager rm, ViewPort vp) { + } + + /** + * Alter whether physics-space coordinates should match the spatial's local + * coordinates. + * + * @param applyPhysicsLocal true→match local coordinates, + * false→match world coordinates (default=false) + */ + @Override + public void setApplyPhysicsLocal(boolean applyPhysicsLocal) { + if (applyPhysicsLocal) { + throw new UnsupportedOperationException( + "DynamicAnimControl does not support local physics."); + } + } + + /** + * Serialize this control, for example when saving to a J3O file. + * + * @param ex exporter (not null) + * @throws IOException from exporter + */ + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + OutputCapsule oc = ex.getCapsule(this); + + oc.write(damping, "damping", 0.6f); + oc.write(eventDispatchImpulseThreshold, "eventDispatchImpulseThreshold", + 0f); + + int count = countLinkedBones(); + String[] linkedBoneNames = new String[count]; + RangeOfMotion[] roms = new RangeOfMotion[count]; + float[] blConfigs = new float[count]; + int i = 0; + for (Map.Entry entry : blConfigMap.entrySet()) { + linkedBoneNames[i] = entry.getKey(); + roms[i] = jointMap.get(entry.getKey()); + blConfigs[i] = entry.getValue(); + ++i; + } + oc.write(linkedBoneNames, "linkedBoneNames", null); + oc.write(roms, "linkedBoneJoints", null); + oc.write(blConfigs, "blConfigs", null); + + oc.write(torsoMass, "torsoMass", 1f); + oc.write(gravityVector, "gravity", null); + } + // ************************************************************************* + // private methods + + /** + * Verify that this control is NOT added to a Spatial. + * + * @param desiredAction (not null, not empty) + */ + private void verifyNotAddedToSpatial(String desiredAction) { + assert desiredAction != null; + + Spatial controlledSpatial = getSpatial(); + if (controlledSpatial != null) { + String message = "Cannot " + desiredAction + + " while the Control is added to a Spatial."; + throw new IllegalStateException(message); + } + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/DacLinks.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/DacLinks.java new file mode 100644 index 0000000000..d80adc4a21 --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/DacLinks.java @@ -0,0 +1,1108 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.anim.Armature; +import com.jme3.anim.Joint; +import com.jme3.anim.SkinningControl; +import com.jme3.bullet.PhysicsSpace; +import com.jme3.bullet.PhysicsTickListener; +import com.jme3.bullet.collision.shapes.CollisionShape; +import com.jme3.bullet.collision.shapes.HullCollisionShape; +import com.jme3.bullet.joints.PhysicsJoint; +import com.jme3.bullet.joints.SixDofJoint; +import com.jme3.bullet.objects.PhysicsRigidBody; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.export.Savable; +import com.jme3.math.Quaternion; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; +import com.jme3.scene.Mesh; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.util.clone.Cloner; +import java.io.IOException; +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Access a DynamicAnimControl at the PhysicsLink level once it's been added to + * a Spatial. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on KinematicRagdollControl by Normen Hansen and Rémy Bouquet (Nehon). + */ +public class DacLinks + extends DacConfiguration + implements PhysicsTickListener { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final public static Logger logger3 + = Logger.getLogger(DacLinks.class.getName()); + /** + * local copy of {@link com.jme3.math.Quaternion#IDENTITY} + */ + final private static Quaternion rotateIdentity = new Quaternion(); + /** + * local copy of {@link com.jme3.math.Transform#IDENTITY} + */ + final private static Transform transformIdentity = new Transform(); + /** + * local copy of {@link com.jme3.math.Vector3f#ZERO} + */ + final private static Vector3f translateIdentity = new Vector3f(0f, 0f, 0f); + // ************************************************************************* + // fields + + /** + * false until the 1st physics tick, true thereafter, indicating that all + * links are ready for dynamic mode + */ + private boolean isReady = false; + /** + * bone links in a pre-order, depth-first traversal of the link hierarchy + */ + private List boneLinkList = null; + /** + * map bone names to bone links + */ + private Map boneLinks = new HashMap<>(32); + /** + * skeleton being controlled + */ + private Armature skeleton = null; + /** + * spatial that provides the mesh-coordinate transform + */ + private Spatial transformer = null; + /** + * torso link for this control + */ + private TorsoLink torsoLink = null; + // ************************************************************************* + // constructors + + /** + * Instantiate an enabled control without any linked bones (torso only). + */ + DacLinks() { + } + // ************************************************************************* + // new methods exposed + + /** + * Access the named bone. + *

+ * Allowed only when the control IS added to a spatial. + * + * @param boneName the name of the skeleton bone to access + * @return the pre-existing instance, or null if not found + */ + public Joint findBone(String boneName) { + verifyAddedToSpatial("access a bone"); + Joint result = skeleton.getJoint(boneName); + return result; + } + + /** + * Access the BoneLink for the named bone. Returns null if bone is not + * linked, or if the control is not added to a spatial. + * + * @param boneName the name of the bone (not null, not empty) + * @return the pre-existing BoneLink, or null if not found + */ + public BoneLink findBoneLink(String boneName) { + BoneLink boneLink = boneLinks.get(boneName); + return boneLink; + } + + /** + * Access the named link. Returns null if the name is invalid, or if the + * control is not added to a spatial. + * + * @param linkName the name of the link (not null, not empty) + * @return the pre-existing link, or null if not found + */ + public PhysicsLink findLink(String linkName) { + PhysicsLink link; + if (linkName.startsWith("Bone:")) { + String boneName = linkName.substring(5); + link = findBoneLink(boneName); + } else { + assert linkName.equals("Torso:"); + link = torsoLink; + } + + return link; + } + + /** + * Access the skeleton. Returns null if the control is not added to a + * spatial. + * + * @return the pre-existing skeleton, or null + */ + public Armature getSkeleton() { + return skeleton; + } + + /** + * Access the TorsoLink. Returns null if the control is not added to a + * spatial. + * + * @return the pre-existing TorsoLink, or null + */ + public TorsoLink getTorsoLink() { + return torsoLink; + } + + /** + * Access the spatial with the mesh-coordinate transform. Returns null if + * the control is not added to a spatial. + * + * @return the pre-existing spatial, or null + */ + Spatial getTransformer() { + return transformer; + } + + /** + * Test whether this control is ready for dynamic mode. + * + * @return true if ready, otherwise false + */ + public boolean isReady() { + return isReady; + } + + /** + * Enumerate all physics links of the specified type managed by this + * control. + * + * @param subclass of PhysicsLink + * @param linkType the subclass of PhysicsLink to search for (not null) + * @return a new array of links (not null, not empty) + */ + @SuppressWarnings("unchecked") + public List listLinks(Class linkType) { + int numLinks = countLinks(); + List result = new ArrayList<>(numLinks); + + if (torsoLink != null + && linkType.isAssignableFrom(torsoLink.getClass())) { + result.add((T) torsoLink); + } + for (BoneLink link : boneLinkList) { + if (linkType.isAssignableFrom(link.getClass())) { + result.add((T) link); + } + } + + return result; + } + + /** + * Enumerate all managed bones of the named link, in a pre-order, + * depth-first traversal of the skeleton, such that child bones never + * precede their ancestors. + * + * @param managerName the name of the managing link (not null) + * @return a new array of managed bones, including the manager if it is not + * the torso + */ + Joint[] listManagedBones(String managerName) { + List list = new ArrayList<>(8); + + if (torsoName.equals(managerName)) { + Joint[] roots = skeleton.getRoots(); + for (Joint rootBone : roots) { + list.add(rootBone); + addUnlinkedDescendants(rootBone, list); + } + + } else { + BoneLink manager = findBoneLink(managerName); + if (manager == null) { + String msg = "No link named " + managerName; + throw new IllegalArgumentException(msg); + } + Joint managerBone = manager.getBone(); + list.add(managerBone); + addUnlinkedDescendants(managerBone, list); + } + /* + * Convert the list to an array. + */ + int numManagedBones = list.size(); + Joint[] array = new Joint[numManagedBones]; + list.toArray(array); + + return array; + } + + /** + * Enumerate all rigid bodies managed by this control. + *

+ * Allowed only when the control IS added to a spatial. + * + * @return a new array of pre-existing rigid bodies (not null, not empty) + */ + public PhysicsRigidBody[] listRigidBodies() { + verifyAddedToSpatial("enumerate rigid bodies"); + + int numLinks = countLinks(); + PhysicsRigidBody[] result = new PhysicsRigidBody[numLinks]; + + int linkIndex = 0; + if (torsoLink != null) { + result[0] = torsoLink.getRigidBody(); + ++linkIndex; + } + for (BoneLink boneLink : boneLinkList) { + result[linkIndex] = boneLink.getRigidBody(); + ++linkIndex; + } + assert linkIndex == numLinks; + + return result; + } + + /** + * Copy the model's mesh-to-world transform. + * + * @param storeResult storage for the result (modified if not null) + * @return the model's mesh transform (in world coordinates, either + * storeResult or a new transform, not null) + */ + Transform meshTransform(Transform storeResult) { + Transform result = transformer.getWorldTransform().clone(); + return result; + } + + /** + * Calculate the physics transform to match the specified skeleton bone. + * + * @param bone the skeleton bone to match (not null, unaffected) + * @param localOffset the location of the body's center (in the bone's local + * coordinates, not null, unaffected) + * @param storeResult storage for the result (modified if not null) + * @return the calculated physics transform (either storeResult or a new + * transform, not null) + */ + Transform physicsTransform(Joint bone, Vector3f localOffset, + Transform storeResult) { + Transform result + = (storeResult == null) ? new Transform() : storeResult; + /* + * Start with the body's transform in the bone's local coordinates. + */ + result.setTranslation(localOffset); + result.setRotation(rotateIdentity); + result.setScale(1f); + /* + * Convert to mesh coordinates. + */ + Transform localToMesh = bone.getModelTransform(); + result.combineWithParent(localToMesh); + /* + * Convert to world (physics-space) coordinates. + */ + Transform meshToWorld = meshTransform(null); + result.combineWithParent(meshToWorld); + + return result; + } + + /** + * Rebuild the ragdoll. This is useful if you applied scale to the model + * after it was initialized. + *

+ * Allowed only when the control IS added to a spatial. + */ + public void rebuild() { + verifyAddedToSpatial("rebuild the ragdoll"); + + Map saveBones = new HashMap<>(boneLinks); + TorsoLink saveTorso = torsoLink; + + Spatial controlledSpatial = getSpatial(); + removeSpatialData(controlledSpatial); + createSpatialData(controlledSpatial); + + for (Map.Entry entry : boneLinks.entrySet()) { + String name = entry.getKey(); + BoneLink newLink = entry.getValue(); + BoneLink oldLink = saveBones.get(name); + newLink.postRebuild(oldLink); + } + if (torsoLink != null) { + torsoLink.postRebuild(saveTorso); + } + } + + /** + * Alter the mass of the specified link. + * + * @param link the link to modify (not null) + * @param mass the desired mass (>0) + */ + public void setMass(PhysicsLink link, float mass) { + if (link instanceof BoneLink) { + String boneName = link.boneName(); + setMass(boneName, mass); + } else { + assert link instanceof TorsoLink; + setMass(torsoName, mass); + } + } + + /** + * Verify that this control is ready for dynamic mode, which implies that it + * is added to a Spatial. + * + * @param desiredAction (not null, not empty) + */ + public void verifyReadyForDynamicMode(String desiredAction) { + assert desiredAction != null; + + verifyAddedToSpatial(desiredAction); + + if (!isReady) { + String message = "Cannot " + desiredAction + + " until the physics has been stepped."; + throw new IllegalStateException(message); + } + } + // ************************************************************************* + // new protected methods + + /** + * Access the list of bone links in a pre-order, depth-first traversal of + * the link hierarchy. + * + * @return the pre-existing list (not null) + */ + protected List getBoneLinks() { + assert boneLinkList != null; + return boneLinkList; + } + + /** + * Verify that this control is added to a Spatial. + * + * @param desiredAction (not null, not empty) + */ + protected void verifyAddedToSpatial(String desiredAction) { + assert desiredAction != null; + + Spatial controlledSpatial = getSpatial(); + if (controlledSpatial == null) { + String message = "Cannot " + desiredAction + + " unless the Control is added to a Spatial."; + throw new IllegalStateException(message); + } + } + // ************************************************************************* + // DacConfiguration methods + + /** + * Add all managed physics objects to the PhysicsSpace. + */ + @Override + protected void addPhysics(PhysicsSpace space) { + Vector3f gravity = gravity(null); + + PhysicsRigidBody rigidBody; + if (torsoLink != null) { + rigidBody = torsoLink.getRigidBody(); + space.add(rigidBody); + rigidBody.setGravity(gravity); + } + + for (BoneLink boneLink : boneLinkList) { + rigidBody = boneLink.getRigidBody(); + space.add(rigidBody); + rigidBody.setGravity(gravity); + + PhysicsJoint joint = boneLink.getJoint(); + space.add(joint); + } + } + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned control into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this control (not null, modified) + * @param original the control from which this control was shallow-cloned + * (not null, unaffected) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + super.cloneFields(cloner, original); + DacLinks originalDac = (DacLinks) original; + + boneLinkList = cloner.clone(boneLinkList); + + boneLinks = new HashMap<>(32); + for (Map.Entry entry + : originalDac.boneLinks.entrySet()) { + String boneName = entry.getKey(); + BoneLink link = entry.getValue(); + BoneLink copyLink = cloner.clone(link); + boneLinks.put(boneName, copyLink); + } + + skeleton = cloner.clone(skeleton); + transformer = cloner.clone(transformer); + torsoLink = cloner.clone(torsoLink); + } + + /** + * Create spatial-dependent data. Invoked each time the control is added to + * a spatial. Also invoked by {@link #rebuild()}. + * + * @param spatial the controlled spatial (not null) + */ + @Override + protected void createSpatialData(Spatial spatial) { + RagUtils.validate(spatial); + + SkinningControl skeletonControl + = spatial.getControl(SkinningControl.class); + if (skeletonControl == null) { + throw new IllegalArgumentException( + "The controlled spatial must have a SkinningControl. " + + "Make sure the control is there and not on a subnode."); + } + sortControls(skeletonControl); + skeletonControl.setHardwareSkinningPreferred(false); + /* + * Analyze the model's skeleton. + */ + skeleton = skeletonControl.getArmature(); + validateSkeleton(); + String[] tempManagerMap = managerMap(skeleton); + int numBones = skeleton.getJointCount(); + /* + * Temporarily set all bones' local translations and rotations to bind. + */ + Transform[] savedTransforms = new Transform[numBones]; + for (int boneIndex = 0; boneIndex < numBones; ++boneIndex) { + Joint bone = skeleton.getJoint(boneIndex); + savedTransforms[boneIndex] = bone.getLocalTransform().clone(); + bone.applyBindPose(); // TODO adjust the scale? + } + skeleton.update(); + /* + * Find the target meshes and choose the transform spatial. + */ + List targetList = RagUtils.listAnimatedMeshes(spatial, null); + Mesh[] targets = new Mesh[targetList.size()]; + targetList.toArray(targets); + transformer = RagUtils.findAnimatedGeometry(spatial); + if (transformer == null) { + transformer = spatial; + } + /* + * Enumerate mesh-vertex coordinates and assign them to managers. + */ + Map coordsMap + = RagUtils.coordsMap(targets, tempManagerMap); + /* + * Create the torso link. + */ + VectorSet vertexLocations = coordsMap.get(torsoName); + createTorsoLink(vertexLocations, targets); + /* + * Create bone links without joints. + */ + String[] linkedBoneNames = listLinkedBoneNames(); + for (String boneName : linkedBoneNames) { + vertexLocations = coordsMap.get(boneName); + createBoneLink(boneName, vertexLocations); + } + int numLinkedBones = countLinkedBones(); + assert boneLinks.size() == numLinkedBones; + /* + * Add joints to connect each BoneLink rigid body with its parent in the + * link hierarchy. Also initialize the boneLinkList. + */ + boneLinkList = new ArrayList<>(numLinkedBones); + addJoints(torsoLink); + assert boneLinkList.size() == numLinkedBones : boneLinkList.size(); + /* + * Restore the skeleton's pose. + */ + for (int boneIndex = 0; boneIndex < numBones; ++boneIndex) { + Joint bone = skeleton.getJoint(boneIndex); + bone.setLocalTransform(savedTransforms[boneIndex]); + } + skeleton.update(); + + if (added) { + addPhysics(space); + } + + logger3.log(Level.FINE, "Created ragdoll for skeleton."); + } + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new instance + */ + @Override + public DacLinks jmeClone() { + try { + DacLinks clone = (DacLinks) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * Read the mass of the named bone/torso. + * + * @param boneName the name of the bone/torso (not null) + * @return the mass (>0) or NaN if undetermined + */ + @Override + public float mass(String boneName) { + float mass; + if (getSpatial() == null) { + mass = super.mass(boneName); + } else if (torsoName.equals(boneName)) { + PhysicsRigidBody rigidBody = torsoLink.getRigidBody(); + mass = rigidBody.getMass(); + } else if (boneLinks.containsKey(boneName)) { + BoneLink link = boneLinks.get(boneName); + PhysicsRigidBody rigidBody = link.getRigidBody(); + mass = rigidBody.getMass(); + } else { + String msg = "No bone/torso named " + boneName; + throw new IllegalArgumentException(msg); + } + + return mass; + } + + /** + * De-serialize this control, for example when loading from a J3O file. + * + * @param im importer (not null) + * @throws IOException from importer + */ + @Override + @SuppressWarnings("unchecked") + public void read(JmeImporter im) throws IOException { + super.read(im); + InputCapsule ic = im.getCapsule(this); + + boneLinkList + = ic.readSavableArrayList("boneLinkList", null); + for (BoneLink link : boneLinkList) { + String name = link.boneName(); + boneLinks.put(name, link); + } + + skeleton = (Armature) ic.readSavable("skeleton", null); + transformer = (Spatial) ic.readSavable("transformer", null); + torsoLink = (TorsoLink) ic.readSavable("torsoLink", null); + } + + /** + * Remove all managed physics objects from the PhysicsSpace. + */ + @Override + protected void removePhysics(PhysicsSpace space) { + assert added; + + PhysicsRigidBody rigidBody; + if (torsoLink != null) { + rigidBody = torsoLink.getRigidBody(); + space.remove(rigidBody); + } + + for (BoneLink boneLink : boneLinks.values()) { + rigidBody = boneLink.getRigidBody(); + space.remove(rigidBody); + + PhysicsJoint joint = boneLink.getJoint(); + space.remove(joint); + } + } + + /** + * Remove spatial-dependent data. Invoked each time this control is rebuilt + * or removed from a spatial. + * + * @param spat the previously controlled spatial (unused) + */ + @Override + protected void removeSpatialData(Spatial spat) { + if (added) { + removePhysics(space); + } + + skeleton = null; + + boneLinks.clear(); + boneLinkList = null; + torsoLink = null; + transformer = null; + } + + /** + * Alter the viscous damping ratio for all rigid bodies, including new ones. + * + * @param dampingRatio the desired damping ratio (non-negative, 0→no + * damping, 1→critically damped, default=0.6) + */ + @Override + public void setDamping(float dampingRatio) { + super.setDamping(dampingRatio); + + if (getSpatial() != null) { + PhysicsRigidBody[] bodies = listRigidBodies(); + for (PhysicsRigidBody rigidBody : bodies) { + rigidBody.setDamping(dampingRatio, dampingRatio); + } + } + } + + /** + * Alter this control's gravitational acceleration for Ragdoll mode. + * + * @param gravity the desired acceleration vector (in physics-space + * coordinates, not null, unaffected, default=0,-9.8,0) + */ + @Override + public void setGravity(Vector3f gravity) { + super.setGravity(gravity); + + if (getSpatial() != null) { // TODO make sure it's in ragdoll mode + PhysicsRigidBody[] bodies = listRigidBodies(); + for (PhysicsRigidBody rigidBody : bodies) { + rigidBody.setGravity(gravity); + } + } + } + + /** + * Alter the range of motion of the joint connecting the named BoneLink to + * its parent in the link hierarchy. + * + * @param boneName the name of the BoneLink (not null, not empty) + * @param rom the desired range of motion (not null) + */ + @Override + public void setJointLimits(String boneName, RangeOfMotion rom) { + if (!hasBoneLink(boneName)) { + String msg = "No linked bone named " + boneName; + throw new IllegalArgumentException(msg); + } + + super.setJointLimits(boneName, rom); + + if (getSpatial() != null) { + BoneLink boneLink = findBoneLink(boneName); + SixDofJoint joint = (SixDofJoint) boneLink.getJoint(); + rom.setupJoint(joint); + } + } + + /** + * Alter the mass of the named bone/torso. + * + * @param boneName the name of the bone, or torsoName (not null) + * @param mass the desired mass (>0) + */ + @Override + public void setMass(String boneName, float mass) { + super.setMass(boneName, mass); + + if (getSpatial() != null) { + PhysicsRigidBody rigidBody; + if (torsoName.equals(boneName)) { + rigidBody = torsoLink.getRigidBody(); + } else { + BoneLink link = findBoneLink(boneName); + rigidBody = link.getRigidBody(); + } + rigidBody.setMass(mass); + } + } + + /** + * Translate the torso to the specified location. + * + * @param vec desired location (not null, unaffected) + */ + @Override + protected void setPhysicsLocation(Vector3f vec) { + torsoLink.getRigidBody().setPhysicsLocation(vec); + } + + /** + * Rotate the torso to the specified orientation. + * + * @param quat desired orientation (not null, unaffected) + */ + @Override + protected void setPhysicsRotation(Quaternion quat) { + torsoLink.getRigidBody().setPhysicsRotation(quat); + } + + /** + * Update this control. Invoked once per frame during the logical-state + * update, provided the control is added to a scene. Do not invoke directly + * from user code. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ + @Override + public void update(float tpf) { + verifyAddedToSpatial("update the control"); + if (!isEnabled()) { + return; + } + + if (torsoLink != null) { + torsoLink.update(tpf); + } + for (BoneLink boneLink : boneLinkList) { + boneLink.update(tpf); + } + } + + /** + * Serialize this control, for example when saving to a J3O file. + * + * @param ex exporter (not null) + * @throws IOException from exporter + */ + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + OutputCapsule oc = ex.getCapsule(this); + + int count = countLinkedBones(); + Savable[] savableArray = new Savable[count]; + boneLinkList.toArray(savableArray); + oc.write(savableArray, "boneLinkList", null); + + oc.write(skeleton, "skeleton", null); + oc.write(transformer, "transformer", null); + oc.write(torsoLink, "torsoLink", null); + } + // ************************************************************************* + // PhysicsTickListener methods + + /** + * Callback from Bullet, invoked just after the physics has been stepped. + * Used to re-activate any deactivated rigid bodies. + * + * @param space the space that was just stepped (not null) + * @param timeStep the time per physics step (in seconds, ≥0) + */ + @Override + public void physicsTick(PhysicsSpace space, float timeStep) { + assert space == getPhysicsSpace(); + + torsoLink.postTick(); + for (BoneLink boneLink : boneLinkList) { + boneLink.postTick(); + } + + isReady = true; + } + + /** + * Callback from Bullet, invoked just before the physics is stepped. A good + * time to clear/apply forces. + * + * @param space the space that is about to be stepped (not null) + * @param timeStep the time per physics step (in seconds, ≥0) + */ + @Override + public void prePhysicsTick(PhysicsSpace space, float timeStep) { + assert space == getPhysicsSpace(); + + torsoLink.preTick(timeStep); + for (BoneLink boneLink : boneLinkList) { + boneLink.preTick(timeStep); + } + } + // ************************************************************************* + // private methods + + /** + * Add joints to connect the named bone/torso link with each of its + * children. Also fill in the boneLinkList. Note: recursive! + * + * @param parentName the parent bone/torso link (not null) + */ + private void addJoints(PhysicsLink parentLink) { + List childNames = childNames(parentLink); + for (String childName : childNames) { + /* + * Add the joint and configure its range of motion. + * Also initialize the BoneLink's parent and its array + * of managed bones. + */ + BoneLink childLink = findBoneLink(childName); + childLink.addJoint(parentLink); + /* + * Add the BoneLink to the pre-order list. + */ + boneLinkList.add(childLink); + + addJoints(childLink); + } + } + + /** + * Enumerate all immediate child BoneLinks of the specified bone/torso link. + * + * @param link the bone/torso link (not null) + * @return a new list of bone names + */ + private List childNames(PhysicsLink link) { + assert link != null; + + String linkName; + if (link == torsoLink) { + linkName = torsoName; + } else { + linkName = link.boneName(); + } + + List result = new ArrayList<>(8); + for (String childName : listLinkedBoneNames()) { + Joint bone = findBone(childName); + Joint parent = bone.getParent(); + if (parent != null && findManager(parent).equals(linkName)) { + result.add(childName); + } + } + + return result; + } + + /** + * Create a jointless BoneLink for the named bone, and add it to the + * boneLinks map. + * + * @param boneName the name of the bone to be linked (not null) + * @param vertexLocations the set of vertex locations (not null, not empty) + */ + private void createBoneLink(String boneName, VectorSet vertexLocations) { + Joint bone = findBone(boneName); + Transform boneToMesh = bone.getModelTransform(); + Transform meshToBone = boneToMesh.invert(); + //logger3.log(Level.INFO, "meshToBone = {0}", meshToBone); + /* + * Create the CollisionShape and locate the center of mass. + */ + CollisionShape shape; + Vector3f center; + if (vertexLocations == null || vertexLocations.numVectors() == 0) { + throw new IllegalStateException("no vertex for " + boneName); + } else { + center = vertexLocations.mean(null); + center.subtractLocal(bone.getModelTransform().getTranslation()); + shape = createShape(meshToBone, center, vertexLocations); + } + + meshToBone.getTranslation().zero(); + float mass = super.mass(boneName); + Vector3f offset = meshToBone.transformVector(center, null); + BoneLink link = new BoneLink(this, bone, shape, mass, offset); + boneLinks.put(boneName, link); + } + + /** + * Create a CollisionShape for the specified transform, center, and vertex + * locations. + * + * @param vertexToShape the transform from vertex coordinates to de-scaled + * shape coordinates (not null, unaffected) + * @param center the location of the shape's center, in vertex coordinates + * (not null, unaffected) + * @param vertexLocations the set of vertex locations (not null, not empty, + * TRASHED) + * @return a new CollisionShape + */ + private CollisionShape createShape(Transform vertexToShape, Vector3f center, + VectorSet vertexLocations) { + int numVectors = vertexLocations.numVectors(); + assert numVectors > 0 : numVectors; + + Vector3f tempLocation = new Vector3f(); + int numPoints = vertexLocations.numVectors(); + float points[] = new float[3 * numPoints]; + FloatBuffer buffer = vertexLocations.toBuffer(); + buffer.rewind(); + int floatIndex = 0; + while (buffer.hasRemaining()) { + tempLocation.x = buffer.get(); + tempLocation.y = buffer.get(); + tempLocation.z = buffer.get(); + /* + * Translate so that vertex coordinates are relative to + * the shape's center. + */ + tempLocation.subtractLocal(center); + /* + * Transform vertex coordinates to de-scaled shape coordinates. + */ + vertexToShape.transformVector(tempLocation, tempLocation); + points[floatIndex] = tempLocation.x; + points[floatIndex + 1] = tempLocation.y; + points[floatIndex + 2] = tempLocation.z; + floatIndex += 3; + } + + CollisionShape result = new HullCollisionShape(points); + + return result; + } + + /** + * Create the TorsoLink. + * + * @param vertexLocations the set of vertex locations (not null, not empty) + * @param meshes array of animated meshes to use (not null, unaffected) + */ + private void createTorsoLink(VectorSet vertexLocations, Mesh[] meshes) { + if (vertexLocations == null || vertexLocations.numVectors() == 0) { + throw new IllegalArgumentException( + "No mesh vertices for the torso." + + " Make sure the root bone is not linked."); + } + /* + * Create the CollisionShape. + */ + Joint bone = RagUtils.findMainBone(skeleton, meshes); + assert bone.getParent() == null; + Transform boneToMesh = bone.getModelTransform(); + Transform meshToBone = boneToMesh.invert(); + Vector3f center = vertexLocations.mean(null); + center.subtractLocal(boneToMesh.getTranslation()); + CollisionShape shape = createShape(meshToBone, center, vertexLocations); + + meshToBone.getTranslation().zero(); + Vector3f offset = meshToBone.transformVector(center, null); + + Transform meshToModel; + Spatial cgm = getSpatial(); + if (cgm instanceof Node) { + Transform modelToMesh + = RagUtils.relativeTransform(transformer, (Node) cgm, null); + meshToModel = modelToMesh.invert(); + } else { + meshToModel = transformIdentity; + } + + float mass = super.mass(torsoName); + torsoLink = new TorsoLink(this, bone, shape, mass, meshToModel, offset); + } + + /** + * Sort the controls of the controlled spatial, such that this control will + * come BEFORE the specified SkinningControl. + * + * @param skinningControl (not null) + */ + private void sortControls(SkinningControl skinningControl) { + assert skinningControl != null; + + int dacIndex = RagUtils.findIndex(spatial, this); + assert dacIndex != -1; + int scIndex = RagUtils.findIndex(spatial, skinningControl); + assert scIndex != -1; + assert dacIndex != scIndex; + + if (dacIndex > scIndex) { + /* + * Remove the SkinningControl and re-add it to make sure it will get + * updated *after* this control. + */ + spatial.removeControl(skinningControl); + spatial.addControl(skinningControl); + + dacIndex = RagUtils.findIndex(spatial, this); + assert dacIndex != -1; + scIndex = RagUtils.findIndex(spatial, skinningControl); + assert scIndex != -1; + assert dacIndex < scIndex; + } + } + + /** + * Validate the model's skeleton. + */ + private void validateSkeleton() { + RagUtils.validate(skeleton); + + for (String boneName : listLinkedBoneNames()) { + Joint bone = findBone(boneName); + if (bone == null) { + String msg = String.format( + "Linked bone %s not found in skeleton.", boneName); + throw new IllegalArgumentException(msg); + } + if (bone.getParent() == null) { + logger3.log(Level.WARNING, "Linked bone {0} is a root bone.", + boneName); + } + } + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/DynamicAnimControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/DynamicAnimControl.java new file mode 100644 index 0000000000..7ae598f0be --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/DynamicAnimControl.java @@ -0,0 +1,530 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.bullet.PhysicsSpace; +import com.jme3.bullet.collision.PhysicsCollisionEvent; +import com.jme3.bullet.collision.PhysicsCollisionListener; +import com.jme3.bullet.collision.PhysicsCollisionObject; +import com.jme3.bullet.objects.PhysicsRigidBody; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; +import com.jme3.util.SafeArrayList; +import com.jme3.util.clone.Cloner; +import java.io.IOException; +import java.util.List; +import java.util.logging.Logger; + +/** + * Before adding this control to a spatial, configure it by invoking + * {@link #link(java.lang.String, float, com.jme3.bullet.animation.RangeOfMotion)} + * for each bone that should have its own rigid body. Leave unlinked bones near + * the root of the skeleton to form the torso of the ragdoll. + *

+ * When you add the control to a spatial, it generates a ragdoll consisting of a + * rigid body for the torso and another for each linked bone. It also creates a + * SixDofJoint connecting each rigid body to its parent in the link hierarchy. + * The mass of each rigid body and the range-of-motion of each joint can be + * reconfigured on the fly. + *

+ * Each link is either dynamic (driven by forces and torques) or kinematic + * (unperturbed by forces and torques). Transitions from dynamic to kinematic + * can be immediate or gradual. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on KinematicRagdollControl by Normen Hansen and Rémy Bouquet (Nehon). + */ +public class DynamicAnimControl + extends DacLinks + implements PhysicsCollisionListener { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final public static Logger logger35 + = Logger.getLogger(DynamicAnimControl.class.getName()); + // ************************************************************************* + // fields + + /** + * calculated total mass + */ + private float ragdollMass = 0f; + /** + * list of registered collision listeners + */ + private List collisionListeners + = new SafeArrayList<>(RagdollCollisionListener.class); + /* + * center-of-mass actual location (in physics-space coordinates) + */ + private Vector3f centerLocation = new Vector3f(); + /* + * center-of-mass estimated velocity (psu/second in physics-space coordinates) + */ + private Vector3f centerVelocity = new Vector3f(); + // ************************************************************************* + // constructors + + /** + * Instantiate an enabled control without any linked bones (torso only). + */ + public DynamicAnimControl() { + } + // ************************************************************************* + // new methods exposed + + /** + * Add a collision listener to this control. + * + * @param listener (not null, alias created) + */ + public void addCollisionListener(RagdollCollisionListener listener) { + collisionListeners.add(listener); + } + + /** + * Begin blending the specified link and all its descendants to kinematic + * animation. + * + * @param rootLink the root of the subtree to bind (not null) + * @param blendInterval the duration of the blend interval (in seconds, + * ≥0) + */ + public void animateSubtree(PhysicsLink rootLink, float blendInterval) { + verifyAddedToSpatial("change modes"); + blendSubtree(rootLink, KinematicSubmode.Animated, blendInterval); + } + + /** + * Begin blending all links to purely kinematic mode, driven by animation. + * TODO callback when the transition completes + *

+ * Allowed only when the control IS added to a spatial. + * + * @param blendInterval the duration of the blend interval (in seconds, + * ≥0) + * @param endModelTransform the desired local transform for the controlled + * spatial when the transition completes or null for no change to local + * transform (unaffected) + */ + public void blendToKinematicMode(float blendInterval, + Transform endModelTransform) { + verifyAddedToSpatial("change modes"); + + getTorsoLink().blendToKinematicMode(KinematicSubmode.Animated, blendInterval, + endModelTransform); + for (BoneLink boneLink : getBoneLinks()) { + boneLink.blendToKinematicMode(KinematicSubmode.Animated, + blendInterval); + } + } + + /** + * Calculate the ragdoll's total mass and center of mass. + *

+ * Allowed only when the control IS added to a spatial. + * + * @param storeLocation storage for the location of the center (in + * physics-space coordinates, modified if not null) + * @param storeVelocity storage for the velocity of the center (psu/second + * in physics-space coordinates, modified if not null) + * @return the total mass (>0) + */ + public float centerOfMass(Vector3f storeLocation, Vector3f storeVelocity) { + verifyReadyForDynamicMode("calculate the center of mass"); + + recalculateCenter(); + if (storeLocation != null) { + storeLocation.set(centerLocation); + } + if (storeVelocity != null) { + storeVelocity.set(centerVelocity); + } + + return ragdollMass; + } + + /** + * Alter the contact-response setting of the specified link and all its + * descendants. Note: recursive! + *

+ * Allowed only when the control IS added to a spatial. + * + * @param rootLink the root of the subtree to modify (not null) + * @param desiredResponse true for the usual rigid-body response, false for + * ghost-like response + */ + public void setContactResponseSubtree(PhysicsLink rootLink, + boolean desiredResponse) { + verifyAddedToSpatial("change modes"); + + PhysicsRigidBody rigidBody = rootLink.getRigidBody(); + rigidBody.setContactResponse(desiredResponse); + + PhysicsLink[] children = rootLink.listChildren(); + for (PhysicsLink child : children) { + setContactResponseSubtree(child, desiredResponse); + } + } + + /** + * Immediately put the specified link and all its ancestors (excluding the + * torso) into dynamic mode. Note: recursive! + *

+ * Allowed only when the control IS added to a spatial. + * + * @param startLink the start of the chain to modify (not null) + * @param chainLength the maximum number of links to modify (≥0) + * @param uniformAcceleration the uniform acceleration vector (in + * physics-space coordinates, not null, unaffected) + */ + public void setDynamicChain(PhysicsLink startLink, int chainLength, + Vector3f uniformAcceleration) { + if (chainLength == 0) { + return; + } + verifyAddedToSpatial("change modes"); + + if (startLink instanceof BoneLink) { + BoneLink boneLink = (BoneLink) startLink; + boneLink.setDynamic(uniformAcceleration); + } + + PhysicsLink parent = startLink.getParent(); + if (parent != null && chainLength > 1) { + setDynamicChain(parent, chainLength - 1, uniformAcceleration); + } + } + + /** + * Immediately put the specified link and all its descendants into dynamic + * mode. Note: recursive! + *

+ * Allowed only when the control IS added to a spatial. + * + * @param rootLink the root of the subtree to modify (not null) + * @param uniformAcceleration the uniform acceleration vector (in + * physics-space coordinates, not null, unaffected) + */ + public void setDynamicSubtree(PhysicsLink rootLink, + Vector3f uniformAcceleration) { + verifyAddedToSpatial("change modes"); + + if (rootLink == getTorsoLink()) { + getTorsoLink().setDynamic(uniformAcceleration); + } else if (rootLink instanceof BoneLink) { + BoneLink boneLink = (BoneLink) rootLink; + boneLink.setDynamic(uniformAcceleration); + } + + PhysicsLink[] children = rootLink.listChildren(); + for (PhysicsLink child : children) { + setDynamicSubtree(child, uniformAcceleration); + } + } + + /** + * Immediately put all links into purely kinematic mode. + *

+ * Allowed only when the control IS added to a spatial. + */ + public void setKinematicMode() { + verifyAddedToSpatial("set kinematic mode"); + + Transform localTransform = getSpatial().getLocalTransform(); + blendToKinematicMode(0f, localTransform); + } + + /** + * Immediately put this control into ragdoll mode. + *

+ * Allowed only when the control IS added to a spatial and all links are + * "ready". + */ + public void setRagdollMode() { + verifyReadyForDynamicMode("set ragdoll mode"); + + TorsoLink torsoLink = getTorsoLink(); + Vector3f acceleration = gravity(null); + torsoLink.setDynamic(acceleration); + for (BoneLink boneLink : getBoneLinks()) { + boneLink.setDynamic(acceleration); + } + } + // ************************************************************************* + // DacPhysicsLinks methods + + /** + * Add all managed physics objects to the PhysicsSpace. + */ + @Override + protected void addPhysics(PhysicsSpace space) { + super.addPhysics(space); + + space.addCollisionListener(this); + space.addTickListener(this); + } + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned control into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this control (not null, modified) + * @param original the control from which this control was shallow-cloned + * (not null, unaffected) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + super.cloneFields(cloner, original); + + collisionListeners = cloner.clone(collisionListeners); + centerLocation = cloner.clone(centerLocation); + centerVelocity = cloner.clone(centerVelocity); + } + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new instance + */ + @Override + public DynamicAnimControl jmeClone() { + try { + DynamicAnimControl clone = (DynamicAnimControl) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * De-serialize this control, for example when loading from a J3O file. + * + * @param im the importer (not null) + * @throws IOException from the importer + */ + @Override + @SuppressWarnings("unchecked") + public void read(JmeImporter im) throws IOException { + super.read(im); + InputCapsule ic = im.getCapsule(this); + + // isReady and collisionListeners not read + ragdollMass = ic.readFloat("ragdollMass", 1f); + centerLocation + = (Vector3f) ic.readSavable("centerLocation", new Vector3f()); + centerVelocity + = (Vector3f) ic.readSavable("centerVelocity", new Vector3f()); + } + + /** + * Remove all managed physics objects from the PhysicsSpace. + */ + @Override + protected void removePhysics(PhysicsSpace space) { + super.removePhysics(space); + + space.removeCollisionListener(this); + space.removeTickListener(this); + } + + /** + * Serialize this control, for example when saving to a J3O file. + * + * @param ex the exporter (not null) + * @throws IOException from the exporter + */ + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + OutputCapsule oc = ex.getCapsule(this); + + // isReady and collisionListeners not written + oc.write(ragdollMass, "ragdollMass", 1f); + oc.write(centerLocation, "centerLocation", null); + oc.write(centerVelocity, "centerVelocity", null); + } + // ************************************************************************* + // PhysicsCollisionListener methods + + /** + * For internal use only: callback for collision events. + * + * @param event (not null) + */ + @Override + public void collision(PhysicsCollisionEvent event) { + if (event.getNodeA() == null && event.getNodeB() == null) { + return; + } + /* + * Determine which bone was involved (if any) and also the + * other collision object involved. + */ + boolean isThisControlInvolved = false; + PhysicsLink physicsLink = null; + PhysicsCollisionObject otherPco = null; + PhysicsCollisionObject pcoA = event.getObjectA(); + PhysicsCollisionObject pcoB = event.getObjectB(); + + Object userA = pcoA.getUserObject(); + Object userB = pcoB.getUserObject(); + if (userA instanceof PhysicsLink) { + physicsLink = (PhysicsLink) userA; + DacLinks control = physicsLink.getControl(); + if (control == this) { + isThisControlInvolved = true; + } + otherPco = pcoB; + } + if (userB instanceof PhysicsLink) { + physicsLink = (PhysicsLink) userB; + DacLinks control = physicsLink.getControl(); + if (control == this) { + isThisControlInvolved = true; + } + otherPco = pcoA; + } + /* + * Discard collisions that don't involve this control. + */ + if (!isThisControlInvolved) { + return; + } + /* + * Discard low-impulse collisions. + */ + float impulseThreshold = eventDispatchImpulseThreshold(); + if (event.getAppliedImpulse() < impulseThreshold) { + return; + } + /* + * Dispatch an event. + */ + for (RagdollCollisionListener listener : collisionListeners) { + listener.collide(physicsLink, otherPco, event); + } + } + // ************************************************************************* + // private methods + + /** + * Begin blending the descendents of the specified link to the specified + * kinematic submode. Note: recursive! + * + * @param rootLink the root of the subtree to blend (not null) + * @param submode an enum value (not null) + * @param blendInterval the duration of the blend interval (in seconds, + * ≥0) + */ + private void blendDescendants(PhysicsLink rootLink, + KinematicSubmode submode, float blendInterval) { + assert rootLink != null; + assert submode != null; + assert blendInterval >= 0f : blendInterval; + + PhysicsLink[] children = rootLink.listChildren(); + for (PhysicsLink child : children) { + if (child instanceof BoneLink) { + BoneLink boneLink = (BoneLink) child; + boneLink.blendToKinematicMode(submode, blendInterval); + } + blendDescendants(child, submode, blendInterval); + } + } + + /** + * Begin blending the specified link and all its descendants to the + * specified kinematic submode. + * + * @param rootLink the root of the subtree to blend (not null) + * @param submode the desired submode (not null) + * @param blendInterval the duration of the blend interval (in seconds, + * ≥0) + */ + private void blendSubtree(PhysicsLink rootLink, KinematicSubmode submode, + float blendInterval) { + assert rootLink != null; + assert submode != null; + assert blendInterval >= 0f : blendInterval; + + blendDescendants(rootLink, submode, blendInterval); + + if (rootLink == getTorsoLink()) { + getTorsoLink().blendToKinematicMode(submode, blendInterval, null); + } else if (rootLink instanceof BoneLink) { + BoneLink boneLink = (BoneLink) rootLink; + boneLink.blendToKinematicMode(submode, blendInterval); + } + } + + /** + * Recalculate the total mass of the ragdoll. Also updates the location and + * estimated velocity of the center of mass. + */ + private void recalculateCenter() { + double massSum = 0.0; + Vector3f locationSum = new Vector3f(); + Vector3f velocitySum = new Vector3f(); + Vector3f tmpVector = new Vector3f(); + List links = listLinks(PhysicsLink.class); + for (PhysicsLink link : links) { + PhysicsRigidBody rigidBody = link.getRigidBody(); + float mass = rigidBody.getMass(); + massSum += mass; + + rigidBody.getPhysicsLocation(tmpVector); + tmpVector.multLocal(mass); + locationSum.addLocal(tmpVector); + + link.velocity(tmpVector); + tmpVector.multLocal(mass); + velocitySum.addLocal(tmpVector); + } + + float invMass = (float) (1.0 / massSum); + locationSum.mult(invMass, centerLocation); + velocitySum.mult(invMass, centerVelocity); + ragdollMass = (float) massSum; + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/KinematicSubmode.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/KinematicSubmode.java new file mode 100644 index 0000000000..95ffa186bf --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/KinematicSubmode.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +/** + * Enumerate submodes for a link in kinematic mode. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + */ +public enum KinematicSubmode { + /** + * driven by animation (if any) + */ + Animated, + /** + * frozen in the transform it had when blending started + */ + Frozen; +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/PhysicsLink.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/PhysicsLink.java new file mode 100644 index 0000000000..22ed5a4da5 --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/PhysicsLink.java @@ -0,0 +1,634 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.anim.Joint; +import com.jme3.bullet.collision.shapes.CollisionShape; +import com.jme3.bullet.joints.PhysicsJoint; +import com.jme3.bullet.objects.PhysicsRigidBody; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.export.Savable; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; +import com.jme3.util.clone.Cloner; +import com.jme3.util.clone.JmeCloneable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * The abstract base class used by DynamicAnimControl to link pieces of a JME + * model to their corresponding collision objects in a ragdoll. Subclasses + * include BoneLink and TorsoLink. The links in each DynamicAnimControl form a + * hierarchy with the TorsoLink at its root. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on KinematicRagdollControl by Normen Hansen and Rémy Bouquet (Nehon). + */ +abstract public class PhysicsLink + implements JmeCloneable, Savable { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final public static Logger logger + = Logger.getLogger(PhysicsLink.class.getName()); + // ************************************************************************* + // fields + + /** + * immediate children in the link hierarchy (not null) + */ + private ArrayList children = new ArrayList<>(8); + /** + * corresponding bone in the skeleton (not null) + */ + private Joint bone; + /** + * scene-graph control that manages this link (not null) + */ + private DacLinks control; + /** + * duration of the most recent blend interval (in seconds, ≥0) + */ + private float blendInterval = 1f; + /** + * weighting of kinematic movement (≥0, ≤1, 0=purely dynamic, 1=purely + * kinematic, default=1, progresses from 0 to 1 during the blend interval) + */ + private float kinematicWeight = 1f; + /** + * joint between the rigid body and the parent's rigid body, or null if not + * yet created + */ + private PhysicsJoint joint = null; + /** + * parent/manager in the link hierarchy, or null if none + */ + private PhysicsLink parent = null; + /** + * linked rigid body in the ragdoll (not null) + */ + private PhysicsRigidBody rigidBody; + /** + * transform of the rigid body as of the most recent update (in + * physics-space coordinates, updated in kinematic mode only) + */ + private Transform kpTransform = new Transform(); + /** + * estimate of the body's linear velocity as of the most recent update + * (psu/sec in physics-space coordinates, kinematic mode only) + */ + private Vector3f kpVelocity = new Vector3f(); + /** + * location of the rigid body's center (in the skeleton bone's local + * coordinates) + */ + private Vector3f localOffset; + // ************************************************************************* + // constructors + + /** + * No-argument constructor needed by SavableClassUtil. Do not invoke + * directly! + */ + public PhysicsLink() { + } + + /** + * Instantiate a purely kinematic link between the specified skeleton bone + * and the specified rigid body. + * + * @param control the control that will manage this link (not null, alias + * created) + * @param bone the corresponding bone (not null, alias created) + * @param collisionShape the desired shape (not null, alias created) + * @param mass the mass (in physics-mass units) + * @param localOffset the location of the body's center (in the bone's local + * coordinates, not null, unaffected) + */ + PhysicsLink(DacLinks control, Joint bone, CollisionShape collisionShape, + float mass, Vector3f localOffset) { + assert control != null; + assert bone != null; + assert collisionShape != null; + assert localOffset != null; + + this.control = control; + this.bone = bone; + rigidBody = createRigidBody(mass, collisionShape); + + logger.log(Level.FINE, "Creating link for bone {0} with mass={1}", + new Object[]{bone.getName(), rigidBody.getMass()}); + + this.localOffset = localOffset.clone(); + updateKPTransform(); + } + // ************************************************************************* + // new methods exposed + + /** + * Read the name of the corresponding bone. + * + * @return the bone name (not null) + */ + public String boneName() { + String boneName = bone.getName(); + + assert boneName != null; + return boneName; + } + + /** + * Count this link's immediate children in the link hierarchy. + * + * @return the count (≥0) + */ + public int countChildren() { + int numChildren = children.size(); + return numChildren; + } + + /** + * Access the corresponding bone. + * + * @return the pre-existing instance (not null) + */ + final public Joint getBone() { + assert bone != null; + return bone; + } + + /** + * Access the control that manages this link. + * + * @return the pre-existing instance (not null) + */ + public DacLinks getControl() { + assert control != null; + return control; + } + + /** + * Access the joint between this link's rigid body and that of its parent. + * + * @return the pre-existing instance, or null for the torso + */ + public PhysicsJoint getJoint() { + return joint; + } + + /** + * Access this link's parent/manager in the link hierarchy. + * + * @return the link, or null if none + */ + public PhysicsLink getParent() { + return parent; + } + + /** + * Access the linked rigid body. + * + * @return the pre-existing instance (not null) + */ + public PhysicsRigidBody getRigidBody() { + assert rigidBody != null; + return rigidBody; + } + + /** + * Test whether the link is in kinematic mode. + * + * @return true if kinematic, or false if purely dynamic + */ + public boolean isKinematic() { + if (kinematicWeight > 0f) { + return true; + } else { + return false; + } + } + + /** + * Read the kinematic weight of this link. + * + * @return 0 if purely dynamic, 1 if purely kinematic + */ + public float kinematicWeight() { + assert kinematicWeight >= 0f : kinematicWeight; + assert kinematicWeight <= 1f : kinematicWeight; + return kinematicWeight; + } + + /** + * Enumerate this link's immediate children in the link hierarchy. + * + * @return a new array (not null) + */ + public PhysicsLink[] listChildren() { + int numChildren = children.size(); + PhysicsLink[] result = new PhysicsLink[numChildren]; + children.toArray(result); + + return result; + } + + /** + * Unambiguously identify this link by name, within its DynamicAnimControl. + * + * @return a text string (not null, not empty) + */ + abstract public String name(); + + /** + * Calculate a physics transform for the rigid body (to match the skeleton + * bone). + * + * @param storeResult storage for the result (modified if not null) + * @return the calculated transform (in physics-space coordinates, either + * storeResult or a new transform, not null) + */ + public Transform physicsTransform(Transform storeResult) { + Transform result + = (storeResult == null) ? new Transform() : storeResult; + if (isKinematic()) { + result.set(kpTransform); + } else { + rigidBody.getPhysicsLocation(result.getTranslation()); + rigidBody.getPhysicsRotation(result.getRotation()); + result.setScale(rigidBody.getCollisionShape().getScale()); + } + + return result; + } + + /** + * Copy animation data from the specified link, which must correspond to the + * same bone. + * + * @param oldLink the link to copy from (not null, unaffected) + */ + void postRebuild(PhysicsLink oldLink) { + assert oldLink != null; + assert oldLink.bone == bone; + + if (oldLink.isKinematic()) { + blendInterval = oldLink.blendInterval; + kinematicWeight = oldLink.kinematicWeight; + } else { + blendInterval = 0f; + kinematicWeight = 1f; + } + } + + /** + * Internal callback, invoked just AFTER the physics is stepped. + */ + void postTick() { + if (!isKinematic()) { + rigidBody.activate(); + } + } + + /** + * Internal callback, invoked just BEFORE the physics is stepped. + * + * @param timeStep the physics time step (in seconds, ≥0) + */ + void preTick(float timeStep) { + if (isKinematic()) { + rigidBody.setPhysicsLocation(kpTransform.getTranslation()); + rigidBody.setPhysicsRotation(kpTransform.getRotation()); + rigidBody.getCollisionShape().setScale(kpTransform.getScale()); + } + } + + /** + * Immediately put this link into dynamic mode. The control must be "ready". + * + * @param uniformAcceleration the uniform acceleration vector to apply (in + * physics-space coordinates, not null, unaffected) + */ + public void setDynamic(Vector3f uniformAcceleration) { + control.verifyReadyForDynamicMode("put link into dynamic mode"); + + setKinematicWeight(0f); + rigidBody.setGravity(uniformAcceleration); + } + + /** + * Internal callback, invoked once per frame during the logical-state + * update, provided the control is added to a scene. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ + void update(float tpf) { + assert tpf >= 0f : tpf; + + if (kinematicWeight > 0f) { + kinematicUpdate(tpf); + } else { + dynamicUpdate(); + } + } + + /** + * Copy the body's linear velocity, or an estimate thereof. + * + * @param storeResult (modified if not null) + * @return a new velocity vector (psu/sec in physics-space coordinates) + */ + Vector3f velocity(Vector3f storeResult) { + Vector3f result = (storeResult == null) ? new Vector3f() : storeResult; + if (isKinematic()) { + result.set(kpVelocity); + } else { + assert !rigidBody.isKinematic(); + rigidBody.getLinearVelocity(result); + } + + return result; + } + // ************************************************************************* + // new protected methods + + /** + * Begin blending this link to a purely kinematic mode. + * + * @param blendInterval the duration of the blend interval (in seconds, + * ≥0) + */ + protected void blendToKinematicMode(float blendInterval) { + assert blendInterval >= 0f : blendInterval; + + this.blendInterval = blendInterval; + setKinematicWeight(Float.MIN_VALUE); // non-zero to trigger blending + } + + /** + * Update this link in Dynamic mode, setting the linked bone's transform + * based on the transform of the rigid body. + */ + abstract protected void dynamicUpdate(); + + /** + * Update this link in blended Kinematic mode. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ + protected void kinematicUpdate(float tpf) { + assert tpf >= 0f : tpf; + assert rigidBody.isKinematic(); + /* + * If blending, increase the kinematic weight. + */ + if (blendInterval == 0f) { + setKinematicWeight(1f); // done blending + } else { + setKinematicWeight(kinematicWeight + tpf / blendInterval); + } + /* + * If we didn't need kpVelocity, we could defer this + * calculation until the preTick(). + */ + Vector3f previousLocation = kpTransform.getTranslation(null); + updateKPTransform(); + if (tpf > 0f) { + kpTransform.getTranslation().subtract(previousLocation, kpVelocity); + kpVelocity.divideLocal(tpf); + } + } + + /** + * Copy the local offset of this link. + * + * @param storeResult storage for the result (modified if not null) + * @return the offset (in bone local coordinates, either storeResult or a + * new vector, not null) + */ + protected Vector3f localOffset(Vector3f storeResult) { + Vector3f result = (storeResult == null) ? new Vector3f() : storeResult; + result.set(localOffset); + return result; + } + + /** + * Assign a physics joint to this link, or cancel the assigned joint. + * + * @param joint (may be null, alias created) + */ + final protected void setJoint(PhysicsJoint joint) { + this.joint = joint; + } + + /** + * Assign a parent/manager for this link. + * + * @param parent (not null, alias created) + */ + final protected void setParent(PhysicsLink parent) { + assert parent != null; + assert this.parent == null; + this.parent = parent; + parent.children.add(this); + } + + /** + * Alter the rigid body for this link. + * + * @param body the desired rigid body (not null, alias created) + */ + protected void setRigidBody(PhysicsRigidBody body) { + assert body != null; + assert rigidBody != null; + rigidBody = body; + } + // ************************************************************************* + // JmeCloneable methods + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned link into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this link (not null) + * @param original the instance from which this link was shallow-cloned + * (unused) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + bone = cloner.clone(bone); + control = cloner.clone(control); + children = cloner.clone(children); + joint = cloner.clone(joint); + parent = cloner.clone(parent); + rigidBody = cloner.clone(rigidBody); + kpTransform = cloner.clone(kpTransform); + kpVelocity = cloner.clone(kpVelocity); + localOffset = cloner.clone(localOffset); + } + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new instance + */ + @Override + public PhysicsLink jmeClone() { + try { + PhysicsLink clone = (PhysicsLink) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + // ************************************************************************* + // Savable methods + + /** + * De-serialize this link, for example when loading from a J3O file. + * + * @param im importer (not null) + * @throws IOException from importer + */ + @Override + @SuppressWarnings("unchecked") + public void read(JmeImporter im) throws IOException { + InputCapsule ic = im.getCapsule(this); + + children = ic.readSavableArrayList("children", new ArrayList(1)); + bone = (Joint) ic.readSavable("bone", null); + control = (DacLinks) ic.readSavable("control", null); + blendInterval = ic.readFloat("blendInterval", 1f); + kinematicWeight = ic.readFloat("kinematicWeight", 1f); + joint = (PhysicsJoint) ic.readSavable("joint", null); + parent = (PhysicsLink) ic.readSavable("parent", null); + rigidBody = (PhysicsRigidBody) ic.readSavable("rigidBody", null); + kpTransform + = (Transform) ic.readSavable("kpTransform", new Transform()); + kpVelocity = (Vector3f) ic.readSavable("kpVelocity", new Vector3f()); + localOffset = (Vector3f) ic.readSavable("offset", new Vector3f()); + } + + /** + * Serialize this link, for example when saving to a J3O file. + * + * @param ex exporter (not null) + * @throws IOException from exporter + */ + @Override + public void write(JmeExporter ex) throws IOException { + OutputCapsule oc = ex.getCapsule(this); + + oc.writeSavableArrayList(children, "children", null); + oc.write(bone, "bone", null); + oc.write(control, "control", null); + oc.write(blendInterval, "blendInterval", 1f); + oc.write(kinematicWeight, "kinematicWeight", 1f); + oc.write(joint, "joint", null); + oc.write(parent, "parent", null); + oc.write(rigidBody, "rigidBody", null); + oc.write(kpTransform, "kpTransform", null); + oc.write(kpVelocity, "kpVelocity", null); + oc.write(localOffset, "offset", null); + } + // ************************************************************************* + // private methods + + /** + * Create and configure a rigid body for this link. + * + * @param linkConfig the link configuration (not null) + * @param collisionShape the desired shape (not null, alias created) + * @return a new instance, not in any PhysicsSpace + */ + private PhysicsRigidBody createRigidBody(float mass, + CollisionShape collisionShape) { + assert collisionShape != null; + + PhysicsRigidBody body = new PhysicsRigidBody(collisionShape, mass); + + float viscousDamping = control.damping(); + body.setDamping(viscousDamping, viscousDamping); + + body.setKinematic(true); + body.setUserObject(this); + + return body; + } + + /** + * Alter the kinematic weight and copy the physics transform and velocity + * info as needed. + * + * @param weight (≥0) + */ + private void setKinematicWeight(float weight) { + assert weight >= 0f : weight; + + boolean wasKinematic = (kinematicWeight > 0f); + kinematicWeight = (weight > 1f) ? 1f : weight; + boolean isKinematic = (kinematicWeight > 0f); + + if (wasKinematic && !isKinematic) { + rigidBody.setKinematic(false); + rigidBody.setPhysicsLocation(kpTransform.getTranslation()); + rigidBody.setPhysicsRotation(kpTransform.getRotation()); + rigidBody.getCollisionShape().setScale(kpTransform.getScale()); + rigidBody.setLinearVelocity(kpVelocity); + } else if (isKinematic && !wasKinematic) { + rigidBody.getPhysicsLocation(kpTransform.getTranslation()); + rigidBody.getPhysicsRotation(kpTransform.getRotation()); + Vector3f scale = rigidBody.getCollisionShape().getScale(); + kpTransform.setScale(scale); + rigidBody.getLinearVelocity(kpVelocity); + rigidBody.setKinematic(true); + } + } + + /** + * Update the kinematic physics transform. + */ + private void updateKPTransform() { + control.physicsTransform(bone, localOffset, kpTransform); + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/RagUtils.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/RagUtils.java new file mode 100644 index 0000000000..89b112283f --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/RagUtils.java @@ -0,0 +1,707 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.anim.Armature; +import com.jme3.anim.Joint; +import com.jme3.export.InputCapsule; +import com.jme3.export.Savable; +import com.jme3.math.FastMath; +import com.jme3.math.Quaternion; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.Mesh; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.VertexBuffer; +import com.jme3.scene.control.Control; +import java.io.IOException; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.ShortBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.logging.Logger; + +/** + * Utility methods used by DynamicAnimControl and associated classes. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on KinematicRagdollControl by Normen Hansen and Rémy Bouquet (Nehon). + */ +public class RagUtils { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final private static Logger logger + = Logger.getLogger(RagUtils.class.getName()); + // ************************************************************************* + // constructors + + /** + * A private constructor to inhibit instantiation of this class. + */ + private RagUtils() { + } + // ************************************************************************* + // new methods exposed + + /** + * Assign each mesh vertex to a bone/torso link and add its location (mesh + * coordinates in bind pose) to that link's list. + * + * @param meshes array of animated meshes to use (not null, unaffected) + * @param managerMap a map from bone indices to managing link names (not + * null, unaffected) + * @return a new map from bone/torso names to sets of vertex coordinates + */ + static Map coordsMap(Mesh[] meshes, + String[] managerMap) { + float[] wArray = new float[4]; + int[] iArray = new int[4]; + Vector3f bindPosition = new Vector3f(); + Map coordsMap = new HashMap<>(32); + for (Mesh mesh : meshes) { + int numVertices = mesh.getVertexCount(); + for (int vertexI = 0; vertexI < numVertices; ++vertexI) { + String managerName = findManager(mesh, vertexI, iArray, wArray, + managerMap); + VectorSet set = coordsMap.get(managerName); + if (set == null) { + set = new VectorSet(1); + coordsMap.put(managerName, set); + } + vertexVector3f(mesh, VertexBuffer.Type.BindPosePosition, + vertexI, bindPosition); + set.add(bindPosition); + } + } + + return coordsMap; + } + + /** + * Find an animated geometry in the specified subtree of the scene graph. + * Note: recursive! + * + * @param subtree where to search (not null, unaffected) + * @return a pre-existing instance, or null if none + */ + static Geometry findAnimatedGeometry(Spatial subtree) { + Geometry result = null; + if (subtree instanceof Geometry) { + Geometry geometry = (Geometry) subtree; + Mesh mesh = geometry.getMesh(); + VertexBuffer indices = mesh.getBuffer(VertexBuffer.Type.BoneIndex); + boolean hasIndices = indices != null; + VertexBuffer weights = mesh.getBuffer(VertexBuffer.Type.BoneWeight); + boolean hasWeights = weights != null; + if (hasIndices && hasWeights) { + result = geometry; + } + + } else if (subtree instanceof Node) { + Node node = (Node) subtree; + List children = node.getChildren(); + for (Spatial child : children) { + result = findAnimatedGeometry(child); + if (result != null) { + break; + } + } + } + + return result; + } + + /** + * Find the index of the specified scene-graph control in the specified + * spatial. + * + * @param spatial the spatial to search (not null, unaffected) + * @param sgc the control to search for (not null, unaffected) + * @return the index (≥0) or -1 if not found + */ + static int findIndex(Spatial spatial, Control sgc) { + int numControls = spatial.getNumControls(); + int result = -1; + for (int controlIndex = 0; controlIndex < numControls; ++controlIndex) { + Control control = spatial.getControl(controlIndex); + if (control == sgc) { + result = controlIndex; + break; + } + } + + return result; + } + + /** + * Find the main root bone of a skeleton, based on its total bone weight. + * + * @param skeleton the skeleton (not null, unaffected) + * @param targetMeshes an array of animated meshes to provide bone weights + * (not null) + * @return a root bone, or null if none found + */ + static Joint findMainBone(Armature skeleton, Mesh[] targetMeshes) { + Joint[] rootBones = skeleton.getRoots(); + + Joint result; + if (rootBones.length == 1) { + result = rootBones[0]; + } else { + result = null; + float[] totalWeights = totalWeights(targetMeshes, skeleton); + float greatestTotalWeight = Float.NEGATIVE_INFINITY; + for (Joint rootBone : rootBones) { + int boneIndex = skeleton.getJointIndex(rootBone); + float weight = totalWeights[boneIndex]; + if (weight > greatestTotalWeight) { + result = rootBone; + greatestTotalWeight = weight; + } + } + } + + return result; + } + + /** + * Enumerate all animated meshes in the specified subtree of a scene graph. + * Note: recursive! + * + * @param subtree which subtree (aliases created) + * @param storeResult (added to if not null) + * @return an expanded list (either storeResult or a new instance) + */ + static List listAnimatedMeshes(Spatial subtree, + List storeResult) { + if (storeResult == null) { + storeResult = new ArrayList<>(10); + } + + if (subtree instanceof Geometry) { + Geometry geometry = (Geometry) subtree; + Mesh mesh = geometry.getMesh(); + VertexBuffer indices = mesh.getBuffer(VertexBuffer.Type.BoneIndex); + boolean hasIndices = indices != null; + VertexBuffer weights = mesh.getBuffer(VertexBuffer.Type.BoneWeight); + boolean hasWeights = weights != null; + if (hasIndices && hasWeights && !storeResult.contains(mesh)) { + storeResult.add(mesh); + } + + } else if (subtree instanceof Node) { + Node node = (Node) subtree; + List children = node.getChildren(); + for (Spatial child : children) { + listAnimatedMeshes(child, storeResult); + } + } + + return storeResult; + } + + /** + * Convert a transform from the mesh coordinate system to the local + * coordinate system of the specified bone. + * + * @param parentBone (not null) + * @param transform the transform to convert (not null, modified) + */ + static void meshToLocal(Joint parentBone, Transform transform) { + Vector3f location = transform.getTranslation(); + Quaternion orientation = transform.getRotation(); + Vector3f scale = transform.getScale(); + + Transform pmx = parentBone.getModelTransform(); + Vector3f pmTranslate = pmx.getTranslation(); + Quaternion pmRotInv = pmx.getRotation().inverse(); + Vector3f pmScale = pmx.getScale(); + + location.subtractLocal(pmTranslate); + location.divideLocal(pmScale); + pmRotInv.mult(location, location); + scale.divideLocal(pmScale); + pmRotInv.mult(orientation, orientation); + } + + /** + * Read an array of transforms from an input capsule. + * + * @param capsule the input capsule (not null) + * @param fieldName the name of the field to read (not null) + * @return a new array or null + * @throws IOException from capsule + */ + static Transform[] readTransformArray(InputCapsule capsule, + String fieldName) throws IOException { + Savable[] tmp = capsule.readSavableArray(fieldName, null); + Transform[] result; + if (tmp == null) { + result = null; + } else { + result = new Transform[tmp.length]; + for (int i = 0; i < tmp.length; ++i) { + result[i] = (Transform) tmp[i]; + } + } + + return result; + } + + /** + * Calculate a coordinate transform for the specified spatial relative to a + * specified ancestor node. The result incorporates the transform of the + * starting spatial, but not that of the ancestor. + * + * @param startSpatial the starting spatial (not null, unaffected) + * @param ancestorNode the ancestor node (not null, unaffected) + * @param storeResult storage for the result (modified if not null) + * @return a coordinate transform (either storeResult or a new vector, not + * null) + */ + static Transform relativeTransform(Spatial startSpatial, + Node ancestorNode, Transform storeResult) { + assert startSpatial.hasAncestor(ancestorNode); + Transform result + = (storeResult == null) ? new Transform() : storeResult; + + result.loadIdentity(); + Spatial loopSpatial = startSpatial; + while (loopSpatial != ancestorNode) { + Transform localTransform = loopSpatial.getLocalTransform(); + result.combineWithParent(localTransform); + loopSpatial = loopSpatial.getParent(); + } + + return result; + } + + /** + * Validate a skeleton for use with DynamicAnimControl. + * + * @param skeleton the skeleton to validate (not null, unaffected) + */ + static void validate(Armature skeleton) { + int numBones = skeleton.getJointCount(); + if (numBones < 0) { + throw new IllegalArgumentException("Bone count is negative!"); + } + + Set nameSet = new TreeSet<>(); + for (int boneIndex = 0; boneIndex < numBones; ++boneIndex) { + Joint bone = skeleton.getJoint(boneIndex); + if (bone == null) { + String msg = String.format("Bone %d in skeleton is null!", + boneIndex); + throw new IllegalArgumentException(msg); + } + String boneName = bone.getName(); + if (boneName == null) { + String msg = String.format("Bone %d in skeleton has null name!", + boneIndex); + throw new IllegalArgumentException(msg); + } else if (boneName.equals(DynamicAnimControl.torsoName)) { + String msg = String.format( + "Bone %d in skeleton has a reserved name!", + boneIndex); + throw new IllegalArgumentException(msg); + } else if (nameSet.contains(boneName)) { + String msg = "Duplicate bone name in skeleton: " + boneName; + throw new IllegalArgumentException(msg); + } + nameSet.add(boneName); + } + } + + /** + * Validate a model for use with DynamicAnimControl. + * + * @param model the model to validate (not null, unaffected) + */ + static void validate(Spatial model) { + List geometries = listGeometries(model, null); + if (geometries.isEmpty()) { + throw new IllegalArgumentException("No meshes in the model."); + } + for (Geometry geometry : geometries) { + if (geometry.isIgnoreTransform()) { + throw new IllegalArgumentException( + "A model geometry ignores transforms."); + } + } + } + // ************************************************************************* + // private methods + + private static void addPreOrderJoints(Joint bone, List addResult) { + assert bone != null; + addResult.add(bone); + List children = bone.getChildren(); + for (Joint child : children) { + addPreOrderJoints(child, addResult); + } + } + + /** + * Add the vertex weights of each bone in the specified mesh to an array of + * total weights. + * + * @param mesh animated mesh to analyze (not null, unaffected) + * @param totalWeights (not null, modified) + */ + private static void addWeights(Mesh mesh, float[] totalWeights) { + assert totalWeights != null; + + int maxWeightsPerVert = mesh.getMaxNumWeights(); + if (maxWeightsPerVert <= 0) { + maxWeightsPerVert = 1; + } + assert maxWeightsPerVert > 0 : maxWeightsPerVert; + assert maxWeightsPerVert <= 4 : maxWeightsPerVert; + + VertexBuffer biBuf = mesh.getBuffer(VertexBuffer.Type.BoneIndex); + Buffer boneIndexBuffer = biBuf.getDataReadOnly(); + boneIndexBuffer.rewind(); + int numBoneIndices = boneIndexBuffer.remaining(); + assert numBoneIndices % 4 == 0 : numBoneIndices; + int numVertices = boneIndexBuffer.remaining() / 4; + + VertexBuffer wBuf = mesh.getBuffer(VertexBuffer.Type.BoneWeight); + FloatBuffer weightBuffer = (FloatBuffer) wBuf.getDataReadOnly(); + weightBuffer.rewind(); + int numWeights = weightBuffer.remaining(); + assert numWeights == numVertices * 4 : numWeights; + + for (int vIndex = 0; vIndex < numVertices; ++vIndex) { + for (int wIndex = 0; wIndex < 4; ++wIndex) { + float weight = weightBuffer.get(); + int boneIndex = readIndex(boneIndexBuffer); + if (wIndex < maxWeightsPerVert) { + totalWeights[boneIndex] += FastMath.abs(weight); + } + } + } + } + + /** + * Determine which physics link should manage the specified mesh vertex. + * + * @param mesh the mesh containing the vertex (not null, unaffected) + * @param vertexIndex the vertex index in the mesh (≥0) + * @param iArray temporary storage for bone indices (not null, modified) + * @param wArray temporary storage for bone weights (not null, modified) + * @param managerMap a map from bone indices to bone/torso names (not null, + * unaffected) + * @return a bone/torso name + */ + private static String findManager(Mesh mesh, int vertexIndex, int[] iArray, + float[] wArray, String[] managerMap) { + vertexBoneIndices(mesh, vertexIndex, iArray); + vertexBoneWeights(mesh, vertexIndex, wArray); + Map weightMap = weightMap(iArray, wArray, managerMap); + + float bestTotalWeight = Float.NEGATIVE_INFINITY; + String bestName = null; + for (Map.Entry entry : weightMap.entrySet()) { + float totalWeight = entry.getValue(); + if (totalWeight >= bestTotalWeight) { + bestTotalWeight = totalWeight; + bestName = entry.getKey(); + } + } + + return bestName; + } + + /** + * Enumerate all geometries in the specified subtree of a scene graph. Note: + * recursive! + * + * @param subtree (not null, aliases created) + * @param addResult (added to if not null) + * @return an expanded list (either storeResult or a new instance) + */ + private static List listGeometries(Spatial subtree, + List addResult) { + List result = (addResult == null) ? new ArrayList(50) : addResult; + + if (subtree instanceof Geometry) { + Geometry geometry = (Geometry) subtree; + if (!result.contains(geometry)) { + result.add(geometry); + } + } + + if (subtree instanceof Node) { + Node node = (Node) subtree; + List children = node.getChildren(); + for (Spatial child : children) { + listGeometries(child, result); + } + } + + return result; + } + + /** + * Enumerate all bones in a pre-order, depth-first traversal of the + * skeleton, such that child bones never precede their ancestors. + * + * @param skeleton the skeleton to traverse (not null, unaffected) + * @return a new list of bones + */ + private static List preOrderJoints(Armature skeleton) { + int numBones = skeleton.getJointCount(); + List result = new ArrayList<>(numBones); + Joint[] rootBones = skeleton.getRoots(); + for (Joint rootBone : rootBones) { + addPreOrderJoints(rootBone, result); + } + + assert result.size() == numBones : result.size(); + return result; + } + + /** + * Read an index from a buffer. + * + * @param buffer a buffer of bytes or shorts (not null) + * @return index (≥0) + */ + private static int readIndex(Buffer buffer) { + int result; + if (buffer instanceof ByteBuffer) { + ByteBuffer byteBuffer = (ByteBuffer) buffer; + byte b = byteBuffer.get(); + result = 0xff & b; + } else if (buffer instanceof ShortBuffer) { + ShortBuffer shortBuffer = (ShortBuffer) buffer; + short s = shortBuffer.get(); + result = 0xffff & s; + } else { + throw new IllegalArgumentException(); + } + + assert result >= 0 : result; + return result; + } + + /** + * Calculate the total bone weight animated by each bone in the specified + * meshes. + * + * @param meshes the animated meshes to analyze (not null, unaffected) + * @param skeleton (not null, unaffected) + * @return a map from bone indices to total bone weight + */ + private static float[] totalWeights(Mesh[] meshes, Armature skeleton) { + int numBones = skeleton.getJointCount(); + float[] result = new float[numBones]; + for (Mesh mesh : meshes) { + RagUtils.addWeights(mesh, result); + } + + List bones = preOrderJoints(skeleton); + Collections.reverse(bones); + for (Joint childBone : bones) { + int childIndex = skeleton.getJointIndex(childBone); + Joint parent = childBone.getParent(); + if (parent != null) { + int parentIndex = skeleton.getJointIndex(parent); + result[parentIndex] += result[childIndex]; + } + } + + return result; + } + + /** + * Copy the bone indices for the indexed vertex. + * + * @param mesh subject mesh (not null) + * @param vertexIndex index into the mesh's vertices (≥0) + * @param storeResult (modified if not null) + * @return the data vector (either storeResult or a new instance) + */ + private static int[] vertexBoneIndices(Mesh mesh, + int vertexIndex, int[] storeResult) { + if (storeResult == null) { + storeResult = new int[4]; + } else { + assert storeResult.length >= 4 : storeResult.length; + } + + int maxWeightsPerVert = mesh.getMaxNumWeights(); + if (maxWeightsPerVert <= 0) { + maxWeightsPerVert = 1; + } + + VertexBuffer biBuf = mesh.getBuffer(VertexBuffer.Type.BoneIndex); + Buffer boneIndexBuffer = biBuf.getDataReadOnly(); + boneIndexBuffer.position(4 * vertexIndex); + for (int wIndex = 0; wIndex < maxWeightsPerVert; ++wIndex) { + int boneIndex = readIndex(boneIndexBuffer); + storeResult[wIndex] = boneIndex; + } + /* + * Fill with -1s. + */ + int length = storeResult.length; + for (int wIndex = maxWeightsPerVert; wIndex < length; ++wIndex) { + storeResult[wIndex] = -1; + } + + return storeResult; + } + + /** + * Copy the bone weights for the indexed vertex. + * + * @param mesh subject mesh (not null) + * @param vertexIndex index into the mesh's vertices (≥0) + * @param storeResult (modified if not null) + * @return the data vector (either storeResult or a new instance) + */ + private static float[] vertexBoneWeights(Mesh mesh, + int vertexIndex, float[] storeResult) { + if (storeResult == null) { + storeResult = new float[4]; + } else { + assert storeResult.length >= 4 : storeResult.length; + } + + int maxWeightsPerVert = mesh.getMaxNumWeights(); + if (maxWeightsPerVert <= 0) { + maxWeightsPerVert = 1; + } + + VertexBuffer wBuf = mesh.getBuffer(VertexBuffer.Type.BoneWeight); + FloatBuffer weightBuffer = (FloatBuffer) wBuf.getDataReadOnly(); + weightBuffer.position(4 * vertexIndex); + for (int wIndex = 0; wIndex < maxWeightsPerVert; ++wIndex) { + storeResult[wIndex] = weightBuffer.get(); + } + /* + * Fill with 0s. + */ + int length = storeResult.length; + for (int wIndex = maxWeightsPerVert; wIndex < length; ++wIndex) { + storeResult[wIndex] = 0f; + } + + return storeResult; + } + + /** + * Copy Vector3f data for the indexed vertex from the specified vertex + * buffer. + *

+ * A software skin update is required BEFORE reading vertex + * positions/normals/tangents from an animated mesh + * + * @param mesh subject mesh (not null) + * @param bufferType which buffer to read (5 legal values) + * @param vertexIndex index into the mesh's vertices (≥0) + * @param storeResult (modified if not null) + * @return the data vector (either storeResult or a new instance) + */ + private static Vector3f vertexVector3f(Mesh mesh, + VertexBuffer.Type bufferType, int vertexIndex, + Vector3f storeResult) { + assert bufferType == VertexBuffer.Type.BindPoseNormal + || bufferType == VertexBuffer.Type.BindPosePosition + || bufferType == VertexBuffer.Type.Binormal + || bufferType == VertexBuffer.Type.Normal + || bufferType == VertexBuffer.Type.Position : bufferType; + if (storeResult == null) { + storeResult = new Vector3f(); + } + + VertexBuffer vertexBuffer = mesh.getBuffer(bufferType); + FloatBuffer floatBuffer = (FloatBuffer) vertexBuffer.getDataReadOnly(); + floatBuffer.position(3 * vertexIndex); + storeResult.x = floatBuffer.get(); + storeResult.y = floatBuffer.get(); + storeResult.z = floatBuffer.get(); + + return storeResult; + } + + /** + * Tabulate the total bone weight associated with each bone/torso link in a + * ragdoll. + * + * @param biArray the array of bone indices (not null, unaffected) + * @param bwArray the array of bone weights (not null, unaffected) + * @param managerMap a map from bone indices to managing link names (not + * null, unaffected) + * @return a new map from link names to total weight + */ + private static Map weightMap(int[] biArray, + float[] bwArray, String[] managerMap) { + assert biArray.length == 4; + assert bwArray.length == 4; + + Map weightMap = new HashMap<>(4); + for (int j = 0; j < 4; ++j) { + int boneIndex = biArray[j]; + if (boneIndex != -1) { + String managerName = managerMap[boneIndex]; + if (weightMap.containsKey(managerName)) { + float oldWeight = weightMap.get(managerName); + float newWeight = oldWeight + bwArray[j]; + weightMap.put(managerName, newWeight); + } else { + weightMap.put(managerName, bwArray[j]); + } + } + } + + return weightMap; + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/RagdollCollisionListener.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/RagdollCollisionListener.java new file mode 100644 index 0000000000..3e0eccdb48 --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/RagdollCollisionListener.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.bullet.collision.PhysicsCollisionEvent; +import com.jme3.bullet.collision.PhysicsCollisionObject; + +/** + * Interface to receive notifications whenever a linked rigid body in a + * DynamicAnimControl collides with another physics object. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Nehon + */ +public interface RagdollCollisionListener { + + /** + * Invoked when a collision involving a linked rigid body occurs. + * + * @param physicsLink the physics link that collided (not null) + * @param object the collision object that collided with the bone (not null) + * @param event other event details (not null) + */ + void collide(PhysicsLink physicsLink, PhysicsCollisionObject object, + PhysicsCollisionEvent event); +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/RangeOfMotion.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/RangeOfMotion.java new file mode 100644 index 0000000000..b79d8519c7 --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/RangeOfMotion.java @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.bullet.PhysicsSpace; +import com.jme3.bullet.joints.SixDofJoint; +import com.jme3.bullet.joints.motors.RotationalLimitMotor; +import com.jme3.bullet.joints.motors.TranslationalLimitMotor; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.export.Savable; +import com.jme3.math.Vector3f; +import java.io.IOException; +import java.util.logging.Logger; + +/** + * Range of motion for a ragdoll joint. Immutable except for + * {@link #read(com.jme3.export.JmeImporter)}. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on RagdollPreset by Rémy Bouquet (Nehon). + */ +public class RangeOfMotion implements Savable { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final public static Logger logger + = Logger.getLogger(RangeOfMotion.class.getName()); + /** + * local copy of {@link com.jme3.math.Vector3f#ZERO} + */ + final private static Vector3f translateIdentity = new Vector3f(0f, 0f, 0f); + // ************************************************************************* + // fields + + /** + * maximum rotation angle around the X axis (in radians) + */ + private float maxX = 0f; + /** + * minimum rotation angle around the X axis (in radians) + */ + private float minX = 0f; + /** + * maximum rotation angle around the Y axis (in radians) + */ + private float maxY = 0f; + /** + * minimum rotation angle around the Y axis (in radians) + */ + private float minY = 0f; + /** + * maximum rotation angle around the Z axis (in radians) + */ + private float maxZ = 0f; + /** + * minimum rotation angle around the Z axis (in radians) + */ + private float minZ = 0f; + // ************************************************************************* + // constructors + + /** + * Instantiate a preset with no motion allowed. + */ + public RangeOfMotion() { + } + + /** + * Instantiate a preset with the specified range of motion. + * + * @param maxX the maximum rotation around the X axis (in radians) + * @param minX the minimum rotation around the X axis (in radians) + * @param maxY the maximum rotation around the Y axis (in radians) + * @param minY the minimum rotation around the Y axis (in radians) + * @param maxZ the maximum rotation around the Z axis (in radians) + * @param minZ the minimum rotation around the Z axis (in radians) + */ + public RangeOfMotion(float maxX, float minX, float maxY, float minY, + float maxZ, float minZ) { + this.maxX = maxX; + this.minX = minX; + this.maxY = maxY; + this.minY = minY; + this.maxZ = maxZ; + this.minZ = minZ; + } + + /** + * Instantiate a preset with the specified symmetric range of motion. + * + * @param maxX the maximum rotation around the X axis (in radians, ≥0) + * @param maxY the maximum rotation around the Y axis (in radians, ≥0) + * @param maxZ the maximum rotation around the Z axis (in radians, ≥0) + */ + public RangeOfMotion(float maxX, float maxY, float maxZ) { + this.maxX = maxX; + this.minX = -maxX; + this.maxY = maxY; + this.minY = -maxY; + this.maxZ = maxZ; + this.minZ = -maxZ; + } + + /** + * Instantiate a preset with the specified symmetric range of motion. + * + * @param maxAngle the maximum rotation around each axis (in radians, ≥0) + */ + public RangeOfMotion(float maxAngle) { + maxX = maxAngle; + minX = -maxAngle; + maxY = maxAngle; + minY = -maxAngle; + maxZ = maxAngle; + minZ = -maxAngle; + } + + /** + * Instantiate a preset for rotation on a single axis. + * + * @param axisIndex which axis: 0→X, 1→Y, 2→Z + */ + public RangeOfMotion(int axisIndex) { + switch (axisIndex) { + case PhysicsSpace.AXIS_X: + maxX = 1f; + minX = -1f; + break; + case PhysicsSpace.AXIS_Y: + maxY = 1f; + minY = -1f; + break; + case PhysicsSpace.AXIS_Z: + maxZ = 1f; + minZ = -1f; + break; + default: + String msg = String.format("axisIndex=%d", axisIndex); + throw new IllegalArgumentException(msg); + } + } + // ************************************************************************* + // new methods exposed + + /** + * Read the maximum rotation around the indexed axis. + * + * @param axisIndex which axis: 0→X, 1→Y, 2→Z + * + * @return the rotation angle (in radians) + */ + public float getMaxRotation(int axisIndex) { + float result; + switch (axisIndex) { + case PhysicsSpace.AXIS_X: + result = maxX; + break; + case PhysicsSpace.AXIS_Y: + result = maxY; + break; + case PhysicsSpace.AXIS_Z: + result = maxZ; + break; + default: + String msg = String.format("axisIndex=%d", axisIndex); + throw new IllegalArgumentException(msg); + } + + return result; + } + + /** + * Read the minimum rotation around the indexed axis. + * + * @param axisIndex which axis: 0→X, 1→Y, 2→Z + * + * @return the rotation angle (in radians) + */ + public float getMinRotation(int axisIndex) { + float result; + switch (axisIndex) { + case PhysicsSpace.AXIS_X: + result = minX; + break; + case PhysicsSpace.AXIS_Y: + result = minY; + break; + case PhysicsSpace.AXIS_Z: + result = minZ; + break; + default: + String msg = String.format("axisIndex=%d", axisIndex); + throw new IllegalArgumentException(msg); + } + + return result; + } + + /** + * Apply this preset to the specified joint. + * + * @param joint where to apply this preset (not null, modified) + */ + public void setupJoint(SixDofJoint joint) { + Vector3f lower = new Vector3f(minX, minY, minZ); + Vector3f upper = new Vector3f(maxX, maxY, maxZ); + + RotationalLimitMotor rotX + = joint.getRotationalLimitMotor(PhysicsSpace.AXIS_X); + rotX.setLoLimit(lower.x); + rotX.setHiLimit(upper.x); + + RotationalLimitMotor rotY + = joint.getRotationalLimitMotor(PhysicsSpace.AXIS_Y); + rotY.setLoLimit(lower.y); + rotY.setHiLimit(upper.y); + + RotationalLimitMotor rotZ + = joint.getRotationalLimitMotor(PhysicsSpace.AXIS_Z); + rotZ.setLoLimit(lower.z); + rotZ.setHiLimit(upper.z); + + joint.setAngularLowerLimit(lower); + joint.setAngularUpperLimit(upper); + + for (int i = 0; i < 3; ++i) { + RotationalLimitMotor rot = joint.getRotationalLimitMotor(i); + rot.setMaxMotorForce(1e8f); + rot.setMaxLimitForce(1e9f); + } + + joint.setLinearLowerLimit(translateIdentity); + joint.setLinearUpperLimit(translateIdentity); + + TranslationalLimitMotor tra = joint.getTranslationalLimitMotor(); + tra.setLowerLimit(translateIdentity); + tra.setUpperLimit(translateIdentity); + } + // ************************************************************************* + // Savable methods + + /** + * De-serialize this preset, for example when loading from a J3O file. + * + * @param im importer (not null) + * @throws IOException from importer + */ + @Override + public void read(JmeImporter im) throws IOException { + InputCapsule capsule = im.getCapsule(this); + maxX = capsule.readFloat("maxX", 0f); + minX = capsule.readFloat("minX", 0f); + maxY = capsule.readFloat("maxY", 0f); + minY = capsule.readFloat("minY", 0f); + maxZ = capsule.readFloat("maxZ", 0f); + minZ = capsule.readFloat("minZ", 0f); + } + + /** + * Serialize this preset, for example when saving to a J3O file. + * + * @param ex exporter (not null) + * @throws IOException from exporter + */ + @Override + public void write(JmeExporter ex) throws IOException { + OutputCapsule capsule = ex.getCapsule(this); + capsule.write(maxX, "maxX", 0f); + capsule.write(minX, "minX", 0f); + capsule.write(maxY, "maxY", 0f); + capsule.write(minY, "minY", 0f); + capsule.write(maxZ, "maxZ", 0f); + capsule.write(minZ, "minZ", 0f); + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/TorsoLink.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/TorsoLink.java new file mode 100644 index 0000000000..c44868116a --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/TorsoLink.java @@ -0,0 +1,486 @@ +/* + * Copyright (c) 2018-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.anim.Joint; +import com.jme3.bullet.collision.shapes.CollisionShape; +import com.jme3.bullet.objects.PhysicsRigidBody; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.export.Savable; +import com.jme3.math.Quaternion; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; +import com.jme3.scene.Node; +import com.jme3.util.clone.Cloner; +import java.io.IOException; +import java.util.logging.Logger; + +/** + * Link the torso of an animated model to a rigid body in a ragdoll. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + * + * Based on KinematicRagdollControl by Normen Hansen and Rémy Bouquet (Nehon). + */ +public class TorsoLink extends PhysicsLink { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final public static Logger logger2 + = Logger.getLogger(TorsoLink.class.getName()); + // ************************************************************************* + // fields + + /** + * bones managed by this link, in a pre-order, depth-first traversal of the + * skeleton + */ + private Joint[] managedBones = null; + /** + * submode when kinematic + */ + private KinematicSubmode submode = KinematicSubmode.Animated; + /** + * local transform for the controlled spatial at the end of this link's most + * recent blend interval, or null for no spatial blending + */ + private Transform endModelTransform = null; + /** + * transform from mesh coordinates to model coordinates + */ + private Transform meshToModel = null; + /** + * local transform of the controlled spatial at the start of this link's + * most recent blend interval + */ + private Transform startModelTransform = new Transform(); + /** + * local transform of each managed bone from the previous update + */ + private Transform[] prevBoneTransforms = null; + /** + * local transform of each managed bone at the start of the most recent + * blend interval + */ + private Transform[] startBoneTransforms = null; + // ************************************************************************* + // constructors + + /** + * No-argument constructor needed by SavableClassUtil. Do not invoke + * directly! + */ + public TorsoLink() { + } + + /** + * Instantiate a purely kinematic link between the torso of the specified + * control and the specified rigid body. + * + * @param control the control that will manage this link (not null, alias + * created) + * @param mainRootBone the root bone with the most animation weight (not + * null, alias created) + * @param collisionShape the desired shape (not null, alias created) + * @param mass the mass (in physics-mass units) + * @param meshToModel the transform from mesh coordinates to model + * coordinates (not null, unaffected) + * @param localOffset the location of the body's center (in the bone's local + * coordinates, not null, unaffected) + */ + TorsoLink(DacLinks control, Joint mainRootBone, + CollisionShape collisionShape, float mass, + Transform meshToModel, Vector3f localOffset) { + super(control, mainRootBone, collisionShape, mass, localOffset); + this.meshToModel = meshToModel.clone(); + managedBones = control.listManagedBones(DynamicAnimControl.torsoName); + + int numManagedBones = managedBones.length; + startBoneTransforms = new Transform[numManagedBones]; + for (int i = 0; i < numManagedBones; ++i) { + startBoneTransforms[i] = new Transform(); + } + } + // ************************************************************************* + // new methods exposed + + /** + * Begin blending this link to a purely kinematic mode. + * + * @param submode enum value (not null) + * @param blendInterval the duration of the blend interval (in seconds, + * ≥0) + * @param endModelTransform the desired local transform for the controlled + * spatial when the blend completes or null for no change to local transform + * (unaffected) + */ + public void blendToKinematicMode(KinematicSubmode submode, + float blendInterval, Transform endModelTransform) { + super.blendToKinematicMode(blendInterval); + + this.submode = submode; + this.endModelTransform = endModelTransform; + /* + * Save initial transforms for blending. + */ + if (endModelTransform != null) { + Transform current = getControl().getSpatial().getLocalTransform(); + startModelTransform.set(current); + } + int numManagedBones = managedBones.length; + for (int mbIndex = 0; mbIndex < numManagedBones; ++mbIndex) { + Transform transform; + if (prevBoneTransforms == null) { // this link not updated yet + Joint managedBone = managedBones[mbIndex]; + transform = managedBone.getLocalTransform().clone(); + } else { + transform = prevBoneTransforms[mbIndex]; + } + startBoneTransforms[mbIndex].set(transform); + } + } + // ************************************************************************* + // PhysicsLink methods + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned link into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this link (not null) + * @param original the instance from which this link was shallow-cloned + * (unused) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + super.cloneFields(cloner, original); + + managedBones = cloner.clone(managedBones); + endModelTransform = cloner.clone(endModelTransform); + meshToModel = cloner.clone(meshToModel); + prevBoneTransforms = cloner.clone(prevBoneTransforms); + startBoneTransforms = cloner.clone(startBoneTransforms); + startModelTransform = cloner.clone(startModelTransform); + } + + /** + * Update this link in Dynamic mode, setting the local transform of the + * model's root spatial based on the transform of the linked rigid body. + */ + @Override + protected void dynamicUpdate() { + /* + * Calculate the inverse world transform of the model's parent node. + */ + Transform worldToParent; + Node parent = getControl().getSpatial().getParent(); + if (parent == null) { + worldToParent = new Transform(); + } else { + Transform parentToWorld = parent.getWorldTransform(); + worldToParent = parentToWorld.invert(); + } + + Transform transform = meshToModel.clone(); + Transform shapeToWorld = new Transform(); + PhysicsRigidBody body = getRigidBody(); + body.getPhysicsLocation(shapeToWorld.getTranslation()); + body.getPhysicsRotation(shapeToWorld.getRotation()); + shapeToWorld.setScale(body.getCollisionShape().getScale()); + + transform.combineWithParent(shapeToWorld); + transform.combineWithParent(worldToParent); + getControl().getSpatial().setLocalTransform(transform); + + localBoneTransform(transform); + Joint[] rootBones = getControl().getSkeleton().getRoots(); + for (Joint rootBone : rootBones) { + rootBone.setLocalTransform(transform); + } + + for (Joint managedBone : managedBones) { + managedBone.updateModelTransforms(); + } + } + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new instance + */ + @Override + public TorsoLink jmeClone() { + try { + TorsoLink clone = (TorsoLink) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * Update this link in blended Kinematic mode. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ + @Override + protected void kinematicUpdate(float tpf) { + assert tpf >= 0f : tpf; + assert getRigidBody().isKinematic(); + + Transform transform = new Transform(); + + if (endModelTransform != null) { + /* + * For a smooth transition, blend the saved model transform + * (from the start of the blend interval) into the goal transform. + */ + transform.interpolateTransforms(startModelTransform.clone(), + endModelTransform, kinematicWeight()); + getControl().getSpatial().setLocalTransform(transform); + } + + for (int mbIndex = 0; mbIndex < managedBones.length; ++mbIndex) { + Joint managedBone = managedBones[mbIndex]; + switch (submode) { + case Animated: + transform.set(managedBone.getLocalTransform()); + break; + case Frozen: + transform.set(prevBoneTransforms[mbIndex]); + break; + default: + throw new IllegalStateException(submode.toString()); + } + + if (kinematicWeight() < 1f) { // not purely kinematic yet + /* + * For a smooth transition, blend the saved bone transform + * (from the start of the blend interval) + * into the goal transform. + */ + transform.interpolateTransforms( + startBoneTransforms[mbIndex].clone(), transform, + kinematicWeight()); + } + /* + * Update the managed bone. + */ + managedBone.setLocalTransform(transform); + managedBone.updateModelTransforms(); + } + + super.kinematicUpdate(tpf); + } + + /** + * Unambiguously identify this link by name, within its DynamicAnimControl. + * + * @return a brief textual description (not null, not empty) + */ + @Override + public String name() { + return "Torso:"; + } + + /** + * Copy animation data from the specified link, which must have the same + * main bone. + * + * @param oldLink the link to copy from (not null, unaffected) + */ + void postRebuild(TorsoLink oldLink) { + int numManagedBones = managedBones.length; + assert oldLink.managedBones.length == numManagedBones; + + super.postRebuild(oldLink); + if (oldLink.isKinematic()) { + submode = oldLink.submode; + } else { + submode = KinematicSubmode.Frozen; + } + + Transform emt = oldLink.endModelTransform; + endModelTransform = (emt == null) ? null : emt.clone(); + startModelTransform.set(oldLink.startModelTransform); + + if (prevBoneTransforms == null) { + prevBoneTransforms = new Transform[numManagedBones]; + for (int i = 0; i < numManagedBones; ++i) { + prevBoneTransforms[i] = new Transform(); + } + } + for (int i = 0; i < numManagedBones; ++i) { + prevBoneTransforms[i].set(oldLink.prevBoneTransforms[i]); + startBoneTransforms[i].set(oldLink.startBoneTransforms[i]); + } + } + + /** + * De-serialize this link, for example when loading from a J3O file. + * + * @param im importer (not null) + * @throws IOException from importer + */ + @Override + public void read(JmeImporter im) throws IOException { + super.read(im); + InputCapsule ic = im.getCapsule(this); + + Savable[] tmp = ic.readSavableArray("managedBones", null); + if (tmp == null) { + managedBones = null; + } else { + managedBones = new Joint[tmp.length]; + for (int i = 0; i < tmp.length; ++i) { + managedBones[i] = (Joint) tmp[i]; + } + } + + submode = ic.readEnum("submode", KinematicSubmode.class, + KinematicSubmode.Animated); + endModelTransform = (Transform) ic.readSavable("endModelTransform", + new Transform()); + meshToModel + = (Transform) ic.readSavable("meshToModel", new Transform()); + startModelTransform = (Transform) ic.readSavable("startModelTransform", + new Transform()); + prevBoneTransforms = RagUtils.readTransformArray(ic, + "prevBoneTransforms"); + startBoneTransforms = RagUtils.readTransformArray(ic, + "startBoneTransforms"); + } + + /** + * Internal callback, invoked once per frame during the logical-state + * update, provided the control is added to a scene. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ + @Override + void update(float tpf) { + assert tpf >= 0f : tpf; + + if (prevBoneTransforms == null) { + /* + * On the first update, allocate and initialize + * the array of previous bone transforms, if it wasn't + * allocated in blendToKinematicMode(). + */ + int numManagedBones = managedBones.length; + prevBoneTransforms = new Transform[numManagedBones]; + for (int mbIndex = 0; mbIndex < numManagedBones; ++mbIndex) { + Joint managedBone = managedBones[mbIndex]; + Transform boneTransform + = managedBone.getLocalTransform().clone(); + prevBoneTransforms[mbIndex] = boneTransform; + } + } + + super.update(tpf); + /* + * Save copies of the latest bone transforms. + */ + for (int mbIndex = 0; mbIndex < managedBones.length; ++mbIndex) { + Transform lastTransform = prevBoneTransforms[mbIndex]; + Joint managedBone = managedBones[mbIndex]; + lastTransform.set(managedBone.getLocalTransform()); + } + } + + /** + * Serialize this link, for example when saving to a J3O file. + * + * @param ex exporter (not null) + * @throws IOException from exporter + */ + @Override + public void write(JmeExporter ex) throws IOException { + super.write(ex); + OutputCapsule oc = ex.getCapsule(this); + + oc.write(managedBones, "managedBones", null); + oc.write(submode, "submode", KinematicSubmode.Animated); + oc.write(endModelTransform, "endModelTransforms", new Transform()); + oc.write(meshToModel, "meshToModel", new Transform()); + oc.write(startModelTransform, "startModelTransforms", new Transform()); + oc.write(prevBoneTransforms, "prevBoneTransforms", new Transform[0]); + oc.write(startBoneTransforms, "startBoneTransforms", new Transform[0]); + } + // ************************************************************************* + // private methods + + /** + * Calculate the local bone transform to match the physics transform of the + * rigid body. + * + * @param storeResult storage for the result (modified if not null) + * @return the calculated bone transform (in local coordinates, either + * storeResult or a new transform, not null) + */ + private Transform localBoneTransform(Transform storeResult) { + Transform result + = (storeResult == null) ? new Transform() : storeResult; + Vector3f location = result.getTranslation(); + Quaternion orientation = result.getRotation(); + Vector3f scale = result.getScale(); + /* + * Start with the rigid body's transform in physics/world coordinates. + */ + PhysicsRigidBody body = getRigidBody(); + body.getPhysicsLocation(result.getTranslation()); + body.getPhysicsRotation(result.getRotation()); + result.setScale(body.getCollisionShape().getScale()); + /* + * Convert to mesh coordinates. + */ + Transform worldToMesh = getControl().meshTransform(null).invert(); + result.combineWithParent(worldToMesh); + /* + * Subtract the body's local offset, rotated and scaled. + */ + Vector3f meshOffset = localOffset(null); + meshOffset.multLocal(scale); + orientation.mult(meshOffset, meshOffset); + location.subtractLocal(meshOffset); + + return result; + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/VectorSet.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/VectorSet.java new file mode 100644 index 0000000000..482f957396 --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/VectorSet.java @@ -0,0 +1,151 @@ +/* + Copyright (c) 2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.animation; + +import com.jme3.math.Vector3f; +import com.jme3.util.BufferUtils; +import java.nio.FloatBuffer; +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Logger; + +/** + * A simplified collection of Vector3f values without duplicates, implemented + * using a Collection. + *

+ * This class is shared between JBullet and Native Bullet. + * + * @author Stephen Gold sgold@sonic.net + */ +public class VectorSet { + // ************************************************************************* + // constants and loggers + + /** + * message logger for this class + */ + final private static Logger logger + = Logger.getLogger(VectorSet.class.getName()); + // ************************************************************************* + // fields + + /** + * collection of values + */ + final private Set set; + // ************************************************************************* + // constructors + + /** + * Instantiate an empty set with the specified initial capacity and default + * load factor. + * + * @param numVectors the initial capacity of the hash table (>0) + */ + public VectorSet(int numVectors) { + set = new HashSet<>(numVectors); + } + // ************************************************************************* + // VectorSet methods + + /** + * Add the value of the specified Vector3f to this set. + * + * @param vector the value to add (not null, unaffected) + */ + public void add(Vector3f vector) { + set.add(vector.clone()); + } + + /** + * Test whether this set contains the value of the specified Vector3f. + * + * @param vector the value to find (not null, unaffected) + * @return true if found, otherwise false + */ + public boolean contains(Vector3f vector) { + boolean result = set.contains(vector); + return result; + } + + /** + * Calculate the sample mean for each axis over the Vector3f values in this + * set. + * + * @param storeResult (modified if not null) + * @return the sample mean for each axis (either storeResult or a new + * Vector3f) + */ + public Vector3f mean(Vector3f storeResult) { + int numVectors = numVectors(); + assert numVectors > 0 : numVectors; + Vector3f result = (storeResult == null) ? new Vector3f() : storeResult; + + result.zero(); + for (Vector3f tempVector : set) { + result.addLocal(tempVector); + } + result.divideLocal(numVectors); + + return result; + } + + /** + * Calculate the number of Vector3f values in this set. + * + * @return the count (≥0) + */ + public int numVectors() { + int numVectors = set.size(); + assert numVectors >= 0 : numVectors; + return numVectors; + } + + /** + * Access the buffer containing all the Vector3f values in this set. No + * further add() is allowed. + * + * @return a new buffer, flipped + */ + public FloatBuffer toBuffer() { + int numFloats = 3 * set.size(); + FloatBuffer buffer = BufferUtils.createFloatBuffer(numFloats); + for (Vector3f tempVector : set) { + buffer.put(tempVector.x); + buffer.put(tempVector.y); + buffer.put(tempVector.z); + } + buffer.flip(); + + return buffer; + } +} diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/animation/package-info.java b/jme3-bullet/src/common/java/com/jme3/bullet/animation/package-info.java new file mode 100644 index 0000000000..ac9b2f72ae --- /dev/null +++ b/jme3-bullet/src/common/java/com/jme3/bullet/animation/package-info.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/** + * A dynamic animation control and some associated classes. + */ +package com.jme3.bullet.animation; diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java index f858d0e00e..739701d9fc 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java @@ -246,6 +246,13 @@ public void setSpatial(Spatial spatial) { setPhysicsRotation(getSpatialRotation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + /** * Enable or disable this control. *

diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java index 85dcf1a955..2ee7fbe622 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java @@ -102,6 +102,7 @@ public Object jmeClone() { control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); + control.setContactResponse(isContactResponse()); control.setFallSpeed(getFallSpeed()); control.setGravity(getGravity()); control.setJumpSpeed(getJumpSpeed()); @@ -128,6 +129,13 @@ public void setSpatial(Spatial spatial) { setPhysicsLocation(getSpatialTranslation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java index 7ff51670d2..ca3fc72543 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java @@ -206,6 +206,13 @@ public void setSpatial(Spatial spatial) { setPhysicsRotation(getSpatialRotation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + /** * Enable or disable this control. *

diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java index 6b8714da8d..cee3401e1a 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java @@ -150,6 +150,7 @@ public Object jmeClone() { control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); + control.setContactResponse(isContactResponse()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); @@ -206,6 +207,13 @@ public void setSpatial(Spatial spatial) { setPhysicsRotation(getSpatialRotation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + /** * Set the collision shape based on the controlled spatial and its * descendents. diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java index ccc90091a9..51210c6a7a 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/VehicleControl.java @@ -168,6 +168,7 @@ public Object jmeClone() { control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); + control.setContactResponse(isContactResponse()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/ragdoll/RagdollUtils.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/ragdoll/RagdollUtils.java index 419c337bca..9e354a1fa0 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/ragdoll/RagdollUtils.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/ragdoll/RagdollUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,9 +41,12 @@ import com.jme3.math.Vector3f; import com.jme3.scene.Mesh; import com.jme3.scene.Spatial; +import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer.Type; +import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.FloatBuffer; +import java.nio.ShortBuffer; import java.util.*; /** @@ -254,7 +257,8 @@ public static HullCollisionShape makeShapeFromVerticeWeights(Spatial model, private static List getPoints(Mesh mesh, int boneIndex, Vector3f initialScale, Vector3f offset, float weightThreshold) { FloatBuffer vertices = mesh.getFloatBuffer(Type.Position); - ByteBuffer boneIndices = (ByteBuffer) mesh.getBuffer(Type.BoneIndex).getData(); + VertexBuffer biBuf = mesh.getBuffer(VertexBuffer.Type.BoneIndex); + Buffer boneIndices = biBuf.getDataReadOnly(); FloatBuffer boneWeight = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData(); vertices.rewind(); @@ -270,7 +274,8 @@ private static List getPoints(Mesh mesh, int boneIndex, Vector3f initialS boolean add = false; int start = i / 3 * 4; for (k = start; k < start + 4; k++) { - if (boneIndices.get(k) == boneIndex && boneWeight.get(k) >= weightThreshold) { + if (readIndex(boneIndices, k) == boneIndex + && boneWeight.get(k) >= weightThreshold) { add = true; break; } @@ -349,8 +354,8 @@ public static void setUserControl(Bone bone, boolean bool) { public static boolean hasVertices(int boneIndex, Mesh[] targets, float weightThreshold) { for (Mesh mesh : targets) { - ByteBuffer boneIndices - = (ByteBuffer) mesh.getBuffer(Type.BoneIndex).getData(); + VertexBuffer biBuf = mesh.getBuffer(VertexBuffer.Type.BoneIndex); + Buffer boneIndices = biBuf.getDataReadOnly(); FloatBuffer boneWeight = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData(); @@ -361,7 +366,7 @@ public static boolean hasVertices(int boneIndex, Mesh[] targets, for (int i = 0; i < vertexComponents; i += 3) { int start = i / 3 * 4; for (int k = start; k < start + 4; k++) { - if (boneIndices.get(k) == boneIndex + if (readIndex(boneIndices, k) == boneIndex && boneWeight.get(k) >= weightThreshold) { return true; } @@ -371,4 +376,29 @@ public static boolean hasVertices(int boneIndex, Mesh[] targets, return false; } + + /** + * Read an index from a buffer. + * + * @param buffer a buffer of bytes or shorts (not null) + * @param k the position from which the index will be read + * @return the index value (≥0) + */ + public static int readIndex(Buffer buffer, int k) { + int result; + if (buffer instanceof ByteBuffer) { + ByteBuffer byteBuffer = (ByteBuffer) buffer; + byte b = byteBuffer.get(k); + result = 0xff & b; + } else if (buffer instanceof ShortBuffer) { + ShortBuffer shortBuffer = (ShortBuffer) buffer; + short s = shortBuffer.get(k); + result = 0xffff & s; + } else { + throw new IllegalArgumentException(buffer.getClass().getName()); + } + + assert result >= 0 : result; + return result; + } } diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletCharacterDebugControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletCharacterDebugControl.java index 687d6ba27c..514e79b165 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletCharacterDebugControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletCharacterDebugControl.java @@ -67,6 +67,11 @@ public class BulletCharacterDebugControl extends AbstractPhysicsDebugControl { * geometry to visualize myShape (not null) */ protected Spatial geom; + /** + * physics scale for which geom was generated + */ + final private Vector3f oldScale = new Vector3f(); + /** * Instantiate an enabled control to visualize the specified character. * @@ -78,7 +83,10 @@ public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCha super(debugAppState); this.body = body; myShape = body.getCollisionShape(); - this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); + oldScale.set(myShape.getScale()); + + this.geom = DebugShapeFactory.getDebugShape(myShape); + this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_PINK); } @@ -110,15 +118,24 @@ public void setSpatial(Spatial spatial) { */ @Override protected void controlUpdate(float tpf) { - if(myShape != body.getCollisionShape()){ - Node node = (Node) this.spatial; + CollisionShape newShape = body.getCollisionShape(); + Vector3f newScale = newShape.getScale(); + if (myShape != newShape || !oldScale.equals(newScale)) { + myShape = newShape; + oldScale.set(newScale); + + Node node = (Node) spatial; node.detachChild(geom); - geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); - geom.setMaterial(debugAppState.DEBUG_PINK); + + geom = DebugShapeFactory.getDebugShape(myShape); + geom.setName(body.toString()); + node.attachChild(geom); } - applyPhysicsTransform(body.getPhysicsLocation(location), Quaternion.IDENTITY); - geom.setLocalScale(body.getCollisionShape().getScale()); + geom.setMaterial(debugAppState.DEBUG_PINK); + + body.getPhysicsLocation(location); + applyPhysicsTransform(location, Quaternion.IDENTITY); } /** diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletGhostObjectDebugControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletGhostObjectDebugControl.java index 09f24c7fc7..bdb6932d7a 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletGhostObjectDebugControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletGhostObjectDebugControl.java @@ -70,7 +70,10 @@ public class BulletGhostObjectDebugControl extends AbstractPhysicsDebugControl { * geometry to visualize myShape (not null) */ protected Spatial geom; - + /** + * physics scale for which geom was generated + */ + final private Vector3f oldScale = new Vector3f(); /** * Instantiate an enabled control to visualize the specified ghost object. * @@ -81,8 +84,9 @@ public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsG super(debugAppState); this.body = body; myShape = body.getCollisionShape(); - this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); - this.geom.setName(body.toString()); + oldScale.set(myShape.getScale()); + + this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_YELLOW); } @@ -115,15 +119,25 @@ public void setSpatial(Spatial spatial) { */ @Override protected void controlUpdate(float tpf) { - if (myShape != body.getCollisionShape()) { - Node node = (Node) this.spatial; + CollisionShape newShape = body.getCollisionShape(); + Vector3f newScale = newShape.getScale(); + if (myShape != newShape || !oldScale.equals(newScale)) { + myShape = newShape; + oldScale.set(newScale); + + Node node = (Node) spatial; node.detachChild(geom); - geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); - geom.setMaterial(debugAppState.DEBUG_YELLOW); + + geom = DebugShapeFactory.getDebugShape(myShape); + geom.setName(body.toString()); + node.attachChild(geom); } - applyPhysicsTransform(body.getPhysicsLocation(location), body.getPhysicsRotation(rotation)); - geom.setLocalScale(body.getCollisionShape().getScale()); + geom.setMaterial(debugAppState.DEBUG_YELLOW); + + body.getPhysicsLocation(location); + body.getPhysicsRotation(rotation); + applyPhysicsTransform(location, rotation); } /** diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletRigidBodyDebugControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletRigidBodyDebugControl.java index 83e5b786fa..727deebc33 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletRigidBodyDebugControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/debug/BulletRigidBodyDebugControl.java @@ -70,6 +70,10 @@ public class BulletRigidBodyDebugControl extends AbstractPhysicsDebugControl { * geometry to visualize myShape (not null) */ protected Spatial geom; + /** + * physics scale for which geom was generated + */ + final private Vector3f oldScale = new Vector3f(); /** * Instantiate an enabled control to visualize the specified body. @@ -81,7 +85,9 @@ public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRig super(debugAppState); this.body = body; myShape = body.getCollisionShape(); - this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); + oldScale.set(myShape.getScale()); + + this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_BLUE); } @@ -114,10 +120,18 @@ public void setSpatial(Spatial spatial) { */ @Override protected void controlUpdate(float tpf) { - if(myShape != body.getCollisionShape()){ - Node node = (Node) this.spatial; + CollisionShape newShape = body.getCollisionShape(); + Vector3f newScale = newShape.getScale(); + if (myShape != newShape || !oldScale.equals(newScale)) { + myShape = newShape; + oldScale.set(newScale); + + Node node = (Node) spatial; node.detachChild(geom); - geom = DebugShapeFactory.getDebugShape(body.getCollisionShape()); + + geom = DebugShapeFactory.getDebugShape(myShape); + geom.setName(body.toString()); + node.attachChild(geom); } if(body.isActive()){ @@ -125,8 +139,10 @@ protected void controlUpdate(float tpf) { }else{ geom.setMaterial(debugAppState.DEBUG_BLUE); } - applyPhysicsTransform(body.getPhysicsLocation(location), body.getPhysicsRotation(rotation)); - geom.setLocalScale(body.getCollisionShape().getScale()); + + body.getPhysicsLocation(location); + body.getPhysicsRotation(rotation); + applyPhysicsTransform(location, rotation); } /** diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java index ea5f74518d..f2d709131b 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/PhysicsSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,7 +55,6 @@ import java.util.List; import java.util.Map; import java.util.Comparator; -import java.util.Deque; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -1002,7 +1001,7 @@ public void removeCollisionGroupListener(int collisionGroup) { * unaffected) * @return a new list of results (not null) */ - public List rayTest(Vector3f from, Vector3f to) { + public List rayTest(Vector3f from, Vector3f to) { List results = new ArrayList(); rayTest(from, to, results); @@ -1019,7 +1018,7 @@ public List rayTest(Vector3f from, Vector3f to) { * unaffected) * @return a new list of results (not null) */ - public List rayTestRaw(Vector3f from, Vector3f to) { + public List rayTestRaw(Vector3f from, Vector3f to) { List results = new ArrayList(); rayTestRaw(from, to, results); diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/collision/CollisionFlag.java b/jme3-bullet/src/main/java/com/jme3/bullet/collision/CollisionFlag.java new file mode 100644 index 0000000000..6445af53f3 --- /dev/null +++ b/jme3-bullet/src/main/java/com/jme3/bullet/collision/CollisionFlag.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.bullet.collision; + +/** + * Named collision flags for a {@link PhysicsCollisionObject}. Values must agree + * with those in BulletCollision/CollisionDispatch/btCollisionObject.h + * + * @author Stephen Gold sgold@sonic.net + * @see PhysicsCollisionObject#getCollisionFlags(long) + */ +public class CollisionFlag { + /** + * flag for a static object + */ + final public static int STATIC_OBJECT = 0x1; + /** + * flag for a kinematic object + */ + final public static int KINEMATIC_OBJECT = 0x2; + /** + * flag for an object with no contact response, such as a PhysicsGhostObject + */ + final public static int NO_CONTACT_RESPONSE = 0x4; + /** + * flag to enable a custom material callback for per-triangle + * friction/restitution (not used by JME) + */ + final public static int CUSTOM_MATERIAL_CALLBACK = 0x8; + /** + * flag for a character object, such as a PhysicsCharacter + */ + final public static int CHARACTER_OBJECT = 0x10; + /** + * flag to disable debug visualization (not used by JME) + */ + final public static int DISABLE_VISUALIZE_OBJECT = 0x20; + /** + * flag to disable parallel/SPU processing (not used by JME) + */ + final public static int DISABLE_SPU_COLLISION_PROCESSING = 0x40; + /** + * flag not used by JME + */ + final public static int HAS_CONTACT_STIFFNESS_DAMPING = 0x80; + /** + * flag not used by JME + */ + final public static int HAS_CUSTOM_DEBUG_RENDERING_COLOR = 0x100; + /** + * flag not used by JME + */ + final public static int HAS_FRICTION_ANCHOR = 0x200; + /** + * flag not used by JME + */ + final public static int HAS_COLLISION_SOUND_TRIGGER = 0x400; +} diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java b/jme3-bullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java index 443433623d..ea8ced87c8 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java @@ -254,6 +254,17 @@ public Object getUserObject() { return userObject; } + /** + * Test whether this object responds to contact with other objects. + * + * @return true if responsive, otherwise false + */ + public boolean isContactResponse() { + int flags = getCollisionFlags(objectId); + boolean result = (flags & CollisionFlag.NO_CONTACT_RESPONSE) == 0x0; + return result; + } + /** * Associate a user object (such as a Spatial) with this collision object. * @@ -314,6 +325,24 @@ public void read(JmeImporter e) throws IOException { collisionShape = shape; } + /** + * Read the collision flags of this object. Subclasses are responsible for + * cloning/reading/writing these flags. + * + * @param objectId the ID of the btCollisionObject (not zero) + * @return the collision flags (bit mask) + */ + native protected int getCollisionFlags(long objectId); + + /** + * Alter the collision flags of this object. Subclasses are responsible for + * cloning/reading/writing these flags. + * + * @param objectId the ID of the btCollisionObject (not zero) + * @param desiredFlags the desired collision flags (bit mask) + */ + native protected void setCollisionFlags(long objectId, int desiredFlags); + /** * Finalize this collision object just before it is destroyed. Should be * invoked only by a subclass or by the garbage collector. diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java b/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java index ea6f11be9c..acdd6ed04d 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,6 +49,11 @@ */ public abstract class CollisionShape implements Savable { + /** + * default margin for new non-sphere/non-capsule shapes (in physics-space + * units, >0, default=0.04) + */ + private static float defaultMargin = 0.04f; /** * unique identifier of the btCollisionShape *

@@ -63,7 +68,7 @@ public abstract class CollisionShape implements Savable { /** * copy of collision margin (in physics-space units, >0, default=0) */ - protected float margin = 0.0f; + protected float margin = defaultMargin; public CollisionShape() { } @@ -135,6 +140,27 @@ public float getMargin() { private native float getMargin(long objectId); + /** + * Alter the default margin for new shapes that are neither capsules nor + * spheres. + * + * @param margin the desired margin distance (in physics-space units, >0, + * default=0.04) + */ + public static void setDefaultMargin(float margin) { + defaultMargin = margin; + } + + /** + * Read the default margin for new shapes. + * + * @return margin the default margin distance (in physics-space units, + * >0) + */ + public static float getDefaultMargin() { + return defaultMargin; + } + /** * Alter the collision margin of this shape. CAUTION: Margin is applied * differently, depending on the type of shape. Generally the collision @@ -145,7 +171,7 @@ public float getMargin() { * compound shapes) changes can have unintended consequences. * * @param margin the desired margin distance (in physics-space units, >0, - * default=0) + * default=0.04) */ public void setMargin(float margin) { setMargin(objectId, margin); diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/MeshCollisionShape.java b/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/MeshCollisionShape.java index dead3294ca..60089fddeb 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/MeshCollisionShape.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/collision/shapes/MeshCollisionShape.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.nio.ByteBuffer; -import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java b/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java index 148199b75b..3824462e92 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,7 @@ */ package com.jme3.bullet.objects; +import com.jme3.bullet.collision.CollisionFlag; import com.jme3.bullet.collision.PhysicsCollisionObject; import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.export.InputCapsule; @@ -50,7 +51,6 @@ * @author normenhansen */ public class PhysicsCharacter extends PhysicsCollisionObject { - /** * Unique identifier of btKinematicCharacterController (as opposed to its * collision object, which is a ghost). Constructors are responsible for @@ -88,6 +88,12 @@ public PhysicsCharacter(CollisionShape shape, float stepHeight) { // } this.stepHeight = stepHeight; buildObject(); + /* + * The default gravity for a Bullet btKinematicCharacterController + * is (0,0,-29.4), which makes no sense for JME. + * So override the default. + */ + setGravity(new Vector3f(0f, -29.4f, 0f)); } /** @@ -289,14 +295,14 @@ public float getJumpSpeed() { /** * @deprecated Deprecated in bullet 2.86.1. Use setGravity(Vector3f) * instead. - * @param value the desired upward component of the acceleration (typically - * negative) + * @param value the desired downward (-Y) component of the acceleration + * (typically positive) */ @Deprecated public void setGravity(float value) { - setGravity(new Vector3f(0,value,0)); + setGravity(new Vector3f(0, -value, 0)); } - + /** * Alter this character's gravitational acceleration. * @@ -311,11 +317,12 @@ public void setGravity(Vector3f value) { /** * @deprecated Deprecated in bullet 2.86.1. Use getGravity(Vector3f) * instead. - * @return the upward component of the acceleration (typically negative) + * @return the downward (-Y) component of the acceleration (typically + * positive) */ @Deprecated public float getGravity() { - return getGravity(null).y; + return -getGravity(null).y; } /** @@ -456,6 +463,22 @@ public float getMaxSlope() { private native float getMaxSlope(long characterId); + /** + * Enable/disable this character's contact response. + * + * @param responsive true to respond to contacts, false to ignore them + * (default=true) + */ + public void setContactResponse(boolean responsive) { + int flags = getCollisionFlags(objectId); + if (responsive) { + flags &= ~CollisionFlag.NO_CONTACT_RESPONSE; + } else { + flags |= CollisionFlag.NO_CONTACT_RESPONSE; + } + setCollisionFlags(objectId, flags); + } + /** * Test whether this character is on the ground. * @@ -472,10 +495,15 @@ public boolean onGround() { */ @Deprecated public void jump() { - jump(Vector3f.UNIT_Y); + jump(Vector3f.ZERO); + /* + * The zero vector is treated as a special case + * by Bullet's btKinematicCharacterController::jump(), + * causing the character to jump in its "up" direction + * with the pre-set speed. + */ } - - + /** * Jump in the specified direction. * diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java b/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java index 303060fe3f..2cbbf3c42d 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java @@ -32,6 +32,7 @@ package com.jme3.bullet.objects; import com.jme3.bullet.PhysicsSpace; +import com.jme3.bullet.collision.CollisionFlag; import com.jme3.bullet.collision.PhysicsCollisionObject; import com.jme3.bullet.collision.shapes.CollisionShape; import com.jme3.bullet.collision.shapes.MeshCollisionShape; @@ -56,7 +57,6 @@ * @author normenhansen */ public class PhysicsRigidBody extends PhysicsCollisionObject { - /** * motion state */ @@ -370,6 +370,22 @@ public boolean isKinematic() { return kinematic; } + /** + * Enable/disable this body's contact response. + * + * @param responsive true to respond to contacts, false to ignore them + * (default=true) + */ + public void setContactResponse(boolean responsive) { + int flags = getCollisionFlags(objectId); + if (responsive) { + flags &= ~CollisionFlag.NO_CONTACT_RESPONSE; + } else { + flags |= CollisionFlag.NO_CONTACT_RESPONSE; + } + setCollisionFlags(objectId, flags); + } + /** * Alter the radius of the swept sphere used for continuous collision * detection (CCD). @@ -993,6 +1009,7 @@ public void write(JmeExporter e) throws IOException { capsule.write(getMass(), "mass", 1.0f); capsule.write(getGravity(), "gravity", Vector3f.ZERO); + capsule.write(isContactResponse(), "contactResponse", true); capsule.write(getFriction(), "friction", 0.5f); capsule.write(getRestitution(), "restitution", 0); Vector3f angularFactor = getAngularFactor(null); @@ -1014,6 +1031,8 @@ public void write(JmeExporter e) throws IOException { capsule.write(getPhysicsLocation(new Vector3f()), "physicsLocation", new Vector3f()); capsule.write(getPhysicsRotationMatrix(new Matrix3f()), "physicsRotation", new Matrix3f()); + capsule.write(getLinearVelocity(), "linearVelocity", null); + capsule.write(getAngularVelocity(), "angularVelocity", null); capsule.writeSavableArrayList(joints, "joints", null); } @@ -1033,6 +1052,7 @@ public void read(JmeImporter e) throws IOException { this.mass = mass; rebuildRigidBody(); setGravity((Vector3f) capsule.readSavable("gravity", Vector3f.ZERO.clone())); + setContactResponse(capsule.readBoolean("contactResponse", true)); setFriction(capsule.readFloat("friction", 0.5f)); setKinematic(capsule.readBoolean("kinematic", false)); @@ -1051,6 +1071,8 @@ public void read(JmeImporter e) throws IOException { setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f())); setPhysicsRotation((Matrix3f) capsule.readSavable("physicsRotation", new Matrix3f())); + setLinearVelocity((Vector3f) capsule.readSavable("linearVelocity", new Vector3f())); + setAngularVelocity((Vector3f) capsule.readSavable("angularVelocity", new Vector3f())); joints = capsule.readSavableArrayList("joints", null); } diff --git a/jme3-bullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java b/jme3-bullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java index 9351306852..d56440911a 100644 --- a/jme3-bullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java +++ b/jme3-bullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java @@ -35,7 +35,6 @@ import com.jme3.bullet.collision.shapes.CompoundCollisionShape; import com.jme3.bullet.collision.shapes.infos.ChildCollisionShape; import com.jme3.math.Matrix3f; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.Mesh; import com.jme3.scene.Node; @@ -46,6 +45,7 @@ import java.util.List; /** + * A utility class to generate debug spatials from Bullet collision shapes. * * @author CJ Hare, normenhansen */ @@ -128,14 +128,8 @@ private static Geometry createDebugShape(CollisionShape shape) { public static Mesh getDebugMesh(CollisionShape shape) { Mesh mesh = new Mesh(); DebugMeshCallback callback = new DebugMeshCallback(); - /* - * Populate the mesh based on an unscaled shape; - * the shape's scale will be applied later, to the geometry. - */ - Vector3f savedScale = shape.getScale().clone(); - shape.setScale(Vector3f.UNIT_XYZ); - getVertices(shape.getObjectId(), callback); - shape.setScale(savedScale); + long id = shape.getObjectId(); + getVertices(id, callback); mesh.setBuffer(Type.Position, 3, callback.getVertices()); mesh.getFloatBuffer(Type.Position).clear(); diff --git a/jme3-core/src/main/java/checkers/quals/SubtypeOf.java b/jme3-core/src/main/java/checkers/quals/SubtypeOf.java index ffc8be0453..189969c050 100644 --- a/jme3-core/src/main/java/checkers/quals/SubtypeOf.java +++ b/jme3-core/src/main/java/checkers/quals/SubtypeOf.java @@ -6,8 +6,8 @@ * A meta-annotation to specify all the qualifiers that the given qualifier * is a subtype of. This provides a declarative way to specify the type * qualifier hierarchy. (Alternatively, the hierarchy can be defined - * procedurally by subclassing {@link checkers.types.QualifierHierarchy} or - * {@link checkers.types.TypeHierarchy}.) + * procedurally by subclassing checkers.types.QualifierHierarchy or + * checkers.types.TypeHierarchy.) * *

* Example: diff --git a/jme3-core/src/main/java/checkers/quals/package-info.java b/jme3-core/src/main/java/checkers/quals/package-info.java index 5ae80a7d68..192a8312f5 100644 --- a/jme3-core/src/main/java/checkers/quals/package-info.java +++ b/jme3-core/src/main/java/checkers/quals/package-info.java @@ -5,6 +5,6 @@ * They may serve as documentation for the type qualifiers, and aid the * Checker Framework to infer the relations between the type qualifiers. * - * @checker.framework.manual #writing-a-checker Writing a checker + * checker.framework.manual #writing-a-checker Writing a checker */ package checkers.quals; diff --git a/jme3-core/src/main/java/com/jme3/anim/AnimClip.java b/jme3-core/src/main/java/com/jme3/anim/AnimClip.java index 9b86858a33..be29e2105e 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AnimClip.java +++ b/jme3-core/src/main/java/com/jme3/anim/AnimClip.java @@ -1,8 +1,6 @@ package com.jme3.anim; -import com.jme3.anim.tween.Tween; import com.jme3.export.*; -import com.jme3.util.SafeArrayList; import com.jme3.util.clone.Cloner; import com.jme3.util.clone.JmeCloneable; diff --git a/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java b/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java index 6462893678..d997ab39d1 100644 --- a/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java +++ b/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java @@ -3,7 +3,10 @@ import com.jme3.anim.tween.Tween; import com.jme3.anim.tween.Tweens; import com.jme3.anim.tween.action.*; -import com.jme3.export.*; +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.scene.control.AbstractControl; @@ -26,7 +29,7 @@ public class AnimComposer extends AbstractControl { private Map layers = new LinkedHashMap<>(); public AnimComposer() { - layers.put(DEFAULT_LAYER, new Layer()); + layers.put(DEFAULT_LAYER, new Layer(this)); } /** @@ -67,18 +70,47 @@ public void removeAnimClip(AnimClip anim) { public Action setCurrentAction(String name) { return setCurrentAction(name, DEFAULT_LAYER); } - + + /** + * Run an action on specified layer. + * + * @param actionName The name of the action to run. + * @param layerName The layer on which action should run. + * @return The action corresponding to the given name. + */ public Action setCurrentAction(String actionName, String layerName) { Layer l = layers.get(layerName); if (l == null) { throw new IllegalArgumentException("Unknown layer " + layerName); } + Action currentAction = action(actionName); l.time = 0; l.currentAction = currentAction; return currentAction; } + + /** + * Remove current action on specified layer. + * + * @param layerName The name of the layer we want to remove its action. + */ + public void removeCurrentAction(String layerName) { + Layer l = layers.get(layerName); + if (l == null) { + throw new IllegalArgumentException("Unknown layer " + layerName); + } + + l.time = 0; + l.currentAction = null; + } + /** + * + * @param name The name of the action to return. + * @return The action registered with specified name. It will make a new action if there isn't any. + * @see #makeAction(java.lang.String) + */ public Action action(String name) { Action action = actions.get(name); if (action == null) { @@ -87,7 +119,33 @@ public Action action(String name) { } return action; } + + /** + * + * @param name The name of the action to return. + * @return The action registered with specified name or null if nothing is registered. + */ + public Action getAction(String name){ + return actions.get(name); + } + + /** + * Register given action with specified name. + * + * @param name The name of the action. + * @param action The action to add. + */ + public void addAction(String name, Action action){ + actions.put(name, action); + } + /** + * Create a new ClipAction with specified clip name. + * + * @param name The name of the clip. + * @return a new action + * @throws IllegalArgumentException if clip with specified name not found. + */ public Action makeAction(String name) { Action action; AnimClip clip = animClipMap.get(name); @@ -97,13 +155,35 @@ public Action makeAction(String name) { action = new ClipAction(clip); return action; } + + public boolean hasAction(String name) { + return actions.containsKey(name); + } + + /** + * Remove specified action. + * + * @param name The name of the action to remove. + * @return The removed action. + */ + public Action removeAction(String name) { + return actions.remove(name); + } - public void makeLayer(String name, AnimationMask mask){ - Layer l = new Layer(); + public void makeLayer(String name, AnimationMask mask) { + Layer l = new Layer(this); l.mask = mask; layers.put(name, l); } + /** + * Remove specified layer. This will stop the current action on this layer. + * + * @param name The name of the layer to remove. + */ + public void removeLayer(String name) { + layers.remove(name); + } public BaseAction actionSequence(String name, Tween... tweens) { BaseAction action = new BaseAction(Tweens.sequence(tweens)); @@ -129,12 +209,25 @@ public void reset() { } } + /** + * Returns an unmodifiable collection of all available animations. When an attempt + * is made to modify the collection, an UnsupportedOperationException is thrown. + * + * @return the unmodifiable collection of animations + */ public Collection getAnimClips() { return Collections.unmodifiableCollection(animClipMap.values()); } - public Collection getAnimClipsNames() { - return Collections.unmodifiableCollection(animClipMap.keySet()); + /** + * Returns an unmodifiable set of all available animation names. When an + * attempt is made to modify the set, an UnsupportedOperationException is + * thrown. + * + * @return the unmodifiable set of animation names. + */ + public Set getAnimClipsNames() { + return Collections.unmodifiableSet(animClipMap.keySet()); } @Override @@ -207,6 +300,7 @@ public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); animClipMap = (Map) ic.readStringSavableMap("animClipMap", new HashMap()); + globalSpeed = ic.readFloat("globalSpeed", 1f); } @Override @@ -214,16 +308,22 @@ public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.writeStringSavableMap(animClipMap, "animClipMap", new HashMap()); + oc.write(globalSpeed, "globalSpeed", 1f); } - private class Layer implements JmeCloneable { + private static class Layer implements JmeCloneable { + private AnimComposer ac; private Action currentAction; private AnimationMask mask; private float weight; private double time; + public Layer(AnimComposer ac) { + this.ac = ac; + } + public void advance(float tpf) { - time += tpf * currentAction.getSpeed() * globalSpeed; + time += tpf * currentAction.getSpeed() * ac.globalSpeed; // make sure negative time is in [0, length] range if (time < 0) { double length = currentAction.getLength(); @@ -244,6 +344,7 @@ public Object jmeClone() { @Override public void cloneFields(Cloner cloner, Object original) { + ac = cloner.clone(ac); currentAction = null; } } diff --git a/jme3-core/src/main/java/com/jme3/anim/Armature.java b/jme3-core/src/main/java/com/jme3/anim/Armature.java index ad7f5b0ac5..361603b9d1 100644 --- a/jme3-core/src/main/java/com/jme3/anim/Armature.java +++ b/jme3-core/src/main/java/com/jme3/anim/Armature.java @@ -63,7 +63,7 @@ public Armature(Joint[] jointList) { } /** - * Update all joints sin this Amature. + * Update all joints in this Armature. */ public void update() { for (Joint rootJoint : rootJoints) { @@ -83,7 +83,9 @@ private void createSkinningMatrices() { * Default is {@link MatrixJointModelTransform} * * @param modelTransformClass - * @see {@link JointModelTransform},{@link MatrixJointModelTransform},{@link SeparateJointModelTransform}, + * @see JointModelTransform + * @see MatrixJointModelTransform + * @see SeparateJointModelTransform */ public void setModelTransformClass(Class modelTransformClass) { this.modelTransformClass = modelTransformClass; @@ -106,7 +108,7 @@ private void instanciateJointModelTransform(Joint joint) { /** * returns the array of all root joints of this Armature * - * @return + * @return the pre-existing array */ public Joint[] getRoots() { return rootJoints; @@ -120,7 +122,7 @@ public List getJointList() { * return a joint for the given index * * @param index - * @return + * @return the pre-existing instance */ public Joint getJoint(int index) { return jointList[index]; @@ -130,7 +132,7 @@ public Joint getJoint(int index) { * returns the joint with the given name * * @param name - * @return + * @return the pre-existing instance or null if not found */ public Joint getJoint(String name) { for (int i = 0; i < jointList.length; i++) { @@ -145,7 +147,7 @@ public Joint getJoint(String name) { * returns the bone index of the given bone * * @param joint - * @return + * @return the index (≥0) or -1 if not found */ public int getJointIndex(Joint joint) { for (int i = 0; i < jointList.length; i++) { @@ -161,7 +163,7 @@ public int getJointIndex(Joint joint) { * returns the joint index of the joint that has the given name * * @param name - * @return + * @return the index (≥0) or -1 if not found */ public int getJointIndex(String name) { for (int i = 0; i < jointList.length; i++) { @@ -219,7 +221,7 @@ public void applyInitialPose() { /** * Compute the skinning matrices for each bone of the armature that would be used to transform vertices of associated meshes * - * @return + * @return the pre-existing array */ public Matrix4f[] computeSkinningMatrices() { for (int i = 0; i < jointList.length; i++) { @@ -231,7 +233,7 @@ public Matrix4f[] computeSkinningMatrices() { /** * returns the number of joints of this armature * - * @return + * @return the count (≥0) */ public int getJointCount() { return jointList.length; @@ -274,7 +276,7 @@ public void read(JmeImporter im) throws IOException { try { modelTransformClass = (Class) Class.forName(className); } catch (ClassNotFoundException e) { - throw new AssetLoadException("Cannnot find class for name " + className); + throw new AssetLoadException("Cannot find class for name " + className); } int i = 0; diff --git a/jme3-core/src/main/java/com/jme3/anim/Joint.java b/jme3-core/src/main/java/com/jme3/anim/Joint.java index bf672fa29a..0c7153d296 100644 --- a/jme3-core/src/main/java/com/jme3/anim/Joint.java +++ b/jme3-core/src/main/java/com/jme3/anim/Joint.java @@ -154,7 +154,7 @@ protected void saveInitialPose() { /** * Sets the local transform with the bind transforms */ - protected void applyBindPose() { + public void applyBindPose() { jointModelTransform.applyBindPose(localTransform, inverseModelBindMatrix, parent); updateModelTransforms(); diff --git a/jme3-core/src/main/java/com/jme3/anim/MorphTrack.java b/jme3-core/src/main/java/com/jme3/anim/MorphTrack.java index cd662c11e5..a72456c72e 100644 --- a/jme3-core/src/main/java/com/jme3/anim/MorphTrack.java +++ b/jme3-core/src/main/java/com/jme3/anim/MorphTrack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,11 +32,9 @@ package com.jme3.anim; import com.jme3.anim.interpolator.FrameInterpolator; -import com.jme3.animation.*; import com.jme3.export.*; import com.jme3.scene.Geometry; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; @@ -79,7 +77,7 @@ public MorphTrack(Geometry target, float[] times, float[] weights, int nbMorphTa /** * return the array of weights of this track * - * @return + * @return the pre-existing array */ public float[] getWeights() { return weights; @@ -88,7 +86,7 @@ public float[] getWeights() { /** * returns the arrays of time for this track * - * @return + * @return the pre-existing array */ public float[] getTimes() { return times; diff --git a/jme3-core/src/main/java/com/jme3/anim/SkinningControl.java b/jme3-core/src/main/java/com/jme3/anim/SkinningControl.java index 097840e815..02f4808256 100644 --- a/jme3-core/src/main/java/com/jme3/anim/SkinningControl.java +++ b/jme3-core/src/main/java/com/jme3/anim/SkinningControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2017 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -409,7 +409,7 @@ public Node getAttachmentsNode(String jointName) { /** * returns the armature of this control * - * @return + * @return the pre-existing instance */ public Armature getArmature() { return armature; diff --git a/jme3-core/src/main/java/com/jme3/anim/TransformTrack.java b/jme3-core/src/main/java/com/jme3/anim/TransformTrack.java index dee2aefb93..29354fead0 100644 --- a/jme3-core/src/main/java/com/jme3/anim/TransformTrack.java +++ b/jme3-core/src/main/java/com/jme3/anim/TransformTrack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,14 +32,12 @@ package com.jme3.anim; import com.jme3.anim.interpolator.FrameInterpolator; -import com.jme3.anim.tween.Tween; import com.jme3.anim.util.HasLocalTransform; import com.jme3.animation.CompactQuaternionArray; import com.jme3.animation.CompactVector3Array; import com.jme3.export.*; import com.jme3.math.*; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; @@ -84,7 +82,7 @@ public TransformTrack(HasLocalTransform target, float[] times, Vector3f[] transl /** * return the array of rotations of this track * - * @return + * @return an array */ public Quaternion[] getRotations() { return rotations.toObjectArray(); @@ -93,7 +91,7 @@ public Quaternion[] getRotations() { /** * returns the array of scales for this track * - * @return + * @return an array or null */ public Vector3f[] getScales() { return scales == null ? null : scales.toObjectArray(); @@ -102,7 +100,7 @@ public Vector3f[] getScales() { /** * returns the arrays of time for this track * - * @return + * @return the pre-existing array */ public float[] getTimes() { return times; @@ -111,7 +109,7 @@ public float[] getTimes() { /** * returns the array of translations of this track * - * @return + * @return an array */ public Vector3f[] getTranslations() { return translations.toObjectArray(); diff --git a/jme3-core/src/main/java/com/jme3/anim/tween/AbstractTween.java b/jme3-core/src/main/java/com/jme3/anim/tween/AbstractTween.java index 272ec8dae9..34d4fb83e3 100644 --- a/jme3-core/src/main/java/com/jme3/anim/tween/AbstractTween.java +++ b/jme3-core/src/main/java/com/jme3/anim/tween/AbstractTween.java @@ -36,10 +36,8 @@ package com.jme3.anim.tween; - -import com.jme3.export.*; - -import java.io.IOException; +import com.jme3.util.clone.Cloner; +import com.jme3.util.clone.JmeCloneable; /** * Base implementation of the Tween interface that provides @@ -50,7 +48,7 @@ * * @author Paul Speed */ -public abstract class AbstractTween implements Tween { +public abstract class AbstractTween implements JmeCloneable, Tween { private double length; @@ -94,4 +92,32 @@ public boolean interpolate(double t) { } protected abstract void doInterpolate(double t); + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new tween (not null) + */ + @Override + public AbstractTween jmeClone() { + try { + AbstractTween clone = (AbstractTween) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned tween into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this tween (not null) + * @param original the tween from which this tween was shallow-cloned + * (unused) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + } } diff --git a/jme3-core/src/main/java/com/jme3/anim/tween/Tween.java b/jme3-core/src/main/java/com/jme3/anim/tween/Tween.java index 9ed4752c87..e79b4d29e6 100644 --- a/jme3-core/src/main/java/com/jme3/anim/tween/Tween.java +++ b/jme3-core/src/main/java/com/jme3/anim/tween/Tween.java @@ -36,9 +36,6 @@ package com.jme3.anim.tween; - -import com.jme3.export.Savable; - /** * Represents some action that interpolates across input between 0 * and some length value. (For example, movement, rotation, fading.) diff --git a/jme3-core/src/main/java/com/jme3/anim/tween/Tweens.java b/jme3-core/src/main/java/com/jme3/anim/tween/Tweens.java index 54ff3986b1..0fedf9b75a 100644 --- a/jme3-core/src/main/java/com/jme3/anim/tween/Tweens.java +++ b/jme3-core/src/main/java/com/jme3/anim/tween/Tweens.java @@ -378,7 +378,7 @@ public Stretch(Tween delegate, double length) { this.length = length; // Caller desires delegate to be 'length' instead of - // it's actual length so we will calculate a time scale + // its actual length so we will calculate a time scale // If the desired length is longer than delegate's then // we need to feed time in slower, ie: scale < 1 if (length != 0) { diff --git a/jme3-core/src/main/java/com/jme3/anim/tween/action/Action.java b/jme3-core/src/main/java/com/jme3/anim/tween/action/Action.java index e4038caff0..6846f91460 100644 --- a/jme3-core/src/main/java/com/jme3/anim/tween/action/Action.java +++ b/jme3-core/src/main/java/com/jme3/anim/tween/action/Action.java @@ -2,8 +2,10 @@ import com.jme3.anim.AnimationMask; import com.jme3.anim.tween.Tween; +import com.jme3.util.clone.Cloner; +import com.jme3.util.clone.JmeCloneable; -public abstract class Action implements Tween { +public abstract class Action implements JmeCloneable, Tween { protected Action[] actions; private double length; @@ -67,4 +69,34 @@ protected void setForward(boolean forward) { } } + + /** + * Create a shallow clone for the JME cloner. + * + * @return a new action (not null) + */ + @Override + public Action jmeClone() { + try { + Action clone = (Action) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned action into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this action (not null) + * @param original the action from which this action was shallow-cloned + * (unused) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + actions = cloner.clone(actions); + mask = cloner.clone(mask); + } } diff --git a/jme3-core/src/main/java/com/jme3/anim/tween/action/BaseAction.java b/jme3-core/src/main/java/com/jme3/anim/tween/action/BaseAction.java index d2e8913430..7de04bc742 100644 --- a/jme3-core/src/main/java/com/jme3/anim/tween/action/BaseAction.java +++ b/jme3-core/src/main/java/com/jme3/anim/tween/action/BaseAction.java @@ -4,7 +4,6 @@ import com.jme3.anim.tween.Tween; import com.jme3.util.SafeArrayList; -import java.util.Collections; import java.util.List; public class BaseAction extends Action { diff --git a/jme3-core/src/main/java/com/jme3/anim/tween/action/BlendableAction.java b/jme3-core/src/main/java/com/jme3/anim/tween/action/BlendableAction.java index 0ba79d8416..4b3b6f9660 100644 --- a/jme3-core/src/main/java/com/jme3/anim/tween/action/BlendableAction.java +++ b/jme3-core/src/main/java/com/jme3/anim/tween/action/BlendableAction.java @@ -3,9 +3,8 @@ import com.jme3.anim.tween.AbstractTween; import com.jme3.anim.tween.Tween; import com.jme3.anim.util.HasLocalTransform; -import com.jme3.math.FastMath; import com.jme3.math.Transform; - +import com.jme3.util.clone.Cloner; import java.util.Collection; public abstract class BlendableAction extends Action { @@ -81,6 +80,37 @@ protected float getTransitionWeight() { return transitionWeight; } + /** + * Create a shallow clone for the JME cloner. + * + * @return a new action (not null) + */ + @Override + public BlendableAction jmeClone() { + try { + BlendableAction clone = (BlendableAction) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned action into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this action (not null) + * @param original the action from which this action was shallow-cloned + * (unused) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + super.cloneFields(cloner, original); + collectTransformDelegate = cloner.clone(collectTransformDelegate); + transition = cloner.clone(transition); + } + private class TransitionTween extends AbstractTween { diff --git a/jme3-core/src/main/java/com/jme3/anim/tween/action/ClipAction.java b/jme3-core/src/main/java/com/jme3/anim/tween/action/ClipAction.java index 9f0d49f200..fdf211962a 100644 --- a/jme3-core/src/main/java/com/jme3/anim/tween/action/ClipAction.java +++ b/jme3-core/src/main/java/com/jme3/anim/tween/action/ClipAction.java @@ -1,11 +1,10 @@ package com.jme3.anim.tween.action; import com.jme3.anim.*; -import com.jme3.anim.tween.AbstractTween; import com.jme3.anim.util.HasLocalTransform; import com.jme3.math.Transform; import com.jme3.scene.Geometry; - +import com.jme3.util.clone.Cloner; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -90,5 +89,34 @@ public void collectTransform(HasLocalTransform target, Transform t, float weight } } + /** + * Create a shallow clone for the JME cloner. + * + * @return a new action (not null) + */ + @Override + public ClipAction jmeClone() { + try { + ClipAction clone = (ClipAction) super.clone(); + return clone; + } catch (CloneNotSupportedException exception) { + throw new RuntimeException(exception); + } + } + /** + * Callback from {@link com.jme3.util.clone.Cloner} to convert this + * shallow-cloned action into a deep-cloned one, using the specified cloner + * and original to resolve copied fields. + * + * @param cloner the cloner that's cloning this action (not null) + * @param original the action from which this action was shallow-cloned + * (unused) + */ + @Override + public void cloneFields(Cloner cloner, Object original) { + super.cloneFields(cloner, original); + clip = cloner.clone(clip); + transform = cloner.clone(transform); + } } diff --git a/jme3-core/src/main/java/com/jme3/anim/util/Weighted.java b/jme3-core/src/main/java/com/jme3/anim/util/Weighted.java index 8fb6d32552..f771d44edd 100644 --- a/jme3-core/src/main/java/com/jme3/anim/util/Weighted.java +++ b/jme3-core/src/main/java/com/jme3/anim/util/Weighted.java @@ -1,7 +1,6 @@ package com.jme3.anim.util; import com.jme3.anim.tween.action.Action; -import com.jme3.math.Transform; public interface Weighted { diff --git a/jme3-core/src/main/java/com/jme3/animation/Animation.java b/jme3-core/src/main/java/com/jme3/animation/Animation.java index 8345952382..fe0ac8ce43 100644 --- a/jme3-core/src/main/java/com/jme3/animation/Animation.java +++ b/jme3-core/src/main/java/com/jme3/animation/Animation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -194,7 +194,7 @@ public Animation clone() { /** * * @param spat - * @return + * @return a new instance */ public Animation cloneForSpatial(Spatial spat) { try { @@ -264,7 +264,7 @@ public void read(JmeImporter im) throws IOException { // NOTE: Backward compat only .. Some animations have no // tracks set at all even though it makes no sense. // Since there's a null check in setTime(), - // its only appropriate that the check is made here as well. + // it's only appropriate that the check is made here as well. tracks = new SafeArrayList(Track.class); for (Savable savable : arr) { tracks.add((Track) savable); diff --git a/jme3-core/src/main/java/com/jme3/animation/AnimationFactory.java b/jme3-core/src/main/java/com/jme3/animation/AnimationFactory.java index 53a7c8ede4..0b0a435c76 100644 --- a/jme3-core/src/main/java/com/jme3/animation/AnimationFactory.java +++ b/jme3-core/src/main/java/com/jme3/animation/AnimationFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -443,7 +443,7 @@ private void interpolate(Object[] keyFrames, Type type) { //jumping to the next keyFrame i = key; } else { - //No more key frame, filling the array witht he last transform computed. + //No more key frame, filling the array with the last transform computed. for (int j = i; j < totalFrames; j++) { switch (type) { diff --git a/jme3-core/src/main/java/com/jme3/animation/AnimationUtils.java b/jme3-core/src/main/java/com/jme3/animation/AnimationUtils.java index 2254638e74..f7f2c54ddd 100644 --- a/jme3-core/src/main/java/com/jme3/animation/AnimationUtils.java +++ b/jme3-core/src/main/java/com/jme3/animation/AnimationUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ public AnimationUtils(){ * @param time * @param duration * @param loopMode - * @return + * @return the clamped time (in seconds) */ public static float clampWrapTime(float time, float duration, LoopMode loopMode){ if (time == 0 || duration == 0) { diff --git a/jme3-core/src/main/java/com/jme3/animation/AudioTrack.java b/jme3-core/src/main/java/com/jme3/animation/AudioTrack.java index 300287c1e3..1f9df35e63 100644 --- a/jme3-core/src/main/java/com/jme3/animation/AudioTrack.java +++ b/jme3-core/src/main/java/com/jme3/animation/AudioTrack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -158,7 +158,7 @@ public float[] getKeyFrameTimes() { /** * Clone this track * - * @return + * @return a new track */ @Override public Track clone() { diff --git a/jme3-core/src/main/java/com/jme3/animation/Bone.java b/jme3-core/src/main/java/com/jme3/animation/Bone.java index edc1b88945..6c99e5b99f 100644 --- a/jme3-core/src/main/java/com/jme3/animation/Bone.java +++ b/jme3-core/src/main/java/com/jme3/animation/Bone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -961,7 +961,7 @@ public void setLocalScale(Vector3f scale){ /** * returns true if this bone can be directly manipulated by the user. * @see #setUserControl(boolean) - * @return + * @return true if can be manipulated */ public boolean hasUserControl(){ return userControl; diff --git a/jme3-core/src/main/java/com/jme3/animation/BoneTrack.java b/jme3-core/src/main/java/com/jme3/animation/BoneTrack.java index a39108c5a8..3d613984cf 100644 --- a/jme3-core/src/main/java/com/jme3/animation/BoneTrack.java +++ b/jme3-core/src/main/java/com/jme3/animation/BoneTrack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,7 @@ * Contains a list of transforms and times for each keyframe. * * @author Kirill Vainer - * @deprecated use {@link com.jme3.anim.JointTrack} + * @deprecated use {@link com.jme3.anim.AnimTrack} */ @Deprecated public final class BoneTrack implements JmeCloneable, Track { @@ -110,7 +110,7 @@ public int getTargetBoneIndex() { /** * return the array of rotations of this track - * @return + * @return an array */ public Quaternion[] getRotations() { return rotations.toObjectArray(); @@ -118,7 +118,7 @@ public Quaternion[] getRotations() { /** * returns the array of scales for this track - * @return + * @return an array or null */ public Vector3f[] getScales() { return scales == null ? null : scales.toObjectArray(); @@ -126,7 +126,7 @@ public Vector3f[] getScales() { /** * returns the arrays of time for this track - * @return + * @return the pre-existing array */ public float[] getTimes() { return times; @@ -134,7 +134,7 @@ public float[] getTimes() { /** * returns the array of translations of this track - * @return + * @return an array */ public Vector3f[] getTranslations() { return translations.toObjectArray(); diff --git a/jme3-core/src/main/java/com/jme3/animation/CompactArray.java b/jme3-core/src/main/java/com/jme3/animation/CompactArray.java index b64e0785ce..54516145a4 100644 --- a/jme3-core/src/main/java/com/jme3/animation/CompactArray.java +++ b/jme3-core/src/main/java/com/jme3/animation/CompactArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -131,7 +131,7 @@ public final void set(int index, T value) { * returns the object for the given index * @param index the index * @param store an object to store the result - * @return + * @return an element */ public final T get(int index, T store) { serialize(); @@ -141,7 +141,7 @@ public final T get(int index, T store) { /** * return a float array of serialized data - * @return + * @return the pre-existing array */ public final float[] getSerializedData() { serialize(); @@ -177,7 +177,7 @@ protected final int getSerializedSize() { * Ensure the capacity for the given array and the given size * @param arr the array * @param size the size - * @return + * @return an array */ protected float[] ensureCapacity(float[] arr, int size) { if (arr == null) { @@ -195,7 +195,7 @@ protected float[] ensureCapacity(float[] arr, int size) { /** * Return an array of indices for the given objects * @param objArray - * @return + * @return a new array */ @SuppressWarnings("unchecked") public final int[] getIndex(T... objArray) { diff --git a/jme3-core/src/main/java/com/jme3/animation/CompactFloatArray.java b/jme3-core/src/main/java/com/jme3/animation/CompactFloatArray.java index a879ef1cb2..097bfa4009 100644 --- a/jme3-core/src/main/java/com/jme3/animation/CompactFloatArray.java +++ b/jme3-core/src/main/java/com/jme3/animation/CompactFloatArray.java @@ -32,7 +32,6 @@ package com.jme3.animation; import com.jme3.export.*; -import com.jme3.math.Vector3f; import java.io.IOException; diff --git a/jme3-core/src/main/java/com/jme3/animation/EffectTrack.java b/jme3-core/src/main/java/com/jme3/animation/EffectTrack.java index a05b481c4b..597237d245 100644 --- a/jme3-core/src/main/java/com/jme3/animation/EffectTrack.java +++ b/jme3-core/src/main/java/com/jme3/animation/EffectTrack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -247,7 +247,7 @@ public float[] getKeyFrameTimes() { /** * Clone this track * - * @return + * @return a new instance */ @Override public Track clone() { diff --git a/jme3-core/src/main/java/com/jme3/animation/Skeleton.java b/jme3-core/src/main/java/com/jme3/animation/Skeleton.java index 651bf06a3e..e29ffb3cc8 100644 --- a/jme3-core/src/main/java/com/jme3/animation/Skeleton.java +++ b/jme3-core/src/main/java/com/jme3/animation/Skeleton.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -203,7 +203,7 @@ public final void resetAndUpdate() { /** * returns the array of all root bones of this skeleton - * @return + * @return the pre-existing array */ public Bone[] getRoots() { return rootBones; @@ -212,7 +212,7 @@ public Bone[] getRoots() { /** * return a bone for the given index * @param index - * @return + * @return the pre-existing instance */ public Bone getBone(int index) { return boneList[index]; @@ -221,7 +221,7 @@ public Bone getBone(int index) { /** * returns the bone with the given name * @param name - * @return + * @return the pre-existing instance, or null if not found */ public Bone getBone(String name) { for (int i = 0; i < boneList.length; i++) { @@ -235,7 +235,7 @@ public Bone getBone(String name) { /** * returns the bone index of the given bone * @param bone - * @return + * @return the index (≥0) or -1 if not found */ public int getBoneIndex(Bone bone) { for (int i = 0; i < boneList.length; i++) { @@ -250,7 +250,7 @@ public int getBoneIndex(Bone bone) { /** * returns the bone index of the bone that has the given name * @param name - * @return + * @return the index (≥0) or -1 if not found */ public int getBoneIndex(String name) { for (int i = 0; i < boneList.length; i++) { @@ -263,8 +263,8 @@ public int getBoneIndex(String name) { } /** - * Compute the skining matrices for each bone of the skeleton that would be used to transform vertices of associated meshes - * @return + * Compute the skinning matrices for each bone of the skeleton that would be used to transform vertices of associated meshes + * @return the pre-existing matrices */ public Matrix4f[] computeSkinningMatrices() { TempVars vars = TempVars.get(); @@ -277,7 +277,7 @@ public Matrix4f[] computeSkinningMatrices() { /** * returns the number of bones of this skeleton - * @return + * @return the count (≥0) */ public int getBoneCount() { return boneList.length; diff --git a/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java b/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java index 06f6927ab5..2f54771dbc 100644 --- a/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java +++ b/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -405,7 +405,7 @@ public Node getAttachmentsNode(String boneName) { /** * returns the skeleton of this control * - * @return + * @return the pre-existing instance */ public Skeleton getSkeleton() { return skeleton; diff --git a/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java b/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java index d652e4488f..6987ebc048 100644 --- a/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java +++ b/jme3-core/src/main/java/com/jme3/app/BasicProfiler.java @@ -187,6 +187,10 @@ public void appStep( AppStep step ) { } } + @Override + public void appSubStep(String... additionalInfo) { + } + @Override public void vpStep( VpStep step, ViewPort vp, Bucket bucket ) { } diff --git a/jme3-core/src/main/java/com/jme3/app/ChaseCameraAppState.java b/jme3-core/src/main/java/com/jme3/app/ChaseCameraAppState.java index 2aa8bebb62..1823e18ac9 100644 --- a/jme3-core/src/main/java/com/jme3/app/ChaseCameraAppState.java +++ b/jme3-core/src/main/java/com/jme3/app/ChaseCameraAppState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -348,7 +348,7 @@ public void setMinVerticalRotation(float minHeight) { /** * returns the zoom speed * - * @return + * @return the speed */ public float getZoomSpeed() { return zoomSpeed; @@ -358,7 +358,7 @@ public float getZoomSpeed() { * Sets the zoom speed, the lower the value, the slower the camera will zoom * in and out. default is 2. * - * @param zoomSpeed + * @param zoomSpeed the speed */ public void setZoomSpeed(float zoomSpeed) { this.zoomSpeed = zoomSpeed; @@ -415,7 +415,7 @@ public void setDefaultVerticalRotation(float angleInRad) { /** * @return If drag to rotate feature is enabled. * - * @see FlyByCamera#setDragToRotate(boolean) + * @see #setDragToRotate(boolean) */ public boolean isDragToRotate() { return dragToRotate; diff --git a/jme3-core/src/main/java/com/jme3/app/DetailedProfiler.java b/jme3-core/src/main/java/com/jme3/app/DetailedProfiler.java index 403af46ad6..e5673df53c 100644 --- a/jme3-core/src/main/java/com/jme3/app/DetailedProfiler.java +++ b/jme3-core/src/main/java/com/jme3/app/DetailedProfiler.java @@ -87,6 +87,17 @@ public void appStep(AppStep step) { closeFrame(); } } + + + @Override + public void appSubStep(String... additionalInfo) { + if (data != null) { + String pathStep = getPath("", additionalInfo); + path.setLength(0); + path.append(curAppPath).append(pathStep); + addStep(path.toString(), System.nanoTime()); + } + } private void closeFrame() { //close frame diff --git a/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java b/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java index d796ba3095..1cc53b75e3 100644 --- a/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java +++ b/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -485,16 +485,15 @@ public AppProfiler getAppProfiler() { /** * Initializes the application's canvas for use. *

- * After calling this method, cast the {@link #getContext() context} to - * {@link JmeCanvasContext}, - * then acquire the canvas with {@link JmeCanvasContext#getCanvas() } + * After calling this method, cast the {@link #getContext()} context to + * JmeCanvasContext, + * then acquire the canvas with JmeCanvasContext.getCanvas() * and attach it to an AWT/Swing Frame. * The rendering thread will start when the canvas becomes visible on * screen, however if you wish to start the context immediately you * may call {@link #startCanvas() } to force the rendering thread * to start. * - * @see JmeCanvasContext * @see Type#Canvas */ public void createCanvas(){ diff --git a/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java b/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java index 01c04601c2..5a1fab7a94 100644 --- a/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java +++ b/jme3-core/src/main/java/com/jme3/app/SimpleApplication.java @@ -124,6 +124,23 @@ public void start() { setSettings(settings); super.start(); } + + /** + * Returns the applications speed. + * + * @return The speed of the application. + */ + public float getSpeed() { + return speed; + } + + /** + * Changes the application speed. 0.0f prevents the application from updating. + * @param speed The speed to set. + */ + public void setSpeed(float speed) { + this.speed = speed; + } /** * Retrieves flyCam diff --git a/jme3-core/src/main/java/com/jme3/app/package.html b/jme3-core/src/main/java/com/jme3/app/package.html index ec6bb9a898..63d18c955c 100644 --- a/jme3-core/src/main/java/com/jme3/app/package.html +++ b/jme3-core/src/main/java/com/jme3/app/package.html @@ -50,7 +50,6 @@

Usage

app.start();
}

- @Override
public void initialize(){
super.initialize();

@@ -58,7 +57,6 @@

Usage

viewPort.attachScene(rootNode);
}

- @Override
public void update(){
super.update();

diff --git a/jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java b/jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java index 177fcb22fb..b15b555989 100644 --- a/jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java +++ b/jme3-core/src/main/java/com/jme3/app/state/AppStateManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,6 +32,7 @@ package com.jme3.app.state; import com.jme3.app.Application; +import com.jme3.profile.AppProfiler; import com.jme3.renderer.RenderManager; import com.jme3.util.SafeArrayList; import java.util.Arrays; @@ -210,6 +211,18 @@ public boolean hasState(AppState state){ * @return First attached state that is an instance of stateClass */ public T getState(Class stateClass){ + return getState(stateClass, false); + } + + /** + * Returns the first state that is an instance of subclass of the specified class. + * @param + * @param stateClass + * @param failOnMiss + * @return First attached state that is an instance of stateClass. If failOnMiss is true + * then an IllegalArgumentException is thrown if the state is not attached. + */ + public T getState(Class stateClass, boolean failOnMiss){ synchronized (states){ AppState[] array = getStates(); for (AppState state : array) { @@ -218,7 +231,7 @@ public T getState(Class stateClass){ } } - // This may be more trouble than its worth but I think + // This may be more trouble than it's worth but I think // it's necessary for proper decoupling of states and provides // similar behavior to before where a state could be looked // up even if it wasn't initialized. -pspeed @@ -229,6 +242,10 @@ public T getState(Class stateClass){ } } } + + if(failOnMiss) { + throw new IllegalArgumentException("State not found for:" + stateClass); + } return null; } @@ -284,6 +301,9 @@ public void update(float tpf){ AppState[] array = getStates(); for (AppState state : array){ if (state.isEnabled()) { + if (app.getAppProfiler() != null) { + app.getAppProfiler().appSubStep(state.getClass().getSimpleName()); + } state.update(tpf); } } diff --git a/jme3-core/src/main/java/com/jme3/app/state/BaseAppState.java b/jme3-core/src/main/java/com/jme3/app/state/BaseAppState.java index a8a80f19eb..cee045355e 100644 --- a/jme3-core/src/main/java/com/jme3/app/state/BaseAppState.java +++ b/jme3-core/src/main/java/com/jme3/app/state/BaseAppState.java @@ -142,7 +142,11 @@ public final AppStateManager getStateManager() { } public final T getState( Class type ) { - return getStateManager().getState(type); + return getState( type, false ); + } + + public final T getState( Class type, boolean failOnMiss ) { + return getStateManager().getState( type, failOnMiss ); } @Override diff --git a/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java b/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java index 6fa35c2d72..4a2b1acc89 100644 --- a/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java +++ b/jme3-core/src/main/java/com/jme3/app/state/ScreenshotAppState.java @@ -45,7 +45,6 @@ import com.jme3.renderer.queue.RenderQueue; import com.jme3.system.JmeSystem; import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image; import com.jme3.util.BufferUtils; import java.io.File; import java.io.FileOutputStream; diff --git a/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java b/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java index 71c4d8bb17..bef9cfecef 100644 --- a/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java +++ b/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.io.InputStream; -import java.net.URISyntaxException; import java.net.URL; import java.util.Locale; import java.util.Scanner; diff --git a/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java b/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java index 94ee68ceb3..bf6b41b7ab 100644 --- a/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java +++ b/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -258,12 +258,12 @@ protected T loadLocatedAsset(AssetKey key, AssetInfo info, AssetProcessor handler.establishParentKey(key); obj = loader.load(info); } catch (IOException ex) { - throw new AssetLoadException("An exception has occured while loading asset: " + key, ex); + throw new AssetLoadException("An exception has occurred while loading asset: " + key, ex); } finally { handler.releaseParentKey(key); } if (obj == null) { - throw new AssetLoadException("Error occured while loading asset \"" + throw new AssetLoadException("Error occurred while loading asset \"" + key + "\" using " + loader.getClass().getSimpleName()); } else { if (logger.isLoggable(Level.FINER)) { diff --git a/jme3-core/src/main/java/com/jme3/audio/AudioNode.java b/jme3-core/src/main/java/com/jme3/audio/AudioNode.java index 862348b635..becc7fa19e 100644 --- a/jme3-core/src/main/java/com/jme3/audio/AudioNode.java +++ b/jme3-core/src/main/java/com/jme3/audio/AudioNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012, 2016, 2018 jMonkeyEngine + * Copyright (c) 2009-2012, 2016, 2018-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -299,7 +299,7 @@ public void setDryFilter(Filter dryFilter) { */ public void setAudioData(AudioData audioData, AudioKey audioKey) { if (data != null) { - throw new IllegalStateException("Cannot change data once its set"); + throw new IllegalStateException("Cannot change data once it's set"); } data = audioData; @@ -490,7 +490,7 @@ public boolean isReverbEnabled() { /** * Set to true to enable reverberation effects for this audio node. * Does nothing if the audio node is not positional. - *
+ *
* When enabled, the audio environment set with * {@link AudioRenderer#setEnvironment(com.jme3.audio.Environment) } * will apply a reverb effect to the audio playing from this audio node. diff --git a/jme3-core/src/main/java/com/jme3/audio/AudioRenderer.java b/jme3-core/src/main/java/com/jme3/audio/AudioRenderer.java index 695999e482..f10fd5d267 100644 --- a/jme3-core/src/main/java/com/jme3/audio/AudioRenderer.java +++ b/jme3-core/src/main/java/com/jme3/audio/AudioRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ public interface AudioRenderer { /** * Sets the environment, used for reverb effects. * - * @see AudioSource#setReverbEnabled(boolean) + * @see AudioNode#setReverbEnabled(boolean) * @param env The environment to set. */ public void setEnvironment(Environment env); diff --git a/jme3-core/src/main/java/com/jme3/audio/AudioSource.java b/jme3-core/src/main/java/com/jme3/audio/AudioSource.java index 75a4e70f9b..de2540022c 100644 --- a/jme3-core/src/main/java/com/jme3/audio/AudioSource.java +++ b/jme3-core/src/main/java/com/jme3/audio/AudioSource.java @@ -17,7 +17,7 @@ public interface AudioSource { public enum Status { /** * The audio source is currently playing. This will be set if - * {@link AudioSource#play() } is called. + * {@link AudioNode#play()} is called. */ Playing, @@ -28,7 +28,7 @@ public enum Status { /** * The audio source is currently stopped. - * This will be set if {@link AudioSource#stop() } is called + * This will be set if {@link AudioNode#stop()} is called * or the audio has reached the end of the file. */ Stopped, @@ -47,13 +47,13 @@ public enum Status { /** * @return The {#link Filter dry filter} that is set. - * @see AudioSource#setDryFilter(com.jme3.audio.Filter) + * @see AudioNode#setDryFilter(com.jme3.audio.Filter) */ public Filter getDryFilter(); /** * @return The {@link AudioData} set previously with - * {@link AudioSource#setAudioData(com.jme3.audio.AudioData, com.jme3.audio.AudioKey) } + * {@link AudioNode#setAudioData(com.jme3.audio.AudioData, com.jme3.audio.AudioKey)} * or any of the constructors that initialize the audio data. */ public AudioData getAudioData(); @@ -65,34 +65,34 @@ public enum Status { /** * @return The {@link Status} of the audio source. - * The status will be changed when either the {@link AudioSource#play() } - * or {@link AudioSource#stop() } methods are called. + * The status will be changed when either the {@link AudioNode#play()} + * or {@link AudioNode#stop()} methods are called. */ public Status getStatus(); /** * @return True if the audio will keep looping after it is done playing, * otherwise, false. - * @see AudioSource#setLooping(boolean) + * @see AudioNode#setLooping(boolean) */ public boolean isLooping(); /** * @return The pitch of the audio, also the speed of playback. * - * @see AudioSource#setPitch(float) + * @see AudioNode#setPitch(float) */ public float getPitch(); /** * @return The volume of this audio source. * - * @see AudioSource#setVolume(float) + * @see AudioNode#setVolume(float) */ public float getVolume(); /** - * @return the time offset in the sound sample when to start playing. + * @return the time offset in the sound sample to start playing */ public float getTimeOffset(); @@ -102,79 +102,77 @@ public enum Status { public float getPlaybackTime(); /** - * @return The velocity of the audio source. - * - * @see AudioSource#setVelocity(com.jme3.math.Vector3f) + * @return The position of the audio source. */ public Vector3f getPosition(); /** * @return The velocity of the audio source. * - * @see AudioSource#setVelocity(com.jme3.math.Vector3f) + * @see AudioNode#setVelocity(com.jme3.math.Vector3f) */ public Vector3f getVelocity(); /** * @return True if reverb is enabled, otherwise false. * - * @see AudioSource#setReverbEnabled(boolean) + * @see AudioNode#setReverbEnabled(boolean) */ public boolean isReverbEnabled(); /** * @return Filter for the reverberations of this audio source. * - * @see AudioSource#setReverbFilter(com.jme3.audio.Filter) + * @see AudioNode#setReverbFilter(com.jme3.audio.Filter) */ public Filter getReverbFilter(); /** * @return Max distance for this audio source. * - * @see AudioSource#setMaxDistance(float) + * @see AudioNode#setMaxDistance(float) */ public float getMaxDistance(); /** * @return The reference playing distance for the audio source. * - * @see AudioSource#setRefDistance(float) + * @see AudioNode#setRefDistance(float) */ public float getRefDistance(); /** * @return True if the audio source is directional * - * @see AudioSource#setDirectional(boolean) + * @see AudioNode#setDirectional(boolean) */ public boolean isDirectional(); /** * @return The direction of this audio source. * - * @see AudioSource#setDirection(com.jme3.math.Vector3f) + * @see AudioNode#setDirection(com.jme3.math.Vector3f) */ public Vector3f getDirection(); /** * @return The directional audio source, cone inner angle. * - * @see AudioSource#setInnerAngle(float) + * @see AudioNode#setInnerAngle(float) */ public float getInnerAngle(); /** * @return The directional audio source, cone outer angle. * - * @see AudioSource#setOuterAngle(float) + * @see AudioNode#setOuterAngle(float) */ public float getOuterAngle(); /** * @return True if the audio source is positional. * - * @see AudioSource#setPositional(boolean) + * @see AudioNode#setPositional(boolean) */ public boolean isPositional(); diff --git a/jme3-core/src/main/java/com/jme3/audio/AudioStream.java b/jme3-core/src/main/java/com/jme3/audio/AudioStream.java index 598ae189c2..1047c673bc 100644 --- a/jme3-core/src/main/java/com/jme3/audio/AudioStream.java +++ b/jme3-core/src/main/java/com/jme3/audio/AudioStream.java @@ -35,7 +35,6 @@ import java.io.Closeable; import java.io.IOException; import java.io.InputStream; -import java.util.logging.Level; import java.util.logging.Logger; /** diff --git a/jme3-core/src/main/java/com/jme3/audio/openal/ALAudioRenderer.java b/jme3-core/src/main/java/com/jme3/audio/openal/ALAudioRenderer.java index 82c588d4dc..a4bcddeead 100644 --- a/jme3-core/src/main/java/com/jme3/audio/openal/ALAudioRenderer.java +++ b/jme3-core/src/main/java/com/jme3/audio/openal/ALAudioRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -897,7 +897,7 @@ public void updateInRenderThread(float tpf) { reclaimChannel = true; } else { // Stream still has data. - // Buffer starvation occured. + // Buffer starvation occurred. // Audio decoder thread will fill the data // and start the channel again. } diff --git a/jme3-core/src/main/java/com/jme3/cinematic/Cinematic.java b/jme3-core/src/main/java/com/jme3/cinematic/Cinematic.java index c14ac9dbd1..d9e9d5b11f 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/Cinematic.java +++ b/jme3-core/src/main/java/com/jme3/cinematic/Cinematic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,13 +41,10 @@ import com.jme3.export.*; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; -import com.jme3.renderer.ViewPort; import com.jme3.scene.CameraNode; import com.jme3.scene.Node; -import com.jme3.scene.Spatial; import com.jme3.scene.control.CameraControl; import com.jme3.scene.control.CameraControl.ControlDirection; -import com.jme3.scene.control.Control; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -288,7 +285,7 @@ public void initialize(AppStateManager stateManager, Application app) { /** * used internally * - * @return + * @return true if initialized, otherwise false */ public boolean isInitialized() { return initialized; @@ -639,7 +636,7 @@ public void putEventData(String type, Object key, Object object) { * * @param type the type of data * @param key the key - * @return + * @return the pre-existing object, or null */ public Object getEventData(String type, Object key) { if (eventsData != null) { diff --git a/jme3-core/src/main/java/com/jme3/cinematic/MotionPath.java b/jme3-core/src/main/java/com/jme3/cinematic/MotionPath.java index 4e3a0df89f..a0f978f0a1 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/MotionPath.java +++ b/jme3-core/src/main/java/com/jme3/cinematic/MotionPath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -244,7 +244,7 @@ public void removeWayPoint(int i) { /** * returns an iterator on the waypoints collection - * @return + * @return an iterator */ public Iterator iterator() { return spline.getControlPoints().iterator(); @@ -317,7 +317,7 @@ public void removeListener(MotionPathListener listener) { /** * return the number of waypoints of this path - * @return + * @return the count (≥0) */ public int getNbWayPoints() { return spline.getControlPoints().size(); @@ -334,7 +334,7 @@ public void triggerWayPointReach(int wayPointIndex, MotionEvent control) { /** * Returns the curve tension - * @return + * @return the curve tension */ public float getCurveTension() { return spline.getCurveTension(); @@ -378,7 +378,7 @@ public void setCycle(boolean cycle) { /** * returns true if the path is a cycle - * @return + * @return true if the path is a cycle */ public boolean isCycle() { return spline.isCycle(); diff --git a/jme3-core/src/main/java/com/jme3/cinematic/events/AbstractCinematicEvent.java b/jme3-core/src/main/java/com/jme3/cinematic/events/AbstractCinematicEvent.java index 695eb93490..6fb4899c36 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/events/AbstractCinematicEvent.java +++ b/jme3-core/src/main/java/com/jme3/cinematic/events/AbstractCinematicEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -200,7 +200,7 @@ public void pause() { /** * Returns the actual duration of the animation (initialDuration/speed) - * @return + * @return the duration (in seconds) */ public float getDuration() { return initialDuration / speed; @@ -218,7 +218,7 @@ public void setSpeed(float speed) { /** * Returns the speed of the animation. - * @return + * @return the speed */ public float getSpeed() { return speed; @@ -226,7 +226,7 @@ public float getSpeed() { /** * Returns the current playstate of the animation (playing or paused or stopped). - * @return + * @return the enum value */ public PlayState getPlayState() { return playState; @@ -234,7 +234,7 @@ public PlayState getPlayState() { /** * Returns the initial duration of the animation at speed = 1 in seconds. - * @return + * @return the duration in seconds */ public float getInitialDuration() { return initialDuration; @@ -251,7 +251,7 @@ public void setInitialDuration(float initialDuration) { /** * Returns the loopMode of the animation. * @see LoopMode - * @return + * @return the enum value */ public LoopMode getLoopMode() { return loopMode; diff --git a/jme3-core/src/main/java/com/jme3/cinematic/events/CameraEvent.java b/jme3-core/src/main/java/com/jme3/cinematic/events/CameraEvent.java index 80d677e3c4..91b9ee5e18 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/events/CameraEvent.java +++ b/jme3-core/src/main/java/com/jme3/cinematic/events/CameraEvent.java @@ -33,15 +33,11 @@ import com.jme3.app.Application; import com.jme3.cinematic.Cinematic; -import com.jme3.cinematic.TimeLine; import com.jme3.export.InputCapsule; import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; -import com.jme3.export.Savable; -import com.jme3.scene.CameraNode; import java.io.IOException; -import java.util.Map; /** * diff --git a/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java b/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java index 60cb5c09ef..e7d217f45f 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java +++ b/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -231,7 +231,7 @@ public void read(JmeImporter im) throws IOException { /** * This method is meant to be called by the motion path only. - * @return + * @return true if needed, otherwise false */ public boolean needsDirection() { return directionType == Direction.Path || directionType == Direction.PathAndRotation; @@ -272,7 +272,7 @@ private void computeTargetDirection() { /** * Clone this control for the given spatial. * @param spatial - * @return + * @return never */ @Deprecated @Override @@ -321,7 +321,7 @@ public void onPause() { /** * This method is meant to be called by the motion path only. - * @return + * @return the value */ public float getCurrentValue() { return currentValue; @@ -337,7 +337,7 @@ public void setCurrentValue(float currentValue) { /** * This method is meant to be called by the motion path only. - * @return + * @return the waypoint index */ public int getCurrentWayPoint() { return currentWayPoint; @@ -353,7 +353,7 @@ public void setCurrentWayPoint(int currentWayPoint) { /** * Returns the direction the spatial is moving. - * @return + * @return the pre-existing vector */ public Vector3f getDirection() { return direction; @@ -431,7 +431,7 @@ public void setRotation(Quaternion rotation) { /** * Return the motion path this control follows. - * @return + * @return the pre-existing instance */ public MotionPath getPath() { return path; @@ -470,7 +470,7 @@ public Spatial getSpatial() { /** * Return the distance traveled by the spatial on the path. - * @return + * @return the distance */ public float getTraveledDistance() { return traveledDistance; diff --git a/jme3-core/src/main/java/com/jme3/cinematic/events/SoundEvent.java b/jme3-core/src/main/java/com/jme3/cinematic/events/SoundEvent.java index 6de7e21f60..fe31678c3b 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/events/SoundEvent.java +++ b/jme3-core/src/main/java/com/jme3/cinematic/events/SoundEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -194,7 +194,7 @@ public void onUpdate(float tpf) { /** * Returns the underlying audio node of this sound track - * @return + * @return the pre-existing instance */ public AudioNode getAudioNode() { return audioNode; diff --git a/jme3-core/src/main/java/com/jme3/collision/CollisionResult.java b/jme3-core/src/main/java/com/jme3/collision/CollisionResult.java index ae271c880a..d66ec62cfc 100644 --- a/jme3-core/src/main/java/com/jme3/collision/CollisionResult.java +++ b/jme3-core/src/main/java/com/jme3/collision/CollisionResult.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,7 @@ /** * A CollisionResult represents a single collision instance * between two {@link Collidable}. A collision check can result in many - * collision instances (places where collision has occured). + * collision instances (places where collision has occurred). * * @author Kirill Vainer */ diff --git a/jme3-core/src/main/java/com/jme3/collision/CollisionResults.java b/jme3-core/src/main/java/com/jme3/collision/CollisionResults.java index 087e143d7e..93c5c81b58 100644 --- a/jme3-core/src/main/java/com/jme3/collision/CollisionResults.java +++ b/jme3-core/src/main/java/com/jme3/collision/CollisionResults.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -130,7 +130,7 @@ public CollisionResult getCollision(int index){ /** * Internal use only. * @param index - * @return + * @return the pre-existing instance */ public CollisionResult getCollisionDirect(int index){ if (results == null) { diff --git a/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java b/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java index ba0c0282dc..020803c876 100644 --- a/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java +++ b/jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -854,7 +854,7 @@ public Vector3f getInitialVelocity() { * Use ParticleEmitter.getParticleInfluencer().setInitialVelocity(initialVelocity); instead. * * @see ParticleEmitter#setVelocityVariation(float) - * @see ParticleEmitter#setGravity(float) + * @see #setGravity(com.jme3.math.Vector3f) */ @Deprecated public void setInitialVelocity(Vector3f initialVelocity) { @@ -876,7 +876,8 @@ public float getVelocityVariation() { * @param variation Set the variation by which the initial velocity * of the particle is determined. variation should be a value * from 0 to 1, where 0 means particles are to spawn with exactly - * the velocity given in {@link ParticleEmitter#setStartVel(com.jme3.math.Vector3f) }, + * the velocity specified in + * {@link com.jme3.effect.influencers.ParticleInfluencer#setInitialVelocity(com.jme3.math.Vector3f)}, * and 1 means particles are to spawn with a completely random velocity. * * @deprecated diff --git a/jme3-core/src/main/java/com/jme3/effect/ParticleMesh.java b/jme3-core/src/main/java/com/jme3/effect/ParticleMesh.java index 7d0d2d92dc..11e05555d9 100644 --- a/jme3-core/src/main/java/com/jme3/effect/ParticleMesh.java +++ b/jme3-core/src/main/java/com/jme3/effect/ParticleMesh.java @@ -31,7 +31,6 @@ */ package com.jme3.effect; -import com.jme3.material.RenderState; import com.jme3.math.Matrix3f; import com.jme3.renderer.Camera; import com.jme3.scene.Mesh; diff --git a/jme3-core/src/main/java/com/jme3/effect/influencers/DefaultParticleInfluencer.java b/jme3-core/src/main/java/com/jme3/effect/influencers/DefaultParticleInfluencer.java index 9cd06f0e37..efe26af495 100644 --- a/jme3-core/src/main/java/com/jme3/effect/influencers/DefaultParticleInfluencer.java +++ b/jme3-core/src/main/java/com/jme3/effect/influencers/DefaultParticleInfluencer.java @@ -40,7 +40,6 @@ import com.jme3.math.FastMath; import com.jme3.math.Vector3f; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; /** diff --git a/jme3-core/src/main/java/com/jme3/effect/influencers/EmptyParticleInfluencer.java b/jme3-core/src/main/java/com/jme3/effect/influencers/EmptyParticleInfluencer.java index 88e938430f..0271df1106 100644 --- a/jme3-core/src/main/java/com/jme3/effect/influencers/EmptyParticleInfluencer.java +++ b/jme3-core/src/main/java/com/jme3/effect/influencers/EmptyParticleInfluencer.java @@ -37,7 +37,6 @@ import com.jme3.export.JmeImporter; import com.jme3.math.Vector3f; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; /** diff --git a/jme3-core/src/main/java/com/jme3/effect/influencers/NewtonianParticleInfluencer.java b/jme3-core/src/main/java/com/jme3/effect/influencers/NewtonianParticleInfluencer.java index b0bc1be251..b2f81f9a8d 100644 --- a/jme3-core/src/main/java/com/jme3/effect/influencers/NewtonianParticleInfluencer.java +++ b/jme3-core/src/main/java/com/jme3/effect/influencers/NewtonianParticleInfluencer.java @@ -39,8 +39,6 @@ import com.jme3.export.OutputCapsule; import com.jme3.math.FastMath; import com.jme3.math.Matrix3f; -import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; /** diff --git a/jme3-core/src/main/java/com/jme3/effect/influencers/RadialParticleInfluencer.java b/jme3-core/src/main/java/com/jme3/effect/influencers/RadialParticleInfluencer.java index fba223dc1d..567763c9fa 100644 --- a/jme3-core/src/main/java/com/jme3/effect/influencers/RadialParticleInfluencer.java +++ b/jme3-core/src/main/java/com/jme3/effect/influencers/RadialParticleInfluencer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -106,7 +106,7 @@ public void setRadialVelocity(float radialVelocity) { /** * nullify y component of particle velocity to make the effect expand only on x and z axis - * @return + * @return true if nullifying, otherwise false */ public boolean isHorizontal() { return horizontal; diff --git a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterBoxShape.java b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterBoxShape.java index 6b29843c94..be9d0257da 100644 --- a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterBoxShape.java +++ b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterBoxShape.java @@ -38,7 +38,6 @@ import com.jme3.math.FastMath; import com.jme3.math.Vector3f; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; public class EmitterBoxShape implements EmitterShape { diff --git a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterMeshVertexShape.java b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterMeshVertexShape.java index e6e35d9cfa..5d209b5583 100644 --- a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterMeshVertexShape.java +++ b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterMeshVertexShape.java @@ -41,7 +41,6 @@ import com.jme3.scene.VertexBuffer.Type; import com.jme3.util.BufferUtils; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; diff --git a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterPointShape.java b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterPointShape.java index e336911016..fb89be826b 100644 --- a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterPointShape.java +++ b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterPointShape.java @@ -36,7 +36,6 @@ import com.jme3.export.OutputCapsule; import com.jme3.math.Vector3f; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; public class EmitterPointShape implements EmitterShape { diff --git a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterSphereShape.java b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterSphereShape.java index a74eeaf39e..015be8b835 100644 --- a/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterSphereShape.java +++ b/jme3-core/src/main/java/com/jme3/effect/shapes/EmitterSphereShape.java @@ -38,7 +38,6 @@ import com.jme3.math.FastMath; import com.jme3.math.Vector3f; import com.jme3.util.clone.Cloner; -import com.jme3.util.clone.JmeCloneable; import java.io.IOException; public class EmitterSphereShape implements EmitterShape { diff --git a/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java b/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java index a8fa7de37f..025d9a7b46 100644 --- a/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java +++ b/jme3-core/src/main/java/com/jme3/environment/EnvironmentCamera.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -289,7 +289,7 @@ protected void cleanup(Application app) { /** * returns the images format used for the generated maps. * - * @return + * @return the enum value */ public Image.Format getImageFormat() { return imageFormat; @@ -311,7 +311,7 @@ protected void onDisable() { * @param axisX the x axis * @param axisY the y axis * @param axisZ tha z axis - * @return + * @return a new instance */ protected Camera createOffCamera(final int mapSize, final Vector3f worldPos, final Vector3f axisX, final Vector3f axisY, final Vector3f axisZ) { final Camera offCamera = new Camera(mapSize, mapSize); @@ -327,7 +327,7 @@ protected Camera createOffCamera(final int mapSize, final Vector3f worldPos, fin * * @param name * @param offCamera - * @return + * @return a new instance */ protected ViewPort createOffViewPort(final String name, final Camera offCamera) { final ViewPort offView = new ViewPort(name, offCamera); @@ -341,7 +341,7 @@ protected ViewPort createOffViewPort(final String name, final Camera offCamera) * * @param mapSize * @param offView - * @return + * @return a new instance */ protected FrameBuffer createOffScreenFrameBuffer(int mapSize, ViewPort offView) { // create offscreen framebuffer diff --git a/jme3-core/src/main/java/com/jme3/environment/LightProbeFactory.java b/jme3-core/src/main/java/com/jme3/environment/LightProbeFactory.java index 859472fe1c..537c94cc8a 100644 --- a/jme3-core/src/main/java/com/jme3/environment/LightProbeFactory.java +++ b/jme3-core/src/main/java/com/jme3/environment/LightProbeFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,10 +51,11 @@ * The process is as follows: * 1. Create an EnvironmentCamera * 2. give it a position in the scene - * 3. call {@link LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Node)} + * 3. call {@link LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Spatial)} * 4. add the created LightProbe to a node with the {@link Node#addLight(com.jme3.light.Light) } method. * - * Optionally for step 3 call {@link LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Node, com.jme3.environment.generation.JobProgressListener) } + * Optionally for step 3 call + * {@link #makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Spatial, com.jme3.environment.generation.JobProgressListener)} * with a {@link JobProgressListener} to be notified of the progress of the generation process. * * The generation will be split in several threads for faster generation. @@ -78,7 +79,8 @@ public class LightProbeFactory { * The process is thread safe. * The created lightProbe will only be marked as ready when the rendering process is done. * - * If you want to monitor the process use {@link LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Node, com.jme3.environment.generation.JobProgressListener) } + * If you want to monitor the process use + * {@link #makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Spatial, com.jme3.environment.generation.JobProgressListener)} * * * diff --git a/jme3-core/src/main/java/com/jme3/environment/generation/IrradianceSphericalHarmonicsGenerator.java b/jme3-core/src/main/java/com/jme3/environment/generation/IrradianceSphericalHarmonicsGenerator.java index d098fa61dd..7a3f637ff9 100644 --- a/jme3-core/src/main/java/com/jme3/environment/generation/IrradianceSphericalHarmonicsGenerator.java +++ b/jme3-core/src/main/java/com/jme3/environment/generation/IrradianceSphericalHarmonicsGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,18 +32,12 @@ package com.jme3.environment.generation; import com.jme3.app.Application; -import com.jme3.environment.util.CubeMapWrapper; import com.jme3.environment.util.EnvMapUtils; import com.jme3.light.LightProbe; -import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.texture.TextureCubeMap; -import com.jme3.util.BufferUtils; - -import java.nio.ByteBuffer; import java.util.concurrent.Callable; -import static com.jme3.environment.util.EnvMapUtils.shBandFactor; /** * Generates the Irradiance map for PBR. This job can be launched from a separate @@ -76,7 +70,7 @@ public IrradianceSphericalHarmonicsGenerator(Application app, JobProgressListene * Fills all the generation parameters * * @param sourceMap the source cube map - * {@link EnvMapUtils.FixSeamsMethod} + * {@link com.jme3.environment.util.EnvMapUtils.FixSeamsMethod} * @param store The cube map to store the result in. */ public void setGenerationParam(TextureCubeMap sourceMap, LightProbe store) { diff --git a/jme3-core/src/main/java/com/jme3/environment/generation/PrefilteredEnvMapFaceGenerator.java b/jme3-core/src/main/java/com/jme3/environment/generation/PrefilteredEnvMapFaceGenerator.java index fbfa73669a..cd4f969981 100644 --- a/jme3-core/src/main/java/com/jme3/environment/generation/PrefilteredEnvMapFaceGenerator.java +++ b/jme3-core/src/main/java/com/jme3/environment/generation/PrefilteredEnvMapFaceGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -96,8 +96,9 @@ public PrefilteredEnvMapFaceGenerator(Application app, int face, JobProgressList * @param sourceMap the source cube map * @param targetMapSize the size of the generated map (width or height in * pixel) - * @param fixSeamsMethod the method used to fix seams as described here - * {@link EnvMapUtils.FixSeamsMethod} + * @param fixSeamsMethod the method used to fix seams as described in + * {@link com.jme3.environment.util.EnvMapUtils.FixSeamsMethod} + * @param genType * @param store The cube map to store the result in. */ public void setGenerationParam(TextureCubeMap sourceMap, int targetMapSize, EnvMapUtils.FixSeamsMethod fixSeamsMethod, EnvMapUtils.GenerationType genType, TextureCubeMap store) { @@ -331,8 +332,8 @@ private Vector3f rotateDirection(float angle, Vector3f l, Vector3f store) { * * @param xi * @param a2 - * @param store - * @return + * @param store caller-provided storage + * @return either store or a new vector (not null) */ public Vector3f importanceSampleGGX(Vector4f xi, float a2, Vector3f store) { if (store == null) { diff --git a/jme3-core/src/main/java/com/jme3/environment/generation/RunnableWithProgress.java b/jme3-core/src/main/java/com/jme3/environment/generation/RunnableWithProgress.java index 33fc922c62..dec5abd2a5 100644 --- a/jme3-core/src/main/java/com/jme3/environment/generation/RunnableWithProgress.java +++ b/jme3-core/src/main/java/com/jme3/environment/generation/RunnableWithProgress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ protected void setEnd(int end) { /** * return the current progress of the process. * - * @return + * @return fraction (≥0, ≤1) */ public double getProgress() { return (double) progress / (double) end; diff --git a/jme3-core/src/main/java/com/jme3/environment/util/CubeMapWrapper.java b/jme3-core/src/main/java/com/jme3/environment/util/CubeMapWrapper.java index 7226f9610a..d03dbe88c3 100644 --- a/jme3-core/src/main/java/com/jme3/environment/util/CubeMapWrapper.java +++ b/jme3-core/src/main/java/com/jme3/environment/util/CubeMapWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -175,7 +175,7 @@ public ColorRGBA getPixel(int x, int y, int face, int mipLevel, ColorRGBA store) /** * writes a pixel given the coordinates vector and the color. - * @param vector the cooredinates where to write the pixel + * @param vector the coordinates where to write the pixel * @param color the color to write */ public void setPixel(Vector3f vector, ColorRGBA color) { @@ -186,7 +186,7 @@ public void setPixel(Vector3f vector, ColorRGBA color) { } /** * writes a pixel given the coordinates vector, the mip level and the color. - * @param vector the cooredinates where to write the pixel + * @param vector the coordinates where to write the pixel * @param mipLevel the miplevel to write to * @param color the color to write */ @@ -231,7 +231,7 @@ public void setPixel(int x, int y, int face, int mipLevel, ColorRGBA color) { } /** - * Inits the mip maps of a cube map witht he given number of mip maps + * Inits the mip maps of a cube map with the given number of mip maps * @param nbMipMaps the number of mip maps to initialize */ public void initMipMaps(int nbMipMaps) { diff --git a/jme3-core/src/main/java/com/jme3/environment/util/EnvMapUtils.java b/jme3-core/src/main/java/com/jme3/environment/util/EnvMapUtils.java index 91b65655e0..8f7ad841c6 100644 --- a/jme3-core/src/main/java/com/jme3/environment/util/EnvMapUtils.java +++ b/jme3-core/src/main/java/com/jme3/environment/util/EnvMapUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -136,13 +136,13 @@ public static TextureCubeMap makeCubeMap(Image rightImg, Image leftImg, Image up * original ones. see {@link ByteBuffer#duplicate()} * * Use this if you need to read from the map from multiple threads, it - * should garanty the thread safety. Note that if you want to write to the + * should guaranty the thread safety. Note that if you want to write to the * cube map you have to make sure that the different thread do not write to * the same area of the buffer. The position, limit and mark are not an * issue. * * @param sourceMap - * @return + * @return a new instance */ public static TextureCubeMap duplicateCubeMap(TextureCubeMap sourceMap) { Image srcImg = sourceMap.getImage(); @@ -233,7 +233,7 @@ private static float areaElement(float x, float y) { * @param face the face to consider * @param store a vector3f where the resulting vector will be stored * @param fixSeamsMethod the method to fix the seams - * @return + * @return either store or a new vector */ public static Vector3f getVectorFromCubemapFaceTexCoord(int x, int y, int mapSize, int face, Vector3f store, FixSeamsMethod fixSeamsMethod) { if (store == null) { @@ -396,12 +396,12 @@ public static float getMipFromRoughness(float roughness, int miptot) { /** * same as - * {@link EnvMapUtils#getSphericalHarmonicsCoefficents(com.jme3.texture.TextureCubeMap, com.jme3.utils.EnvMapUtils.FixSeamsMethod)} + * {@link #getSphericalHarmonicsCoefficents(com.jme3.texture.TextureCubeMap, com.jme3.environment.util.EnvMapUtils.FixSeamsMethod)} * the fix method used is {@link FixSeamsMethod#Wrap} * * @param cubeMap the environment cube map to compute SH for - * @return an array of 9 vector3f representing thos coefficients for each - * r,g,b channnel + * @return an array of 9 vectors representing the coefficients for each + * RGB channel */ public static Vector3f[] getSphericalHarmonicsCoefficents(TextureCubeMap cubeMap) { return getSphericalHarmonicsCoefficents(cubeMap, FixSeamsMethod.Wrap); @@ -419,8 +419,8 @@ public static Vector3f[] getSphericalHarmonicsCoefficents(TextureCubeMap cubeMap * @param cubeMap the environment cube map to compute SH for * @param fixSeamsMethod method to fix seams when computing the SH * coefficients - * @return an array of 9 vector3f representing thos coefficients for each - * r,g,b channnel + * @return an array of 9 vectors representing the coefficients for each + * RGB channel */ public static Vector3f[] getSphericalHarmonicsCoefficents(TextureCubeMap cubeMap, FixSeamsMethod fixSeamsMethod) { @@ -604,7 +604,7 @@ public static Vector3f importanceSampleGGX(Vector4f xi, float a2, Vector3f norma * * @param cubeMap the cube map * @param assetManager the asset Manager - * @return + * @return a new Node */ public static Node getCubeMapCrossDebugView(TextureCubeMap cubeMap, AssetManager assetManager) { Node n = new Node("CubeMapDebug" + cubeMap.getName()); diff --git a/jme3-core/src/main/java/com/jme3/environment/util/LightsDebugState.java b/jme3-core/src/main/java/com/jme3/environment/util/LightsDebugState.java index a9d2a9e463..31c51c9714 100644 --- a/jme3-core/src/main/java/com/jme3/environment/util/LightsDebugState.java +++ b/jme3-core/src/main/java/com/jme3/environment/util/LightsDebugState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,6 @@ import com.jme3.app.Application; import com.jme3.app.state.BaseAppState; -import com.jme3.bounding.BoundingSphere; import com.jme3.light.*; import com.jme3.material.Material; import com.jme3.renderer.RenderManager; @@ -158,7 +157,7 @@ public void render(RenderManager rm) { /** * returns the scale of the probe's debug sphere - * @return + * @return the scale factor */ public float getProbeScale() { return probeScale; diff --git a/jme3-core/src/main/java/com/jme3/font/BitmapCharacterSet.java b/jme3-core/src/main/java/com/jme3/font/BitmapCharacterSet.java index 8760e0ec06..f1c6f644ed 100644 --- a/jme3-core/src/main/java/com/jme3/font/BitmapCharacterSet.java +++ b/jme3-core/src/main/java/com/jme3/font/BitmapCharacterSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -180,7 +180,7 @@ public void setHeight(int height) { * Merge two fonts. * If two font have the same style, merge will fail. * @param styleSet Style must be assigned to this. - * @author Yonghoon + * author: Yonghoon */ public void merge(BitmapCharacterSet styleSet) { if (this.renderedSize != styleSet.renderedSize) { diff --git a/jme3-core/src/main/java/com/jme3/font/BitmapFont.java b/jme3-core/src/main/java/com/jme3/font/BitmapFont.java index 856268c37b..694278057d 100644 --- a/jme3-core/src/main/java/com/jme3/font/BitmapFont.java +++ b/jme3-core/src/main/java/com/jme3/font/BitmapFont.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -261,7 +261,7 @@ public float getLineWidth(CharSequence text){ * Merge two fonts. * If two font have the same style, merge will fail. * @param newFont Style must be assigned to this. - * @author Yonghoon + * author: Yonghoon */ public void merge(BitmapFont newFont) { charSet.merge(newFont.charSet); diff --git a/jme3-core/src/main/java/com/jme3/font/BitmapTextPage.java b/jme3-core/src/main/java/com/jme3/font/BitmapTextPage.java index 0df557906f..104e059843 100644 --- a/jme3-core/src/main/java/com/jme3/font/BitmapTextPage.java +++ b/jme3-core/src/main/java/com/jme3/font/BitmapTextPage.java @@ -43,7 +43,6 @@ import java.nio.FloatBuffer; import java.nio.ShortBuffer; import java.util.LinkedList; -import java.util.LinkedList; /** * One page per BitmapText Font Texture. diff --git a/jme3-core/src/main/java/com/jme3/font/Letters.java b/jme3-core/src/main/java/com/jme3/font/Letters.java index 604f687852..718ebd532c 100644 --- a/jme3-core/src/main/java/com/jme3/font/Letters.java +++ b/jme3-core/src/main/java/com/jme3/font/Letters.java @@ -35,6 +35,7 @@ import com.jme3.font.BitmapFont.VAlign; import com.jme3.font.ColorTags.Range; import com.jme3.math.ColorRGBA; + import java.util.LinkedList; /** @@ -179,8 +180,8 @@ void update() { l = l.getNext(); } - align(); block.setLineCount(lineCount); + align(); rewind(); } @@ -203,10 +204,10 @@ private void align() { gapY = 0; break; case Center: - gapY = (height-totalHeight)*0.5f; + gapY = (height - totalHeight) * 0.5f; break; case Bottom: - gapY = height-totalHeight; + gapY = height - totalHeight; break; } } @@ -323,9 +324,9 @@ void validateSize() { while (!l.isTail()) { totalWidth = Math.max(totalWidth, l.getX1()); l = l.getNext(); - totalHeight = Math.max(totalHeight, -l.getY1()); } } + totalHeight = font.getLineHeight(block) * block.getLineCount(); } /** diff --git a/jme3-core/src/main/java/com/jme3/input/ChaseCamera.java b/jme3-core/src/main/java/com/jme3/input/ChaseCamera.java index c185393f27..43f0941fc3 100644 --- a/jme3-core/src/main/java/com/jme3/input/ChaseCamera.java +++ b/jme3-core/src/main/java/com/jme3/input/ChaseCamera.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -268,7 +268,7 @@ public final void registerWithInput(InputManager inputManager) { /** * Cleans up the input mappings from the input manager. * Undoes the work of registerWithInput(). - * @param inputManager InputManager from which to cleanup mappings. + * @param mgr the InputManager to clean up */ public void cleanupWithInput(InputManager mgr){ mgr.deleteMapping(CameraInput.CHASECAM_TOGGLEROTATE); @@ -583,7 +583,7 @@ public void setMinDistance(float minDistance) { * clone this camera for a spatial * * @param spatial - * @return + * @return never */ @Deprecated @Override @@ -707,7 +707,7 @@ public void setSmoothMotion(boolean smoothMotion) { /** * returns the chasing sensitivity - * @return + * @return the sensitivity */ public float getChasingSensitivity() { return chasingSensitivity; @@ -726,7 +726,7 @@ public void setChasingSensitivity(float chasingSensitivity) { /** * Returns the rotation sensitivity - * @return + * @return the sensitivity */ public float getRotationSensitivity() { return rotationSensitivity; @@ -745,7 +745,7 @@ public void setRotationSensitivity(float rotationSensitivity) { /** * returns true if the trailing is enabled - * @return + * @return true if enabled, otherwise false */ public boolean isTrailingEnabled() { return trailingEnabled; @@ -763,7 +763,7 @@ public void setTrailingEnabled(boolean trailingEnabled) { /** * * returns the trailing rotation inertia - * @return + * @return the inertia */ public float getTrailingRotationInertia() { return trailingRotationInertia; @@ -781,7 +781,7 @@ public void setTrailingRotationInertia(float trailingRotationInertia) { /** * returns the trailing sensitivity - * @return + * @return the sensitivity */ public float getTrailingSensitivity() { return trailingSensitivity; @@ -799,7 +799,7 @@ public void setTrailingSensitivity(float trailingSensitivity) { /** * returns the zoom sensitivity - * @return + * @return the sensitivity */ public float getZoomSensitivity() { return zoomSensitivity; @@ -863,7 +863,7 @@ public void setDefaultVerticalRotation(float angleInRad) { /** * @return If drag to rotate feature is enabled. * - * @see FlyByCamera#setDragToRotate(boolean) + * @see #setDragToRotate(boolean) */ public boolean isDragToRotate() { return dragToRotate; @@ -904,7 +904,7 @@ public boolean getDownRotateOnCloseViewOnly() { /** * return the current distance from the camera to the target - * @return + * @return the distance */ public float getDistanceToTarget() { return distance; @@ -912,7 +912,7 @@ public float getDistanceToTarget() { /** * returns the current horizontal rotation around the target in radians - * @return + * @return the angle */ public float getHorizontalRotation() { return rotation; @@ -920,7 +920,7 @@ public float getHorizontalRotation() { /** * returns the current vertical rotation around the target in radians. - * @return + * @return the angle in radians */ public float getVerticalRotation() { return vRotation; @@ -928,7 +928,7 @@ public float getVerticalRotation() { /** * returns the offset from the target's position where the camera looks at - * @return + * @return the pre-existing vector */ public Vector3f getLookAtOffset() { return lookAtOffset; @@ -952,7 +952,7 @@ public void setUpVector(Vector3f up) { /** * Returns the up vector of the camera used for the lookAt on the target - * @return + * @return the pre-existing vector */ public Vector3f getUpVector() { return initialUpVec; diff --git a/jme3-core/src/main/java/com/jme3/input/InputManager.java b/jme3-core/src/main/java/com/jme3/input/InputManager.java index 63d90078ff..eb15f1c8b6 100644 --- a/jme3-core/src/main/java/com/jme3/input/InputManager.java +++ b/jme3-core/src/main/java/com/jme3/input/InputManager.java @@ -1,956 +1,1016 @@ -/* - * Copyright (c) 2009-2018 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.jme3.input; - -import com.jme3.app.Application; -import com.jme3.cursors.plugins.JmeCursor; -import com.jme3.input.controls.*; -import com.jme3.input.event.*; -import com.jme3.math.FastMath; -import com.jme3.math.Vector2f; -import com.jme3.util.IntMap; -import com.jme3.util.IntMap.Entry; -import com.jme3.util.SafeArrayList; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * The InputManager is responsible for converting input events - * received from the Key, Mouse and Joy Input implementations into an - * abstract, input device independent representation that user code can use. - *

- * By default an InputManager is included with every Application instance for use - * in user code to query input, unless the Application is created as headless - * or with input explicitly disabled. - *

- * The input manager has two concepts, a {@link Trigger} and a mapping. - * A trigger represents a specific input trigger, such as a key button, - * or a mouse axis. A mapping represents a link onto one or several triggers, - * when the appropriate trigger is activated (e.g. a key is pressed), the - * mapping will be invoked. Any listeners registered to receive an event - * from the mapping will have an event raised. - *

- * There are two types of events that {@link InputListener input listeners} - * can receive, one is {@link ActionListener#onAction(java.lang.String, boolean, float) action} - * events and another is {@link AnalogListener#onAnalog(java.lang.String, float, float) analog} - * events. - *

- * onAction events are raised when the specific input - * activates or deactivates. For a digital input such as key press, the onAction() - * event will be raised with the isPressed argument equal to true, - * when the key is released, onAction is called again but this time - * with the isPressed argument set to false. - * For analog inputs, the onAction method will be called any time - * the input is non-zero, however an exception to this is for joystick axis inputs, - * which are only called when the input is above the {@link InputManager#setAxisDeadZone(float) dead zone}. - *

- * onAnalog events are raised every frame while the input is activated. - * For digital inputs, every frame that the input is active will cause the - * onAnalog method to be called, the argument value - * argument will equal to the frame's time per frame (TPF) value but only - * for digital inputs. For analog inputs however, the value argument - * will equal the actual analog value. - */ -public class InputManager implements RawInputListener { - - private static final Logger logger = Logger.getLogger(InputManager.class.getName()); - private final KeyInput keys; - private final MouseInput mouse; - private final JoyInput joystick; - private final TouchInput touch; - private float frameTPF; - private long lastLastUpdateTime = 0; - private long lastUpdateTime = 0; - private long frameDelta = 0; - private long firstTime = 0; - private boolean eventsPermitted = false; - private boolean mouseVisible = true; - private boolean safeMode = false; - private float globalAxisDeadZone = 0.05f; - private final Vector2f cursorPos = new Vector2f(); - private Joystick[] joysticks; - private final IntMap> bindings = new IntMap>(); - private final HashMap mappings = new HashMap(); - private final IntMap pressedButtons = new IntMap(); - private final IntMap axisValues = new IntMap(); - private final SafeArrayList rawListeners = new SafeArrayList(RawInputListener.class); - private final ArrayList inputQueue = new ArrayList(); - - private static class Mapping { - - private final String name; - private final ArrayList triggers = new ArrayList(); - private final ArrayList listeners = new ArrayList(); - - public Mapping(String name) { - this.name = name; - } - } - - /** - * Initializes the InputManager. - * - *

This should only be called internally in {@link Application}. - * - * @param mouse - * @param keys - * @param joystick - * @param touch - * @throws IllegalArgumentException If either mouseInput or keyInput are null. - */ - public InputManager(MouseInput mouse, KeyInput keys, JoyInput joystick, TouchInput touch) { - if (keys == null || mouse == null) { - throw new IllegalArgumentException("Mouse or keyboard cannot be null"); - } - - this.keys = keys; - this.mouse = mouse; - this.joystick = joystick; - this.touch = touch; - - keys.setInputListener(this); - mouse.setInputListener(this); - if (joystick != null) { - joystick.setInputListener(this); - joysticks = joystick.loadJoysticks(this); - } - if (touch != null) { - touch.setInputListener(this); - } - - firstTime = keys.getInputTimeNanos(); - } - - private void invokeActions(int hash, boolean pressed) { - ArrayList maps = bindings.get(hash); - if (maps == null) { - return; - } - - int size = maps.size(); - for (int i = size - 1; i >= 0; i--) { - Mapping mapping = maps.get(i); - ArrayList listeners = mapping.listeners; - int listenerSize = listeners.size(); - for (int j = listenerSize - 1; j >= 0; j--) { - InputListener listener = listeners.get(j); - if (listener instanceof ActionListener) { - ((ActionListener) listener).onAction(mapping.name, pressed, frameTPF); - } - } - } - } - - private float computeAnalogValue(long timeDelta) { - if (safeMode || frameDelta == 0) { - return 1f; - } else { - return FastMath.clamp((float) timeDelta / (float) frameDelta, 0, 1); - } - } - - private void invokeTimedActions(int hash, long time, boolean pressed) { - if (!bindings.containsKey(hash)) { - return; - } - - if (pressed) { - pressedButtons.put(hash, time); - } else { - Long pressTimeObj = pressedButtons.remove(hash); - if (pressTimeObj == null) { - return; // under certain circumstances it can be null, ignore - } // the event then. - - long pressTime = pressTimeObj; - long lastUpdate = lastLastUpdateTime; - long releaseTime = time; - long timeDelta = releaseTime - Math.max(pressTime, lastUpdate); - - if (timeDelta > 0) { - invokeAnalogs(hash, computeAnalogValue(timeDelta), false); - } - } - } - - private void invokeUpdateActions() { - for (Entry pressedButton : pressedButtons) { - int hash = pressedButton.getKey(); - - long pressTime = pressedButton.getValue(); - long timeDelta = lastUpdateTime - Math.max(lastLastUpdateTime, pressTime); - - if (timeDelta > 0) { - invokeAnalogs(hash, computeAnalogValue(timeDelta), false); - } - } - - for (Entry axisValue : axisValues) { - int hash = axisValue.getKey(); - float value = axisValue.getValue(); - invokeAnalogs(hash, value * frameTPF, true); - } - } - - private void invokeAnalogs(int hash, float value, boolean isAxis) { - ArrayList maps = bindings.get(hash); - if (maps == null) { - return; - } - - if (!isAxis) { - value *= frameTPF; - } - - int size = maps.size(); - for (int i = size - 1; i >= 0; i--) { - Mapping mapping = maps.get(i); - ArrayList listeners = mapping.listeners; - int listenerSize = listeners.size(); - for (int j = listenerSize - 1; j >= 0; j--) { - InputListener listener = listeners.get(j); - if (listener instanceof AnalogListener) { - // NOTE: multiply by TPF for any button bindings - ((AnalogListener) listener).onAnalog(mapping.name, value, frameTPF); - } - } - } - } - - private void invokeAnalogsAndActions(int hash, float value, float effectiveDeadZone, boolean applyTpf) { - if (value < effectiveDeadZone) { - invokeAnalogs(hash, value, !applyTpf); - return; - } - - ArrayList maps = bindings.get(hash); - if (maps == null) { - return; - } - - boolean valueChanged = !axisValues.containsKey(hash); - if (applyTpf) { - value *= frameTPF; - } - - int size = maps.size(); - for (int i = size - 1; i >= 0; i--) { - Mapping mapping = maps.get(i); - ArrayList listeners = mapping.listeners; - int listenerSize = listeners.size(); - for (int j = listenerSize - 1; j >= 0; j--) { - InputListener listener = listeners.get(j); - - if (listener instanceof ActionListener && valueChanged) { - ((ActionListener) listener).onAction(mapping.name, true, frameTPF); - } - - if (listener instanceof AnalogListener) { - ((AnalogListener) listener).onAnalog(mapping.name, value, frameTPF); - } - - } - } - } - - /** - * Callback from RawInputListener. Do not use. - */ - @Override - public void beginInput() { - } - - /** - * Callback from RawInputListener. Do not use. - */ - @Override - public void endInput() { - } - - private void onJoyAxisEventQueued(JoyAxisEvent evt) { -// for (int i = 0; i < rawListeners.size(); i++){ -// rawListeners.get(i).onJoyAxisEvent(evt); -// } - - int joyId = evt.getJoyIndex(); - int axis = evt.getAxisIndex(); - float value = evt.getValue(); - float effectiveDeadZone = Math.max(globalAxisDeadZone, evt.getAxis().getDeadZone()); - if (value < effectiveDeadZone && value > -effectiveDeadZone) { - int hash1 = JoyAxisTrigger.joyAxisHash(joyId, axis, true); - int hash2 = JoyAxisTrigger.joyAxisHash(joyId, axis, false); - - Float val1 = axisValues.get(hash1); - Float val2 = axisValues.get(hash2); - - if (val1 != null && val1 > effectiveDeadZone) { - invokeActions(hash1, false); - } - if (val2 != null && val2 > effectiveDeadZone) { - invokeActions(hash2, false); - } - - axisValues.remove(hash1); - axisValues.remove(hash2); - - } else if (value < 0) { - int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, true); - int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, false); - - // Clear the reverse direction's actions in case we - // crossed center too quickly - Float otherVal = axisValues.get(otherHash); - if (otherVal != null && otherVal > effectiveDeadZone) { - invokeActions(otherHash, false); - } - - invokeAnalogsAndActions(hash, -value, effectiveDeadZone, true); - axisValues.put(hash, -value); - axisValues.remove(otherHash); - } else { - int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, false); - int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, true); - - // Clear the reverse direction's actions in case we - // crossed center too quickly - Float otherVal = axisValues.get(otherHash); - if (otherVal != null && otherVal > effectiveDeadZone) { - invokeActions(otherHash, false); - } - - invokeAnalogsAndActions(hash, value, effectiveDeadZone, true); - axisValues.put(hash, value); - axisValues.remove(otherHash); - } - } - - /** - * Callback from RawInputListener. Do not use. - */ - @Override - public void onJoyAxisEvent(JoyAxisEvent evt) { - if (!eventsPermitted) { - throw new UnsupportedOperationException("JoyInput has raised an event at an illegal time."); - } - - inputQueue.add(evt); - } - - private void onJoyButtonEventQueued(JoyButtonEvent evt) { -// for (int i = 0; i < rawListeners.size(); i++){ -// rawListeners.get(i).onJoyButtonEvent(evt); -// } - - int hash = JoyButtonTrigger.joyButtonHash(evt.getJoyIndex(), evt.getButtonIndex()); - invokeActions(hash, evt.isPressed()); - invokeTimedActions(hash, evt.getTime(), evt.isPressed()); - } - - /** - * Callback from RawInputListener. Do not use. - */ - @Override - public void onJoyButtonEvent(JoyButtonEvent evt) { - if (!eventsPermitted) { - throw new UnsupportedOperationException("JoyInput has raised an event at an illegal time."); - } - - inputQueue.add(evt); - } - - private void onMouseMotionEventQueued(MouseMotionEvent evt) { -// for (int i = 0; i < rawListeners.size(); i++){ -// rawListeners.get(i).onMouseMotionEvent(evt); -// } - - if (evt.getDX() != 0) { - float val = Math.abs(evt.getDX()) / 1024f; - invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_X, evt.getDX() < 0), val, globalAxisDeadZone, false); - } - if (evt.getDY() != 0) { - float val = Math.abs(evt.getDY()) / 1024f; - invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_Y, evt.getDY() < 0), val, globalAxisDeadZone, false); - } - if (evt.getDeltaWheel() != 0) { - float val = Math.abs(evt.getDeltaWheel()) / 100f; - invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_WHEEL, evt.getDeltaWheel() < 0), val, globalAxisDeadZone, false); - } - } - - /** - * Sets the mouse cursor image or animation. - * Set cursor to null to show default system cursor. - * To hide the cursor completely, use {@link #setCursorVisible(boolean) }. - * - * @param jmeCursor The cursor to set, or null to reset to system cursor. - * - * @see JmeCursor - */ - public void setMouseCursor(JmeCursor jmeCursor) { - mouse.setNativeCursor(jmeCursor); - } - - /** - * Callback from RawInputListener. Do not use. - * - * @param evt event to add to the input queue (not null) - */ - @Override - public void onMouseMotionEvent(MouseMotionEvent evt) { - /* - * If events aren't allowed, the event may be a "first mouse event" - * triggered by the constructor setting the mouse listener. - * In that case, use the event to initialize the cursor position, - * but don't queue it for further processing. - * This is part of the fix for issue #792. - */ - cursorPos.set(evt.getX(), evt.getY()); - if (eventsPermitted) { - inputQueue.add(evt); - } - } - - private void onMouseButtonEventQueued(MouseButtonEvent evt) { - int hash = MouseButtonTrigger.mouseButtonHash(evt.getButtonIndex()); - invokeActions(hash, evt.isPressed()); - invokeTimedActions(hash, evt.getTime(), evt.isPressed()); - } - - /** - * Callback from RawInputListener. Do not use. - */ - @Override - public void onMouseButtonEvent(MouseButtonEvent evt) { - if (!eventsPermitted) { - throw new UnsupportedOperationException("MouseInput has raised an event at an illegal time."); - } - //updating cursor pos on click, so that non android touch events can properly update cursor position. - cursorPos.set(evt.getX(), evt.getY()); - inputQueue.add(evt); - } - - private void onKeyEventQueued(KeyInputEvent evt) { - if (evt.isRepeating()) { - return; // repeat events not used for bindings - } - - int hash = KeyTrigger.keyHash(evt.getKeyCode()); - invokeActions(hash, evt.isPressed()); - invokeTimedActions(hash, evt.getTime(), evt.isPressed()); - } - - /** - * Callback from RawInputListener. Do not use. - */ - @Override - public void onKeyEvent(KeyInputEvent evt) { - if (!eventsPermitted) { - throw new UnsupportedOperationException("KeyInput has raised an event at an illegal time."); - } - - inputQueue.add(evt); - } - - /** - * Set the deadzone for joystick axes. - * - *

{@link ActionListener#onAction(java.lang.String, boolean, float) } - * events will only be raised if the joystick axis value is greater than - * the deadZone. - * - * @param deadZone the deadzone for joystick axes. - */ - public void setAxisDeadZone(float deadZone) { - this.globalAxisDeadZone = deadZone; - } - - /** - * Returns the deadzone for joystick axes. - * - * @return the deadzone for joystick axes. - */ - public float getAxisDeadZone() { - return globalAxisDeadZone; - } - - /** - * Adds a new listener to receive events on the given mappings. - * - *

The given InputListener will be registered to receive events - * on the specified mapping names. When a mapping raises an event, the - * listener will have its appropriate method invoked, either - * {@link ActionListener#onAction(java.lang.String, boolean, float) } - * or {@link AnalogListener#onAnalog(java.lang.String, float, float) } - * depending on which interface the listener implements. - * If the listener implements both interfaces, then it will receive the - * appropriate event for each method. - * - * @param listener The listener to register to receive input events. - * @param mappingNames The mapping names which the listener will receive - * events from. - * - * @see InputManager#removeListener(com.jme3.input.controls.InputListener) - */ - public void addListener(InputListener listener, String... mappingNames) { - for (String mappingName : mappingNames) { - Mapping mapping = mappings.get(mappingName); - if (mapping == null) { - mapping = new Mapping(mappingName); - mappings.put(mappingName, mapping); - } - if (!mapping.listeners.contains(listener)) { - mapping.listeners.add(listener); - } - } - } - - /** - * Removes a listener from receiving events. - * - *

This will unregister the listener from any mappings that it - * was previously registered with via - * {@link InputManager#addListener(com.jme3.input.controls.InputListener, java.lang.String[]) }. - * - * @param listener The listener to unregister. - * - * @see InputManager#addListener(com.jme3.input.controls.InputListener, java.lang.String[]) - */ - public void removeListener(InputListener listener) { - for (Mapping mapping : mappings.values()) { - mapping.listeners.remove(listener); - } - } - - /** - * Create a new mapping to the given triggers. - * - *

- * The given mapping will be assigned to the given triggers, when - * any of the triggers given raise an event, the listeners - * registered to the mappings will receive appropriate events. - * - * @param mappingName The mapping name to assign. - * @param triggers The triggers to which the mapping is to be registered. - * - * @see InputManager#deleteMapping(java.lang.String) - */ - public void addMapping(String mappingName, Trigger... triggers) { - Mapping mapping = mappings.get(mappingName); - if (mapping == null) { - mapping = new Mapping(mappingName); - mappings.put(mappingName, mapping); - } - - for (Trigger trigger : triggers) { - int hash = trigger.triggerHashCode(); - ArrayList names = bindings.get(hash); - if (names == null) { - names = new ArrayList(); - bindings.put(hash, names); - } - if (!names.contains(mapping)) { - names.add(mapping); - mapping.triggers.add(hash); - } else { - logger.log(Level.WARNING, "Attempted to add mapping \"{0}\" twice to trigger.", mappingName); - } - } - } - - /** - * Returns true if this InputManager has a mapping registered - * for the given mappingName. - * - * @param mappingName The mapping name to check. - * - * @see InputManager#addMapping(java.lang.String, com.jme3.input.controls.Trigger[]) - * @see InputManager#deleteMapping(java.lang.String) - */ - public boolean hasMapping(String mappingName) { - return mappings.containsKey(mappingName); - } - - /** - * Deletes a mapping from receiving trigger events. - * - *

- * The given mapping will no longer be assigned to receive trigger - * events. - * - * @param mappingName The mapping name to unregister. - * - * @see InputManager#addMapping(java.lang.String, com.jme3.input.controls.Trigger[]) - */ - public void deleteMapping(String mappingName) { - Mapping mapping = mappings.remove(mappingName); - if (mapping == null) { - //throw new IllegalArgumentException("Cannot find mapping: " + mappingName); - logger.log(Level.WARNING, "Cannot find mapping to be removed, skipping: {0}", mappingName); - return; - } - - ArrayList triggers = mapping.triggers; - for (int i = triggers.size() - 1; i >= 0; i--) { - int hash = triggers.get(i); - ArrayList maps = bindings.get(hash); - maps.remove(mapping); - } - } - - /** - * Deletes a specific trigger registered to a mapping. - * - *

- * The given mapping will no longer receive events raised by the - * trigger. - * - * @param mappingName The mapping name to cease receiving events from the - * trigger. - * @param trigger The trigger to no longer invoke events on the mapping. - */ - public void deleteTrigger(String mappingName, Trigger trigger) { - Mapping mapping = mappings.get(mappingName); - if (mapping == null) { - throw new IllegalArgumentException("Cannot find mapping: " + mappingName); - } - - ArrayList maps = bindings.get(trigger.triggerHashCode()); - maps.remove(mapping); - - } - - /** - * Clears all the input mappings from this InputManager. - * Consequently, also clears all of the - * InputListeners as well. - */ - public void clearMappings() { - mappings.clear(); - bindings.clear(); - reset(); - } - - /** - * Do not use. - * Called to reset pressed keys or buttons when focus is restored. - */ - public void reset() { - pressedButtons.clear(); - axisValues.clear(); - } - - /** - * Returns whether the mouse cursor is visible or not. - * - *

By default the cursor is visible. - * - * @return whether the mouse cursor is visible or not. - * - * @see InputManager#setCursorVisible(boolean) - */ - public boolean isCursorVisible() { - return mouseVisible; - } - - /** - * Set whether the mouse cursor should be visible or not. - * - * @param visible whether the mouse cursor should be visible or not. - */ - public void setCursorVisible(boolean visible) { - if (mouseVisible != visible) { - mouseVisible = visible; - mouse.setCursorVisible(mouseVisible); - } - } - - /** - * Returns the current cursor position. The position is relative to the - * bottom-left of the screen and is in pixels. - * - * @return the current cursor position - */ - public Vector2f getCursorPosition() { - return cursorPos; - } - - /** - * Returns an array of all joysticks installed on the system. - * - * @return an array of all joysticks installed on the system. - */ - public Joystick[] getJoysticks() { - return joysticks; - } - - /** - * Adds a {@link RawInputListener} to receive raw input events. - * - *

- * Any raw input listeners registered to this InputManager - * will receive raw input events first, before they get handled - * by the InputManager itself. The listeners are - * each processed in the order they were added, e.g. FIFO. - *

- * If a raw input listener has handled the event and does not wish - * other listeners down the list to process the event, it may set the - * {@link InputEvent#setConsumed() consumed flag} to indicate the - * event was consumed and shouldn't be processed any further. - * The listener may do this either at each of the event callbacks - * or at the {@link RawInputListener#endInput() } method. - * - * @param listener A listener to receive raw input events. - * - * @see RawInputListener - */ - public void addRawInputListener(RawInputListener listener) { - rawListeners.add(listener); - } - - /** - * Removes a {@link RawInputListener} so that it no longer - * receives raw input events. - * - * @param listener The listener to cease receiving raw input events. - * - * @see InputManager#addRawInputListener(com.jme3.input.RawInputListener) - */ - public void removeRawInputListener(RawInputListener listener) { - rawListeners.remove(listener); - } - - /** - * Clears all {@link RawInputListener}s. - * - * @see InputManager#addRawInputListener(com.jme3.input.RawInputListener) - */ - public void clearRawInputListeners() { - rawListeners.clear(); - } - - /** - * Enable simulation of mouse events. Used for touchscreen input only. - * - * @param value True to enable simulation of mouse events - */ - public void setSimulateMouse(boolean value) { - if (touch != null) { - touch.setSimulateMouse(value); - } - } - /** - * @deprecated Use isSimulateMouse - * Returns state of simulation of mouse events. Used for touchscreen input only. - * - */ - public boolean getSimulateMouse() { - if (touch != null) { - return touch.isSimulateMouse(); - } else { - return false; - } - } - - /** - * Returns state of simulation of mouse events. Used for touchscreen input only. - * - */ - public boolean isSimulateMouse() { - if (touch != null) { - return touch.isSimulateMouse(); - } else { - return false; - } - } - - /** - * Enable simulation of keyboard events. Used for touchscreen input only. - * - * @param value True to enable simulation of keyboard events - */ - public void setSimulateKeyboard(boolean value) { - if (touch != null) { - touch.setSimulateKeyboard(value); - } - } - - /** - * Returns state of simulation of key events. Used for touchscreen input only. - * - */ - public boolean isSimulateKeyboard() { - if (touch != null) { - return touch.isSimulateKeyboard(); - } else { - return false; - } - } - - private void processQueue() { - int queueSize = inputQueue.size(); - RawInputListener[] array = rawListeners.getArray(); - - for (RawInputListener listener : array) { - listener.beginInput(); - - for (int j = 0; j < queueSize; j++) { - InputEvent event = inputQueue.get(j); - if (event.isConsumed()) { - continue; - } - - if (event instanceof MouseMotionEvent) { - listener.onMouseMotionEvent((MouseMotionEvent) event); - } else if (event instanceof KeyInputEvent) { - listener.onKeyEvent((KeyInputEvent) event); - } else if (event instanceof MouseButtonEvent) { - listener.onMouseButtonEvent((MouseButtonEvent) event); - } else if (event instanceof JoyAxisEvent) { - listener.onJoyAxisEvent((JoyAxisEvent) event); - } else if (event instanceof JoyButtonEvent) { - listener.onJoyButtonEvent((JoyButtonEvent) event); - } else if (event instanceof TouchEvent) { - listener.onTouchEvent((TouchEvent) event); - } else { - assert false; - } - } - - listener.endInput(); - } - - for (int i = 0; i < queueSize; i++) { - InputEvent event = inputQueue.get(i); - if (event.isConsumed()) { - continue; - } - - if (event instanceof MouseMotionEvent) { - onMouseMotionEventQueued((MouseMotionEvent) event); - } else if (event instanceof KeyInputEvent) { - onKeyEventQueued((KeyInputEvent) event); - } else if (event instanceof MouseButtonEvent) { - onMouseButtonEventQueued((MouseButtonEvent) event); - } else if (event instanceof JoyAxisEvent) { - onJoyAxisEventQueued((JoyAxisEvent) event); - } else if (event instanceof JoyButtonEvent) { - onJoyButtonEventQueued((JoyButtonEvent) event); - } else if (event instanceof TouchEvent) { - onTouchEventQueued((TouchEvent) event); - } else { - assert false; - } - // larynx, 2011.06.10 - flag event as reusable because - // the android input uses a non-allocating ringbuffer which - // needs to know when the event is not anymore in inputQueue - // and therefore can be reused. - event.setConsumed(); - } - - inputQueue.clear(); - } - - /** - * Updates the InputManager. - * This will query current input devices and send - * appropriate events to registered listeners. - * - * @param tpf Time per frame value. - */ - public void update(float tpf) { - frameTPF = tpf; - - // Activate safemode if the TPF value is so small - // that rounding errors are inevitable - safeMode = tpf < 0.015f; - - long currentTime = keys.getInputTimeNanos(); - frameDelta = currentTime - lastUpdateTime; - - eventsPermitted = true; - - keys.update(); - mouse.update(); - if (joystick != null) { - joystick.update(); - } - if (touch != null) { - touch.update(); - } - - eventsPermitted = false; - - processQueue(); - invokeUpdateActions(); - - lastLastUpdateTime = lastUpdateTime; - lastUpdateTime = currentTime; - } - - /** - * Dispatches touch events to touch listeners - * @param evt The touch event to be dispatched to all onTouch listeners - */ - public void onTouchEventQueued(TouchEvent evt) { - ArrayList maps = bindings.get(TouchTrigger.touchHash(evt.getKeyCode())); - if (maps == null) { - return; - } - - int size = maps.size(); - for (int i = size - 1; i >= 0; i--) { - Mapping mapping = maps.get(i); - ArrayList listeners = mapping.listeners; - int listenerSize = listeners.size(); - for (int j = listenerSize - 1; j >= 0; j--) { - InputListener listener = listeners.get(j); - if (listener instanceof TouchListener) { - ((TouchListener) listener).onTouch(mapping.name, evt, frameTPF); - } - } - } - } - - /** - * Callback from RawInputListener. Do not use. - */ - @Override - public void onTouchEvent(TouchEvent evt) { - if (!eventsPermitted) { - throw new UnsupportedOperationException("TouchInput has raised an event at an illegal time."); - } - cursorPos.set(evt.getX(), evt.getY()); - inputQueue.add(evt); - } -} +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.input; + +import com.jme3.app.Application; +import com.jme3.cursors.plugins.JmeCursor; +import com.jme3.input.controls.*; +import com.jme3.input.event.*; +import com.jme3.math.FastMath; +import com.jme3.math.Vector2f; +import com.jme3.util.IntMap; +import com.jme3.util.IntMap.Entry; +import com.jme3.util.SafeArrayList; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * The InputManager is responsible for converting input events + * received from the Key, Mouse and Joy Input implementations into an + * abstract, input device independent representation that user code can use. + *

+ * By default an InputManager is included with every Application instance for use + * in user code to query input, unless the Application is created as headless + * or with input explicitly disabled. + *

+ * The input manager has two concepts, a {@link Trigger} and a mapping. + * A trigger represents a specific input trigger, such as a key button, + * or a mouse axis. A mapping represents a link onto one or several triggers, + * when the appropriate trigger is activated (e.g. a key is pressed), the + * mapping will be invoked. Any listeners registered to receive an event + * from the mapping will have an event raised. + *

+ * There are two types of events that {@link InputListener input listeners} + * can receive, one is {@link ActionListener#onAction(java.lang.String, boolean, float) action} + * events and another is {@link AnalogListener#onAnalog(java.lang.String, float, float) analog} + * events. + *

+ * onAction events are raised when the specific input + * activates or deactivates. For a digital input such as key press, the onAction() + * event will be raised with the isPressed argument equal to true, + * when the key is released, onAction is called again but this time + * with the isPressed argument set to false. + * For analog inputs, the onAction method will be called any time + * the input is non-zero, however an exception to this is for joystick axis inputs, + * which are only called when the input is above the {@link InputManager#setAxisDeadZone(float) dead zone}. + *

+ * onAnalog events are raised every frame while the input is activated. + * For digital inputs, every frame that the input is active will cause the + * onAnalog method to be called, the argument value + * argument will equal to the frame's time per frame (TPF) value but only + * for digital inputs. For analog inputs however, the value argument + * will equal the actual analog value. + */ +public class InputManager implements RawInputListener { + + private static final Logger logger = Logger.getLogger(InputManager.class.getName()); + private final KeyInput keys; + private final MouseInput mouse; + private final JoyInput joystick; + private final TouchInput touch; + private float frameTPF; + private long lastLastUpdateTime = 0; + private long lastUpdateTime = 0; + private long frameDelta = 0; + private long firstTime = 0; + private boolean eventsPermitted = false; + private boolean mouseVisible = true; + private boolean safeMode = false; + private float globalAxisDeadZone = 0.05f; + private final Vector2f cursorPos = new Vector2f(); + private Joystick[] joysticks; + private final IntMap> bindings = new IntMap>(); + private final HashMap mappings = new HashMap(); + private final IntMap pressedButtons = new IntMap(); + private final IntMap axisValues = new IntMap(); + private final SafeArrayList rawListeners = new SafeArrayList(RawInputListener.class); + private final ArrayList inputQueue = new ArrayList(); + private final List joystickConnectionListeners = new ArrayList<>(); + + private static class Mapping { + + private final String name; + private final ArrayList triggers = new ArrayList(); + private final ArrayList listeners = new ArrayList(); + + public Mapping(String name) { + this.name = name; + } + } + + /** + * Initializes the InputManager. + * + *

This should only be called internally in {@link Application}. + * + * @param mouse + * @param keys + * @param joystick + * @param touch + * @throws IllegalArgumentException If either mouseInput or keyInput are null. + */ + public InputManager(MouseInput mouse, KeyInput keys, JoyInput joystick, TouchInput touch) { + if (keys == null || mouse == null) { + throw new IllegalArgumentException("Mouse or keyboard cannot be null"); + } + + this.keys = keys; + this.mouse = mouse; + this.joystick = joystick; + this.touch = touch; + + keys.setInputListener(this); + mouse.setInputListener(this); + if (joystick != null) { + joystick.setInputListener(this); + joysticks = joystick.loadJoysticks(this); + } + if (touch != null) { + touch.setInputListener(this); + } + + firstTime = keys.getInputTimeNanos(); + } + + private void invokeActions(int hash, boolean pressed) { + ArrayList maps = bindings.get(hash); + if (maps == null) { + return; + } + + int size = maps.size(); + for (int i = size - 1; i >= 0; i--) { + Mapping mapping = maps.get(i); + ArrayList listeners = mapping.listeners; + int listenerSize = listeners.size(); + for (int j = listenerSize - 1; j >= 0; j--) { + InputListener listener = listeners.get(j); + if (listener instanceof ActionListener) { + ((ActionListener) listener).onAction(mapping.name, pressed, frameTPF); + } + } + } + } + + private float computeAnalogValue(long timeDelta) { + if (safeMode || frameDelta == 0) { + return 1f; + } else { + return FastMath.clamp((float) timeDelta / (float) frameDelta, 0, 1); + } + } + + private void invokeTimedActions(int hash, long time, boolean pressed) { + if (!bindings.containsKey(hash)) { + return; + } + + if (pressed) { + pressedButtons.put(hash, time); + } else { + Long pressTimeObj = pressedButtons.remove(hash); + if (pressTimeObj == null) { + return; // under certain circumstances it can be null, ignore + } // the event then. + + long pressTime = pressTimeObj; + long lastUpdate = lastLastUpdateTime; + long releaseTime = time; + long timeDelta = releaseTime - Math.max(pressTime, lastUpdate); + + if (timeDelta > 0) { + invokeAnalogs(hash, computeAnalogValue(timeDelta), false); + } + } + } + + private void invokeUpdateActions() { + for (Entry pressedButton : pressedButtons) { + int hash = pressedButton.getKey(); + + long pressTime = pressedButton.getValue(); + long timeDelta = lastUpdateTime - Math.max(lastLastUpdateTime, pressTime); + + if (timeDelta > 0) { + invokeAnalogs(hash, computeAnalogValue(timeDelta), false); + } + } + + for (Entry axisValue : axisValues) { + int hash = axisValue.getKey(); + float value = axisValue.getValue(); + invokeAnalogs(hash, value * frameTPF, true); + } + } + + private void invokeAnalogs(int hash, float value, boolean isAxis) { + ArrayList maps = bindings.get(hash); + if (maps == null) { + return; + } + + if (!isAxis) { + value *= frameTPF; + } + + int size = maps.size(); + for (int i = size - 1; i >= 0; i--) { + Mapping mapping = maps.get(i); + ArrayList listeners = mapping.listeners; + int listenerSize = listeners.size(); + for (int j = listenerSize - 1; j >= 0; j--) { + InputListener listener = listeners.get(j); + if (listener instanceof AnalogListener) { + // NOTE: multiply by TPF for any button bindings + ((AnalogListener) listener).onAnalog(mapping.name, value, frameTPF); + } + } + } + } + + private void invokeAnalogsAndActions(int hash, float value, float effectiveDeadZone, boolean applyTpf) { + if (value < effectiveDeadZone) { + invokeAnalogs(hash, value, !applyTpf); + return; + } + + ArrayList maps = bindings.get(hash); + if (maps == null) { + return; + } + + boolean valueChanged = !axisValues.containsKey(hash); + if (applyTpf) { + value *= frameTPF; + } + + int size = maps.size(); + for (int i = size - 1; i >= 0; i--) { + Mapping mapping = maps.get(i); + ArrayList listeners = mapping.listeners; + int listenerSize = listeners.size(); + for (int j = listenerSize - 1; j >= 0; j--) { + InputListener listener = listeners.get(j); + + if (listener instanceof ActionListener && valueChanged) { + ((ActionListener) listener).onAction(mapping.name, true, frameTPF); + } + + if (listener instanceof AnalogListener) { + ((AnalogListener) listener).onAnalog(mapping.name, value, frameTPF); + } + + } + } + } + + /** + * Callback from RawInputListener. Do not use. + */ + @Override + public void beginInput() { + } + + /** + * Callback from RawInputListener. Do not use. + */ + @Override + public void endInput() { + } + + private void onJoyAxisEventQueued(JoyAxisEvent evt) { +// for (int i = 0; i < rawListeners.size(); i++){ +// rawListeners.get(i).onJoyAxisEvent(evt); +// } + + int joyId = evt.getJoyIndex(); + int axis = evt.getAxisIndex(); + float value = evt.getValue(); + float effectiveDeadZone = Math.max(globalAxisDeadZone, evt.getAxis().getDeadZone()); + if (value < effectiveDeadZone && value > -effectiveDeadZone) { + int hash1 = JoyAxisTrigger.joyAxisHash(joyId, axis, true); + int hash2 = JoyAxisTrigger.joyAxisHash(joyId, axis, false); + + Float val1 = axisValues.get(hash1); + Float val2 = axisValues.get(hash2); + + if (val1 != null && val1 > effectiveDeadZone) { + invokeActions(hash1, false); + } + if (val2 != null && val2 > effectiveDeadZone) { + invokeActions(hash2, false); + } + + axisValues.remove(hash1); + axisValues.remove(hash2); + + } else if (value < 0) { + int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, true); + int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, false); + + // Clear the reverse direction's actions in case we + // crossed center too quickly + Float otherVal = axisValues.get(otherHash); + if (otherVal != null && otherVal > effectiveDeadZone) { + invokeActions(otherHash, false); + } + + invokeAnalogsAndActions(hash, -value, effectiveDeadZone, true); + axisValues.put(hash, -value); + axisValues.remove(otherHash); + } else { + int hash = JoyAxisTrigger.joyAxisHash(joyId, axis, false); + int otherHash = JoyAxisTrigger.joyAxisHash(joyId, axis, true); + + // Clear the reverse direction's actions in case we + // crossed center too quickly + Float otherVal = axisValues.get(otherHash); + if (otherVal != null && otherVal > effectiveDeadZone) { + invokeActions(otherHash, false); + } + + invokeAnalogsAndActions(hash, value, effectiveDeadZone, true); + axisValues.put(hash, value); + axisValues.remove(otherHash); + } + } + + /** + * Callback from RawInputListener. Do not use. + */ + @Override + public void onJoyAxisEvent(JoyAxisEvent evt) { + if (!eventsPermitted) { + throw new UnsupportedOperationException("JoyInput has raised an event at an illegal time."); + } + + inputQueue.add(evt); + } + + private void onJoyButtonEventQueued(JoyButtonEvent evt) { +// for (int i = 0; i < rawListeners.size(); i++){ +// rawListeners.get(i).onJoyButtonEvent(evt); +// } + + int hash = JoyButtonTrigger.joyButtonHash(evt.getJoyIndex(), evt.getButtonIndex()); + invokeActions(hash, evt.isPressed()); + invokeTimedActions(hash, evt.getTime(), evt.isPressed()); + } + + /** + * Callback from RawInputListener. Do not use. + */ + @Override + public void onJoyButtonEvent(JoyButtonEvent evt) { + if (!eventsPermitted) { + throw new UnsupportedOperationException("JoyInput has raised an event at an illegal time."); + } + + inputQueue.add(evt); + } + + private void onMouseMotionEventQueued(MouseMotionEvent evt) { +// for (int i = 0; i < rawListeners.size(); i++){ +// rawListeners.get(i).onMouseMotionEvent(evt); +// } + + if (evt.getDX() != 0) { + float val = Math.abs(evt.getDX()) / 1024f; + invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_X, evt.getDX() < 0), val, globalAxisDeadZone, false); + } + if (evt.getDY() != 0) { + float val = Math.abs(evt.getDY()) / 1024f; + invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_Y, evt.getDY() < 0), val, globalAxisDeadZone, false); + } + if (evt.getDeltaWheel() != 0) { + float val = Math.abs(evt.getDeltaWheel()) / 100f; + invokeAnalogsAndActions(MouseAxisTrigger.mouseAxisHash(MouseInput.AXIS_WHEEL, evt.getDeltaWheel() < 0), val, globalAxisDeadZone, false); + } + } + + /** + * Sets the mouse cursor image or animation. + * Set cursor to null to show default system cursor. + * To hide the cursor completely, use {@link #setCursorVisible(boolean) }. + * + * @param jmeCursor The cursor to set, or null to reset to system cursor. + * + * @see JmeCursor + */ + public void setMouseCursor(JmeCursor jmeCursor) { + mouse.setNativeCursor(jmeCursor); + } + + /** + * Callback from RawInputListener. Do not use. + * + * @param evt event to add to the input queue (not null) + */ + @Override + public void onMouseMotionEvent(MouseMotionEvent evt) { + /* + * If events aren't allowed, the event may be a "first mouse event" + * triggered by the constructor setting the mouse listener. + * In that case, use the event to initialize the cursor position, + * but don't queue it for further processing. + * This is part of the fix for issue #792. + */ + cursorPos.set(evt.getX(), evt.getY()); + if (eventsPermitted) { + inputQueue.add(evt); + } + } + + private void onMouseButtonEventQueued(MouseButtonEvent evt) { + int hash = MouseButtonTrigger.mouseButtonHash(evt.getButtonIndex()); + invokeActions(hash, evt.isPressed()); + invokeTimedActions(hash, evt.getTime(), evt.isPressed()); + } + + /** + * Callback from RawInputListener. Do not use. + */ + @Override + public void onMouseButtonEvent(MouseButtonEvent evt) { + if (!eventsPermitted) { + throw new UnsupportedOperationException("MouseInput has raised an event at an illegal time."); + } + //updating cursor pos on click, so that non android touch events can properly update cursor position. + cursorPos.set(evt.getX(), evt.getY()); + inputQueue.add(evt); + } + + private void onKeyEventQueued(KeyInputEvent evt) { + if (evt.isRepeating()) { + return; // repeat events not used for bindings + } + + int hash = KeyTrigger.keyHash(evt.getKeyCode()); + invokeActions(hash, evt.isPressed()); + invokeTimedActions(hash, evt.getTime(), evt.isPressed()); + } + + /** + * Callback from RawInputListener. Do not use. + */ + @Override + public void onKeyEvent(KeyInputEvent evt) { + if (!eventsPermitted) { + throw new UnsupportedOperationException("KeyInput has raised an event at an illegal time."); + } + + inputQueue.add(evt); + } + + /** + * Set the deadzone for joystick axes. + * + *

{@link ActionListener#onAction(java.lang.String, boolean, float) } + * events will only be raised if the joystick axis value is greater than + * the deadZone. + * + * @param deadZone the deadzone for joystick axes. + */ + public void setAxisDeadZone(float deadZone) { + this.globalAxisDeadZone = deadZone; + } + + /** + * Returns the deadzone for joystick axes. + * + * @return the deadzone for joystick axes. + */ + public float getAxisDeadZone() { + return globalAxisDeadZone; + } + + /** + * Adds a new listener to receive events on the given mappings. + * + *

The given InputListener will be registered to receive events + * on the specified mapping names. When a mapping raises an event, the + * listener will have its appropriate method invoked, either + * {@link ActionListener#onAction(java.lang.String, boolean, float) } + * or {@link AnalogListener#onAnalog(java.lang.String, float, float) } + * depending on which interface the listener implements. + * If the listener implements both interfaces, then it will receive the + * appropriate event for each method. + * + * @param listener The listener to register to receive input events. + * @param mappingNames The mapping names which the listener will receive + * events from. + * + * @see InputManager#removeListener(com.jme3.input.controls.InputListener) + */ + public void addListener(InputListener listener, String... mappingNames) { + for (String mappingName : mappingNames) { + Mapping mapping = mappings.get(mappingName); + if (mapping == null) { + mapping = new Mapping(mappingName); + mappings.put(mappingName, mapping); + } + if (!mapping.listeners.contains(listener)) { + mapping.listeners.add(listener); + } + } + } + + /** + * Removes a listener from receiving events. + * + *

This will unregister the listener from any mappings that it + * was previously registered with via + * {@link InputManager#addListener(com.jme3.input.controls.InputListener, java.lang.String[]) }. + * + * @param listener The listener to unregister. + * + * @see InputManager#addListener(com.jme3.input.controls.InputListener, java.lang.String[]) + */ + public void removeListener(InputListener listener) { + for (Mapping mapping : mappings.values()) { + mapping.listeners.remove(listener); + } + } + + /** + * Create a new mapping to the given triggers. + * + *

+ * The given mapping will be assigned to the given triggers, when + * any of the triggers given raise an event, the listeners + * registered to the mappings will receive appropriate events. + * + * @param mappingName The mapping name to assign. + * @param triggers The triggers to which the mapping is to be registered. + * + * @see InputManager#deleteMapping(java.lang.String) + */ + public void addMapping(String mappingName, Trigger... triggers) { + Mapping mapping = mappings.get(mappingName); + if (mapping == null) { + mapping = new Mapping(mappingName); + mappings.put(mappingName, mapping); + } + + for (Trigger trigger : triggers) { + int hash = trigger.triggerHashCode(); + ArrayList names = bindings.get(hash); + if (names == null) { + names = new ArrayList(); + bindings.put(hash, names); + } + if (!names.contains(mapping)) { + names.add(mapping); + mapping.triggers.add(hash); + } else { + logger.log(Level.WARNING, "Attempted to add mapping \"{0}\" twice to trigger.", mappingName); + } + } + } + + /** + * Returns true if this InputManager has a mapping registered + * for the given mappingName. + * + * @param mappingName The mapping name to check. + * + * @see InputManager#addMapping(java.lang.String, com.jme3.input.controls.Trigger[]) + * @see InputManager#deleteMapping(java.lang.String) + */ + public boolean hasMapping(String mappingName) { + return mappings.containsKey(mappingName); + } + + /** + * Deletes a mapping from receiving trigger events. + * + *

+ * The given mapping will no longer be assigned to receive trigger + * events. + * + * @param mappingName The mapping name to unregister. + * + * @see InputManager#addMapping(java.lang.String, com.jme3.input.controls.Trigger[]) + */ + public void deleteMapping(String mappingName) { + Mapping mapping = mappings.remove(mappingName); + if (mapping == null) { + //throw new IllegalArgumentException("Cannot find mapping: " + mappingName); + logger.log(Level.WARNING, "Cannot find mapping to be removed, skipping: {0}", mappingName); + return; + } + + ArrayList triggers = mapping.triggers; + for (int i = triggers.size() - 1; i >= 0; i--) { + int hash = triggers.get(i); + ArrayList maps = bindings.get(hash); + maps.remove(mapping); + } + } + + /** + * Deletes a specific trigger registered to a mapping. + * + *

+ * The given mapping will no longer receive events raised by the + * trigger. + * + * @param mappingName The mapping name to cease receiving events from the + * trigger. + * @param trigger The trigger to no longer invoke events on the mapping. + */ + public void deleteTrigger(String mappingName, Trigger trigger) { + Mapping mapping = mappings.get(mappingName); + if (mapping == null) { + throw new IllegalArgumentException("Cannot find mapping: " + mappingName); + } + + ArrayList maps = bindings.get(trigger.triggerHashCode()); + maps.remove(mapping); + + } + + /** + * Clears all the input mappings from this InputManager. + * Consequently, also clears all of the + * InputListeners as well. + */ + public void clearMappings() { + mappings.clear(); + bindings.clear(); + reset(); + } + + /** + * Do not use. + * Called to reset pressed keys or buttons when focus is restored. + */ + public void reset() { + pressedButtons.clear(); + axisValues.clear(); + } + + /** + * Returns whether the mouse cursor is visible or not. + * + *

By default the cursor is visible. + * + * @return whether the mouse cursor is visible or not. + * + * @see InputManager#setCursorVisible(boolean) + */ + public boolean isCursorVisible() { + return mouseVisible; + } + + /** + * Set whether the mouse cursor should be visible or not. + * + * @param visible whether the mouse cursor should be visible or not. + */ + public void setCursorVisible(boolean visible) { + if (mouseVisible != visible) { + mouseVisible = visible; + mouse.setCursorVisible(mouseVisible); + } + } + + /** + * Returns the current cursor position. The position is relative to the + * bottom-left of the screen and is in pixels. + * + * @return the current cursor position + */ + public Vector2f getCursorPosition() { + return cursorPos; + } + + /** + * Returns an array of all joysticks installed on the system. + * + * @return an array of all joysticks installed on the system. + */ + public Joystick[] getJoysticks() { + return joysticks; + } + + /** + * Adds a {@link RawInputListener} to receive raw input events. + * + *

+ * Any raw input listeners registered to this InputManager + * will receive raw input events first, before they get handled + * by the InputManager itself. The listeners are + * each processed in the order they were added, e.g. FIFO. + *

+ * If a raw input listener has handled the event and does not wish + * other listeners down the list to process the event, it may set the + * {@link InputEvent#setConsumed() consumed flag} to indicate the + * event was consumed and shouldn't be processed any further. + * The listener may do this either at each of the event callbacks + * or at the {@link RawInputListener#endInput() } method. + * + * @param listener A listener to receive raw input events. + * + * @see RawInputListener + */ + public void addRawInputListener(RawInputListener listener) { + rawListeners.add(listener); + } + + /** + * Removes a {@link RawInputListener} so that it no longer + * receives raw input events. + * + * @param listener The listener to cease receiving raw input events. + * + * @see InputManager#addRawInputListener(com.jme3.input.RawInputListener) + */ + public void removeRawInputListener(RawInputListener listener) { + rawListeners.remove(listener); + } + + /** + * Clears all {@link RawInputListener}s. + * + * @see InputManager#addRawInputListener(com.jme3.input.RawInputListener) + */ + public void clearRawInputListeners() { + rawListeners.clear(); + } + + /** + * Enable simulation of mouse events. Used for touchscreen input only. + * + * @param value True to enable simulation of mouse events + */ + public void setSimulateMouse(boolean value) { + if (touch != null) { + touch.setSimulateMouse(value); + } + } + /** + * @deprecated Use isSimulateMouse + * Returns state of simulation of mouse events. Used for touchscreen input only. + * + */ + public boolean getSimulateMouse() { + if (touch != null) { + return touch.isSimulateMouse(); + } else { + return false; + } + } + + /** + * Returns state of simulation of mouse events. Used for touchscreen input only. + * + */ + public boolean isSimulateMouse() { + if (touch != null) { + return touch.isSimulateMouse(); + } else { + return false; + } + } + + /** + * Enable simulation of keyboard events. Used for touchscreen input only. + * + * @param value True to enable simulation of keyboard events + */ + public void setSimulateKeyboard(boolean value) { + if (touch != null) { + touch.setSimulateKeyboard(value); + } + } + + /** + * Returns state of simulation of key events. Used for touchscreen input only. + * + */ + public boolean isSimulateKeyboard() { + if (touch != null) { + return touch.isSimulateKeyboard(); + } else { + return false; + } + } + + private void processQueue() { + int queueSize = inputQueue.size(); + RawInputListener[] array = rawListeners.getArray(); + + for (RawInputListener listener : array) { + listener.beginInput(); + + for (int j = 0; j < queueSize; j++) { + InputEvent event = inputQueue.get(j); + if (event.isConsumed()) { + continue; + } + + if (event instanceof MouseMotionEvent) { + listener.onMouseMotionEvent((MouseMotionEvent) event); + } else if (event instanceof KeyInputEvent) { + listener.onKeyEvent((KeyInputEvent) event); + } else if (event instanceof MouseButtonEvent) { + listener.onMouseButtonEvent((MouseButtonEvent) event); + } else if (event instanceof JoyAxisEvent) { + listener.onJoyAxisEvent((JoyAxisEvent) event); + } else if (event instanceof JoyButtonEvent) { + listener.onJoyButtonEvent((JoyButtonEvent) event); + } else if (event instanceof TouchEvent) { + listener.onTouchEvent((TouchEvent) event); + } else { + assert false; + } + } + + listener.endInput(); + } + + for (int i = 0; i < queueSize; i++) { + InputEvent event = inputQueue.get(i); + if (event.isConsumed()) { + continue; + } + + if (event instanceof MouseMotionEvent) { + onMouseMotionEventQueued((MouseMotionEvent) event); + } else if (event instanceof KeyInputEvent) { + onKeyEventQueued((KeyInputEvent) event); + } else if (event instanceof MouseButtonEvent) { + onMouseButtonEventQueued((MouseButtonEvent) event); + } else if (event instanceof JoyAxisEvent) { + onJoyAxisEventQueued((JoyAxisEvent) event); + } else if (event instanceof JoyButtonEvent) { + onJoyButtonEventQueued((JoyButtonEvent) event); + } else if (event instanceof TouchEvent) { + onTouchEventQueued((TouchEvent) event); + } else { + assert false; + } + // larynx, 2011.06.10 - flag event as reusable because + // the android input uses a non-allocating ringbuffer which + // needs to know when the event is not anymore in inputQueue + // and therefore can be reused. + event.setConsumed(); + } + + inputQueue.clear(); + } + + /** + * Updates the InputManager. + * This will query current input devices and send + * appropriate events to registered listeners. + * + * @param tpf Time per frame value. + */ + public void update(float tpf) { + frameTPF = tpf; + + // Activate safemode if the TPF value is so small + // that rounding errors are inevitable + safeMode = tpf < 0.015f; + + long currentTime = keys.getInputTimeNanos(); + frameDelta = currentTime - lastUpdateTime; + + eventsPermitted = true; + + keys.update(); + mouse.update(); + if (joystick != null) { + joystick.update(); + } + if (touch != null) { + touch.update(); + } + + eventsPermitted = false; + + processQueue(); + invokeUpdateActions(); + + lastLastUpdateTime = lastUpdateTime; + lastUpdateTime = currentTime; + } + + /** + * Dispatches touch events to touch listeners + * @param evt The touch event to be dispatched to all onTouch listeners + */ + public void onTouchEventQueued(TouchEvent evt) { + ArrayList maps = bindings.get(TouchTrigger.touchHash(evt.getKeyCode())); + if (maps == null) { + return; + } + + int size = maps.size(); + for (int i = size - 1; i >= 0; i--) { + Mapping mapping = maps.get(i); + ArrayList listeners = mapping.listeners; + int listenerSize = listeners.size(); + for (int j = listenerSize - 1; j >= 0; j--) { + InputListener listener = listeners.get(j); + if (listener instanceof TouchListener) { + ((TouchListener) listener).onTouch(mapping.name, evt, frameTPF); + } + } + } + } + + /** + * Callback from RawInputListener. Do not use. + */ + @Override + public void onTouchEvent(TouchEvent evt) { + if (!eventsPermitted) { + throw new UnsupportedOperationException("TouchInput has raised an event at an illegal time."); + } + cursorPos.set(evt.getX(), evt.getY()); + inputQueue.add(evt); + } + + /** + * Re-sets the joystick list when a joystick is added or removed. + * This should only be called internally. + * + * @param joysticks + */ + public void setJoysticks(Joystick[] joysticks) { + this.joysticks = joysticks; + } + + /** + * Add a listener that reports when a joystick has been added or removed. + * Currently only implemented in LWJGL3 + * @param listener the listner. + */ + public boolean addJoystickConnectionListener(JoystickConnectionListener listener) { + return joystickConnectionListeners.add(listener); + } + + /** + * Remove an existing listener. + * @param listener the listener to remove. + * @return true if this listener was removed, or false if it was not found. + */ + public boolean removeJoystickConnectionListener(JoystickConnectionListener listener) { + return joystickConnectionListeners.remove(listener); + } + + /** + * Remove all joystick connection listeners. + */ + public void clearJoystickConnectionListeners() { + joystickConnectionListeners.clear(); + } + + /** + * Called when a joystick has been connected. + * This should only be called internally. + * @param joystick the joystick that has been connected. + */ + public void fireJoystickConnectedEvent(Joystick joystick) { + for (JoystickConnectionListener listener : joystickConnectionListeners) { + listener.onConnected(joystick); + } + } + + /** + * Called when a joystick has been disconnected. + * This should only be called internally. + * @param joystick the joystick that has been disconnected. + */ + public void fireJoystickDisconnectedEvent(Joystick joystick) { + for (JoystickConnectionListener listener : joystickConnectionListeners) { + listener.onDisconnected(joystick); + } + } + +} diff --git a/jme3-core/src/main/java/com/jme3/input/JoystickAxis.java b/jme3-core/src/main/java/com/jme3/input/JoystickAxis.java index c951ef321f..45a0733115 100644 --- a/jme3-core/src/main/java/com/jme3/input/JoystickAxis.java +++ b/jme3-core/src/main/java/com/jme3/input/JoystickAxis.java @@ -42,6 +42,29 @@ public interface JoystickAxis { public static final String Y_AXIS = "y"; public static final String Z_AXIS = "z"; public static final String Z_ROTATION = "rz"; + public static final String LEFT_TRIGGER = "rx"; + public static final String RIGHT_TRIGGER = "ry"; + + // Note: the left/right trigger bit may be a bit controversial in + // the sense that this is one case where XBox controllers make a lot + // more sense. + // I've seen the following mappings for various things: + // + // Axis | XBox | Non-Xbox (generally) (includes actual Sony PS4 controllers) + // --------------+-------+--------------- + // left trigger | z | rx (also button 6) + // right trigger | rz | ry (also button 7) + // left stick x | x | x + // left stick y | y | y + // right stick x | rx | z + // right stick y | ry | rz + // + // The issue is that in all cases I've seen, the XBox controllers will + // use the name "xbox" somewhere in their name. The Non-XBox controllers + // never mention anything uniform... even the PS4 controller only calls + // itself "Wireless Controller". In that light, it seems easier to make + // the default the ugly case and the "XBox" way the exception because it + // can more easily be identified. public static final String POV_X = "pov_x"; public static final String POV_Y = "pov_y"; diff --git a/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java b/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java index ee2434d543..db3b4aec99 100644 --- a/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java +++ b/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java @@ -41,6 +41,8 @@ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** @@ -63,6 +65,10 @@ public class JoystickCompatibilityMappings { private static Map> joystickMappings = new HashMap>(); + // Remaps names by regex. + private static Map nameRemappings = new HashMap<>(); + private static Map nameCache = new HashMap<>(); + static { loadDefaultMappings(); } @@ -81,11 +87,29 @@ protected static Map getMappings( String joystickName, boolean cr * is a mapping for it otherwise it returns the original name. */ public static String remapComponent( String joystickName, String componentId ) { - Map map = getMappings(joystickName.trim(), false); - if( map == null ) + logger.log(Level.FINE, "remapComponent(" + joystickName + ", " + componentId + ")"); + + // Always try the specific name first. + joystickName = joystickName.trim(); + Map map = getMappings(joystickName, false); + if( map != null && map.containsKey(componentId) ) { + logger.log(Level.FINE, "returning remapped:" + map.get(componentId)); + return map.get(componentId); + } + // Try the normalized name + joystickName = getNormalizedName(joystickName); + logger.log(Level.FINE, "normalized joystick name:" + joystickName); + if( joystickName == null ) { + return componentId; + } + map = getMappings(joystickName, false); + if( map == null ) { return componentId; - if( !map.containsKey(componentId) ) + } + if( !map.containsKey(componentId) ) { return componentId; + } + logger.log(Level.FINE, "returning remapped:" + map.get(componentId)); return map.get(componentId); } @@ -130,8 +154,36 @@ public static void addMappings( Properties p ) { String stick = key.substring(0, split).trim(); String component = key.substring(split+1).trim(); String value = String.valueOf(e.getValue()).trim(); - addMapping(stick, component, value); + if( "regex".equals(component) ) { + // It's a name remapping + addJoystickNameRegex(value, stick); + } + addMapping(stick, component, value); + } + } + + /** + * Maps a regular expression to a normalized name for that joystick. + */ + public static void addJoystickNameRegex( String regex, String name ) { + logger.log(Level.FINE, "addJoystickNameRegex(" + regex + ", " + name + ")"); + nameRemappings.put(Pattern.compile(regex), name); + } + + protected static String getNormalizedName( String name ) { + String result = nameCache.get(name); + if( result != null ) { + return result; + } + for( Map.Entry e : nameRemappings.entrySet() ) { + Pattern p = e.getKey(); + Matcher m = p.matcher(name); + if( m.matches() ) { + nameCache.put(name, e.getValue()); + return e.getValue(); + } } + return null; } /** diff --git a/jme3-core/src/main/java/com/jme3/input/JoystickConnectionListener.java b/jme3-core/src/main/java/com/jme3/input/JoystickConnectionListener.java new file mode 100644 index 0000000000..17457f5a4d --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/input/JoystickConnectionListener.java @@ -0,0 +1,21 @@ +package com.jme3.input; + +/** + * Listens for the state of a joystick connection. + * @author jayfella + */ +public interface JoystickConnectionListener { + + /** + * Occurs when a new joystick has been detected. + * @param joystick the joystick that has been detected. + */ + void onConnected(Joystick joystick); + + /** + * Occurs when an existing joystick has been disconnected. + * @param joystick the joystick that has been disconnected. + */ + void onDisconnected(Joystick joystick); + +} diff --git a/jme3-core/src/main/java/com/jme3/input/event/InputEvent.java b/jme3-core/src/main/java/com/jme3/input/event/InputEvent.java index 761abc1aa1..e22c2a3d0a 100644 --- a/jme3-core/src/main/java/com/jme3/input/event/InputEvent.java +++ b/jme3-core/src/main/java/com/jme3/input/event/InputEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ public abstract class InputEvent { * The time when the event occurred. This is relative to * {@link Input#getInputTimeNanos() }. * - * @return time when the event occured + * @return time when the event occurred */ public long getTime(){ return time; diff --git a/jme3-core/src/main/java/com/jme3/input/event/JoyAxisEvent.java b/jme3-core/src/main/java/com/jme3/input/event/JoyAxisEvent.java index 5ba56c43ba..7e63fc68fb 100644 --- a/jme3-core/src/main/java/com/jme3/input/event/JoyAxisEvent.java +++ b/jme3-core/src/main/java/com/jme3/input/event/JoyAxisEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,6 @@ package com.jme3.input.event; import com.jme3.input.InputManager; -import com.jme3.input.Joystick; import com.jme3.input.JoystickAxis; /** @@ -53,7 +52,7 @@ public JoyAxisEvent(JoystickAxis axis, float value) { /** * Returns the JoystickAxis that triggered this event. * - * @see JoystickAxis#assignAxis(java.lang.String, java.lang.String, int) + * @see com.jme3.input.JoystickAxis#assignAxis(java.lang.String, java.lang.String) */ public JoystickAxis getAxis() { return axis; @@ -64,7 +63,7 @@ public JoystickAxis getAxis() { * * @return joystick axis index. * - * @see Joystick#assignAxis(java.lang.String, java.lang.String, int) + * @see com.jme3.input.JoystickAxis#assignAxis(java.lang.String, java.lang.String) */ public int getAxisIndex() { return axis.getAxisId(); diff --git a/jme3-core/src/main/java/com/jme3/input/event/JoyButtonEvent.java b/jme3-core/src/main/java/com/jme3/input/event/JoyButtonEvent.java index 4a2c701d71..f69e3f0299 100644 --- a/jme3-core/src/main/java/com/jme3/input/event/JoyButtonEvent.java +++ b/jme3-core/src/main/java/com/jme3/input/event/JoyButtonEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,8 @@ public JoyButtonEvent(JoystickButton button, boolean pressed) { /** * Returns the JoystickButton that triggered this event. * - * @see JoystickAxis#assignAxis(java.lang.String, java.lang.String, int) + * @see com.jme3.input.JoystickAxis#assignAxis(java.lang.String, java.lang.String) + * @return the button */ public JoystickButton getButton() { return button; diff --git a/jme3-core/src/main/java/com/jme3/light/AmbientLight.java b/jme3-core/src/main/java/com/jme3/light/AmbientLight.java index a2dc1cd389..531c7b5d0b 100644 --- a/jme3-core/src/main/java/com/jme3/light/AmbientLight.java +++ b/jme3-core/src/main/java/com/jme3/light/AmbientLight.java @@ -34,7 +34,6 @@ import com.jme3.bounding.BoundingBox; import com.jme3.bounding.BoundingSphere; import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.scene.Spatial; import com.jme3.util.TempVars; diff --git a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java index 6613b84288..d5b28fe55c 100644 --- a/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java +++ b/jme3-core/src/main/java/com/jme3/light/DirectionalLight.java @@ -132,6 +132,11 @@ public Type getType() { return Type.Directional; } + @Override + public String toString() { + return getClass().getSimpleName() + "[name=" + name + ", direction=" + direction + ", color=" + color + ", enabled=" + enabled + "]"; + } + @Override public void write(JmeExporter ex) throws IOException { super.write(ex); diff --git a/jme3-core/src/main/java/com/jme3/light/LightProbe.java b/jme3-core/src/main/java/com/jme3/light/LightProbe.java index d6d7168776..c2e011c6c1 100644 --- a/jme3-core/src/main/java/com/jme3/light/LightProbe.java +++ b/jme3-core/src/main/java/com/jme3/light/LightProbe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,8 @@ * - The irradiance spherical harmonics factors (used for indirect diffuse lighting in the PBR pipeline). * - The prefiltered environment map (used for indirect specular lighting and reflection in the PBE pipeline). * Note that when instantiating the LightProbe, both of those structures are null. - * To compute them see {@link LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Node)} + * To compute them see + * {@link com.jme3.environment.LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Spatial)} * and {@link EnvironmentCamera}. * * The light probe has an area of effect centered on its position. It can have a Spherical area or an Oriented Box area @@ -86,7 +87,9 @@ public enum AreaType{ /** * Empty constructor used for serialization. - * You should never call it, use {@link LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Node)} instead + * You should never call it, use + * {@link com.jme3.environment.LightProbeFactory#makeProbe(com.jme3.environment.EnvironmentCamera, com.jme3.scene.Spatial)} + * instead. */ public LightProbe() { } diff --git a/jme3-core/src/main/java/com/jme3/light/OrientedBoxProbeArea.java b/jme3-core/src/main/java/com/jme3/light/OrientedBoxProbeArea.java index 84bef1b3f8..6b1e1b5940 100644 --- a/jme3-core/src/main/java/com/jme3/light/OrientedBoxProbeArea.java +++ b/jme3-core/src/main/java/com/jme3/light/OrientedBoxProbeArea.java @@ -23,7 +23,7 @@ public OrientedBoxProbeArea() { } public OrientedBoxProbeArea(Transform transform) { - transform.set(transform); + this.transform.set(transform); updateMatrix(); } diff --git a/jme3-core/src/main/java/com/jme3/light/PointLight.java b/jme3-core/src/main/java/com/jme3/light/PointLight.java index dddf062875..4d9f306a06 100644 --- a/jme3-core/src/main/java/com/jme3/light/PointLight.java +++ b/jme3-core/src/main/java/com/jme3/light/PointLight.java @@ -39,7 +39,6 @@ import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; -import com.jme3.math.FastMath; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; diff --git a/jme3-core/src/main/java/com/jme3/light/SphereProbeArea.java b/jme3-core/src/main/java/com/jme3/light/SphereProbeArea.java index 9c2d3fbe86..ded9bfffa3 100644 --- a/jme3-core/src/main/java/com/jme3/light/SphereProbeArea.java +++ b/jme3-core/src/main/java/com/jme3/light/SphereProbeArea.java @@ -8,7 +8,6 @@ import com.jme3.util.TempVars; import java.io.IOException; -import java.util.logging.Level; public class SphereProbeArea implements ProbeArea { diff --git a/jme3-core/src/main/java/com/jme3/material/Material.java b/jme3-core/src/main/java/com/jme3/material/Material.java index ddd75ace7a..ea0ac70b91 100644 --- a/jme3-core/src/main/java/com/jme3/material/Material.java +++ b/jme3-core/src/main/java/com/jme3/material/Material.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,6 @@ import com.jme3.material.RenderState.BlendMode; import com.jme3.material.RenderState.FaceCullMode; import com.jme3.material.TechniqueDef.LightMode; -import com.jme3.material.TechniqueDef.ShadowMode; import com.jme3.math.*; import com.jme3.renderer.Caps; import com.jme3.renderer.RenderManager; @@ -361,7 +360,7 @@ public boolean isReceivesShadows() { *

This value is merely a marker, by itself it does nothing. * Generally model loaders will use this marker to indicate * the material should receive shadows and therefore any - * geometries using it should have the {@link ShadowMode#Receive} set + * geometries using it should have {@link com.jme3.renderer.queue.RenderQueue.ShadowMode#Receive} set * on them. * * @param receivesShadows if the material should receive shadows or not. @@ -942,7 +941,7 @@ private void resetUniformsNotSetByCurrent(Shader shader) { * or the first default technique that the renderer supports * (based on the technique's {@link TechniqueDef#getRequiredCaps() requested rendering capabilities})

    *
  • If the technique has been changed since the last frame, then it is notified via - * {@link Technique#makeCurrent(com.jme3.asset.AssetManager, boolean, java.util.EnumSet) + * {@link Technique#makeCurrent(com.jme3.renderer.RenderManager, com.jme3.util.SafeArrayList, com.jme3.util.SafeArrayList, com.jme3.light.LightList, java.util.EnumSet) * Technique.makeCurrent()}. * If the technique wants to use a shader to render the model, it should load it at this part - * the shader should have all the proper defines as declared in the technique definition, @@ -958,7 +957,7 @@ private void resetUniformsNotSetByCurrent(Shader shader) { *
  • {@link RenderManager#getForcedRenderState() RenderManager's Forced RenderState} * - i.e. renderstate requested by a {@link com.jme3.post.SceneProcessor} or * post-processing filter.
  • - *
  • If the technique {@link TechniqueDef#isUsingShaders() uses a shader}, then the uniforms of the shader must be updated.
      + *
    • If the technique uses a shader, then the uniforms of the shader must be updated.
        *
      • Uniforms bound to material parameters are updated based on the current material parameter values.
      • *
      • Uniforms bound to world parameters are updated from the RenderManager. * Internally {@link UniformBindingManager} is used for this task.
      • @@ -973,8 +972,8 @@ private void resetUniformsNotSetByCurrent(Shader shader) { * rendered with {@link BlendMode#AlphaAdditive alpha-additive} blending and depth writing disabled. *
      *
    • For techniques that do not use shaders, - * fixed function OpenGL is used to render the model (see {@link GL1Renderer} interface):
        - *
      • OpenGL state ({@link FixedFuncBinding}) that is bound to material parameters is updated.
      • + * fixed function OpenGL is used to render the model (see {@link com.jme3.renderer.opengl.GLRenderer} interface):
          + *
        • OpenGL state that is bound to material parameters is updated.
        • *
        • The texture set on the material is uploaded and bound. * Currently only 1 texture is supported for fixed function techniques.
        • *
        • If the technique uses lighting, then OpenGL lighting state is updated diff --git a/jme3-core/src/main/java/com/jme3/material/MaterialDef.java b/jme3-core/src/main/java/com/jme3/material/MaterialDef.java index 537eac37b8..59e84db62c 100644 --- a/jme3-core/src/main/java/com/jme3/material/MaterialDef.java +++ b/jme3-core/src/main/java/com/jme3/material/MaterialDef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,13 +32,13 @@ package com.jme3.material; import com.jme3.asset.AssetManager; -import com.jme3.renderer.RenderManager; import com.jme3.shader.VarType; import com.jme3.texture.image.ColorSpace; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; +import com.jme3.texture.Texture; /** * Describes a J3MD (Material definition). @@ -129,13 +129,12 @@ public void addMaterialParam(VarType type, String name, Object value) { * * @param type Type of the parameter * @param name Name of the parameter + * @param colorSpace the color space of the texture required by this texture param * @param value Default value of the parameter - * @param ffBinding Fixed function binding for the parameter - * @param colorSpace the color space of the texture required by thiis texture param * @see ColorSpace */ - public void addMaterialParamTexture(VarType type, String name, ColorSpace colorSpace) { - matParams.put(name, new MatParamTexture(type, name, null, colorSpace)); + public void addMaterialParamTexture(VarType type, String name, ColorSpace colorSpace,Texture value) { + matParams.put(name, new MatParamTexture(type, name, value, colorSpace)); } /** diff --git a/jme3-core/src/main/java/com/jme3/material/RenderState.java b/jme3-core/src/main/java/com/jme3/material/RenderState.java index d2a557c65c..fea4d26e21 100644 --- a/jme3-core/src/main/java/com/jme3/material/RenderState.java +++ b/jme3-core/src/main/java/com/jme3/material/RenderState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -303,6 +303,17 @@ public enum BlendMode { * (1 - Source Alpha) * Dest Color -> (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) */ Alpha, + /** + * Alpha blending, interpolates to source color from dest color + * using source alpha. + * The resulting alpha is the sum between the source alpha and the destination alpha. + *

          + * Result.rgb = Source Alpha * Source Color + + * (1 - Source Alpha) * Dest Color -> (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) + * Result.a = 1 * Source Alpha + 1 * Dest Alpha -> (GL_ONE, GL_ONE) + * + */ + AlphaSumA, /** * Multiplies the source and dest colors. *

          @@ -975,7 +986,8 @@ public void setAlphaFunc(TestFunction alphaFunc) { /** * Sets the mesh line width. - * This is to use in conjunction with {@link #setWireframe(boolean)} or with a mesh in {@link Mesh.Mode#Lines} mode. + * Use this in conjunction with {@link #setWireframe(boolean)} or with a mesh in + * {@link com.jme3.scene.Mesh.Mode#Lines} mode. * @param lineWidth the line width. */ public void setLineWidth(float lineWidth) { diff --git a/jme3-core/src/main/java/com/jme3/material/Technique.java b/jme3-core/src/main/java/com/jme3/material/Technique.java index 3ae32814ee..5b02d77e73 100644 --- a/jme3-core/src/main/java/com/jme3/material/Technique.java +++ b/jme3-core/src/main/java/com/jme3/material/Technique.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -183,7 +183,7 @@ public DefineList getDynamicDefines() { * * @deprecated Preset defines are precompiled into * {@link TechniqueDef#getShaderPrologue()}, whereas dynamic defines are - * available via {@link #getParamDefines()}. + * available via {@link #getDynamicDefines()}. */ @Deprecated public DefineList getAllDefines() { diff --git a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java index 1b01115220..cd0c1da866 100644 --- a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java +++ b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -290,7 +290,7 @@ public void setRenderState(RenderState renderState) { * * @param noRender not render or render ? * - * @see NoRender + * @see #isNoRender() */ public void setNoRender(boolean noRender) { this.noRender = noRender; @@ -374,7 +374,7 @@ public String getShaderPrologue() { * @param paramName The parameter name to look up * @return The define name * - * @see #addShaderParamDefine(java.lang.String, java.lang.String) + * @see #addShaderParamDefine(java.lang.String, com.jme3.shader.VarType, java.lang.String) */ public String getShaderParamDefine(String paramName){ Integer defineId = paramToDefineId.get(paramName); @@ -610,7 +610,7 @@ public String getShaderProgramName(Shader.ShaderType shaderType){ /** * returns the weight of the technique def * - * @return + * @return the weight */ public float getWeight() { return weight; @@ -723,7 +723,7 @@ public void setShaderNodes(List shaderNodes) { /** * Returns the Enum containing the ShaderProgramNames; - * @return + * @return the pre-existing EnumMap */ public EnumMap getShaderProgramNames() { return shaderNames; @@ -731,7 +731,7 @@ public EnumMap getShaderProgramNames() { /** * Returns the Enum containing the ShaderProgramLanguages; - * @return + * @return the pre-existing EnumMap */ public EnumMap getShaderProgramLanguages() { return shaderLanguages; diff --git a/jme3-core/src/main/java/com/jme3/material/logic/MultiPassLightingLogic.java b/jme3-core/src/main/java/com/jme3/material/logic/MultiPassLightingLogic.java index d239681bc3..8d4b639567 100644 --- a/jme3-core/src/main/java/com/jme3/material/logic/MultiPassLightingLogic.java +++ b/jme3-core/src/main/java/com/jme3/material/logic/MultiPassLightingLogic.java @@ -31,8 +31,6 @@ */ package com.jme3.material.logic; -import com.jme3.asset.AssetManager; -import com.jme3.light.AmbientLight; import com.jme3.light.DirectionalLight; import com.jme3.light.Light; import com.jme3.light.LightList; @@ -41,20 +39,16 @@ import com.jme3.material.RenderState; import com.jme3.material.TechniqueDef; import com.jme3.math.ColorRGBA; -import com.jme3.math.FastMath; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.math.Vector4f; -import com.jme3.renderer.Caps; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; import com.jme3.scene.Geometry; -import com.jme3.shader.DefineList; import com.jme3.shader.Shader; import com.jme3.shader.Uniform; import com.jme3.shader.VarType; import com.jme3.util.TempVars; -import java.util.EnumSet; public final class MultiPassLightingLogic extends DefaultTechniqueDefLogic { diff --git a/jme3-core/src/main/java/com/jme3/material/logic/SinglePassAndImageBasedLightingLogic.java b/jme3-core/src/main/java/com/jme3/material/logic/SinglePassAndImageBasedLightingLogic.java index f80c8274ae..513c35d6d9 100644 --- a/jme3-core/src/main/java/com/jme3/material/logic/SinglePassAndImageBasedLightingLogic.java +++ b/jme3-core/src/main/java/com/jme3/material/logic/SinglePassAndImageBasedLightingLogic.java @@ -32,7 +32,6 @@ package com.jme3.material.logic; import com.jme3.asset.AssetManager; -import com.jme3.bounding.BoundingSphere; import com.jme3.light.*; import com.jme3.material.*; import com.jme3.material.RenderState.BlendMode; @@ -49,8 +48,10 @@ public final class SinglePassAndImageBasedLightingLogic extends DefaultTechnique private static final String DEFINE_SINGLE_PASS_LIGHTING = "SINGLE_PASS_LIGHTING"; private static final String DEFINE_NB_LIGHTS = "NB_LIGHTS"; private static final String DEFINE_NB_PROBES = "NB_PROBES"; + private static final String DEFINE_USE_AMBIENT_LIGHT = "USE_AMBIENT_LIGHT"; private static final RenderState ADDITIVE_LIGHT = new RenderState(); + private boolean useAmbientLight; private final ColorRGBA ambientLightColor = new ColorRGBA(0, 0, 0, 1); private List lightProbes = new ArrayList<>(3); @@ -62,12 +63,14 @@ public final class SinglePassAndImageBasedLightingLogic extends DefaultTechnique private final int singlePassLightingDefineId; private final int nbLightsDefineId; private final int nbProbesDefineId; + private final int useAmbientLightDefineId; public SinglePassAndImageBasedLightingLogic(TechniqueDef techniqueDef) { super(techniqueDef); singlePassLightingDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_SINGLE_PASS_LIGHTING, VarType.Boolean); nbLightsDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_NB_LIGHTS, VarType.Int); nbProbesDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_NB_PROBES, VarType.Int); + useAmbientLightDefineId = techniqueDef.addShaderUnmappedDefine(DEFINE_USE_AMBIENT_LIGHT, VarType.Boolean); } @Override @@ -84,6 +87,7 @@ public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager lightProbes.clear(); extractIndirectLights(lights, false); defines.set(nbProbesDefineId, lightProbes.size()); + defines.set(useAmbientLightDefineId, useAmbientLight); } return super.makeCurrent(assetManager, renderManager, rendererCaps, lights, defines); @@ -128,7 +132,7 @@ protected int updateLightListUniforms(Shader shader, Geometry g, LightList light // apply additive blending for 2nd and future passes rm.getRenderer().applyRenderState(ADDITIVE_LIGHT); ambientColor.setValue(VarType.Vector4, ColorRGBA.Black); - }else{ + } else{ extractIndirectLights(lightList,true); ambientColor.setValue(VarType.Vector4, ambientLightColor); } @@ -261,9 +265,11 @@ public void render(RenderManager renderManager, Shader shader, Geometry geometry protected void extractIndirectLights(LightList lightList, boolean removeLights) { ambientLightColor.set(0, 0, 0, 1); + useAmbientLight = false; for (int j = 0; j < lightList.size(); j++) { Light l = lightList.get(j); if (l instanceof AmbientLight) { + useAmbientLight = true; ambientLightColor.addLocal(l.getColor()); if(removeLights){ lightList.remove(l); diff --git a/jme3-core/src/main/java/com/jme3/material/logic/TechniqueDefLogic.java b/jme3-core/src/main/java/com/jme3/material/logic/TechniqueDefLogic.java index 18a8051861..e0921e869d 100644 --- a/jme3-core/src/main/java/com/jme3/material/logic/TechniqueDefLogic.java +++ b/jme3-core/src/main/java/com/jme3/material/logic/TechniqueDefLogic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,14 +33,12 @@ import com.jme3.asset.AssetManager; import com.jme3.light.LightList; -import com.jme3.material.TechniqueDef.LightMode; import com.jme3.renderer.Caps; import com.jme3.renderer.RenderManager; import com.jme3.scene.Geometry; import com.jme3.shader.DefineList; import com.jme3.shader.Shader; import com.jme3.shader.Uniform; -import com.jme3.shader.UniformBinding; import com.jme3.texture.Texture; import java.util.EnumSet; @@ -48,9 +46,9 @@ * TechniqueDefLogic is used to customize how * a material should be rendered. * - * Typically used to implement {@link LightMode lighting modes}. + * Typically used to implement {@link com.jme3.material.TechniqueDef.LightMode lighting modes}. * Implementations can register - * {@link TechniqueDef#addShaderUnmappedDefine(java.lang.String) unmapped defines} + * {@link com.jme3.material.TechniqueDef#addShaderUnmappedDefine(java.lang.String, com.jme3.shader.VarType) unmapped defines} * in their constructor and then later set them based on the geometry * or light environment being rendered. * @@ -69,7 +67,7 @@ public interface TechniqueDefLogic { * @param lights The lights with which the geometry shall be rendered. This * list must not include culled lights. * @param defines The define list used by the technique, any - * {@link TechniqueDef#addShaderUnmappedDefine(java.lang.String) unmapped defines} + * {@link com.jme3.material.TechniqueDef#addShaderUnmappedDefine(java.lang.String, com.jme3.shader.VarType) unmapped defines} * should be set here to change shader behavior. * * @return The shader to use for rendering. @@ -80,16 +78,16 @@ public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager /** * Requests that the TechniqueDefLogic renders the given geometry. * - * Fixed material functionality such as {@link RenderState}, - * {@link MatParam material parameters}, and - * {@link UniformBinding uniform bindings} + * Fixed material functionality such as {@link com.jme3.material.RenderState}, + * {@link com.jme3.material.MatParam material parameters}, and + * {@link com.jme3.shader.UniformBinding uniform bindings} * have already been applied by the material, however, - * {@link RenderState}, {@link Uniform uniforms}, {@link Texture textures}, - * can still be overriden. + * {@link com.jme3.material.RenderState}, {@link Uniform uniforms}, {@link Texture textures}, + * can still be overridden. * * @param renderManager The render manager to perform the rendering against. - * * @param shader The shader that was selected by this logic in - * {@link #makeCurrent(com.jme3.asset.AssetManager, com.jme3.renderer.RenderManager, java.util.EnumSet, com.jme3.shader.DefineList)}. + * @param shader The shader that was selected by this logic in + * {@link #makeCurrent(com.jme3.asset.AssetManager, com.jme3.renderer.RenderManager, java.util.EnumSet, com.jme3.light.LightList, com.jme3.shader.DefineList)}. * @param geometry The geometry to render * @param lights Lights which influence the geometry. */ diff --git a/jme3-core/src/main/java/com/jme3/math/EaseFunction.java b/jme3-core/src/main/java/com/jme3/math/EaseFunction.java index c2f5383f2b..76d6a7dedd 100644 --- a/jme3-core/src/main/java/com/jme3/math/EaseFunction.java +++ b/jme3-core/src/main/java/com/jme3/math/EaseFunction.java @@ -7,7 +7,7 @@ public interface EaseFunction { /** * @param value a value from 0 to 1. Passing a value out of this range will have unexpected behavior. - * @return + * @return the blended value */ float apply(float value); } diff --git a/jme3-core/src/main/java/com/jme3/math/MathUtils.java b/jme3-core/src/main/java/com/jme3/math/MathUtils.java index 8c22700b17..3f60d2fffd 100644 --- a/jme3-core/src/main/java/com/jme3/math/MathUtils.java +++ b/jme3-core/src/main/java/com/jme3/math/MathUtils.java @@ -92,7 +92,7 @@ public static Quaternion slerp(Quaternion q1, Quaternion q2, float t, Quaternion float invSinTheta = 1f / FastMath.sin(theta); // Calculate the scale for q1 and q2, according to the angle and - // it's sine value + // its sine value scale0 = FastMath.sin((1 - t) * theta) * invSinTheta; scale1 = FastMath.sin((t * theta)) * invSinTheta; diff --git a/jme3-core/src/main/java/com/jme3/math/Matrix4f.java b/jme3-core/src/main/java/com/jme3/math/Matrix4f.java index 6b260ee31a..ff51e3c7bf 100644 --- a/jme3-core/src/main/java/com/jme3/math/Matrix4f.java +++ b/jme3-core/src/main/java/com/jme3/math/Matrix4f.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1741,7 +1741,7 @@ public void toRotationMatrix(Matrix3f mat) { } /** - * Retreives the scale vector from the matrix. + * Retrieves the scale vector from the matrix. * * @return the scale vector */ @@ -1751,13 +1751,13 @@ public Vector3f toScaleVector() { return result; } - /** - * Retreives the scale vector from the matrix and stores it into a given - * vector. + /** + * Retrieves the scale vector from the matrix and stores it into a given + * vector. * * @param store the vector where the scale will be stored * @return the store vector - */ + */ public Vector3f toScaleVector(Vector3f store) { float scaleX = (float) Math.sqrt(m00 * m00 + m10 * m10 + m20 * m20); float scaleY = (float) Math.sqrt(m01 * m01 + m11 * m11 + m21 * m21); diff --git a/jme3-core/src/main/java/com/jme3/math/Plane.java b/jme3-core/src/main/java/com/jme3/math/Plane.java index 81dd3a5cb1..3da90b2bc3 100644 --- a/jme3-core/src/main/java/com/jme3/math/Plane.java +++ b/jme3-core/src/main/java/com/jme3/math/Plane.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -255,7 +255,7 @@ public void setPlanePoints(Vector3f v1, Vector3f v2, Vector3f v3) { } /** - * toString returns a string thta represents the string + * toString returns a string that represents the string * representation of this plane. It represents the normal as a * Vector3f object, so the format is the following: * com.jme.math.Plane [Normal: org.jme.math.Vector3f [X=XX.XXXX, Y=YY.YYYY, diff --git a/jme3-core/src/main/java/com/jme3/math/Quaternion.java b/jme3-core/src/main/java/com/jme3/math/Quaternion.java index 0625b8edd2..0a5b818b6c 100644 --- a/jme3-core/src/main/java/com/jme3/math/Quaternion.java +++ b/jme3-core/src/main/java/com/jme3/math/Quaternion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1279,6 +1279,29 @@ public boolean equals(Object o) { } return true; } + + /** + * Returns true if this quaternion is similar to the specified quaternion + * within some value of epsilon. + */ + public boolean isSimilar(Quaternion other, float epsilon) { + if (other == null) { + return false; + } + if (Float.compare(Math.abs(other.x - x), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.y - y), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.z - z), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.w - w), epsilon) > 0) { + return false; + } + return true; + } /** * diff --git a/jme3-core/src/main/java/com/jme3/math/Triangle.java b/jme3-core/src/main/java/com/jme3/math/Triangle.java index 527d6e7b44..5902682131 100644 --- a/jme3-core/src/main/java/com/jme3/math/Triangle.java +++ b/jme3-core/src/main/java/com/jme3/math/Triangle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,9 @@ public class Triangle extends AbstractTriangle implements Savable, Cloneable, ja private float projection; private int index; + /** + * Instantiate a zero-size Triangle at the origin. + */ public Triangle() { } @@ -75,11 +78,11 @@ public Triangle(Vector3f p1, Vector3f p2, Vector3f p3) { } /** - * * get retrieves a point on the triangle denoted by the index * supplied. - * @param i the index of the point. - * @return the point. + * + * @param i the index of the point (0, 1, or 2) + * @return a pre-existing location vector */ public Vector3f get(int i) { switch (i) { @@ -94,26 +97,47 @@ public Vector3f get(int i) { } } + /** + * Access the location of the 1st point (A). + * + * @return the pre-existing vector (not null) + */ + @Override public Vector3f get1() { return pointa; } + /** + * Access the location of the 2nd point (B). + * + * @return the pre-existing vector (not null) + */ + @Override public Vector3f get2() { return pointb; } + /** + * Access the location of the 3rd point (C). + * + * @return the pre-existing vector (not null) + */ + @Override public Vector3f get3() { return pointc; } /** + * set sets one of the triangle's points to that specified as a + * parameter. * - * set sets one of the triangle's points to that specified as - * a parameter. - * @param i the index to place the point. - * @param point the point to set. + * @param i the index to place the point (0, 1, or 2) + * @param point the desired location of the point (not null, unaffected) */ public void set(int i, Vector3f point) { + center = null; + normal = null; + switch (i) { case 0: pointa.set(point); @@ -128,12 +152,17 @@ public void set(int i, Vector3f point) { } /** + * set alters the location of one of the triangle's points. * - * set sets one of the triangle's points to that specified as - * a parameter. - * @param i the index to place the point. + * @param i the index to place the point (0, 1, or 2) + * @param x the desired X-component of the point's location + * @param y the desired Y-component of the point's location + * @param z the desired Z-component of the point's location */ public void set(int i, float x, float y, float z) { + center = null; + normal = null; + switch (i) { case 0: pointa.set(x, y, z); @@ -147,19 +176,54 @@ public void set(int i, float x, float y, float z) { } } + /** + * set1 alters the location of the triangle's 1st point. + * + * @param v the desired location (not null, unaffected) + */ public void set1(Vector3f v) { + center = null; + normal = null; + pointa.set(v); } + /** + * set2 alters the location of the triangle's 2nd point. + * + * @param v the desired location (not null, unaffected) + */ public void set2(Vector3f v) { + center = null; + normal = null; + pointb.set(v); } + /** + * set3 alters the location of the triangle's 3rd point. + * + * @param v the desired location (not null, unaffected) + */ public void set3(Vector3f v) { + center = null; + normal = null; + pointc.set(v); } + /** + * set alters the locations of all 3 points. + * + * @param v1 the desired location of the 1st point (not null, unaffected) + * @param v2 the desired location of the 2nd point (not null, unaffected) + * @param v3 the desired location of the 3rd point (not null, unaffected) + */ + @Override public void set(Vector3f v1, Vector3f v2, Vector3f v3) { + center = null; + normal = null; + pointa.set(v1); pointb.set(v2); pointc.set(v3); @@ -275,12 +339,14 @@ public static Vector3f computeTriangleNormal(Vector3f v1, Vector3f v2, Vector3f return store.normalizeLocal(); } + @Override public void write(JmeExporter e) throws IOException { e.getCapsule(this).write(pointa, "pointa", Vector3f.ZERO); e.getCapsule(this).write(pointb, "pointb", Vector3f.ZERO); e.getCapsule(this).write(pointc, "pointc", Vector3f.ZERO); } + @Override public void read(JmeImporter e) throws IOException { pointa = (Vector3f) e.getCapsule(this).readSavable("pointa", Vector3f.ZERO.clone()); pointb = (Vector3f) e.getCapsule(this).readSavable("pointb", Vector3f.ZERO.clone()); diff --git a/jme3-core/src/main/java/com/jme3/math/Vector2f.java b/jme3-core/src/main/java/com/jme3/math/Vector2f.java index 1ad2ac0c61..e2c3a96c09 100644 --- a/jme3-core/src/main/java/com/jme3/math/Vector2f.java +++ b/jme3-core/src/main/java/com/jme3/math/Vector2f.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,6 @@ package com.jme3.math; import com.jme3.export.*; -import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; @@ -693,6 +692,23 @@ public boolean equals(Object o) { return false; return true; } + + /** + * Returns true if this vector is similar to the specified vector within + * some value of epsilon. + */ + public boolean isSimilar(Vector2f other, float epsilon) { + if (other == null) { + return false; + } + if (Float.compare(Math.abs(other.x - x), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.y - y), epsilon) > 0) { + return false; + } + return true; + } /** * toString returns the string representation of this vector diff --git a/jme3-core/src/main/java/com/jme3/math/Vector3f.java b/jme3-core/src/main/java/com/jme3/math/Vector3f.java index d5fdac06ce..04638ef2b7 100644 --- a/jme3-core/src/main/java/com/jme3/math/Vector3f.java +++ b/jme3-core/src/main/java/com/jme3/math/Vector3f.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -969,6 +969,26 @@ public boolean equals(Object o) { if (Float.compare(z,comp.z) != 0) return false; return true; } + + /** + * Returns true if this vector is similar to the specified vector within + * some value of epsilon. + */ + public boolean isSimilar(Vector3f other, float epsilon) { + if (other == null) { + return false; + } + if (Float.compare(Math.abs(other.x - x), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.y - y), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.z - z), epsilon) > 0) { + return false; + } + return true; + } /** * hashCode returns a unique code for this vector object based diff --git a/jme3-core/src/main/java/com/jme3/math/Vector4f.java b/jme3-core/src/main/java/com/jme3/math/Vector4f.java index 2993c4f0c6..d7c3e48f19 100644 --- a/jme3-core/src/main/java/com/jme3/math/Vector4f.java +++ b/jme3-core/src/main/java/com/jme3/math/Vector4f.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -874,6 +874,29 @@ public boolean equals(Object o) { if (Float.compare(w,comp.w) != 0) return false; return true; } + + /** + * Returns true if this vector is similar to the specified vector within + * some value of epsilon. + */ + public boolean isSimilar(Vector4f other, float epsilon) { + if (other == null) { + return false; + } + if (Float.compare(Math.abs(other.x - x), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.y - y), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.z - z), epsilon) > 0) { + return false; + } + if (Float.compare(Math.abs(other.w - w), epsilon) > 0) { + return false; + } + return true; + } /** * hashCode returns a unique code for this vector object based @@ -1001,4 +1024,4 @@ public void set(int index, float value) { throw new IllegalArgumentException("index must be either 0, 1, 2 or 3"); } -} \ No newline at end of file +} diff --git a/jme3-core/src/main/java/com/jme3/opencl/Context.java b/jme3-core/src/main/java/com/jme3/opencl/Context.java index b53906a3c3..3b48c29d93 100644 --- a/jme3-core/src/main/java/com/jme3/opencl/Context.java +++ b/jme3-core/src/main/java/com/jme3/opencl/Context.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -87,7 +87,7 @@ public Context register() { * memory size and so on, are queried over the Device instances. *
          * The available devices were specified by a {@link PlatformChooser}. - * @return + * @return a list of devices */ public abstract List getDevices(); @@ -184,10 +184,10 @@ public Buffer createBufferFromHost(ByteBuffer data) { * Note: The vertex buffer must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. *

          - * Before the returned buffer can be used, it must be acquried explicitly + * Before the returned buffer can be used, it must be acquired explicitly * by {@link Buffer#acquireBufferForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Buffer#releaseBufferForSharingAsync(com.jme3.opencl.CommandQueue) }. - * This is needed so that OpenGL and OpenCL operations do not interfer with each other. + * This is needed so that OpenGL and OpenCL operations do not interfere with each other. * @param vb the vertex buffer to share * @param access the memory access for the kernel * @return the new buffer @@ -204,10 +204,10 @@ public Buffer createBufferFromHost(ByteBuffer data) { * Note: The image must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. *

          - * Before the returned image can be used, it must be acquried explicitly + * Before the returned image can be used, it must be acquired explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } - * This is needed so that OpenGL and OpenCL operations do not interfer with each other. + * This is needed so that OpenGL and OpenCL operations do not interfere with each other. * * @param image the jME3 image object * @param textureType the texture type (1D, 2D, 3D), since this is not stored in the image @@ -226,10 +226,10 @@ public Buffer createBufferFromHost(ByteBuffer data) { * Note: The image must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. *

          - * Before the returned image can be used, it must be acquried explicitly + * Before the returned image can be used, it must be acquired explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } - * This is needed so that OpenGL and OpenCL operations do not interfer with each other. + * This is needed so that OpenGL and OpenCL operations do not interfere with each other. *

          * This method is equivalent to calling * {@code bindImage(texture.getImage(), texture.getType(), miplevel, access)}. @@ -263,14 +263,14 @@ public Image bindImage(Texture texture, MemoryAccess access) { * Note: The renderbuffer must already been uploaded to the GPU, * i.e. it must be used at least once for drawing. *

          - * Before the returned image can be used, it must be acquried explicitly + * Before the returned image can be used, it must be acquired explicitly * by {@link Image#acquireImageForSharingAsync(com.jme3.opencl.CommandQueue) } * and after modifying it, released by {@link Image#releaseImageForSharingAsync(com.jme3.opencl.CommandQueue) } - * This is needed so that OpenGL and OpenCL operations do not interfer with each other. + * This is needed so that OpenGL and OpenCL operations do not interfere with each other. * * @param buffer * @param access - * @return + * @return an image */ public Image bindRenderBuffer(FrameBuffer.RenderBuffer buffer, MemoryAccess access) { if (buffer.getTexture() == null) { diff --git a/jme3-core/src/main/java/com/jme3/opencl/Device.java b/jme3-core/src/main/java/com/jme3/opencl/Device.java index 3529a25703..b9f083c572 100644 --- a/jme3-core/src/main/java/com/jme3/opencl/Device.java +++ b/jme3-core/src/main/java/com/jme3/opencl/Device.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -155,7 +155,7 @@ public static enum DeviceType { long getMaximumWorkItemDimensions(); /** * Maximum number of work-items that can be specified in each dimension of the - * work-group to {@link Kernel#Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.WorkSize, com.jme3.opencl.WorkSize, java.lang.Object...) }. + * work-group to {@link Kernel#Run2(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...)}. * The array has a length of at least 3. * @return the maximum size of the work group in each dimension */ diff --git a/jme3-core/src/main/java/com/jme3/opencl/Image.java b/jme3-core/src/main/java/com/jme3/opencl/Image.java index 7d5d07fb74..fd024000c3 100644 --- a/jme3-core/src/main/java/com/jme3/opencl/Image.java +++ b/jme3-core/src/main/java/com/jme3/opencl/Image.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2016 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -175,10 +175,10 @@ public static enum ImageType { /** * The image descriptor structure describes the type and dimensions of the image or image array. *

          - * There exists two constructors:
          - * {@link #ImageDescriptor(com.jme3.opencl.Image.ImageType, long, long, long, long) } + * There exist two constructors:
          + * ImageDescriptor(ImageType, long, long, long, long) * is used when an image with new memory should be created (used most often).
          - * {@link #ImageDescriptor(com.jme3.opencl.Image.ImageType, long, long, long, long, long, long, java.nio.ByteBuffer) } + * ImageDescriptor(ImageType, long, long, long, long, long, long, ByteBuffer) * creates an image using the provided {@code ByteBuffer} as source. */ public static class ImageDescriptor { //Struct @@ -270,12 +270,10 @@ public Image register() { public abstract long getDepth(); /** * @return the row pitch when the image was created from a host buffer - * @see ImageDescriptor#ImageDescriptor(com.jme3.opencl.Image.ImageType, long, long, long, long, long, long, java.nio.ByteBuffer) */ public abstract long getRowPitch(); /** * @return the slice pitch when the image was created from a host buffer - * @see ImageDescriptor#ImageDescriptor(com.jme3.opencl.Image.ImageType, long, long, long, long, long, long, java.nio.ByteBuffer) */ public abstract long getSlicePitch(); /** diff --git a/jme3-core/src/main/java/com/jme3/opencl/KernelCompilationException.java b/jme3-core/src/main/java/com/jme3/opencl/KernelCompilationException.java index a0e20c9e52..6203dd641e 100644 --- a/jme3-core/src/main/java/com/jme3/opencl/KernelCompilationException.java +++ b/jme3-core/src/main/java/com/jme3/opencl/KernelCompilationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2016 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,10 +32,10 @@ package com.jme3.opencl; /** - * This exception is thrown by {@link Program#build() } and {@link Program#build(java.lang.String) } + * This exception is thrown by {@link Program#build()} * when the compilation failed. * The error log returned by {@link #getLog() } contains detailed information - * where the error occured. + * where the error occurred. * @author shaman */ public class KernelCompilationException extends OpenCLException { @@ -49,7 +49,7 @@ public KernelCompilationException(String msg, int errorCode, String log) { /** * The output of the compiler - * @return + * @return the output text */ public String getLog() { return log; diff --git a/jme3-core/src/main/java/com/jme3/opencl/Program.java b/jme3-core/src/main/java/com/jme3/opencl/Program.java index c55f320d5b..5c4342b0af 100644 --- a/jme3-core/src/main/java/com/jme3/opencl/Program.java +++ b/jme3-core/src/main/java/com/jme3/opencl/Program.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2016 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,7 +74,6 @@ public Program register() { /** * Builds this program without additional arguments * @throws KernelCompilationException if the compilation fails - * @see #build(java.lang.String) */ public void build() throws KernelCompilationException { build("", (Device[]) null); @@ -85,7 +84,7 @@ public void build() throws KernelCompilationException { * @param name the name of the kernel as defined in the source code * @return the kernel object * @throws OpenCLException if the kernel was not found or some other - * error occured + * error occurred */ public abstract Kernel createKernel(String name); diff --git a/jme3-core/src/main/java/com/jme3/opencl/package-info.java b/jme3-core/src/main/java/com/jme3/opencl/package-info.java index 36ad65eb41..0a3552d5f8 100644 --- a/jme3-core/src/main/java/com/jme3/opencl/package-info.java +++ b/jme3-core/src/main/java/com/jme3/opencl/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,6 +30,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +package com.jme3.opencl; /** * This package contains an API for using OpenCL together with jME3. *

          @@ -62,7 +63,8 @@ * with the following syntax: {@code __kernel void KernelName(KernelArgs) {Code} }. * On the programming side, a {@link com.jme3.opencl.Kernel} instance is obtained * by calling {@link com.jme3.opencl.Program#createKernel(java.lang.String) }. - * To execute the kernel, the method {@link com.jme3.opencl.Kernel#Run1(com.jme3.opencl.CommandQueue, com.jme3.opencl.WorkSize, java.lang.Object...) } + * To execute the kernel, the method + * {@link Kernel#Run1(com.jme3.opencl.CommandQueue, com.jme3.opencl.Kernel.WorkSize, java.lang.Object...)} * is provided. You first pass the command queue and the work size (i.e. the number of parallel executed threads) * followed by the kernel arguments. *
          @@ -77,8 +79,7 @@ * of the buffer, the behavior is completely undefined and may often result in * a program cache later on. * {@link com.jme3.opencl.Image} objects are structured one, two or three dimensional - * memory chunks of a fixed type. They are created by - * {@link com.jme3.opencl.Context#createImage(com.jme3.opencl.MemoryAccess, com.jme3.opencl.Image.ImageFormat, com.jme3.opencl.Image.ImageDescriptor, java.nio.ByteBuffer) }. + * memory chunks of a fixed type. They are created by Context.createImage(). * They need special functions in the kernel code to write to or read from images. * Both buffer and image objects provide methods for copying between buffers and images, * reading and writing to host code and directly mapping memory parts to the host code. @@ -158,6 +159,5 @@ * OpenCL 1.2 and 2.0. *

        */ -package com.jme3.opencl; //TODO: add profiling to Kernel, CommandQueue diff --git a/jme3-core/src/main/java/com/jme3/post/Filter.java b/jme3-core/src/main/java/com/jme3/post/Filter.java index ff1f71017a..d594b7be8a 100644 --- a/jme3-core/src/main/java/com/jme3/post/Filter.java +++ b/jme3-core/src/main/java/com/jme3/post/Filter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -221,7 +221,7 @@ protected Format getDefaultPassTextureFormat() { /** * returns the default pass depth format - * @return + * @return the enum value */ protected Format getDefaultPassDepthFormat() { return Format.Depth; @@ -371,14 +371,14 @@ public void setName(String name) { /** * returns the default pass frame buffer - * @return + * @return the pre-existing buffer */ protected FrameBuffer getRenderFrameBuffer() { return defaultPass.renderFrameBuffer; } /** - * sets the default pas frame buffer + * sets the default pass frame buffer * @param renderFrameBuffer */ protected void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) { @@ -387,7 +387,7 @@ protected void setRenderFrameBuffer(FrameBuffer renderFrameBuffer) { /** * returns the rendered texture of this filter - * @return + * @return the pre-existing texture */ protected Texture2D getRenderedTexture() { return defaultPass.renderedTexture; @@ -434,7 +434,7 @@ protected boolean isRequiresBilinear() { /** * returns the list of the postRender passes - * @return + * @return the pre-existing List */ protected List getPostRenderPasses() { return postRenderPasses; diff --git a/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java b/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java index e69408157f..d3580ccab1 100644 --- a/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java +++ b/jme3-core/src/main/java/com/jme3/post/FilterPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -393,7 +393,7 @@ private void updateLastFilterIndex() { lastFilterIndex = i; //the Fpp is initialized, but the viwport framebuffer is the //original out framebuffer so we must recover from a situation - //where no filter was enabled. So we set th correc framebuffer + //where no filter was enabled. So we set the correct framebuffer //on the viewport if(isInitialized() && viewPort.getOutputFrameBuffer()==outputBuffer){ setupViewPortFrameBuffer(); diff --git a/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java b/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java index 4cfe0b92f9..480de08f43 100644 --- a/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java +++ b/jme3-core/src/main/java/com/jme3/profile/AppProfiler.java @@ -51,6 +51,11 @@ public interface AppProfiler { */ public void appStep(AppStep step); + /** + * Called as a substep of the previous AppStep + */ + public void appSubStep(String... additionalInfo); + /** * Called at the beginning of the specified VpStep during * the rendering of the specified ViewPort. For bucket-specific diff --git a/jme3-core/src/main/java/com/jme3/renderer/Caps.java b/jme3-core/src/main/java/com/jme3/renderer/Caps.java index 0369517e2c..b930863a6f 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/Caps.java +++ b/jme3-core/src/main/java/com/jme3/renderer/Caps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -367,11 +367,12 @@ public enum Caps { *

        * Use of NPOT textures is allowed iff: *

          - *
        • The {@link Texture.WrapMode} is set to - * {@link Texture.WrapMode#EdgeClamp}.
        • - *
        • Mip-mapping is not used, meaning {@link Texture.MinFilter} is set to - * {@link Texture.MinFilter#BilinearNoMipMaps} or - * {@link Texture.MinFilter#NearestNoMipMaps}
        • + *
        • The {@link com.jme3.texture.Texture.WrapMode} is set to + * {@link com.jme3.texture.Texture.WrapMode#EdgeClamp}.
        • + *
        • Mip-mapping is not used, meaning + * {@link com.jme3.texture.Texture.MinFilter} is set to + * {@link com.jme3.texture.Texture.MinFilter#BilinearNoMipMaps} or + * {@link com.jme3.texture.Texture.MinFilter#NearestNoMipMaps}
        • *
        */ PartialNonPowerOfTwoTextures, diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java b/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java index 4599fdbb39..f7626f1bd5 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java +++ b/jme3-core/src/main/java/com/jme3/renderer/RenderContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -192,19 +192,19 @@ public class RenderContext { /** * Currently bound element array vertex buffer. * - * @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int) + * @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int, com.jme3.scene.VertexBuffer[]) */ public int boundElementArrayVBO; /** - * @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int) + * @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int, com.jme3.scene.VertexBuffer[]) */ public int boundVertexArray; /** * Currently bound array vertex buffer. * - * @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int) + * @see Renderer#renderMesh(com.jme3.scene.Mesh, int, int, com.jme3.scene.VertexBuffer[]) */ public int boundArrayVBO; diff --git a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java index cc86b5ad48..54e661e66a 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java +++ b/jme3-core/src/main/java/com/jme3/renderer/RenderManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -541,7 +541,7 @@ public void updateUniformBindings(Shader shader) { * If a {@link #setForcedTechnique(java.lang.String) forced technique} is * set on this RenderManager, then it is selected automatically * on the geometry's material and is used for rendering. Otherwise, one - * of the {@link MaterialDef#getDefaultTechniques() default techniques} is + * of the {@link com.jme3.material.MaterialDef#getTechniqueDefsNames() default techniques} is * used. *

        * If a {@link #setForcedRenderState(com.jme3.material.RenderState) forced @@ -553,8 +553,8 @@ public void updateUniformBindings(Shader shader) { * * @see Technique * @see RenderState - * @see Material#selectTechnique(java.lang.String, com.jme3.renderer.RenderManager) - * @see Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager) + * @see com.jme3.material.Material#selectTechnique(java.lang.String, com.jme3.renderer.RenderManager) + * @see com.jme3.material.Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager) */ public void renderGeometry(Geometry geom) { if (geom.isIgnoreTransform()) { @@ -690,7 +690,7 @@ public void preloadScene(Spatial scene) { * In addition to enqueuing the visible geometries, this method * also scenes which cast or receive shadows, by putting them into the * RenderQueue's - * {@link RenderQueue#addToShadowQueue(com.jme3.scene.Geometry, com.jme3.renderer.queue.RenderQueue.ShadowMode) + * {@link RenderQueue#addToQueue(com.jme3.scene.Geometry, com.jme3.renderer.queue.RenderQueue.Bucket) * shadow queue}. Each Spatial which has its * {@link Spatial#setShadowMode(com.jme3.renderer.queue.RenderQueue.ShadowMode) shadow mode} * set to not off, will be put into the appropriate shadow queue, note that @@ -1048,7 +1048,7 @@ public void renderViewPortRaw(ViewPort vp) { * (see {@link #renderTranslucentQueue(com.jme3.renderer.ViewPort) }) *

      • If any objects remained in the render queue, they are removed * from the queue. This is generally objects added to the - * {@link RenderQueue#renderShadowQueue(com.jme3.renderer.queue.RenderQueue.ShadowMode, com.jme3.renderer.RenderManager, com.jme3.renderer.Camera, boolean) + * {@link RenderQueue#renderQueue(com.jme3.renderer.queue.RenderQueue.Bucket, com.jme3.renderer.RenderManager, com.jme3.renderer.Camera) * shadow queue} * which were not rendered because of a missing shadow renderer.
      • *
      diff --git a/jme3-core/src/main/java/com/jme3/renderer/Renderer.java b/jme3-core/src/main/java/com/jme3/renderer/Renderer.java index 201729da82..095cc76de9 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/Renderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/Renderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -223,7 +223,7 @@ public interface Renderer { /** * Reads the pixels currently stored in the specified framebuffer * into the given ByteBuffer object. - * Only color pixels are transferred, witht hte given format. + * Only color pixels are transferred, with the given format. * The given byte buffer should have at least * fb.getWidth() * fb.getHeight() * 4 bytes remaining. * @@ -381,14 +381,14 @@ public interface Renderer { * set shall undergo an sRGB to linear RGB color conversion when read by a shader. * * The conversion is performed for the following formats: - * - {@link Image.Format#RGB8} - * - {@link Image.Format#RGBA8} - * - {@link Image.Format#Luminance8} - * - {@link Image.Format#Luminance8Alpha8} - * - {@link Image.Format#DXT1} - * - {@link Image.Format#DXT1A} - * - {@link Image.Format#DXT3} - * - {@link Image.Format#DXT5} + * - {@link com.jme3.texture.Image.Format#RGB8} + * - {@link com.jme3.texture.Image.Format#RGBA8} + * - {@link com.jme3.texture.Image.Format#Luminance8} + * - {@link com.jme3.texture.Image.Format#Luminance8Alpha8} + * - {@link com.jme3.texture.Image.Format#DXT1} + * - {@link com.jme3.texture.Image.Format#DXT1A} + * - {@link com.jme3.texture.Image.Format#DXT3} + * - {@link com.jme3.texture.Image.Format#DXT5} * * For all other formats, no conversion is performed. * diff --git a/jme3-core/src/main/java/com/jme3/renderer/ViewPort.java b/jme3-core/src/main/java/com/jme3/renderer/ViewPort.java index e2fdc99ca3..ad85c0be64 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/ViewPort.java +++ b/jme3-core/src/main/java/com/jme3/renderer/ViewPort.java @@ -38,7 +38,6 @@ import com.jme3.scene.Spatial; import com.jme3.texture.FrameBuffer; import com.jme3.util.SafeArrayList; -import java.util.List; /** * A ViewPort represents a view inside the display diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java index dcf1d91eb1..1c7c995031 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GL3.java @@ -54,6 +54,10 @@ public interface GL3 extends GL2 { public static final int GL_TEXTURE_SWIZZLE_B = 0x8E44; public static final int GL_TEXTURE_SWIZZLE_G = 0x8E43; public static final int GL_TEXTURE_SWIZZLE_R = 0x8E42; + public static final int GL_COMPRESSED_RED_RGTC1 = 0x8DBB; + public static final int GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC; + public static final int GL_COMPRESSED_RG_RGTC2 = 0x8DBD; + public static final int GL_COMPRESSED_SIGNED_RG_RGTC2 = 0x8DBE; public static final int GL_R8I = 33329; public static final int GL_R8UI = 33330; public static final int GL_R16I = 33331; diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java index ca8546a675..52c9a5b3d3 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLImageFormats.java @@ -245,6 +245,13 @@ public static GLImageFormat[][] getFormatsForCaps(EnumSet caps) { formatComp(formatToGL, Format.DXT3, GLExt.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); formatComp(formatToGL, Format.DXT5, GLExt.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); } + + if(caps.contains(Caps.OpenGL30)){ + formatComp(formatToGL, Format.RGTC2, GL3.GL_COMPRESSED_RG_RGTC2, GL3.GL_RG, GL.GL_UNSIGNED_BYTE); + formatComp(formatToGL, Format.SIGNED_RGTC2, GL3.GL_COMPRESSED_SIGNED_RG_RGTC2, GL3.GL_RG, GL.GL_BYTE); + formatComp(formatToGL, Format.RGTC1, GL3.GL_COMPRESSED_RED_RGTC1, GL3.GL_RED, GL.GL_UNSIGNED_BYTE); + formatComp(formatToGL, Format.SIGNED_RGTC1, GL3.GL_COMPRESSED_SIGNED_RED_RGTC1, GL3.GL_RED, GL.GL_BYTE); + } if (caps.contains(Caps.TextureCompressionETC2)) { formatComp(formatToGL, Format.ETC1, GLExt.GL_COMPRESSED_RGB8_ETC2, GL.GL_RGB, GL.GL_UNSIGNED_BYTE); diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java index 372233dd6d..6f222eb02d 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -789,6 +789,14 @@ public void applyRenderState(RenderState state) { case Alpha: blendFunc(RenderState.BlendFunc.Src_Alpha, RenderState.BlendFunc.One_Minus_Src_Alpha); break; + case AlphaSumA: + blendFuncSeparate( + RenderState.BlendFunc.Src_Alpha, + RenderState.BlendFunc.One_Minus_Src_Alpha, + RenderState.BlendFunc.One, + RenderState.BlendFunc.One + ); + break; case PremultAlpha: blendFunc(RenderState.BlendFunc.One, RenderState.BlendFunc.One_Minus_Src_Alpha); break; @@ -1641,7 +1649,7 @@ private void checkFrameBufferError() { default: //Programming error; will fail on all hardware throw new IllegalStateException("Some video driver error " - + "or programming error occured. " + + "or programming error occurred. " + "Framebuffer object status is invalid. "); } } @@ -2821,7 +2829,7 @@ public void drawTriangleList(VertexBuffer indexBuf, Mesh mesh, int count) { // OK: Works on all platforms. break; case UnsignedInt: - // Requres extension on OpenGL ES 2. + // Requires extension on OpenGL ES 2. if (!caps.contains(Caps.IntegerIndexBuffer)) { throw new RendererException("32-bit index buffers are not supported by the video hardware"); } diff --git a/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java b/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java index 114ac09d15..db5331e110 100644 --- a/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java +++ b/jme3-core/src/main/java/com/jme3/renderer/opengl/TextureUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -304,7 +304,7 @@ public void uploadSubTexture(Image image, int target, int index, int x, int y, b } if (image.getMipMapSizes() != null) { - throw new UnsupportedOperationException("Updating mip-mappped images is not supported"); + throw new UnsupportedOperationException("Updating mip-mapped images is not supported"); } if (image.getMultiSamples() > 1) { diff --git a/jme3-core/src/main/java/com/jme3/scene/BatchNode.java b/jme3-core/src/main/java/com/jme3/scene/BatchNode.java index d2d44dd566..f50780967f 100644 --- a/jme3-core/src/main/java/com/jme3/scene/BatchNode.java +++ b/jme3-core/src/main/java/com/jme3/scene/BatchNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,7 +57,7 @@ * The geometries are directly attached to the node in the scene graph. * Usage is like any other node except you have to call the {@link #batch()} method once all the geometries have been attached to the sub scene graph and their material set * (see todo more automagic for further enhancements) - * All the geometries that have been batched are set to not be rendered - {@link CullHint} is left intact. + * All the geometries that have been batched are set to not be rendered - {@link Spatial.CullHint} is left intact. * The sub geometries can be transformed as usual, their transforms are used to update the mesh of the geometryBatch. * Sub geoms can be removed but it may be slower than the normal spatial removing * Sub geoms can be added after the batch() method has been called but won't be batched and will just be rendered as normal geometries. diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index 4370362228..005d0e8c75 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -603,7 +603,7 @@ public void setMorphState(float[] state) { /** * returns true if the morph state has changed on the last frame. - * @return + * @return true if changed, otherwise false */ public boolean isDirtyMorph() { return dirtyMorph; @@ -621,7 +621,7 @@ public void setDirtyMorph(boolean dirtyMorph) { /** * returns the morph state of this Geometry. * Used internally by the MorphControl. - * @return + * @return an array */ public float[] getMorphState() { if (morphState == null) { diff --git a/jme3-core/src/main/java/com/jme3/scene/Mesh.java b/jme3-core/src/main/java/com/jme3/scene/Mesh.java index 8dececf26e..caffca063d 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Mesh.java +++ b/jme3-core/src/main/java/com/jme3/scene/Mesh.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -50,7 +50,6 @@ import java.io.IOException; import java.nio.*; import java.util.ArrayList; -import java.util.Arrays; /** * Mesh is used to store rendering data. @@ -1457,7 +1456,7 @@ public boolean isAnimated() { /** * @deprecated use isAnimatedByJoint * @param boneIndex - * @return + * @return true if animated by that bone, otherwise false */ @Deprecated public boolean isAnimatedByBone(int boneIndex) { @@ -1513,7 +1512,7 @@ public void setPatchVertexCount(int patchVertexCount) { /** * Gets the amount of vertices used for each patch; - * @return + * @return the count (≥0) */ public int getPatchVertexCount() { return patchVertexCount; diff --git a/jme3-core/src/main/java/com/jme3/scene/Node.java b/jme3-core/src/main/java/com/jme3/scene/Node.java index 3e14829550..ef3ed34b88 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Node.java +++ b/jme3-core/src/main/java/com/jme3/scene/Node.java @@ -31,15 +31,14 @@ */ package com.jme3.scene; +import com.jme3.bounding.BoundingBox; import com.jme3.bounding.BoundingVolume; import com.jme3.collision.Collidable; import com.jme3.collision.CollisionResults; import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; -import com.jme3.export.Savable; import com.jme3.material.Material; import com.jme3.util.SafeArrayList; -import com.jme3.util.TempVars; import com.jme3.util.clone.Cloner; import java.io.IOException; import java.util.ArrayList; @@ -170,6 +169,9 @@ protected void updateWorldBound(){ } } } + if (resultBound == null) { + resultBound = new BoundingBox(getWorldTranslation(), 0f, 0f, 0f); + } this.worldBound = resultBound; } @@ -769,20 +771,22 @@ public void updateModelBound() { } } } + @Override public void depthFirstTraversal(SceneGraphVisitor visitor, DFSMode mode) { if (mode == DFSMode.POST_ORDER) { for (Spatial child : children.getArray()) { - child.depthFirstTraversal(visitor); + child.depthFirstTraversal(visitor, mode); } visitor.visit(this); } else { //pre order visitor.visit(this); for (Spatial child : children.getArray()) { - child.depthFirstTraversal(visitor); + child.depthFirstTraversal(visitor, mode); } } } + @Override protected void breadthFirstTraversal(SceneGraphVisitor visitor, Queue queue) { queue.addAll(children); diff --git a/jme3-core/src/main/java/com/jme3/scene/SimpleBatchNode.java b/jme3-core/src/main/java/com/jme3/scene/SimpleBatchNode.java index 2c5a1773f1..954161067c 100644 --- a/jme3-core/src/main/java/com/jme3/scene/SimpleBatchNode.java +++ b/jme3-core/src/main/java/com/jme3/scene/SimpleBatchNode.java @@ -32,7 +32,6 @@ package com.jme3.scene; import com.jme3.math.Matrix4f; -import com.jme3.math.Transform; import com.jme3.util.TempVars; /** diff --git a/jme3-core/src/main/java/com/jme3/scene/Spatial.java b/jme3-core/src/main/java/com/jme3/scene/Spatial.java index c44db734be..06bc63f7f6 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Spatial.java +++ b/jme3-core/src/main/java/com/jme3/scene/Spatial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -158,7 +158,7 @@ public enum BatchHint { /** * Used for smart asset caching * - * @see AssetKey#useSmartCache() + * @see com.jme3.asset.AssetKey#getCacheType() */ protected AssetKey key; /** diff --git a/jme3-core/src/main/java/com/jme3/scene/UserData.java b/jme3-core/src/main/java/com/jme3/scene/UserData.java index 3047618fc7..0e94e2c0b2 100644 --- a/jme3-core/src/main/java/com/jme3/scene/UserData.java +++ b/jme3-core/src/main/java/com/jme3/scene/UserData.java @@ -70,6 +70,9 @@ public final class UserData implements Savable { private static final int TYPE_LIST = 6; private static final int TYPE_MAP = 7; private static final int TYPE_ARRAY = 8; + private static final int TYPE_DOUBLE = 9; + private static final int TYPE_SHORT = 10; + private static final int TYPE_BYTE = 11; protected byte type; protected Object value; @@ -87,7 +90,7 @@ public UserData() { * Value of the data */ public UserData(byte type, Object value) { - assert type >= 0 && type <= 8; + assert type >= 0 && type <= 11; this.type = type; this.value = value; } @@ -120,6 +123,12 @@ public static byte getObjectType(Object type) { return TYPE_MAP; } else if (type instanceof Object[]) { return TYPE_ARRAY; + } else if (type instanceof Double) { + return TYPE_DOUBLE; + } else if (type instanceof Short) { + return TYPE_SHORT; + } else if (type instanceof Byte) { + return TYPE_BYTE; } else { throw new IllegalArgumentException("Unsupported type: " + type.getClass().getName()); } @@ -165,6 +174,18 @@ public void write(JmeExporter ex) throws IOException { case TYPE_ARRAY: this.writeList(oc, Arrays.asList((Object[]) value), "0"); break; + case TYPE_DOUBLE: + Double d = (Double) value; + oc.write(d, "doubleVal", 0.); + break; + case TYPE_SHORT: + Short sh = (Short) value; + oc.write(sh, "shortVal", (short)0); + break; + case TYPE_BYTE: + Byte bh = (Byte) value; + oc.write(bh, "byteVal", (byte)0); + break; default: throw new UnsupportedOperationException("Unsupported value type: " + value.getClass()); } @@ -207,6 +228,15 @@ public void read(JmeImporter im) throws IOException { case TYPE_ARRAY: value = this.readList(ic, "0").toArray(); break; + case TYPE_DOUBLE: + value = ic.readDouble("doubleVal", 0.); + break; + case TYPE_SHORT: + value = ic.readShort("shortVal", (short)0); + break; + case TYPE_BYTE: + value = ic.readByte("byteVal", (byte)0); + break; default: throw new UnsupportedOperationException("Unknown type of stored data: " + type); } @@ -255,6 +285,15 @@ private void writeList(OutputCapsule oc, Collection list, String listName) th Map map = (Map) o; this.writeList(oc, map.keySet(), listName + "v(keys)" + counter); this.writeList(oc, map.values(), listName + "v(vals)" + counter); + } else if (o instanceof Double) { + oc.write(TYPE_DOUBLE, listName + "t" + counter, 0); + oc.write((Double) o, listName + "v" + counter, 0.); + } else if (o instanceof Short) { + oc.write(TYPE_SHORT, listName + "t" + counter, 0); + oc.write((Short) o, listName + "v" + counter, (short)0); + } else if (o instanceof Byte) { + oc.write(TYPE_BYTE, listName + "t" + counter, 0); + oc.write((Byte) o, listName + "v" + counter, (byte)0); } else { throw new UnsupportedOperationException("Unsupported type stored in the list: " + o.getClass()); } diff --git a/jme3-core/src/main/java/com/jme3/scene/control/CameraControl.java b/jme3-core/src/main/java/com/jme3/scene/control/CameraControl.java index 4eccdfa690..0b8606d23a 100644 --- a/jme3-core/src/main/java/com/jme3/scene/control/CameraControl.java +++ b/jme3-core/src/main/java/com/jme3/scene/control/CameraControl.java @@ -40,7 +40,6 @@ import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; -import com.jme3.scene.Spatial; import com.jme3.util.TempVars; import java.io.IOException; diff --git a/jme3-core/src/main/java/com/jme3/scene/control/UpdateControl.java b/jme3-core/src/main/java/com/jme3/scene/control/UpdateControl.java index 8e276c32f4..aa84faf1cb 100644 --- a/jme3-core/src/main/java/com/jme3/scene/control/UpdateControl.java +++ b/jme3-core/src/main/java/com/jme3/scene/control/UpdateControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ */ public class UpdateControl extends AbstractControl { - private final ConcurrentLinkedQueue> taskQueue = new ConcurrentLinkedQueue>(); + private ConcurrentLinkedQueue> taskQueue = new ConcurrentLinkedQueue<>(); /** * Enqueues a task/callable object to execute in the jME3 @@ -87,6 +87,7 @@ protected void controlRender(RenderManager rm, ViewPort vp) { @Override public Object jmeClone() { UpdateControl clone = (UpdateControl)super.jmeClone(); + clone.taskQueue = new ConcurrentLinkedQueue<>(); // This is kind of questionable since the tasks aren't cloned and have // no reference to the new spatial or anything. They'll get run again diff --git a/jme3-core/src/main/java/com/jme3/scene/debug/custom/ArmatureDebugger.java b/jme3-core/src/main/java/com/jme3/scene/debug/custom/ArmatureDebugger.java index 31c292186e..e06f3e248f 100644 --- a/jme3-core/src/main/java/com/jme3/scene/debug/custom/ArmatureDebugger.java +++ b/jme3-core/src/main/java/com/jme3/scene/debug/custom/ArmatureDebugger.java @@ -39,7 +39,6 @@ import com.jme3.collision.CollisionResults; import com.jme3.material.Material; import com.jme3.material.RenderState; -import com.jme3.math.Vector2f; import com.jme3.renderer.Camera; import com.jme3.renderer.queue.RenderQueue; import com.jme3.scene.Geometry; diff --git a/jme3-core/src/main/java/com/jme3/scene/mesh/IndexBuffer.java b/jme3-core/src/main/java/com/jme3/scene/mesh/IndexBuffer.java index 43846b5416..3fc4b318e7 100644 --- a/jme3-core/src/main/java/com/jme3/scene/mesh/IndexBuffer.java +++ b/jme3-core/src/main/java/com/jme3/scene/mesh/IndexBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -84,7 +84,7 @@ public void rewind() { } /** - * @return + * @return the count (≥0) * @see Buffer#remaining() */ public int remaining() { @@ -94,7 +94,7 @@ public int remaining() { /** * Returns the vertex index for the current position. * - * @return + * @return the index */ public abstract int get(); @@ -102,7 +102,7 @@ public int remaining() { * Returns the vertex index for the given index in the index buffer. * * @param i The index inside the index buffer - * @return + * @return the index */ public abstract int get(int i); diff --git a/jme3-core/src/main/java/com/jme3/scene/shape/Dome.java b/jme3-core/src/main/java/com/jme3/scene/shape/Dome.java index 8060498f9d..c3c4583744 100644 --- a/jme3-core/src/main/java/com/jme3/scene/shape/Dome.java +++ b/jme3-core/src/main/java/com/jme3/scene/shape/Dome.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -80,7 +80,7 @@ public Dome() { * Influences how round the base of the dome is. * @param radius * Radius of the dome. - * @see #Dome(com.jme.math.Vector3f, int, int, float) + * @see #Dome(com.jme3.math.Vector3f, int, int, float) */ public Dome(int planes, int radialSamples, float radius) { this(new Vector3f(0, 0, 0), planes, radialSamples, radius); diff --git a/jme3-core/src/main/java/com/jme3/shader/Glsl150ShaderGenerator.java b/jme3-core/src/main/java/com/jme3/shader/Glsl150ShaderGenerator.java index 3dc6aaf9d0..e3fb15a7b2 100644 --- a/jme3-core/src/main/java/com/jme3/shader/Glsl150ShaderGenerator.java +++ b/jme3-core/src/main/java/com/jme3/shader/Glsl150ShaderGenerator.java @@ -35,7 +35,6 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.Shader.ShaderType; -import java.util.List; /** * This shader Generator can generate Vertex and Fragment shaders from diff --git a/jme3-core/src/main/java/com/jme3/shader/Shader.java b/jme3-core/src/main/java/com/jme3/shader/Shader.java index 05264f8db0..cd93ab9f37 100644 --- a/jme3-core/src/main/java/com/jme3/shader/Shader.java +++ b/jme3-core/src/main/java/com/jme3/shader/Shader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -220,7 +220,7 @@ public NativeObject createDestructableClone(){ } /** - * Creates a new shader, {@link #initialize() } must be called + * Creates a new shader, initialize() must be called * after this constructor for the shader to be usable. */ public Shader(){ diff --git a/jme3-core/src/main/java/com/jme3/shader/ShaderNodeDefinition.java b/jme3-core/src/main/java/com/jme3/shader/ShaderNodeDefinition.java index ba5fc01618..68a7b80d8f 100644 --- a/jme3-core/src/main/java/com/jme3/shader/ShaderNodeDefinition.java +++ b/jme3-core/src/main/java/com/jme3/shader/ShaderNodeDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -170,7 +170,7 @@ public void setOutputs(List outputs) { /** * return the path of this definition - * @return + * @return the path */ public String getPath() { return path; diff --git a/jme3-core/src/main/java/com/jme3/shader/Uniform.java b/jme3-core/src/main/java/com/jme3/shader/Uniform.java index 0340c8a132..30d5d72bf1 100644 --- a/jme3-core/src/main/java/com/jme3/shader/Uniform.java +++ b/jme3-core/src/main/java/com/jme3/shader/Uniform.java @@ -373,7 +373,7 @@ public void setValue(VarType type, Object value){ //feed this.value with the collected values. if (this.value instanceof ColorRGBA) { ((ColorRGBA) this.value).set(vec4.x, vec4.y, vec4.z, vec4.w); - } else if (value instanceof Vector4f) { + } else if (this.value instanceof Vector4f) { ((Vector4f) this.value).set(vec4); } else { ((Quaternion) this.value).set(vec4.x, vec4.y, vec4.z, vec4.w); diff --git a/jme3-core/src/main/java/com/jme3/shader/UniformBindingManager.java b/jme3-core/src/main/java/com/jme3/shader/UniformBindingManager.java index 340fc162ca..6b9fc82be7 100644 --- a/jme3-core/src/main/java/com/jme3/shader/UniformBindingManager.java +++ b/jme3-core/src/main/java/com/jme3/shader/UniformBindingManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -43,7 +43,7 @@ * UniformBindingManager helps {@link RenderManager} to manage * {@link UniformBinding uniform bindings}. * - * The {@link #updateUniformBindings(java.util.List) } will update + * The {@link #updateUniformBindings(com.jme3.shader.Shader)} method will update * a given list of uniforms based on the current state * of the manager. * @@ -223,8 +223,6 @@ public void updateUniformBindings(Shader shader) { * Internal use only. Sets the world matrix to use for future * rendering. This has no effect unless objects are rendered manually * using {@link Material#render(com.jme3.scene.Geometry, com.jme3.renderer.RenderManager) }. - * Using {@link #renderGeometry(com.jme3.scene.Geometry) } will - * override this value. * * @param mat The world matrix to set */ diff --git a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowFilter.java b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowFilter.java index 7146e0d228..abdbe054db 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowFilter.java +++ b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,8 +74,6 @@ protected AbstractShadowFilter(){ * @param manager the application asset manager * @param shadowMapSize the size of the rendered shadowmaps (512,1024,2048, * etc...) - * @param nbShadowMaps the number of shadow maps rendered (the more shadow - * maps the more quality, the less fps). * @param shadowRenderer the shadowRenderer to use for this Filter */ @SuppressWarnings("all") @@ -305,7 +303,7 @@ public RenderState getPreShadowForcedRenderState() { * returns the edge filtering mode * * @see EdgeFilteringMode - * @return + * @return the enum value */ public EdgeFilteringMode getEdgeFilteringMode() { return shadowRenderer.getEdgeFilteringMode(); diff --git a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java index 602b7c89d9..4c0df0bd66 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/AbstractShadowRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -245,7 +245,7 @@ final public void setEdgeFilteringMode(EdgeFilteringMode filterMode) { * returns the edge filtering mode * * @see EdgeFilteringMode - * @return + * @return the enum value */ public EdgeFilteringMode getEdgeFilteringMode() { return edgeFilteringMode; @@ -367,7 +367,7 @@ public boolean isInitialized() { * * @param shadowMapIndex the index of the shadow map being rendered * @param shadowMapOccluders the list of occluders - * @return + * @return the geometryList */ protected abstract GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders); diff --git a/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java index 4beb4000c9..54c1f3b4f2 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/BasicShadowRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -117,7 +117,7 @@ public boolean isInitialized() { /** * returns the light direction used for this processor - * @return + * @return the pre-existing vector */ public Vector3f getDirection() { return direction; @@ -133,7 +133,7 @@ public void setDirection(Vector3f direction) { /** * debug only - * @return + * @return the pre-existing array */ public Vector3f[] getPoints() { return points; @@ -142,7 +142,7 @@ public Vector3f[] getPoints() { /** * debug only * returns the shadow camera - * @return + * @return the pre-existing camera */ public Camera getShadowCamera() { return shadowCam; @@ -202,7 +202,7 @@ public void postQueue(RenderQueue rq) { /** * debug only - * @return + * @return the pre-existing instance */ public Picture getDisplayPicture() { return dispPic; diff --git a/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowFilter.java b/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowFilter.java index 2d745b3fe4..77fea9db4f 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowFilter.java +++ b/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -126,7 +126,7 @@ public void setLambda(float lambda) { /** * returns true if stabilization is enabled - * @return + * @return true if stabilization is enabled */ public boolean isEnabledStabilization() { return shadowRenderer.isEnabledStabilization(); diff --git a/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java index e203f16a90..2528911865 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/DirectionalLightShadowRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -304,7 +304,7 @@ public void write(JmeExporter ex) throws IOException { /** * Directional light are always in the view frustum * @param viewCam - * @return + * @return true */ @Override protected boolean checkCulling(Camera viewCam) { diff --git a/jme3-core/src/main/java/com/jme3/shadow/PointLightShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/PointLightShadowRenderer.java index a16c4353be..ae76f6da73 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/PointLightShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/PointLightShadowRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -227,7 +227,7 @@ public void write(JmeExporter ex) throws IOException { /** * * @param viewCam - * @return + * @return true if intersects */ @Override protected boolean checkCulling(Camera viewCam) { diff --git a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowFilter.java b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowFilter.java index f403f22c6b..03175d0650 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowFilter.java +++ b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -135,7 +135,7 @@ protected void initFilter(AssetManager manager, RenderManager renderManager, Vie /** * returns the light direction used by the processor - * @return + * @return a direction vector */ public Vector3f getDirection() { return pssmRenderer.getDirection(); @@ -172,7 +172,7 @@ public void setLambda(float lambda) { /** * How far the shadows are rendered in the view - * @see setShadowZExtend(float zFar) + * @see #setShadowZExtend(float zFar) * @return shadowZExtend */ public float getShadowZExtend() { diff --git a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java index 2361be28a0..0b36a56471 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,7 +40,6 @@ import com.jme3.post.SceneProcessor; import com.jme3.profile.AppProfiler; import com.jme3.renderer.Camera; -import com.jme3.renderer.Caps; import com.jme3.renderer.RenderManager; import com.jme3.renderer.Renderer; import com.jme3.renderer.ViewPort; @@ -187,9 +186,7 @@ public enum CompareMode { * @param manager the application asset manager * @param size the size of the rendered shadowmaps (512,1024,2048, etc...) * @param nbSplits the number of shadow maps rendered (the more shadow maps - * the more quality, the less fps). - * @param nbSplits the number of shadow maps rendered (the more shadow maps - * the more quality, the less fps). + * the more quality, the less fps) */ public PssmShadowRenderer(AssetManager manager, int size, int nbSplits) { this(manager, size, nbSplits, new Material(manager, "Common/MatDefs/Shadow/PostShadow.j3md")); @@ -368,7 +365,7 @@ public boolean isInitialized() { /** * returns the light direction used by the processor * - * @return + * @return the pre-existing vector */ public Vector3f getDirection() { return direction; diff --git a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowUtil.java b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowUtil.java index 888dc2fa81..3764a4b09e 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/PssmShadowUtil.java +++ b/jme3-core/src/main/java/com/jme3/shadow/PssmShadowUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,7 @@ /** * Includes various useful shadow mapping functions. * - * @see + * See *
        *
      • http://appsrv.cse.cuhk.edu.hk/~fzhang/pssm_vrcia/
      • *
      • http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
      • diff --git a/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java b/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java index 653d044881..7cad0a54c1 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java +++ b/jme3-core/src/main/java/com/jme3/shadow/ShadowUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -53,7 +53,7 @@ /** * Includes various useful shadow mapping functions. * - * @see
        • http://appsrv.cse.cuhk.edu.hk/~fzhang/pssm_vrcia/
        • *
        • http://http.developer.nvidia.com/GPUGems3/gpugems3_ch10.html
        • @@ -171,7 +171,7 @@ public static void updateFrustumPoints(Camera viewCam, * Compute bounds of a geomList * @param list * @param transform - * @return + * @return a new instance */ public static BoundingBox computeUnionBound(GeometryList list, Transform transform) { BoundingBox bbox = new BoundingBox(); @@ -192,7 +192,7 @@ public static BoundingBox computeUnionBound(GeometryList list, Transform transfo * Compute bounds of a geomList * @param list * @param mat - * @return + * @return a new instance */ public static BoundingBox computeUnionBound(GeometryList list, Matrix4f mat) { BoundingBox bbox = new BoundingBox(); @@ -213,7 +213,7 @@ public static BoundingBox computeUnionBound(GeometryList list, Matrix4f mat) { * Computes the bounds of multiple bounding volumes * * @param bv - * @return + * @return a new instance */ public static BoundingBox computeUnionBound(List bv) { BoundingBox bbox = new BoundingBox(); @@ -229,7 +229,7 @@ public static BoundingBox computeUnionBound(List bv) { * * @param pts * @param transform - * @return + * @return a new instance */ public static BoundingBox computeBoundForPoints(Vector3f[] pts, Transform transform) { Vector3f min = new Vector3f(Vector3f.POSITIVE_INFINITY); @@ -250,7 +250,7 @@ public static BoundingBox computeBoundForPoints(Vector3f[] pts, Transform transf * Compute bounds from an array of points * @param pts * @param mat - * @return + * @return a new BoundingBox */ public static BoundingBox computeBoundForPoints(Vector3f[] pts, Matrix4f mat) { Vector3f min = new Vector3f(Vector3f.POSITIVE_INFINITY); @@ -718,7 +718,8 @@ public static void getGeometriesInLightRadius(GeometryList inputGeometryList, * of OccludersExtractor.rootScene node that are both in the frustum of the given vpCamera and some camera inside cameras array. * The array of cameras must be initialized to represent the light viewspace of some light like pointLight or spotLight * - * @param camera the viewPort camera + * @param rootScene + * @param vpCamera the viewPort camera * @param cameras the camera array to check geometries against, representing the light viewspace * @param outputGeometryList the output list of all geometries that are in the camera frustum */ diff --git a/jme3-core/src/main/java/com/jme3/shadow/SpotLightShadowRenderer.java b/jme3-core/src/main/java/com/jme3/shadow/SpotLightShadowRenderer.java index 32eef5630d..b979f7ed22 100644 --- a/jme3-core/src/main/java/com/jme3/shadow/SpotLightShadowRenderer.java +++ b/jme3-core/src/main/java/com/jme3/shadow/SpotLightShadowRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -224,7 +224,7 @@ public void write(JmeExporter ex) throws IOException { /** * * @param viewCam - * @return + * @return true if intersects, otherwise false */ @Override protected boolean checkCulling(Camera viewCam) { diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 1e058f3292..cab197ce8c 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -274,7 +274,7 @@ public void copyFrom(AppSettings other) { */ public void mergeFrom(AppSettings other) { for (String key : other.keySet()) { - if (get(key) == null) { + if( !this.containsKey(key) ) { put(key, other.get(key)); } } @@ -816,7 +816,7 @@ public void setVSync(boolean value) { /** * Enable 3D stereo. *

          This feature requires hardware support from the GPU driver. - * @see http://en.wikipedia.org/wiki/Quad_buffering
          + * See http://en.wikipedia.org/wiki/Quad_buffering
          * Once enabled, filters or scene processors that handle 3D stereo rendering * could use this feature to render using hardware 3D stereo.

          * (Default: false) diff --git a/jme3-core/src/main/java/com/jme3/system/JmeContext.java b/jme3-core/src/main/java/com/jme3/system/JmeContext.java index 36aaa44a80..b31042128d 100644 --- a/jme3-core/src/main/java/com/jme3/system/JmeContext.java +++ b/jme3-core/src/main/java/com/jme3/system/JmeContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,9 +58,9 @@ public enum Type { /** * A canvas type context makes a rendering surface available as an - * AWT {@link java.awt.Canvas} object that can be embedded in a Swing/AWT + * AWT Canvas object that can be embedded in a Swing/AWT * frame. To retrieve the Canvas object, you should cast the context - * to {@link JmeCanvasContext}. + * to JmeCanvasContext. */ Canvas, diff --git a/jme3-core/src/main/java/com/jme3/system/JmeSystem.java b/jme3-core/src/main/java/com/jme3/system/JmeSystem.java index 4d57de0171..44ee834191 100644 --- a/jme3-core/src/main/java/com/jme3/system/JmeSystem.java +++ b/jme3-core/src/main/java/com/jme3/system/JmeSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,9 +34,6 @@ import com.jme3.asset.AssetManager; import com.jme3.audio.AudioRenderer; import com.jme3.input.SoftTextDialogInput; -import com.jme3.texture.Image; -import com.jme3.texture.image.DefaultImageRaster; -import com.jme3.texture.image.ImageRaster; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -127,7 +124,7 @@ public static SoftTextDialogInput getSoftTextDialogInput() { * * @param outStream The stream where to write the image data. * @param format The format to use, either "png" or "jpg". - * @param imageData The image data in {@link Image.Format#RGBA8} format. + * @param imageData The image data in {@link com.jme3.texture.Image.Format#RGBA8} format. * @param width The width of the image. * @param height The height of the image. * @throws IOException If outStream throws an exception while writing. diff --git a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java index e6516df0b9..26e79aacc1 100644 --- a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java +++ b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java @@ -35,9 +35,6 @@ import com.jme3.asset.DesktopAssetManager; import com.jme3.audio.AudioRenderer; import com.jme3.input.SoftTextDialogInput; -import com.jme3.texture.Image; -import com.jme3.texture.image.DefaultImageRaster; -import com.jme3.texture.image.ImageRaster; import java.io.File; import java.io.IOException; import java.io.InputStream; diff --git a/jme3-core/src/main/java/com/jme3/system/SystemListener.java b/jme3-core/src/main/java/com/jme3/system/SystemListener.java index a548173825..e2e604a4b0 100644 --- a/jme3-core/src/main/java/com/jme3/system/SystemListener.java +++ b/jme3-core/src/main/java/com/jme3/system/SystemListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,8 +81,8 @@ public interface SystemListener { public void loseFocus(); /** - * Called when an error has occured. This is typically - * invoked when an uncought exception is thrown in the render thread. + * Called when an error has occurred. This is typically + * invoked when an uncaught exception is thrown in the render thread. * @param errorMsg The error message, if any, or null. * @param t Throwable object, or null. */ diff --git a/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java b/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java index 4c7a813ee4..d5684e8854 100644 --- a/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java +++ b/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,7 +56,7 @@ * depth testing (which requires a depth buffer). * Buffers can be copied to other framebuffers * including the main screen, by using - * {@link Renderer#copyFrameBuffer(com.jme3.texture.FrameBuffer, com.jme3.texture.FrameBuffer) }. + * {@link Renderer#copyFrameBuffer(com.jme3.texture.FrameBuffer, com.jme3.texture.FrameBuffer, boolean)}. * The content of a {@link RenderBuffer} can be retrieved by using * {@link Renderer#readFrameBuffer(com.jme3.texture.FrameBuffer, java.nio.ByteBuffer) }. *

          @@ -510,7 +510,7 @@ public RenderBuffer getColorBuffer(int index){ } /** - * @return The color buffer with the index set by {@link #setTargetIndex(int), or null + * @return The color buffer with the index set by {@link #setTargetIndex(int)}, or null * if no color buffers are attached. * If MRT is disabled, the first color buffer is returned. */ @@ -600,15 +600,14 @@ public long getUniqueId() { * Specifies that the color values stored in this framebuffer are in SRGB * format. * - * The FrameBuffer must have a texture attached with the flag - * {@link Image#isSrgb()} set to true. + * The FrameBuffer must have an SRGB texture attached. * * The Renderer must expose the {@link Caps#Srgb sRGB pipeline} capability * for this option to take any effect. * * Rendering operations performed on this framebuffer shall undergo a linear * -> sRGB color space conversion when this flag is enabled. If - * {@link RenderState#getBlendMode() blending} is enabled, it will be + * {@link com.jme3.material.RenderState#getBlendMode() blending} is enabled, it will be * performed in linear space by first decoding the stored sRGB pixel values * into linear, combining with the shader result, and then converted back to * sRGB upon being written into the framebuffer. @@ -616,7 +615,7 @@ public long getUniqueId() { * @param srgb If the framebuffer color values should be stored in sRGB * color space. * - * @throws InvalidStateException If the texture attached to this framebuffer + * @throws IllegalStateException If the texture attached to this framebuffer * is not sRGB. */ public void setSrgb(boolean srgb) { @@ -626,7 +625,7 @@ public void setSrgb(boolean srgb) { /** * Determines if this framebuffer contains SRGB data. * - * @returns True if the framebuffer color values are in SRGB space, false if + * @return True if the framebuffer color values are in SRGB space, false if * in linear space. */ public boolean isSrgb() { diff --git a/jme3-core/src/main/java/com/jme3/texture/Image.java b/jme3-core/src/main/java/com/jme3/texture/Image.java index fde8d4ecb5..eaa3aae8a4 100644 --- a/jme3-core/src/main/java/com/jme3/texture/Image.java +++ b/jme3-core/src/main/java/com/jme3/texture/Image.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -185,6 +185,14 @@ public enum Format { * */ DXT5(8,false,true, false), + + RGTC2(8,false,true, false), + + SIGNED_RGTC2(8,false,true, false), + + RGTC1(4,false,true, false), + + SIGNED_RGTC1(4,false,true, false), /** * Luminance-Alpha Texture Compression. @@ -735,7 +743,7 @@ public Image(Format format, int width, int height, int depth, ArrayList * Allows directly manipulating pixels of the image by writing and * reading {@link ColorRGBA colors} at any coordinate, without - * regard to the underlying {@link Image.Format format} of the image. + * regard to the underlying {@link com.jme3.texture.Image.Format format} of the image. * NOTE: compressed and depth formats are not supported. * Special RGB formats like RGB111110F and RGB9E5 are not supported * at the moment, but may be added later on. For now @@ -136,7 +135,7 @@ public ImageRaster() { * lower than 0.0 are still not allowed (as all formats are unsigned). *

          * If the underlying format is grayscale (e.g. one of the luminance formats, - * such as {@link Image.Format#Luminance8}) then a color to grayscale + * such as {@link com.jme3.texture.Image.Format#Luminance8}) then a color to grayscale * conversion is done first, before writing the result into the image. *

          * If the image does not have some of the components in the color (such @@ -160,7 +159,7 @@ public ImageRaster() { *

          * Any components that are not defined in the image format * will be set to 1.0 in the returned color. For example, - * reading from an {@link Image.Format#Alpha8} format will + * reading from an {@link com.jme3.texture.Image.Format#Alpha8} format will * return a ColorRGBA with the R, G, and B components set to 1.0, and * the A component set to the alpha in the image. *

          @@ -170,7 +169,7 @@ public ImageRaster() { * Integer formats are converted to the range 0.0 - 1.0, based * on the maximum possible integer value that can be represented * by the number of bits the component has. - * For example, the {@link Image.Format#RGB5A1} format can + * For example, the {@link com.jme3.texture.Image.Format#RGB5A1} format can * contain the integer values 0 - 31, a conversion to floating point * is done by diving the integer value by 31 (done with floating point * precision). diff --git a/jme3-core/src/main/java/com/jme3/util/ListSort.java b/jme3-core/src/main/java/com/jme3/util/ListSort.java index cede1ff8a3..c45353a0cb 100644 --- a/jme3-core/src/main/java/com/jme3/util/ListSort.java +++ b/jme3-core/src/main/java/com/jme3/util/ListSort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -451,7 +451,7 @@ private void mergeRuns(int idx) { /* Where does B start in A? Elements in A before that can be * ignored (already in place). */ - //didn't find proper naming for k as it's used inthe original implementation + //didn't find proper naming for k as it's used in the original implementation int k = gallopRight(array[indexB], array, indexA, lenA, 0, comparator); indexA += k; lenA -= k; @@ -771,7 +771,7 @@ public void innerMergeLow(Comparator comp, T[] arr, T[] tempArray) { /* lengthA==0 is impossible now if the comparison * function is consistent, but we can't assume * that it is. - * a propper error will be thrown in mergeLow if lengthA == 0 + * a proper error will be thrown in mergeLow if lengthA == 0 */ if (lengthA <= 1){ return; @@ -942,7 +942,7 @@ public void innerMergeHigh(Comparator comp, T[] tempArray, T[] arr, int idxA) /* lengthB==0 is impossible now if the comparison * function is consistent, but we can't assume * that it is. - * a propper error will be thrown in mergeLow if lengthB == 0 + * a proper error will be thrown in mergeLow if lengthB == 0 */ if (lengthB <= 1){ return; diff --git a/jme3-core/src/main/java/com/jme3/util/NativeObject.java b/jme3-core/src/main/java/com/jme3/util/NativeObject.java index 426e4c9e02..727250b70a 100644 --- a/jme3-core/src/main/java/com/jme3/util/NativeObject.java +++ b/jme3-core/src/main/java/com/jme3/util/NativeObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -80,10 +80,8 @@ public abstract class NativeObject implements Cloneable { protected boolean updateNeeded = true; /** - * Creates a new GLObject with the given type. Should be + * Creates a new GLObject. Should be * called by the subclasses. - * - * @param type The type that the subclass represents. */ public NativeObject(){ this.handleRef = new Object(); diff --git a/jme3-core/src/main/java/com/jme3/util/SkyFactory.java b/jme3-core/src/main/java/com/jme3/util/SkyFactory.java index 2d435d50f1..9ef2a37a3d 100644 --- a/jme3-core/src/main/java/com/jme3/util/SkyFactory.java +++ b/jme3-core/src/main/java/com/jme3/util/SkyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,6 @@ import com.jme3.texture.Texture; import com.jme3.texture.TextureCubeMap; import java.nio.ByteBuffer; -import java.util.ArrayList; /** * SkyFactory is used to create jME {@link Spatial}s that can @@ -62,7 +61,7 @@ public class SkyFactory { public enum EnvMapType{ /** * The env map is a cube map see {@link TextureCubeMap} or 6 separate images that form a cube map - * The texture is either a {@link TextureCubeMap} or 6 {@link Texture2D}. + * The texture is either a {@link TextureCubeMap} or 6 {@link com.jme3.texture.Texture2D}. * In the latter case, a TextureCubeMap is build from the 6 2d maps. */ CubeMap, @@ -152,7 +151,7 @@ public static Spatial createSky(AssetManager assetManager, Texture texture, * frustum * @return a new spatial representing the sky, ready to be attached to the * scene graph - * @deprecated use {@link SkyFactory#createSky(com.jme3.asset.AssetManager, com.jme3.texture.Texture, com.jme3.math.Vector3f, com.jme3.util.SkyFactory.EnvMapType, int)} + * @deprecated use {@link #createSky(com.jme3.asset.AssetManager, com.jme3.texture.Texture, com.jme3.math.Vector3f, com.jme3.util.SkyFactory.EnvMapType, float)} */ @Deprecated public static Spatial createSky(AssetManager assetManager, Texture texture, @@ -254,7 +253,7 @@ public static Spatial createSky(AssetManager assetManager, Texture texture, bool *

        * @return a new spatial representing the sky, ready to be attached to the * scene graph - * @deprecated use {@link SkyFactory#createSky(com.jme3.asset.AssetManager, java.lang.String, com.jme3.math.Vector3f, com.jme3.util.SkyFactory.EnvMapType)} + * @deprecated use {@link #createSky(com.jme3.asset.AssetManager, java.lang.String, com.jme3.util.SkyFactory.EnvMapType)} */ @Deprecated public static Spatial createSky(AssetManager assetManager, String textureName, boolean sphereMap) { diff --git a/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java b/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java index a1ee640600..1ae3610962 100644 --- a/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java +++ b/jme3-core/src/main/java/com/jme3/util/TangentBinormalGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,9 +36,7 @@ import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.scene.*; -import com.jme3.scene.VertexBuffer.Format; import com.jme3.scene.VertexBuffer.Type; -import com.jme3.scene.VertexBuffer.Usage; import com.jme3.scene.mesh.IndexBuffer; import static com.jme3.util.BufferUtils.*; @@ -266,8 +264,8 @@ private static List processTriangles(Mesh mesh, return vertices; } - //Don't remove splitmirorred boolean,It's not used right now, but I intend to - //make this method also split vertice with rotated tangent space and I'll + //Don't remove splitmirorred boolean. It's not used right now, but I intend to + //make this method also split vertices with rotated tangent space and I'll //add another splitRotated boolean private static List splitVertices(Mesh mesh, List vertexData, boolean splitMirorred) { int nbVertices = mesh.getBuffer(Type.Position).getNumElements(); @@ -646,8 +644,8 @@ private static ArrayList linkVertices(Mesh mesh, boolean splitMirror boolean found = false; //Nehon 07/07/2013 - //Removed this part, joining splitted vertice to compute tangent space makes no sense to me - //separate vertice should have separate tangent space + //Removed this part, joining split vertices to compute tangent space makes no sense to me + //separate vertices should have separate tangent space if(!splitMirrored){ for (int j = 0; j < vertexMap.size(); j++) { VertexInfo vertexInfo = vertexMap.get(j); diff --git a/jme3-core/src/main/java/com/jme3/util/TempVars.java b/jme3-core/src/main/java/com/jme3/util/TempVars.java index a7bd088b87..5c1a45f4c8 100644 --- a/jme3-core/src/main/java/com/jme3/util/TempVars.java +++ b/jme3-core/src/main/java/com/jme3/util/TempVars.java @@ -32,7 +32,6 @@ package com.jme3.util; import com.jme3.bounding.BoundingBox; -import com.jme3.bounding.BoundingVolume; import com.jme3.collision.CollisionResults; import com.jme3.collision.bih.BIHNode.BIHStackData; import com.jme3.math.*; diff --git a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikkTSpaceContext.java b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikkTSpaceContext.java index dc56ac2406..d45913b835 100644 --- a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikkTSpaceContext.java +++ b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikkTSpaceContext.java @@ -15,7 +15,7 @@ public interface MikkTSpaceContext { * Returns the number of faces (triangles/quads) on the mesh to be * processed. * - * @return + * @return the count (≥0) */ public int getNumFaces(); @@ -24,7 +24,7 @@ public interface MikkTSpaceContext { * the range {0, 1, ..., getNumFaces()-1} * * @param face - * @return + * @return the count (≥0) */ public int getNumVerticesOfFace(int face); diff --git a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java index dbaedb0989..48a13d6f4b 100644 --- a/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java +++ b/jme3-core/src/main/java/com/jme3/util/mikktspace/MikktspaceTangentGenerator.java @@ -841,7 +841,7 @@ static void initTriInfo(TriInfo pTriInfos[], final int piTriListIn[], final Mikk //Edge * pEdges = (Edge *) malloc(sizeof(Edge)*iNrTrianglesIn*3); Edge[] pEdges = new Edge[iNrTrianglesIn * 3]; - //TODO nehon weird... original algorithm check if pEdges is null but it's just been allocated... weirder, it does soemthing different if the edges are null... + //TODO nehon weird... original algorithm checked if pEdges is null but it's just been allocated... weirder, it does something different if the edges are null... // if (pEdges==null) // BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn); // else diff --git a/jme3-core/src/main/java/com/jme3/util/xml/SAXUtil.java b/jme3-core/src/main/java/com/jme3/util/xml/SAXUtil.java index 2bcf821674..17a8e2067d 100644 --- a/jme3-core/src/main/java/com/jme3/util/xml/SAXUtil.java +++ b/jme3-core/src/main/java/com/jme3/util/xml/SAXUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ public final class SAXUtil { * * @param i The string to parse * @param def The default value if the string is null - * @return + * @return the parsed value or def * @throws SAXException */ public static int parseInt(String i, int def) throws SAXException{ diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag index 9b8aa27097..32f3535788 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag @@ -6,6 +6,26 @@ #import "Common/ShaderLib/Lighting.glsllib" #endif +// fog - jayfella +#ifdef USE_FOG +#import "Common/ShaderLib/MaterialFog.glsllib" +varying float fog_distance; +uniform vec4 m_FogColor; + +#ifdef FOG_LINEAR +uniform vec2 m_LinearFog; +#endif + +#ifdef FOG_EXP +uniform float m_ExpFog; +#endif + +#ifdef FOG_EXPSQ +uniform float m_ExpSqFog; +#endif + +#endif // end fog + varying vec2 texCoord; #ifdef SEPARATE_TEXCOORD varying vec2 texCoord2; @@ -115,6 +135,7 @@ void main(){ #endif + // *********************** // Read from textures // *********************** @@ -207,5 +228,22 @@ void main(){ DiffuseSum.rgb * diffuseColor.rgb * vec3(light.x) + SpecularSum2.rgb * specularColor.rgb * vec3(light.y); #endif + + + // add fog after the lighting because shadows will cause the fog to darken + // which just results in the geometry looking like it's changed color + #ifdef USE_FOG + #ifdef FOG_LINEAR + gl_FragColor = getFogLinear(gl_FragColor, m_FogColor, m_LinearFog.x, m_LinearFog.y, fog_distance); + #endif + #ifdef FOG_EXP + gl_FragColor = getFogExp(gl_FragColor, m_FogColor, m_ExpFog, fog_distance); + #endif + #ifdef FOG_EXPSQ + gl_FragColor = getFogExpSquare(gl_FragColor, m_FogColor, m_ExpSqFog, fog_distance); + #endif + #endif // end fog + + gl_FragColor.a = alpha; } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md index 2a8847324e..824a173696 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md @@ -120,6 +120,14 @@ MaterialDef Phong Lighting { Boolean UseInstancing Boolean BackfaceShadows : false + + // fog - jayfella + Boolean UseFog + Color FogColor + Vector2 LinearFog + Float ExpFog + Float ExpSqFog + } Technique { @@ -159,6 +167,12 @@ MaterialDef Phong Lighting { INSTANCING : UseInstancing NUM_MORPH_TARGETS: NumberOfMorphTargets NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers + + // fog - jayfella + USE_FOG : UseFog + FOG_LINEAR : LinearFog + FOG_EXP : ExpFog + FOG_EXPSQ : ExpSqFog } } @@ -200,6 +214,12 @@ MaterialDef Phong Lighting { INSTANCING : UseInstancing NUM_MORPH_TARGETS: NumberOfMorphTargets NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers + + // fog - jayfella + USE_FOG : UseFog + FOG_LINEAR : LinearFog + FOG_EXP : ExpFog + FOG_EXPSQ : ExpSqFog } } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert index 6c74a75578..390c1f1a47 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert @@ -8,6 +8,11 @@ #import "Common/ShaderLib/BlinnPhongLighting.glsllib" #endif +// fog - jayfella +#ifdef USE_FOG +varying float fog_distance; +uniform vec3 g_CameraPosition; +#endif uniform vec4 m_Ambient; uniform vec4 m_Diffuse; @@ -178,5 +183,9 @@ void main(){ #ifdef USE_REFLECTION computeRef(modelSpacePos); - #endif + #endif + + #ifdef USE_FOG + fog_distance = distance(g_CameraPosition, (g_WorldMatrix * modelSpacePos).xyz); + #endif } \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag index 716d3ff7ab..077b08579f 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -12,6 +12,7 @@ varying vec4 Color; uniform vec4 g_LightData[NB_LIGHTS]; uniform vec3 g_CameraPosition; +uniform vec4 g_AmbientLightColor; uniform float m_Roughness; uniform float m_Metallic; @@ -40,7 +41,7 @@ varying vec3 wPosition; #endif #ifdef USE_PACKED_MR - uniform sampler2D m_MetallicRoughnessMap; + uniform sampler2D m_MetallicRoughnessMap; #else #ifdef METALLICMAP uniform sampler2D m_MetallicMap; @@ -51,10 +52,10 @@ varying vec3 wPosition; #endif #ifdef EMISSIVE - uniform vec4 m_Emissive; + uniform vec4 m_Emissive; #endif #ifdef EMISSIVEMAP - uniform sampler2D m_EmissiveMap; + uniform sampler2D m_EmissiveMap; #endif #if defined(EMISSIVE) || defined(EMISSIVEMAP) uniform float m_EmissivePower; @@ -91,7 +92,7 @@ varying vec3 wPosition; varying vec3 wNormal; #ifdef DISCARD_ALPHA -uniform float m_AlphaDiscardThreshold; + uniform float m_AlphaDiscardThreshold; #endif void main(){ @@ -273,7 +274,7 @@ void main(){ float ndf3 = renderProbe(viewDir, wPosition, normal, norm, Roughness, diffuseColor, specularColor, ndotv, ao, g_LightProbeData3, g_ShCoeffs3, g_PrefEnvMap3, color3); #endif - #if NB_PROBES >= 2 + #if NB_PROBES >= 2 float invNdf = max(1.0 - ndf,0.0); float invNdf2 = max(1.0 - ndf2,0.0); float sumNdf = ndf + ndf2; @@ -294,6 +295,12 @@ void main(){ weight2 /= weightSum; weight3 /= weightSum; #endif + + #if USE_AMBIENT_LIGHT + color1.rgb *= g_AmbientLightColor.rgb; + color2.rgb *= g_AmbientLightColor.rgb; + color3.rgb *= g_AmbientLightColor.rgb; + #endif gl_FragColor.rgb += color1 * clamp(weight1,0.0,1.0) + color2 * clamp(weight2,0.0,1.0) + color3 * clamp(weight3,0.0,1.0); #endif diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md index e300bffdca..8465d2f0b2 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md @@ -53,7 +53,7 @@ MaterialDef PBR Lighting { // Parallax/height map Texture2D ParallaxMap -LINEAR - //Set to true is parallax map is stored in the alpha channel of the normal map + //Set to true if parallax map is stored in the alpha channel of the normal map Boolean PackedNormalParallax //Sets the relief height for parallax mapping @@ -111,10 +111,10 @@ MaterialDef PBR Lighting { Int NumberOfMorphTargets Int NumberOfTargetsBuffers - //For instancing + // For instancing Boolean UseInstancing - //For Vertex Color + // For Vertex Color Boolean UseVertexColor Boolean BackfaceShadows : false diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag index a510fc1dbc..2b5a4481c4 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag @@ -6,6 +6,26 @@ #import "Common/ShaderLib/Lighting.glsllib" #endif +// fog - jayfella +#ifdef USE_FOG +#import "Common/ShaderLib/MaterialFog.glsllib" +varying float fog_distance; +uniform vec4 m_FogColor; + +#ifdef FOG_LINEAR +uniform vec2 m_LinearFog; +#endif + +#ifdef FOG_EXP +uniform float m_ExpFog; +#endif + +#ifdef FOG_EXPSQ +uniform float m_ExpSqFog; +#endif + +#endif // end fog + varying vec2 texCoord; #ifdef SEPARATE_TEXCOORD varying vec2 texCoord2; @@ -226,5 +246,20 @@ void main(){ } #endif + + // add fog after the lighting because shadows will cause the fog to darken + // which just results in the geometry looking like it's changed color + #ifdef USE_FOG + #ifdef FOG_LINEAR + gl_FragColor = getFogLinear(gl_FragColor, m_FogColor, m_LinearFog.x, m_LinearFog.y, fog_distance); + #endif + #ifdef FOG_EXP + gl_FragColor = getFogExp(gl_FragColor, m_FogColor, m_ExpFog, fog_distance); + #endif + #ifdef FOG_EXPSQ + gl_FragColor = getFogExpSquare(gl_FragColor, m_FogColor, m_ExpSqFog, fog_distance); + #endif + #endif // end fog + gl_FragColor.a = alpha; } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert index f9fbe40cfb..71233819b3 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert @@ -8,6 +8,11 @@ #import "Common/ShaderLib/BlinnPhongLighting.glsllib" #endif +// fog - jayfella +#ifdef USE_FOG +varying float fog_distance; +uniform vec3 g_CameraPosition; +#endif uniform vec4 m_Ambient; uniform vec4 m_Diffuse; @@ -187,5 +192,9 @@ void main(){ #ifdef USE_REFLECTION computeRef(modelSpacePos); - #endif + #endif + + #ifdef USE_FOG + fog_distance = distance(g_CameraPosition, (g_WorldMatrix * modelSpacePos).xyz); + #endif } \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Common/Billboard.j3sn b/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Common/Billboard.j3sn index a9421de4cf..0bc6a85337 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Common/Billboard.j3sn +++ b/jme3-core/src/main/resources/Common/MatDefs/ShaderNodes/Common/Billboard.j3sn @@ -24,7 +24,7 @@ ShaderNodeDefinitions{ mat4 worldViewMatrix mat4 projectionMatrix vec3 modelPosition - float scale 1 + float scale 1.0 } Output { //all the node outputs diff --git a/jme3-core/src/main/resources/Common/ShaderLib/MaterialFog.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/MaterialFog.glsllib new file mode 100644 index 0000000000..912be9d4c6 --- /dev/null +++ b/jme3-core/src/main/resources/Common/ShaderLib/MaterialFog.glsllib @@ -0,0 +1,25 @@ + +vec4 getFogLinear(in vec4 diffuseColor, in vec4 fogColor, in float start, in float end, in float distance) { + + float fogFactor = (end - distance) / (end - start); + fogFactor = clamp(fogFactor, 0.0, 1.0); + + return mix(fogColor, diffuseColor, fogFactor); +} + +vec4 getFogExp(in vec4 diffuseColor, in vec4 fogColor, in float fogDensity, in float distance) { + + float fogFactor = 1.0 / exp(distance * fogDensity); + fogFactor = clamp( fogFactor, 0.0, 1.0 ); + + return mix(fogColor, diffuseColor, fogFactor); +} + +vec4 getFogExpSquare(in vec4 diffuseColor, in vec4 fogColor, in float fogDensity, in float distance) { + + float fogFactor = 1.0 / exp( (distance * fogDensity) * (distance * fogDensity)); + fogFactor = clamp( fogFactor, 0.0, 1.0 ); + + vec4 finalColor = mix(fogColor, diffuseColor, fogFactor); + return finalColor; +} \ No newline at end of file diff --git a/jme3-core/src/main/resources/joystick-mapping.properties b/jme3-core/src/main/resources/joystick-mapping.properties index 6c0653c506..210a0ac544 100644 --- a/jme3-core/src/main/resources/joystick-mapping.properties +++ b/jme3-core/src/main/resources/joystick-mapping.properties @@ -21,12 +21,27 @@ # square / 4 : 3 # L1 : 4 # R1 : 5 -# L2 : 6 +# L2 : 6 # R2 : 7 # select : 8 # start : 9 # Lstick button : 10 # Rstick button : 11 +# +# +# L2 and R2 are also often mapped to JoystickAxis.LEFT_TRIGGER +# and JoystickAxis.RIGHT_TRIGGER if the gamepad has pressure sensitive +# triggers. +# +# +# Additionally, joystick names can be "normalized" with a regex +# entry such as: +# XBOX.regex=(?i).*xbox.* +# +# ...that remaps all strings with 'xbox' anywhere in them, case insensitive, +# to the string XBOX. Joystick name remapping is only done if a specific +# mapping doesn't exist. So it is possible to define a default mapping for +# all .*xbox.* joysticks but then specific mappings for some specific name. # Final Fantasy XIV mapping @@ -35,51 +50,83 @@ FF-GP1.1=2 FF-GP1.2=1 FF-GP1.3=0 -# Xbox 360 Controller (Wireless) -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).0=2 -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).1=1 -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).2=3 -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).3=0 +# Some standard regex name remappings +XBOX.regex=(?i).*xbox.* -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).6=8 -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).7=9 +# Cover all XBOX controllers that match the above regex +XBOX.0=2 +XBOX.1=1 +XBOX.2=3 +XBOX.3=0 -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).8=10 -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).9=11 +XBOX.6=8 +XBOX.7=9 -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).rx=z -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).ry=rz +XBOX.8=10 +XBOX.9=11 -# requires custom code to support trigger buttons but this -# keeps it from confusing the .rx mapping. -Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).z=trigger - -# Xbox 360 Controller (copied from wireless version) -Controller\ (XBOX\ 360\ For\ Windows).0=2 -Controller\ (XBOX\ 360\ For\ Windows).1=1 -Controller\ (XBOX\ 360\ For\ Windows).2=3 -Controller\ (XBOX\ 360\ For\ Windows).3=0 +# Maps the right joystick to our 'standard' way +XBOX.rx=z +XBOX.ry=rz -Controller\ (XBOX\ 360\ For\ Windows).6=8 -Controller\ (XBOX\ 360\ For\ Windows).7=9 +# Maps the left/right triggers to our 'standard' way +XBOX.z=rx +XBOX.rz=ry -Controller\ (XBOX\ 360\ For\ Windows).8=10 -Controller\ (XBOX\ 360\ For\ Windows).9=11 -Controller\ (XBOX\ 360\ For\ Windows).rx=z -Controller\ (XBOX\ 360\ For\ Windows).ry=rz +# Xbox 360 Controller (Wireless) +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).0=2 +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).1=1 +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).2=3 +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).3=0 +# +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).6=8 +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).7=9 +# +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).8=10 +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).9=11 +# +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).rx=z +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).ry=rz +# +# requires custom code to support trigger buttons but this +# keeps it from confusing the .rx mapping. +#Controller\ (Xbox\ 360\ Wireless\ Receiver\ for\ Windows).z=trigger +##### Above can be removed, now handled by the "XBOX" configuration. +# Xbox 360 Controller (copied from wireless version) +#Controller\ (XBOX\ 360\ For\ Windows).0=2 +#Controller\ (XBOX\ 360\ For\ Windows).1=1 +#Controller\ (XBOX\ 360\ For\ Windows).2=3 +#Controller\ (XBOX\ 360\ For\ Windows).3=0 +# +#Controller\ (XBOX\ 360\ For\ Windows).6=8 +#Controller\ (XBOX\ 360\ For\ Windows).7=9 +# +#Controller\ (XBOX\ 360\ For\ Windows).8=10 +#Controller\ (XBOX\ 360\ For\ Windows).9=11 +# +#Controller\ (XBOX\ 360\ For\ Windows).rx=z +#Controller\ (XBOX\ 360\ For\ Windows).ry=rz +# # requires custom code to support trigger buttons but this # keeps it from confusing the .rx mapping. -Controller\ (XBOX\ 360\ For\ Windows).z=trigger -Controller\ (XBOX\ 360\ For\ Windows).rz=rtrigger +#Controller\ (XBOX\ 360\ For\ Windows).z=trigger +#Controller\ (XBOX\ 360\ For\ Windows).rz=rtrigger +##### Above can be removed, now handled by the "XBOX" configuration. # XBOX 360 Controller connected to Android using # the USB dongle -Xbox\ 360\ Wireless\ Receiver.AXIS_RX=z -Xbox\ 360\ Wireless\ Receiver.AXIS_RY=rz -Xbox\ 360\ Wireless\ Receiver.z=AXIS_RX -Xbox\ 360\ Wireless\ Receiver.rz=AXIS_RY +#Xbox\ 360\ Wireless\ Receiver.AXIS_RX=z +#Xbox\ 360\ Wireless\ Receiver.AXIS_RY=rz +#Xbox\ 360\ Wireless\ Receiver.z=AXIS_RX +#Xbox\ 360\ Wireless\ Receiver.rz=AXIS_RY +# +# Note: even though the old format didn't define button remappings +# I'm going to assume that they should be remapped. The thing +# is with the new regex XBOX remapping, the ones that aren't +# defined here would have fallen back to that one anyway. +##### Above can be removed, now handled by the "XBOX" configuration. # Microsoft PC-joystick driver Microsoft\ PC-joystick\ driver.12=POV +Y @@ -108,10 +155,8 @@ Gamepad\ F310\ (Controller).9=11 Gamepad\ F310\ (Controller).rx=z Gamepad\ F310\ (Controller).ry=rz -# requires custom code to support trigger buttons but this -# keeps it from confusing the .rx mapping. -Gamepad\ F310\ (Controller).z=trigger -Gamepad\ F310\ (Controller).rz=rtrigger +Gamepad\ F310\ (Controller).z=rx +Gamepad\ F310\ (Controller).rz=ry # Logitech F310 gamepad with dip switch XInput for Windows 10 Controller\ (Gamepad\ F310).0=2 @@ -128,50 +173,73 @@ Controller\ (Gamepad\ F310).9=11 Controller\ (Gamepad\ F310).rx=z Controller\ (Gamepad\ F310).ry=rz -# requires custom code to support trigger buttons but this -# keeps it from confusing the .rx mapping. -Controller\ (Gamepad\ F310).z=trigger -Controller\ (Gamepad\ F310).rz=rtrigger +Controller\ (Gamepad\ F310).z=rx +Controller\ (Gamepad\ F310).rz=ry # Alternate version of the XBOX 360 controller -XBOX\ 360\ For\ Windows\ (Controller).0=2 -XBOX\ 360\ For\ Windows\ (Controller).1=1 -XBOX\ 360\ For\ Windows\ (Controller).2=3 -XBOX\ 360\ For\ Windows\ (Controller).3=0 - -XBOX\ 360\ For\ Windows\ (Controller).6=8 -XBOX\ 360\ For\ Windows\ (Controller).7=9 - -XBOX\ 360\ For\ Windows\ (Controller).8=10 -XBOX\ 360\ For\ Windows\ (Controller).9=11 - -XBOX\ 360\ For\ Windows\ (Controller).rx=z -XBOX\ 360\ For\ Windows\ (Controller).ry=rz - +#XBOX\ 360\ For\ Windows\ (Controller).0=2 +#XBOX\ 360\ For\ Windows\ (Controller).1=1 +#XBOX\ 360\ For\ Windows\ (Controller).2=3 +#XBOX\ 360\ For\ Windows\ (Controller).3=0 +# +#XBOX\ 360\ For\ Windows\ (Controller).6=8 +#XBOX\ 360\ For\ Windows\ (Controller).7=9 +# +#XBOX\ 360\ For\ Windows\ (Controller).8=10 +#XBOX\ 360\ For\ Windows\ (Controller).9=11 +# +#XBOX\ 360\ For\ Windows\ (Controller).rx=z +#XBOX\ 360\ For\ Windows\ (Controller).ry=rz +# # requires custom code to support trigger buttons but this # keeps it from confusing the .rx mapping. -XBOX\ 360\ For\ Windows\ (Controller).z=trigger -XBOX\ 360\ For\ Windows\ (Controller).rz=rtrigger +#XBOX\ 360\ For\ Windows\ (Controller).z=trigger +#XBOX\ 360\ For\ Windows\ (Controller).rz=rtrigger +##### Above can be removed, now handled by the "XBOX" configuration. #Xbox One S controller -Microsoft\ X-Box\ One\ S\ pad.0=2 -Microsoft\ X-Box\ One\ S\ pad.1=1 -Microsoft\ X-Box\ One\ S\ pad.2=3 -Microsoft\ X-Box\ One\ S\ pad.3=0 - -Microsoft\ X-Box\ One\ S\ pad.6=8 -Microsoft\ X-Box\ One\ S\ pad.7=9 - -Microsoft\ X-Box\ One\ S\ pad.8=10 -Microsoft\ X-Box\ One\ S\ pad.9=11 - -Microsoft\ X-Box\ One\ S\ pad.rx=z -Microsoft\ X-Box\ One\ S\ pad.ry=rz - +#Microsoft\ X-Box\ One\ S\ pad.0=2 +#Microsoft\ X-Box\ One\ S\ pad.1=1 +#Microsoft\ X-Box\ One\ S\ pad.2=3 +#Microsoft\ X-Box\ One\ S\ pad.3=0 +# +#Microsoft\ X-Box\ One\ S\ pad.6=8 +#Microsoft\ X-Box\ One\ S\ pad.7=9 +# +#Microsoft\ X-Box\ One\ S\ pad.8=10 +#Microsoft\ X-Box\ One\ S\ pad.9=11 +# +#Microsoft\ X-Box\ One\ S\ pad.rx=z +#Microsoft\ X-Box\ One\ S\ pad.ry=rz +# +# requires custom code to support trigger buttons but this +# keeps it from confusing the .rx mapping. +#Microsoft\ X-Box\ One\ S\ pad.z=trigger +#Microsoft\ X-Box\ One\ S\ pad.rz=rtrigger +##### Above can be removed, now handled by the "XBOX" configuration. + +# XBONE S pad connected via Bluetooth +#Xbox\ Wireless\ Controller.0=2 +#Xbox\ Wireless\ Controller.1=1 +#Xbox\ Wireless\ Controller.2=3 +#Xbox\ Wireless\ Controller.3=0 +# +#Xbox\ Wireless\ Controller.6=8 +#Xbox\ Wireless\ Controller.7=9 +# +#Xbox\ Wireless\ Controller.8=10 +#Xbox\ Wireless\ Controller.9=11 +# +#Xbox\ Wireless\ Controller.rx=z +#Xbox\ Wireless\ Controller.ry=rz +# # requires custom code to support trigger buttons but this # keeps it from confusing the .rx mapping. -Microsoft\ X-Box\ One\ S\ pad.z=trigger -Microsoft\ X-Box\ One\ S\ pad.rz=rtrigger +#Xbox\ Wireless\ Controller.z=trigger +#Xbox\ Wireless\ Controller.rz=rtrigger +##### Above can be removed, now handled by the "XBOX" configuration. + + # from : Freebox controller as "DragonRise Inc. Generic USB Joystick" DragonRise\ Inc.\ \ \ Generic\ \ \ USB\ \ Joystick.x=rx diff --git a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java index b34adbca60..d4c24054dc 100644 --- a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java +++ b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,7 +110,7 @@ public Object load(AssetInfo info){ return s; } catch (IOException ex) { - logger.log(Level.SEVERE, "An error occured while loading jME binary object", ex); + logger.log(Level.SEVERE, "An error occurred while loading jME binary object", ex); } finally { if (is != null){ try { diff --git a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryInputCapsule.java b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryInputCapsule.java index cca304a3b4..1216887143 100644 --- a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryInputCapsule.java +++ b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryInputCapsule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1073,7 +1073,7 @@ else if ((b & 0xE0) == 0xE0) { else { logger.log( Level.WARNING, - "Your export has been saved with an incorrect encoding for it's String fields which means it might not load correctly " + + "Your export has been saved with an incorrect encoding for its String fields which means it might not load correctly " + "due to encoding issues. You should probably re-export your work. See ISSUE 276 in the jME issue tracker." ); // We use ISO8859_1 to be consistent across platforms. We could default to native encoding, but this would lead to inconsistent diff --git a/jme3-core/src/plugins/java/com/jme3/font/plugins/BitmapFontLoader.java b/jme3-core/src/plugins/java/com/jme3/font/plugins/BitmapFontLoader.java index 93d8bb5f08..07aa9813ee 100644 --- a/jme3-core/src/plugins/java/com/jme3/font/plugins/BitmapFontLoader.java +++ b/jme3-core/src/plugins/java/com/jme3/font/plugins/BitmapFontLoader.java @@ -43,7 +43,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import org.omg.PortableInterceptor.SYSTEM_EXCEPTION; public class BitmapFontLoader implements AssetLoader { diff --git a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java index bd0c597002..88674fdffd 100644 --- a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java +++ b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java @@ -295,8 +295,7 @@ private Texture parseTextureType(final VarType type, final String value) { for (final TextureOptionValue textureOptionValue : textureOptionValues) { textureOptionValue.applyToTexture(texture); } - } - + } return texture; } @@ -402,7 +401,7 @@ private void readParam(String statement) throws IOException{ defaultValObj = readValue(type, defaultVal); } if(type.isTextureType()){ - materialDef.addMaterialParamTexture(type, name, colorSpace); + materialDef.addMaterialParamTexture(type, name, colorSpace,(Texture)defaultValObj); }else{ materialDef.addMaterialParam(type, name, defaultValObj); } @@ -657,7 +656,7 @@ private void readTechnique(Statement techStat) throws IOException{ technique.setLogic(new SinglePassAndImageBasedLightingLogic(technique)); break; default: - throw new UnsupportedOperationException(); + throw new IOException("Light mode not supported:" + technique.getLightMode()); } List techniqueDefs = new ArrayList<>(); diff --git a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java b/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java index 5132fbd2f9..359fa979e5 100644 --- a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java +++ b/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -280,16 +280,14 @@ private void readPixelFormat() throws IOException { normal = true; } break; - /* case PF_ATI1: bpp = 4; - pixelFormat = Image.Format.LTC; + pixelFormat = Image.Format.RGTC1; break; case PF_ATI2: bpp = 8; - pixelFormat = Image.Format.LATC; + pixelFormat = Image.Format.RGTC2; break; - */ case PF_DX10: compressed = false; directx10 = true; @@ -446,7 +444,7 @@ public byte[] flipData(byte[] data, int scanlineSize, int height) { * @param flip Flip the loaded image by Y axis * @param totalSize Total size of the image in bytes including the mipmaps * @return A ByteBuffer containing the grayscale image data with mips. - * @throws java.io.IOException If an error occured while reading from InputStream + * @throws java.io.IOException If an error occurred while reading from InputStream */ public ByteBuffer readGrayscale2D(boolean flip, int totalSize) throws IOException { ByteBuffer buffer = BufferUtils.createByteBuffer(totalSize); @@ -481,7 +479,7 @@ public ByteBuffer readGrayscale2D(boolean flip, int totalSize) throws IOExceptio * @param flip Flip the image on the Y axis * @param totalSize Size of the image in bytes including mipmaps * @return ByteBuffer containing image data with mipmaps in the format specified by pixelFormat_ - * @throws java.io.IOException If an error occured while reading from InputStream + * @throws java.io.IOException If an error occurred while reading from InputStream */ public ByteBuffer readRGB2D(boolean flip, int totalSize) throws IOException { int redCount = count(redMask), @@ -547,7 +545,7 @@ public ByteBuffer readRGB2D(boolean flip, int totalSize) throws IOException { * * @param totalSize Total size of the image in bytes, including mipmaps * @return ByteBuffer containing compressed DXT image in the format specified by pixelFormat_ - * @throws java.io.IOException If an error occured while reading from InputStream + * @throws java.io.IOException If an error occurred while reading from InputStream */ public ByteBuffer readDXT2D(boolean flip, int totalSize) throws IOException { logger.finest("Source image format: DXT"); @@ -584,7 +582,7 @@ public ByteBuffer readDXT2D(boolean flip, int totalSize) throws IOException { * @param flip Flip the loaded image by Y axis * @param totalSize Total size of the image in bytes including the mipmaps * @return A ByteBuffer containing the grayscale image data with mips. - * @throws java.io.IOException If an error occured while reading from InputStream + * @throws java.io.IOException If an error occurred while reading from InputStream */ public ByteBuffer readGrayscale3D(boolean flip, int totalSize) throws IOException { ByteBuffer buffer = BufferUtils.createByteBuffer(totalSize * depth); @@ -622,7 +620,7 @@ public ByteBuffer readGrayscale3D(boolean flip, int totalSize) throws IOExceptio * @param flip Flip the image on the Y axis * @param totalSize Size of the image in bytes including mipmaps * @return ByteBuffer containing image data with mipmaps in the format specified by pixelFormat_ - * @throws java.io.IOException If an error occured while reading from InputStream + * @throws java.io.IOException If an error occurred while reading from InputStream */ public ByteBuffer readRGB3D(boolean flip, int totalSize) throws IOException { int redCount = count(redMask), @@ -690,7 +688,7 @@ public ByteBuffer readRGB3D(boolean flip, int totalSize) throws IOException { * * @param totalSize Total size of the image in bytes, including mipmaps * @return ByteBuffer containing compressed DXT image in the format specified by pixelFormat_ - * @throws java.io.IOException If an error occured while reading from InputStream + * @throws java.io.IOException If an error occurred while reading from InputStream */ public ByteBuffer readDXT3D(boolean flip, int totalSize) throws IOException { logger.finest("Source image format: DXT"); @@ -738,7 +736,7 @@ public ByteBuffer readDXT3D(boolean flip, int totalSize) throws IOException { * @return An ArrayList containing a single ByteBuffer for a 2D image, or 6 ByteBuffers for a cubemap. * The cubemap ByteBuffer order is PositiveX, NegativeX, PositiveY, NegativeY, PositiveZ, NegativeZ. * - * @throws java.io.IOException If an error occured while reading from the stream. + * @throws java.io.IOException If an error occurred while reading from the stream. */ public ArrayList readData(boolean flip) throws IOException { int totalSize = 0; diff --git a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DXTFlipper.java b/jme3-core/src/plugins/java/com/jme3/texture/plugins/DXTFlipper.java index 726cf3e192..e460a75a63 100644 --- a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DXTFlipper.java +++ b/jme3-core/src/plugins/java/com/jme3/texture/plugins/DXTFlipper.java @@ -213,14 +213,12 @@ public static ByteBuffer flipDXT(ByteBuffer img, int w, int h, Format format){ case DXT5: type = 3; break; - /* - case LATC: + case RGTC2: type = 4; - break; - case LTC: + break; + case RGTC1: type = 5; break; - */ default: throw new IllegalArgumentException(); } diff --git a/jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java b/jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java new file mode 100644 index 0000000000..331784352d --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/anim/AnimComposerTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.anim; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Remy Van Doosselaer + */ +public class AnimComposerTest { + + @Test + public void testGetAnimClips() { + AnimComposer composer = new AnimComposer(); + + Assert.assertNotNull(composer.getAnimClips()); + Assert.assertEquals(0, composer.getAnimClips().size()); + } + + @Test + public void testGetAnimClipsNames() { + AnimComposer composer = new AnimComposer(); + + Assert.assertNotNull(composer.getAnimClipsNames()); + Assert.assertEquals(0, composer.getAnimClipsNames().size()); + } + + @Test(expected = UnsupportedOperationException.class) + public void testGetAnimClipsIsNotModifiable() { + AnimComposer composer = new AnimComposer(); + + composer.getAnimClips().add(new AnimClip("test")); + } + + @Test(expected = UnsupportedOperationException.class) + public void testGetAnimClipsNamesIsNotModifiable() { + AnimComposer composer = new AnimComposer(); + + composer.getAnimClipsNames().add("test"); + } + +} diff --git a/jme3-core/src/test/java/com/jme3/material/MaterialTest.java b/jme3-core/src/test/java/com/jme3/material/MaterialTest.java index e186f5e65d..05a9ef3781 100644 --- a/jme3-core/src/test/java/com/jme3/material/MaterialTest.java +++ b/jme3-core/src/test/java/com/jme3/material/MaterialTest.java @@ -32,7 +32,6 @@ package com.jme3.material; import com.jme3.asset.AssetManager; -import com.jme3.light.LightList; import com.jme3.renderer.Caps; import com.jme3.renderer.RenderManager; import com.jme3.scene.Geometry; diff --git a/jme3-core/src/test/java/com/jme3/math/FastMathTest.java b/jme3-core/src/test/java/com/jme3/math/FastMathTest.java index 709f0829cf..e4aa1750a7 100644 --- a/jme3-core/src/test/java/com/jme3/math/FastMathTest.java +++ b/jme3-core/src/test/java/com/jme3/math/FastMathTest.java @@ -33,15 +33,22 @@ import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import org.junit.Ignore; +import java.lang.Math; + +import org.junit.Rule; +import org.junit.rules.ExpectedException; + /** * Verifies that algorithms in {@link FastMath} are working correctly. * * @author Kirill Vainer */ public class FastMathTest { + + @Rule public ExpectedException thrown = ExpectedException.none(); private int nearestPowerOfTwoSlow(int number) { return (int) Math.pow(2, Math.ceil(Math.log(number) / Math.log(2))); @@ -69,7 +76,7 @@ private static Vector2f randomVector() { return new Vector2f(FastMath.nextRandomFloat(), FastMath.nextRandomFloat()); } - + @Ignore @Test public void testCounterClockwise() { @@ -94,4 +101,624 @@ public void testCounterClockwise() { assertEquals(slowResult, fastResult); } + + @Test + public void testAcos() { + assertEquals((float)Math.PI, FastMath.acos(-2.0f), 0.01f); + assertEquals(0.0f, FastMath.acos(2.0f), 0.0f); + assertEquals(1.57f, FastMath.acos(0.0f), 0.01f); + assertEquals(1.047f, FastMath.acos(0.5f), 0.01f); + assertEquals(0.0f, FastMath.acos(Float.POSITIVE_INFINITY), 0.0f); + assertEquals(0x1.921fb6p+1f, FastMath.acos(-0x1p+113f), 0.01f); + } + + @Test + public void testApproximateEquals() { + assertTrue(FastMath.approximateEquals(1000.0f, 1000.0f)); + assertTrue(FastMath.approximateEquals(100000.0f, 100001.0f)); + assertTrue(FastMath.approximateEquals(0.0f, -0.0f)); + + assertFalse(FastMath.approximateEquals(10000.0f, 10001.0f)); + assertFalse(FastMath.approximateEquals(149.0f, 0.0f)); + } + + @Test + public void testAsin() { + final float HALF_PI = 0.5f * (float)Math.PI; + + assertEquals(-HALF_PI, FastMath.asin(-2.0f), 0.01f); + assertEquals(HALF_PI, FastMath.asin(2.0f), 0.01f); + assertEquals(HALF_PI, FastMath.asin(Float.POSITIVE_INFINITY), 0.0f); + assertEquals(0.0f, FastMath.asin(0.0f), 0.0f); + assertEquals(0.523f, FastMath.asin(0.5f), 0.01f); + assertEquals(-1.570f, FastMath.asin(-0x1p+113f), 0.01f); + } + + @Test + public void testAtan() { + assertEquals(0.0f, FastMath.atan2(0.0f, 0.0f), 0.0f); + assertEquals(0.076f, FastMath.atan2(1.0f, 13.0f), 0.01f); + } + + @Test + public void testCartesianToSpherical() { + final Vector3f cartCoords = new Vector3f(1.1f, 5.8f, 8.1f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.cartesianToSpherical(cartCoords, store); + + assertEquals(store, retval); + + assertNotNull(store); + assertEquals(10.022974f, store.getX(), 0.0f); + assertEquals(1.4358196f, store.getY(), 0.01f); + assertEquals(0.61709767f, store.getZ(), 0.0f); + + assertNotNull(retval); + assertEquals(10.022974f, retval.getX(), 0.0f); + assertEquals(1.4358196f, retval.getY(), 0.01f); + assertEquals(0.61709767f, retval.getZ(), 0.0f); + } + + @Test + public void testCartesianZToSpherical() { + final Vector3f cartCoords = new Vector3f(1.1f, 5.8f, 8.1f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.cartesianZToSpherical(cartCoords, store); + + assertEquals(store, retval); + + assertNotNull(store); + assertEquals(10.022974f, store.getX(), 0.01f); + assertEquals(0.61709767f, store.getY(), 0.01f); + assertEquals(1.4358196f, store.getZ(), 0.01f); + + assertNotNull(retval); + assertEquals(10.022974f, retval.getX(), 0.01f); + assertEquals(0.61709767f, retval.getY(), 0.01f); + assertEquals(1.4358196f, retval.getZ(), 0.01f); + } + + @Test + public void testComputeNormal() { + final Vector3f v1 = new Vector3f(1.1f, 9.5f, -7.2f); + final Vector3f v2 = new Vector3f(Float.NaN, -0.2f, 6.1f); + final Vector3f v3 = new Vector3f(-0.5f, -0.14f, -1.8f); + + final Vector3f retval = FastMath.computeNormal(v1, v2, v3); + + assertNotNull(retval); + assertEquals(Float.NaN, retval.getX(), 0.0f); + assertEquals(Float.NaN, retval.getY(), 0.0f); + assertEquals(Float.NaN, retval.getZ(), 0.0f); + } + + @Test + public void testComputeNormal2() { + final Vector3f v1 = new Vector3f(-0.4f, 0.1f, 2.9f); + final Vector3f v2 = new Vector3f(-0.4f, 0.1f, 2.9f); + final Vector3f v3 = new Vector3f(-1.4f, 10.1f, 2.9f); + + final Vector3f retval = FastMath.computeNormal(v1, v2, v3); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testConvertFloatToHalfUnsupportedOperationException() { + thrown.expect(UnsupportedOperationException.class); + FastMath.convertFloatToHalf(Float.NaN); + } + + @Test + public void testConvertFloatToHalf() { + assertEquals((short)-1024, FastMath.convertFloatToHalf(Float.NEGATIVE_INFINITY)); + assertEquals((short)31744, FastMath.convertFloatToHalf(Float.POSITIVE_INFINITY)); + assertEquals((short)-1025, FastMath.convertFloatToHalf(-131328.0f)); + assertEquals((short)-32767, FastMath.convertFloatToHalf(-0x1p-135f)); + assertEquals((short)1, FastMath.convertFloatToHalf(0x1.008p-71f)); + assertEquals((short)31743, FastMath.convertFloatToHalf(0x1.008p+121f)); + assertEquals((short)0, FastMath.convertFloatToHalf(0.0f)); + } + + @Test + public void testConvertHalfToFloat() { + assertEquals(Float.POSITIVE_INFINITY, FastMath.convertHalfToFloat((short)31744), 0.0f); + assertEquals(0.0f, FastMath.convertHalfToFloat((short)0), 0.0f); + assertEquals(65504.0f, FastMath.convertHalfToFloat((short)31743), 0.0f); + assertEquals(-65536.0f, FastMath.convertHalfToFloat((short)-1024), 0.0f); + assertEquals(-65504.0f, FastMath.convertHalfToFloat((short)-1025), 0.0f); + } + + @Test + public void testCopysign() { + assertEquals(-3.85186e-34, FastMath.copysign(-3.85186e-34f, -1.0f), 0.01f); + assertEquals(0.0f, FastMath.copysign(0.0f, Float.NaN), 0.0f); + assertEquals(Float.NaN, FastMath.copysign(Float.NaN, 1.0f), 0.0f); + assertEquals(0.0f, FastMath.copysign(-0.0f, -1.0f), 0.0f); + assertEquals(0.0f, FastMath.copysign(-0.0f, 0.0f), 0.0f); + assertEquals(-1.0f, FastMath.copysign(1.0f, -3.0f), 0.0f); + } + + @Test + public void testCounterClockwise2() { + final Vector2f p0 = new Vector2f(0.125f, -2.14644e+09f); + final Vector2f p1 = new Vector2f(-6.375f, -3.96141e+28f); + final Vector2f p2 = new Vector2f(0.078125f, -2.14644e+09f); + + assertEquals(-1, FastMath.counterClockwise(p0, p1, p2)); + } + + @Test + public void testCounterClockwise3() { + final Vector2f p0 = new Vector2f(2.34982e-38f, 1.25063e+27f); + final Vector2f p1 = new Vector2f(2.34982e-38f, 1.25061e+27f); + final Vector2f p2 = new Vector2f(3.51844e+13f, Float.NaN); + + assertEquals(0, FastMath.counterClockwise(p0, p1, p2)); + } + + @Test + public void testCounterClockwise4() { + final Vector2f p0 = new Vector2f(262143.0f, 4.55504e-38f); + final Vector2f p1 = new Vector2f(262144.0f, 2.50444f); + final Vector2f p2 = new Vector2f(204349.0f, 4.77259e-38f); + + assertEquals(1, FastMath.counterClockwise(p0, p1, p2)); + } + + @Test + public void testCounterClockwise5() { + final Vector2f p0 = new Vector2f(-1.87985e-37f, -1.16631e-38f); + final Vector2f p1 = new Vector2f(-1.87978e-37f, -1.18154e-38f); + final Vector2f p2 = new Vector2f(-6.56451e-21f, -1.40453e-38f); + + assertEquals(1, FastMath.counterClockwise(p0, p1, p2)); + } + + @Test + public void testCounterClockwise6() { + final Vector2f p0 = new Vector2f(1.07374e+09f, 1.07374e+09f); + final Vector2f p1 = new Vector2f(1.07374e+09f, 1.07374e+09f); + final Vector2f p2 = new Vector2f(1.07374e+09f, 1.07374e+09f); + + assertEquals(0, FastMath.counterClockwise(p0, p1, p2)); + } + + + @Test + public void testDeterminant() { + assertEquals(20.0f, FastMath.determinant( + 5.0, -7.0, 2.0, 2.0, + 0.0, 3.0, 0.0, -4.0, + -5.0, -8.0, 0.0, 3.0, + 0.0, 5.0, 0.0, -6.0), 0.0f); + + assertEquals(0.0f, FastMath.determinant( + 1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, 12.0, + 13.0, 14.0, 15.0, 16.0), 0.0f); + } + + @Test + public void testExtrapolateLinear() { + final float scale = 0.0f; + final Vector3f startValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f endValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.extrapolateLinear(scale, startValue, endValue, store); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testExtrapolateLinear2() { + final float scale = 0.6f; + final Vector3f startValue = new Vector3f(1.6f, 3.1f, 2.2f); + final Vector3f endValue = new Vector3f(0.5f, 1.2f, 4.9f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.extrapolateLinear(scale, startValue, endValue, store); + + assertNotNull(retval); + assertEquals(0.94f, retval.getX(), 0.01f); + assertEquals(1.95f, retval.getY(), 0.01f); + assertEquals(3.82f, retval.getZ(), 0.01f); + } + + @Test + public void testExtrapolateLinearNoStore() { + final float scale = 0.0f; + final Vector3f startValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f endValue = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.extrapolateLinear(scale, startValue, endValue); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testExtrapolateLinearNoStore2() { + final float scale = 0.6f; + final Vector3f startValue = new Vector3f(1.6f, 3.1f, 2.2f); + final Vector3f endValue = new Vector3f(0.5f, 1.2f, 4.9f); + + final Vector3f retval = FastMath.extrapolateLinear(scale, startValue, endValue); + + assertNotNull(retval); + assertEquals(0.94f, retval.getX(), 0.01f); + assertEquals(1.95f, retval.getY(), 0.01f); + assertEquals(3.82f, retval.getZ(), 0.01f); + } + + @Test + public void testInterpolateBezier() { + final float u = 0.0f; + final Vector3f p0 = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f p1 = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f p2 = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f p3 = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.interpolateBezier(u, p0, p1, p2, p3, store); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateBezier2() { + final float u = 0.5f; + final Vector3f p0 = new Vector3f(1.0f, 2.0f, 3.0f); + final Vector3f p1 = new Vector3f(6.0f, 7.0f, 8.0f); + final Vector3f p2 = new Vector3f(2.0f, 3.0f, 4.0f); + final Vector3f p3 = new Vector3f(0.0f, 1.0f, 8.0f); + final Vector3f store = new Vector3f(1.0f, 2.0f, 3.0f); + + final Vector3f retval = FastMath.interpolateBezier(u, p0, p1, p2, p3, store); + + assertNotNull(retval); + assertEquals(3.125f, retval.getX(), 0.0f); + assertEquals(4.125f, retval.getY(), 0.0f); + assertEquals(5.875f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateBezierNoStore() { + final float u = 0.5f; + final Vector3f p0 = new Vector3f(1.0f, 2.0f, 3.0f); + final Vector3f p1 = new Vector3f(6.0f, 7.0f, 8.0f); + final Vector3f p2 = new Vector3f(2.0f, 3.0f, 4.0f); + final Vector3f p3 = new Vector3f(0.0f, 1.0f, 8.0f); + + final Vector3f retval = FastMath.interpolateBezier(u, p0, p1, p2, p3); + + assertNotNull(retval); + assertEquals(3.125f, retval.getX(), 0.0f); + assertEquals(4.125f, retval.getY(), 0.0f); + assertEquals(5.875f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateCatmullRom() { + final float u = 0.5f; + final float T = 0.5f; + final Vector3f p0 = new Vector3f(1.0f, 2.0f, 3.0f); + final Vector3f p1 = new Vector3f(6.0f, 7.0f, 8.0f); + final Vector3f p2 = new Vector3f(2.0f, 3.0f, 4.0f); + final Vector3f p3 = new Vector3f(0.0f, 1.0f, 8.0f); + + final Vector3f retval = FastMath.interpolateCatmullRom(u, T, p0, p1, p2, p3); + + assertNotNull(retval); + assertEquals(4.4375f, retval.getX(), 0.0f); + assertEquals(5.4375f, retval.getY(), 0.0f); + assertEquals(6.0625f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear() { + final float scale = -1.00195f; + final Vector3f startValue = new Vector3f(32.0f, 0.0f, 0.0f); + final Vector3f endValue = new Vector3f(32.0f, Float.POSITIVE_INFINITY, -0.0f); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue); + + assertNotNull(retval); + assertEquals(32.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear2() { + final float scale = 1.0842e-19f; + final Vector3f startValue = new Vector3f(0.0f, 0.0f, 1.4013e-45f); + final Vector3f endValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue, store); + + assertEquals(store, retval); + + assertNotNull(store); + assertEquals(0.0f, store.getX(), 0.0f); + assertEquals(0.0f, store.getY(), 0.0f); + assertEquals(1.4013e-45f, store.getZ(), 0.0f); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(1.4013e-45f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear3() { + final float scale = 1.03125f; + final Vector3f startValue = new Vector3f(0.0f, 16.0f, Float.NaN); + final Vector3f endValue = new Vector3f(0.0f, 16.0f, Float.POSITIVE_INFINITY); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue, store); + + assertEquals(store, retval); + + assertNotNull(store); + assertEquals(0.0f, store.getX(), 0.0f); + assertEquals(16.0f, store.getY(), 0.0f); + assertEquals(Float.POSITIVE_INFINITY, store.getZ(), 0.0f); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(16.0f, retval.getY(), 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear4() { + final float scale = 1.00195f; + final Vector3f startValue = new Vector3f(256.0f, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY); + final Vector3f endValue = new Vector3f(0.0f, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.getY(), 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear5() { + final float scale = 0.309184f; + final Vector3f startValue = new Vector3f(-53.1157f, 0.0f, 1.23634f); + final Vector3f endValue = new Vector3f(-1.98571f, Float.POSITIVE_INFINITY, 3.67342e-40f); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue); + + assertNotNull(retval); + assertEquals(-37.3071f, retval.getX(), 0.01f); + assertEquals(Float.POSITIVE_INFINITY, retval.getY(), 0.0f); + assertEquals(0.854082f, retval.getZ(), 0.01f); + } + + @Test + public void testInterpolateLinear6() { + final float scale = 0.0f; + final Vector3f startValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f endValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue, store); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear7() { + final float scale = 0.0f; + final Vector3f startValue = new Vector3f(1.4013e-45f, 0.0f, 0.0f); + final Vector3f endValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue, store); + + assertEquals(store, retval); + + assertNotNull(store); + assertEquals(1.4013e-45f, store.getX(), 0.0f); + assertEquals(0.0f, store.getY(), 0.0f); + assertEquals(0.0f, store.getZ(), 0.0f); + + assertNotNull(retval); + assertEquals(1.4013e-45f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear8() { + final float scale = 0.0f; + final Vector3f startValue = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f endValue = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.interpolateLinear(scale, startValue, endValue); + + assertNotNull(retval); + assertEquals(0.0f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testInterpolateLinear_float() { + assertEquals(0.0f, FastMath.interpolateLinear(2.0f, 2.93874e-39f, 0.0f), 0.0f); + assertEquals(0.0f, FastMath.interpolateLinear(0.999999f, 1.4013e-45f, 0.0f), 0.0f); + assertEquals(-2.93874e-39f, FastMath.interpolateLinear(0.0f, -2.93874e-39f, -0.0f), 0.0f); + assertEquals(0.0f, FastMath.interpolateLinear(0.0f, 0.0f, 0.0f), 0.0f); + } + + @Test + public void testNormalize() { + assertEquals(0.0f, FastMath.normalize(Float.POSITIVE_INFINITY, 0.0f, 0.0f), 0.0f); + assertEquals(0.0f, FastMath.normalize(Float.NaN, 0.0f, 0.0f), 0.0f); + assertEquals(4.0f, FastMath.normalize(15.0f, 1.0f, 12.0f), 0.0f); + assertEquals(15.0f, FastMath.normalize(15.0f, 1.0f, 16.0f), 0.0f); + assertEquals(0.0f, FastMath.normalize(0.0f, 0.0f, 0.0f), 0.0f); + } + + @Test + public void testPointInsideTriangle() { + final Vector2f t0 = new Vector2f(2.03f, -4.04f); + final Vector2f t1 = new Vector2f(0.12f, 5.45f); + final Vector2f t2 = new Vector2f(1.90f, 3.43f); + final Vector2f p = new Vector2f(1.28f, 3.46f); + + assertEquals(-1, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testPointInsideTriangle2() { + final Vector2f t0 = new Vector2f(2.03f, 4.04f); + final Vector2f t1 = new Vector2f(0.12f, -5.45f); + final Vector2f t2 = new Vector2f(1.90f, -3.43f); + final Vector2f p = new Vector2f(1.90f, -3.43f); + + assertEquals(1, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testPointInsideTriangle3() { + final Vector2f t0 = new Vector2f(-0.0f, 7.38f); + final Vector2f t1 = new Vector2f(-1.0f, 1.70f); + final Vector2f t2 = new Vector2f(Float.NaN, -4.18f); + final Vector2f p = new Vector2f(-1.0f, -2.12f); + + assertEquals(1, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testPointInsideTriangle4() { + final Vector2f t0 = new Vector2f(4.82f, 1.35f); + final Vector2f t1 = new Vector2f(-1.36f, Float.NaN); + final Vector2f t2 = new Vector2f(-1.0f, 9.45f); + final Vector2f p = new Vector2f(2.32f, Float.NaN); + + assertEquals(1, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testPointInsideTriangle5() { + final Vector2f t0 = new Vector2f(1.32f, 9.55f); + final Vector2f t1 = new Vector2f(Float.NaN, -2.35f); + final Vector2f t2 = new Vector2f(-5.42f, Float.NaN); + final Vector2f p = new Vector2f(-7.20f, 8.81f); + + assertEquals(1, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testPointInsideTriangle6() { + final Vector2f t0 = new Vector2f(-0.43f, 2.54f); + final Vector2f t1 = new Vector2f(Float.NEGATIVE_INFINITY, 2.54f); + final Vector2f t2 = new Vector2f(Float.NaN, Float.POSITIVE_INFINITY); + final Vector2f p = new Vector2f(-3.19f, -0.001f);; + + assertEquals(0, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testPointInsideTriangle7() { + final Vector2f t0 = new Vector2f(-3.32f, 1.87f); + final Vector2f t1 = new Vector2f(-2.72f, 1.87f); + final Vector2f t2 = new Vector2f(-1.27f, 1.87f); + final Vector2f p = new Vector2f(6.38f, 1.90f); + + assertEquals(0, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testPointInsideTriangle8() { + final Vector2f t0 = new Vector2f(3.96f, -511.96f); + final Vector2f t1 = new Vector2f(-5.36f, 1.27f); + final Vector2f t2 = new Vector2f(1.56f, -7.84f); + final Vector2f p = new Vector2f(5.06f, Float.NEGATIVE_INFINITY); + + assertEquals(0, FastMath.pointInsideTriangle(t0, t1, t2, p)); + } + + @Test + public void testSaturate() { + assertEquals(0.0f, FastMath.saturate(-2.0f), 0.0f); + assertEquals(1.0f, FastMath.saturate(1.0f), 0.0f); + assertEquals(1.0f, FastMath.saturate(7.5f), 0.0f); + assertEquals(0.0f, FastMath.saturate(0.0f), 0.0f); + assertEquals(0.5f, FastMath.saturate(0.5f), 0.0f); + assertEquals(0.75f, FastMath.saturate(0.75f), 0.0f); + } + + @Test + public void testSign() { + assertEquals(-1, FastMath.sign(-2_147_483_647)); + assertEquals(1, FastMath.sign(1)); + assertEquals(0, FastMath.sign(0)); + assertEquals(0.0f, FastMath.sign(0.0f), 0.0f); + } + + @Test + public void testSphericalToCartesian() { + final Vector3f sphereCoords = new Vector3f(4.29497e+09f, 0.0f, 0.0f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.sphericalToCartesian(sphereCoords, store); + + assertEquals(store, retval); + + assertNotNull(store); + assertEquals(4294969900f, store.getX(), 0.01f); + assertEquals(0.0f, store.getY(), 0.0f); + assertEquals(0.0f, store.getZ(), 0.0f); + + assertNotNull(retval); + assertEquals(4294969900f, retval.getX(), 0.01f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } + + @Test + public void testSphericalToCartesianZ() { + final Vector3f sphereCoords = new Vector3f(4.29497e+09f, 0.0f, 0.0f); + final Vector3f store = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = FastMath.sphericalToCartesianZ(sphereCoords, store); + + assertEquals(store, retval); + + assertNotNull(store); + assertEquals(4294969900f, store.getX(), 0.0f); + assertEquals(0.0f, store.getY(), 0.0f); + assertEquals(0.0f, store.getZ(), 0.0f); + + assertNotNull(retval); + assertEquals(4294969900f, retval.getX(), 0.0f); + assertEquals(0.0f, retval.getY(), 0.0f); + assertEquals(0.0f, retval.getZ(), 0.0f); + } } diff --git a/jme3-core/src/test/java/com/jme3/math/TestIssue957.java b/jme3-core/src/test/java/com/jme3/math/TestIssue957.java new file mode 100644 index 0000000000..16cca641e0 --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/math/TestIssue957.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.math; + +import org.junit.Test; + +/** + * Verify that a Triangle center and normal get recomputed after a change. This + * was issue #957 at GitHub. + * + * @author Stephen Gold + */ +public class TestIssue957 { + + final private Vector3f v0 = new Vector3f(0f, 0f, 0f); + final private Vector3f v1 = new Vector3f(3f, 0f, 0f); + final private Vector3f v2 = new Vector3f(0f, 3f, 0f); + + @Test + public void testIssue957() { + Vector3f v3 = new Vector3f(0f, 0f, 3f); + + Triangle t1 = makeTriangle(); + t1.set(2, v3); + checkTriangle(t1); + + Triangle t2 = makeTriangle(); + t2.set(v3, v0, v1); + checkTriangle(t2); + + Triangle t3 = makeTriangle(); + t3.set(2, v3.x, v3.y, v3.z); + checkTriangle(t3); + + Triangle t4 = makeTriangle(); + t4.set3(v3); + checkTriangle(t4); + } + + private Triangle makeTriangle() { + + Triangle triangle = new Triangle(v0, v1, v2); + /* + * Check center and normal before modification. + */ + Vector3f center = triangle.getCenter(); + Vector3f normal = triangle.getNormal(); + assert center.equals(new Vector3f(1f, 1f, 0f)); + assert normal.equals(new Vector3f(0f, 0f, 1f)); + + return triangle; + } + + /** + * Check center and normal after modification. + */ + private void checkTriangle(Triangle triangle) { + Vector3f center = triangle.getCenter(); + Vector3f normal = triangle.getNormal(); + assert center.equals(new Vector3f(1f, 0f, 1f)); + assert normal.equals(new Vector3f(0f, -1f, 0f)); + } +} diff --git a/jme3-core/src/test/java/com/jme3/math/Vector3fTest.java b/jme3-core/src/test/java/com/jme3/math/Vector3fTest.java new file mode 100644 index 0000000000..136f634745 --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/math/Vector3fTest.java @@ -0,0 +1,1098 @@ +/* + * Copyright (c) 2009-2015 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.math; + +import org.junit.Test; + +import static org.junit.Assert.*; +import org.junit.Rule; +import org.junit.rules.ExpectedException; + +public class Vector3fTest { + + @Rule public ExpectedException thrown = ExpectedException.none(); + + @Test + public void testAdd() { + final Vector3f target = new Vector3f(1.0f, Float.NaN, 5.36f); + final Vector3f vec = new Vector3f(-1.0f, 2.93f, -5.36f); + + final Vector3f retval = target.add(vec); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(Float.NaN, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testAdd2() { + final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); + final Vector3f retval = target.add(1.42f, 7.52f, 1.1f); + + assertNotNull(retval); + assertEquals(1.42f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(4.2f, retval.z, 0.0f); + } + + @Test + public void testAdd3() { + final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); + final Vector3f other = new Vector3f(1.42f, 7.52f, 1.1f); + final Vector3f result = new Vector3f(); + final Vector3f retval = target.add(other, result); + + assertNotNull(retval); + assertEquals(retval, result); + assertEquals(1.42f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(4.2f, retval.z, 0.0f); + } + + @Test + public void testAdd4() { + thrown.expect(NullPointerException.class); + final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); + final Vector3f other = new Vector3f(1.42f, 7.52f, 1.1f); + final Vector3f result = null; + target.add(other, result); + } + + + @Test + public void testAdd5() { + final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); + final Vector3f retval = target.add(null); + + assertNull(retval); + } + + @Test + public void testAddLocal() { + final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); + final Vector3f retval = target.addLocal(null); + + assertNull(retval); + } + + @Test + public void testAddLocal2() { + final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); + final Vector3f retval = target.addLocal(new Vector3f(2.0f, 6.2f, 8.3f)); + + assertNotNull(retval); + assertEquals(retval.x, 2.0f, 0.0f); + assertEquals(retval.y, -1.32f, 0.01f); + assertEquals(retval.z, 11.4f, 0.0f); + } + + @Test + public void testAddLocal3() { + final Vector3f target = new Vector3f(0.0f, -7.52f, 3.1f); + final Vector3f retval = target.addLocal(2.0f, 6.2f, 8.3f); + + assertNotNull(retval); + assertEquals(retval.x, 2.0f, 0.0f); + assertEquals(retval.y, -1.32f, 0.01f); + assertEquals(retval.z, 11.4f, 0.0f); + } + + @Test + public void testDot() { + final Vector3f target = new Vector3f(0.0f, -1.5f, 3.0f); + assertEquals(19.5f, target.dot(new Vector3f(2.0f, 3.0f, 8.0f)), 0.0f); + } + + @Test + public void testDot2() { + final Vector3f target = new Vector3f(0.0f, -1.5f, 3.0f); + assertEquals(0.0f, target.dot(null), 0.0f); + } + + @Test + public void testAngleBetween() { + final Vector3f target = new Vector3f(Float.NaN, 6.08159e-39f, 5.33333f); + final Vector3f otherVector = new Vector3f(3.76643e-39f, -2.97033e+38f, 0.09375f); + + assertEquals(3.141f, target.angleBetween(otherVector), 0.001f); + } + + @Test + public void testAngleBetween2() { + final Vector3f target = new Vector3f(-0.779272f, -2.08408e+38f, 5.33333f); + final Vector3f otherVector = new Vector3f(4.50029e-39f, -1.7432f, 0.09375f); + + assertEquals(0.0f, target.angleBetween(otherVector), 0.0f); + } + + @Test + public void testAngleBetween3() { + final Vector3f target = new Vector3f(-8.57f, 5.93f, 5.33f); + final Vector3f otherVector = new Vector3f(6.59f, -2.04f, -0.09f); + + assertEquals(3.141f, target.angleBetween(otherVector), 0.01f); + } + + @Test + public void testAngleBetween4() { + final Vector3f target = new Vector3f(0.0f, -1.0f, 0.0f); + final Vector3f otherVector = new Vector3f(1.0f, 0.0f, 0.0f); + + assertEquals(1.57f, target.angleBetween(otherVector), 0.01f); + } + + @Test + public void testCross() { + final Vector3f target = new Vector3f(-1.55f, 2.07f, -0.0f); + final Vector3f v = new Vector3f(4.39f, 1.11f, 0.0f); + final Vector3f result = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = target.cross(v, result); + + assertEquals(retval, result); + + assertNotNull(result); + assertEquals(0.0f, result.x, 0.0f); + assertEquals(0.0f, result.y, 0.0f); + assertEquals(-10.807f, result.z, 0.01f); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(-10.807f, retval.z, 0.01f); + } + + @Test + public void testCross2() { + final Vector3f target = new Vector3f(Float.NaN, 0.042f, 1.76f); + final Vector3f v = new Vector3f(0.0012f, 7.64f, 4.50f); + + final Vector3f retval = target.cross(v); + + assertNotNull(retval); + assertEquals(-13.257f, retval.x, 0.001f); + assertEquals(Float.NaN, retval.y, 0.0f); + assertEquals(Float.NaN, retval.z, 0.0f); + } + + @Test + public void testCross3() { + final Vector3f target = new Vector3f(7.814f, 2.570f, 1.320f); + final Vector3f result = new Vector3f(0.0f, 0.0f, 0.0f); + + final Vector3f retval = target.cross(1.607f, -6.762f, -0.007f, result); + + assertEquals(result, retval); + + assertNotNull(retval); + assertEquals(8.90785f, retval.x, 0.0001f); + assertEquals(2.17593f, retval.y, 0.0001f); + assertEquals(-56.96825f, retval.z, 0.0001f); + } + + @Test + public void testCrossLocal() { + final Vector3f target = new Vector3f(-1.80144e+16f, 0.0f, 8.4323e+06f); + final Vector3f v = new Vector3f(8.9407e-08f, 0.0f, -1.05324e-35f); + + final Vector3f retval = target.crossLocal(v); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(-0.0f, retval.x, 0.0f); + assertEquals(0.753f, retval.y, 0.01f); + assertEquals(-0.0f, retval.z, 0.0f); + } + + @Test + public void testDistance() { + final Vector3f target = new Vector3f(3.86405e+18f, 3.02146e+23f, 0.171875f); + final Vector3f v = new Vector3f(-2.0f, -1.61503e+19f, 0.171875f); + + assertEquals(Float.POSITIVE_INFINITY, target.distance(v), 0.0f); + } + + @Test + public void testDistance2() { + final Vector3f target = new Vector3f(5.0f, 4.0f, 6.0f); + final Vector3f v = new Vector3f(-2.0f, -7.0f, 0.5f); + + assertEquals(14.150971f, target.distance(v), 0.0f); + } + + @Test + public void testDivide_byVector() { + final Vector3f target = new Vector3f(0.0f, 8.63998e+37f, 3.23117e-27f); + final Vector3f divideBy = new Vector3f(0.0f, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY); + + final Vector3f retval = target.divide(divideBy); + + assertNotNull(retval); + assertEquals(Float.NaN, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testDivide_byScalar() { + final Vector3f target = new Vector3f(2e+28f, 7e+19f, 3.e+23f); + + final Vector3f retval = target.divide(0.0f); + + assertNotNull(retval); + assertEquals(Float.POSITIVE_INFINITY, retval.x, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.y, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.z, 0.0f); + } + + @Test + public void testDivide_byScalar2() { + final Vector3f target = new Vector3f(1.98f, 7.43f, 9.61f); + + final Vector3f retval = target.divide(3.5f); + + assertNotNull(retval); + assertEquals(0.5657f, retval.x, 0.001f); + assertEquals(2.1228f, retval.y, 0.001f); + assertEquals(2.7457f, retval.z, 0.001f); + } + + @Test + public void testDivideLocal_byScalar() { + final Vector3f target = new Vector3f(1.98f, 7.43f, 9.61f); + + final Vector3f retval = target.divideLocal(3.5f); + + assertNotNull(retval); + assertEquals(0.5657f, retval.x, 0.001f); + assertEquals(2.1228f, retval.y, 0.001f); + assertEquals(2.7457f, retval.z, 0.001f); + } + + @Test + public void testDivideLocal2_byVector() { + final Vector3f target = new Vector3f(1.98f, 7.43f, 9.61f); + + final Vector3f retval = target.divideLocal(new Vector3f(1.2f, 2.5f, 6.3f)); + + assertNotNull(retval); + assertEquals(1.65f, retval.x, 0.001f); + assertEquals(2.972f, retval.y, 0.001f); + assertEquals(1.5253967f, retval.z, 0.001f); + } + + @Test + public void testGenerateComplementBasis() { + final Vector3f u = new Vector3f(); + final Vector3f v = new Vector3f(); + final Vector3f w = new Vector3f(-7.0f, Float.NaN, Float.NaN); + + Vector3f.generateComplementBasis(u, v, w); + + assertNotNull(v); + assertEquals(Float.NaN, v.x, 0.0f); + assertEquals(Float.NaN, v.y, 0.0f); + assertEquals(Float.NaN, v.z, 0.0f); + assertNotNull(u); + assertEquals(0.0f, u.x, 0.0f); + assertEquals(Float.NaN, u.y, 0.0f); + assertEquals(Float.NaN, u.z, 0.0f); + } + + @Test + public void testGenerateComplementBasis2() { + final Vector3f u = new Vector3f(); + final Vector3f v = new Vector3f(); + final Vector3f w = new Vector3f(-7.0f, 1.075f, Float.NaN); + + Vector3f.generateComplementBasis(u, v, w); + + assertNotNull(v); + assertEquals(Float.NaN, v.x, 0.0f); + assertEquals(Float.NaN, v.y, 0.0f); + assertEquals(Float.NaN, v.z, 0.0f); + assertNotNull(u); + assertEquals(Float.NaN, u.x, 0.0f); + assertEquals(0.0f, u.y, 0.0f); + assertEquals(Float.NaN, u.z, 0.0f); + } + + @Test + public void testGenerateComplementBasis3() { + final Vector3f u = new Vector3f(); + final Vector3f v = new Vector3f(); + final Vector3f w = new Vector3f(-7.0f, 1.075f, 4.3f); + + Vector3f.generateComplementBasis(u, v, w); + + assertNotNull(v); + assertEquals(-0.9159, v.x, 0.001f); + assertEquals(-8.2152, v.y, 0.001f); + assertEquals(0.5626, v.z, 0.001f); + assertNotNull(u); + assertEquals(-0.5234f, u.x, 0.001f); + assertEquals(0.0f, u.y, 0.0f); + assertEquals(-0.8520f, u.z, 0.001f); + } + + @Test + public void testGenerateOrthonormalBasis() { + final Vector3f u = new Vector3f(); + final Vector3f v = new Vector3f(); + final Vector3f w = new Vector3f(1.6e-37f, -2.24e-44f, -2.08e-36f); + + Vector3f.generateOrthonormalBasis(u, v, w); + + assertNotNull(v); + assertEquals(Float.NEGATIVE_INFINITY, v.x, 0.0f); + assertEquals(Float.NEGATIVE_INFINITY, v.y, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, v.z, 0.0f); + assertNotNull(u); + assertEquals(Float.POSITIVE_INFINITY, u.x, 0.0f); + assertEquals(0.0f, u.y, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, u.z, 0.0f); + } + + @Test + public void testGenerateOrthonormalBasis2() { + final Vector3f u = new Vector3f(); + final Vector3f v = new Vector3f(); + final Vector3f w = new Vector3f(2e+20f, -5e-20f, -14e+20f); + + Vector3f.generateOrthonormalBasis(u, v, w); + + assertNotNull(v); + assertEquals(Float.NaN, v.x, 0.0f); + assertEquals(Float.NaN, v.y, 0.0f); + assertEquals(Float.NaN, v.z, 0.0f); + assertNotNull(u); + assertEquals(Float.NaN, u.x, 0.0f); + assertEquals(0.0f, u.y, 0.0f); + assertEquals(Float.NaN, u.z, 0.0f); + assertNotNull(w); + assertEquals(0.0f, w.x, 0.0f); + assertEquals(-0.0f, w.y, 0.0f); + assertEquals(-0.0f, w.z, 0.0f); + } + + @Test + public void testGenerateOrthonormalBasis3() { + final Vector3f u = new Vector3f(); + final Vector3f v = new Vector3f(); + final Vector3f w = new Vector3f(-1.24672e-39f, -1.25343e-39f, -2.08336e-36f); + + Vector3f.generateOrthonormalBasis(u, v, w); + + assertNotNull(v); + assertEquals(Float.NEGATIVE_INFINITY, v.x, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, v.y, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, v.z, 0.0f); + assertNotNull(u); + assertEquals(0.0f, u.x, 0.0f); + assertEquals(Float.NEGATIVE_INFINITY, u.y, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, u.z, 0.0f); + } + + @Test + public void testGenerateOrthonormalBasis4() { + final Vector3f u = new Vector3f(); + final Vector3f v = new Vector3f(); + final Vector3f w = new Vector3f(-7.0f, 1.075f, 4.3f); + + Vector3f.generateOrthonormalBasis(u, v, w); + + assertNotNull(v); + assertEquals(-0.1105, v.x, 0.001f); + assertEquals(-0.9915, v.y, 0.001f); + assertEquals(0.0679, v.z, 0.001f); + assertNotNull(u); + assertEquals(-0.5234f, u.x, 0.001f); + assertEquals(0.0f, u.y, 0.0f); + assertEquals(-0.8520f, u.z, 0.001f); + } + + @Test + public void testGet_illegalArgumentException() { + thrown.expect(IllegalArgumentException.class); + new Vector3f(0.0f, 0.0f, 0.0f).get(536_870_914); + } + + @Test + public void testGet() { + final Vector3f target = new Vector3f(0.0f, 0.5f, 1.5f); + + assertEquals(0.0f, target.get(0), 0.0f); + assertEquals(0.5f, target.get(1), 0.0f); + assertEquals(1.5f, target.get(2), 0.0f); + } + + @Test + public void testInterpolateLocal() { + final Vector3f target = new Vector3f(); + final Vector3f beginVec = new Vector3f(0.0f, -9.094f, 0.0f); + final Vector3f finalVec = new Vector3f(-0.0f, 1.355f, 1.414f); + + final Vector3f retval = target.interpolateLocal(beginVec, finalVec, -4.056f); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(-51.475147f, retval.y, 0.01f); + assertEquals(-5.736f, retval.z, 0.001f); + } + + @Test + public void testInterpolateLocal2() { + final Vector3f target = new Vector3f(1.5f, 3.5f, 8.2f); + final Vector3f other = new Vector3f(5.0f, 1.5f, 2.0f); + + final Vector3f retval = target.interpolateLocal(other, 3.0f); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(12.0f, retval.x, 0.0f); + assertEquals(-2.5f, retval.y, 0.01f); + assertEquals(-10.4f, retval.z, 0.001f); + } + + @Test + public void testIsSimilar() { + final Vector3f target = new Vector3f(-1.14f, 8.50f, 1.88f); + final Vector3f other = new Vector3f(-1.52f, 8.50f, 3.76f); + assertTrue(target.isSimilar(other, 2.0f)); + + final Vector3f target_2 = new Vector3f(-1.14f, 8.50f, 1.88f); + final Vector3f other_2 = new Vector3f(-1.52f, 8.50f, 3.76f); + assertFalse(target_2.isSimilar(other_2, 0.0f)); + + final Vector3f target_3 = new Vector3f(-1.14f, 8.50f, 1.88f); + final Vector3f other_3 = null; + assertFalse(target_3.isSimilar(other_3, 0.0f)); + + final Vector3f target_4 = new Vector3f(-1.14f, -1.14f, 1.88f); + final Vector3f other_4 = new Vector3f(-1.52f, -1.52f, 3.76f); + assertFalse(target_4.isSimilar(other_4, 1.2f)); + + final Vector3f target_5 = new Vector3f(-1.14f, -1.14f, 1.88f); + final Vector3f other_5 = new Vector3f(-1.52f, -1.52f, 3.76f); + assertFalse(target_5.isSimilar(other_5, 1.2f)); + + final Vector3f target_6 = new Vector3f(-1.14f, -11.14f, 1.0f); + final Vector3f other_6 = new Vector3f(-1.1f, -1.52f, 1.0f); + assertFalse(target_6.isSimilar(other_6, 1.2f)); + } + + @Test + public void testIsUnitVector() { + assertFalse(new Vector3f(1.07f, 2.12f, 3.32f).isUnitVector()); + assertFalse(new Vector3f(1.07f, 2.12f, Float.NaN).isUnitVector()); + assertTrue(new Vector3f(1.0f, 0.0f, 0.0f).isUnitVector()); + assertTrue(new Vector3f(0.0f, 1.0f, 0.0f).isUnitVector()); + assertTrue(new Vector3f(0.0f, 0.0f, 1.0f).isUnitVector()); + assertTrue(new Vector3f(0.0f, 0.0f, -1.0f).isUnitVector()); + assertTrue(new Vector3f(-1.0f, 0.0f, 0.0f).isUnitVector()); + assertTrue(new Vector3f(0.0f, -1.0f, 0.0f).isUnitVector()); + } + + @Test + public void testIsValidVector() { + assertFalse(Vector3f.isValidVector(new Vector3f(Float.NaN, 2.1f, 3.0f))); + assertFalse(Vector3f.isValidVector(new Vector3f(Float.POSITIVE_INFINITY, 1.5f, 1.9f))); + assertFalse(Vector3f.isValidVector(new Vector3f(Float.NEGATIVE_INFINITY, 2.5f, 8.2f))); + assertFalse(Vector3f.isValidVector(null)); + + assertTrue(Vector3f.isValidVector(new Vector3f())); + assertTrue(Vector3f.isValidVector(new Vector3f(1.5f, 5.7f, 8.2f))); + } + + @Test + public void testLength() { + assertEquals(0.0f, new Vector3f(1.88079e-37f, 0.0f, 1.55077e-36f).length(), 0.0f); + assertEquals(Float.NaN, new Vector3f(Float.NaN, 0.0f, 1.55077e-36f).length(), 0.0f); + assertEquals(Float.POSITIVE_INFINITY, new Vector3f(Float.POSITIVE_INFINITY, 0.0f, 1.0f).length(), 0.0f); + assertEquals(4.0124f, new Vector3f(1.9f, 3.2f, 1.5f).length(), 0.001f); + assertEquals(Float.POSITIVE_INFINITY, new Vector3f(1.8e37f, 1.8e37f, 1.5e36f).length(), 0.0f); + } + + @Test + public void testMaxLocal() { + final Vector3f target = new Vector3f(); + + final Vector3f retval = target.maxLocal(new Vector3f(-0.0f, -0.0f, -0.0f)); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testMaxLocal2() { + final Vector3f target = new Vector3f(0.0f, 0.0f, -1.32931e+36f); + + final Vector3f retval = target.maxLocal(new Vector3f(-0.0f, -0.0f, 1.32923e+36f)); + + assertEquals(target, retval); + + assertEquals(1.32923e+36f, target.z, 0.0f); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(1.32923e+36f, retval.z, 0.0f); + } + + + @Test + public void testMaxLocal3() { + final Vector3f target = new Vector3f(0.0f, Float.NEGATIVE_INFINITY, -1.32931e+36f); + + final Vector3f retval = target.maxLocal(new Vector3f(-0.0f, Float.POSITIVE_INFINITY, 1.32923e+36f)); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.y, 0.0f); + assertEquals(1.32923e+36f, retval.z, 0.0f); + } + + + @Test + public void testMaxLocal4() { + final Vector3f target = new Vector3f(-2.24208e-44f, Float.NEGATIVE_INFINITY, -1.32f); + final Vector3f other = new Vector3f(0.0f, Float.POSITIVE_INFINITY, 1.35f); + + final Vector3f retval = target.maxLocal(other); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0f, retval.x, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.y, 0.0f); + assertEquals(1.35f, retval.z, 0.0f); + } + + @Test + public void testMinLocal() { + final Vector3f target = new Vector3f(0.0f, 0.0f, 0.0f); + final Vector3f other = new Vector3f(-0.0f, -0.0f, -0.0f); + + final Vector3f retval = target.minLocal(other); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testMinLocal2() { + final Vector3f target = new Vector3f(0.0f, 0.0f, Float.POSITIVE_INFINITY); + final Vector3f other = new Vector3f(-0.0f, -0.0f, -0.0f); + + final Vector3f retval = target.minLocal(other); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(-0.0f, retval.z, 0.0f); + } + + @Test + public void testMinLocal3() { + final Vector3f target = new Vector3f(0.0f, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY); + final Vector3f other = new Vector3f(-0.0f, Float.NEGATIVE_INFINITY, -0.0f); + + final Vector3f retval = target.minLocal(other); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(Float.NEGATIVE_INFINITY, retval.y, 0.0f); + assertEquals(-0.0f, retval.z, 0.0f); + } + + @Test + public void testMinLocal4() { + final Vector3f target = new Vector3f(1.43493e-42f, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY); + final Vector3f other = new Vector3f(-0.0f, Float.NEGATIVE_INFINITY, -0.0f); + + final Vector3f retval = target.minLocal(other); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(-0.0f, retval.x, 0.0f); + assertEquals(Float.NEGATIVE_INFINITY, retval.y, 0.0f); + assertEquals(-0.0f, retval.z, 0.0f); + } + + + @Test + public void testMult() { + final Vector3f target = new Vector3f(4.9e+27f, 3.1e-20f, 1.9e-31f); + final Vector3f vec = new Vector3f(0, 4.4e-29f, 0); + final Vector3f store = new Vector3f(); + + final Vector3f retval = target.mult(vec, store); + + assertNotNull(retval); + assertEquals(0, retval.x, 0.0f); + assertEquals(0, retval.y, 0.0f); + assertEquals(0, retval.z, 0.0f); + } + + @Test + public void testMult2() { + final Vector3f target = new Vector3f(1.12f, 1.21f, 0.0f); + final Vector3f vec = new Vector3f(1.09f, 5.87f, -5.2f); + + final Vector3f retval = target.mult(vec); + + assertNotNull(retval); + assertEquals(1.2208f, retval.x, 0.0f); + assertEquals(7.1027f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testMult3() { + final Vector3f target = new Vector3f(1.12f, 1.21f, 0.0f); + + assertNull(target.mult(null)); + } + + @Test + public void testMult4() { + final Vector3f target = new Vector3f(1.12f, 1.21f, 0.0f); + final Vector3f store = new Vector3f(); + + assertNull(target.mult(null, store)); + } + + @Test + public void testMult5() { + final Vector3f retval = new Vector3f(3.24f, 6.63f, 7.81f).mult(1.5f); + + assertNotNull(retval); + assertEquals(4.86f, retval.x, 0.0f); + assertEquals(9.945f, retval.y, 0.0f); + assertEquals(11.715f, retval.z, 0.0f); + } + + @Test + public void testMult6() { + final Vector3f product = new Vector3f(); + final Vector3f retval = new Vector3f(3.24f, 6.63f, 7.81f).mult(1.5f, product); + + assertEquals(product, retval); + + assertNotNull(retval); + assertEquals(4.86f, retval.x, 0.0f); + assertEquals(9.945f, retval.y, 0.0f); + assertEquals(11.715f, retval.z, 0.0f); + } + + @Test + public void testMult7() { + final Vector3f retval = new Vector3f(3.24f, 6.63f, 7.81f).mult(1.5f, null); + + assertNotNull(retval); + assertEquals(4.86f, retval.x, 0.0f); + assertEquals(9.945f, retval.y, 0.0f); + assertEquals(11.715f, retval.z, 0.0f); + } + + @Test + public void testMultLocal() { + final Vector3f target = new Vector3f(1.26f, 4.95f, 5.90f); + final Vector3f retval = target.multLocal(1.3f, 3.5f, 2.2f); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(1.6379999f, retval.x, 0.01f); + assertEquals(17.324999f, retval.y, 0.01f); + assertEquals(12.9800005f, retval.z, 0.01f); + } + + @Test + public void testMultLocal2() { + final Vector3f target = new Vector3f(1.26f, 4.95f, 5.90f); + final Vector3f retval = target.multLocal(new Vector3f(1.3f, 3.5f, 2.2f)); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(1.6379999f, retval.x, 0.01f); + assertEquals(17.324999f, retval.y, 0.01f); + assertEquals(12.9800005f, retval.z, 0.01f); + } + + @Test + public void testMultLocal3() { + final Vector3f target = new Vector3f(1.26f, 4.95f, 5.90f); + final Vector3f retval = target.multLocal(null); + + assertNull(retval); + } + + @Test + public void testNegate() { + final Vector3f target = new Vector3f(-1.0f, 2.0f, -0.0f); + final Vector3f retval = target.negate(); + + assertNotNull(retval); + assertEquals(1.0f, retval.x, 0.0f); + assertEquals(-2.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + + final Vector3f retval2 = retval.negate(); + + assertEquals(retval2, target); + } + + @Test + public void testNegate2() { + final Vector3f retval = new Vector3f(Float.NaN, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY).negate(); + + assertNotNull(retval); + assertEquals(Float.NaN, retval.x, 0.0f); + assertEquals(Float.NEGATIVE_INFINITY, retval.y, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.z, 0.0f); + } + + @Test + public void testNegateLocal() { + final Vector3f target = new Vector3f(-4.5f, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY); + final Vector3f retval = target.negateLocal(); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(4.5f, retval.x, 0.0f); + assertEquals(Float.NEGATIVE_INFINITY, retval.y, 0.0f); + assertEquals(Float.POSITIVE_INFINITY, retval.z, 0.0f); + } + + @Test + public void testNormalizeLocal() { + final Vector3f target = new Vector3f(6.9282f, Float.NaN, 4.694f); + + final Vector3f retval = target.normalizeLocal(); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(Float.NaN, retval.x, 0.0f); + assertEquals(Float.NaN, retval.y, 0.0f); + assertEquals(Float.NaN, retval.z, 0.0f); + } + + @Test + public void testNormalize() { + final Vector3f retval = new Vector3f(2.071f, 2.45f, 1.35f).normalize(); + + assertNotNull(retval); + assertEquals(0.5950255f, retval.x, 0.01f); + assertEquals(0.70391715f, retval.y, 0.0f); + assertEquals(0.3878727f, retval.z, 0.0f); + } + + @Test + public void testNormalize2() { + final Vector3f target = new Vector3f(1.0f, 0.0f, 0.0f); + final Vector3f retval = target.normalize(); + + assertNotNull(retval); + + assertEquals(retval, target); + + assertEquals(1.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testProject() { + final Vector3f target = new Vector3f(3.8e+15f, 2.1e-25f, 0.0f); + final Vector3f other = new Vector3f(2e-28f, -3.6e+12f, Float.POSITIVE_INFINITY); + + final Vector3f retval = target.project(other); + + assertNotNull(retval); + assertEquals(Float.NaN, retval.x, 0.0f); + assertEquals(Float.NaN, retval.y, 0.0f); + assertEquals(Float.NaN, retval.z, 0.0f); + } + + @Test + public void testProject2() { + final Vector3f target = new Vector3f(7.32f, 1.44f, 3.37f); + final Vector3f other = new Vector3f(9.12f, -3.64f, 5.19f); + + final Vector3f retval = target.project(other); + + assertNotNull(retval); + assertEquals(5.84f, retval.x, 0.01f); + assertEquals(-2.33f, retval.y, 0.01f); + assertEquals(3.32f, retval.z, 0.01f); + } + + @Test + public void testProjectLocal() { + final Vector3f target = new Vector3f(-2.9e+17f, 3.9e-34f, 3.8e+20f); + final Vector3f other = new Vector3f(5.4e-20f, -2.6e+36f, Float.NaN); + + final Vector3f retval = target.projectLocal(other); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(Float.NaN, retval.z, 0.0f); + assertEquals(Float.NaN, retval.x, 0.0f); + assertEquals(Float.NaN, retval.y, 0.0f); + } + + @Test + public void testProjectLocal2() { + final Vector3f target = new Vector3f(7.32f, 1.44f, 3.37f); + final Vector3f other = new Vector3f(9.12f, -3.64f, 5.19f); + + final Vector3f retval = target.projectLocal(other); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(5.8409867f, retval.x, 0.01f); + assertEquals(-2.331271f, retval.y, 0.01f); + assertEquals(3.3239825f, retval.z, 0.01f); + } + + @Test + public void testScaleAdd() { + final Vector3f target = new Vector3f(); + final Vector3f mult = new Vector3f(Float.POSITIVE_INFINITY, 5.60f, -1.74f); + final Vector3f add = new Vector3f(-0.0f, -0.0f, 3.79f); + + final Vector3f retval = target.scaleAdd(1.70f, mult, add); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(Float.POSITIVE_INFINITY, retval.x, 0.0f); + assertEquals(9.52f, retval.y, 0.0f); + assertEquals(0.8319998f, retval.z, 0.0f); + } + + @Test + public void testScaleAdd2() { + final Vector3f target = new Vector3f(4.86f, 6.10f, -1.74f); + final Vector3f add = new Vector3f(-0.16f, -0.51f, 1.03f); + + final Vector3f retval = target.scaleAdd(1.99f, add); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(9.5114f, retval.x, 0.001f); + assertEquals(11.629f, retval.y, 0.001f); + assertEquals(-2.4326f, retval.z, 0.001f); + } + + @Test + public void testSet_OutputIllegalArgumentException() { + thrown.expect(IllegalArgumentException.class); + new Vector3f(1.5f, 2.3f, 4.7f).set(5, 1.5f); + } + + @Test + public void testSet() { + Vector3f target = new Vector3f(0.0f, 0.0f, 0.0f); + target.set(0, 5.0f); + assertEquals(target.x, 5.0, 0.0f); + + target = new Vector3f(0.0f, 0.0f, 0.0f); + target.set(1, 3.0f); + assertEquals(target.y, 3.0, 0.0f); + + target = new Vector3f(0.0f, 0.0f, 0.0f); + target.set(2, 8.0f); + assertEquals(target.z, 8.0, 0.0f); + } + + @Test + public void testSetX() { + final Vector3f retval = new Vector3f(0.0f, 0.0f, 0.0f).setX(3.0f); + + assertNotNull(retval); + assertEquals(3.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testSetY() { + final Vector3f retval = new Vector3f(0.0f, 0.0f, 0.0f).setY(3.0f); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(3.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } + + @Test + public void testSetZ() { + final Vector3f retval = new Vector3f(0.0f, 0.0f, 0.0f).setZ(3.0f); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(3.0f, retval.z, 0.0f); + } + + @Test + public void testSubtract() { + final Vector3f retval = new Vector3f(12.0f, 8.0f, 5.0f).subtract(new Vector3f(7.0f, 4.0f, -2.0f)); + + assertNotNull(retval); + assertEquals(5.0f, retval.x, 0.0f); + assertEquals(4.0f, retval.y, 0.0f); + assertEquals(7.0f, retval.z, 0.0f); + } + + @Test + public void testSubtract2() { + final Vector3f target = new Vector3f(12.0f, 8.0f, 5.0f); + final Vector3f other = new Vector3f(); + final Vector3f retval = target.subtract(new Vector3f(7.0f, 4.0f, -2.0f), other); + + assertEquals(other, retval); + + assertNotNull(retval); + assertEquals(5.0f, retval.x, 0.0f); + assertEquals(4.0f, retval.y, 0.0f); + assertEquals(7.0f, retval.z, 0.0f); + } + + @Test + public void testSubtract3() { + final Vector3f other = null; + final Vector3f target = new Vector3f(12.0f, 8.0f, 5.0f); + final Vector3f retval = target.subtract(new Vector3f(7.0f, 4.0f, -2.0f), other); + + assertEquals(5.0f, retval.x, 0.0f); + assertEquals(4.0f, retval.y, 0.0f); + assertEquals(7.0f, retval.z, 0.0f); + } + + @Test + public void testSubtract4() { + final Vector3f target = new Vector3f(12.0f, 8.0f, 5.0f); + final Vector3f retval = target.subtract(7.0f, 4.0f, -2.0f); + + assertEquals(5.0f, retval.x, 0.0f); + assertEquals(4.0f, retval.y, 0.0f); + assertEquals(7.0f, retval.z, 0.0f); + } + + @Test + public void testSubtractLocal() { + final Vector3f target = new Vector3f(12.0f, 8.0f, 5.0f); + final Vector3f retval = target.subtractLocal(new Vector3f(7.0f, 4.0f, -2.0f)); + + assertEquals(target, retval); + + assertEquals(5.0f, retval.x, 0.0f); + assertEquals(4.0f, retval.y, 0.0f); + assertEquals(7.0f, retval.z, 0.0f); + } + + @Test + public void testSubtractLocal2() { + final Vector3f target = new Vector3f(12.0f, 8.0f, 5.0f); + final Vector3f retval = target.subtractLocal(7.0f, 4.0f, -2.0f); + + assertEquals(target, retval); + + assertEquals(5.0f, retval.x, 0.0f); + assertEquals(4.0f, retval.y, 0.0f); + assertEquals(7.0f, retval.z, 0.0f); + } + + @Test + public void testSubtractLocal3() { + final Vector3f target = new Vector3f(12.0f, 8.0f, 5.0f); + final Vector3f retval = target.subtractLocal(null); + + assertNull(retval); + } + + @Test + public void testToArray() { + final float[] store = {0.0f, 0.0f, 0.0f}; + final float[] retval = new Vector3f(1.0f, 2.0f, 3.0f).toArray(store); + assertEquals(store, retval); + assertArrayEquals(new float[] {1.0f, 2.0f, 3.0f}, retval, 0.0f); + + final float[] retval2 = new Vector3f(1.0f, 2.0f, 3.0f).toArray(new float[]{4.0f, 5.0f, 6.0f}); + assertArrayEquals(new float[] {1.0f, 2.0f, 3.0f}, retval2, 0.0f); + + final float[] retval3 = new Vector3f(1.0f, 2.0f, 3.0f).toArray(null); + assertArrayEquals(new float[] {1.0f, 2.0f, 3.0f}, retval3, 0.0f); + } + + @Test + public void testZero() { + final Vector3f target = new Vector3f(1.0f, 5.0f, 9.0f); + final Vector3f retval = target.zero(); + + assertEquals(target, retval); + + assertNotNull(retval); + assertEquals(0.0f, retval.x, 0.0f); + assertEquals(0.0f, retval.y, 0.0f); + assertEquals(0.0f, retval.z, 0.0f); + } +} diff --git a/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java b/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java index 0d29ad8697..72fb43580e 100644 --- a/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java +++ b/jme3-core/src/test/java/com/jme3/renderer/OpaqueComparatorTest.java @@ -51,7 +51,6 @@ import java.util.HashSet; import java.util.Set; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; public class OpaqueComparatorTest { diff --git a/jme3-core/src/test/java/com/jme3/scene/SceneGraphTraversalTest.java b/jme3-core/src/test/java/com/jme3/scene/SceneGraphTraversalTest.java new file mode 100644 index 0000000000..6327df4881 --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/scene/SceneGraphTraversalTest.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.jme3.scene; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import org.junit.Test; + +/** + * Tests for traversal order when using SceneGraphVisitor + * with Spatial.depthFirstTraversal() and Spatial.breadthFirstTraversal(). + * + * Related: Pull Request #1012 at GitHub + * + * @author 1000ml/FennelFetish (https://github.com/FennelFetish) + */ +public class SceneGraphTraversalTest { + + private static Node buildTestSceneGraph() { + Node root = new Node("Root"); + + Node n1 = new Node("N1"); + Node n11 = new Node("N11"); + Node n111 = new Node("N111"); + Geometry g112 = new Geometry("G112"); + + Node n2 = new Node("N2"); + Node n21 = new Node("N21"); + Node n211 = new Node("N211"); + Geometry g212 = new Geometry("G212"); + + root.attachChild(n1); + n1.attachChild(n11); + n11.attachChild(n111); + n11.attachChild(g112); + + root.attachChild(n2); + n2.attachChild(n21); + n21.attachChild(n211); + n21.attachChild(g212); + + /* Graph: + Root + N1 + N11 + N111 + G112 + N2 + N21 + N211 + G212 + */ + + return root; + } + + + private static final List EXPECTED_ORDER_DFS_PRE; + private static final List EXPECTED_ORDER_DFS_POST; + private static final List EXPECTED_ORDER_BFS; + + static { + List expectedDfsPre = new ArrayList<>(); + expectedDfsPre.add("Root"); + expectedDfsPre.add("N1"); + expectedDfsPre.add("N11"); + expectedDfsPre.add("N111"); + expectedDfsPre.add("G112"); + expectedDfsPre.add("N2"); + expectedDfsPre.add("N21"); + expectedDfsPre.add("N211"); + expectedDfsPre.add("G212"); + EXPECTED_ORDER_DFS_PRE = Collections.unmodifiableList(expectedDfsPre); + + List expectedDfsPost = new ArrayList<>(); + expectedDfsPost.add("N111"); + expectedDfsPost.add("G112"); + expectedDfsPost.add("N11"); + expectedDfsPost.add("N1"); + expectedDfsPost.add("N211"); + expectedDfsPost.add("G212"); + expectedDfsPost.add("N21"); + expectedDfsPost.add("N2"); + expectedDfsPost.add("Root"); + EXPECTED_ORDER_DFS_POST = Collections.unmodifiableList(expectedDfsPost); + + List expectedBfs = new ArrayList<>(); + expectedBfs.add("Root"); + expectedBfs.add("N1"); + expectedBfs.add("N2"); + expectedBfs.add("N11"); + expectedBfs.add("N21"); + expectedBfs.add("N111"); + expectedBfs.add("G112"); + expectedBfs.add("N211"); + expectedBfs.add("G212"); + EXPECTED_ORDER_BFS = Collections.unmodifiableList(expectedBfs); + } + + + private static class NameListVisitor implements SceneGraphVisitor { + private final List namesInOrder = new ArrayList<>(); + + @Override + public void visit(Spatial spatial) { + namesInOrder.add(spatial.getName()); + } + } + + + @Test + public void testDFSPreOrder() { + NameListVisitor visitor = new NameListVisitor(); + buildTestSceneGraph().depthFirstTraversal(visitor, Spatial.DFSMode.PRE_ORDER); + + assertThat(visitor.namesInOrder, is(EXPECTED_ORDER_DFS_PRE)); + } + + @Test + public void testDFSPostOrder() { + NameListVisitor visitor = new NameListVisitor(); + buildTestSceneGraph().depthFirstTraversal(visitor, Spatial.DFSMode.POST_ORDER); + + assertThat(visitor.namesInOrder, is(EXPECTED_ORDER_DFS_POST)); + } + + @Test + public void testDFSDefaultOrder() { + NameListVisitor visitor = new NameListVisitor(); + buildTestSceneGraph().depthFirstTraversal(visitor); + + assertThat(visitor.namesInOrder, is(EXPECTED_ORDER_DFS_POST)); + } + + @Test + public void testBFS() { + NameListVisitor visitor = new NameListVisitor(); + buildTestSceneGraph().breadthFirstTraversal(visitor); + + assertThat(visitor.namesInOrder, is(EXPECTED_ORDER_BFS)); + } +} diff --git a/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java b/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java index a615d5c928..fb8a60aa7f 100644 --- a/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java +++ b/jme3-core/src/test/java/com/jme3/scene/SceneMatParamOverrideTest.java @@ -40,7 +40,6 @@ import static org.junit.Assert.*; import com.jme3.system.TestUtil; -import java.util.ArrayList; import java.util.List; /** diff --git a/jme3-core/src/test/java/com/jme3/scene/TestIssue954.java b/jme3-core/src/test/java/com/jme3/scene/TestIssue954.java new file mode 100644 index 0000000000..6b94da6641 --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/scene/TestIssue954.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.scene; + +import org.junit.Test; + +/** + * Verify that an empty Node gets a valid bounding volume. This was issue #954 + * at GitHub. + * + * @author Stephen Gold + */ +public class TestIssue954 { + + Node rootNode; + + @Test + public void testIssue954() { + rootNode = new Node(); + rootNode.updateLogicalState(0.01f); + rootNode.updateGeometricState(); + assert rootNode.worldBound != null; + } +} diff --git a/jme3-core/src/test/java/com/jme3/scene/TestUserData.java b/jme3-core/src/test/java/com/jme3/scene/TestUserData.java new file mode 100644 index 0000000000..c228af8926 --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/scene/TestUserData.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.scene; + +import junit.framework.TestCase; +import org.junit.Test; + +public class TestUserData extends TestCase { + + public static void userDataTest(Spatial sp, Object v) { + sp.setUserData("test", v); + assertTrue("UserData is null", sp.getUserData("test") != null); + assertEquals("UserData value is different than input value", sp.getUserData("test"), v); + sp.setUserData("test", null); + } + + @Test + public void testLong() throws Exception { + Spatial sp = new Node("TestSpatial"); + userDataTest(sp, (Long) (long) (Math.random() * Long.MAX_VALUE)); + } + + @Test + public void testInt() throws Exception { + Spatial sp = new Node("TestSpatial"); + userDataTest(sp, (Integer) (int) (Math.random() * Integer.MAX_VALUE)); + } + + @Test + public void testShort() throws Exception { + Spatial sp = new Node("TestSpatial"); + userDataTest(sp, (Short) (short) (Math.random() * Short.MAX_VALUE)); + } + + @Test + public void testByte() throws Exception { + Spatial sp = new Node("TestSpatial"); + userDataTest(sp, (Byte) (byte) (Math.random() * Byte.MAX_VALUE)); + } + + @Test + public void testDouble() throws Exception { + Spatial sp = new Node("TestSpatial"); + userDataTest(sp, (Double) (double) (Math.random() * Double.MAX_VALUE)); + } + + @Test + public void testFloat() throws Exception { + Spatial sp = new Node("TestSpatial"); + userDataTest(sp, (Float) (float) (Math.random() * Float.MAX_VALUE)); + } +} diff --git a/jme3-core/src/test/java/com/jme3/scene/mesh/VirtualIndexBufferTest.java b/jme3-core/src/test/java/com/jme3/scene/mesh/VirtualIndexBufferTest.java new file mode 100644 index 0000000000..85759a525a --- /dev/null +++ b/jme3-core/src/test/java/com/jme3/scene/mesh/VirtualIndexBufferTest.java @@ -0,0 +1,203 @@ +package com.jme3.scene.mesh; + +import com.jme3.scene.Mesh.Mode; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.nio.IntBuffer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertArrayEquals; + +public class VirtualIndexBufferTest { + + @Rule public ExpectedException thrown = ExpectedException.none(); + + @Test + public void testHybrid() { + thrown.expect(UnsupportedOperationException.class); + new VirtualIndexBuffer(8, Mode.Hybrid); + } + + @Test + public void testRemaining() { + final VirtualIndexBuffer bufferPoints = new VirtualIndexBuffer(8, Mode.Points); + assertEquals(8, bufferPoints.remaining()); + bufferPoints.get(); + assertEquals(7, bufferPoints.remaining()); + + final VirtualIndexBuffer bufferLineLoop = new VirtualIndexBuffer(8, Mode.LineLoop); + assertEquals(15, bufferLineLoop.remaining()); + + final VirtualIndexBuffer bufferLineStrip = new VirtualIndexBuffer(8, Mode.LineStrip); + assertEquals(14, bufferLineStrip.remaining()); + + final VirtualIndexBuffer bufferLines = new VirtualIndexBuffer(8, Mode.Lines); + assertEquals(8, bufferLines.remaining()); + + final VirtualIndexBuffer bufferTriangleFan = new VirtualIndexBuffer(8, Mode.TriangleFan); + assertEquals(18, bufferTriangleFan.remaining()); + + final VirtualIndexBuffer bufferTriangleStrip = new VirtualIndexBuffer(8, Mode.TriangleStrip); + assertEquals(18, bufferTriangleStrip.remaining()); + + final VirtualIndexBuffer bufferTriangles = new VirtualIndexBuffer(8, Mode.Triangles); + assertEquals(8, bufferTriangles.remaining()); + + final VirtualIndexBuffer bufferPatch = new VirtualIndexBuffer(8, Mode.Patch); + assertEquals(0, bufferPatch.remaining()); + } + + @Test + public void testRewind() { + final VirtualIndexBuffer buffer = new VirtualIndexBuffer(5, Mode.Points); + + assertEquals(5, buffer.remaining()); + buffer.get(); + assertEquals(4, buffer.remaining()); + buffer.rewind(); + assertEquals(5, buffer.remaining()); + } + + @Test + public void testGet() { + IntBuffer ib = IntBuffer.allocate(27); + + final VirtualIndexBuffer bufferPoints = new VirtualIndexBuffer(27, Mode.Points); + for (int i=0; i<27; i++) {ib.put(bufferPoints.get());} + assertArrayEquals(new int[]{ + 0, 1, 2, + 3, 4, 5, + 6, 7, 8, + 9, 10, 11, + 12, 13, 14, + 15, 16, 17, + 18, 19, 20, + 21, 22, 23, + 24, 25, 26}, ib.array()); + ib.clear(); + assertEquals(0, bufferPoints.remaining()); + + final VirtualIndexBuffer bufferLines = new VirtualIndexBuffer(27, Mode.Lines); + for (int i=0; i<27; i++) {ib.put(bufferLines.get());} + assertArrayEquals(new int[]{ + 0, 1, 2, + 3, 4, 5, + 6, 7, 8, + 9, 10, 11, + 12, 13, 14, + 15, 16, 17, + 18, 19, 20, + 21, 22, 23, + 24, 25, 26}, ib.array()); + assertEquals(0, bufferLines.remaining()); + ib.clear(); + + final VirtualIndexBuffer bufferTriangles = new VirtualIndexBuffer(27, Mode.Triangles); + for (int i=0; i<27; i++) {ib.put(bufferTriangles.get());} + assertArrayEquals(new int[]{ + 0, 1, 2, + 3, 4, 5, + 6, 7, 8, + 9, 10, 11, + 12, 13, 14, + 15, 16, 17, + 18, 19, 20, + 21, 22, 23, + 24, 25, 26}, ib.array()); + assertEquals(0, bufferTriangles.remaining()); + ib.clear(); + + final VirtualIndexBuffer bufferLineStrip = new VirtualIndexBuffer(27, Mode.LineStrip); + for (int i=0; i<27; i++) {ib.put(bufferLineStrip.get());} + assertArrayEquals(new int[]{ + 0, 1, 1, + 2, 2, 3, + 3, 4, 4, + 5, 5, 6, + 6, 7, 7, + 8, 8, 9, + 9, 10, 10, + 11, 11, 12, + 12, 13, 13}, ib.array()); + assertEquals(25, bufferLineStrip.remaining()); + ib.clear(); + + final VirtualIndexBuffer bufferLineLoop = new VirtualIndexBuffer(27, Mode.LineLoop); + for (int i=0; i<27; i++) {ib.put(bufferLineLoop.get());} + assertArrayEquals(new int[]{ + 0, 1, 1, + 2, 2, 3, + 3, 4, 4, + 5, 5, 6, + 6, 7, 7, + 8, 8, 9, + 9, 10, 10, + 11, 11, 12, + 12, 13, 0}, ib.array()); + assertEquals(26, bufferLineLoop.remaining()); + ib.clear(); + + final VirtualIndexBuffer bufferTriangleStrip = new VirtualIndexBuffer(27, Mode.TriangleStrip); + for (int i=0; i<27; i++) {ib.put(bufferTriangleStrip.get());} + assertArrayEquals(new int[]{ + 0, 1, 2, + 2, 1, 3, + 2, 3, 4, + 4, 3, 5, + 4, 5, 6, + 6, 5, 7, + 6, 7, 8, + 8, 7, 9, + 8, 9, 10}, ib.array()); + assertEquals(48, bufferTriangleStrip.remaining()); + ib.clear(); + + final VirtualIndexBuffer bufferTriangleFan = new VirtualIndexBuffer(27, Mode.TriangleFan); + for (int i=0; i<27; i++) {ib.put(bufferTriangleFan.get());} + assertArrayEquals(new int[]{ + 0, 1, 2, + 0, 2, 3, + 0, 3, 4, + 0, 4, 5, + 0, 5, 6, + 0, 6, 7, + 0, 7, 8, + 0, 8, 9, + 0, 9, 10}, ib.array()); + assertEquals(48, bufferTriangleFan.remaining()); + ib.clear(); + } + + @Test + public void testGet_Patch() { + final VirtualIndexBuffer bufferPatch = new VirtualIndexBuffer(27, Mode.Patch); + thrown.expect(UnsupportedOperationException.class); + bufferPatch.get(); + } + + @Test + public void testSize() { + final VirtualIndexBuffer bufferTriangleFan = new VirtualIndexBuffer(5, Mode.TriangleFan); + assertEquals(9, bufferTriangleFan.size()); + + final VirtualIndexBuffer bufferLineLoop = new VirtualIndexBuffer(8, Mode.LineLoop); + assertEquals(15, bufferLineLoop.size()); + + final VirtualIndexBuffer bufferPoints = new VirtualIndexBuffer(8, Mode.Points); + assertEquals(8, bufferPoints.size()); + + final VirtualIndexBuffer bufferLines = new VirtualIndexBuffer(8, Mode.Lines); + assertEquals(8, bufferLines.size()); + + final VirtualIndexBuffer bufferLineStrip = new VirtualIndexBuffer(8, Mode.LineStrip); + assertEquals(14, bufferLineStrip.size()); + + final VirtualIndexBuffer bufferTriangles = new VirtualIndexBuffer(8, Mode.Triangles); + assertEquals(8, bufferTriangles.size()); + + final VirtualIndexBuffer bufferTriangleStrip = new VirtualIndexBuffer(8, Mode.TriangleStrip); + assertEquals(18, bufferTriangleStrip.size()); + } +} diff --git a/jme3-core/src/tools/java/jme3tools/shadercheck/Validator.java b/jme3-core/src/tools/java/jme3tools/shadercheck/Validator.java index cbfc339da7..a3574ca572 100644 --- a/jme3-core/src/tools/java/jme3tools/shadercheck/Validator.java +++ b/jme3-core/src/tools/java/jme3tools/shadercheck/Validator.java @@ -18,14 +18,15 @@ public interface Validator { public boolean isInstalled(); /** - * Returns the tool version as a string, must return null if the tool + * @return the tool version as a String, must return null if the tool * is not installed. */ public String getInstalledVersion(); /** * Validates the given shader to make sure it follows all requirements - * of the shader language specified as {@link Shader#getLanguage() }. + * of the shader language specified as + * {@link com.jme3.shader.Shader.ShaderSource#getLanguage()}. * The results of the validation will be written into the * results argument. * diff --git a/jme3-desktop/build.gradle b/jme3-desktop/build.gradle index 0a77d7d720..60d0a831d8 100644 --- a/jme3-desktop/build.gradle +++ b/jme3-desktop/build.gradle @@ -4,4 +4,4 @@ if (!hasProperty('mainClass')) { dependencies { compile project(':jme3-core') -} +} \ No newline at end of file diff --git a/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java b/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java index 159bd95ac3..3765c1f809 100644 --- a/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java +++ b/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -78,7 +78,7 @@ private void createCanvas(){ } catch (IOException ex){ // Called before application has been created .... // Display error message through AWT - JOptionPane.showMessageDialog(this, "An error has occured while " + JOptionPane.showMessageDialog(this, "An error has occurred while " + "loading applet configuration" + ex.getMessage(), "jME3 Applet", diff --git a/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java b/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java index e2d64c8b9a..15e7aa76c2 100644 --- a/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java +++ b/jme3-desktop/src/main/java/com/jme3/app/SettingsDialog.java @@ -442,6 +442,12 @@ public void actionPerformed(ActionEvent e) { if (verifyAndSaveCurrentSelection()) { setUserSelection(APPROVE_SELECTION); dispose(); + + // System.gc() should be called to prevent "X Error of failed request: RenderBadPicture (invalid Picture parameter)" + // on Linux when using AWT/Swing + GLFW. + // For more info see: https://github.com/LWJGL/lwjgl3/issues/149, https://hub.jmonkeyengine.org/t/experimenting-lwjgl3/37275 + System.gc(); + System.gc(); } } }); diff --git a/jme3-desktop/src/main/java/com/jme3/app/state/AWTComponentAppState.java b/jme3-desktop/src/main/java/com/jme3/app/state/AWTComponentAppState.java new file mode 100644 index 0000000000..4a24f04958 --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/app/state/AWTComponentAppState.java @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.app.state; + +import java.awt.Component; + +import com.jme3.app.Application; +import com.jme3.app.state.AbstractAppState; +import com.jme3.app.state.AppStateManager; +import com.jme3.system.AWTFrameProcessor; +import com.jme3.system.AWTTaskExecutor; + +/** + * An app state dedicated to the rendering of a JMonkey application within an AWT component. + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + */ +public class AWTComponentAppState extends AbstractAppState { + + private final AWTTaskExecutor executor = AWTTaskExecutor.getInstance(); + + private Component component = null; + + private AWTFrameProcessor processor = null; + + private AWTFrameProcessor.TransferMode transferMode = AWTFrameProcessor.TransferMode.ON_CHANGES; + + @Override + public void initialize(AppStateManager stateManager, Application app) { + super.initialize(stateManager, app); + } + + @Override + public void stateAttached(final AppStateManager stateManager) { + processor = new AWTFrameProcessor(); + processor.setTransferMode(transferMode); + + AWTTaskExecutor.getInstance().addToExecute(new Runnable() { + + @Override + public void run() { + processor.bind(component, stateManager.getApplication(), stateManager.getApplication().getViewPort()); + } + + }); + } + + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + } + + @Override + public void update(float tpf) { + executor.execute(); + super.update(tpf); + } + + @Override + public void cleanup() { + super.cleanup(); + } + + /** + * Create a new app state dedicated to the rendering of a JMonkey application within the given AWT component. + * @param component the component that is used as rendering output. + */ + public AWTComponentAppState(Component component) { + this.component = component; + } + + /** + * Get the AWT component that is used as rendering output. + * @return the AWT component that is used as rendering output. + * @see #setComponent(Component) + */ + public Component getComponent() { + return component; + } + + /** + * Set the AWT component that is used as rendering output. + * @param component the AWT component that is used as rendering output. + * @see #getComponent() + */ + public void setComponent(Component component) { + this.component = component; + } + + /** + * Get the {@link com.jme3.system.AWTFrameProcessor.TransferMode transfer mode} that is used by the underlying frame processor. + * @return the {@link com.jme3.system.AWTFrameProcessor.TransferMode transfer mode} that is used by the underlying frame processor. + * @see #setTransferMode(com.jme3.system.AWTFrameProcessor.TransferMode) + */ + public AWTFrameProcessor.TransferMode getTransferMode(){ + return transferMode; + } + + /** + * Set the {@link com.jme3.system.AWTFrameProcessor.TransferMode transfer mode} that is used by the underlying frame processor. + * @param mode the {@link com.jme3.system.AWTFrameProcessor.TransferMode transfer mode} that is used by the underlying frame processor. + * @see #getTransferMode() + */ + public void setTransferMode(AWTFrameProcessor.TransferMode mode) { + this.transferMode = mode; + } +} diff --git a/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java b/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java index 90b9e98cf6..eb4abe4cdc 100644 --- a/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java +++ b/jme3-desktop/src/main/java/com/jme3/app/state/VideoRecorderAppState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -120,7 +120,6 @@ public VideoRecorderAppState(File file) { * This constructor allows you to specify the output file of the video as well as the quality * @param file the video file * @param quality the quality of the jpegs in the video stream (0.0 smallest file - 1.0 largest file) - * @param framerate the frame rate of the resulting video, the application will be locked to this framerate */ public VideoRecorderAppState(File file, float quality) { this.file = file; diff --git a/jme3-desktop/src/main/java/com/jme3/input/AWTInput.java b/jme3-desktop/src/main/java/com/jme3/input/AWTInput.java new file mode 100644 index 0000000000..cceab1d6e3 --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/input/AWTInput.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.input; + +import java.awt.Component; +import java.util.Objects; + +import com.jme3.app.Application; +import com.jme3.input.Input; +import com.jme3.input.RawInputListener; +import com.jme3.system.AWTContext; +import com.jme3.system.AWTTaskExecutor; + +/** + * The implementation of the {@link Input} dedicated to AWT {@link Component component}. + *

        + * This class is based on the JavaFX original code provided by Alexander Brui (see JME3-FX) + *

        + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Alexander Brui (JavaSaBr) + */ +public class AWTInput implements Input { + + protected static final AWTTaskExecutor EXECUTOR = AWTTaskExecutor.getInstance(); + + /** + * The context. + */ + protected final AWTContext context; + + /** + * The raw listener. + */ + protected RawInputListener listener; + + /** + * The input node. + */ + protected Component component; + + /** + * The {@link Application JMonkey application} that provide the context. + */ + protected Application application; + + /** + * Initializes is it. + */ + protected boolean initialized; + + public AWTInput(final AWTContext context) { + this.context = context; + } + + public void bind(final Component component) { + this.component = component; + Objects.requireNonNull(this.component, "binded Component cannot be null"); + } + + public void unbind() { + this.component = null; + } + + @Override + public void initialize() { + if (isInitialized()) return; + initializeImpl(); + initialized = true; + } + + protected void initializeImpl() { + } + + @Override + public void update() { + if (!context.isRenderable()) return; + updateImpl(); + } + + protected void updateImpl() { + } + + @Override + public void destroy() { + unbind(); + } + + @Override + public boolean isInitialized() { + return initialized; + } + + @Override + public void setInputListener(RawInputListener listener) { + this.listener = listener; + } + + @Override + public long getInputTimeNanos() { + return System.nanoTime(); + } +} \ No newline at end of file diff --git a/jme3-desktop/src/main/java/com/jme3/input/AWTKeyInput.java b/jme3-desktop/src/main/java/com/jme3/input/AWTKeyInput.java new file mode 100644 index 0000000000..0280d8aedb --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/input/AWTKeyInput.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.input; + +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import com.jme3.input.KeyInput; +import com.jme3.input.event.KeyInputEvent; +import com.jme3.system.AWTContext; + + +/** + * The implementation of the {@link KeyInput} dedicated to AWT {@link Component component}. + *

        + * This class is based on the JavaFX original code provided by Alexander Brui (see JME3-FX) + *

        + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Alexander Brui (JavaSaBr) + */ +public class AWTKeyInput extends AWTInput implements KeyInput, KeyListener{ + + private static final Map KEY_CODE_TO_JME = new HashMap<>(); + + static { + KEY_CODE_TO_JME.put(KeyEvent.VK_ESCAPE, KEY_ESCAPE); + KEY_CODE_TO_JME.put(KeyEvent.VK_0, KEY_0); + KEY_CODE_TO_JME.put(KeyEvent.VK_1, KEY_1); + KEY_CODE_TO_JME.put(KeyEvent.VK_2, KEY_2); + KEY_CODE_TO_JME.put(KeyEvent.VK_3, KEY_3); + KEY_CODE_TO_JME.put(KeyEvent.VK_4, KEY_4); + KEY_CODE_TO_JME.put(KeyEvent.VK_5, KEY_5); + KEY_CODE_TO_JME.put(KeyEvent.VK_6, KEY_6); + KEY_CODE_TO_JME.put(KeyEvent.VK_7, KEY_7); + KEY_CODE_TO_JME.put(KeyEvent.VK_8, KEY_8); + KEY_CODE_TO_JME.put(KeyEvent.VK_9, KEY_9); + KEY_CODE_TO_JME.put(KeyEvent.VK_MINUS, KEY_MINUS); + KEY_CODE_TO_JME.put(KeyEvent.VK_EQUALS, KEY_EQUALS); + KEY_CODE_TO_JME.put(KeyEvent.VK_BACK_SPACE, KEY_BACK); + KEY_CODE_TO_JME.put(KeyEvent.VK_TAB, KEY_TAB); + KEY_CODE_TO_JME.put(KeyEvent.VK_Q, KEY_Q); + KEY_CODE_TO_JME.put(KeyEvent.VK_W, KEY_W); + KEY_CODE_TO_JME.put(KeyEvent.VK_E, KEY_E); + KEY_CODE_TO_JME.put(KeyEvent.VK_R, KEY_R); + KEY_CODE_TO_JME.put(KeyEvent.VK_T, KEY_T); + KEY_CODE_TO_JME.put(KeyEvent.VK_U, KEY_U); + KEY_CODE_TO_JME.put(KeyEvent.VK_I, KEY_I); + KEY_CODE_TO_JME.put(KeyEvent.VK_O, KEY_O); + KEY_CODE_TO_JME.put(KeyEvent.VK_P, KEY_P); + KEY_CODE_TO_JME.put(KeyEvent.VK_OPEN_BRACKET, KEY_LBRACKET); + KEY_CODE_TO_JME.put(KeyEvent.VK_CLOSE_BRACKET, KEY_RBRACKET); + KEY_CODE_TO_JME.put(KeyEvent.VK_ENTER, KEY_RETURN); + KEY_CODE_TO_JME.put(KeyEvent.VK_CONTROL, KEY_LCONTROL); + KEY_CODE_TO_JME.put(KeyEvent.VK_A, KEY_A); + KEY_CODE_TO_JME.put(KeyEvent.VK_S, KEY_S); + KEY_CODE_TO_JME.put(KeyEvent.VK_D, KEY_D); + KEY_CODE_TO_JME.put(KeyEvent.VK_F, KEY_F); + KEY_CODE_TO_JME.put(KeyEvent.VK_G, KEY_G); + KEY_CODE_TO_JME.put(KeyEvent.VK_H, KEY_H); + KEY_CODE_TO_JME.put(KeyEvent.VK_J, KEY_J); + KEY_CODE_TO_JME.put(KeyEvent.VK_Y, KEY_Y); + KEY_CODE_TO_JME.put(KeyEvent.VK_K, KEY_K); + KEY_CODE_TO_JME.put(KeyEvent.VK_L, KEY_L); + KEY_CODE_TO_JME.put(KeyEvent.VK_SEMICOLON, KEY_SEMICOLON); + KEY_CODE_TO_JME.put(KeyEvent.VK_QUOTE, KEY_APOSTROPHE); + KEY_CODE_TO_JME.put(KeyEvent.VK_DEAD_GRAVE, KEY_GRAVE); + KEY_CODE_TO_JME.put(KeyEvent.VK_SHIFT, KEY_LSHIFT); + KEY_CODE_TO_JME.put(KeyEvent.VK_BACK_SLASH, KEY_BACKSLASH); + KEY_CODE_TO_JME.put(KeyEvent.VK_Z, KEY_Z); + KEY_CODE_TO_JME.put(KeyEvent.VK_X, KEY_X); + KEY_CODE_TO_JME.put(KeyEvent.VK_C, KEY_C); + KEY_CODE_TO_JME.put(KeyEvent.VK_V, KEY_V); + KEY_CODE_TO_JME.put(KeyEvent.VK_B, KEY_B); + KEY_CODE_TO_JME.put(KeyEvent.VK_N, KEY_N); + KEY_CODE_TO_JME.put(KeyEvent.VK_M, KEY_M); + KEY_CODE_TO_JME.put(KeyEvent.VK_COMMA, KEY_COMMA); + KEY_CODE_TO_JME.put(KeyEvent.VK_PERIOD, KEY_PERIOD); + KEY_CODE_TO_JME.put(KeyEvent.VK_SLASH, KEY_SLASH); + KEY_CODE_TO_JME.put(KeyEvent.VK_MULTIPLY, KEY_MULTIPLY); + KEY_CODE_TO_JME.put(KeyEvent.VK_SPACE, KEY_SPACE); + KEY_CODE_TO_JME.put(KeyEvent.VK_CAPS_LOCK, KEY_CAPITAL); + KEY_CODE_TO_JME.put(KeyEvent.VK_F1, KEY_F1); + KEY_CODE_TO_JME.put(KeyEvent.VK_F2, KEY_F2); + KEY_CODE_TO_JME.put(KeyEvent.VK_F3, KEY_F3); + KEY_CODE_TO_JME.put(KeyEvent.VK_F4, KEY_F4); + KEY_CODE_TO_JME.put(KeyEvent.VK_F5, KEY_F5); + KEY_CODE_TO_JME.put(KeyEvent.VK_F6, KEY_F6); + KEY_CODE_TO_JME.put(KeyEvent.VK_F7, KEY_F7); + KEY_CODE_TO_JME.put(KeyEvent.VK_F8, KEY_F8); + KEY_CODE_TO_JME.put(KeyEvent.VK_F9, KEY_F9); + KEY_CODE_TO_JME.put(KeyEvent.VK_F10, KEY_F10); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUM_LOCK, KEY_NUMLOCK); + KEY_CODE_TO_JME.put(KeyEvent.VK_SCROLL_LOCK, KEY_SCROLL); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD7, KEY_NUMPAD7); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD8, KEY_NUMPAD8); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD9, KEY_NUMPAD9); + KEY_CODE_TO_JME.put(KeyEvent.VK_SUBTRACT, KEY_SUBTRACT); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD4, KEY_NUMPAD4); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD5, KEY_NUMPAD5); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD6, KEY_NUMPAD6); + KEY_CODE_TO_JME.put(KeyEvent.VK_ADD, KEY_ADD); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD1, KEY_NUMPAD1); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD2, KEY_NUMPAD2); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD3, KEY_NUMPAD3); + KEY_CODE_TO_JME.put(KeyEvent.VK_NUMPAD0, KEY_NUMPAD0); + KEY_CODE_TO_JME.put(KeyEvent.VK_DECIMAL, KEY_DECIMAL); + KEY_CODE_TO_JME.put(KeyEvent.VK_F11, KEY_F11); + KEY_CODE_TO_JME.put(KeyEvent.VK_F12, KEY_F12); + KEY_CODE_TO_JME.put(KeyEvent.VK_F13, KEY_F13); + KEY_CODE_TO_JME.put(KeyEvent.VK_F14, KEY_F14); + KEY_CODE_TO_JME.put(KeyEvent.VK_F15, KEY_F15); + KEY_CODE_TO_JME.put(KeyEvent.VK_KANA, KEY_KANA); + KEY_CODE_TO_JME.put(KeyEvent.VK_CONVERT, KEY_CONVERT); + KEY_CODE_TO_JME.put(KeyEvent.VK_NONCONVERT, KEY_NOCONVERT); + KEY_CODE_TO_JME.put(KeyEvent.VK_CIRCUMFLEX, KEY_CIRCUMFLEX); + KEY_CODE_TO_JME.put(KeyEvent.VK_AT, KEY_AT); + KEY_CODE_TO_JME.put(KeyEvent.VK_COLON, KEY_COLON); + KEY_CODE_TO_JME.put(KeyEvent.VK_UNDERSCORE, KEY_UNDERLINE); + KEY_CODE_TO_JME.put(KeyEvent.VK_STOP, KEY_STOP); + KEY_CODE_TO_JME.put(KeyEvent.VK_DIVIDE, KEY_DIVIDE); + KEY_CODE_TO_JME.put(KeyEvent.VK_PAUSE, KEY_PAUSE); + KEY_CODE_TO_JME.put(KeyEvent.VK_HOME, KEY_HOME); + KEY_CODE_TO_JME.put(KeyEvent.VK_UP, KEY_UP); + KEY_CODE_TO_JME.put(KeyEvent.VK_PAGE_UP, KEY_PRIOR); + KEY_CODE_TO_JME.put(KeyEvent.VK_LEFT, KEY_LEFT); + KEY_CODE_TO_JME.put(KeyEvent.VK_RIGHT, KEY_RIGHT); + KEY_CODE_TO_JME.put(KeyEvent.VK_END, KEY_END); + KEY_CODE_TO_JME.put(KeyEvent.VK_DOWN, KEY_DOWN); + KEY_CODE_TO_JME.put(KeyEvent.VK_PAGE_DOWN, KEY_NEXT); + KEY_CODE_TO_JME.put(KeyEvent.VK_INSERT, KEY_INSERT); + KEY_CODE_TO_JME.put(KeyEvent.VK_DELETE, KEY_DELETE); + KEY_CODE_TO_JME.put(KeyEvent.VK_ALT, KEY_LMENU); + KEY_CODE_TO_JME.put(KeyEvent.VK_META, KEY_RCONTROL); + } + + private final LinkedList keyInputEvents; + + public AWTKeyInput(AWTContext context) { + super(context); + keyInputEvents = new LinkedList(); + } + + @Override + public void bind(Component component) { + super.bind(component); + component.addKeyListener(this); + } + + @Override + public void unbind() { + if (component != null) { + component.removeKeyListener(this); + } + super.unbind(); + } + + private void onKeyEvent(KeyEvent keyEvent, boolean pressed) { + + int code = convertKeyCode(keyEvent.getID()); + char keyChar = keyEvent.getKeyChar(); + + final KeyInputEvent event = new KeyInputEvent(code, keyChar, pressed, false); + event.setTime(getInputTimeNanos()); + + EXECUTOR.addToExecute(new Runnable() { + + @Override + public void run() { + keyInputEvents.add(event); + } + + }); + } + + @Override + protected void updateImpl() { + while (!keyInputEvents.isEmpty()) { + listener.onKeyEvent(keyInputEvents.poll()); + } + } + + private int convertKeyCode(int keyCode) { + final Integer code = KEY_CODE_TO_JME.get(keyCode); + return code == null ? KEY_UNKNOWN : code; + } + + @Override + public void keyTyped(KeyEvent e) { + System.out.println("Key typed "+e.getKeyChar()); + //onKeyEvent(e, false); + } + + @Override + public void keyPressed(KeyEvent e) { + System.out.println("Key pressed "+e.getKeyChar()); + onKeyEvent(e, true); + } + + @Override + public void keyReleased(KeyEvent e) { + System.out.println("Key released "+e.getKeyChar()); + onKeyEvent(e, false); + } +} diff --git a/jme3-desktop/src/main/java/com/jme3/input/AWTMouseInput.java b/jme3-desktop/src/main/java/com/jme3/input/AWTMouseInput.java new file mode 100644 index 0000000000..72b75a5d38 --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/input/AWTMouseInput.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.input; + +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import com.jme3.cursors.plugins.JmeCursor; +import com.jme3.input.MouseInput; +import com.jme3.input.event.MouseButtonEvent; +import com.jme3.input.event.MouseMotionEvent; +import com.jme3.system.AWTContext; + +/** + * The implementation of the {@link MouseInput} dedicated to AWT {@link Component component}. + *

        + * This class is based on the JavaFX original code provided by Alexander Brui (see JME3-FX) + *

        + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Alexander Brui (JavaSaBr) + */ +public class AWTMouseInput extends AWTInput implements MouseInput, MouseListener, MouseMotionListener, MouseWheelListener { + + private static final Map MOUSE_BUTTON_TO_JME = new HashMap<>(); + + static { + MOUSE_BUTTON_TO_JME.put(MouseEvent.BUTTON1, BUTTON_LEFT); + MOUSE_BUTTON_TO_JME.put(MouseEvent.BUTTON2, BUTTON_RIGHT); + MOUSE_BUTTON_TO_JME.put(MouseEvent.BUTTON3, BUTTON_MIDDLE); + } + + /** + * The scale factor for scrolling. + */ + private static final int WHEEL_SCALE = 10; + + private final LinkedList mouseMotionEvents; + + private final LinkedList mouseButtonEvents; + + private int mouseX; + private int mouseY; + private int mouseWheel; + + public AWTMouseInput(AWTContext context) { + super(context); + mouseMotionEvents = new LinkedList(); + mouseButtonEvents = new LinkedList(); + } + + @Override + public void bind(Component component) { + super.bind(component); + component.addMouseListener(this); + component.addMouseMotionListener(this); + component.addMouseWheelListener(this); + } + + @Override + public void unbind() { + if (component != null) { + component.removeMouseListener(this); + component.removeMouseMotionListener(this); + component.removeMouseWheelListener(this); + } + super.unbind(); + } + + @Override + protected void updateImpl() { + while (!mouseMotionEvents.isEmpty()) { + listener.onMouseMotionEvent(mouseMotionEvents.poll()); + } + while (!mouseButtonEvents.isEmpty()) { + listener.onMouseButtonEvent(mouseButtonEvents.poll()); + } + } + + private void onWheelScroll(final double xOffset, final double yOffset) { + + mouseWheel += yOffset; + + final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(mouseX, mouseY, 0, 0, mouseWheel, (int) Math.round(yOffset)); + mouseMotionEvent.setTime(getInputTimeNanos()); + + EXECUTOR.addToExecute(new Runnable() { + + @Override + public void run() { + mouseMotionEvents.add(mouseMotionEvent); + } + + }); + } + + private void onCursorPos(double xpos, double ypos) { + + int xDelta; + int yDelta; + int x = (int) Math.round(xpos); + int y = context.getHeight() - (int) Math.round(ypos); + + if (mouseX == 0) mouseX = x; + if (mouseY == 0) mouseY = y; + + xDelta = x - mouseX; + yDelta = y - mouseY; + + mouseX = x; + mouseY = y; + + if (xDelta == 0 && yDelta == 0) return; + + final MouseMotionEvent mouseMotionEvent = new MouseMotionEvent(x, y, xDelta, yDelta, mouseWheel, 0); + mouseMotionEvent.setTime(getInputTimeNanos()); + + EXECUTOR.addToExecute(new Runnable() { + + @Override + public void run() { + mouseMotionEvents.add(mouseMotionEvent); + } + + }); + } + + private void onMouseButton(MouseEvent event, final boolean pressed) { + + final MouseButtonEvent mouseButtonEvent = new MouseButtonEvent(convertButton(event.getButton()), pressed, mouseX, mouseY); + mouseButtonEvent.setTime(getInputTimeNanos()); + + EXECUTOR.addToExecute(new Runnable() { + + @Override + public void run() { + mouseButtonEvents.add(mouseButtonEvent); + } + + }); + } + + private int convertButton(int i) { + final Integer result = MOUSE_BUTTON_TO_JME.get(i); + return result == null ? 0 : result; + } + + @Override + public void setCursorVisible(final boolean visible) { + } + + @Override + public int getButtonCount() { + return 3; + } + + @Override + public void setNativeCursor(JmeCursor cursor) { + } + + @Override + public void mouseDragged(java.awt.event.MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseMoved(java.awt.event.MouseEvent e) { + onCursorPos(e.getX(), e.getY()); + } + + @Override + public void mouseClicked(java.awt.event.MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(java.awt.event.MouseEvent e) { + onMouseButton(e, true); + } + + @Override + public void mouseReleased(java.awt.event.MouseEvent e) { + onMouseButton(e, false); + } + + @Override + public void mouseEntered(java.awt.event.MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(java.awt.event.MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + onWheelScroll(e.getWheelRotation() * WHEEL_SCALE, e.getWheelRotation() * WHEEL_SCALE); + } +} \ No newline at end of file diff --git a/jme3-desktop/src/main/java/com/jme3/system/AWTComponentRenderer.java b/jme3-desktop/src/main/java/com/jme3/system/AWTComponentRenderer.java new file mode 100644 index 0000000000..99e7456754 --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/system/AWTComponentRenderer.java @@ -0,0 +1,391 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.system; + +import java.awt.Component; +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferInt; +import java.awt.image.Raster; +import java.awt.image.SampleModel; +import java.awt.image.SinglePixelPackedSampleModel; +import java.awt.image.WritableRaster; +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicInteger; + +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.Renderer; +import com.jme3.system.AWTFrameProcessor.TransferMode; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image; +import com.jme3.util.BufferUtils; + + +/** + *

        + * This class enables to update graphics of an AWT component with the result of JMonkey 3D rendering. + *

        + *

        + * This class is based on the JavaFX original code provided by Alexander Brui (see JME3-FX) + *

        + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Alexander Brui (JavaSaBr) + * + */ +public class AWTComponentRenderer { + + /** + * The constant RUNNING_STATE. + */ + protected static final int RUNNING_STATE = 1; + /** + * The constant WAITING_STATE. + */ + protected static final int WAITING_STATE = 2; + /** + * The constant DISPOSING_STATE. + */ + protected static final int DISPOSING_STATE = 3; + /** + * The constant DISPOSED_STATE. + */ + protected static final int DISPOSED_STATE = 4; + + /** + * The Frame state. + */ + protected final AtomicInteger frameState; + + /** + * The Image state. + */ + protected final AtomicInteger imageState; + + /** + * The Frame buffer. + */ + protected final FrameBuffer frameBuffer; + + /** + * The Pixel writer. + */ + protected final Graphics pixelWriter; + + /** + * The Frame byte buffer. + */ + protected final ByteBuffer frameByteBuffer; + + + /** + * The transfer mode. + */ + protected final TransferMode transferMode; + + /** + * The byte buffer. + */ + protected final byte[] byteBuffer; + + /** + * The image byte buffer. + */ + protected final int[] imageByteBuffer; + + /** + * The prev image byte buffer. + */ + protected final byte[] prevImageByteBuffer; + + /** + * How many frames need to write else. + */ + protected int frameCount; + + /** + * The width. + */ + private final int width; + + /** + * The height. + */ + private final int height; + + private ColorModel colorModel = null; + + private Component component = null; + + private Graphics2D offGraphics = null; + + /** + * Create a new component renderer attached to the given {@link Component destination}. + * The graphics of the destination are updated with the JMonkeyEngine rendering result. + * @param destination the AWT component to use as target of the JMonkeyEngine rendering. + * @param width the width of the component in pixels. + * @param height the height of the component in pixels. + * @param transferMode the rendering mode that can be {@link TransferMode#ALWAYS} if the component has to be rendered at each update + * or {@link TransferMode#ON_CHANGES} if the component has to be rendered only when changes are occurring. + */ + public AWTComponentRenderer(Component destination, final int width, final int height, TransferMode transferMode) { + this(destination, transferMode, null, width, height); + } + + /** + * Create a new component renderer attached to the given {@link Component destination}. + * The graphics of the destination are updated with the JMonkeyEngine rendering result. + * @param destination the AWT component to use as target of the JMonkeyEngine rendering. + * @param transferMode the rendering mode that can be {@link TransferMode#ALWAYS} if the component has to be rendered at each update or {@link TransferMode#ON_CHANGES} if the component has to be rendered only when changes are occurring. + * @param frameBuffer the JMonkey frame buffer to use (if null is passed, a new default frame buffer is created) + * @param width the width of the component in pixels. + * @param height the height of the component in pixels. + */ + public AWTComponentRenderer(Component destination, TransferMode transferMode, FrameBuffer frameBuffer, int width, int height) { + this.transferMode = transferMode; + this.frameState = new AtomicInteger(WAITING_STATE); + this.imageState = new AtomicInteger(WAITING_STATE); + this.width = frameBuffer != null ? frameBuffer.getWidth() : width; + this.height = frameBuffer != null ? frameBuffer.getHeight() : height; + this.frameCount = 0; + + if (frameBuffer != null) { + this.frameBuffer = frameBuffer; + } else { + this.frameBuffer = new FrameBuffer(width, height, 1); + this.frameBuffer.setDepthBuffer(Image.Format.Depth); + this.frameBuffer.setColorBuffer(Image.Format.RGBA8); + this.frameBuffer.setSrgb(true); + } + + colorModel = ColorModel.getRGBdefault(); + + frameByteBuffer = BufferUtils.createByteBuffer(getWidth() * getHeight() * 4); + byteBuffer = new byte[getWidth() * getHeight() * 4]; + prevImageByteBuffer = new byte[getWidth() * getHeight() * 4]; + imageByteBuffer = new int[getWidth() * getHeight()]; + pixelWriter = getGraphics(destination); + + this.component = destination; + + } + + /** + * Initialize the component renderer. + * @param renderer the JMonkey {@link Renderer renderer} to use. + * @param main true if the attached frame buffer is the main one or false otherwise. + */ + public void init(Renderer renderer, boolean main) { + if (main) { + renderer.setMainFrameBufferOverride(frameBuffer); + } + } + + /** + * Get the graphics context of the given component. + * @param destination the AWT component used for rendering. + * @return the graphics context of the given component. + */ + protected Graphics getGraphics(Component destination) { + if (destination != null) { + + if (destination.getGraphics() != null) { + return destination.getGraphics(); + } else { + System.out.println("AWT component "+destination.getClass().getSimpleName()+" does not provide 2D graphics capabilities."); + return null; + //throw new IllegalArgumentException("AWT component "+destination.getClass().getSimpleName()+" does not provide 2D graphics capabilities."); + } + } else { + throw new NullPointerException("Component cannot be null."); + } + } + + /** + * Get the width of the area to render. + * @return the width of the area to render. + * @see #getHeight() + */ + public int getWidth() { + return width; + } + + /** + * Get the height of the area to render. + * @return the height of the area to render. + * @see #getWidth() + */ + public int getHeight() { + return height; + } + + /** + * Copy the JMonkey frame buffer that has been rendered by the JMonkey engine and schedule the rendering of the component. + * @param renderManager the JMonkey render manager. + */ + public void copyFrameBufferToImage(RenderManager renderManager) { + + while (!frameState.compareAndSet(WAITING_STATE, RUNNING_STATE)) { + if (frameState.get() == DISPOSED_STATE) { + return; + } + } + + // Convert screenshot. + try { + + frameByteBuffer.clear(); + + final Renderer renderer = renderManager.getRenderer(); + renderer.readFrameBufferWithFormat(frameBuffer, frameByteBuffer, Image.Format.RGBA8); + + } finally { + if (!frameState.compareAndSet(RUNNING_STATE, WAITING_STATE)) { + throw new RuntimeException("unknown problem with the frame state"); + } + } + + synchronized (byteBuffer) { + frameByteBuffer.get(byteBuffer); + + if (transferMode == TransferMode.ON_CHANGES) { + + final byte[] prevBuffer = getPrevImageByteBuffer(); + + if (Arrays.equals(prevBuffer, byteBuffer)) { + if (frameCount == 0) return; + } else { + frameCount = 2; + System.arraycopy(byteBuffer, 0, prevBuffer, 0, byteBuffer.length); + } + + frameByteBuffer.position(0); + frameCount--; + } + } + + EventQueue.invokeLater(new Runnable() { + + @Override + public void run() { + writeFrame(); + }}); + } + + /** + * Write the current rendered frame to the component graphics contex. + */ + protected void writeFrame() { + + + if (pixelWriter != null) { + while (!imageState.compareAndSet(WAITING_STATE, RUNNING_STATE)) { + if (imageState.get() == DISPOSED_STATE) { + return; + } + } + + try { + + final int[] imageDataBuffer = getImageByteBuffer(); + + synchronized (byteBuffer) { + + for(int i = 0; i < width * height; i++) { + imageDataBuffer[i] = ((0xff & byteBuffer[i*4+3]) << 24) // Alpha + | ((0xff & byteBuffer[i*4]) << 16) // Red + | ((0xff & byteBuffer[i*4+1]) << 8) // Green + | ((0xff & byteBuffer[i*4+2])); // BLue + + } + } + + DataBuffer buffer = new DataBufferInt(imageDataBuffer, imageDataBuffer.length); + + SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, getWidth(), getHeight(), new int[] {0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}); + + WritableRaster raster = Raster.createWritableRaster(sm, buffer, null); + + BufferedImage img = new BufferedImage(colorModel, raster, false, null); + + BufferedImage img2 = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB); + offGraphics = img2.createGraphics(); + offGraphics.setColor(component.getBackground()); + img2.createGraphics().fillRect(0, 0, getWidth(), getHeight()); + img2.createGraphics().drawImage(img, null, null); + + component.getGraphics().drawImage(img2, 0, 0, null); + + } finally { + if (!imageState.compareAndSet(RUNNING_STATE, WAITING_STATE)) { + throw new RuntimeException("unknown problem with the image state"); + } + } + } else { + System.out.println("No graphics context available for rendering."); + } + + + } + + /** + * Get the image byte buffer. + * @return the image byte buffer. + */ + protected int[] getImageByteBuffer() { + return imageByteBuffer; + } + + /** + * Get the previous image byte buffer. + * @return the previous image byte buffer. + */ + protected byte[] getPrevImageByteBuffer() { + return prevImageByteBuffer; + } + + /** + * Dispose this renderer. The underlying frame buffer is also disposed. + */ + public void dispose() { + while (!frameState.compareAndSet(WAITING_STATE, DISPOSING_STATE)) ; + while (!imageState.compareAndSet(WAITING_STATE, DISPOSING_STATE)) ; + frameBuffer.dispose(); + BufferUtils.destroyDirectBuffer(frameByteBuffer); + frameState.compareAndSet(DISPOSING_STATE, DISPOSED_STATE); + imageState.compareAndSet(DISPOSING_STATE, DISPOSED_STATE); + } +} \ No newline at end of file diff --git a/jme3-desktop/src/main/java/com/jme3/system/AWTContext.java b/jme3-desktop/src/main/java/com/jme3/system/AWTContext.java new file mode 100644 index 0000000000..78cde8f744 --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/system/AWTContext.java @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2009-2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.system; + + +import com.jme3.input.AWTKeyInput; +import com.jme3.input.AWTMouseInput; +import com.jme3.input.JoyInput; +import com.jme3.input.TouchInput; +import com.jme3.opencl.Context; +import com.jme3.renderer.Renderer; +import com.jme3.system.AppSettings; +import com.jme3.system.JmeContext; +import com.jme3.system.JmeSystem; +import com.jme3.system.SystemListener; +import com.jme3.system.Timer; + +/** + * A JMonkey {@link JmeContext context} that is dedicated to AWT component rendering. + *

        + * This class is based on the JavaFX original code provided by Alexander Brui (see JME3-FX) + *

        + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Alexander Brui (JavaSaBr) + */ +public class AWTContext implements JmeContext { + + /** + * The settings. + */ + protected final AppSettings settings; + + /** + * The key input. + */ + protected final AWTKeyInput keyInput; + + /** + * The mouse input. + */ + protected final AWTMouseInput mouseInput; + + /** + * The current width. + */ + private volatile int width; + + /** + * The current height. + */ + private volatile int height; + + /** + * The background context. + */ + protected JmeContext backgroundContext; + + public AWTContext() { + this.keyInput = new AWTKeyInput(this); + this.mouseInput = new AWTMouseInput(this); + this.settings = createSettings(); + this.backgroundContext = createBackgroundContext(); + this.height = 1; + this.width = 1; + } + + /** + * @return the current height. + */ + public int getHeight() { + return height; + } + + /** + * @param height the current height. + */ + public void setHeight(final int height) { + this.height = height; + } + + /** + * @return the current width. + */ + public int getWidth() { + return width; + } + + /** + * @param width the current width. + */ + public void setWidth(final int width) { + this.width = width; + } + + /** + * @return new settings. + */ + protected AppSettings createSettings() { + final AppSettings settings = new AppSettings(true); + settings.setRenderer(AppSettings.LWJGL_OPENGL3); + return settings; + } + + /** + * @return new context/ + */ + protected JmeContext createBackgroundContext() { + return JmeSystem.newContext(settings, Type.OffscreenSurface); + } + + @Override + public Type getType() { + return Type.OffscreenSurface; + } + + @Override + public void setSettings(AppSettings settings) { + this.settings.copyFrom(settings); + this.settings.setRenderer(AppSettings.LWJGL_OPENGL3); + this.backgroundContext.setSettings(settings); + } + + @Override + public void setSystemListener(final SystemListener listener) { + backgroundContext.setSystemListener(listener); + } + + @Override + public AppSettings getSettings() { + return settings; + } + + @Override + public Renderer getRenderer() { + return backgroundContext.getRenderer(); + } + + @Override + public Context getOpenCLContext() { + return null; + } + + @Override + public AWTMouseInput getMouseInput() { + return mouseInput; + } + + @Override + public AWTKeyInput getKeyInput() { + return keyInput; + } + + @Override + public JoyInput getJoyInput() { + return null; + } + + @Override + public TouchInput getTouchInput() { + return null; + } + + @Override + public Timer getTimer() { + return backgroundContext.getTimer(); + } + + @Override + public void setTitle(final String title) { + } + + @Override + public boolean isCreated() { + return backgroundContext != null && backgroundContext.isCreated(); + } + + @Override + public boolean isRenderable() { + return backgroundContext != null && backgroundContext.isRenderable(); + } + + @Override + public void setAutoFlushFrames(final boolean enabled) { + // TODO Auto-generated method stub + } + + @Override + public void create(final boolean waitFor) { + String render = System.getProperty("awt.background.render", AppSettings.LWJGL_OPENGL33); + backgroundContext.getSettings().setRenderer(render); + backgroundContext.create(waitFor); + } + + @Override + public void restart() { + } + + @Override + public void destroy(final boolean waitFor) { + if (backgroundContext == null) throw new IllegalStateException("Not created"); + // destroy wrapped context + backgroundContext.destroy(waitFor); +} + +} diff --git a/jme3-desktop/src/main/java/com/jme3/system/AWTFrameProcessor.java b/jme3-desktop/src/main/java/com/jme3/system/AWTFrameProcessor.java new file mode 100644 index 0000000000..bb254e450a --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/system/AWTFrameProcessor.java @@ -0,0 +1,657 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.system; + +import java.awt.Component; +import java.awt.EventQueue; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import com.jme3.app.Application; +import com.jme3.input.AWTKeyInput; +import com.jme3.input.AWTMouseInput; +import com.jme3.post.SceneProcessor; +import com.jme3.profile.AppProfiler; +import com.jme3.renderer.Camera; +import com.jme3.renderer.RenderManager; +import com.jme3.renderer.ViewPort; +import com.jme3.renderer.queue.RenderQueue; +import com.jme3.texture.FrameBuffer; +import com.jme3.texture.Image; + +/** + * A frame processor that enables to render JMonkey frame buffer onto an AWT component. + *

        + * This class is based on the JavaFX original code provided by Alexander Brui (see JME3-FX) + *

        + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Alexander Brui (JavaSaBr) + * + */ +public class AWTFrameProcessor implements SceneProcessor, PropertyChangeListener { + + public enum TransferMode { + ALWAYS, + ON_CHANGES + } + + private Application application = null; + + /** + * The width listener. + */ + protected PropertyChangeListener widthListener; + + /** + * The height listener. + */ + protected PropertyChangeListener heightListener; + + /** + * The ration listener. + */ + protected PropertyChangeListener rationListener; + + /** + * The flag to decide when we should resize. + */ + private final AtomicInteger reshapeNeeded; + + /** + * The render manager. + */ + private RenderManager renderManager; + + /** + * The source view port. + */ + private ViewPort viewPort; + + /** + * The frame transfer. + */ + private AWTComponentRenderer frameTransfer; + + /** + * The transfer mode. + */ + private TransferMode transferMode; + + /** + * The destination of jMe frames. + */ + protected volatile Component destination; + + /** + * The flag is true if this processor is main. + */ + private volatile boolean main; + + private int askWidth; + private int askHeight; + + private boolean askFixAspect; + private boolean enabled; + + @Override + public void initialize(RenderManager rm, ViewPort vp) { + this.renderManager = rm; + } + + @Override + public void reshape(ViewPort vp, int w, int h) { + // TODO Auto-generated method stub + } + + @Override + public boolean isInitialized() { + return frameTransfer != null; + } + + @Override + public void preFrame(float tpf) { + // TODO Auto-generated method stub + + } + + @Override + public void postQueue(RenderQueue rq) { + // TODO Auto-generated method stub + + } + + @Override + public void postFrame(FrameBuffer out) { + if (!isEnabled()) { + return; + } + + final AWTComponentRenderer frameTransfer = getFrameTransfer(); + if (frameTransfer != null) { + frameTransfer.copyFrameBufferToImage(getRenderManager()); + } + + // for the next frame + if (hasDestination() && reshapeNeeded.get() > 0 && reshapeNeeded.decrementAndGet() >= 0) { + + if (frameTransfer != null) { + frameTransfer.dispose(); + } + + setFrameTransfer(reshapeInThread(askWidth, askHeight, askFixAspect)); + } + } + + @Override + public void cleanup() { + final AWTComponentRenderer frameTransfer = getFrameTransfer(); + + if (frameTransfer != null) { + frameTransfer.dispose(); + setFrameTransfer(null); + } + } + + @Override + public void setProfiler(AppProfiler profiler) { + // TODO Auto-generated method stub + + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + System.out.println("Property changed: "+evt.getPropertyName()+" "+evt.getOldValue()+" -> "+evt.getNewValue()); + } + + public AWTFrameProcessor() { + transferMode = TransferMode.ALWAYS; + askWidth = 1; + askHeight = 1; + main = true; + reshapeNeeded = new AtomicInteger(2); + } + + /** + * Notify about that the ratio was changed. + * + * @param newValue the new value of the ratio. + */ + protected void notifyChangedRatio(Boolean newValue) { + notifyComponentResized(destination.getWidth(), destination.getHeight(), newValue); + } + + /** + * Notify about that the height was changed. + * + * @param newValue the new value of the height. + */ + protected void notifyChangedHeight(Number newValue) { + notifyComponentResized(destination.getWidth(), newValue.intValue(), isPreserveRatio()); + } + + /** + * Notify about that the width was changed. + * + * @param newValue the new value of the width. + */ + protected void notifyChangedWidth(Number newValue) { + notifyComponentResized(newValue.intValue(), destination.getHeight(), isPreserveRatio()); + } + + /** + * Gets the application. + * + * @return the application. + */ + protected Application getApplication() { + return application; + } + + /** + * Sets the application. + * + * @param application the application. + */ + protected void setApplication(Application application) { + this.application = application; + } + + /** + * Gets the current destination. + * + * @return the current destination. + */ + protected Component getDestination() { + return destination; + } + + /** + * Sets the destination. + * + * @param destination the destination. + */ + protected void setDestination(Component destination) { + this.destination = destination; + } + + /** + * Checks of existing destination. + * @return true if destination is exists. + */ + protected boolean hasDestination() { + return destination != null; + } + + /** + * Checks of existing application. + * @return true if destination is exists. + */ + protected boolean hasApplication() { + return application != null; + } + + + /** + * Gets the frame transfer. + * @return the file transfer. + */ + protected AWTComponentRenderer getFrameTransfer() { + return frameTransfer; + } + + /** + * Sets the frame transfer. + * + * @param frameTransfer the file transfer. + */ + protected void setFrameTransfer(AWTComponentRenderer frameTransfer) { + this.frameTransfer = frameTransfer; + } + + /** + * Gets the view port. + * + * @return the view port. + */ + protected ViewPort getViewPort() { + return viewPort; + } + + /** + * Gets the render manager. + * + * @return the render manager. + */ + protected RenderManager getRenderManager() { + return renderManager; + } + + public boolean isMain() { + return main; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(final boolean enabled) { + this.enabled = enabled; + } + + /** + * Handle resizing. + * + * @param newWidth the new width. + * @param newHeight the new height. + * @param fixAspect true if need to fix aspect. + */ + protected void notifyComponentResized(int newWidth, int newHeight, boolean fixAspect) { + + newWidth = Math.max(newWidth, 1); + newHeight = Math.max(newHeight, 1); + + if (askWidth == newWidth && askWidth == newHeight && askFixAspect == fixAspect) { + return; + } + + askWidth = newWidth; + askHeight = newHeight; + askFixAspect = fixAspect; + reshapeNeeded.set(2); + } + + public void reshape() { + reshapeNeeded.set(2); + } + + /** + * Is preserve ratio. + * + * @return is preserve ratio. + */ + protected boolean isPreserveRatio() { + return false; + } + + /** + * Gets destination width. + * + * @return the destination width. + */ + protected int getDestinationWidth() { + return getDestination().getWidth(); + } + + /** + * Gets destination height. + * + * @return the destination height. + */ + protected int getDestinationHeight() { + return getDestination().getHeight(); + } + + /** + * Bind this processor. + * + * @param destination the destination. + * @param application the application. + */ + public void bind(Component destination, Application application) { + final RenderManager renderManager = application.getRenderManager(); + + if (renderManager == null) { + throw new RuntimeException("No render manager available from the application."); + } + + List postViews = renderManager.getPostViews(); + if (postViews.isEmpty()) { + throw new RuntimeException("the list of a post view is empty."); + } + + bind(destination, application, postViews.get(postViews.size() - 1), true); + } + + /** + * Bind this processor. + * + * @param destination the destination. + * @param application the application. + * @param viewPort the view port. + */ + public void bind(Component destination, Application application, ViewPort viewPort) { + bind(destination, application, viewPort, true); + } + + /** + * Bind this processor. + * + * @param destination the destination. + * @param application the application. + * @param viewPort the view port. + * @param main true if this processor is main. + */ + public void bind(final Component destination, final Application application, ViewPort viewPort, boolean main) { + + if (hasApplication()) { + throw new RuntimeException("This process is already bonded."); + } + + setApplication(application); + setEnabled(true); + + this.main = main; + this.viewPort = viewPort; + this.viewPort.addProcessor(this); + + if (EventQueue.isDispatchThread()) { + bindDestination(application, destination); + } else { + EventQueue.invokeLater(new Runnable() { + + @Override + public void run() { + bindDestination(application, destination); + }}); + } + } + + /** + * Unbind this processor from its current destination. + */ + public void unbind() { + + if (viewPort != null) { + viewPort.removeProcessor(this); + viewPort = null; + } + + if (EventQueue.isDispatchThread()) { + unbindDestination(); + } else { + EventQueue.invokeLater(new Runnable() { + + @Override + public void run() { + unbindDestination(); + }}); + } + + } + + /** + * Bind this processor. + * + * @param application the application. + * @param destination the destination. + */ + protected void bindDestination(Application application, Component destination) { + + if (!EventQueue.isDispatchThread()) { + throw new RuntimeException("bind has to be done from the Event Dispatching thread."); + } + + if (isMain()) { + + if (application.getContext() != null) { + if (application.getContext() instanceof AWTContext) { + AWTContext context = (AWTContext) application.getContext(); + AWTMouseInput mouseInput = context.getMouseInput(); + mouseInput.bind(destination); + AWTKeyInput keyInput = context.getKeyInput(); + keyInput.bind(destination); + + setDestination(destination); + bindListeners(); + + notifyComponentResized(getDestinationWidth(), getDestinationHeight(), isPreserveRatio()); + + } else { + throw new IllegalArgumentException("Underlying application has to use AWTContext (actually using "+application.getContext().getClass().getSimpleName()+")"); + } + } else { + throw new IllegalArgumentException("Underlying application has to use a valid AWTContext (context is null)"); + } + } + } + + /** + * Unbind this processor from destination. + */ + protected void unbindDestination() { + + if (!EventQueue.isDispatchThread()) { + throw new RuntimeException("unbind has to be done from the Event Dispatching thread."); + } + + if (hasApplication() && isMain()) { + final AWTContext context = (AWTContext) getApplication().getContext(); + final AWTMouseInput mouseInput = context.getMouseInput(); + mouseInput.unbind(); + final AWTKeyInput keyInput = context.getKeyInput(); + keyInput.unbind(); + } + + setApplication(null); + + if (hasDestination()) { + unbindListeners(); + setDestination(null); + } + } + + + protected void bindListeners() { + Component destination = getDestination(); + destination.addPropertyChangeListener(this); + destination.addPropertyChangeListener(this); + } + + + protected void unbindListeners() { + Component destination = getDestination(); + destination.removePropertyChangeListener(this); + destination.removePropertyChangeListener(this); + } + + /** + * Reshape the current frame transfer for the new size. + * + * @param width the width. + * @param height the height. + * @param fixAspect true if need to fix aspect ration. + * @return the new frame transfer. + */ + protected AWTComponentRenderer reshapeInThread(final int width, final int height, final boolean fixAspect) { + + reshapeCurrentViewPort(width, height); + + ViewPort viewPort = getViewPort(); + RenderManager renderManager = getRenderManager(); + FrameBuffer frameBuffer = viewPort.getOutputFrameBuffer(); + + AWTComponentRenderer frameTransfer = createFrameTransfer(frameBuffer, width, height); + frameTransfer.init(renderManager.getRenderer(), isMain()); + + if (isMain()) { + AWTContext context = (AWTContext) getApplication().getContext(); + context.setHeight(height); + context.setWidth(width); + } + + return frameTransfer; + } + + /** + * Create a new frame transfer. + * + * @param frameBuffer the frame buffer. + * @param width the width. + * @param height the height. + * @return the new frame transfer. + */ + protected AWTComponentRenderer createFrameTransfer(FrameBuffer frameBuffer, int width, int height) { + return new AWTComponentRenderer(getDestination(), getTransferMode(), isMain() ? null : frameBuffer, width, height); + } + + /** + * Reshape the current view port. + * + * @param width the width. + * @param height the height. + */ + protected void reshapeCurrentViewPort(int width, int height) { + + ViewPort viewPort = getViewPort(); + Camera camera = viewPort.getCamera(); + int cameraAngle = getCameraAngle(); + float aspect = (float) camera.getWidth() / camera.getHeight(); + + if (isMain()) { + getRenderManager().notifyReshape(width, height); + camera.setFrustumPerspective(cameraAngle, aspect, 1f, 10000); + return; + } + + camera.resize(width, height, true); + camera.setFrustumPerspective(cameraAngle, aspect, 1f, 10000); + + final List processors = viewPort.getProcessors(); + + boolean found = false; + Iterator iter = processors.iterator(); + while(!found && iter.hasNext()) { + if (!(iter.next() instanceof AWTFrameProcessor)) { + found = true; + } + } + + if (found) { + + FrameBuffer frameBuffer = new FrameBuffer(width, height, 1); + frameBuffer.setDepthBuffer(Image.Format.Depth); + frameBuffer.setColorBuffer(Image.Format.RGBA8); + frameBuffer.setSrgb(true); + + viewPort.setOutputFrameBuffer(frameBuffer); + } + + for (final SceneProcessor sceneProcessor : processors) { + if (!sceneProcessor.isInitialized()) { + sceneProcessor.initialize(renderManager, viewPort); + } else { + sceneProcessor.reshape(viewPort, width, height); + } + } + } + + /** + * Gets camera angle. + * + * @return the camera angle. + */ + protected int getCameraAngle() { + final String angle = System.getProperty("awt.frame.transfer.camera.angle", "45"); + return Integer.parseInt(angle); + } + + public TransferMode getTransferMode() { + return transferMode; + } + + public void setTransferMode(TransferMode transferMode) { + this.transferMode = transferMode; + } +} diff --git a/jme3-desktop/src/main/java/com/jme3/system/AWTTaskExecutor.java b/jme3-desktop/src/main/java/com/jme3/system/AWTTaskExecutor.java new file mode 100644 index 0000000000..8e9f586232 --- /dev/null +++ b/jme3-desktop/src/main/java/com/jme3/system/AWTTaskExecutor.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.system; + +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + *

        + * This class is dedicated to the queuing of AWT related tasks and their execution. + * It's able to store tasks that have to be executed within an AWT context and execute them at the specified time. + *

        + *

        + * This class is an AWT implementation of the JavaFX original code provided by Alexander Brui (see JME3-FX) + *

        + * @author Julien Seinturier - COMEX SA - http://www.seinturier.fr + * @author Alexander Brui (JavaSaBr) + */ +public class AWTTaskExecutor { + + private final ReadWriteLock lock = new ReentrantReadWriteLock(); + + private static final AWTTaskExecutor INSTANCE = new AWTTaskExecutor(); + + /** + * Get the instance of the executor. + * @return the instance of executor. + */ + public static AWTTaskExecutor getInstance() { + return INSTANCE; + } + + /** + * The list of waiting tasks. + */ + private final List waitTasks; + + private AWTTaskExecutor() { + waitTasks = new LinkedList(); + } + + public List getWaitingTasks(){ + return waitTasks; + } + + /** + * Add the given {@link Runnable runnable} to the list of planned executions. + * @param task the task to add. + * @see #execute() + */ + public void addToExecute(final Runnable task) { + lock.writeLock().lock(); + try { + waitTasks.add(task); + } catch (Exception e) { + // This try catch block enable to free the lock in case of any unexpected error. + } + lock.writeLock().unlock(); + } + + /** + * Execute all the tasks that are waiting. + * @see #addToExecute(Runnable) + */ + public void execute() { + + if (waitTasks.isEmpty()) return; + + lock.readLock().lock(); + + try { + for(Runnable runnable : waitTasks) { + runnable.run(); + } + } catch (Exception e) { + // This try catch block enable to free the lock in case of any unexpected error. + } + + waitTasks.clear(); + + lock.readLock().unlock(); + } +} diff --git a/jme3-desktop/src/main/java/jme3tools/navigation/NavCalculator.java b/jme3-desktop/src/main/java/jme3tools/navigation/NavCalculator.java index bc4deaf502..e67247ae68 100644 --- a/jme3-desktop/src/main/java/jme3tools/navigation/NavCalculator.java +++ b/jme3-desktop/src/main/java/jme3tools/navigation/NavCalculator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -139,7 +139,7 @@ public RLSailing mercatorSailing(Position p1, Position p2) { * Calculate a plane sailing situation - i.e. where Lats are the same * @param p1 * @param p2 - * @return + * @return a new instance * @since 1.0 */ public RLSailing planeSailing(Position p1, Position p2) { @@ -171,7 +171,7 @@ public RLSailing planeSailing(Position p1, Position p2) { * @param tc * @param p1 position one * @param p2 position two - * @return + * @return angle (in degrees) * @since 1.0 */ public static double convertCourse(float tc, Position p1, Position p2) { @@ -312,9 +312,8 @@ public static Position predictPosition(int time, double speed, * Computes the coordinate of position B relative to an offset given * a distance and an angle. * - * @param offset The offset position. - * @param bearing The bearing between the offset and the coordinate - * that you want to calculate. + * @param initialPos + * @param heading * @param distance The distance, in meters, between the offset * and point B. * @return The position of point B that is located from @@ -554,7 +553,7 @@ public static double toDegrees(double meters) { * * @param p1 * @param p2 - * @return + * @return bearing (in degrees) * @since 1.0 */ public static int computeBearing(Position p1, Position p2) { @@ -572,7 +571,7 @@ public static int computeBearing(Position p1, Position p2) { * * @param p1 * @param p2 - * @return + * @return angle (in degrees) */ public static int computeAngle(Position p1, Position p2) { // cos (adj / hyp) diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/BloomFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/BloomFilter.java index 7a83809cda..1d4ad6021b 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/BloomFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/BloomFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ * There are 2 mode : Scene and Objects.
        * Scene mode extracts the bright parts of the scene to make them glow
        * Object mode make objects glow according to their material's glowMap or their GlowColor
        - * @see advanced:bloom_and_glow for more details + * See advanced:bloom_and_glow for more details * * @author Rémy Bouquet aka Nehon */ @@ -226,7 +226,7 @@ protected void cleanUpFilter(Renderer r) { /** * returns the bloom intensity - * @return + * @return the intensity value */ public float getBloomIntensity() { return bloomIntensity; @@ -242,7 +242,7 @@ public void setBloomIntensity(float bloomIntensity) { /** * returns the blur scale - * @return + * @return the blur scale */ public float getBlurScale() { return blurScale; @@ -259,7 +259,7 @@ public void setBlurScale(float blurScale) { /** * returns the exposure cutoff
        * for more details see {@link #setExposureCutOff(float exposureCutOff)} - * @return + * @return the exposure cutoff */ public float getExposureCutOff() { return exposureCutOff; @@ -275,8 +275,8 @@ public void setExposureCutOff(float exposureCutOff) { /** * returns the exposure power
        - * form more details see {@link #setExposurePower(float exposurePower)} - * @return + * for more details see {@link #setExposurePower(float exposurePower)} + * @return the exposure power */ public float getExposurePower() { return exposurePower; @@ -293,8 +293,8 @@ public void setExposurePower(float exposurePower) { /** * returns the downSampling factor
        - * form more details see {@link #setDownSamplingFactor(float downSamplingFactor)} - * @return + * for more details see {@link #setDownSamplingFactor(float downSamplingFactor)} + * @return the downsampling factor */ public float getDownSamplingFactor() { return downSamplingFactor; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/CartoonEdgeFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/CartoonEdgeFilter.java index efcc319a7d..c1d5b0dfb6 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/CartoonEdgeFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/CartoonEdgeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -115,7 +115,7 @@ protected void cleanUpFilter(Renderer r) { /** * Return the depth sensitivity
        * for more details see {@link #setDepthSensitivity(float depthSensitivity)} - * @return + * @return the depth sensitivity */ public float getDepthSensitivity() { return depthSensitivity; @@ -136,7 +136,7 @@ public void setDepthSensitivity(float depthSensitivity) { /** * returns the depth threshold
        * for more details see {@link #setDepthThreshold(float depthThreshold)} - * @return + * @return the threshold */ public float getDepthThreshold() { return depthThreshold; @@ -157,7 +157,7 @@ public void setDepthThreshold(float depthThreshold) { /** * returns the edge intensity
        * for more details see {@link #setEdgeIntensity(float edgeIntensity) } - * @return + * @return the intensity */ public float getEdgeIntensity() { return edgeIntensity; @@ -177,7 +177,7 @@ public void setEdgeIntensity(float edgeIntensity) { /** * returns the width of the edges - * @return + * @return the width */ public float getEdgeWidth() { return edgeWidth; @@ -198,7 +198,7 @@ public void setEdgeWidth(float edgeWidth) { /** * returns the normals sensitivity
        * form more details see {@link #setNormalSensitivity(float normalSensitivity)} - * @return + * @return the sensitivity */ public float getNormalSensitivity() { return normalSensitivity; @@ -219,7 +219,7 @@ public void setNormalSensitivity(float normalSensitivity) { * returns the normal threshold
        * for more details see {@link #setNormalThreshold(float normalThreshold)} * - * @return + * @return the threshold */ public float getNormalThreshold() { return normalThreshold; @@ -238,7 +238,7 @@ public void setNormalThreshold(float normalThreshold) { /** * returns the edge color - * @return + * @return the pre-existing instance */ public ColorRGBA getEdgeColor() { return edgeColor; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/ComposeFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/ComposeFilter.java index 2aff1b174d..401b31a6ff 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/ComposeFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/ComposeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,7 +68,7 @@ public ComposeFilter() { /** * creates a ComposeFilter with the given texture * - * @param color + * @param compositeTexture */ public ComposeFilter(Texture2D compositeTexture) { this(); diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/CrossHatchFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/CrossHatchFilter.java index 31399e79cd..4f50e7dd13 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/CrossHatchFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/CrossHatchFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -219,7 +219,7 @@ public void setLineDistance(float lineDistance) { /** * Returns line color - * @return + * @return the pre-existing instance */ public ColorRGBA getLineColor() { return lineColor; @@ -227,7 +227,7 @@ public ColorRGBA getLineColor() { /** * Returns paper background color - * @return + * @return the pre-existing instance */ public ColorRGBA getPaperColor() { return paperColor; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/DepthOfFieldFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/DepthOfFieldFilter.java index 872b3566e2..31ca381237 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/DepthOfFieldFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/DepthOfFieldFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,7 +110,7 @@ public void setFocusDistance(float f) { /** * returns the focus distance - * @return + * @return the distance */ public float getFocusDistance() { return focusDistance; @@ -131,7 +131,7 @@ public void setFocusRange(float f) { /** * returns the focus range - * @return + * @return the distance */ public float getFocusRange() { return focusRange; @@ -159,7 +159,7 @@ public void setBlurScale(float f) { /** * returns the blur scale - * @return + * @return the scale */ public float getBlurScale() { return blurScale; @@ -188,7 +188,7 @@ public void setBlurThreshold( float f ) { /** * returns the blur threshold. - * @return + * @return the threshold */ public float getBlurThreshold() { return blurThreshold; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/FadeFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/FadeFilter.java index ba8210c306..8864f77576 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/FadeFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/FadeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,7 +101,7 @@ protected void preFrame(float tpf) { /** * returns the duration of the effect - * @return + * @return the duration (in seconds) */ public float getDuration() { return duration; @@ -155,7 +155,7 @@ public void read(JmeImporter im) throws IOException { /** * return the current value of the fading * can be used to check if fade is complete (eg value=1) - * @return + * @return the fractional progress (≥0, ≤1) */ public float getValue() { return value; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/FogFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/FogFilter.java index c1df3b7617..089dec5571 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/FogFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/FogFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -95,7 +95,7 @@ protected Material getMaterial() { /** * returns the fog color - * @return + * @return the pre-existing instance */ public ColorRGBA getFogColor() { return fogColor; @@ -114,7 +114,7 @@ public void setFogColor(ColorRGBA fogColor) { /** * returns the fog density - * @return + * @return the density value */ public float getFogDensity() { return fogDensity; @@ -133,7 +133,7 @@ public void setFogDensity(float fogDensity) { /** * returns the fog distance - * @return + * @return the distance */ public float getFogDistance() { return fogDistance; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java index 3d98e11656..845b1b8372 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/LightScatteringFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -133,7 +133,7 @@ protected void initFilter(AssetManager manager, RenderManager renderManager, Vie /** * returns the blur start of the scattering * see {@link #setBlurStart(float blurStart)} - * @return + * @return the start distance */ public float getBlurStart() { return blurStart; @@ -151,7 +151,7 @@ public void setBlurStart(float blurStart) { /** * returns the blur width
        * see {@link #setBlurWidth(float blurWidth)} - * @return + * @return the width */ public float getBlurWidth() { return blurWidth; @@ -169,7 +169,7 @@ public void setBlurWidth(float blurWidth) { * returns the light density * see {@link #setLightDensity(float lightDensity)} * - * @return + * @return the density */ public float getLightDensity() { return lightDensity; @@ -185,7 +185,7 @@ public void setLightDensity(float lightDensity) { /** * returns the light position - * @return + * @return the pre-existing vector */ public Vector3f getLightPosition() { return lightPosition; @@ -201,7 +201,7 @@ public void setLightPosition(Vector3f lightPosition) { /** * returns the number of samples for the radial blur - * @return + * @return count (≥0) */ public int getNbSamples() { return nbSamples; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/RadialBlurFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/RadialBlurFilter.java index 28cc2c28cb..c79339848f 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/RadialBlurFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/RadialBlurFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -81,7 +81,7 @@ protected Material getMaterial() { /** * return the sample distance - * @return + * @return the distance */ public float getSampleDistance() { return sampleDist; @@ -97,7 +97,7 @@ public void setSampleDistance(float sampleDist) { /** * - * @return + * @return the distance * @deprecated use {@link #getSampleDistance()} */ @Deprecated @@ -117,7 +117,7 @@ public void setSampleDist(float sampleDist) { /** * Returns the sample Strength - * @return + * @return the strength value */ public float getSampleStrength() { return sampleStrength; diff --git a/jme3-effects/src/main/java/com/jme3/post/filters/TranslucentBucketFilter.java b/jme3-effects/src/main/java/com/jme3/post/filters/TranslucentBucketFilter.java index 39c1205e61..743c0abea9 100644 --- a/jme3-effects/src/main/java/com/jme3/post/filters/TranslucentBucketFilter.java +++ b/jme3-effects/src/main/java/com/jme3/post/filters/TranslucentBucketFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -107,8 +107,8 @@ protected void setDepthTexture(Texture depthTexture) { } /** - * Override this method and return false if your Filter does not need the scene texture - * @return + * Override this method and return true if your Filter needs the scene texture + * @return false */ @Override protected boolean isRequiresSceneTexture() { diff --git a/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java b/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java index a3c12e4e8c..f310f5313a 100644 --- a/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java +++ b/jme3-effects/src/main/java/com/jme3/water/ReflectionProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -110,7 +110,7 @@ public void setProfiler(AppProfiler profiler) { /** * Internal use only
        * returns the frame buffer - * @return + * @return the pre-existing buffer */ public FrameBuffer getReflectionBuffer() { return reflectionBuffer; @@ -127,7 +127,7 @@ public void setReflectionBuffer(FrameBuffer reflectionBuffer) { /** * returns the reflection cam - * @return + * @return the pre-existing Camera */ public Camera getReflectionCam() { return reflectionCam; @@ -143,7 +143,7 @@ public void setReflectionCam(Camera reflectionCam) { /** * returns the reflection clip plane - * @return + * @return the pre-existing instance */ public Plane getReflectionClipPlane() { return reflectionClipPlane; diff --git a/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java b/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java index 36ae8ee60d..a628514ceb 100644 --- a/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java +++ b/jme3-effects/src/main/java/com/jme3/water/SimpleWaterProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -310,7 +310,7 @@ protected void destroyViews() { /** * Get the water material from this processor, apply this to your water quad. - * @return + * @return the pre-existing Material */ public Material getMaterial() { return material; @@ -327,7 +327,7 @@ public void setReflectionScene(Spatial spat) { /** * returns the width of the reflection and refraction textures - * @return + * @return the width (in pixels) */ public int getRenderWidth() { return renderWidth; @@ -335,7 +335,7 @@ public int getRenderWidth() { /** * returns the height of the reflection and refraction textures - * @return + * @return the height (in pixels) */ public int getRenderHeight() { return renderHeight; @@ -354,7 +354,7 @@ public void setRenderSize(int width, int height) { /** * returns the water plane - * @return + * @return the pre-existing instance */ public Plane getPlane() { return plane; @@ -417,7 +417,7 @@ public void setWaterDepth(float depth) { /** * return the water depth - * @return + * @return the depth */ public float getWaterDepth() { return waterDepth; @@ -425,7 +425,7 @@ public float getWaterDepth() { /** * returns water transparency - * @return + * @return the transparency value */ public float getWaterTransparency() { return waterTransparency; @@ -515,7 +515,7 @@ public float getTexScale() { /** * returns true if the waterprocessor is in debug mode - * @return + * @return true if in debug mode, otherwise false */ public boolean isDebug() { return debug; @@ -533,7 +533,7 @@ public void setDebug(boolean debug) { * Creates a quad with the water material applied to it. * @param width * @param height - * @return + * @return a new Geometry */ public Geometry createWaterGeometry(float width, float height) { Quad quad = new Quad(width, height); @@ -545,7 +545,7 @@ public Geometry createWaterGeometry(float width, float height) { /** * returns the reflection clipping plane offset - * @return + * @return the offset value */ public float getReflectionClippingOffset() { return reflectionClippingOffset; @@ -563,7 +563,7 @@ public void setReflectionClippingOffset(float reflectionClippingOffset) { /** * returns the refraction clipping plane offset - * @return + * @return the offset value */ public float getRefractionClippingOffset() { return refractionClippingOffset; diff --git a/jme3-effects/src/main/java/com/jme3/water/WaterFilter.java b/jme3-effects/src/main/java/com/jme3/water/WaterFilter.java index 162abb85e4..a42a5d9479 100644 --- a/jme3-effects/src/main/java/com/jme3/water/WaterFilter.java +++ b/jme3-effects/src/main/java/com/jme3/water/WaterFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -464,7 +464,7 @@ public void read(JmeImporter im) throws IOException { /** * gets the height of the water plane - * @return + * @return the height */ public float getWaterHeight() { return waterHeight; @@ -517,7 +517,7 @@ public Spatial getReflectionScene() { /** * returns the waterTransparency value - * @return + * @return the transparency value */ public float getWaterTransparency() { return waterTransparency; @@ -539,7 +539,7 @@ public void setWaterTransparency(float waterTransparency) { /** * Returns the normal scales applied to the normal map - * @return + * @return the scale factor */ public float getNormalScale() { return normalScale; @@ -559,8 +559,8 @@ public void setNormalScale(float normalScale) { } /** - * returns the refractoin constant - * @return + * returns the refraction constant + * @return the refraction constant */ public float getRefractionConstant() { return refractionConstant; @@ -584,7 +584,7 @@ public void setRefractionConstant(float refractionConstant) { /** * return the maximum wave amplitude - * @return + * @return the maximum amplitude */ public float getMaxAmplitude() { return maxAmplitude; @@ -604,7 +604,7 @@ public void setMaxAmplitude(float maxAmplitude) { /** * gets the light direction - * @return + * @return the pre-existing vector */ public Vector3f getLightDirection() { return lightDirection; @@ -623,7 +623,7 @@ public void setLightDirection(Vector3f lightDirection) { /** * returns the light color - * @return + * @return the pre-existing instance */ public ColorRGBA getLightColor() { return lightColor; @@ -643,7 +643,7 @@ public void setLightColor(ColorRGBA lightColor) { /** * Return the shoreHardeness - * @return + * @return the hardness value */ public float getShoreHardness() { return shoreHardness; @@ -664,7 +664,7 @@ public void setShoreHardness(float shoreHardness) { /** * returns the foam hardness - * @return + * @return the hardness value */ public float getFoamHardness() { return foamHardness; @@ -684,7 +684,7 @@ public void setFoamHardness(float foamHardness) { /** * returns the refractionStrength - * @return + * @return the strength value */ public float getRefractionStrength() { return refractionStrength; @@ -705,7 +705,7 @@ public void setRefractionStrength(float refractionStrength) { /** * returns the scale factor of the waves height map - * @return + * @return the scale factor */ public float getWaveScale() { return waveScale; @@ -726,7 +726,7 @@ public void setWaveScale(float waveScale) { /** * returns the foam existence vector - * @return + * @return the pre-existing vector */ public Vector3f getFoamExistence() { return foamExistence; @@ -748,7 +748,7 @@ public void setFoamExistence(Vector3f foamExistence) { /** * gets the scale of the sun - * @return + * @return the scale factor */ public float getSunScale() { return sunScale; @@ -767,7 +767,7 @@ public void setSunScale(float sunScale) { /** * Returns the color extinction vector of the water - * @return + * @return the pre-existing vector */ public Vector3f getColorExtinction() { return colorExtinction; @@ -857,7 +857,7 @@ public Texture2D getNormalTexture() { /** * return the shininess factor of the water - * @return + * @return the shininess factor */ public float getShininess() { return shininess; @@ -877,7 +877,7 @@ public void setShininess(float shininess) { /** * returns the speed of the waves - * @return + * @return the speed value */ public float getSpeed() { return speed; @@ -894,7 +894,7 @@ public void setSpeed(float speed) { /** * returns the color of the water * - * @return + * @return the pre-existing instance */ public ColorRGBA getWaterColor() { return waterColor; @@ -915,7 +915,7 @@ public void setWaterColor(ColorRGBA waterColor) { /** * returns the deep water color - * @return + * @return the pre-existing instance */ public ColorRGBA getDeepWaterColor() { return deepWaterColor; @@ -936,7 +936,7 @@ public void setDeepWaterColor(ColorRGBA deepWaterColor) { /** * returns the wind direction - * @return + * @return the pre-existing direction vector */ public Vector2f getWindDirection() { return windDirection; @@ -957,7 +957,7 @@ public void setWindDirection(Vector2f windDirection) { /** * returns the size of the reflection map - * @return + * @return the size (in pixels) */ public int getReflectionMapSize() { return reflectionMapSize; @@ -1119,7 +1119,7 @@ public void setUseSpecular(boolean useSpecular) { /** * returns the foam intensity - * @return + * @return the intensity value */ public float getFoamIntensity() { return foamIntensity; @@ -1140,7 +1140,7 @@ public void setFoamIntensity(float foamIntensity) { /** * returns the reflection displace * see {@link #setReflectionDisplace(float) } - * @return + * @return the displacement value */ public float getReflectionDisplace() { return reflectionDisplace; @@ -1167,7 +1167,7 @@ public boolean isUnderWater() { /** * returns the distance of the fog when under water - * @return + * @return the distance */ public float getUnderWaterFogDistance() { return underWaterFogDistance; @@ -1187,7 +1187,7 @@ public void setUnderWaterFogDistance(float underWaterFogDistance) { /** * get the intensity of caustics under water - * @return + * @return the intensity value (≥0, ≤1) */ public float getCausticsIntensity() { return causticsIntensity; diff --git a/jme3-examples/TerrainGridTestData.zip b/jme3-examples/TerrainGridTestData.zip new file mode 100644 index 0000000000..2acdd5bebe Binary files /dev/null and b/jme3-examples/TerrainGridTestData.zip differ diff --git a/jme3-examples/build.gradle b/jme3-examples/build.gradle index cd98abaa9b..08e2a8dadd 100644 --- a/jme3-examples/build.gradle +++ b/jme3-examples/build.gradle @@ -126,4 +126,4 @@ task dist (dependsOn: ['build', ':jme3-jogl:jar', ':jme3-bullet:jar', ':jme3-and rename {project(':jme3-bullet-native-android').name+".jar"} } } -} +} \ No newline at end of file diff --git a/jme3-examples/src/main/java/jme3test/animation/TestCameraMotionPath.java b/jme3-examples/src/main/java/jme3test/animation/TestCameraMotionPath.java index baeb41a312..392792ac2c 100644 --- a/jme3-examples/src/main/java/jme3test/animation/TestCameraMotionPath.java +++ b/jme3-examples/src/main/java/jme3test/animation/TestCameraMotionPath.java @@ -36,7 +36,6 @@ import com.jme3.cinematic.MotionPath; import com.jme3.cinematic.MotionPathListener; import com.jme3.cinematic.events.MotionEvent; -import com.jme3.cinematic.events.MotionEvent; import com.jme3.font.BitmapText; import com.jme3.input.ChaseCamera; import com.jme3.input.KeyInput; diff --git a/jme3-examples/src/main/java/jme3test/animation/TestMotionPath.java b/jme3-examples/src/main/java/jme3test/animation/TestMotionPath.java index 51268b6bca..02bc5335c9 100644 --- a/jme3-examples/src/main/java/jme3test/animation/TestMotionPath.java +++ b/jme3-examples/src/main/java/jme3test/animation/TestMotionPath.java @@ -31,12 +31,10 @@ */ package jme3test.animation; -import com.jme3.animation.LoopMode; import com.jme3.app.SimpleApplication; import com.jme3.cinematic.MotionPath; import com.jme3.cinematic.MotionPathListener; import com.jme3.cinematic.events.MotionEvent; -import com.jme3.cinematic.events.MotionEvent; import com.jme3.font.BitmapText; import com.jme3.input.ChaseCamera; import com.jme3.input.KeyInput; diff --git a/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java b/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java index ebca77683d..b6517c9d2b 100644 --- a/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java +++ b/jme3-examples/src/main/java/jme3test/app/TestAppStateLifeCycle.java @@ -37,7 +37,6 @@ import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; import com.jme3.material.Material; -import com.jme3.math.Vector3f; import com.jme3.renderer.RenderManager; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; diff --git a/jme3-examples/src/main/java/jme3test/app/TestBareBonesApp.java b/jme3-examples/src/main/java/jme3test/app/TestBareBonesApp.java index 491f4817be..b90d28310e 100644 --- a/jme3-examples/src/main/java/jme3test/app/TestBareBonesApp.java +++ b/jme3-examples/src/main/java/jme3test/app/TestBareBonesApp.java @@ -33,7 +33,6 @@ package jme3test.app; import com.jme3.app.LegacyApplication; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; diff --git a/jme3-examples/src/main/java/jme3test/app/TestCloneSpatial.java b/jme3-examples/src/main/java/jme3test/app/TestCloneSpatial.java index 89dae89b8b..132fb44a38 100644 --- a/jme3-examples/src/main/java/jme3test/app/TestCloneSpatial.java +++ b/jme3-examples/src/main/java/jme3test/app/TestCloneSpatial.java @@ -43,7 +43,6 @@ import com.jme3.scene.*; import com.jme3.scene.control.*; import com.jme3.scene.shape.*; -import com.jme3.util.clone.*; /** diff --git a/jme3-examples/src/main/java/jme3test/app/TestReleaseDirectMemory.java b/jme3-examples/src/main/java/jme3test/app/TestReleaseDirectMemory.java index 28947c400d..102d03f432 100644 --- a/jme3-examples/src/main/java/jme3test/app/TestReleaseDirectMemory.java +++ b/jme3-examples/src/main/java/jme3test/app/TestReleaseDirectMemory.java @@ -34,7 +34,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.material.Material; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; import com.jme3.util.BufferUtils; diff --git a/jme3-examples/src/main/java/jme3test/app/TestResizableApp.java b/jme3-examples/src/main/java/jme3test/app/TestResizableApp.java index ad493ab447..d2314b989d 100644 --- a/jme3-examples/src/main/java/jme3test/app/TestResizableApp.java +++ b/jme3-examples/src/main/java/jme3test/app/TestResizableApp.java @@ -33,12 +33,10 @@ import com.jme3.app.SimpleApplication; import com.jme3.font.BitmapText; -import com.jme3.font.Rectangle; import com.jme3.material.Material; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; import com.jme3.system.AppSettings; -import jme3test.model.shape.TestBox; /** * Tests the capability to resize the application window. diff --git a/jme3-examples/src/main/java/jme3test/app/TestUseAfterFree.java b/jme3-examples/src/main/java/jme3test/app/TestUseAfterFree.java index a8127469a8..8c8c5dddd8 100644 --- a/jme3-examples/src/main/java/jme3test/app/TestUseAfterFree.java +++ b/jme3-examples/src/main/java/jme3test/app/TestUseAfterFree.java @@ -37,8 +37,6 @@ import com.jme3.scene.shape.Box; import com.jme3.texture.Texture; import com.jme3.util.BufferUtils; -import java.util.logging.Level; -import java.util.logging.Logger; public class TestUseAfterFree extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/asset/TestManyLocators.java b/jme3-examples/src/main/java/jme3test/asset/TestManyLocators.java index b7b52059dc..bf0cc642e1 100644 --- a/jme3-examples/src/main/java/jme3test/asset/TestManyLocators.java +++ b/jme3-examples/src/main/java/jme3test/asset/TestManyLocators.java @@ -43,13 +43,13 @@ public class TestManyLocators { public static void main(String[] args){ AssetManager am = JmeSystem.newAssetManager(); - am.registerLocator("http://www.jmonkeyengine.com/wp-content/uploads/2010/09/", + am.registerLocator("http://wiki.jmonkeyengine.org/jme3/beginner", UrlLocator.class); am.registerLocator("town.zip", ZipLocator.class); - am.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", - HttpZipLocator.class); - + am.registerLocator( + "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/wildhouse.zip", + HttpZipLocator.class); am.registerLocator("/", ClasspathLocator.class); @@ -65,7 +65,7 @@ public static void main(String[] args){ AssetInfo c = am.locateAsset(new ModelKey("glasstile2.png")); // Try loading directly from HTTP - AssetInfo d = am.locateAsset(new TextureKey("planet-2.jpg")); + AssetInfo d = am.locateAsset(new TextureKey("beginner-physics.png")); if (a == null) System.out.println("Failed to load from classpath"); @@ -73,12 +73,12 @@ public static void main(String[] args){ System.out.println("Found classpath font: " + a.toString()); if (b == null) - System.out.println("Failed to load from town.zip"); + System.out.println("Failed to load from town.zip file"); else System.out.println("Found zip image: " + b.toString()); if (c == null) - System.out.println("Failed to load from wildhouse.zip on googlecode.com"); + System.out.println("Failed to load from wildhouse.zip on googleapis.com"); else System.out.println("Found online zip image: " + c.toString()); diff --git a/jme3-examples/src/main/java/jme3test/asset/TestOnlineJar.java b/jme3-examples/src/main/java/jme3test/asset/TestOnlineJar.java index 1de154f56a..0a864a0cda 100644 --- a/jme3-examples/src/main/java/jme3test/asset/TestOnlineJar.java +++ b/jme3-examples/src/main/java/jme3test/asset/TestOnlineJar.java @@ -33,12 +33,9 @@ package jme3test.asset; import com.jme3.app.SimpleApplication; -import com.jme3.asset.TextureKey; import com.jme3.asset.plugins.HttpZipLocator; -import com.jme3.material.Material; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Quad; -import com.jme3.texture.Texture; import com.jme3.ui.Picture; /** diff --git a/jme3-examples/src/main/java/jme3test/audio/TestMusicStreaming.java b/jme3-examples/src/main/java/jme3test/audio/TestMusicStreaming.java index 35332b11dc..677d6d2483 100644 --- a/jme3-examples/src/main/java/jme3test/audio/TestMusicStreaming.java +++ b/jme3-examples/src/main/java/jme3test/audio/TestMusicStreaming.java @@ -46,7 +46,7 @@ public static void main(String[] args){ @Override public void simpleInitApp(){ - assetManager.registerLocator("http://www.vorbis.com/music/", UrlLocator.class); + assetManager.registerLocator("https://web.archive.org/web/20170625151521if_/http://www.vorbis.com/music/", UrlLocator.class); AudioNode audioSource = new AudioNode(assetManager, "Lumme-Badloop.ogg", AudioData.DataType.Stream); audioSource.setPositional(false); diff --git a/jme3-examples/src/main/java/jme3test/awt/TestAwtPanels.java b/jme3-examples/src/main/java/jme3test/awt/TestAwtPanels.java index 5c00e50085..55d74e1197 100644 --- a/jme3-examples/src/main/java/jme3test/awt/TestAwtPanels.java +++ b/jme3-examples/src/main/java/jme3test/awt/TestAwtPanels.java @@ -2,7 +2,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.material.Material; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; import com.jme3.system.AppSettings; diff --git a/jme3-examples/src/main/java/jme3test/awt/TestSafeCanvas.java b/jme3-examples/src/main/java/jme3test/awt/TestSafeCanvas.java index 6264f82469..5c6940df31 100644 --- a/jme3-examples/src/main/java/jme3test/awt/TestSafeCanvas.java +++ b/jme3-examples/src/main/java/jme3test/awt/TestSafeCanvas.java @@ -2,7 +2,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.material.Material; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; import com.jme3.system.AppSettings; diff --git a/jme3-examples/src/main/java/jme3test/bullet/PhysicsTestHelper.java b/jme3-examples/src/main/java/jme3test/bullet/PhysicsTestHelper.java index 531331d13b..c0fa6f0653 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/PhysicsTestHelper.java +++ b/jme3-examples/src/main/java/jme3test/bullet/PhysicsTestHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,10 +59,12 @@ public class PhysicsTestHelper { /** - * creates a simple physics test world with a floor, an obstacle and some test boxes - * @param rootNode - * @param assetManager - * @param space + * creates a simple physics test world with a floor, an obstacle and some + * test boxes + * + * @param rootNode where lights and geometries should be added + * @param assetManager for loading assets + * @param space where collision objects should be added */ public static void createPhysicsTestWorld(Node rootNode, AssetManager assetManager, PhysicsSpace space) { AmbientLight light = new AmbientLight(); @@ -161,8 +163,9 @@ public static void createPhysicsTestWorldSoccer(Node rootNode, AssetManager asse /** * creates a box geometry with a RigidBodyControl - * @param assetManager - * @return + * + * @param assetManager for loading assets + * @return a new Geometry */ public static Geometry createPhysicsTestBox(AssetManager assetManager) { Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); @@ -177,8 +180,9 @@ public static Geometry createPhysicsTestBox(AssetManager assetManager) { /** * creates a sphere geometry with a RigidBodyControl - * @param assetManager - * @return + * + * @param assetManager for loading assets + * @return a new Geometry */ public static Geometry createPhysicsTestSphere(AssetManager assetManager) { Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); @@ -193,10 +197,11 @@ public static Geometry createPhysicsTestSphere(AssetManager assetManager) { /** * creates an empty node with a RigidBodyControl - * @param manager - * @param shape - * @param mass - * @return + * + * @param manager for loading assets + * @param shape a shape for the collision object + * @param mass a mass for rigid body + * @return a new Node */ public static Node createPhysicsTestNode(AssetManager manager, CollisionShape shape, float mass) { Node node = new Node("PhysicsNode"); @@ -206,10 +211,12 @@ public static Node createPhysicsTestNode(AssetManager manager, CollisionShape sh } /** - * creates the necessary inputlistener and action to shoot balls from the camera - * @param app - * @param rootNode - * @param space + * creates the necessary inputlistener and action to shoot balls from the + * camera + * + * @param app the application that's running + * @param rootNode where ball geometries should be added + * @param space where collision objects should be added */ public static void createBallShooter(final Application app, final Node rootNode, final PhysicsSpace space) { ActionListener actionListener = new ActionListener() { diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestBoneRagdoll.java b/jme3-examples/src/main/java/jme3test/bullet/TestBoneRagdoll.java index 8b86f1b0c1..ee6e2f9978 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestBoneRagdoll.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestBoneRagdoll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,43 +31,51 @@ */ package jme3test.bullet; -import com.jme3.animation.*; +import com.jme3.anim.AnimComposer; +import com.jme3.anim.tween.Tweens; +import com.jme3.anim.tween.action.Action; import com.jme3.app.SimpleApplication; import com.jme3.asset.TextureKey; import com.jme3.bullet.BulletAppState; import com.jme3.bullet.PhysicsSpace; -import com.jme3.bullet.collision.*; +import com.jme3.bullet.animation.DynamicAnimControl; +import com.jme3.bullet.animation.PhysicsLink; +import com.jme3.bullet.animation.RagdollCollisionListener; +import com.jme3.bullet.collision.PhysicsCollisionEvent; +import com.jme3.bullet.collision.PhysicsCollisionObject; import com.jme3.bullet.collision.shapes.SphereCollisionShape; -import com.jme3.bullet.control.KinematicRagdollControl; import com.jme3.bullet.control.RigidBodyControl; import com.jme3.font.BitmapText; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; -import com.jme3.input.controls.*; +import com.jme3.input.controls.ActionListener; +import com.jme3.input.controls.KeyTrigger; +import com.jme3.input.controls.MouseButtonTrigger; import com.jme3.light.DirectionalLight; import com.jme3.material.Material; -import com.jme3.math.*; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Transform; +import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.Node; -import com.jme3.scene.debug.SkeletonDebugger; import com.jme3.scene.shape.Sphere; import com.jme3.scene.shape.Sphere.TextureMode; import com.jme3.texture.Texture; /** - * PHYSICS RAGDOLLS ARE NOT WORKING PROPERLY YET! * @author normenhansen */ -//TODO rework this Test when the new animation system is done. -public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisionListener, AnimEventListener { - - private BulletAppState bulletAppState; - Material matBullet; - Node model; - KinematicRagdollControl ragdoll; - float bulletSize = 1f; - Material mat; - Material mat3; +public class TestBoneRagdoll + extends SimpleApplication + implements ActionListener, RagdollCollisionListener { + + private AnimComposer composer; + private DynamicAnimControl ragdoll; + private float bulletSize = 1f; + private Material matBullet; + private Node model; + private PhysicsSpace physicsSpace; private Sphere bullet; private SphereCollisionShape bulletCollisionShape; @@ -76,276 +84,161 @@ public static void main(String[] args) { app.start(); } - public void simpleInitApp() { - initCrossHairs(); - initMaterial(); - - cam.setLocation(new Vector3f(0.26924422f, 6.646658f, 22.265987f)); - cam.setRotation(new Quaternion(-2.302544E-4f, 0.99302495f, -0.117888905f, -0.0019395084f)); + public void onStandDone() { + composer.setCurrentAction("IdleTop"); + } + @Override + public void onAction(String name, boolean isPressed, float tpf) { + if (name.equals("boom") && !isPressed) { + Geometry bulletg = new Geometry("bullet", bullet); + bulletg.setMaterial(matBullet); + bulletg.setLocalTranslation(cam.getLocation()); + bulletg.setLocalScale(bulletSize); + bulletCollisionShape = new SphereCollisionShape(bulletSize); + BombControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1f); + bulletNode.setForceFactor(8f); + bulletNode.setExplosionRadius(20f); + bulletNode.setCcdMotionThreshold(0.001f); + bulletNode.setLinearVelocity(cam.getDirection().mult(180f)); + bulletg.addControl(bulletNode); + rootNode.attachChild(bulletg); + physicsSpace.add(bulletNode); + } + if (name.equals("bullet+") && isPressed) { + bulletSize += 0.1f; + } + if (name.equals("bullet-") && isPressed) { + bulletSize -= 0.1f; + } + if (name.equals("shoot") && !isPressed) { + Geometry bulletg = new Geometry("bullet", bullet); + bulletg.setMaterial(matBullet); + bulletg.setLocalTranslation(cam.getLocation()); + bulletg.setLocalScale(bulletSize); + bulletCollisionShape = new SphereCollisionShape(bulletSize); + RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, bulletSize * 10f); + bulletNode.setCcdMotionThreshold(0.001f); + bulletNode.setLinearVelocity(cam.getDirection().mult(80f)); + bulletg.addControl(bulletNode); + rootNode.attachChild(bulletg); + physicsSpace.add(bulletNode); + } + if (name.equals("stop") && isPressed) { + ragdoll.setEnabled(!ragdoll.isEnabled()); + ragdoll.setRagdollMode(); + } + if (name.equals("toggle") && isPressed) { + Vector3f v = new Vector3f(model.getLocalTranslation()); + v.y = 0f; + Quaternion q = new Quaternion(); + float[] angles = new float[3]; + model.getLocalRotation().toAngles(angles); + q.fromAngleAxis(angles[1], Vector3f.UNIT_Y); + Transform endModelTransform + = new Transform(v, q, new Vector3f(1f, 1f, 1f)); + if (angles[0] < 0f) { + composer.setCurrentAction("BackOnce"); + ragdoll.blendToKinematicMode(0.5f, endModelTransform); + } else { + composer.setCurrentAction("FrontOnce"); + ragdoll.blendToKinematicMode(0.5f, endModelTransform); + } + } + } - bulletAppState = new BulletAppState(); - bulletAppState.setEnabled(true); - stateManager.attach(bulletAppState); - bullet = new Sphere(32, 32, 1.0f, true, false); - bullet.setTextureMode(TextureMode.Projected); - bulletCollisionShape = new SphereCollisionShape(1.0f); + @Override + public void simpleInitApp() { + flyCam.setMoveSpeed(50f); + cam.setLocation(new Vector3f(0.3f, 6.7f, 22.3f)); + cam.setRotation(new Quaternion(-2E-4f, 0.993025f, -0.1179f, -0.0019f)); -// bulletAppState.getPhysicsSpace().enableDebug(assetManager); - PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); + initCrossHairs(); + initMaterial(); + setupKeys(); setupLight(); - model = (Node) assetManager.loadModel("Models/Sinbad/SinbadOldAnim.j3o"); - - // model.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.HALF_PI, Vector3f.UNIT_X)); - - //debug view - AnimControl control = model.getControl(AnimControl.class); - SkeletonDebugger skeletonDebug = new SkeletonDebugger("skeleton", control.getSkeleton()); - Material mat2 = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md"); - mat2.getAdditionalRenderState().setWireframe(true); - mat2.setColor("Color", ColorRGBA.Green); - mat2.getAdditionalRenderState().setDepthTest(false); - skeletonDebug.setMaterial(mat2); - skeletonDebug.setLocalTranslation(model.getLocalTranslation()); - - //Note: PhysicsRagdollControl is still TODO, constructor will change - ragdoll = new KinematicRagdollControl(0.5f); - setupSinbad(ragdoll); - ragdoll.addCollisionListener(this); - model.addControl(ragdoll); - - float eighth_pi = FastMath.PI * 0.125f; - ragdoll.setJointLimit("Waist", eighth_pi, eighth_pi, eighth_pi, eighth_pi, eighth_pi, eighth_pi); - ragdoll.setJointLimit("Chest", eighth_pi, eighth_pi, 0, 0, eighth_pi, eighth_pi); - + BulletAppState bulletAppState = new BulletAppState(); + stateManager.attach(bulletAppState); + //bulletAppState.setDebugEnabled(true); + physicsSpace = bulletAppState.getPhysicsSpace(); - //Oto's head is almost rigid - // ragdoll.setJointLimit("head", 0, 0, eighth_pi, -eighth_pi, 0, 0); + bullet = new Sphere(32, 32, 1f, true, false); + bullet.setTextureMode(TextureMode.Projected); + bulletCollisionShape = new SphereCollisionShape(1f); - getPhysicsSpace().add(ragdoll); - speed = 1.3f; + PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, + physicsSpace); + model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml"); rootNode.attachChild(model); - // rootNode.attachChild(skeletonDebug); - flyCam.setMoveSpeed(50); - - - animChannel = control.createChannel(); - animChannel.setAnim("Dance"); - control.addListener(this); - - inputManager.addListener(new ActionListener() { - - public void onAction(String name, boolean isPressed, float tpf) { - if (name.equals("toggle") && isPressed) { - - Vector3f v = new Vector3f(); - v.set(model.getLocalTranslation()); - v.y = 0; - model.setLocalTranslation(v); - Quaternion q = new Quaternion(); - float[] angles = new float[3]; - model.getLocalRotation().toAngles(angles); - q.fromAngleAxis(angles[1], Vector3f.UNIT_Y); - model.setLocalRotation(q); - if (angles[0] < 0) { - animChannel.setAnim("StandUpBack"); - ragdoll.blendToKinematicMode(0.5f); - } else { - animChannel.setAnim("StandUpFront"); - ragdoll.blendToKinematicMode(0.5f); - } - } - if (name.equals("bullet+") && isPressed) { - bulletSize += 0.1f; - - } - if (name.equals("bullet-") && isPressed) { - bulletSize -= 0.1f; - - } - - if (name.equals("stop") && isPressed) { - ragdoll.setEnabled(!ragdoll.isEnabled()); - ragdoll.setRagdollMode(); - } - - if (name.equals("shoot") && !isPressed) { - Geometry bulletg = new Geometry("bullet", bullet); - bulletg.setMaterial(matBullet); - bulletg.setLocalTranslation(cam.getLocation()); - bulletg.setLocalScale(bulletSize); - bulletCollisionShape = new SphereCollisionShape(bulletSize); - RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, bulletSize * 10); - bulletNode.setCcdMotionThreshold(0.001f); - bulletNode.setLinearVelocity(cam.getDirection().mult(80)); - bulletg.addControl(bulletNode); - rootNode.attachChild(bulletg); - getPhysicsSpace().add(bulletNode); - } - if (name.equals("boom") && !isPressed) { - Geometry bulletg = new Geometry("bullet", bullet); - bulletg.setMaterial(matBullet); - bulletg.setLocalTranslation(cam.getLocation()); - bulletg.setLocalScale(bulletSize); - bulletCollisionShape = new SphereCollisionShape(bulletSize); - BombControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); - bulletNode.setForceFactor(8); - bulletNode.setExplosionRadius(20); - bulletNode.setCcdMotionThreshold(0.001f); - bulletNode.setLinearVelocity(cam.getDirection().mult(180)); - bulletg.addControl(bulletNode); - rootNode.attachChild(bulletg); - getPhysicsSpace().add(bulletNode); - } - } - }, "toggle", "shoot", "stop", "bullet+", "bullet-", "boom"); - inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE)); - inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); - inputManager.addMapping("boom", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); - inputManager.addMapping("stop", new KeyTrigger(KeyInput.KEY_H)); - inputManager.addMapping("bullet-", new KeyTrigger(KeyInput.KEY_COMMA)); - inputManager.addMapping("bullet+", new KeyTrigger(KeyInput.KEY_PERIOD)); + composer = model.getControl(AnimComposer.class); + composer.setCurrentAction("Dance"); + Action standUpFront = composer.action("StandUpFront"); + composer.actionSequence("FrontOnce", + standUpFront, Tweens.callMethod(this, "onStandDone")); + Action standUpBack = composer.action("StandUpBack"); + composer.actionSequence("BackOnce", + standUpBack, Tweens.callMethod(this, "onStandDone")); + ragdoll = new DynamicAnimControl(); + TestRagdollCharacter.setupSinbad(ragdoll); + model.addControl(ragdoll); + physicsSpace.add(ragdoll); + ragdoll.addCollisionListener(this); } - private void setupLight() { - // AmbientLight al = new AmbientLight(); - // al.setColor(ColorRGBA.White.mult(1)); - // rootNode.addLight(al); - - DirectionalLight dl = new DirectionalLight(); - dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); - dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); - rootNode.addLight(dl); - } - - private PhysicsSpace getPhysicsSpace() { - return bulletAppState.getPhysicsSpace(); - } - - public void initMaterial() { - - matBullet = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); - TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); - key2.setGenerateMips(true); - Texture tex2 = assetManager.loadTexture(key2); - matBullet.setTexture("ColorMap", tex2); + @Override + public void collide(PhysicsLink bone, PhysicsCollisionObject object, + PhysicsCollisionEvent event) { + if (object.getUserObject() != null + && object.getUserObject() instanceof Geometry) { + Geometry geom = (Geometry) object.getUserObject(); + if ("bullet".equals(geom.getName())) { + ragdoll.setRagdollMode(); + } + } } - protected void initCrossHairs() { + private void initCrossHairs() { guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt"); BitmapText ch = new BitmapText(guiFont, false); - ch.setSize(guiFont.getCharSet().getRenderedSize() * 2); + ch.setSize(guiFont.getCharSet().getRenderedSize() * 2f); ch.setText("+"); // crosshairs ch.setLocalTranslation( // center - settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, - settings.getHeight() / 2 + ch.getLineHeight() / 2, 0); + settings.getWidth() / 2f - guiFont.getCharSet().getRenderedSize() / 3f * 2f, + settings.getHeight() / 2f + ch.getLineHeight() / 2f, 0f); guiNode.attachChild(ch); } - public void collide(Bone bone, PhysicsCollisionObject object, PhysicsCollisionEvent event) { - - if (object.getUserObject() != null && object.getUserObject() instanceof Geometry) { - Geometry geom = (Geometry) object.getUserObject(); - if ("Floor".equals(geom.getName())) { - return; - } - } - - ragdoll.setRagdollMode(); - - } - - private void setupSinbad(KinematicRagdollControl ragdoll) { - ragdoll.addBoneName("Ulna.L"); - ragdoll.addBoneName("Ulna.R"); - ragdoll.addBoneName("Chest"); - ragdoll.addBoneName("Foot.L"); - ragdoll.addBoneName("Foot.R"); - ragdoll.addBoneName("Hand.R"); - ragdoll.addBoneName("Hand.L"); - ragdoll.addBoneName("Neck"); - ragdoll.addBoneName("Root"); - ragdoll.addBoneName("Stomach"); - ragdoll.addBoneName("Waist"); - ragdoll.addBoneName("Humerus.L"); - ragdoll.addBoneName("Humerus.R"); - ragdoll.addBoneName("Thigh.L"); - ragdoll.addBoneName("Thigh.R"); - ragdoll.addBoneName("Calf.L"); - ragdoll.addBoneName("Calf.R"); - ragdoll.addBoneName("Clavicle.L"); - ragdoll.addBoneName("Clavicle.R"); - - } - float elTime = 0; - boolean forward = true; - AnimControl animControl; - AnimChannel animChannel; - Vector3f direction = new Vector3f(0, 0, 1); - Quaternion rotate = new Quaternion().fromAngleAxis(FastMath.PI / 8, Vector3f.UNIT_Y); - boolean dance = true; - - @Override - public void simpleUpdate(float tpf) { - // System.out.println(((BoundingBox) model.getWorldBound()).getYExtent()); -// elTime += tpf; -// if (elTime > 3) { -// elTime = 0; -// if (dance) { -// rotate.multLocal(direction); -// } -// if (Math.random() > 0.80) { -// dance = true; -// animChannel.setAnim("Dance"); -// } else { -// dance = false; -// animChannel.setAnim("RunBase"); -// rotate.fromAngleAxis(FastMath.QUARTER_PI * ((float) Math.random() - 0.5f), Vector3f.UNIT_Y); -// rotate.multLocal(direction); -// } -// } -// if (!ragdoll.hasControl() && !dance) { -// if (model.getLocalTranslation().getZ() < -10) { -// direction.z = 1; -// direction.normalizeLocal(); -// } else if (model.getLocalTranslation().getZ() > 10) { -// direction.z = -1; -// direction.normalizeLocal(); -// } -// if (model.getLocalTranslation().getX() < -10) { -// direction.x = 1; -// direction.normalizeLocal(); -// } else if (model.getLocalTranslation().getX() > 10) { -// direction.x = -1; -// direction.normalizeLocal(); -// } -// model.move(direction.multLocal(tpf * 8)); -// direction.normalizeLocal(); -// model.lookAt(model.getLocalTranslation().add(direction), Vector3f.UNIT_Y); -// } + private void initMaterial() { + matBullet = new Material(assetManager, + "Common/MatDefs/Misc/Unshaded.j3md"); + TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG"); + key2.setGenerateMips(true); + Texture tex2 = assetManager.loadTexture(key2); + matBullet.setTexture("ColorMap", tex2); } - public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { -// if(channel.getAnimationName().equals("StandUpFront")){ -// channel.setAnim("Dance"); -// } + private void setupKeys() { + inputManager.addMapping("boom", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT)); + inputManager.addMapping("bullet+", new KeyTrigger(KeyInput.KEY_PERIOD)); + inputManager.addMapping("bullet-", new KeyTrigger(KeyInput.KEY_COMMA)); + inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); + inputManager.addMapping("stop", new KeyTrigger(KeyInput.KEY_H)); + inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE)); - if (channel.getAnimationName().equals("StandUpBack") || channel.getAnimationName().equals("StandUpFront")) { - channel.setLoopMode(LoopMode.DontLoop); - channel.setAnim("IdleTop", 5); - channel.setLoopMode(LoopMode.Loop); - } -// if(channel.getAnimationName().equals("IdleTop")){ -// channel.setAnim("StandUpFront"); -// } + inputManager.addListener(this, + "boom", "bullet-", "bullet+", "shoot", "stop", "toggle"); } - public void onAnimChange(AnimControl control, AnimChannel channel, String animName) { + private void setupLight() { + DirectionalLight dl = new DirectionalLight(); + dl.setDirection(new Vector3f(-0.1f, -0.7f, -1f).normalizeLocal()); + dl.setColor(new ColorRGBA(1f, 1f, 1f, 1f)); + rootNode.addLight(dl); } } diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestFancyCar.java b/jme3-examples/src/main/java/jme3test/bullet/TestFancyCar.java index d628d4616a..3803c4c5d4 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestFancyCar.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestFancyCar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,7 +31,6 @@ */ package jme3test.bullet; -import com.jme3.app.SettingsDialog; import com.jme3.app.SimpleApplication; import com.jme3.bounding.BoundingBox; import com.jme3.bullet.BulletAppState; @@ -51,7 +50,6 @@ import com.jme3.scene.Geometry; import com.jme3.scene.Node; import com.jme3.scene.Spatial; -import com.jme3.system.AppSettings; public class TestFancyCar extends SimpleApplication implements ActionListener { diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java b/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java index a241072a24..c247bfe854 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java @@ -56,7 +56,6 @@ import com.jme3.scene.Spatial; import com.jme3.shadow.DirectionalLightShadowRenderer; import com.jme3.shadow.EdgeFilteringMode; -import com.jme3.system.AppSettings; import com.jme3.terrain.geomipmap.TerrainLodControl; import com.jme3.terrain.geomipmap.TerrainQuad; import com.jme3.terrain.heightmap.AbstractHeightMap; diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestIK.java b/jme3-examples/src/main/java/jme3test/bullet/TestIK.java deleted file mode 100644 index 43313e7892..0000000000 --- a/jme3-examples/src/main/java/jme3test/bullet/TestIK.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2009-2010 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package jme3test.bullet; - -import com.jme3.animation.AnimEventListener; -import com.jme3.animation.Bone; -import com.jme3.bullet.collision.RagdollCollisionListener; -import com.jme3.bullet.control.KinematicRagdollControl; -import com.jme3.input.KeyInput; -import com.jme3.input.controls.ActionListener; -import com.jme3.input.controls.KeyTrigger; -import com.jme3.math.Vector3f; -import com.jme3.scene.Node; - -/** - * @author reden - */ -public class TestIK extends TestBoneRagdoll implements RagdollCollisionListener, AnimEventListener { - - Node targetNode = new Node(""); - Vector3f targetPoint; - Bone mouseBone; - Vector3f oldMousePos; - - public static void main(String[] args) { - TestIK app = new TestIK(); - app.start(); - } - - @Override - public void simpleInitApp() { - super.simpleInitApp(); - final KinematicRagdollControl ikControl = model.getControl(KinematicRagdollControl.class); - inputManager.addListener(new ActionListener() { - - public void onAction(String name, boolean isPressed, float tpf) { - - if (name.equals("stop") && isPressed) { - ikControl.setEnabled(!ikControl.isEnabled()); - ikControl.setIKMode(); - } - - if (name.equals("one") && isPressed) { - //ragdoll.setKinematicMode(); - targetPoint = model.getWorldTranslation().add(new Vector3f(0,2,4)); - targetNode.setLocalTranslation(targetPoint); - ikControl.setIKTarget(ikControl.getBone("Hand.L"), targetPoint, 2); - ikControl.setIKMode(); - } - if (name.equals("two") && isPressed) { - //ragdoll.setKinematicMode(); - targetPoint = model.getWorldTranslation().add(new Vector3f(-3,3,0)); - targetNode.setLocalTranslation(targetPoint); - ikControl.setIKTarget(ikControl.getBone("Hand.R"), targetPoint, 3); - ikControl.setIKMode(); - } - } - }, "one", "two"); - inputManager.addMapping("one", new KeyTrigger(KeyInput.KEY_1)); - inputManager.addMapping("two", new KeyTrigger(KeyInput.KEY_2)); - inputManager.addMapping("stop", new KeyTrigger(KeyInput.KEY_H)); - } - -} diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestIssue1004.java b/jme3-examples/src/main/java/jme3test/bullet/TestIssue1004.java new file mode 100644 index 0000000000..0379fadab1 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/bullet/TestIssue1004.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jme3test.bullet; + +import com.jme3.app.SimpleApplication; +import com.jme3.bullet.BulletAppState; +import com.jme3.bullet.control.KinematicRagdollControl; +import com.jme3.scene.Geometry; +import com.jme3.scene.Mesh; +import com.jme3.scene.Node; +import com.jme3.scene.VertexBuffer; +import java.nio.ByteBuffer; + +/** + * Test case for JME issue #1004: RagdollUtils can't handle 16-bit bone indices. + *

        + * If successful, no exception will be thrown. + */ +public class TestIssue1004 extends SimpleApplication { + // ************************************************************************* + // new methods exposed + + public static void main(String[] args) { + TestIssue1004 app = new TestIssue1004(); + app.start(); + } + // ************************************************************************* + // SimpleApplication methods + + @Override + public void simpleInitApp() { + BulletAppState bulletAppState = new BulletAppState(); + stateManager.attach(bulletAppState); + String sinbadPath = "Models/Sinbad/SinbadOldAnim.j3o"; + Node sinbad = (Node) assetManager.loadModel(sinbadPath); + + Geometry geometry = (Geometry) sinbad.getChild(0); + Mesh mesh = geometry.getMesh(); + VertexBuffer.Type bufferType = VertexBuffer.Type.BoneIndex; + VertexBuffer vertexBuffer = mesh.getBuffer(bufferType); + + // Remove the existing bone-index buffer. + mesh.getBufferList().remove(vertexBuffer); + mesh.getBuffers().remove(bufferType.ordinal()); + + // Copy the 8-bit bone indices to 16-bit indices. + ByteBuffer oldBuffer = (ByteBuffer) vertexBuffer.getDataReadOnly(); + int numComponents = oldBuffer.limit(); + oldBuffer.rewind(); + short[] shortArray = new short[numComponents]; + for (int index = 0; oldBuffer.hasRemaining(); ++index) { + shortArray[index] = oldBuffer.get(); + } + + // Add the 16-bit bone indices to the mesh. + mesh.setBuffer(bufferType, 4, shortArray); + + KinematicRagdollControl ragdoll = new KinematicRagdollControl(0.5f); + sinbad.addControl(ragdoll); + + stop(); + } +} diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestIssue1029.java b/jme3-examples/src/main/java/jme3test/bullet/TestIssue1029.java new file mode 100644 index 0000000000..fa3546f61b --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/bullet/TestIssue1029.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jme3test.bullet; + +import com.jme3.app.Application; +import com.jme3.app.SimpleApplication; +import com.jme3.bullet.BulletAppState; +import com.jme3.bullet.PhysicsSpace; +import com.jme3.bullet.collision.PhysicsCollisionEvent; +import com.jme3.bullet.collision.PhysicsCollisionListener; +import com.jme3.bullet.collision.shapes.CollisionShape; +import com.jme3.bullet.collision.shapes.SphereCollisionShape; +import com.jme3.bullet.objects.PhysicsGhostObject; +import com.jme3.bullet.objects.PhysicsRigidBody; + +/** + * Test case for JME issue #1029: sphere-sphere collisions not reported. + *

        + * If successful, the app will terminate normally, without a RuntimeException. + * + * @author Stephen Gold sgold@sonic.net + */ +public class TestIssue1029 + extends SimpleApplication + implements PhysicsCollisionListener { + + private double elapsedSeconds = 0.0; + + public static void main(String[] arguments) { + Application application = new TestIssue1029(); + application.start(); + } + + @Override + public void simpleInitApp() { + BulletAppState bulletAppState = new BulletAppState(); + stateManager.attach(bulletAppState); + bulletAppState.setDebugEnabled(true); + + PhysicsSpace physicsSpace = bulletAppState.getPhysicsSpace(); + physicsSpace.addCollisionListener(this); + + CollisionShape shape; + shape = new SphereCollisionShape(1f); + //shape = new BoxCollisionShape(new Vector3f(1f, 1f, 1f)); + + PhysicsRigidBody staticBody = new PhysicsRigidBody(shape, 0f); + physicsSpace.add(staticBody); + + PhysicsGhostObject ghost = new PhysicsGhostObject(shape); + physicsSpace.add(ghost); + } + + @Override + public void simpleUpdate(float tpf) { + super.simpleUpdate(tpf); + + elapsedSeconds += tpf; + if (elapsedSeconds > 1.0) { + throw new RuntimeException("No collisions reported!"); + } + } + + @Override + public void collision(PhysicsCollisionEvent event) { + Class aClass = event.getObjectA().getCollisionShape().getClass(); + String aShape = aClass.getSimpleName().replace("CollisionShape", ""); + Class bClass = event.getObjectB().getCollisionShape().getClass(); + String bShape = bClass.getSimpleName().replace("CollisionShape", ""); + + System.out.printf("%s-%s collision reported at t = %f sec%n", + aShape, bShape, elapsedSeconds); + stop(); + } +} diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestIssue970.java b/jme3-examples/src/main/java/jme3test/bullet/TestIssue970.java new file mode 100644 index 0000000000..c94d46c474 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/bullet/TestIssue970.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2018 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jme3test.bullet; + +import com.jme3.app.SimpleApplication; +import com.jme3.asset.AssetNotFoundException; +import com.jme3.asset.ModelKey; +import com.jme3.asset.plugins.FileLocator; +import com.jme3.bullet.collision.shapes.CollisionShape; +import com.jme3.bullet.collision.shapes.SphereCollisionShape; +import com.jme3.bullet.control.RigidBodyControl; +import com.jme3.bullet.objects.PhysicsRigidBody; +import com.jme3.export.JmeExporter; +import com.jme3.export.binary.BinaryExporter; +import com.jme3.math.Matrix3f; +import com.jme3.math.Vector3f; +import com.jme3.scene.Node; +import com.jme3.scene.Spatial; +import com.jme3.scene.control.Control; +import java.io.File; +import java.io.IOException; + +/** + * Test case for JME issue #970: RigidBodyControl doesn't read/write velocities. + * + * If successful, no AssertionError will be thrown. + * + * @author Stephen Gold sgold@sonic.net + */ +public class TestIssue970 extends SimpleApplication { + + private int fileIndex = 0; + + public static void main(String[] args) { + TestIssue970 app = new TestIssue970(); + app.start(); + } + + @Override + public void simpleInitApp() { + assetManager.registerLocator(".", FileLocator.class); + + CollisionShape shape = new SphereCollisionShape(1f); + RigidBodyControl rbc = new RigidBodyControl(shape, 1f); + setParameters(rbc); + verifyParameters(rbc); + RigidBodyControl rbcCopy = (RigidBodyControl) saveThenLoad(rbc); + verifyParameters(rbcCopy); + + stop(); + } + + /** + * Clone a body that implements Control by saving and then loading it. + * + * @param sgc the body/control to copy (not null, unaffected) + * @return a new body/control + */ + private PhysicsRigidBody saveThenLoad(PhysicsRigidBody body) { + Control sgc = (Control) body; + Node savedNode = new Node(); + /* + * Add the Control to the Node without altering its physics transform. + */ + Vector3f pl = body.getPhysicsLocation(null); + Matrix3f pr = body.getPhysicsRotationMatrix(null); + savedNode.addControl(sgc); + body.setPhysicsLocation(pl); + body.setPhysicsRotation(pr); + + String fileName = String.format("tmp%d.j3o", ++fileIndex); + File file = new File(fileName); + + JmeExporter exporter = BinaryExporter.getInstance(); + try { + exporter.save(savedNode, file); + } catch (IOException exception) { + assert false; + } + + ModelKey key = new ModelKey(fileName); + Spatial loadedNode = new Node(); + try { + loadedNode = assetManager.loadAsset(key); + } catch (AssetNotFoundException e) { + assert false; + } + file.delete(); + Control loadedSgc = loadedNode.getControl(0); + + return (PhysicsRigidBody) loadedSgc; + } + + private void setParameters(PhysicsRigidBody body) { + body.setAngularVelocity(new Vector3f(0.04f, 0.05f, 0.06f)); + body.setLinearVelocity(new Vector3f(0.26f, 0.27f, 0.28f)); + } + + private void verifyParameters(PhysicsRigidBody body) { + Vector3f w = body.getAngularVelocity(); + assert w.x == 0.04f : w; + assert w.y == 0.05f : w; + assert w.z == 0.06f : w; + + Vector3f v = body.getLinearVelocity(); + assert v.x == 0.26f : v; + assert v.y == 0.27f : v; + assert v.z == 0.28f : v; + } +} diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestPhysicsCharacter.java b/jme3-examples/src/main/java/jme3test/bullet/TestPhysicsCharacter.java index 235f5d291c..3a75ad5120 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestPhysicsCharacter.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestPhysicsCharacter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine All rights reserved.

        + * Copyright (c) 2009-2019 jMonkeyEngine All rights reserved.

        * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * @@ -139,10 +139,10 @@ public void simpleUpdate(float tpf) { walkDirection.addLocal(camLeft.negate()); } if (leftRotate) { - viewDirection.addLocal(camLeft.mult(0.02f)); + viewDirection.addLocal(camLeft.mult(tpf)); } else if (rightRotate) { - viewDirection.addLocal(camLeft.mult(0.02f).negate()); + viewDirection.addLocal(camLeft.mult(tpf).negate()); } if (forward) { walkDirection.addLocal(camDir); diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestRagdollCharacter.java b/jme3-examples/src/main/java/jme3test/bullet/TestRagdollCharacter.java index f94307d6e2..e84d3b9a3d 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestRagdollCharacter.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestRagdollCharacter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,19 +31,25 @@ */ package jme3test.bullet; -import com.jme3.animation.*; +import com.jme3.anim.AnimComposer; +import com.jme3.anim.tween.Tweens; +import com.jme3.anim.tween.action.Action; import com.jme3.app.SimpleApplication; import com.jme3.asset.TextureKey; import com.jme3.bullet.BulletAppState; import com.jme3.bullet.PhysicsSpace; -import com.jme3.bullet.control.KinematicRagdollControl; +import com.jme3.bullet.animation.DynamicAnimControl; +import com.jme3.bullet.animation.RangeOfMotion; import com.jme3.bullet.control.RigidBodyControl; import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; import com.jme3.light.DirectionalLight; import com.jme3.material.Material; -import com.jme3.math.*; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Quaternion; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Geometry; import com.jme3.scene.Node; @@ -53,101 +59,153 @@ /** * @author normenhansen */ -//TODO rework this Test when the new animation system is done. -public class TestRagdollCharacter extends SimpleApplication implements AnimEventListener, ActionListener { +public class TestRagdollCharacter + extends SimpleApplication + implements ActionListener { - BulletAppState bulletAppState; - Node model; - KinematicRagdollControl ragdoll; - boolean leftStrafe = false, rightStrafe = false, forward = false, backward = false, + private AnimComposer composer; + private boolean forward = false, backward = false, leftRotate = false, rightRotate = false; - AnimControl animControl; - AnimChannel animChannel; + private DynamicAnimControl ragdoll; + private Node model; + private PhysicsSpace physicsSpace; public static void main(String[] args) { TestRagdollCharacter app = new TestRagdollCharacter(); app.start(); } - public void simpleInitApp() { - setupKeys(); - - bulletAppState = new BulletAppState(); - bulletAppState.setEnabled(true); - stateManager.attach(bulletAppState); + public void onSliceDone() { + composer.setCurrentAction("IdleTop"); + } + static void setupSinbad(DynamicAnimControl ragdoll) { + ragdoll.link("Waist", 1f, + new RangeOfMotion(1f, -0.4f, 0.8f, -0.8f, 0.4f, -0.4f)); + ragdoll.link("Chest", 1f, new RangeOfMotion(0.4f, 0f, 0.4f)); + ragdoll.link("Neck", 1f, new RangeOfMotion(0.5f, 1f, 0.7f)); + + ragdoll.link("Clavicle.R", 1f, + new RangeOfMotion(0.3f, -0.6f, 0f, 0f, 0.4f, -0.4f)); + ragdoll.link("Humerus.R", 1f, + new RangeOfMotion(1.6f, -0.8f, 1f, -1f, 1.6f, -1f)); + ragdoll.link("Ulna.R", 1f, new RangeOfMotion(0f, 0f, 1f, -1f, 0f, -2f)); + ragdoll.link("Hand.R", 1f, new RangeOfMotion(0.8f, 0f, 0.2f)); + + ragdoll.link("Clavicle.L", 1f, + new RangeOfMotion(0.6f, -0.3f, 0f, 0f, 0.4f, -0.4f)); + ragdoll.link("Humerus.L", + 1f, new RangeOfMotion(0.8f, -1.6f, 1f, -1f, 1f, -1.6f)); + ragdoll.link("Ulna.L", 1f, new RangeOfMotion(0f, 0f, 1f, -1f, 2f, 0f)); + ragdoll.link("Hand.L", 1f, new RangeOfMotion(0.8f, 0f, 0.2f)); + + ragdoll.link("Thigh.R", 1f, + new RangeOfMotion(0.4f, -1f, 0.4f, -0.4f, 1f, -0.5f)); + ragdoll.link("Calf.R", 1f, new RangeOfMotion(2f, 0f, 0f, 0f, 0f, 0f)); + ragdoll.link("Foot.R", 1f, new RangeOfMotion(0.3f, 0.5f, 0f)); + + ragdoll.link("Thigh.L", 1f, + new RangeOfMotion(0.4f, -1f, 0.4f, -0.4f, 0.5f, -1f)); + ragdoll.link("Calf.L", 1f, new RangeOfMotion(2f, 0f, 0f, 0f, 0f, 0f)); + ragdoll.link("Foot.L", 1f, new RangeOfMotion(0.3f, 0.5f, 0f)); + } -// bulletAppState.getPhysicsSpace().enableDebug(assetManager); - PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); - initWall(2,1,1); - setupLight(); + @Override + public void onAction(String binding, boolean isPressed, float tpf) { + if (binding.equals("Rotate Left")) { + if (isPressed) { + leftRotate = true; + } else { + leftRotate = false; + } + } else if (binding.equals("Rotate Right")) { + if (isPressed) { + rightRotate = true; + } else { + rightRotate = false; + } + } else if (binding.equals("Slice")) { + if (isPressed) { + composer.setCurrentAction("SliceOnce"); + } + } else if (binding.equals("Walk Forward")) { + if (isPressed) { + forward = true; + } else { + forward = false; + } + } else if (binding.equals("Walk Backward")) { + if (isPressed) { + backward = true; + } else { + backward = false; + } + } + } - cam.setLocation(new Vector3f(-8,0,-4)); - cam.lookAt(new Vector3f(4,0,-7), Vector3f.UNIT_Y); + @Override + public void simpleInitApp() { + flyCam.setMoveSpeed(50f); + cam.setLocation(new Vector3f(-16f, 4.7f, -1.6f)); + cam.setRotation(new Quaternion(0.0484f, 0.804337f, -0.066f, 0.5885f)); - model = (Node) assetManager.loadModel("Models/Sinbad/SinbadOldAnim.j3o"); - model.lookAt(new Vector3f(0,0,-1), Vector3f.UNIT_Y); - model.setLocalTranslation(4, 0, -7f); + setupKeys(); + setupLight(); - ragdoll = new KinematicRagdollControl(0.5f); - model.addControl(ragdoll); + BulletAppState bulletAppState = new BulletAppState(); + stateManager.attach(bulletAppState); + //bulletAppState.setDebugEnabled(true); + physicsSpace = bulletAppState.getPhysicsSpace(); - getPhysicsSpace().add(ragdoll); - speed = 1.3f; + PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, + physicsSpace); + initWall(2f, 1f, 1f); + model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml"); rootNode.attachChild(model); + model.lookAt(new Vector3f(0f, 0f, -1f), Vector3f.UNIT_Y); + model.setLocalTranslation(4f, 0f, -7f); + composer = model.getControl(AnimComposer.class); + composer.setCurrentAction("IdleTop"); - AnimControl control = model.getControl(AnimControl.class); - animChannel = control.createChannel(); - animChannel.setAnim("IdleTop"); - control.addListener(this); + Action slice = composer.action("SliceHorizontal"); + composer.actionSequence("SliceOnce", + slice, Tweens.callMethod(this, "onSliceDone")); + ragdoll = new DynamicAnimControl(); + setupSinbad(ragdoll); + model.addControl(ragdoll); + physicsSpace.add(ragdoll); } - private void setupLight() { - DirectionalLight dl = new DirectionalLight(); - dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal()); - dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f)); - rootNode.addLight(dl); - } - - private PhysicsSpace getPhysicsSpace() { - return bulletAppState.getPhysicsSpace(); - } - - private void setupKeys() { - inputManager.addMapping("Rotate Left", - new KeyTrigger(KeyInput.KEY_H)); - inputManager.addMapping("Rotate Right", - new KeyTrigger(KeyInput.KEY_K)); - inputManager.addMapping("Walk Forward", - new KeyTrigger(KeyInput.KEY_U)); - inputManager.addMapping("Walk Backward", - new KeyTrigger(KeyInput.KEY_J)); - inputManager.addMapping("Slice", - new KeyTrigger(KeyInput.KEY_SPACE), - new KeyTrigger(KeyInput.KEY_RETURN)); - inputManager.addListener(this, "Strafe Left", "Strafe Right"); - inputManager.addListener(this, "Rotate Left", "Rotate Right"); - inputManager.addListener(this, "Walk Forward", "Walk Backward"); - inputManager.addListener(this, "Slice"); + @Override + public void simpleUpdate(float tpf) { + if (forward) { + model.move(model.getLocalRotation().multLocal(new Vector3f(0f, 0f, tpf))); + } else if (backward) { + model.move(model.getLocalRotation().multLocal(new Vector3f(0f, 0f, -tpf))); + } else if (leftRotate) { + model.rotate(0f, tpf, 0f); + } else if (rightRotate) { + model.rotate(0f, -tpf, 0f); + } } - public void initWall(float bLength, float bWidth, float bHeight) { + private void initWall(float bLength, float bWidth, float bHeight) { Box brick = new Box(bLength, bHeight, bWidth); - brick.scaleTextureCoordinates(new Vector2f(1f, .5f)); + brick.scaleTextureCoordinates(new Vector2f(1f, 0.5f)); Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg"); key.setGenerateMips(true); Texture tex = assetManager.loadTexture(key); mat2.setTexture("ColorMap", tex); - - float startpt = bLength / 4; - float height = -5; + + float startpt = bLength / 4f; + float height = -5f; for (int j = 0; j < 15; j++) { for (int i = 0; i < 4; i++) { - Vector3f ori = new Vector3f(i * bLength * 2 + startpt, bHeight + height, -10); + Vector3f ori = new Vector3f(i * bLength * 2f + startpt, bHeight + height, -10f); Geometry reBoxg = new Geometry("brick", brick); reBoxg.setMaterial(mat2); reBoxg.setLocalTranslation(ori); @@ -156,71 +214,34 @@ public void initWall(float bLength, float bWidth, float bHeight) { reBoxg.setShadowMode(ShadowMode.CastAndReceive); reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f); this.rootNode.attachChild(reBoxg); - this.getPhysicsSpace().add(reBoxg); + physicsSpace.add(reBoxg); } startpt = -startpt; - height += 2 * bHeight; + height += 2f * bHeight; } } - public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) { - - if (channel.getAnimationName().equals("SliceHorizontal")) { - channel.setLoopMode(LoopMode.DontLoop); - channel.setAnim("IdleTop", 5); - channel.setLoopMode(LoopMode.Loop); - } - - } + private void setupKeys() { + inputManager.addMapping("Rotate Left", + new KeyTrigger(KeyInput.KEY_H)); + inputManager.addMapping("Rotate Right", + new KeyTrigger(KeyInput.KEY_K)); + inputManager.addMapping("Walk Backward", + new KeyTrigger(KeyInput.KEY_J)); + inputManager.addMapping("Walk Forward", + new KeyTrigger(KeyInput.KEY_U)); + inputManager.addMapping("Slice", + new KeyTrigger(KeyInput.KEY_SPACE), + new KeyTrigger(KeyInput.KEY_RETURN)); - public void onAnimChange(AnimControl control, AnimChannel channel, String animName) { - } - - public void onAction(String binding, boolean value, float tpf) { - if (binding.equals("Rotate Left")) { - if (value) { - leftRotate = true; - } else { - leftRotate = false; - } - } else if (binding.equals("Rotate Right")) { - if (value) { - rightRotate = true; - } else { - rightRotate = false; - } - } else if (binding.equals("Walk Forward")) { - if (value) { - forward = true; - } else { - forward = false; - } - } else if (binding.equals("Walk Backward")) { - if (value) { - backward = true; - } else { - backward = false; - } - } else if (binding.equals("Slice")) { - if (value) { - animChannel.setAnim("SliceHorizontal"); - animChannel.setSpeed(0.3f); - } - } + inputManager.addListener(this, "Rotate Left", "Rotate Right", "Slice", + "Walk Backward", "Walk Forward"); } - @Override - public void simpleUpdate(float tpf) { - if(forward){ - model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(tpf)); - }else if(backward){ - model.move(model.getLocalRotation().multLocal(new Vector3f(0,0,1)).multLocal(-tpf)); - }else if(leftRotate){ - model.rotate(0, tpf, 0); - }else if(rightRotate){ - model.rotate(0, -tpf, 0); - } - fpsText.setText(cam.getLocation() + "/" + cam.getRotation()); + private void setupLight() { + DirectionalLight dl = new DirectionalLight(); + dl.setDirection(new Vector3f(-0.1f, -0.7f, -1f).normalizeLocal()); + dl.setColor(new ColorRGBA(1f, 1f, 1f, 1f)); + rootNode.addLight(dl); } - } diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestSweepTest.java b/jme3-examples/src/main/java/jme3test/bullet/TestSweepTest.java index da9089cec3..2086950c6a 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestSweepTest.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestSweepTest.java @@ -15,8 +15,7 @@ * A spatial moves and sweeps its next movement for obstacles before moving * there Run this example with Vsync enabled * - * @author - * @wezrule + * @author wezrule */ public class TestSweepTest extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/conversion/TestMipMapGen.java b/jme3-examples/src/main/java/jme3test/conversion/TestMipMapGen.java index 55fc152f7b..6110469ee0 100644 --- a/jme3-examples/src/main/java/jme3test/conversion/TestMipMapGen.java +++ b/jme3-examples/src/main/java/jme3test/conversion/TestMipMapGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,7 @@ import com.jme3.scene.shape.Quad; import com.jme3.texture.Image; import com.jme3.texture.Texture; -import jme3tools.converters.MipMapGenerator; +import com.jme3.util.MipMapGenerator; public class TestMipMapGen extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/effect/TestEverything.java b/jme3-examples/src/main/java/jme3test/effect/TestEverything.java index 62f06a4227..4d0da65c5a 100644 --- a/jme3-examples/src/main/java/jme3test/effect/TestEverything.java +++ b/jme3-examples/src/main/java/jme3test/effect/TestEverything.java @@ -47,7 +47,6 @@ import com.jme3.scene.shape.Box; import com.jme3.shadow.DirectionalLightShadowRenderer; import com.jme3.texture.Texture; -import com.jme3.texture.Texture.WrapMode; import com.jme3.util.SkyFactory; import com.jme3.util.TangentBinormalGenerator; diff --git a/jme3-examples/src/main/java/jme3test/effect/TestParticleExportingCloning.java b/jme3-examples/src/main/java/jme3test/effect/TestParticleExportingCloning.java index d38fdbdf9f..4b75b1e76c 100644 --- a/jme3-examples/src/main/java/jme3test/effect/TestParticleExportingCloning.java +++ b/jme3-examples/src/main/java/jme3test/effect/TestParticleExportingCloning.java @@ -37,11 +37,8 @@ import com.jme3.effect.ParticleMesh.Type; import com.jme3.effect.shapes.EmitterSphereShape; import com.jme3.export.binary.BinaryExporter; -import com.jme3.export.binary.BinaryImporter; import com.jme3.material.Material; import com.jme3.math.Vector3f; -import java.io.ByteArrayOutputStream; -import java.io.IOException; public class TestParticleExportingCloning extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/export/TestAssetLinkNode.java b/jme3-examples/src/main/java/jme3test/export/TestAssetLinkNode.java index d2c721328c..0710a6843e 100644 --- a/jme3-examples/src/main/java/jme3test/export/TestAssetLinkNode.java +++ b/jme3-examples/src/main/java/jme3test/export/TestAssetLinkNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ package jme3test.export; import com.jme3.app.SimpleApplication; -import com.jme3.asset.AssetKey; +import com.jme3.asset.MaterialKey; import com.jme3.asset.ModelKey; import com.jme3.export.binary.BinaryExporter; import com.jme3.export.binary.BinaryImporter; @@ -93,7 +93,7 @@ public void simpleInitApp() { rootNode.attachChild(loaderNode); lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f)); - lightMdl.setMaterial( (Material) assetManager.loadAsset(new AssetKey("Common/Materials/RedColor.j3m"))); + lightMdl.setMaterial( (Material) assetManager.loadAsset(new MaterialKey("Common/Materials/RedColor.j3m"))); rootNode.attachChild(lightMdl); // flourescent main light diff --git a/jme3-examples/src/main/java/jme3test/games/CubeField.java b/jme3-examples/src/main/java/jme3test/games/CubeField.java index c166b58239..ec4f07f504 100644 --- a/jme3-examples/src/main/java/jme3test/games/CubeField.java +++ b/jme3-examples/src/main/java/jme3test/games/CubeField.java @@ -281,7 +281,6 @@ else if(difficulty>lowCap){ //better way to check collision Geometry playerModel = (Geometry) player.getChild(0); Geometry cubeModel = cubeField.get(i); - cubeModel.updateGeometricState(); BoundingVolume pVol = playerModel.getWorldBound(); BoundingVolume vVol = cubeModel.getWorldBound(); diff --git a/jme3-examples/src/main/java/jme3test/games/WorldOfInception.java b/jme3-examples/src/main/java/jme3test/games/WorldOfInception.java index 6e159263c7..080b3d00b3 100644 --- a/jme3-examples/src/main/java/jme3test/games/WorldOfInception.java +++ b/jme3-examples/src/main/java/jme3test/games/WorldOfInception.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -512,7 +512,7 @@ public static Vector3f[] getPositions(int count, long seed) { * @param x * @param min * @param max - * @return + * @return the mapped value */ public static float mapValue(float x, float min, float max) { return mapValue(x, 0, 1, min, max); @@ -526,7 +526,7 @@ public static float mapValue(float x, float min, float max) { * @param inputMax * @param min * @param max - * @return + * @return the mapped value */ public static float mapValue(float x, float inputMin, float inputMax, float min, float max) { return (x - inputMin) * (max - min) / (inputMax - inputMin) + min; diff --git a/jme3-examples/src/main/java/jme3test/gui/TestBitmapFontAlignment.java b/jme3-examples/src/main/java/jme3test/gui/TestBitmapFontAlignment.java new file mode 100644 index 0000000000..d6bc143d62 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/gui/TestBitmapFontAlignment.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2009-2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package jme3test.gui; + +import com.jme3.app.SimpleApplication; +import com.jme3.font.BitmapFont; +import com.jme3.font.BitmapText; +import com.jme3.font.Rectangle; +import com.jme3.material.Material; +import com.jme3.math.ColorRGBA; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Quad; + +public class TestBitmapFontAlignment extends SimpleApplication { + + public static void main(String[] args) { + TestBitmapFontAlignment test = new TestBitmapFontAlignment(); + test.start(); + } + + @Override + public void simpleInitApp() { + int width = getCamera().getWidth(); + int height = getCamera().getHeight(); + + // VAlign.Top + BitmapText labelAlignTop = guiFont.createLabel("This text has VAlign.Top."); + Rectangle textboxAlignTop = new Rectangle(width * 0.2f, height * 0.7f, 120, 120); + labelAlignTop.setBox(textboxAlignTop); + labelAlignTop.setVerticalAlignment(BitmapFont.VAlign.Top); + getGuiNode().attachChild(labelAlignTop); + + Geometry backgroundBoxAlignTop = new Geometry("", new Quad(textboxAlignTop.width, -textboxAlignTop.height)); + Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + material.setColor("Color", ColorRGBA.Blue); + backgroundBoxAlignTop.setMaterial(material); + backgroundBoxAlignTop.setLocalTranslation(textboxAlignTop.x, textboxAlignTop.y, -1); + getGuiNode().attachChild(backgroundBoxAlignTop); + + // VAlign.Center + BitmapText labelAlignCenter = guiFont.createLabel("This text has VAlign.Center"); + Rectangle textboxAlignCenter = new Rectangle(width * 0.4f, height * 0.7f, 120, 120); + labelAlignCenter.setBox(textboxAlignCenter); + labelAlignCenter.setVerticalAlignment(BitmapFont.VAlign.Center); + getGuiNode().attachChild(labelAlignCenter); + + Geometry backgroundBoxAlignCenter = backgroundBoxAlignTop.clone(false); + backgroundBoxAlignCenter.setLocalTranslation(textboxAlignCenter.x, textboxAlignCenter.y, -1); + getGuiNode().attachChild(backgroundBoxAlignCenter); + + // VAlign.Bottom + BitmapText labelAlignBottom = guiFont.createLabel("This text has VAlign.Bottom"); + Rectangle textboxAlignBottom = new Rectangle(width * 0.6f, height * 0.7f, 120, 120); + labelAlignBottom.setBox(textboxAlignBottom); + labelAlignBottom.setVerticalAlignment(BitmapFont.VAlign.Bottom); + getGuiNode().attachChild(labelAlignBottom); + + Geometry backgroundBoxAlignBottom = backgroundBoxAlignTop.clone(false); + backgroundBoxAlignBottom.setLocalTranslation(textboxAlignBottom.x, textboxAlignBottom.y, -1); + getGuiNode().attachChild(backgroundBoxAlignBottom); + + // VAlign.Top + Align.Right + BitmapText labelAlignTopRight = guiFont.createLabel("This text has VAlign.Top and Align.Right"); + Rectangle textboxAlignTopRight = new Rectangle(width * 0.2f, height * 0.3f, 120, 120); + labelAlignTopRight.setBox(textboxAlignTopRight); + labelAlignTopRight.setVerticalAlignment(BitmapFont.VAlign.Top); + labelAlignTopRight.setAlignment(BitmapFont.Align.Right); + getGuiNode().attachChild(labelAlignTopRight); + + Geometry backgroundBoxAlignTopRight = backgroundBoxAlignTop.clone(false); + backgroundBoxAlignTopRight.setLocalTranslation(textboxAlignTopRight.x, textboxAlignTopRight.y, -1); + getGuiNode().attachChild(backgroundBoxAlignTopRight); + + // VAlign.Center + Align.Center + BitmapText labelAlignCenterCenter = guiFont.createLabel("This text has VAlign.Center and Align.Center"); + Rectangle textboxAlignCenterCenter = new Rectangle(width * 0.4f, height * 0.3f, 120, 120); + labelAlignCenterCenter.setBox(textboxAlignCenterCenter); + labelAlignCenterCenter.setVerticalAlignment(BitmapFont.VAlign.Center); + labelAlignCenterCenter.setAlignment(BitmapFont.Align.Center); + getGuiNode().attachChild(labelAlignCenterCenter); + + Geometry backgroundBoxAlignCenterCenter = backgroundBoxAlignCenter.clone(false); + backgroundBoxAlignCenterCenter.setLocalTranslation(textboxAlignCenterCenter.x, textboxAlignCenterCenter.y, -1); + getGuiNode().attachChild(backgroundBoxAlignCenterCenter); + + // VAlign.Bottom + Align.Left + BitmapText labelAlignBottomLeft = guiFont.createLabel("This text has VAlign.Bottom and Align.Left"); + Rectangle textboxAlignBottomLeft = new Rectangle(width * 0.6f, height * 0.3f, 120, 120); + labelAlignBottomLeft.setBox(textboxAlignBottomLeft); + labelAlignBottomLeft.setVerticalAlignment(BitmapFont.VAlign.Bottom); + labelAlignBottomLeft.setAlignment(BitmapFont.Align.Left); + getGuiNode().attachChild(labelAlignBottomLeft); + + Geometry backgroundBoxAlignBottomLeft = backgroundBoxAlignBottom.clone(false); + backgroundBoxAlignBottomLeft.setLocalTranslation(textboxAlignBottomLeft.x, textboxAlignBottomLeft.y, -1); + getGuiNode().attachChild(backgroundBoxAlignBottomLeft); + + // Large quad with VAlign.Center and Align.Center + BitmapText label = guiFont.createLabel("This text is centered, both horizontally and vertically."); + Rectangle box = new Rectangle(width * 0.05f, height * 0.95f, width * 0.9f, height * 0.1f); + label.setBox(box); + label.setAlignment(BitmapFont.Align.Center); + label.setVerticalAlignment(BitmapFont.VAlign.Center); + getGuiNode().attachChild(label); + + Geometry background = new Geometry("background", new Quad(box.width, -box.height)); + Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); + mat.setColor("Color", ColorRGBA.Green); + background.setMaterial(mat); + background.setLocalTranslation(box.x, box.y, -1); + getGuiNode().attachChild(background); + } + +} diff --git a/jme3-examples/src/main/java/jme3test/gui/TestBitmapFontLayout.java b/jme3-examples/src/main/java/jme3test/gui/TestBitmapFontLayout.java index 8d210c3309..d2ac0e8bec 100644 --- a/jme3-examples/src/main/java/jme3test/gui/TestBitmapFontLayout.java +++ b/jme3-examples/src/main/java/jme3test/gui/TestBitmapFontLayout.java @@ -34,31 +34,21 @@ package jme3test.gui; -import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.FontFormatException; import java.awt.FontMetrics; -import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; import java.awt.RenderingHints; -import java.awt.Toolkit; -import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; -import java.awt.font.TextAttribute; import java.io.IOException; import java.util.*; -import javax.swing.*; import com.jme3.app.DebugKeysAppState; import com.jme3.app.StatsAppState; import com.jme3.app.SimpleApplication; import com.jme3.app.state.ScreenshotAppState; import com.jme3.bounding.BoundingBox; -import com.jme3.font.BitmapCharacter; import com.jme3.font.BitmapCharacterSet; import com.jme3.font.BitmapFont; import com.jme3.font.BitmapText; diff --git a/jme3-examples/src/main/java/jme3test/helloworld/HelloCollision.java b/jme3-examples/src/main/java/jme3test/helloworld/HelloCollision.java index 60db3b052d..7d96f9744f 100644 --- a/jme3-examples/src/main/java/jme3test/helloworld/HelloCollision.java +++ b/jme3-examples/src/main/java/jme3test/helloworld/HelloCollision.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ package jme3test.helloworld; import com.jme3.app.SimpleApplication; -import com.jme3.asset.plugins.ZipLocator; +import com.jme3.asset.plugins.HttpZipLocator; import com.jme3.bullet.BulletAppState; import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; import com.jme3.bullet.collision.shapes.CollisionShape; @@ -88,7 +88,9 @@ public void simpleInitApp() { setUpLight(); // We load the scene from the zip file and adjust its size. - assetManager.registerLocator("town.zip", ZipLocator.class); + assetManager.registerLocator( + "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/town.zip", + HttpZipLocator.class); sceneModel = assetManager.loadModel("main.scene"); sceneModel.setLocalScale(2f); diff --git a/jme3-examples/src/main/java/jme3test/helloworld/HelloJME3.java b/jme3-examples/src/main/java/jme3test/helloworld/HelloJME3.java index 9ffc1931d4..ba6d075e31 100644 --- a/jme3-examples/src/main/java/jme3test/helloworld/HelloJME3.java +++ b/jme3-examples/src/main/java/jme3test/helloworld/HelloJME3.java @@ -35,7 +35,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; -import com.jme3.math.Vector3f; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; diff --git a/jme3-examples/src/main/java/jme3test/input/TestJoystick.java b/jme3-examples/src/main/java/jme3test/input/TestJoystick.java index 29a9166fe2..fbc8ea1989 100644 --- a/jme3-examples/src/main/java/jme3test/input/TestJoystick.java +++ b/jme3-examples/src/main/java/jme3test/input/TestJoystick.java @@ -1,9 +1,12 @@ package jme3test.input; +import java.util.*; + import com.jme3.app.SimpleApplication; import com.jme3.collision.CollisionResult; import com.jme3.collision.CollisionResults; import com.jme3.font.BitmapText; +import com.jme3.input.DefaultJoystickAxis; import com.jme3.input.Joystick; import com.jme3.input.JoystickAxis; import com.jme3.input.JoystickButton; @@ -78,7 +81,7 @@ public void simpleInitApp() { joystickInfo.setLocalTranslation( 0, cam.getHeight(), 0 ); guiNode.attachChild( joystickInfo ); - // Add a raw listener because it's eisier to get all joystick events + // Add a raw listener because it's easier to get all joystick events // this way. inputManager.addRawInputListener( new JoystickEventListener() ); @@ -160,9 +163,29 @@ protected void setViewedJoystick( Joystick stick ) { */ protected class JoystickEventListener implements RawInputListener { + private Map lastValues = new HashMap<>(); + public void onJoyAxisEvent(JoyAxisEvent evt) { - setViewedJoystick( evt.getAxis().getJoystick() ); - gamepad.setAxisValue( evt.getAxis(), evt.getValue() ); + Float last = lastValues.remove(evt.getAxis()); + float value = evt.getValue(); + + // Check the axis dead zone. InputManager normally does this + // by default but not for raw events like we get here. + float effectiveDeadZone = Math.max(inputManager.getAxisDeadZone(), evt.getAxis().getDeadZone()); + if( Math.abs(value) < effectiveDeadZone ) { + if( last == null ) { + // Just skip the event + return; + } + // Else set the value to 0 + lastValues.remove(evt.getAxis()); + value = 0; + } + setViewedJoystick( evt.getAxis().getJoystick() ); + gamepad.setAxisValue( evt.getAxis(), value ); + if( value != 0 ) { + lastValues.put(evt.getAxis(), value); + } } public void onJoyButtonEvent(JoyButtonEvent evt) { @@ -266,7 +289,8 @@ private void addButton( String name, float x, float y, float width, float height } public void setAxisValue( JoystickAxis axis, float value ) { - System.out.println( "Axis:" + axis.getName() + "=" + value ); + + System.out.println( "Axis:" + axis.getName() + "(id:" + axis.getLogicalId() + ")=" + value ); if( axis == axis.getJoystick().getXAxis() ) { setXAxis(value); } else if( axis == axis.getJoystick().getYAxis() ) { @@ -280,6 +304,22 @@ public void setAxisValue( JoystickAxis axis, float value ) { setZAxis(value); } else if( axis == axis.getJoystick().getAxis(JoystickAxis.Z_ROTATION) ) { setZRotation(-value); + } else if( axis == axis.getJoystick().getAxis(JoystickAxis.LEFT_TRIGGER) ) { + if( axis.getJoystick().getButton(JoystickButton.BUTTON_6) == null ) { + // left/right triggers sometimes only show up as axes + boolean pressed = value != 0; + if( pressed != buttons.get(JoystickButton.BUTTON_6).isDown() ) { + setButtonValue(JoystickButton.BUTTON_6, pressed); + } + } + } else if( axis == axis.getJoystick().getAxis(JoystickAxis.RIGHT_TRIGGER) ) { + if( axis.getJoystick().getButton(JoystickButton.BUTTON_7) == null ) { + // left/right triggers sometimes only show up as axes + boolean pressed = value != 0; + if( pressed != buttons.get(JoystickButton.BUTTON_7).isDown() ) { + setButtonValue(JoystickButton.BUTTON_7, pressed); + } + } } else if( axis == axis.getJoystick().getPovXAxis() ) { if( lastPovX < 0 ) { setButtonValue( "POV -X", false ); @@ -402,6 +442,10 @@ private void resetState() { System.out.println( getName() + " state:" + state ); } + public boolean isDown() { + return state > 0; + } + public void down() { state++; resetState(); diff --git a/jme3-examples/src/main/java/jme3test/light/ShadowTestUIManager.java b/jme3-examples/src/main/java/jme3test/light/ShadowTestUIManager.java index 34bc20d897..4c8ae5ff94 100644 --- a/jme3-examples/src/main/java/jme3test/light/ShadowTestUIManager.java +++ b/jme3-examples/src/main/java/jme3test/light/ShadowTestUIManager.java @@ -11,7 +11,6 @@ import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; -import com.jme3.renderer.Camera; import com.jme3.renderer.ViewPort; import com.jme3.scene.Node; import com.jme3.shadow.AbstractShadowFilter; diff --git a/jme3-examples/src/main/java/jme3test/light/TestColorApp.java b/jme3-examples/src/main/java/jme3test/light/TestColorApp.java index 03bef0275e..3db910498a 100644 --- a/jme3-examples/src/main/java/jme3test/light/TestColorApp.java +++ b/jme3-examples/src/main/java/jme3test/light/TestColorApp.java @@ -11,11 +11,9 @@ import com.jme3.math.FastMath; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; -import com.jme3.post.FilterPostProcessor; import com.jme3.renderer.queue.RenderQueue; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; -import com.jme3.shadow.DirectionalLightShadowFilter; import com.jme3.shadow.DirectionalLightShadowRenderer; public class TestColorApp extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/light/TestDirectionalLightShadow.java b/jme3-examples/src/main/java/jme3test/light/TestDirectionalLightShadow.java index 79aacc6165..3f3ac9127e 100644 --- a/jme3-examples/src/main/java/jme3test/light/TestDirectionalLightShadow.java +++ b/jme3-examples/src/main/java/jme3test/light/TestDirectionalLightShadow.java @@ -40,14 +40,12 @@ import com.jme3.light.AmbientLight; import com.jme3.light.DirectionalLight; import com.jme3.material.Material; -import com.jme3.material.RenderState; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.math.Quaternion; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.post.FilterPostProcessor; -import com.jme3.post.ssao.SSAOFilter; import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; diff --git a/jme3-examples/src/main/java/jme3test/light/TestLightingFog.java b/jme3-examples/src/main/java/jme3test/light/TestLightingFog.java new file mode 100644 index 0000000000..adcb24a0cc --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/light/TestLightingFog.java @@ -0,0 +1,79 @@ +package jme3test.light; + +import com.jme3.app.SimpleApplication; +import com.jme3.input.KeyInput; +import com.jme3.input.controls.ActionListener; +import com.jme3.input.controls.KeyTrigger; +import com.jme3.light.DirectionalLight; +import com.jme3.material.Material; +import com.jme3.material.Materials; +import com.jme3.math.ColorRGBA; +import com.jme3.math.FastMath; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.scene.Geometry; +import com.jme3.scene.shape.Sphere; + +public class TestLightingFog extends SimpleApplication implements ActionListener { + + private Material material; + private Vector2f linear = new Vector2f(25, 120); + private float exp = 0.015f; + private float expsq = 0.02f; + + public static void main(String[] args) { + TestLightingFog testLightingFog = new TestLightingFog(); + testLightingFog.start(); + } + + @Override + public void simpleInitApp() { + + ColorRGBA skyColor = new ColorRGBA(0.5f, 0.6f, 0.7f, 0.0f); + + flyCam.setMoveSpeed(20); + viewPort.setBackgroundColor(skyColor.mult(0.9f)); + + DirectionalLight directionalLight = new DirectionalLight(new Vector3f(-1, -1, -1).normalizeLocal()); + rootNode.addLight(directionalLight); + + material = new Material(assetManager, Materials.LIGHTING); + material.setBoolean("UseFog", true); + material.setColor("FogColor", skyColor); + material.setVector2("LinearFog", linear); + + int distance = -3; + + for (int i = 0; i < 100; i++) { + Geometry geometry = new Geometry("Sphere", new Sphere(32, 32, 2)); + geometry.setMaterial(material); + + geometry.setLocalTranslation((FastMath.nextRandomFloat() - 0.5f) * 45, 0, i * distance); + rootNode.attachChild(geometry); + } + + inputManager.addMapping("Linear", new KeyTrigger(KeyInput.KEY_1)); + inputManager.addMapping("Exponential", new KeyTrigger(KeyInput.KEY_2)); + inputManager.addMapping("ExponentialSquared", new KeyTrigger(KeyInput.KEY_3)); + inputManager.addListener(this, "Linear", "Exponential", "ExponentialSquared"); + } + + @Override + public void onAction(String name, boolean isPressed, float tpf) { + if (name.equals("Linear") && !isPressed) { + material.setVector2("LinearFog", linear); + material.clearParam("ExpFog"); + material.clearParam("ExpSqFog"); + } + else if (name.equals("Exponential") && !isPressed) { + material.clearParam("LinearFog"); + material.setFloat("ExpFog", exp); + material.clearParam("ExpSqFog"); + } + else if (name.equals("ExponentialSquared") && !isPressed) { + material.clearParam("LinearFog"); + material.clearParam("ExpFog"); + material.setFloat("ExpSqFog", expsq); + } + } +} diff --git a/jme3-examples/src/main/java/jme3test/light/TestObbVsBounds.java b/jme3-examples/src/main/java/jme3test/light/TestObbVsBounds.java index c327730706..9e5db8948b 100644 --- a/jme3-examples/src/main/java/jme3test/light/TestObbVsBounds.java +++ b/jme3-examples/src/main/java/jme3test/light/TestObbVsBounds.java @@ -35,7 +35,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.bounding.BoundingBox; import com.jme3.bounding.BoundingSphere; -import com.jme3.export.binary.BinaryExporter; import com.jme3.input.KeyInput; import com.jme3.input.MouseInput; import com.jme3.input.controls.*; @@ -50,8 +49,6 @@ import com.jme3.shadow.ShadowUtil; import com.jme3.util.TempVars; -import java.io.File; -import java.io.IOException; public class TestObbVsBounds extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/light/TestShadowsPerf.java b/jme3-examples/src/main/java/jme3test/light/TestShadowsPerf.java index 97629117ea..a631f9eac8 100644 --- a/jme3-examples/src/main/java/jme3test/light/TestShadowsPerf.java +++ b/jme3-examples/src/main/java/jme3test/light/TestShadowsPerf.java @@ -51,8 +51,6 @@ import com.jme3.shadow.DirectionalLightShadowRenderer; import com.jme3.shadow.EdgeFilteringMode; import com.jme3.util.TangentBinormalGenerator; -import java.util.logging.Level; -import java.util.logging.Logger; public class TestShadowsPerf extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/light/TestSpotLightShadows.java b/jme3-examples/src/main/java/jme3test/light/TestSpotLightShadows.java index 52a5dc8c58..254bfb0284 100644 --- a/jme3-examples/src/main/java/jme3test/light/TestSpotLightShadows.java +++ b/jme3-examples/src/main/java/jme3test/light/TestSpotLightShadows.java @@ -49,7 +49,6 @@ import com.jme3.shadow.SpotLightShadowFilter; import com.jme3.shadow.SpotLightShadowRenderer; import com.jme3.texture.Texture.WrapMode; -import com.jme3.util.MaterialDebugAppState; import com.jme3.util.TangentBinormalGenerator; public class TestSpotLightShadows extends SimpleApplication { diff --git a/jme3-examples/src/main/java/jme3test/light/TestTangentCube.java b/jme3-examples/src/main/java/jme3test/light/TestTangentCube.java index c7c3b6716c..eb0353962f 100644 --- a/jme3-examples/src/main/java/jme3test/light/TestTangentCube.java +++ b/jme3-examples/src/main/java/jme3test/light/TestTangentCube.java @@ -33,7 +33,6 @@ import com.jme3.app.ChaseCameraAppState; import com.jme3.app.SimpleApplication; -import com.jme3.light.AmbientLight; import com.jme3.light.PointLight; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; diff --git a/jme3-examples/src/main/java/jme3test/light/TestTwoSideLighting.java b/jme3-examples/src/main/java/jme3test/light/TestTwoSideLighting.java index 03fe89eff5..2d3ff4bccf 100644 --- a/jme3-examples/src/main/java/jme3test/light/TestTwoSideLighting.java +++ b/jme3-examples/src/main/java/jme3test/light/TestTwoSideLighting.java @@ -33,7 +33,6 @@ package jme3test.light; import com.jme3.app.SimpleApplication; -import com.jme3.light.DirectionalLight; import com.jme3.light.PointLight; import com.jme3.material.Material; import com.jme3.material.RenderState; @@ -45,7 +44,6 @@ import com.jme3.scene.Geometry; import com.jme3.scene.shape.Quad; import com.jme3.scene.shape.Sphere; -import com.jme3.util.MaterialDebugAppState; import com.jme3.util.TangentBinormalGenerator; /** diff --git a/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRDirectLighting.java b/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRDirectLighting.java index 26cae098eb..d9f3aef763 100644 --- a/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRDirectLighting.java +++ b/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRDirectLighting.java @@ -33,28 +33,14 @@ import com.jme3.app.ChaseCameraAppState; import com.jme3.app.SimpleApplication; -import com.jme3.bounding.BoundingSphere; -import com.jme3.environment.EnvironmentCamera; -import com.jme3.environment.LightProbeFactory; -import com.jme3.environment.generation.JobProgressAdapter; -import com.jme3.environment.util.EnvMapUtils; -import com.jme3.environment.util.LightsDebugState; -import com.jme3.input.ChaseCamera; import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; import com.jme3.light.DirectionalLight; -import com.jme3.light.LightProbe; import com.jme3.material.Material; import com.jme3.math.*; -import com.jme3.post.FilterPostProcessor; -import com.jme3.post.filters.ToneMapFilter; import com.jme3.scene.*; import com.jme3.scene.shape.Sphere; -import com.jme3.texture.plugins.ktx.KTXLoader; -import com.jme3.util.MaterialDebugAppState; -import com.jme3.util.SkyFactory; -import com.jme3.util.mikktspace.MikktspaceTangentGenerator; /** * A test case for PBR lighting. diff --git a/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java b/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java index 4cc36b123f..d08f57fb6f 100644 --- a/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java +++ b/jme3-examples/src/main/java/jme3test/light/pbr/TestPBRLighting.java @@ -32,7 +32,6 @@ package jme3test.light.pbr; import com.jme3.app.SimpleApplication; -import com.jme3.bounding.BoundingSphere; import com.jme3.environment.EnvironmentCamera; import com.jme3.environment.LightProbeFactory; import com.jme3.environment.generation.JobProgressAdapter; diff --git a/jme3-examples/src/main/java/jme3test/model/TestGltfLoading.java b/jme3-examples/src/main/java/jme3test/model/TestGltfLoading.java index 8aa044d559..5c91859838 100644 --- a/jme3-examples/src/main/java/jme3test/model/TestGltfLoading.java +++ b/jme3-examples/src/main/java/jme3test/model/TestGltfLoading.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -70,7 +70,7 @@ public static void main(String[] args) { } /* - WARNING this test case can't wok without the assets, and considering their size, they are not pushed into the repo + WARNING this test case can't work without the assets, and considering their size, they are not pushed into the repo you can find them here : https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0 https://sketchfab.com/features/gltf @@ -124,7 +124,7 @@ public void simpleInitApp() { //loadModel("Models/gltf/morphCube/AnimatedMorphCube.gltf", new Vector3f(0, 0, 0), 1f); // loadModel("Models/gltf/morph/SimpleMorph.gltf", new Vector3f(0, 0, 0), 0.1f); //loadModel("Models/gltf/nier/scene.gltf", new Vector3f(0, -1.5f, 0), 0.01f); - loadModel("Models/gltf/izzy/scene.gltf", new Vector3f(0, -1, 0), 0.01f); + //loadModel("Models/gltf/izzy/scene.gltf", new Vector3f(0, -1, 0), 0.01f); //loadModel("Models/gltf/darth/scene.gltf", new Vector3f(0, -1, 0), 0.01f); //loadModel("Models/gltf/mech/scene.gltf", new Vector3f(0, -1, 0), 0.01f); //loadModel("Models/gltf/elephant/scene.gltf", new Vector3f(0, -1, 0), 0.01f); @@ -137,7 +137,7 @@ public void simpleInitApp() { //loadModel("Models/gltf/manta/scene.gltf", Vector3f.ZERO, 0.2f); //loadModel("Models/gltf/bone/scene.gltf", Vector3f.ZERO, 0.1f); // loadModel("Models/gltf/box/box.gltf", Vector3f.ZERO, 1); -// loadModel("Models/gltf/duck/Duck.gltf", new Vector3f(0, -1, 0), 1); + loadModel("Models/gltf/duck/Duck.gltf", new Vector3f(0, -1, 0), 1); // loadModel("Models/gltf/damagedHelmet/damagedHelmet.gltf", Vector3f.ZERO, 1); // loadModel("Models/gltf/hornet/scene.gltf", new Vector3f(0, -0.5f, 0), 0.4f); //// loadModel("Models/gltf/adamHead/adamHead.gltf", Vector3f.ZERO, 0.6f); diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMigration.java b/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMigration.java index 18cbb0275e..fd6d9e3e1f 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMigration.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMigration.java @@ -1,9 +1,7 @@ package jme3test.model.anim; import com.jme3.anim.*; -import com.jme3.anim.tween.action.Action; import com.jme3.anim.tween.action.BlendAction; -import com.jme3.anim.tween.action.BlendableAction; import com.jme3.anim.tween.action.LinearBlendSpace; import com.jme3.anim.util.AnimMigrationUtils; import com.jme3.app.ChaseCameraAppState; @@ -20,7 +18,6 @@ import com.jme3.scene.debug.custom.ArmatureDebugAppState; import java.util.LinkedList; -import java.util.Queue; /** * Created by Nehon on 18/12/2017. diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMorphSerialization.java b/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMorphSerialization.java index 2e122a35e1..f89b6ee720 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMorphSerialization.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestAnimMorphSerialization.java @@ -1,7 +1,6 @@ package jme3test.model.anim; import com.jme3.anim.*; -import com.jme3.anim.util.AnimMigrationUtils; import com.jme3.app.ChaseCameraAppState; import com.jme3.app.SimpleApplication; import com.jme3.asset.plugins.FileLocator; @@ -9,8 +8,6 @@ import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; -import com.jme3.light.AmbientLight; -import com.jme3.light.DirectionalLight; import com.jme3.math.*; import com.jme3.scene.Node; import com.jme3.scene.Spatial; diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestAnimationFactory.java b/jme3-examples/src/main/java/jme3test/model/anim/TestAnimationFactory.java index dfd2497110..2ddb251e5b 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestAnimationFactory.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestAnimationFactory.java @@ -46,7 +46,7 @@ public void simpleInitApp() { model.attachChild(childModel); TangentBinormalGenerator.generate(model); - //creating quite complex animation witht the AnimationHelper + //creating quite complex animation with the AnimationHelper // animation of 6 seconds named "anim" and with 25 frames per second AnimationFactory animationFactory = new AnimationFactory(6, "anim", 25); diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestBlenderObjectAnim.java b/jme3-examples/src/main/java/jme3test/model/anim/TestBlenderObjectAnim.java index f7171f2bd2..68855176a0 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestBlenderObjectAnim.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestBlenderObjectAnim.java @@ -69,13 +69,13 @@ public void simpleInitApp() { Spatial scene = (Spatial) assetManager.loadModel(blenderKey); rootNode.attachChild(scene); - Spatial model = this.findNode(rootNode, "TestAnim"); + Spatial model = this.findNode(rootNode, "Cube"); model.center(); control = model.getControl(AnimControl.class); channel = control.createChannel(); - channel.setAnim("TestAnim"); + channel.setAnim("Action"); } /** diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestHWSkinning.java b/jme3-examples/src/main/java/jme3test/model/anim/TestHWSkinning.java index 475075267c..6eca8a9a2a 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestHWSkinning.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestHWSkinning.java @@ -33,7 +33,6 @@ import com.jme3.anim.AnimComposer; import com.jme3.anim.SkinningControl; -import com.jme3.app.DetailedProfilerState; import com.jme3.app.SimpleApplication; import com.jme3.font.BitmapText; import com.jme3.input.KeyInput; diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java b/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java index 63b5023d6a..7795753b9d 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestModelExportingCloning.java @@ -61,18 +61,21 @@ public void simpleInitApp() { Spatial originalModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); composer = originalModel.getControl(AnimComposer.class); composer.setCurrentAction("Walk"); + composer.setGlobalSpeed(1.5f); rootNode.attachChild(originalModel); Spatial clonedModel = originalModel.clone(); clonedModel.move(10, 0, 0); composer = clonedModel.getControl(AnimComposer.class); composer.setCurrentAction("push"); + System.out.println("clonedModel: globalSpeed=" + composer.getGlobalSpeed()); rootNode.attachChild(clonedModel); Spatial exportedModel = BinaryExporter.saveAndLoad(assetManager, originalModel); exportedModel.move(20, 0, 0); composer = exportedModel.getControl(AnimComposer.class); composer.setCurrentAction("pull"); + System.out.println("exportedModel: globalSpeed=" + composer.getGlobalSpeed()); rootNode.attachChild(exportedModel); } } diff --git a/jme3-examples/src/main/java/jme3test/model/anim/TestMorph.java b/jme3-examples/src/main/java/jme3test/model/anim/TestMorph.java index 6290466851..c32a8ae0a7 100644 --- a/jme3-examples/src/main/java/jme3test/model/anim/TestMorph.java +++ b/jme3-examples/src/main/java/jme3test/model/anim/TestMorph.java @@ -10,11 +10,9 @@ import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.scene.Geometry; -import com.jme3.scene.Node; import com.jme3.scene.VertexBuffer; import com.jme3.scene.mesh.MorphTarget; import com.jme3.scene.shape.Box; -import com.jme3.shader.VarType; import com.jme3.util.BufferUtils; import java.nio.FloatBuffer; diff --git a/jme3-examples/src/main/java/jme3test/niftygui/TestIssue99.java b/jme3-examples/src/main/java/jme3test/niftygui/TestIssue99.java new file mode 100644 index 0000000000..44722d2b57 --- /dev/null +++ b/jme3-examples/src/main/java/jme3test/niftygui/TestIssue99.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package jme3test.niftygui; + +import com.jme3.app.SimpleApplication; +import com.jme3.niftygui.NiftyJmeDisplay; +import de.lessvoid.nifty.Nifty; +import de.lessvoid.nifty.screen.Screen; +import de.lessvoid.nifty.screen.ScreenController; + +/** + * Test case for JME issue #99: blendMode="multiply" in Nifty renders + * incorrectly. + *

        + * If successful, two text labels will be legible. If unsuccessful, only the top + * one will be legible. + * + * @author Stephen Gold sgold@sonic.net + */ +public class TestIssue99 + extends SimpleApplication + implements ScreenController { + + public static void main(String[] args) { + TestIssue99 app = new TestIssue99(); + app.start(); + } + + @Override + public void simpleInitApp() { + /* + * GUI requires a cursor; prevent flyCam from hiding it. + */ + flyCam.setDragToRotate(true); + /* + * Start NiftyGUI without the batched renderer. + */ + NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay( + assetManager, inputManager, audioRenderer, guiViewPort); + guiViewPort.addProcessor(niftyDisplay); + /* + * Load GUI controls, styles, and layout from XML assets. + */ + Nifty nifty = niftyDisplay.getNifty(); + nifty.loadControlFile("nifty-default-controls.xml"); + nifty.loadStyleFile("nifty-default-styles.xml"); + nifty.fromXml("Interface/Nifty/test-issue-99.xml", + "test-issue-99", this); + } + + /** + * A callback from Nifty, invoked when the screen gets enabled for the first + * time. + * + * @param nifty (not null) + * @param screen (not null) + */ + @Override + public void bind(Nifty nifty, Screen screen) { + } + + /** + * A callback from Nifty, invoked each time the screen shuts down. + */ + @Override + public void onEndScreen() { + } + + /** + * A callback from Nifty, invoked each time the screen starts up. + */ + @Override + public void onStartScreen() { + } +} diff --git a/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyGui.java b/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyGui.java index 3d2e67b5fd..f02c2c2de2 100644 --- a/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyGui.java +++ b/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyGui.java @@ -34,7 +34,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.material.Material; -import com.jme3.math.Vector3f; import com.jme3.niftygui.NiftyJmeDisplay; import com.jme3.scene.Geometry; import com.jme3.scene.shape.Box; diff --git a/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyToMesh.java b/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyToMesh.java index ce3832c736..9ec915f532 100644 --- a/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyToMesh.java +++ b/jme3-examples/src/main/java/jme3test/niftygui/TestNiftyToMesh.java @@ -34,7 +34,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.material.Material; -import com.jme3.math.Vector3f; import com.jme3.niftygui.NiftyJmeDisplay; import com.jme3.renderer.Camera; import com.jme3.renderer.ViewPort; diff --git a/jme3-examples/src/main/java/jme3test/opencl/TestMultipleApplications.java b/jme3-examples/src/main/java/jme3test/opencl/TestMultipleApplications.java index 1c2a5bf45e..d0045ff203 100644 --- a/jme3-examples/src/main/java/jme3test/opencl/TestMultipleApplications.java +++ b/jme3-examples/src/main/java/jme3test/opencl/TestMultipleApplications.java @@ -34,7 +34,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.font.BitmapFont; import com.jme3.font.BitmapText; -import com.jme3.font.Rectangle; import com.jme3.opencl.*; import com.jme3.system.AppSettings; import java.util.Collections; diff --git a/jme3-examples/src/main/java/jme3test/opencl/TestOpenCLLibraries.java b/jme3-examples/src/main/java/jme3test/opencl/TestOpenCLLibraries.java index 396411397d..b057a15bb7 100644 --- a/jme3-examples/src/main/java/jme3test/opencl/TestOpenCLLibraries.java +++ b/jme3-examples/src/main/java/jme3test/opencl/TestOpenCLLibraries.java @@ -35,7 +35,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.font.BitmapFont; import com.jme3.font.BitmapText; -import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.math.Matrix3f; import com.jme3.math.Matrix4f; @@ -43,7 +42,6 @@ import com.jme3.system.AppSettings; import com.jme3.util.BufferUtils; import java.nio.*; -import java.util.Arrays; import java.util.Objects; import java.util.Random; import java.util.logging.Level; diff --git a/jme3-examples/src/main/java/jme3test/post/TestFog.java b/jme3-examples/src/main/java/jme3test/post/TestFog.java index 544932ab6d..6d3b667aba 100644 --- a/jme3-examples/src/main/java/jme3test/post/TestFog.java +++ b/jme3-examples/src/main/java/jme3test/post/TestFog.java @@ -33,8 +33,6 @@ package jme3test.post; import com.jme3.app.SimpleApplication; -import com.jme3.asset.plugins.HttpZipLocator; -import com.jme3.asset.plugins.ZipLocator; import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.AnalogListener; @@ -49,13 +47,11 @@ import com.jme3.renderer.Camera; import com.jme3.renderer.queue.RenderQueue; import com.jme3.scene.Node; -import com.jme3.scene.Spatial; import com.jme3.terrain.geomipmap.TerrainQuad; import com.jme3.terrain.heightmap.AbstractHeightMap; import com.jme3.terrain.heightmap.ImageBasedHeightMap; import com.jme3.texture.Texture; import com.jme3.util.SkyFactory; -import java.io.File; import java.util.ArrayList; import java.util.List; diff --git a/jme3-examples/src/main/java/jme3test/post/TestMultiplesFilters.java b/jme3-examples/src/main/java/jme3test/post/TestMultiplesFilters.java index 46efd639ae..f2aa6032e3 100644 --- a/jme3-examples/src/main/java/jme3test/post/TestMultiplesFilters.java +++ b/jme3-examples/src/main/java/jme3test/post/TestMultiplesFilters.java @@ -79,7 +79,9 @@ public void simpleInitApp() { // create the geometry and attach it // load the level from zip or http zip if (useHttp) { - assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class); + assetManager.registerLocator( + "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/wildhouse.zip", + HttpZipLocator.class); } else { assetManager.registerLocator("wildhouse.zip", ZipLocator.class); } diff --git a/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java b/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java index c2ee5b04b3..7bd807073f 100644 --- a/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java +++ b/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java @@ -44,11 +44,8 @@ import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; -import com.jme3.scene.Spatial.CullHint; import com.jme3.scene.shape.Box; -import com.jme3.system.AppSettings; import com.jme3.texture.Texture; -import com.jme3.texture.Texture.WrapMode; import com.jme3.util.SkyFactory; import com.jme3.util.SkyFactory.EnvMapType; import com.jme3.util.TangentBinormalGenerator; diff --git a/jme3-examples/src/main/java/jme3test/post/TestPostFiltersCompositing.java b/jme3-examples/src/main/java/jme3test/post/TestPostFiltersCompositing.java index 817fef0eff..5a2353e38d 100644 --- a/jme3-examples/src/main/java/jme3test/post/TestPostFiltersCompositing.java +++ b/jme3-examples/src/main/java/jme3test/post/TestPostFiltersCompositing.java @@ -32,19 +32,14 @@ package jme3test.post; import com.jme3.app.SimpleApplication; -import com.jme3.asset.plugins.HttpZipLocator; import com.jme3.light.DirectionalLight; -import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.post.FilterPostProcessor; import com.jme3.post.filters.ColorOverlayFilter; import com.jme3.post.filters.ComposeFilter; -import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; -import com.jme3.scene.shape.Box; -import com.jme3.system.AppSettings; import com.jme3.texture.FrameBuffer; import com.jme3.texture.Image; import com.jme3.texture.Texture2D; diff --git a/jme3-examples/src/main/java/jme3test/post/TestPosterization.java b/jme3-examples/src/main/java/jme3test/post/TestPosterization.java index 9b6d33f669..c35236bc28 100644 --- a/jme3-examples/src/main/java/jme3test/post/TestPosterization.java +++ b/jme3-examples/src/main/java/jme3test/post/TestPosterization.java @@ -42,12 +42,10 @@ import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.post.FilterPostProcessor; -import com.jme3.post.filters.ColorOverlayFilter; import com.jme3.post.filters.PosterizationFilter; import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; -import com.jme3.scene.debug.WireFrustum; import com.jme3.scene.shape.Box; import com.jme3.util.SkyFactory; diff --git a/jme3-examples/src/main/java/jme3test/post/TestRenderToMemory.java b/jme3-examples/src/main/java/jme3test/post/TestRenderToMemory.java index dd59a1d1b4..c46448efbe 100644 --- a/jme3-examples/src/main/java/jme3test/post/TestRenderToMemory.java +++ b/jme3-examples/src/main/java/jme3test/post/TestRenderToMemory.java @@ -49,7 +49,6 @@ import com.jme3.system.AppSettings; import com.jme3.system.JmeContext.Type; import com.jme3.texture.FrameBuffer; -import com.jme3.texture.Image; import com.jme3.texture.Image.Format; import com.jme3.texture.Texture2D; import com.jme3.util.BufferUtils; diff --git a/jme3-examples/src/main/java/jme3test/renderer/TestBlendEquations.java b/jme3-examples/src/main/java/jme3test/renderer/TestBlendEquations.java index 435d57db30..04eded427b 100644 --- a/jme3-examples/src/main/java/jme3test/renderer/TestBlendEquations.java +++ b/jme3-examples/src/main/java/jme3test/renderer/TestBlendEquations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2016 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -45,7 +45,7 @@ /** * This test demonstrates the usage of customized blend equations and factors on a material.
        - * Customized blend equations and factors always requires {@link RenderState.BlendMode#Custom}. + * Customized blend equations and factors always requires {@link com.jme3.material.RenderState.BlendMode#Custom}. * * @author the_Minka */ diff --git a/jme3-examples/src/main/java/jme3test/renderer/TestDepthFuncChange.java b/jme3-examples/src/main/java/jme3test/renderer/TestDepthFuncChange.java index 1bacf782b7..9f4f4cef8d 100644 --- a/jme3-examples/src/main/java/jme3test/renderer/TestDepthFuncChange.java +++ b/jme3-examples/src/main/java/jme3test/renderer/TestDepthFuncChange.java @@ -32,7 +32,6 @@ package jme3test.renderer; import com.jme3.app.SimpleApplication; -import com.jme3.font.BitmapText; import com.jme3.material.Material; import com.jme3.material.RenderState; import com.jme3.math.ColorRGBA; diff --git a/jme3-examples/src/main/java/jme3test/renderer/TestDepthStencil.java b/jme3-examples/src/main/java/jme3test/renderer/TestDepthStencil.java index a2a09d4365..77528893a2 100644 --- a/jme3-examples/src/main/java/jme3test/renderer/TestDepthStencil.java +++ b/jme3-examples/src/main/java/jme3test/renderer/TestDepthStencil.java @@ -114,10 +114,10 @@ public void onAction(String name, boolean keyPressed, float tpf) { if (name.equals("toggle") && keyPressed) { if (enableStencil) { enableStencil = false; - System.out.println("Stencil Enabled (model should be hidden)"); + System.out.println("Stencil Disabled (model should be visible)"); } else { enableStencil = true; - System.out.println("Stencil Disabled (model should be visible)"); + System.out.println("Stencil Enabled (model should be hidden)"); } } } diff --git a/jme3-examples/src/main/java/jme3test/stress/TestShaderNodesStress.java b/jme3-examples/src/main/java/jme3test/stress/TestShaderNodesStress.java index dc74d3c0db..0635c2b16a 100644 --- a/jme3-examples/src/main/java/jme3test/stress/TestShaderNodesStress.java +++ b/jme3-examples/src/main/java/jme3test/stress/TestShaderNodesStress.java @@ -1,6 +1,5 @@ package jme3test.stress; -import com.jme3.app.BasicProfilerState; import com.jme3.app.SimpleApplication; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; @@ -91,6 +90,11 @@ public void appStep(AppStep step) { } + @Override + public void appSubStep(String... additionalInfo) { + + } + @Override public void vpStep(VpStep step, ViewPort vp, RenderQueue.Bucket bucket) { diff --git a/jme3-examples/src/main/java/jme3test/terrain/TerrainGridSerializationTest.java b/jme3-examples/src/main/java/jme3test/terrain/TerrainGridSerializationTest.java index 27ce15785c..b20357ded7 100644 --- a/jme3-examples/src/main/java/jme3test/terrain/TerrainGridSerializationTest.java +++ b/jme3-examples/src/main/java/jme3test/terrain/TerrainGridSerializationTest.java @@ -12,7 +12,6 @@ import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; -import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; import com.jme3.terrain.geomipmap.TerrainGrid; diff --git a/jme3-examples/src/main/java/jme3test/terrain/TerrainGridTest.java b/jme3-examples/src/main/java/jme3test/terrain/TerrainGridTest.java index 7fb6e5eb3c..1781b71060 100644 --- a/jme3-examples/src/main/java/jme3test/terrain/TerrainGridTest.java +++ b/jme3-examples/src/main/java/jme3test/terrain/TerrainGridTest.java @@ -2,7 +2,6 @@ import com.jme3.app.SimpleApplication; import com.jme3.app.state.ScreenshotAppState; -import com.jme3.asset.plugins.HttpZipLocator; import com.jme3.asset.plugins.ZipLocator; import com.jme3.bullet.BulletAppState; import com.jme3.bullet.collision.shapes.CapsuleCollisionShape; @@ -26,7 +25,6 @@ import com.jme3.terrain.heightmap.Namer; import com.jme3.texture.Texture; import com.jme3.texture.Texture.WrapMode; -import java.io.File; public class TerrainGridTest extends SimpleApplication { @@ -46,12 +44,7 @@ public static void main(final String[] args) { @Override public void simpleInitApp() { - File file = new File("TerrainGridTestData.zip"); - if (!file.exists()) { - assetManager.registerLocator("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/TerrainGridTestData.zip", HttpZipLocator.class); - } else { - assetManager.registerLocator("TerrainGridTestData.zip", ZipLocator.class); - } + assetManager.registerLocator("TerrainGridTestData.zip", ZipLocator.class); this.flyCam.setMoveSpeed(100f); ScreenshotAppState state = new ScreenshotAppState(); @@ -167,12 +160,10 @@ private void initKeys() { this.inputManager.addMapping("Rights", new KeyTrigger(KeyInput.KEY_D)); this.inputManager.addMapping("Ups", new KeyTrigger(KeyInput.KEY_W)); this.inputManager.addMapping("Downs", new KeyTrigger(KeyInput.KEY_S)); - this.inputManager.addMapping("Jumps", new KeyTrigger(KeyInput.KEY_SPACE)); this.inputManager.addListener(this.actionListener, "Lefts"); this.inputManager.addListener(this.actionListener, "Rights"); this.inputManager.addListener(this.actionListener, "Ups"); this.inputManager.addListener(this.actionListener, "Downs"); - this.inputManager.addListener(this.actionListener, "Jumps"); } private boolean left; private boolean right; @@ -206,8 +197,6 @@ public void onAction(final String name, final boolean keyPressed, final float tp } else { TerrainGridTest.this.down = false; } - } else if (name.equals("Jumps")) { - TerrainGridTest.this.player3.jump(); } } }; diff --git a/jme3-examples/src/main/java/jme3test/terrain/TerrainTestTile.java b/jme3-examples/src/main/java/jme3test/terrain/TerrainTestTile.java index 4e093e80c9..454846b8c5 100644 --- a/jme3-examples/src/main/java/jme3test/terrain/TerrainTestTile.java +++ b/jme3-examples/src/main/java/jme3test/terrain/TerrainTestTile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,7 +68,7 @@ public class TerrainTestTile extends SimpleApplication { private TiledTerrain terrain; Material matTerrain; Material matWire; - boolean wireframe = true; + boolean wireframe = false; boolean triPlanar = false; boolean wardiso = false; boolean minnaert = false; @@ -135,7 +135,7 @@ public void simpleInitApp() { public void loadHintText() { hintText = new BitmapText(guiFont, false); hintText.setLocalTranslation(0, getCamera().getHeight(), 0); - hintText.setText("Hit 'T' to toggle wireframe"); + hintText.setText("Press T to toggle wireframe"); guiNode.attachChild(hintText); } @@ -150,7 +150,7 @@ private void setupKeys() { public void onAction(String name, boolean pressed, float tpf) { if (name.equals("wireframe") && !pressed) { wireframe = !wireframe; - if (!wireframe) { + if (wireframe) { terrain.setMaterial(matWire); } else { terrain.setMaterial(matTerrain); diff --git a/jme3-examples/src/main/java/jme3test/texture/TestAnisotropicFilter.java b/jme3-examples/src/main/java/jme3test/texture/TestAnisotropicFilter.java index c8633f5961..b45e613326 100755 --- a/jme3-examples/src/main/java/jme3test/texture/TestAnisotropicFilter.java +++ b/jme3-examples/src/main/java/jme3test/texture/TestAnisotropicFilter.java @@ -1,7 +1,6 @@ package jme3test.texture; import com.jme3.app.SimpleApplication; -import com.jme3.app.state.ScreenshotAppState; import com.jme3.asset.AssetManager; import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; diff --git a/jme3-examples/src/main/java/jme3test/texture/ktx/TestLoadKtx.java b/jme3-examples/src/main/java/jme3test/texture/ktx/TestLoadKtx.java index 62330bea46..8c69c0a7ac 100644 --- a/jme3-examples/src/main/java/jme3test/texture/ktx/TestLoadKtx.java +++ b/jme3-examples/src/main/java/jme3test/texture/ktx/TestLoadKtx.java @@ -32,13 +32,9 @@ package jme3test.texture.ktx; import com.jme3.app.SimpleApplication; -import com.jme3.asset.TextureKey; import com.jme3.math.ColorRGBA; import com.jme3.renderer.RenderManager; -import com.jme3.scene.Node; -import com.jme3.texture.Texture; import com.jme3.texture.Texture2D; -import com.jme3.texture.TextureCubeMap; import com.jme3.texture.plugins.ktx.KTXLoader; import com.jme3.ui.Picture; diff --git a/jme3-examples/src/main/java/jme3test/water/TestPostWaterLake.java b/jme3-examples/src/main/java/jme3test/water/TestPostWaterLake.java index 16441025cf..d5a6df5f22 100644 --- a/jme3-examples/src/main/java/jme3test/water/TestPostWaterLake.java +++ b/jme3-examples/src/main/java/jme3test/water/TestPostWaterLake.java @@ -47,11 +47,13 @@ public class TestPostWaterLake extends SimpleApplication { - // set default for applets - private static boolean useHttp = true; + private static boolean useHttp = false; public static void main(String[] args) { - + File file = new File("wildhouse.zip"); + if (!file.exists()) { + useHttp = true; + } TestPostWaterLake app = new TestPostWaterLake(); app.start(); } @@ -74,7 +76,9 @@ public void simpleInitApp() { // create the geometry and attach it // load the level from zip or http zip if (useHttp) { - assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class); + assetManager.registerLocator( + "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/wildhouse.zip", + HttpZipLocator.class); } else { assetManager.registerLocator("wildhouse.zip", ZipLocator.class); } diff --git a/jme3-examples/src/main/resources/Interface/Nifty/test-issue-99.xml b/jme3-examples/src/main/resources/Interface/Nifty/test-issue-99.xml new file mode 100644 index 0000000000..794e37d1b7 --- /dev/null +++ b/jme3-examples/src/main/resources/Interface/Nifty/test-issue-99.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jme3-examples/town.zip b/jme3-examples/town.zip new file mode 100644 index 0000000000..53e31a0bfc Binary files /dev/null and b/jme3-examples/town.zip differ diff --git a/jme3-ios/src/main/java/com/jme3/renderer/ios/JmeIosGLES.java b/jme3-ios/src/main/java/com/jme3/renderer/ios/JmeIosGLES.java index b5cde67216..2a2eee5b5a 100644 --- a/jme3-ios/src/main/java/com/jme3/renderer/ios/JmeIosGLES.java +++ b/jme3-ios/src/main/java/com/jme3/renderer/ios/JmeIosGLES.java @@ -5,7 +5,6 @@ import java.nio.Buffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import java.util.logging.Level; import java.util.logging.Logger; /** diff --git a/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java b/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java index d29f76f625..820e387e54 100644 --- a/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java +++ b/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java @@ -31,7 +31,6 @@ */ package com.jme3.system.ios; -import com.jme3.audio.AudioRenderer; import com.jme3.system.AppSettings; import com.jme3.system.JmeContext; import com.jme3.system.JmeSystemDelegate; @@ -43,7 +42,6 @@ import com.jme3.audio.openal.AL; import com.jme3.audio.openal.ALAudioRenderer; import com.jme3.audio.openal.ALC; -import com.jme3.audio.openal.EFX; import java.io.IOException; import java.io.OutputStream; import java.net.URL; diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java b/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java index 9dd64be174..2099f7f23f 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/PhysicsSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -411,7 +411,7 @@ public static Future enqueueOnThisThread(Callable callable) { * calls the callable on the next physics tick (ensuring e.g. force applying) * @param * @param callable - * @return + * @return a new AppTask */ public Future enqueue(Callable callable) { AppTask task = new AppTask(callable); diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java index 56769e61c6..35c5dd789e 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/PhysicsCollisionObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -83,7 +83,7 @@ public CollisionShape getCollisionShape() { /** * Returns the collision group for this collision shape - * @return + * @return a bitmask with 1 bit set */ public int getCollisionGroup() { return collisionGroup; @@ -129,7 +129,7 @@ public void setCollideWithGroups(int collisionGroups) { /** * Gets the bitmask of collision groups that this object collides with. - * @return + * @return a bitmask */ public int getCollideWithGroups() { return collisionGroupsMask; diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CapsuleCollisionShape.java b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CapsuleCollisionShape.java index a8fce13eb2..09dceee17b 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CapsuleCollisionShape.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CapsuleCollisionShape.java @@ -39,10 +39,7 @@ import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; -import com.jme3.math.Vector3f; import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Basic capsule collision shape diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java index 2a4ad596de..b251e0ea6a 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/CollisionShape.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,9 +44,17 @@ */ public abstract class CollisionShape implements Savable { + /** + * default margin for new shapes (in physics-space units, >0, + * default=0.04) + */ + private static float defaultMargin = 0.04f; protected com.bulletphysics.collision.shapes.CollisionShape cShape; protected Vector3f scale = new Vector3f(1, 1, 1); - protected float margin = 0.0f; + /** + * copy of collision margin (in physics-space units, >0, default=0) + */ + protected float margin = defaultMargin; public CollisionShape() { } @@ -88,6 +96,26 @@ public float getMargin() { return cShape.getMargin(); } + /** + * Alter the default margin for new shapes. + * + * @param margin the desired margin distance (in physics-space units, >0, + * default=0.04) + */ + public static void setDefaultMargin(float margin) { + defaultMargin = margin; + } + + /** + * Read the default margin for new shapes. + * + * @return margin the default margin distance (in physics-space units, + * >0) + */ + public static float getDefaultMargin() { + return defaultMargin; + } + public void setMargin(float margin) { cShape.setMargin(margin); this.margin = margin; diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/ConeCollisionShape.java b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/ConeCollisionShape.java index 2dc27dcb18..cdcee46e4a 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/ConeCollisionShape.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/ConeCollisionShape.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -64,7 +64,7 @@ public ConeCollisionShape() { * * @param radius The radius of the cone in world units. * @param height The height of the cone in world units. - * @param The axis towards which the cone faces, see the PhysicsSpace.AXIS_* constants. + * @param axis The axis towards which the cone faces, see the PhysicsSpace.AXIS_* constants. */ public ConeCollisionShape(float radius, float height, int axis) { this.radius = radius; diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/SphereCollisionShape.java b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/SphereCollisionShape.java index fb6976aa39..1a568ddf41 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/SphereCollisionShape.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/collision/shapes/SphereCollisionShape.java @@ -37,10 +37,7 @@ import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; -import com.jme3.math.Vector3f; import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Basic sphere collision shape diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java index c057d99d24..1d7f540387 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsCharacter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2018 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -169,6 +169,26 @@ public float getMaxSlope() { return character.getMaxSlope(); } + /** + * Enable/disable this body's contact response. + * + * @param newState true to respond to contacts (default=true) + */ + public void setContactResponse(boolean newState) { + if (!newState) { + throw new UnsupportedOperationException("Not implemented."); + } + } + + /** + * Test whether this body responds to contacts. + * + * @return true if responsive, otherwise false + */ + public boolean isContactResponse() { + return true; + } + public boolean onGround() { return character.onGround(); } @@ -279,6 +299,7 @@ public void read(JmeImporter e) throws IOException { buildObject(); character = new KinematicCharacterController(gObject, (ConvexShape) collisionShape.getCShape(), stepHeight); setGravity(capsule.readFloat("gravity", 9.8f * 3)); + setContactResponse(capsule.readBoolean("contactResponse", true)); setMaxSlope(capsule.readFloat("maxSlope", 1.0f)); setFallSpeed(capsule.readFloat("fallSpeed", 55.0f)); setJumpSpeed(capsule.readFloat("jumpSpeed", 10.0f)); diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java index 6798c63fd1..d585c2001f 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -276,6 +276,33 @@ public boolean isKinematic() { return kinematic; } + /** + * Enable/disable this body's contact response. + * + * @param responsive true to respond to contacts, false to ignore them + * (default=true) + */ + public void setContactResponse(boolean responsive) { + int flags = rBody.getCollisionFlags(); + if (responsive) { + flags &= ~CollisionFlags.NO_CONTACT_RESPONSE; + } else { + flags |= CollisionFlags.NO_CONTACT_RESPONSE; + } + rBody.setCollisionFlags(flags); + } + + /** + * Test whether this body responds to contacts. + * + * @return true if responsive, otherwise false + */ + public boolean isContactResponse() { + int flags = rBody.getCollisionFlags(); + boolean result = (flags & CollisionFlags.NO_CONTACT_RESPONSE) == 0x0; + return result; + } + public void setCcdSweptSphereRadius(float radius) { rBody.setCcdSweptSphereRadius(radius); } @@ -614,6 +641,12 @@ public void destroy() { rBody.destroy(); } + /** + * Serialize this body, for example when saving to a J3O file. + * + * @param e exporter (not null) + * @throws IOException from exporter + */ @Override public void write(JmeExporter e) throws IOException { super.write(e); @@ -637,10 +670,18 @@ public void write(JmeExporter e) throws IOException { capsule.write(getPhysicsLocation(new Vector3f()), "physicsLocation", new Vector3f()); capsule.write(getPhysicsRotationMatrix(new Matrix3f()), "physicsRotation", new Matrix3f()); + capsule.write(getLinearVelocity(), "linearVelocity", null); + capsule.write(getAngularVelocity(), "angularVelocity", null); capsule.writeSavableArrayList(joints, "joints", null); } + /** + * De-serialize this body, for example when loading from a J3O file. + * + * @param e importer (not null) + * @throws IOException from importer + */ @Override public void read(JmeImporter e) throws IOException { super.read(e); @@ -650,6 +691,7 @@ public void read(JmeImporter e) throws IOException { this.mass = mass; rebuildRigidBody(); setGravity((Vector3f) capsule.readSavable("gravity", Vector3f.ZERO.clone())); + setContactResponse(capsule.readBoolean("contactResponse", true)); setFriction(capsule.readFloat("friction", 0.5f)); setKinematic(capsule.readBoolean("kinematic", false)); @@ -662,6 +704,8 @@ public void read(JmeImporter e) throws IOException { setPhysicsLocation((Vector3f) capsule.readSavable("physicsLocation", new Vector3f())); setPhysicsRotation((Matrix3f) capsule.readSavable("physicsRotation", new Matrix3f())); + setLinearVelocity((Vector3f) capsule.readSavable("linearVelocity", new Vector3f())); + setAngularVelocity((Vector3f) capsule.readSavable("angularVelocity", new Vector3f())); joints = capsule.readSavableArrayList("joints", null); } diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsVehicle.java b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsVehicle.java index b21fa698cb..529cb9c86e 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsVehicle.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/PhysicsVehicle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,13 +41,9 @@ import com.jme3.export.JmeImporter; import com.jme3.export.OutputCapsule; import com.jme3.math.Vector3f; -import com.jme3.scene.Geometry; -import com.jme3.scene.Node; import com.jme3.scene.Spatial; -import com.jme3.scene.debug.Arrow; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; /** *

        PhysicsVehicleNode - Special PhysicsNode that implements vehicle functions

        @@ -447,7 +443,7 @@ public void brake(int wheel, float force) { /** * Get the current speed of the vehicle in km/h - * @return + * @return the speed */ public float getCurrentVehicleSpeedKmHour() { return vehicle.getCurrentSpeedKmHour(); diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/infos/RigidBodyMotionState.java b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/infos/RigidBodyMotionState.java index 6de4f040b9..3249e96074 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/objects/infos/RigidBodyMotionState.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/objects/infos/RigidBodyMotionState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,8 +68,8 @@ public RigidBodyMotionState() { /** * called from bullet when creating the rigidbody - * @param t - * @return + * @param t caller-provided storage for the Transform + * @return t */ public Transform getWorldTransform(Transform t) { t.set(motionStateTrans); diff --git a/jme3-jbullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java b/jme3-jbullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java index 077326d574..ab1e7b9b10 100644 --- a/jme3-jbullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java +++ b/jme3-jbullet/src/main/java/com/jme3/bullet/util/DebugShapeFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,7 +68,7 @@ public class DebugShapeFactory { * Creates a debug shape from the given collision shape. This is mostly used internally.
        * To attach a debug shape to a physics object, call attachDebugShape(AssetManager manager); on it. * @param collisionShape - * @return + * @return a new Spatial or null */ public static Spatial getDebugShape(CollisionShape collisionShape) { if (collisionShape == null) { @@ -152,7 +152,7 @@ private static FloatBuffer getVertices(ConcaveShape concaveShape) { * Processes the given convex shape to retrieve a correctly ordered FloatBuffer to * construct the shape from with a TriMesh. * - * @param convexShape the shape to retreieve the vertices from. + * @param convexShape the shape to retrieve the vertices from. * @return the vertices as a FloatBuffer, ordered as Triangles. */ private static FloatBuffer getVertices(ConvexShape convexShape) { diff --git a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclBuffer.java b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclBuffer.java index 1085ad7d2b..6cee05af07 100644 --- a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclBuffer.java +++ b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclBuffer.java @@ -36,7 +36,6 @@ import com.jogamp.opencl.*; import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.llb.gl.CLGL; -import java.util.EnumSet; /** * diff --git a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclDevice.java b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclDevice.java index d4d9b08e1e..adeeb77202 100644 --- a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclDevice.java +++ b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclDevice.java @@ -32,9 +32,7 @@ package com.jme3.opencl.jocl; import com.jme3.opencl.Device; -import com.jme3.opencl.Platform; import com.jogamp.opencl.CLDevice; -import java.util.Arrays; import java.util.Collection; /** diff --git a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclEvent.java b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclEvent.java index c79504dfa9..3354f71ef6 100644 --- a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclEvent.java +++ b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclEvent.java @@ -32,7 +32,6 @@ package com.jme3.opencl.jocl; import com.jme3.opencl.Event; -import com.jme3.opencl.OpenCLObjectManager; import com.jogamp.opencl.CLPlatform; import com.jogamp.opencl.llb.CL; import java.util.logging.Logger; diff --git a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclPlatform.java b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclPlatform.java index a481e88185..65d572526f 100644 --- a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclPlatform.java +++ b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclPlatform.java @@ -31,13 +31,10 @@ */ package com.jme3.opencl.jocl; -import com.jme3.opencl.Device; import com.jme3.opencl.Platform; import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLPlatform; -import com.jogamp.opencl.llb.CL; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; diff --git a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclProgram.java b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclProgram.java index e643418769..2f265290ae 100644 --- a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclProgram.java +++ b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/JoclProgram.java @@ -35,7 +35,6 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.opencl.CLPlatform; -import com.jogamp.opencl.CLProgram; import com.jogamp.opencl.llb.CL; import com.jogamp.opencl.util.CLUtil; import java.nio.ByteBuffer; diff --git a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/Utils.java b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/Utils.java index c1b8c91d7a..eb9738f445 100644 --- a/jme3-jogl/src/main/java/com/jme3/opencl/jocl/Utils.java +++ b/jme3-jogl/src/main/java/com/jme3/opencl/jocl/Utils.java @@ -36,15 +36,9 @@ import com.jme3.opencl.OpenCLException; import com.jme3.util.BufferUtils; import com.jogamp.common.nio.PointerBuffer; -import com.jogamp.opencl.CLEventList; import com.jogamp.opencl.CLException; -import com.jogamp.opencl.CLMemory; -import com.jogamp.opencl.CLVersion; import com.jogamp.opencl.llb.CL; -import java.lang.reflect.Field; import java.nio.*; -import java.util.EnumSet; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java index 12c1d10cb7..0d3af3a70f 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglContext.java @@ -64,7 +64,6 @@ import com.jogamp.opencl.CLDevice; import com.jogamp.opencl.CLPlatform; import com.jogamp.opencl.gl.CLGLContext; -import com.jogamp.opencl.llb.CL; import java.nio.IntBuffer; import java.util.concurrent.atomic.AtomicBoolean; diff --git a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglCommandQueue.java b/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglCommandQueue.java index 28c8676202..408b0d35b1 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglCommandQueue.java +++ b/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglCommandQueue.java @@ -33,7 +33,6 @@ import com.jme3.opencl.CommandQueue; import com.jme3.opencl.Device; -import com.jme3.opencl.OpenCLObjectManager; import org.lwjgl.opencl.CL10; import org.lwjgl.opencl.CLCommandQueue; diff --git a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java b/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java index 7811e3a004..19ae988531 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java +++ b/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java @@ -32,7 +32,6 @@ package com.jme3.opencl.lwjgl; import com.jme3.opencl.Device; -import com.jme3.opencl.Platform; import java.util.Arrays; import java.util.Collection; import org.lwjgl.opencl.CL10; diff --git a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java b/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java index 610b07e478..367aeafb01 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java +++ b/jme3-lwjgl/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java @@ -31,7 +31,6 @@ */ package com.jme3.opencl.lwjgl; -import com.jme3.opencl.Device; import com.jme3.opencl.Platform; import java.util.ArrayList; import java.util.Arrays; diff --git a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglAbstractDisplay.java b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglAbstractDisplay.java index e019008f2a..528c788ead 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglAbstractDisplay.java +++ b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglAbstractDisplay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -135,7 +135,7 @@ protected boolean checkGLError(){ try { Util.checkGLError(); } catch (OpenGLException ex){ - listener.handleError("An OpenGL error has occured!", ex); + listener.handleError("An OpenGL error has occurred!", ex); } // NOTE: Always return true since this is used in an "assert" statement return true; @@ -203,7 +203,7 @@ protected void deinitInThread(){ public void run(){ if (listener == null) { throw new IllegalStateException("SystemListener is not set on context!" - + "Must set with JmeContext.setSystemListner()."); + + "Must set with JmeContext.setSystemListener()."); } loadNatives(); diff --git a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java index 68d46b1c7f..624ad3e027 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java +++ b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglContext.java @@ -58,7 +58,6 @@ import com.jme3.renderer.opengl.GLTimingState; import com.jme3.renderer.opengl.GLTracer; import com.jme3.system.*; -import java.io.File; import java.util.ArrayList; import java.util.List; @@ -107,11 +106,61 @@ protected void printContextInitInfo() { Display.getPixelScaleFactor()}); } + protected int[] getGLVersion(String renderer) { + int maj = -1, min = -1; + switch (settings.getRenderer()) { + case AppSettings.LWJGL_OPENGL2: + maj = 2; + min = 0; + break; + // case AppSettings.LWJGL_OPENGL30: + // maj=3; + // min=0; + // break; + case AppSettings.LWJGL_OPENGL3: + // case AppSettings.LWJGL_OPENGL32: + maj = 3; + min = 2; + break; + case AppSettings.LWJGL_OPENGL33: + maj = 3; + min = 3; + break; + case AppSettings.LWJGL_OPENGL4: + // case AppSettings.LWJGL_OPENGL40: + maj = 4; + min = 0; + break; + case AppSettings.LWJGL_OPENGL41: + maj = 4; + min = 1; + break; + case AppSettings.LWJGL_OPENGL42: + maj = 4; + min = 2; + break; + case AppSettings.LWJGL_OPENGL43: + maj = 4; + min = 3; + break; + case AppSettings.LWJGL_OPENGL44: + maj = 4; + min = 4; + break; + case AppSettings.LWJGL_OPENGL45: + maj = 4; + min = 5; + break; + } + return maj == -1 ? null : new int[] { maj, min }; + } + protected ContextAttribs createContextAttribs() { - if (settings.getBoolean("GraphicsDebug") || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { + int vers[] = getGLVersion(settings.getRenderer()); + if (settings.getBoolean("GraphicsDebug") || (vers != null && vers[0] != 2)) { ContextAttribs attr; - if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { - attr = new ContextAttribs(3, 2); + if (vers != null && vers[0] != 2) { + attr = new ContextAttribs(vers[0], vers[1]); attr = attr.withProfileCore(true).withForwardCompatible(true).withProfileCompatibility(false); } else { attr = new ContextAttribs(); @@ -205,8 +254,8 @@ protected void initContextFirstTime() { + "required for jMonkeyEngine"); } - if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2) - || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) { + int vers[] = getGLVersion(settings.getRenderer()); + if (vers != null) { GL gl = new LwjglGL(); GLExt glext = new LwjglGLExt(); GLFbo glfbo; @@ -261,7 +310,7 @@ protected void initContextFirstTime() { @SuppressWarnings("unchecked") protected void initOpenCL() { - logger.info("Initialize OpenCL wiht LWJGL2"); + logger.info("Initialize OpenCL with LWJGL2"); try { CL.create(); diff --git a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java index afd2c7508a..d4c86a780b 100644 --- a/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java +++ b/jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglOffscreenBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,7 +97,7 @@ protected boolean checkGLError(){ try { Util.checkGLError(); } catch (OpenGLException ex){ - listener.handleError("An OpenGL error has occured!", ex); + listener.handleError("An OpenGL error has occurred!", ex); } // NOTE: Always return true since this is used in an "assert" statement return true; diff --git a/jme3-lwjgl3/build.gradle b/jme3-lwjgl3/build.gradle index 0ac0a55d2c..442aa091e8 100644 --- a/jme3-lwjgl3/build.gradle +++ b/jme3-lwjgl3/build.gradle @@ -2,7 +2,7 @@ if (!hasProperty('mainClass')) { ext.mainClass = '' } -def lwjglVersion = '3.1.6' +def lwjglVersion = '3.2.1' sourceCompatibility = '1.8' @@ -31,4 +31,4 @@ dependencies { runtime "org.lwjgl:lwjgl-openal:${lwjglVersion}:natives-windows" runtime "org.lwjgl:lwjgl-openal:${lwjglVersion}:natives-linux" runtime "org.lwjgl:lwjgl-openal:${lwjglVersion}:natives-macos" -} \ No newline at end of file +} diff --git a/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java b/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java index d8d61805cd..6f3f6a3799 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/GlfwJoystickInput.java @@ -49,11 +49,14 @@ */ public class GlfwJoystickInput implements JoyInput { - private static final Logger LOGGER = Logger.getLogger(InputManager.class.getName()); + private static final Logger LOGGER = Logger.getLogger(GlfwJoystickInput.class.getName()); private RawInputListener listener; + private final Map joysticks = new HashMap<>(); + private final Map joyButtonPressed = new HashMap<>(); + private boolean initialized = false; @Override @@ -63,8 +66,28 @@ public void setJoyRumble(final int joyId, final float amount) { } } + public void fireJoystickConnectedEvent(int jid) { + Joystick joystick = joysticks.get(jid); + ((InputManager)listener).fireJoystickConnectedEvent(joystick); + } + + public void fireJoystickDisconnectedEvent(int jid) { + Joystick joystick = joysticks.get(jid); + ((InputManager)listener).fireJoystickDisconnectedEvent(joystick); + } + + public void reloadJoysticks() { + joysticks.clear(); + + InputManager inputManager = (InputManager) listener; + + Joystick[] joysticks = loadJoysticks(inputManager); + inputManager.setJoysticks(joysticks); + } + @Override public Joystick[] loadJoysticks(final InputManager inputManager) { + for (int i = 0; i < GLFW_JOYSTICK_LAST; i++) { if (glfwJoystickPresent(i)) { final String name = glfwGetJoystickName(i); @@ -88,8 +111,11 @@ public Joystick[] loadJoysticks(final InputManager inputManager) { int buttonIndex = 0; while (byteBuffer.hasRemaining()) { byteBuffer.get(); + final String logicalId = JoystickCompatibilityMappings.remapComponent(joystick.getName(), String.valueOf(buttonIndex)); - joystick.addButton(new DefaultJoystickButton(inputManager, joystick, buttonIndex, String.valueOf(buttonIndex), logicalId)); + final JoystickButton button = new DefaultJoystickButton(inputManager, joystick, buttonIndex, String.valueOf(buttonIndex), logicalId); + joystick.addButton(button); + joyButtonPressed.put(button, false); buttonIndex++; } } @@ -120,20 +146,34 @@ public void initialize() { @Override public void update() { for (final Map.Entry entry : joysticks.entrySet()) { + // Axes final FloatBuffer axisValues = glfwGetJoystickAxes(entry.getKey()); - for (final JoystickAxis axis : entry.getValue().getAxes()) { - final float value = axisValues.get(axis.getAxisId()); - listener.onJoyAxisEvent(new JoyAxisEvent(axis, value)); + // if a joystick is added or removed, the callback reloads the joysticks. + // when the callback is called and reloads the joystick, this iterator may already have started iterating. + // To avoid a NullPointerException we null-check the axisValues and bytebuffer objects. + // If the joystick it's iterating over no-longer exists it will return null. + + if (axisValues != null) { + for (final JoystickAxis axis : entry.getValue().getAxes()) { + final float value = axisValues.get(axis.getAxisId()); + listener.onJoyAxisEvent(new JoyAxisEvent(axis, value)); + } } // Buttons final ByteBuffer byteBuffer = glfwGetJoystickButtons(entry.getKey()); - for (final JoystickButton button : entry.getValue().getButtons()) { - final boolean pressed = byteBuffer.get(button.getButtonId()) == GLFW_PRESS; - listener.onJoyButtonEvent(new JoyButtonEvent(button, pressed)); + if (byteBuffer != null) { + for (final JoystickButton button : entry.getValue().getButtons()) { + final boolean pressed = byteBuffer.get(button.getButtonId()) == GLFW_PRESS; + + if (joyButtonPressed.get(button) != pressed) { + joyButtonPressed.put(button, pressed); + listener.onJoyButtonEvent(new JoyButtonEvent(button, pressed)); + } + } } } } @@ -213,6 +253,3 @@ public int getYAxisIndex() { } } } - - - diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java index d75cebd8e8..a6acd255fc 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglDevice.java @@ -32,7 +32,6 @@ package com.jme3.opencl.lwjgl; import com.jme3.opencl.Device; -import com.jme3.opencl.Platform; import com.jme3.opencl.lwjgl.info.Info; import java.util.Arrays; import java.util.Collection; diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java index 6914cba190..7df32c44c5 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/LwjglPlatform.java @@ -31,20 +31,15 @@ */ package com.jme3.opencl.lwjgl; -import com.jme3.lwjgl3.utils.APIBuffer; -import static com.jme3.lwjgl3.utils.APIUtil.apiBuffer; -import com.jme3.opencl.Device; import com.jme3.opencl.Platform; import com.jme3.opencl.lwjgl.info.Info; import java.nio.IntBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import org.lwjgl.PointerBuffer; import org.lwjgl.opencl.CL10; -import static org.lwjgl.system.Pointer.POINTER_SHIFT; /** * diff --git a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java index fd48b21a53..17e22461c6 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/opencl/lwjgl/info/Info.java @@ -35,29 +35,28 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * String version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} + * String version of CL10#clGetPlatformInfo */ public static String clGetPlatformInfoStringASCII(long platform, int param_name) { return PLATFORM.getStringASCII(platform, param_name); } /** - * String with explicit length version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} + * String with explicit length version of CL10#clGetPlatformInfo */ public static String clGetPlatformInfoStringASCII(long platform, int param_name, int param_value_size) { return PLATFORM.getStringASCII(platform, param_name, param_value_size); } /** - * UTF-8 string version of: {@link CL10#clGetPlatformInfo GetPlatformInfo} + * UTF-8 string version of CL10#clGetPlatformInfo */ public static String clGetPlatformInfoStringUTF8(long platform, int param_name) { return PLATFORM.getStringUTF8(platform, param_name); } /** - * UTF-8 string with explicit length version of: - * {@link CL10#clGetPlatformInfo GetPlatformInfo} + * UTF-8 string with explicit length version of CL10#clGetPlatformInfo */ public static String clGetPlatformInfoStringUTF8(long platform, int param_name, int param_value_size) { return PLATFORM.getStringUTF8(platform, param_name, param_value_size); @@ -74,66 +73,63 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single boolean value version of: - * {@link CL10#clGetDeviceInfo GetDeviceInfo} + * Single boolean value version of CL10#clGetDeviceInfo */ public static boolean clGetDeviceInfoBoolean(long device, int param_name) { return DEVICE.getBoolean(device, param_name); } /** - * Single int value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + * Single int value version of CL10#clGetDeviceInfo */ public static int clGetDeviceInfoInt(long device, int param_name) { return DEVICE.getInt(device, param_name); } /** - * Single long value version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + * Single long value version of CL10#clGetDeviceInfo */ public static long clGetDeviceInfoLong(long device, int param_name) { return DEVICE.getLong(device, param_name); } /** - * Single pointer value version of: - * {@link CL10#clGetDeviceInfo GetDeviceInfo} + * Single pointer value version of CL10#clGetDeviceInfo */ public static long clGetDeviceInfoPointer(long device, int param_name) { return DEVICE.getPointer(device, param_name); } /** - * PointBuffer version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + * PointBuffer version of CL10#clGetDeviceInfo */ public static int clGetDeviceInfoPointers(long device, int param_name, PointerBuffer target) { return DEVICE.getPointers(device, param_name, target); } /** - * String version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + * String version of CL10#clGetDeviceInfo */ public static String clGetDeviceInfoStringASCII(long device, int param_name) { return DEVICE.getStringASCII(device, param_name); } /** - * String with explicit length version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + * String with explicit length version of CL10#clGetDeviceInfo */ public static String clGetDeviceInfoStringASCII(long device, int param_name, int param_value_size) { return DEVICE.getStringASCII(device, param_name, param_value_size); } /** - * UTF-8 string version of: {@link CL10#clGetDeviceInfo GetDeviceInfo} + * UTF-8 string version of CL10#clGetDeviceInfo */ public static String clGetDeviceInfoStringUTF8(long device, int param_name) { return DEVICE.getStringUTF8(device, param_name); } /** - * UTF-8 string with explicit length version of: - * {@link CL10#clGetDeviceInfo GetDeviceInfo} + * UTF-8 string with explicit length version of CL10#clGetDeviceInfo */ public static String clGetDeviceInfoStringUTF8(long device, int param_name, int param_value_size) { return DEVICE.getStringUTF8(device, param_name, param_value_size); @@ -150,22 +146,21 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single int value version of: {@link CL10#clGetContextInfo GetContextInfo} + * Single int value version of CL10#clGetContextInfo */ public static int clGetContextInfoInt(long context, int param_name) { return CONTEXT.getInt(context, param_name); } /** - * Single pointer value version of: - * {@link CL10#clGetContextInfo GetContextInfo} + * Single pointer value version of CL10#clGetContextInfo */ public static long clGetContextInfoPointer(long context, int param_name) { return CONTEXT.getPointer(context, param_name); } /** - * PointBuffer version of: {@link CL10#clGetContextInfo GetContextInfo} + * PointBuffer version of CL10#clGetContextInfo */ public static int clGetContextInfoPointers(long context, int param_name, PointerBuffer target) { return CONTEXT.getPointers(context, param_name, target); @@ -182,24 +177,21 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single int value version of: - * {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} + * Single int value version of CL10#clGetCommandQueueInfo */ public static int clGetCommandQueueInfoInt(long command_queue, int param_name) { return COMMAND_QUEUE.getInt(command_queue, param_name); } /** - * Single pointer value version of: - * {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} + * Single pointer value version of CL10#clGetCommandQueueInfo */ public static long clGetCommandQueueInfoPointer(long command_queue, int param_name) { return COMMAND_QUEUE.getPointer(command_queue, param_name); } /** - * PointBuffer version of: - * {@link CL10#clGetCommandQueueInfo GetCommandQueueInfo} + * PointBuffer version of CL10#clGetCommandQueueInfo */ public static int clGetCommandQueueInfoPointers(long command_queue, int param_name, PointerBuffer target) { return COMMAND_QUEUE.getPointers(command_queue, param_name, target); @@ -216,39 +208,35 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single boolean value version of: - * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + * Single boolean value version of CL10#clGetMemObjectInfo */ public static boolean clGetMemObjectInfoBoolean(long memobj, int param_name) { return MEM_OBJECT.getBoolean(memobj, param_name); } /** - * Single int value version of: - * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + * Single int value version of org.lwjgl.opencl.CL10#clGetMemObjectInfo */ public static int clGetMemObjectInfoInt(long memobj, int param_name) { return MEM_OBJECT.getInt(memobj, param_name); } /** - * Single long value version of: - * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + * Single long value version of org.lwjgl.opencl.CL10#clGetMemObjectInfo */ public static long clGetMemObjectInfoLong(long memobj, int param_name) { return MEM_OBJECT.getLong(memobj, param_name); } /** - * Single pointer value version of: - * {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + * Single pointer value version of org.lwjgl.opencl.CL10#clGetMemObjectInfo */ public static long clGetMemObjectInfoPointer(long memobj, int param_name) { return MEM_OBJECT.getPointer(memobj, param_name); } /** - * PointBuffer version of: {@link CL10#clGetMemObjectInfo GetMemObjectInfo} + * PointBuffer version of org.lwjgl.opencl.CL10#clGetMemObjectInfo */ public static int clGetMemObjectInfoPointers(long memobj, int param_name, PointerBuffer target) { return MEM_OBJECT.getPointers(memobj, param_name, target); @@ -265,21 +253,21 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single int value version of: {@link CL10#clGetImageInfo GetImageInfo} + * Single int value version of org.lwjgl.opencl.CL10#clGetImageInfo */ public static int clGetImageInfoInt(long image, int param_name) { return IMAGE.getInt(image, param_name); } /** - * Single pointer value version of: {@link CL10#clGetImageInfo GetImageInfo} + * Single pointer value version of org.lwjgl.opencl.CL10#clGetImageInfo */ public static long clGetImageInfoPointer(long image, int param_name) { return IMAGE.getPointer(image, param_name); } /** - * PointBuffer version of: {@link CL10#clGetImageInfo GetImageInfo} + * PointBuffer version of org.lwjgl.opencl.CL10#clGetImageInfo */ public static int clGetImageInfoPointers(long image, int param_name, PointerBuffer target) { return IMAGE.getPointers(image, param_name, target); @@ -296,7 +284,7 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single int value version of: {@link CL20#clGetPipeInfo GetPipeInfo} + * Single int value version of org.lwjgl.opencl.CL20#clGetPipeInfo */ public static int clGetPipeInfoInt(long pipe, int param_name) { return PIPE.getInt(pipe, param_name); @@ -313,43 +301,42 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single int value version of: {@link CL10#clGetProgramInfo GetProgramInfo} + * Single int value version of org.lwjgl.opencl.CL10#clGetProgramInfo */ public static int clGetProgramInfoInt(long program, int param_name) { return PROGRAM.getInt(program, param_name); } /** - * Single pointer value version of: - * {@link CL10#clGetProgramInfo GetProgramInfo} + * Single pointer value version of org.lwjgl.opencl.CL10#clGetProgramInfo */ public static long clGetProgramInfoPointer(long program, int param_name) { return PROGRAM.getPointer(program, param_name); } /** - * PointBuffer version of: {@link CL10#clGetProgramInfo GetProgramInfo} + * PointBuffer version of org.lwjgl.opencl.CL10#clGetProgramInfo */ public static int clGetProgramInfoPointers(long program, int param_name, PointerBuffer target) { return PROGRAM.getPointers(program, param_name, target); } /** - * String version of: {@link CL10#clGetProgramInfo GetProgramInfo} + * String version of org.lwjgl.opencl.CL10#clGetProgramInfo */ public static String clGetProgramInfoStringASCII(long program, int param_name) { return PROGRAM.getStringASCII(program, param_name); } /** - * String with explicit length version of: {@link CL10#clGetProgramInfo GetProgramInfo} + * String with explicit length version of org.lwjgl.opencl.CL10#clGetProgramInfo */ public static String clGetProgramInfoStringASCII(long program, int param_name, int param_value_size) { return PROGRAM.getStringASCII(program, param_name, param_value_size); } /** - * UTF-8 string version of: {@link CL10#clGetProgramInfo GetProgramInfo} + * UTF-8 string version of: {@link org.lwjgl.opencl.CL10#clGetProgramInfo GetProgramInfo} */ public static String clGetProgramInfoStringUTF8(long program, int param_name) { return PROGRAM.getStringUTF8(program, param_name); @@ -357,7 +344,7 @@ public static String clGetProgramInfoStringUTF8(long program, int param_name) { /** * UTF-8 string with explicit length version of: - * {@link CL10#clGetProgramInfo GetProgramInfo} + * {@link org.lwjgl.opencl.CL10#clGetProgramInfo GetProgramInfo} */ public static String clGetProgramInfoStringUTF8(long program, int param_name, int param_value_size) { return PROGRAM.getStringUTF8(program, param_name, param_value_size); @@ -375,7 +362,7 @@ protected int get(long pointer, long arg, int param_name, long param_value_size, /** * Single int value version of: - * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + * {@link org.lwjgl.opencl.CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ public static int clGetProgramBuildInfoInt(long program, long device, int param_name) { return PROGRAM_BUILD.getInt(program, device, param_name); @@ -383,7 +370,7 @@ public static int clGetProgramBuildInfoInt(long program, long device, int param_ /** * Single pointer value version of: - * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + * {@link org.lwjgl.opencl.CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ public static long clGetProgramBuildInfoPointer(long program, long device, int param_name) { return PROGRAM_BUILD.getPointer(program, device, param_name); @@ -391,21 +378,21 @@ public static long clGetProgramBuildInfoPointer(long program, long device, int p /** * PointBuffer version of: - * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + * {@link org.lwjgl.opencl.CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ public static int clGetProgramBuildInfoPointers(long program, long device, int param_name, PointerBuffer target) { return PROGRAM_BUILD.getPointers(program, device, param_name, target); } /** - * String version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + * String version of: {@link org.lwjgl.opencl.CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ public static String clGetProgramBuildInfoStringASCII(long program, long device, int param_name) { return PROGRAM_BUILD.getStringASCII(program, device, param_name); } /** - * String with explicit length version of: {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + * String with explicit length version of: {@link org.lwjgl.opencl.CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ public static String clGetProgramBuildInfoStringASCII(long program, long device, int param_name, int param_value_size) { return PROGRAM_BUILD.getStringASCII(program, device, param_name, param_value_size); @@ -413,7 +400,7 @@ public static String clGetProgramBuildInfoStringASCII(long program, long device, /** * UTF-8 string version of: - * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + * {@link org.lwjgl.opencl.CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ public static String clGetProgramBuildInfoStringUTF8(long program, long device, int param_name) { return PROGRAM_BUILD.getStringUTF8(program, device, param_name); @@ -421,7 +408,7 @@ public static String clGetProgramBuildInfoStringUTF8(long program, long device, /** * UTF-8 string with explicit length version of: - * {@link CL10#clGetProgramBuildInfo GetProgramBuildInfo} + * {@link org.lwjgl.opencl.CL10#clGetProgramBuildInfo GetProgramBuildInfo} */ public static String clGetProgramBuildInfoStringUTF8(long program, long device, int param_name, int param_value_size) { return PROGRAM_BUILD.getStringUTF8(program, device, param_name, param_value_size); @@ -438,7 +425,7 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single int value version of: {@link CL10#clGetKernelInfo GetKernelInfo} + * Single int value version of: {@link org.lwjgl.opencl.CL10#clGetKernelInfo GetKernelInfo} */ public static int clGetKernelInfoInt(long kernel, int param_name) { return KERNEL.getInt(kernel, param_name); @@ -446,35 +433,35 @@ public static int clGetKernelInfoInt(long kernel, int param_name) { /** * Single pointer value version of: - * {@link CL10#clGetKernelInfo GetKernelInfo} + * {@link org.lwjgl.opencl.CL10#clGetKernelInfo GetKernelInfo} */ public static long clGetKernelInfoPointer(long kernel, int param_name) { return KERNEL.getPointer(kernel, param_name); } /** - * PointBuffer version of: {@link CL10#clGetKernelInfo GetKernelInfo} + * PointBuffer version of: {@link org.lwjgl.opencl.CL10#clGetKernelInfo GetKernelInfo} */ public static int clGetKernelInfoPointers(long kernel, int param_name, PointerBuffer target) { return KERNEL.getPointers(kernel, param_name, target); } /** - * String version of: {@link CL10#clGetKernelInfo GetKernelInfo} + * String version of: {@link org.lwjgl.opencl.CL10#clGetKernelInfo GetKernelInfo} */ public static String clGetKernelInfoStringASCII(long kernel, int param_name) { return KERNEL.getStringASCII(kernel, param_name); } /** - * String with explicit length version of: {@link CL10#clGetKernelInfo GetKernelInfo} + * String with explicit length version of: {@link org.lwjgl.opencl.CL10#clGetKernelInfo GetKernelInfo} */ public static String clGetKernelInfoStringASCII(long kernel, int param_name, int param_value_size) { return KERNEL.getStringASCII(kernel, param_name, param_value_size); } /** - * UTF-8 string version of: {@link CL10#clGetKernelInfo GetKernelInfo} + * UTF-8 string version of: {@link org.lwjgl.opencl.CL10#clGetKernelInfo GetKernelInfo} */ public static String clGetKernelInfoStringUTF8(long kernel, int param_name) { return KERNEL.getStringUTF8(kernel, param_name); @@ -482,7 +469,7 @@ public static String clGetKernelInfoStringUTF8(long kernel, int param_name) { /** * UTF-8 string with explicit length version of: - * {@link CL10#clGetKernelInfo GetKernelInfo} + * {@link org.lwjgl.opencl.CL10#clGetKernelInfo GetKernelInfo} */ public static String clGetKernelInfoStringUTF8(long kernel, int param_name, int param_value_size) { return KERNEL.getStringUTF8(kernel, param_name, param_value_size); @@ -500,7 +487,7 @@ protected int get(long pointer, long arg, int param_name, long param_value_size, /** * Single long value version of: - * {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} + * {@link org.lwjgl.opencl.CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} */ public static long clGetKernelWorkGroupInfoLong(long kernel, long device, int param_name) { return KERNEL_WORKGROUP.getLong(kernel, device, param_name); @@ -508,7 +495,7 @@ public static long clGetKernelWorkGroupInfoLong(long kernel, long device, int pa /** * Single pointer value version of: - * {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} + * {@link org.lwjgl.opencl.CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} */ public static long clGetKernelWorkGroupInfoPointer(long kernel, long device, int param_name) { return KERNEL_WORKGROUP.getPointer(kernel, device, param_name); @@ -516,7 +503,7 @@ public static long clGetKernelWorkGroupInfoPointer(long kernel, long device, int /** * PointBuffer version of: - * {@link CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} + * {@link org.lwjgl.opencl.CL10#clGetKernelWorkGroupInfo GetKernelWorkGroupInfo} */ public static int clGetKernelWorkGroupInfoPointers(long kernel, long device, int param_name, PointerBuffer target) { return KERNEL_WORKGROUP.getPointers(kernel, device, param_name, target); @@ -534,7 +521,7 @@ protected int get(long pointer, int arg, int param_name, long param_value_size, /** * Single int value version of: - * {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + * {@link org.lwjgl.opencl.CL12#clGetKernelArgInfo GetKernelArgInfo} */ public static int clGetKernelArgInfoInt(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getInt(kernel, arg_indx, param_name); @@ -542,28 +529,28 @@ public static int clGetKernelArgInfoInt(long kernel, int arg_indx, int param_nam /** * Single long value version of: - * {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + * {@link org.lwjgl.opencl.CL12#clGetKernelArgInfo GetKernelArgInfo} */ public static long clGetKernelArgInfoLong(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getLong(kernel, arg_indx, param_name); } /** - * String version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + * String version of: {@link org.lwjgl.opencl.CL12#clGetKernelArgInfo GetKernelArgInfo} */ public static String clGetKernelArgInfoStringASCII(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getStringASCII(kernel, arg_indx, param_name); } /** - * String with explicit length version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + * String with explicit length version of: {@link org.lwjgl.opencl.CL12#clGetKernelArgInfo GetKernelArgInfo} */ public static String clGetKernelArgInfoStringASCII(long kernel, int arg_indx, int param_name, int param_value_size) { return KERNEL_ARG.getStringASCII(kernel, arg_indx, param_name, param_value_size); } /** - * UTF-8 string version of: {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + * UTF-8 string version of: {@link org.lwjgl.opencl.CL12#clGetKernelArgInfo GetKernelArgInfo} */ public static String clGetKernelArgInfoStringUTF8(long kernel, int arg_indx, int param_name) { return KERNEL_ARG.getStringUTF8(kernel, arg_indx, param_name); @@ -571,7 +558,7 @@ public static String clGetKernelArgInfoStringUTF8(long kernel, int arg_indx, int /** * UTF-8 string with explicit length version of: - * {@link CL12#clGetKernelArgInfo GetKernelArgInfo} + * {@link org.lwjgl.opencl.CL12#clGetKernelArgInfo GetKernelArgInfo} */ public static String clGetKernelArgInfoStringUTF8(long kernel, int arg_indx, int param_name, int param_value_size) { return KERNEL_ARG.getStringUTF8(kernel, arg_indx, param_name, param_value_size); @@ -589,14 +576,14 @@ protected int get(long pointer, int param_name, long param_value_size, long para /** * Single boolean value version of: - * {@link CL10#clGetSamplerInfo GetSamplerInfo} + * {@link org.lwjgl.opencl.CL10#clGetSamplerInfo GetSamplerInfo} */ public static boolean clGetSamplerInfoBoolean(long sampler, int param_name) { return SAMPLER.getBoolean(sampler, param_name); } /** - * Single int value version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} + * Single int value version of: {@link org.lwjgl.opencl.CL10#clGetSamplerInfo GetSamplerInfo} */ public static int clGetSamplerInfoInt(long sampler, int param_name) { return SAMPLER.getInt(sampler, param_name); @@ -604,14 +591,14 @@ public static int clGetSamplerInfoInt(long sampler, int param_name) { /** * Single pointer value version of: - * {@link CL10#clGetSamplerInfo GetSamplerInfo} + * {@link org.lwjgl.opencl.CL10#clGetSamplerInfo GetSamplerInfo} */ public static long clGetSamplerInfoPointer(long sampler, int param_name) { return SAMPLER.getPointer(sampler, param_name); } /** - * PointBuffer version of: {@link CL10#clGetSamplerInfo GetSamplerInfo} + * PointBuffer version of: {@link org.lwjgl.opencl.CL10#clGetSamplerInfo GetSamplerInfo} */ public static int clGetSamplerInfoPointers(long sampler, int param_name, PointerBuffer target) { return SAMPLER.getPointers(sampler, param_name, target); @@ -628,21 +615,21 @@ protected int get(long pointer, int param_name, long param_value_size, long para }; /** - * Single int value version of: {@link CL10#clGetEventInfo GetEventInfo} + * Single int value version of: {@link org.lwjgl.opencl.CL10#clGetEventInfo GetEventInfo} */ public static int clGetEventInfoInt(long event, int param_name) { return EVENT.getInt(event, param_name); } /** - * Single pointer value version of: {@link CL10#clGetEventInfo GetEventInfo} + * Single pointer value version of: {@link org.lwjgl.opencl.CL10#clGetEventInfo GetEventInfo} */ public static long clGetEventInfoPointer(long event, int param_name) { return EVENT.getPointer(event, param_name); } /** - * PointBuffer version of: {@link CL10#clGetEventInfo GetEventInfo} + * PointBuffer version of: {@link org.lwjgl.opencl.CL10#clGetEventInfo GetEventInfo} */ public static int clGetEventInfoPointers(long event, int param_name, PointerBuffer target) { return EVENT.getPointers(event, param_name, target); @@ -660,7 +647,7 @@ protected int get(long pointer, int param_name, long param_value_size, long para /** * Single long value version of: - * {@link CL10#clGetEventProfilingInfo GetEventProfilingInfo} + * {@link org.lwjgl.opencl.CL10#clGetEventProfilingInfo GetEventProfilingInfo} */ public static long clGetEventProfilingInfoLong(long event, int param_name) { return EVENT_PROFILING.getLong(event, param_name); @@ -678,7 +665,7 @@ protected int get(long pointer, int param_name, long param_value_size, long para /** * Single int value version of: - * {@link CL10GL#clGetGLTextureInfo GetGLTextureInfo} + * {@link org.lwjgl.opencl.CL10GL#clGetGLTextureInfo GetGLTextureInfo} */ public static int clGetGLTextureInfoInt(long memobj, int param_name) { return GL_TEXTURE.getInt(memobj, param_name); diff --git a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java index 845962cfe8..a34ce795f5 100644 --- a/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java +++ b/jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglContext.java @@ -37,6 +37,7 @@ import static org.lwjgl.opencl.CL10.CL_CONTEXT_PLATFORM; import static org.lwjgl.opengl.GL.createCapabilities; import static org.lwjgl.opengl.GL11.glGetInteger; + import com.jme3.input.lwjgl.GlfwJoystickInput; import com.jme3.input.lwjgl.GlfwKeyInput; import com.jme3.input.lwjgl.GlfwMouseInput; @@ -65,6 +66,7 @@ import org.lwjgl.PointerBuffer; import org.lwjgl.Version; import org.lwjgl.glfw.GLFW; +import org.lwjgl.glfw.GLFWJoystickCallback; import org.lwjgl.opencl.APPLEGLSharing; import org.lwjgl.opencl.CL10; import org.lwjgl.opencl.KHRGLSharing; @@ -233,6 +235,24 @@ protected void initContextFirstTime() { joyInput.initialize(); } + GLFW.glfwSetJoystickCallback(new GLFWJoystickCallback() { + @Override + public void invoke(int jid, int event) { + + // Invoke the disconnected event before we reload the joysticks or we lose the reference to it. + // Invoke the connected event after we reload the joysticks to obtain the reference to it. + + if ( event == GLFW.GLFW_CONNECTED ) { + joyInput.reloadJoysticks(); + joyInput.fireJoystickConnectedEvent(jid); + } + else { + joyInput.fireJoystickDisconnectedEvent(jid); + joyInput.reloadJoysticks(); + } + } + }); + renderable.set(true); } diff --git a/jme3-networking/src/main/java/com/jme3/network/base/KernelAdapter.java b/jme3-networking/src/main/java/com/jme3/network/base/KernelAdapter.java index 0cddbdd244..f3a9965e2a 100644 --- a/jme3-networking/src/main/java/com/jme3/network/base/KernelAdapter.java +++ b/jme3-networking/src/main/java/com/jme3/network/base/KernelAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -180,7 +180,7 @@ protected void dispatch( Endpoint p, Message m ) if( reliable ) { // If it's a reliable connection then it's slightly more // concerning but this can happen all the time for a UDP endpoint. - log.log( Level.WARNING, "Recieved message from unconnected endpoint:" + p + " message:" + m ); + log.log( Level.WARNING, "Received message from unconnected endpoint:" + p + " message:" + m ); } return; } diff --git a/jme3-networking/src/main/java/com/jme3/network/kernel/Envelope.java b/jme3-networking/src/main/java/com/jme3/network/kernel/Envelope.java index 13c6849cda..9b92a1b6d7 100644 --- a/jme3-networking/src/main/java/com/jme3/network/kernel/Envelope.java +++ b/jme3-networking/src/main/java/com/jme3/network/kernel/Envelope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ public class Envelope /** * Creates an incoming envelope holding the data from the specified * source. The 'reliable' flag further indicates on which mode of - * transport the data arrrived. + * transport the data arrived. */ public Envelope( Endpoint source, byte[] data, boolean reliable ) { diff --git a/jme3-networking/src/main/java/com/jme3/network/serializing/Serializer.java b/jme3-networking/src/main/java/com/jme3/network/serializing/Serializer.java index 0e8307eb27..26374762eb 100644 --- a/jme3-networking/src/main/java/com/jme3/network/serializing/Serializer.java +++ b/jme3-networking/src/main/java/com/jme3/network/serializing/Serializer.java @@ -45,7 +45,6 @@ import java.util.*; import java.util.jar.Attributes; import java.util.logging.Level; -import java.util.logging.LogManager; import java.util.logging.Logger; /** diff --git a/jme3-networking/src/main/java/com/jme3/network/service/ServiceManager.java b/jme3-networking/src/main/java/com/jme3/network/service/ServiceManager.java index afcfd73c28..b337ce6b73 100644 --- a/jme3-networking/src/main/java/com/jme3/network/service/ServiceManager.java +++ b/jme3-networking/src/main/java/com/jme3/network/service/ServiceManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 jMonkeyEngine + * Copyright (c) 2015-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,9 +55,9 @@ protected ServiceManager() { } /** - * Retreives the 'parent' of this service manager, usually + * Retrieves the 'parent' of this service manager, usually * a more specifically typed version of 'this' but it can be - * anything the seervices are expecting. + * anything the services are expecting. */ protected abstract T getParent(); diff --git a/jme3-networking/src/main/java/com/jme3/network/service/rmi/MethodInfo.java b/jme3-networking/src/main/java/com/jme3/network/service/rmi/MethodInfo.java index 9b324a6c3d..fa898e5e58 100644 --- a/jme3-networking/src/main/java/com/jme3/network/service/rmi/MethodInfo.java +++ b/jme3-networking/src/main/java/com/jme3/network/service/rmi/MethodInfo.java @@ -33,9 +33,9 @@ package com.jme3.network.service.rmi; import com.jme3.network.serializing.Serializable; +import java.lang.annotation.Annotation; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import javax.jws.Oneway; /** @@ -102,12 +102,18 @@ public static String methodToString( Method m ) { } public static CallType getCallType( Method m ) { - if( m.getReturnType() != Void.TYPE ) + if( m.getReturnType() != Void.TYPE ) { return CallType.Synchronous; - if( m.getAnnotation(Oneway.class) != null ) - return CallType.Asynchronous; - if( m.getAnnotation(Asynchronous.class) == null ) + } + if( m.getAnnotation(Asynchronous.class) == null ) { return CallType.Synchronous; + } + for (Annotation annotation : m.getAnnotations()) { + Class type = annotation.annotationType(); + if (type.getName().equals("javax.jws.Oneway")) { + return CallType.Asynchronous; + } + } Asynchronous async = m.getAnnotation(Asynchronous.class); return async.reliable() ? CallType.Asynchronous : CallType.Unreliable; diff --git a/jme3-networking/src/main/java/com/jme3/network/util/AbstractMessageDelegator.java b/jme3-networking/src/main/java/com/jme3/network/util/AbstractMessageDelegator.java index f8b1be2f53..b5d7a9efea 100644 --- a/jme3-networking/src/main/java/com/jme3/network/util/AbstractMessageDelegator.java +++ b/jme3-networking/src/main/java/com/jme3/network/util/AbstractMessageDelegator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018 jMonkeyEngine + * Copyright (c) 2015-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -111,17 +111,17 @@ protected boolean isValidMethod( Method m, Class messageType ) { if( MessageConnection.class.isAssignableFrom(parms[0]) ) { messageIndex++; } else { - log.finest("First paramter is not a MessageConnection or subclass."); + log.finest("First parameter is not a MessageConnection or subclass."); return false; } } if( messageType == null && !Message.class.isAssignableFrom(parms[messageIndex]) ) { - log.finest("Second paramter is not a Message or subclass."); + log.finest("Second parameter is not a Message or subclass."); return false; } if( messageType != null && !parms[messageIndex].isAssignableFrom(messageType) ) { - log.log(Level.FINEST, "Second paramter is not a {0}", messageType); + log.log(Level.FINEST, "Second parameter is not a {0}", messageType); return false; } return true; diff --git a/jme3-niftygui/build.gradle b/jme3-niftygui/build.gradle index 7db2877116..d0e126207d 100644 --- a/jme3-niftygui/build.gradle +++ b/jme3-niftygui/build.gradle @@ -2,40 +2,11 @@ if (!hasProperty('mainClass')) { ext.mainClass = '' } +def niftyVersion = '1.4.3' + dependencies { compile project(':jme3-core') - compile 'com.github.nifty-gui:nifty:1.4.2' - compile 'com.github.nifty-gui:nifty-default-controls:1.4.2' - compile 'com.github.nifty-gui:nifty-style-black:1.4.2' -} - -ext.pomConfig = { - name POM_NAME - description POM_DESCRIPTION - url POM_URL - inceptionYear POM_INCEPTION_YEAR - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEVELOPER_CONNECTION - } - licenses { - license { - name POM_LICENSE_NAME - url POM_LICENSE_URL - distribution POM_LICENSE_DISTRIBUTION - } - } - developers { - developer { - name 'jMonkeyEngine Team' - id 'jMonkeyEngine' - } - } - repositories { - repository { - id "nifty-maven-repo.sourceforge.net" - url "http://nifty-gui.sourceforge.net/nifty-maven-repo" - } - } + compile "com.github.nifty-gui:nifty:${niftyVersion}" + compile "com.github.nifty-gui:nifty-default-controls:${niftyVersion}" + compile "com.github.nifty-gui:nifty-style-black:${niftyVersion}" } diff --git a/jme3-niftygui/src/main/java/com/jme3/cinematic/events/GuiEvent.java b/jme3-niftygui/src/main/java/com/jme3/cinematic/events/GuiEvent.java index f832b4266b..5671432b62 100644 --- a/jme3-niftygui/src/main/java/com/jme3/cinematic/events/GuiEvent.java +++ b/jme3-niftygui/src/main/java/com/jme3/cinematic/events/GuiEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,48 +42,97 @@ import java.util.logging.Logger; /** + * A CinematicEvent associated with a Nifty screen. * * @author Nehon */ public class GuiEvent extends AbstractCinematicEvent { + /** + * message logger for this class + */ static final Logger log = Logger.getLogger(GuiEvent.class.getName()); + /** + * name of the associated Nifty screen(not null) + */ protected String screen; + /** + * associated Nifty instance (not null) + */ protected Nifty nifty; + /** + * No-argument constructor needed by SavableClassUtil. Do not invoke + * directly! + */ public GuiEvent() { } + /** + * Instantiate an event with the default initial duration (10) and mode + * (DontLoop). + * + * @param nifty the Nifty instance (not null, alias created) + * @param screen the name of the Nifty screen (not null) + */ public GuiEvent(Nifty nifty, String screen) { this.screen = screen; this.nifty = nifty; } + /** + * Instantiate an event the default mode (DontLoop). + * + * @param nifty the Nifty instance (not null, alias created) + * @param screen the name of the Nifty screen (not null) + * @param initialDuration the initial duration (in seconds, ≥0) + */ public GuiEvent(Nifty nifty, String screen, float initialDuration) { super(initialDuration); this.screen = screen; this.nifty = nifty; } + /** + * Instantiate an event with the default initial duration (10). + * + * @param nifty the Nifty instance (not null, alias created) + * @param screen the name of the Nifty screen (not null) + * @param loopMode the loop mode (not null) + */ public GuiEvent(Nifty nifty, String screen, LoopMode loopMode) { super(loopMode); this.screen = screen; this.nifty = nifty; } + /** + * Instantiate an event with the specified initial duration and loop mode. + * + * @param nifty the Nifty instance (not null, alias created) + * @param screen the name of the Nifty screen (not null) + * @param initialDuration the initial duration (in seconds, ≥0) + * @param loopMode the loop mode (not null) + */ public GuiEvent(Nifty nifty, String screen, float initialDuration, LoopMode loopMode) { super(initialDuration, loopMode); this.screen = screen; this.nifty = nifty; } + /** + * Invoked when the event is started. + */ @Override public void onPlay() { log.log(Level.FINEST, "screen should be {0}", screen); nifty.gotoScreen(screen); } + /** + * Invoked when the event is stopped. + */ @Override public void onStop() { if (nifty.getCurrentScreen() != null) { @@ -91,22 +140,46 @@ public void onStop() { } } + /** + * Invoked when the event is paused. + */ @Override public void onPause() { } + /** + * Alter the Nifty instance for this event. + * + * @param nifty the new instance (not null) + */ public void setNifty(Nifty nifty) { this.nifty = nifty; } + /** + * Alter the screen for this event. + * + * @param screen the name of the new screen (not null) + */ public void setScreen(String screen) { this.screen = screen; } + /** + * Invoked once per frame, provided the event is playing. + * + * @param tpf the time interval between frames (in seconds, ≥0) + */ @Override public void onUpdate(float tpf) { } + /** + * Serialize this event, for example when saving to a J3O file. + * + * @param ex exporter (not null) + * @throws IOException from exporter + */ @Override public void write(JmeExporter ex) throws IOException { super.write(ex); @@ -114,6 +187,12 @@ public void write(JmeExporter ex) throws IOException { oc.write(screen, "screen", ""); } + /** + * De-serialize this event, for example when loading from a J3O file. + * + * @param im importer (not null) + * @throws IOException from importer + */ @Override public void read(JmeImporter im) throws IOException { super.read(im); diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/AnimationList.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/AnimationList.java index 6ca884b8c8..20f5c0fe87 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/AnimationList.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/AnimationList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,7 +36,7 @@ /** * Defines animations set that will be created while loading FBX scene - *

        Animation name is using to access animation via {@link AnimControl}.
        + *

        Animation name is using to access animation via {@link com.jme3.animation.AnimControl}.
        * firstFrame and lastFrame defines animation time interval.
        * Use layerName also to define source animation layer in the case of multiple layers in the scene.
        * Skeletal animations will be created if only scene contain skeletal bones

        @@ -47,8 +47,7 @@ public class AnimationList { /** * Use in the case of multiple animation layers in FBX asset - * @param name - animation name to assess via {@link AnimControl} - * @param layerName - source layer + * @param name - animation name to access via {@link com.jme3.animation.AnimControl} */ public void add(String name, int firstFrame, int lastFrame) { add(name, null, firstFrame, lastFrame); @@ -56,7 +55,7 @@ public void add(String name, int firstFrame, int lastFrame) { /** * Use in the case of multiple animation layers in FBX asset - * @param name - animation name to assess via {@link AnimControl} + * @param name - animation name to access via {@link com.jme3.animation.AnimControl} * @param layerName - source layer */ public void add(String name, String layerName, int firstFrame, int lastFrame) { diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/ContentTextureKey.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/ContentTextureKey.java index 35375f9c59..2db439e401 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/ContentTextureKey.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/ContentTextureKey.java @@ -33,7 +33,6 @@ import com.jme3.asset.TextureKey; import com.jme3.asset.cache.AssetCache; -import com.jme3.asset.cache.WeakRefCloneAssetCache; import com.jme3.export.InputCapsule; import com.jme3.export.JmeExporter; import com.jme3.export.JmeImporter; diff --git a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java index fd157cb487..da25bd93e8 100644 --- a/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java +++ b/jme3-plugins/src/fbx/java/com/jme3/scene/plugins/fbx/FbxLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -44,7 +44,6 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.ModelKey; import com.jme3.math.Matrix4f; -import com.jme3.math.Transform; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.plugins.fbx.anim.FbxToJmeTrack; @@ -150,7 +149,7 @@ private void releaseObjects() { private void loadData(InputStream stream) throws IOException { FbxFile scene = FbxReader.readFBX(stream); - FbxDump.dumpFile(scene); + //FbxDump.dumpFile(scene); // TODO: Load FBX object templates @@ -307,7 +306,7 @@ private void updateWorldTransforms() { private void constructAnimations() { // In FBX, animation are not attached to any root. // They are implicitly global. - // So, we need to use hueristics to find which node(s) + // So, we need to use heuristics to find which node(s) // an animation is associated with, so we can create the AnimControl // in the appropriate location in the scene. Map pairs = new HashMap(); @@ -340,8 +339,8 @@ private void constructAnimations() { String animName = pair.animStack.getName(); float duration = pair.animStack.getDuration(); - System.out.println("ANIMATION: " + animName + ", duration = " + duration); - System.out.println("NODE: " + pair.node.getName()); + //System.out.println("ANIMATION: " + animName + ", duration = " + duration); + //System.out.println("NODE: " + pair.node.getName()); duration = pair.getDuration(); diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GlbLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GlbLoader.java index c3fe311039..662e992cac 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GlbLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GlbLoader.java @@ -18,6 +18,7 @@ public class GlbLoader extends GltfLoader { @Override public Object load(AssetInfo assetInfo) throws IOException { + data.clear(); LittleEndien stream = new LittleEndien(new DataInputStream(assetInfo.openStream())); int magic = stream.readInt(); int version = stream.readInt(); diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java index 260e018e6c..7b9c8d93d1 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java @@ -16,12 +16,9 @@ import com.jme3.texture.Texture2D; import com.jme3.util.IntMap; import com.jme3.util.mikktspace.MikktspaceTangentGenerator; - -import javax.xml.bind.DatatypeConverter; import java.io.*; import java.nio.Buffer; import java.nio.FloatBuffer; -import java.rmi.ServerError; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -544,7 +541,7 @@ protected byte[] getBytes(int bufferIndex, String uri, Integer bufferLength) thr if (uri != null) { if (uri.startsWith("data:")) { //base 64 embed data - data = DatatypeConverter.parseBase64Binary(uri.substring(uri.indexOf(",") + 1)); + data = Base64.getDecoder().decode(uri.substring(uri.indexOf(",") + 1)); } else { //external file let's load it if (!uri.endsWith(".bin")) { @@ -626,12 +623,12 @@ public void readCameras() throws IOException { for (int i = 0; i < cameras.size(); i++) { //Can't access resolution here... actually it's a shame we can't access settings from anywhere. - //users will have to call resize ont he camera. + //users will have to call resize on the camera. Camera cam = new Camera(1, 1); JsonObject camObj = cameras.get(i).getAsJsonObject(); String type = getAsString(camObj, "type"); - assertNotNull(type, "No type defined ofr camera"); + assertNotNull(type, "No type defined for camera"); JsonObject camData = camObj.getAsJsonObject(type); if (type.equals("perspective")) { float aspectRatio = getAsFloat(camData, "aspectRation", 1f); @@ -674,7 +671,7 @@ public Texture2D readTexture(JsonObject texture, boolean flip) throws IOExceptio return null; } Integer textureIndex = getAsInteger(texture, "index"); - assertNotNull(textureIndex, "Texture as no index"); + assertNotNull(textureIndex, "Texture has no index"); assertNotNull(textures, "There are no textures, yet one is referenced by a material"); JsonObject textureData = textures.get(textureIndex).getAsJsonObject(); @@ -715,7 +712,7 @@ public Texture2D readImage(int sourceIndex, boolean flip) throws IOException { } else if (uri.startsWith("data:")) { //base64 encoded image String[] uriInfo = uri.split(","); - byte[] data = DatatypeConverter.parseBase64Binary(uriInfo[1]); + byte[] data = Base64.getDecoder().decode(uriInfo[1]); String headerInfo = uriInfo[0].split(";")[0]; String extension = headerInfo.split("/")[1]; TextureKey key = new TextureKey("image" + sourceIndex + "." + extension, flip); diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfModelKey.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfModelKey.java index c2f13e9c08..c8128c44f1 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfModelKey.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfModelKey.java @@ -44,7 +44,7 @@ public void registerMaterialAdapter(String gltfMaterialName, MaterialAdapter ada } /** - * Registers and extension loader for th given extension name. + * Registers an extension loader for the given extension name. * For more information on extension please see glTF 2.0 extensions registry * https://github.com/KhronosGroup/glTF/blob/master/extensions/README.md * diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java index 1e6ebfcd64..f6200f533b 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java @@ -299,7 +299,6 @@ private static void populateShortBuffer(ShortBuffer buffer, LittleEndien stream, } index += stride; } - System.err.println(""); } diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/MaterialAdapter.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/MaterialAdapter.java index 602ad961f5..759360e6af 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/MaterialAdapter.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/MaterialAdapter.java @@ -26,7 +26,7 @@ public abstract class MaterialAdapter { /** * Should return the material definition used by this material adapter * - * @return + * @return path to the material definition */ protected abstract String getMaterialDefPath(); diff --git a/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdExporter.java b/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdExporter.java index 108040e137..affb1215c9 100644 --- a/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdExporter.java +++ b/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdExporter.java @@ -5,9 +5,6 @@ */ package com.jme3.material.plugin.export.materialdef; -import com.jme3.export.JmeExporter; -import com.jme3.export.OutputCapsule; -import com.jme3.export.Savable; import com.jme3.material.*; import java.io.*; diff --git a/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdMatParamWriter.java b/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdMatParamWriter.java index 0bce677826..9d9cc3ef5d 100644 --- a/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdMatParamWriter.java +++ b/jme3-plugins/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdMatParamWriter.java @@ -5,13 +5,11 @@ */ package com.jme3.material.plugin.export.materialdef; -import com.jme3.export.*; import com.jme3.material.*; import com.jme3.math.*; import com.jme3.texture.image.ColorSpace; import java.io.*; -import java.util.*; import static com.jme3.shader.VarType.Vector2; import static com.jme3.shader.VarType.Vector3; diff --git a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneLoader.java b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneLoader.java index bb63f3b932..4c26eb5f4b 100644 --- a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneLoader.java +++ b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SceneLoader.java @@ -44,7 +44,6 @@ import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.scene.CameraNode; -import com.jme3.scene.LightNode; import com.jme3.scene.Spatial; import com.jme3.scene.control.CameraControl.ControlDirection; import com.jme3.scene.plugins.ogre.matext.OgreMaterialKey; diff --git a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SkeletonLoader.java b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SkeletonLoader.java index d9977d3a99..59be5cf7d5 100644 --- a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SkeletonLoader.java +++ b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/SkeletonLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -224,7 +224,7 @@ public void endElement(String uri, String name, String qName) { } /** - * Reset the SkeletonLoader in case an error occured while parsing XML. + * Reset the SkeletonLoader in case an error occurred while parsing XML. * This allows future use of the loader even after an error. */ private void fullReset() { diff --git a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/matext/MaterialExtension.java b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/matext/MaterialExtension.java index 192cbd9091..5c68f5a789 100644 --- a/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/matext/MaterialExtension.java +++ b/jme3-plugins/src/ogre/java/com/jme3/scene/plugins/ogre/matext/MaterialExtension.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,7 +74,7 @@ public void setTextureMapping(String ogreTexAlias, String jmeTexParam){ } /** - * Retreives a mapping from an Ogre3D base material texture alias + * Retrieves a mapping from an Ogre3D base material texture alias * to a jME3 texture param * @param ogreTexAlias The texture alias in the Ogre3D base material * @return The texture alias in the Ogre3D base material diff --git a/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java b/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java index 8dce19e13c..06fda2718b 100644 --- a/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java +++ b/jme3-plugins/src/test/java/com/jme3/scene/plugins/gltf/GltfLoaderTest.java @@ -8,7 +8,6 @@ import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; /** * Created by Nehon on 07/08/2017. diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/LODGeomap.java b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/LODGeomap.java index 286c570d95..4b10e5c59b 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/LODGeomap.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/LODGeomap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,6 @@ import com.jme3.util.TempVars; import java.io.IOException; import java.nio.Buffer; -import java.nio.BufferOverflowException; import java.nio.BufferUnderflowException; import java.nio.FloatBuffer; import java.nio.IntBuffer; @@ -149,7 +148,6 @@ public Vector2f getUV(int x, int y, Vector2f store, Vector2f offset, float offse * Create the LOD index array that will seam its edges with its neighbour's LOD. * This is a scary method!!! It will break your mind. * - * @param store to store the index buffer * @param lod level of detail of the mesh * @param rightLod LOD of the right neighbour * @param topLod LOD of the top neighbour @@ -1069,7 +1067,7 @@ protected Triangle[] getGridTrianglesAtPoint(float x, float z, Vector3f scale, V * * @param x local x coordinate * @param z local z coordinate - * @return + * @return a new array or null */ protected Triangle[] getGridTrianglesAtPoint(float x, float z) { int gridX = (int) x; diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainGrid.java b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainGrid.java index d232be9241..fe754242ef 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainGrid.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainGrid.java @@ -43,7 +43,6 @@ import com.jme3.scene.Spatial; import com.jme3.scene.control.UpdateControl; import com.jme3.terrain.Terrain; -import com.jme3.terrain.heightmap.HeightMapGrid; import java.io.IOException; import java.util.HashSet; import java.util.List; diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainPatch.java b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainPatch.java index eb32639606..36c44ea462 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainPatch.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainPatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -821,7 +821,7 @@ public int collideWith(Collidable other, CollisionResults results) throws Unsupp else if (other instanceof BoundingVolume) return collideWithBoundingVolume((BoundingVolume)other, results); else { - throw new UnsupportedCollisionException("TerrainPatch cannnot collide with "+other.getClass().getName()); + throw new UnsupportedCollisionException("TerrainPatch cannot collide with "+other.getClass().getName()); } } diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainQuad.java b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainQuad.java index 679afcb707..7f41bd3727 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainQuad.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/geomipmap/TerrainQuad.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -852,7 +852,7 @@ private void attachBoundingBox(BoundingBox bb, Node parent) { * exists already, then it will grow the box to fit the new changedPoint. * If the affectedAreaBBox is null, then it will create one of unit size. * - * @param needToRecalculateNormals if null, will cause needToRecalculateNormals() to return false + * @param changedPoint a location to include */ protected void setNormalRecalcNeeded(Vector2f changedPoint) { if (changedPoint == null) { // set needToRecalculateNormals() to false diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/AbstractHeightMap.java b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/AbstractHeightMap.java index 21c504528a..c6466c17b8 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/AbstractHeightMap.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/AbstractHeightMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -216,7 +216,7 @@ public float[] getHeightMap() { /** * Build a new array of height data with the scaled values. - * @return + * @return a new array */ public float[] getScaledHeightMap() { float[] hm = new float[heightData.length]; @@ -351,9 +351,8 @@ public float[] findMinMaxHeights() { /** * erodeTerrain is a convenience method that applies the FIR - * filter to a given height map. This simulates water errosion. + * filter to a given height map. This simulates water erosion. * - * @see setFilter */ public void erodeTerrain() { //erode left to right diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FaultHeightMap.java b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FaultHeightMap.java index d5594b19a7..ea64c570c3 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FaultHeightMap.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FaultHeightMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,7 +97,8 @@ public class FaultHeightMap extends AbstractHeightMap { * @param minFaultHeight Height modified on each side * @param maxFaultHeight Height modified on each side * @param seed A seed to feed the Random generator - * @see setFaultRange, setMinRadius, setMaxRadius + * @see #setMinRadius(float) + * @see #setMaxRadius(float) */ public FaultHeightMap(int size, int iterations, int faultType, int faultShape, float minFaultHeight, float maxFaultHeight, long seed) throws Exception { if (size < 0 || iterations < 0) { diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FluidSimHeightMap.java b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FluidSimHeightMap.java index d5aff587df..c532681d6a 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FluidSimHeightMap.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/FluidSimHeightMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -248,7 +248,7 @@ public void setIterations(int iterations) throws Exception { * * @param maxInitialHeight * the maximum initial height - * @see #setMinInitialHeight(int) + * @see #setMinInitialHeight(float) */ public void setMaxInitialHeight(float maxInitialHeight) { this.maxInitialHeight = maxInitialHeight; @@ -259,7 +259,7 @@ public void setMaxInitialHeight(float maxInitialHeight) { * * @param minInitialHeight * the minimum initial height - * @see #setMaxInitialHeight(int) + * @see #setMaxInitialHeight(float) */ public void setMinInitialHeight(float minInitialHeight) { this.minInitialHeight = minInitialHeight; diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/MidpointDisplacementHeightMap.java b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/MidpointDisplacementHeightMap.java index 7a53c97111..acfbc9881d 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/MidpointDisplacementHeightMap.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/MidpointDisplacementHeightMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,7 +71,7 @@ public class MidpointDisplacementHeightMap extends AbstractHeightMap { * typically a good choice * @param seed * A seed to feed the random number generator. - * @throw IllegalArgumentException if size is not a power of two plus one. + * @throws IllegalArgumentException if size is not a power of two plus one. */ public MidpointDisplacementHeightMap(int size, float range, float persistence, long seed) { if (size < 0 || !FastMath.isPowerOfTwo(size - 1)) { @@ -102,7 +102,7 @@ public MidpointDisplacementHeightMap(int size, float range, float persistence, l * The factor by which the range will evolve at each iteration. * A value of 0.5f will halve the range at each iteration and is * typically a good choice - * @throw JMException if size is not a power of two plus one. + * @throws JMException if size is not a power of two plus one. */ public MidpointDisplacementHeightMap(int size, float range, float persistence) throws Exception { this(size, range, persistence, new Random().nextLong()); @@ -110,7 +110,7 @@ public MidpointDisplacementHeightMap(int size, float range, float persistence) t /** * Generate the heightmap. - * @return + * @return true */ @Override public boolean load() { @@ -163,7 +163,7 @@ public boolean load() { * @param stepSize the size of the square * @param offsetRange the offset range within a random value is picked and added to the average * @param random the random generator - * @return + * @return a new array or null */ protected int[] doSquareStep(float[][] tempBuffer, int[] coords, int stepSize, float offsetRange, Random random) { float cornerAverage = 0; @@ -195,7 +195,7 @@ protected int[] doSquareStep(float[][] tempBuffer, int[] coords, int stepSize, f * @param stepSize * @param offsetRange * @param random - * @return + * @return a new array or null */ protected int[] doDiamondStep(float[][] tempBuffer, int[] coords, int stepSize, float offsetRange, Random random) { int cornerNbr = 0; diff --git a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/Namer.java b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/Namer.java index a260d7b65a..fdaffeb4f3 100644 --- a/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/Namer.java +++ b/jme3-terrain/src/main/java/com/jme3/terrain/heightmap/Namer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ public interface Namer { * Gets a name for a heightmap tile given its cell id * @param x * @param y - * @return + * @return a tile name */ public String getName(int x, int y); diff --git a/jme3-testdata/build.gradle b/jme3-testdata/build.gradle index aad9f2ae94..f0f070fbcb 100644 --- a/jme3-testdata/build.gradle +++ b/jme3-testdata/build.gradle @@ -10,4 +10,5 @@ repositories { dependencies { compile 'lessvoid:nifty-examples:1.4.1' + runtime 'com.github.nifty-gui:nifty-style-black:1.4.3' } diff --git a/jme3-vr/src/main/java/com/jme3/app/VRAppState.java b/jme3-vr/src/main/java/com/jme3/app/VRAppState.java index 2ff8c50d5d..e4b3f18253 100644 --- a/jme3-vr/src/main/java/com/jme3/app/VRAppState.java +++ b/jme3-vr/src/main/java/com/jme3/app/VRAppState.java @@ -1,7 +1,7 @@ package com.jme3.app; /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,7 +55,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; -import java.util.Iterator; import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; @@ -292,7 +291,7 @@ public AppStateManager getStateManager(){ } /** - * Get the scene observer. If no observer has been set, this method return the application {@link #getCamera() camera}. + * Get the scene observer. If no observer has been set, this method returns the application camera. * @return the scene observer. * @see #setObserver(Spatial) */ @@ -301,7 +300,7 @@ public Object getObserver() { } /** - * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application {@link #getCamera() camera}. + * Set the scene observer. The VR headset will be linked to it. If no observer is set, the VR headset is linked to the application camera. * @param observer the scene observer. */ public void setObserver(Spatial observer) { diff --git a/jme3-vr/src/main/java/com/jme3/app/VREnvironment.java b/jme3-vr/src/main/java/com/jme3/app/VREnvironment.java index 747d3f4a75..485a563cec 100644 --- a/jme3-vr/src/main/java/com/jme3/app/VREnvironment.java +++ b/jme3-vr/src/main/java/com/jme3/app/VREnvironment.java @@ -100,7 +100,6 @@ public VRAPI getVRHardware() { /** * Set the VR bounds. - * @return the VR bounds. * @see #getVRBounds() */ public void setVRBounds(VRBounds bounds){ diff --git a/jme3-vr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java b/jme3-vr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java index 8d73e7c045..97c0c2a3a0 100644 --- a/jme3-vr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java +++ b/jme3-vr/src/main/java/com/jme3/input/vr/AbstractVRMouseManager.java @@ -9,7 +9,6 @@ import com.jme3.input.lwjgl.GlfwMouseInputVR; import com.jme3.material.RenderState.BlendMode; import com.jme3.math.Vector2f; -import com.jme3.scene.Node; import com.jme3.system.AppSettings; import com.jme3.system.lwjgl.LwjglWindow; import com.jme3.texture.Texture; @@ -27,8 +26,8 @@ public abstract class AbstractVRMouseManager implements VRMouseManager { private VREnvironment environment = null; - - + private boolean vrMouseEnabled = true; + private boolean mouseAttached = false; private Picture mouseImage; private int recentCenterCount = 0; @@ -70,6 +69,11 @@ public void initialize() { public VREnvironment getVREnvironment() { return environment; } + + @Override + public void setVRMouseEnabled(boolean enabled) { + vrMouseEnabled = enabled; + } @Override public void setThumbstickMode(boolean set) { @@ -185,10 +189,9 @@ public void centerMouse() { @Override public void update(float tpf) { // if we are showing the cursor, add our picture as it - - if( environment.getApplication().getInputManager().isCursorVisible() ) { - if( mouseImage.getParent() == null ) { - + if( vrMouseEnabled && environment.getApplication().getInputManager().isCursorVisible() ) { + if(!mouseAttached) { + mouseAttached = true; environment.getApplication().getGuiViewPort().attachScene(mouseImage); centerMouse(); // the "real" mouse pointer should stay hidden @@ -216,13 +219,13 @@ public void update(float tpf) { mouseImage.updateGeometricState(); - } else if( mouseImage.getParent() != null ) { - Node n = mouseImage.getParent(); - mouseImage.removeFromParent(); - - if (n != null){ - n.updateGeometricState(); - } + } else if(mouseAttached) { + mouseAttached = false; + environment.getApplication().getGuiViewPort().detachScene(mouseImage); + + // Use the setCursorVisible implementation to show the cursor again, depending on the state of cursorVisible + boolean cursorVisible = environment.getApplication().getInputManager().isCursorVisible(); + environment.getApplication().getContext().getMouseInput().setCursorVisible(cursorVisible); } } } diff --git a/jme3-vr/src/main/java/com/jme3/input/vr/VRMouseManager.java b/jme3-vr/src/main/java/com/jme3/input/vr/VRMouseManager.java index 5257cd05c9..aa6b100569 100644 --- a/jme3-vr/src/main/java/com/jme3/input/vr/VRMouseManager.java +++ b/jme3-vr/src/main/java/com/jme3/input/vr/VRMouseManager.java @@ -21,6 +21,12 @@ public interface VRMouseManager { * @return the {@link VREnvironment VR Environment} to which this manager is attached. */ public VREnvironment getVREnvironment(); + + /** + * Set if the mouse cursor should be used in the VR view. + * @param enabled true if the mouse cursor should be displayed in VR and false otherwise. + */ + public void setVRMouseEnabled(boolean enabled); /** * Set if the VR device controller is used within thumb stick mode. @@ -29,7 +35,7 @@ public interface VRMouseManager { public void setThumbstickMode(boolean set); /** - * Get if the VR device controller is used within thumb stick mode. + * Get if the VR device controller is used within thumb stick mode. * @return true if the VR device controller is used within thumb stick mode and false otherwise. */ public boolean isThumbstickMode(); diff --git a/jme3-vr/src/main/java/com/jme3/input/vr/VRViewManager.java b/jme3-vr/src/main/java/com/jme3/input/vr/VRViewManager.java index 96b3eda95d..87aaadff90 100644 --- a/jme3-vr/src/main/java/com/jme3/input/vr/VRViewManager.java +++ b/jme3-vr/src/main/java/com/jme3/input/vr/VRViewManager.java @@ -161,7 +161,7 @@ public interface VRViewManager { * Send the rendering result as textures to the two eyes. * This method should be called after all the rendering operations * (for example at the end of the {@link AppState#postRender() postRender()} method of the attached app state.) - * @see #preRender() + * @see #render() */ public void postRender(); diff --git a/jme3-vr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java b/jme3-vr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java index e3f1df53a6..12eef2ca91 100644 --- a/jme3-vr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java +++ b/jme3-vr/src/main/java/com/jme3/input/vr/osvr/OSVRViewManager.java @@ -441,7 +441,7 @@ private void setupVRScene(){ /** * Update the VR view manager. - * This method is called by the attached {@link VRApplication VR application} and should not be called manually. + * This method is called by the attached VR application and should not be called manually. * @param tpf the time per frame. */ public void update(float tpf) { diff --git a/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java b/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java index 9c6d355c9b..aa9401f3ea 100644 --- a/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java +++ b/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowFilterVR.java @@ -1,7 +1,7 @@ package com.jme3.shadow; /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,8 +69,6 @@ public abstract class AbstractShadowFilterVR * @param manager the application asset manager * @param shadowMapSize the size of the rendered shadowmaps (512,1024,2048, * etc...) - * @param nbShadowMaps the number of shadow maps rendered (the more shadow - * maps the more quality, the less fps). * @param shadowRenderer the shadowRenderer to use for this Filter */ @SuppressWarnings("all") diff --git a/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java b/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java index 296855e5aa..6b30a2812a 100644 --- a/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java +++ b/jme3-vr/src/main/java/com/jme3/shadow/AbstractShadowRendererVR.java @@ -1,7 +1,7 @@ package com.jme3.shadow; /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -364,7 +364,7 @@ public boolean isInitialized() { * * @param shadowMapIndex the index of the shadow map being rendered * @param shadowMapOccluders the list of occluders - * @return + * @return a list of occluders */ protected abstract GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders); @@ -684,7 +684,7 @@ public float getShadowZFadeLength() { /** * returns true if the light source bounding box is in the view frustum - * @return + * @return true if box in frustum */ protected abstract boolean checkCulling(Camera viewCam); diff --git a/jme3-vr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java b/jme3-vr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java index 6002b2e3a2..c4a1336d35 100644 --- a/jme3-vr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java +++ b/jme3-vr/src/main/java/com/jme3/shadow/DirectionalLightShadowRendererVR.java @@ -1,7 +1,7 @@ package com.jme3.shadow; /* - * Copyright (c) 2009-2018 jMonkeyEngine + * Copyright (c) 2009-2019 jMonkeyEngine * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -291,9 +291,9 @@ public void write(JmeExporter ex) throws IOException { } /** - * Directional light are always in the view frustum + * Directional light is always in the view frustum * @param viewCam - * @return + * @return true */ @Override protected boolean checkCulling(Camera viewCam) { diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java index dd7f346f78..b24ad98e6a 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/CameraVideoStreamFrameHeader_t.java @@ -4,50 +4,49 @@ import java.util.Arrays; import java.util.List; /** - * native declaration : headers\openvr_capi.h:1466
        - * This file was autogenerated by JNAerator,
        - * a tool written by Olivier Chafik that uses a few opensource projects..
        - * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class CameraVideoStreamFrameHeader_t extends Structure { + * native declaration : headers\openvr_capi.h:1466
        + * This file was autogenerated by JNAerator,
        + * a tool written by Olivier Chafik that uses a few opensource projects..
        + * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class CameraVideoStreamFrameHeader_t extends Structure { /** - * @see EVRTrackedCameraFrameType
        - * C type : EVRTrackedCameraFrameType - */ - public int eFrameType; - public int nWidth; - public int nHeight; - public int nBytesPerPixel; - public int nFrameSequence; - /** C type : TrackedDevicePose_t */ - public TrackedDevicePose_t standingTrackedDevicePose; - public CameraVideoStreamFrameHeader_t() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("eFrameType", "nWidth", "nHeight", "nBytesPerPixel", "nFrameSequence", "standingTrackedDevicePose"); - } + * C type : EVRTrackedCameraFrameType + */ + public int eFrameType; + public int nWidth; + public int nHeight; + public int nBytesPerPixel; + public int nFrameSequence; + /** C type : TrackedDevicePose_t */ + public TrackedDevicePose_t standingTrackedDevicePose; + public CameraVideoStreamFrameHeader_t() { + super(); + } + protected List getFieldOrder() { + return Arrays.asList("eFrameType", "nWidth", "nHeight", "nBytesPerPixel", "nFrameSequence", "standingTrackedDevicePose"); + } /** - * @param eFrameType @see EVRTrackedCameraFrameType
        - * C type : EVRTrackedCameraFrameType
        - * @param standingTrackedDevicePose C type : TrackedDevicePose_t - */ - public CameraVideoStreamFrameHeader_t(int eFrameType, int nWidth, int nHeight, int nBytesPerPixel, int nFrameSequence, TrackedDevicePose_t standingTrackedDevicePose) { - super(); - this.eFrameType = eFrameType; - this.nWidth = nWidth; - this.nHeight = nHeight; - this.nBytesPerPixel = nBytesPerPixel; - this.nFrameSequence = nFrameSequence; - this.standingTrackedDevicePose = standingTrackedDevicePose; - } - public CameraVideoStreamFrameHeader_t(Pointer peer) { - super(peer); - } - public static class ByReference extends CameraVideoStreamFrameHeader_t implements Structure.ByReference { - - }; - public static class ByValue extends CameraVideoStreamFrameHeader_t implements Structure.ByValue { - - }; + * @param eFrameType @see EVRTrackedCameraFrameType
        + * C type : EVRTrackedCameraFrameType
        + * @param standingTrackedDevicePose C type : TrackedDevicePose_t + */ + public CameraVideoStreamFrameHeader_t(int eFrameType, int nWidth, int nHeight, int nBytesPerPixel, int nFrameSequence, TrackedDevicePose_t standingTrackedDevicePose) { + super(); + this.eFrameType = eFrameType; + this.nWidth = nWidth; + this.nHeight = nHeight; + this.nBytesPerPixel = nBytesPerPixel; + this.nFrameSequence = nFrameSequence; + this.standingTrackedDevicePose = standingTrackedDevicePose; + } + public CameraVideoStreamFrameHeader_t(Pointer peer) { + super(peer); + } + public static class ByReference extends CameraVideoStreamFrameHeader_t implements Structure.ByReference { + + }; + public static class ByValue extends CameraVideoStreamFrameHeader_t implements Structure.ByValue { + + }; } diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java index 1cf9c869c7..4a00707fed 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/JOpenVRLibrary.java @@ -9,12 +9,12 @@ import java.nio.IntBuffer; import java.util.logging.Logger; /** - * JNA Wrapper for library JOpenVR
        - * This file was autogenerated by JNAerator,
        - * a tool written by Olivier Chafik that uses a few opensource projects..
        - * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class JOpenVRLibrary implements Library { + * JNA Wrapper for library JOpenVR
        + * This file was autogenerated by JNAerator,
        + * a tool written by Olivier Chafik that uses a few opensource projects..
        + * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class JOpenVRLibrary implements Library { private static final Logger logger = Logger.getLogger(JOpenVRLibrary.class.getName()); private static String JNA_LIBRARY_NAME; @@ -29,7 +29,6 @@ public class JOpenVRLibrary implements Library { /** * Init the native binding to the underlying system library. - * @return true if the link is effective and false otherwise. */ public static void init() throws UnsatisfiedLinkError { Native.unregister(JOpenVRLibrary.class); @@ -62,1996 +61,1996 @@ public static String getSystemLibraryName(){ return ""+JNA_LIBRARY_NAME; } - - /** - * native declaration : headers\openvr_capi.h:229
        - * enum values - */ - public static interface EVREye { - /** native declaration : headers\openvr_capi.h:227 */ - public static final int EVREye_Eye_Left = 0; - /** native declaration : headers\openvr_capi.h:228 */ - public static final int EVREye_Eye_Right = 1; - }; - /** - * native declaration : headers\openvr_capi.h:239
        - * enum values - */ - public static interface ETextureType { - /** native declaration : headers\openvr_capi.h:231 */ - public static final int ETextureType_TextureType_Invalid = -1; - /** native declaration : headers\openvr_capi.h:232 */ - public static final int ETextureType_TextureType_DirectX = 0; - /** native declaration : headers\openvr_capi.h:233 */ - public static final int ETextureType_TextureType_OpenGL = 1; - /** native declaration : headers\openvr_capi.h:234 */ - public static final int ETextureType_TextureType_Vulkan = 2; - /** native declaration : headers\openvr_capi.h:235 */ - public static final int ETextureType_TextureType_IOSurface = 3; - /** native declaration : headers\openvr_capi.h:236 */ - public static final int ETextureType_TextureType_DirectX12 = 4; - /** native declaration : headers\openvr_capi.h:237 */ - public static final int ETextureType_TextureType_DXGISharedHandle = 5; - /** native declaration : headers\openvr_capi.h:238 */ - public static final int ETextureType_TextureType_Metal = 6; - }; - /** - * native declaration : headers\openvr_capi.h:244
        - * enum values - */ - public static interface EColorSpace { - /** native declaration : headers\openvr_capi.h:241 */ - public static final int EColorSpace_ColorSpace_Auto = 0; - /** native declaration : headers\openvr_capi.h:242 */ - public static final int EColorSpace_ColorSpace_Gamma = 1; - /** native declaration : headers\openvr_capi.h:243 */ - public static final int EColorSpace_ColorSpace_Linear = 2; - }; - /** - * native declaration : headers\openvr_capi.h:251
        - * enum values - */ - public static interface ETrackingResult { - /** native declaration : headers\openvr_capi.h:246 */ - public static final int ETrackingResult_TrackingResult_Uninitialized = 1; - /** native declaration : headers\openvr_capi.h:247 */ - public static final int ETrackingResult_TrackingResult_Calibrating_InProgress = 100; - /** native declaration : headers\openvr_capi.h:248 */ - public static final int ETrackingResult_TrackingResult_Calibrating_OutOfRange = 101; - /** native declaration : headers\openvr_capi.h:249 */ - public static final int ETrackingResult_TrackingResult_Running_OK = 200; - /** native declaration : headers\openvr_capi.h:250 */ - public static final int ETrackingResult_TrackingResult_Running_OutOfRange = 201; - }; - /** - * native declaration : headers\openvr_capi.h:260
        - * enum values - */ - public static interface ETrackedDeviceClass { - /** native declaration : headers\openvr_capi.h:253 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_Invalid = 0; - /** native declaration : headers\openvr_capi.h:254 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_HMD = 1; - /** native declaration : headers\openvr_capi.h:255 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_Controller = 2; - /** native declaration : headers\openvr_capi.h:256 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_GenericTracker = 3; - /** native declaration : headers\openvr_capi.h:257 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_TrackingReference = 4; - /** native declaration : headers\openvr_capi.h:258 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_DisplayRedirect = 5; - /** native declaration : headers\openvr_capi.h:259 */ - public static final int ETrackedDeviceClass_TrackedDeviceClass_Max = 6; - }; - /** - * native declaration : headers\openvr_capi.h:267
        - * enum values - */ - public static interface ETrackedControllerRole { - /** native declaration : headers\openvr_capi.h:262 */ - public static final int ETrackedControllerRole_TrackedControllerRole_Invalid = 0; - /** native declaration : headers\openvr_capi.h:263 */ - public static final int ETrackedControllerRole_TrackedControllerRole_LeftHand = 1; - /** native declaration : headers\openvr_capi.h:264 */ - public static final int ETrackedControllerRole_TrackedControllerRole_RightHand = 2; - /** native declaration : headers\openvr_capi.h:265 */ - public static final int ETrackedControllerRole_TrackedControllerRole_OptOut = 3; - /** native declaration : headers\openvr_capi.h:266 */ - public static final int ETrackedControllerRole_TrackedControllerRole_Max = 4; - }; - /** - * native declaration : headers\openvr_capi.h:272
        - * enum values - */ - public static interface ETrackingUniverseOrigin { - /** native declaration : headers\openvr_capi.h:269 */ - public static final int ETrackingUniverseOrigin_TrackingUniverseSeated = 0; - /** native declaration : headers\openvr_capi.h:270 */ - public static final int ETrackingUniverseOrigin_TrackingUniverseStanding = 1; - /** native declaration : headers\openvr_capi.h:271 */ - public static final int ETrackingUniverseOrigin_TrackingUniverseRawAndUncalibrated = 2; - }; - /** - * native declaration : headers\openvr_capi.h:432
        - * enum values - */ - public static interface ETrackedDeviceProperty { - /** native declaration : headers\openvr_capi.h:274 */ - public static final int ETrackedDeviceProperty_Prop_Invalid = 0; - /** native declaration : headers\openvr_capi.h:275 */ - public static final int ETrackedDeviceProperty_Prop_TrackingSystemName_String = 1000; - /** native declaration : headers\openvr_capi.h:276 */ - public static final int ETrackedDeviceProperty_Prop_ModelNumber_String = 1001; - /** native declaration : headers\openvr_capi.h:277 */ - public static final int ETrackedDeviceProperty_Prop_SerialNumber_String = 1002; - /** native declaration : headers\openvr_capi.h:278 */ - public static final int ETrackedDeviceProperty_Prop_RenderModelName_String = 1003; - /** native declaration : headers\openvr_capi.h:279 */ - public static final int ETrackedDeviceProperty_Prop_WillDriftInYaw_Bool = 1004; - /** native declaration : headers\openvr_capi.h:280 */ - public static final int ETrackedDeviceProperty_Prop_ManufacturerName_String = 1005; - /** native declaration : headers\openvr_capi.h:281 */ - public static final int ETrackedDeviceProperty_Prop_TrackingFirmwareVersion_String = 1006; - /** native declaration : headers\openvr_capi.h:282 */ - public static final int ETrackedDeviceProperty_Prop_HardwareRevision_String = 1007; - /** native declaration : headers\openvr_capi.h:283 */ - public static final int ETrackedDeviceProperty_Prop_AllWirelessDongleDescriptions_String = 1008; - /** native declaration : headers\openvr_capi.h:284 */ - public static final int ETrackedDeviceProperty_Prop_ConnectedWirelessDongle_String = 1009; - /** native declaration : headers\openvr_capi.h:285 */ - public static final int ETrackedDeviceProperty_Prop_DeviceIsWireless_Bool = 1010; - /** native declaration : headers\openvr_capi.h:286 */ - public static final int ETrackedDeviceProperty_Prop_DeviceIsCharging_Bool = 1011; - /** native declaration : headers\openvr_capi.h:287 */ - public static final int ETrackedDeviceProperty_Prop_DeviceBatteryPercentage_Float = 1012; - /** native declaration : headers\openvr_capi.h:288 */ - public static final int ETrackedDeviceProperty_Prop_StatusDisplayTransform_Matrix34 = 1013; - /** native declaration : headers\openvr_capi.h:289 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_UpdateAvailable_Bool = 1014; - /** native declaration : headers\openvr_capi.h:290 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdate_Bool = 1015; - /** native declaration : headers\openvr_capi.h:291 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdateURL_String = 1016; - /** native declaration : headers\openvr_capi.h:292 */ - public static final int ETrackedDeviceProperty_Prop_HardwareRevision_Uint64 = 1017; - /** native declaration : headers\openvr_capi.h:293 */ - public static final int ETrackedDeviceProperty_Prop_FirmwareVersion_Uint64 = 1018; - /** native declaration : headers\openvr_capi.h:294 */ - public static final int ETrackedDeviceProperty_Prop_FPGAVersion_Uint64 = 1019; - /** native declaration : headers\openvr_capi.h:295 */ - public static final int ETrackedDeviceProperty_Prop_VRCVersion_Uint64 = 1020; - /** native declaration : headers\openvr_capi.h:296 */ - public static final int ETrackedDeviceProperty_Prop_RadioVersion_Uint64 = 1021; - /** native declaration : headers\openvr_capi.h:297 */ - public static final int ETrackedDeviceProperty_Prop_DongleVersion_Uint64 = 1022; - /** native declaration : headers\openvr_capi.h:298 */ - public static final int ETrackedDeviceProperty_Prop_BlockServerShutdown_Bool = 1023; - /** native declaration : headers\openvr_capi.h:299 */ - public static final int ETrackedDeviceProperty_Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024; - /** native declaration : headers\openvr_capi.h:300 */ - public static final int ETrackedDeviceProperty_Prop_ContainsProximitySensor_Bool = 1025; - /** native declaration : headers\openvr_capi.h:301 */ - public static final int ETrackedDeviceProperty_Prop_DeviceProvidesBatteryStatus_Bool = 1026; - /** native declaration : headers\openvr_capi.h:302 */ - public static final int ETrackedDeviceProperty_Prop_DeviceCanPowerOff_Bool = 1027; - /** native declaration : headers\openvr_capi.h:303 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ProgrammingTarget_String = 1028; - /** native declaration : headers\openvr_capi.h:304 */ - public static final int ETrackedDeviceProperty_Prop_DeviceClass_Int32 = 1029; - /** native declaration : headers\openvr_capi.h:305 */ - public static final int ETrackedDeviceProperty_Prop_HasCamera_Bool = 1030; - /** native declaration : headers\openvr_capi.h:306 */ - public static final int ETrackedDeviceProperty_Prop_DriverVersion_String = 1031; - /** native declaration : headers\openvr_capi.h:307 */ - public static final int ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool = 1032; - /** native declaration : headers\openvr_capi.h:308 */ - public static final int ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool = 1033; - /** native declaration : headers\openvr_capi.h:309 */ - public static final int ETrackedDeviceProperty_Prop_ParentDriver_Uint64 = 1034; - /** native declaration : headers\openvr_capi.h:310 */ - public static final int ETrackedDeviceProperty_Prop_ResourceRoot_String = 1035; - /** native declaration : headers\openvr_capi.h:311 */ - public static final int ETrackedDeviceProperty_Prop_RegisteredDeviceType_String = 1036; - /** native declaration : headers\openvr_capi.h:312 */ - public static final int ETrackedDeviceProperty_Prop_InputProfilePath_String = 1037; - /** native declaration : headers\openvr_capi.h:313 */ - public static final int ETrackedDeviceProperty_Prop_NeverTracked_Bool = 1038; - /** native declaration : headers\openvr_capi.h:314 */ - public static final int ETrackedDeviceProperty_Prop_NumCameras_Int32 = 1039; - /** native declaration : headers\openvr_capi.h:315 */ - public static final int ETrackedDeviceProperty_Prop_CameraFrameLayout_Int32 = 1040; - /** native declaration : headers\openvr_capi.h:316 */ - public static final int ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool = 2000; - /** native declaration : headers\openvr_capi.h:317 */ - public static final int ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float = 2001; - /** native declaration : headers\openvr_capi.h:318 */ - public static final int ETrackedDeviceProperty_Prop_DisplayFrequency_Float = 2002; - /** native declaration : headers\openvr_capi.h:319 */ - public static final int ETrackedDeviceProperty_Prop_UserIpdMeters_Float = 2003; - /** native declaration : headers\openvr_capi.h:320 */ - public static final int ETrackedDeviceProperty_Prop_CurrentUniverseId_Uint64 = 2004; - /** native declaration : headers\openvr_capi.h:321 */ - public static final int ETrackedDeviceProperty_Prop_PreviousUniverseId_Uint64 = 2005; - /** native declaration : headers\openvr_capi.h:322 */ - public static final int ETrackedDeviceProperty_Prop_DisplayFirmwareVersion_Uint64 = 2006; - /** native declaration : headers\openvr_capi.h:323 */ - public static final int ETrackedDeviceProperty_Prop_IsOnDesktop_Bool = 2007; - /** native declaration : headers\openvr_capi.h:324 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCType_Int32 = 2008; - /** native declaration : headers\openvr_capi.h:325 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCOffset_Float = 2009; - /** native declaration : headers\openvr_capi.h:326 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCScale_Float = 2010; - /** native declaration : headers\openvr_capi.h:327 */ - public static final int ETrackedDeviceProperty_Prop_EdidVendorID_Int32 = 2011; - /** native declaration : headers\openvr_capi.h:328 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageLeft_String = 2012; - /** native declaration : headers\openvr_capi.h:329 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageRight_String = 2013; - /** native declaration : headers\openvr_capi.h:330 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCBlackClamp_Float = 2014; - /** native declaration : headers\openvr_capi.h:331 */ - public static final int ETrackedDeviceProperty_Prop_EdidProductID_Int32 = 2015; - /** native declaration : headers\openvr_capi.h:332 */ - public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransform_Matrix34 = 2016; - /** native declaration : headers\openvr_capi.h:333 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCType_Int32 = 2017; - /** native declaration : headers\openvr_capi.h:334 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCOffset_Float = 2018; - /** native declaration : headers\openvr_capi.h:335 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCScale_Float = 2019; - /** native declaration : headers\openvr_capi.h:336 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCPrescale_Float = 2020; - /** native declaration : headers\openvr_capi.h:337 */ - public static final int ETrackedDeviceProperty_Prop_DisplayGCImage_String = 2021; - /** native declaration : headers\openvr_capi.h:338 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterLeftU_Float = 2022; - /** native declaration : headers\openvr_capi.h:339 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterLeftV_Float = 2023; - /** native declaration : headers\openvr_capi.h:340 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterRightU_Float = 2024; - /** native declaration : headers\openvr_capi.h:341 */ - public static final int ETrackedDeviceProperty_Prop_LensCenterRightV_Float = 2025; - /** native declaration : headers\openvr_capi.h:342 */ - public static final int ETrackedDeviceProperty_Prop_UserHeadToEyeDepthMeters_Float = 2026; - /** native declaration : headers\openvr_capi.h:343 */ - public static final int ETrackedDeviceProperty_Prop_CameraFirmwareVersion_Uint64 = 2027; - /** native declaration : headers\openvr_capi.h:344 */ - public static final int ETrackedDeviceProperty_Prop_CameraFirmwareDescription_String = 2028; - /** native declaration : headers\openvr_capi.h:345 */ - public static final int ETrackedDeviceProperty_Prop_DisplayFPGAVersion_Uint64 = 2029; - /** native declaration : headers\openvr_capi.h:346 */ - public static final int ETrackedDeviceProperty_Prop_DisplayBootloaderVersion_Uint64 = 2030; - /** native declaration : headers\openvr_capi.h:347 */ - public static final int ETrackedDeviceProperty_Prop_DisplayHardwareVersion_Uint64 = 2031; - /** native declaration : headers\openvr_capi.h:348 */ - public static final int ETrackedDeviceProperty_Prop_AudioFirmwareVersion_Uint64 = 2032; - /** native declaration : headers\openvr_capi.h:349 */ - public static final int ETrackedDeviceProperty_Prop_CameraCompatibilityMode_Int32 = 2033; - /** native declaration : headers\openvr_capi.h:350 */ - public static final int ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034; - /** native declaration : headers\openvr_capi.h:351 */ - public static final int ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035; - /** native declaration : headers\openvr_capi.h:352 */ - public static final int ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool = 2036; - /** native declaration : headers\openvr_capi.h:353 */ - public static final int ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool = 2037; - /** native declaration : headers\openvr_capi.h:354 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32 = 2038; - /** native declaration : headers\openvr_capi.h:355 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32 = 2039; - /** native declaration : headers\openvr_capi.h:356 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32 = 2040; - /** native declaration : headers\openvr_capi.h:357 */ - public static final int ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary = 2041; - /** native declaration : headers\openvr_capi.h:358 */ - public static final int ETrackedDeviceProperty_Prop_SecondsFromPhotonsToVblank_Float = 2042; - /** native declaration : headers\openvr_capi.h:359 */ - public static final int ETrackedDeviceProperty_Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043; - /** native declaration : headers\openvr_capi.h:360 */ - public static final int ETrackedDeviceProperty_Prop_DisplayDebugMode_Bool = 2044; - /** native declaration : headers\openvr_capi.h:361 */ - public static final int ETrackedDeviceProperty_Prop_GraphicsAdapterLuid_Uint64 = 2045; - /** native declaration : headers\openvr_capi.h:362 */ - public static final int ETrackedDeviceProperty_Prop_DriverProvidedChaperonePath_String = 2048; - /** native declaration : headers\openvr_capi.h:363 */ - public static final int ETrackedDeviceProperty_Prop_ExpectedTrackingReferenceCount_Int32 = 2049; - /** native declaration : headers\openvr_capi.h:364 */ - public static final int ETrackedDeviceProperty_Prop_ExpectedControllerCount_Int32 = 2050; - /** native declaration : headers\openvr_capi.h:365 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerLeftDeviceOff_String = 2051; - /** native declaration : headers\openvr_capi.h:366 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerRightDeviceOff_String = 2052; - /** native declaration : headers\openvr_capi.h:367 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053; - /** native declaration : headers\openvr_capi.h:368 */ - public static final int ETrackedDeviceProperty_Prop_DoNotApplyPrediction_Bool = 2054; - /** native declaration : headers\openvr_capi.h:369 */ - public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransforms_Matrix34_Array = 2055; - /** native declaration : headers\openvr_capi.h:370 */ - public static final int ETrackedDeviceProperty_Prop_DistortionMeshResolution_Int32 = 2056; - /** native declaration : headers\openvr_capi.h:371 */ - public static final int ETrackedDeviceProperty_Prop_DriverIsDrawingControllers_Bool = 2057; - /** native declaration : headers\openvr_capi.h:372 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestsApplicationPause_Bool = 2058; - /** native declaration : headers\openvr_capi.h:373 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestsReducedRendering_Bool = 2059; - /** native declaration : headers\openvr_capi.h:374 */ - public static final int ETrackedDeviceProperty_Prop_MinimumIpdStepMeters_Float = 2060; - /** native declaration : headers\openvr_capi.h:375 */ - public static final int ETrackedDeviceProperty_Prop_AudioBridgeFirmwareVersion_Uint64 = 2061; - /** native declaration : headers\openvr_capi.h:376 */ - public static final int ETrackedDeviceProperty_Prop_ImageBridgeFirmwareVersion_Uint64 = 2062; - /** native declaration : headers\openvr_capi.h:377 */ - public static final int ETrackedDeviceProperty_Prop_ImuToHeadTransform_Matrix34 = 2063; - /** native declaration : headers\openvr_capi.h:378 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroBias_Vector3 = 2064; - /** native declaration : headers\openvr_capi.h:379 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroScale_Vector3 = 2065; - /** native declaration : headers\openvr_capi.h:380 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerBias_Vector3 = 2066; - /** native declaration : headers\openvr_capi.h:381 */ - public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerScale_Vector3 = 2067; - /** native declaration : headers\openvr_capi.h:382 */ - public static final int ETrackedDeviceProperty_Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069; - /** native declaration : headers\openvr_capi.h:383 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200; - /** native declaration : headers\openvr_capi.h:384 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201; - /** native declaration : headers\openvr_capi.h:385 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202; - /** native declaration : headers\openvr_capi.h:386 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203; - /** native declaration : headers\openvr_capi.h:387 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204; - /** native declaration : headers\openvr_capi.h:388 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205; - /** native declaration : headers\openvr_capi.h:389 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206; - /** native declaration : headers\openvr_capi.h:390 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207; - /** native declaration : headers\openvr_capi.h:391 */ - public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208; - /** native declaration : headers\openvr_capi.h:392 */ - public static final int ETrackedDeviceProperty_Prop_AttachedDeviceId_String = 3000; - /** native declaration : headers\openvr_capi.h:393 */ - public static final int ETrackedDeviceProperty_Prop_SupportedButtons_Uint64 = 3001; - /** native declaration : headers\openvr_capi.h:394 */ - public static final int ETrackedDeviceProperty_Prop_Axis0Type_Int32 = 3002; - /** native declaration : headers\openvr_capi.h:395 */ - public static final int ETrackedDeviceProperty_Prop_Axis1Type_Int32 = 3003; - /** native declaration : headers\openvr_capi.h:396 */ - public static final int ETrackedDeviceProperty_Prop_Axis2Type_Int32 = 3004; - /** native declaration : headers\openvr_capi.h:397 */ - public static final int ETrackedDeviceProperty_Prop_Axis3Type_Int32 = 3005; - /** native declaration : headers\openvr_capi.h:398 */ - public static final int ETrackedDeviceProperty_Prop_Axis4Type_Int32 = 3006; - /** native declaration : headers\openvr_capi.h:399 */ - public static final int ETrackedDeviceProperty_Prop_ControllerRoleHint_Int32 = 3007; - /** native declaration : headers\openvr_capi.h:400 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewLeftDegrees_Float = 4000; - /** native declaration : headers\openvr_capi.h:401 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewRightDegrees_Float = 4001; - /** native declaration : headers\openvr_capi.h:402 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewTopDegrees_Float = 4002; - /** native declaration : headers\openvr_capi.h:403 */ - public static final int ETrackedDeviceProperty_Prop_FieldOfViewBottomDegrees_Float = 4003; - /** native declaration : headers\openvr_capi.h:404 */ - public static final int ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float = 4004; - /** native declaration : headers\openvr_capi.h:405 */ - public static final int ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float = 4005; - /** native declaration : headers\openvr_capi.h:406 */ - public static final int ETrackedDeviceProperty_Prop_ModeLabel_String = 4006; - /** native declaration : headers\openvr_capi.h:407 */ - public static final int ETrackedDeviceProperty_Prop_IconPathName_String = 5000; - /** native declaration : headers\openvr_capi.h:408 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String = 5001; - /** native declaration : headers\openvr_capi.h:409 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String = 5002; - /** native declaration : headers\openvr_capi.h:410 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String = 5003; - /** native declaration : headers\openvr_capi.h:411 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String = 5004; - /** native declaration : headers\openvr_capi.h:412 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String = 5005; - /** native declaration : headers\openvr_capi.h:413 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String = 5006; - /** native declaration : headers\openvr_capi.h:414 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String = 5007; - /** native declaration : headers\openvr_capi.h:415 */ - public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String = 5008; - /** native declaration : headers\openvr_capi.h:416 */ - public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start = 5100; - /** native declaration : headers\openvr_capi.h:417 */ - public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End = 5150; - /** native declaration : headers\openvr_capi.h:418 */ - public static final int ETrackedDeviceProperty_Prop_ParentContainer = 5151; - /** native declaration : headers\openvr_capi.h:419 */ - public static final int ETrackedDeviceProperty_Prop_UserConfigPath_String = 6000; - /** native declaration : headers\openvr_capi.h:420 */ - public static final int ETrackedDeviceProperty_Prop_InstallPath_String = 6001; - /** native declaration : headers\openvr_capi.h:421 */ - public static final int ETrackedDeviceProperty_Prop_HasDisplayComponent_Bool = 6002; - /** native declaration : headers\openvr_capi.h:422 */ - public static final int ETrackedDeviceProperty_Prop_HasControllerComponent_Bool = 6003; - /** native declaration : headers\openvr_capi.h:423 */ - public static final int ETrackedDeviceProperty_Prop_HasCameraComponent_Bool = 6004; - /** native declaration : headers\openvr_capi.h:424 */ - public static final int ETrackedDeviceProperty_Prop_HasDriverDirectModeComponent_Bool = 6005; - /** native declaration : headers\openvr_capi.h:425 */ - public static final int ETrackedDeviceProperty_Prop_HasVirtualDisplayComponent_Bool = 6006; - /** native declaration : headers\openvr_capi.h:426 */ - public static final int ETrackedDeviceProperty_Prop_HasSpatialAnchorsSupport_Bool = 6007; - /** native declaration : headers\openvr_capi.h:427 */ - public static final int ETrackedDeviceProperty_Prop_ControllerType_String = 7000; - /** native declaration : headers\openvr_capi.h:428 */ - public static final int ETrackedDeviceProperty_Prop_LegacyInputProfile_String = 7001; - /** native declaration : headers\openvr_capi.h:429 */ - public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start = 10000; - /** native declaration : headers\openvr_capi.h:430 */ - public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End = 10999; - /** native declaration : headers\openvr_capi.h:431 */ - public static final int ETrackedDeviceProperty_Prop_TrackedDeviceProperty_Max = 1000000; - }; - /** - * native declaration : headers\openvr_capi.h:447
        - * enum values - */ - public static interface ETrackedPropertyError { - /** native declaration : headers\openvr_capi.h:434 */ - public static final int ETrackedPropertyError_TrackedProp_Success = 0; - /** native declaration : headers\openvr_capi.h:435 */ - public static final int ETrackedPropertyError_TrackedProp_WrongDataType = 1; - /** native declaration : headers\openvr_capi.h:436 */ - public static final int ETrackedPropertyError_TrackedProp_WrongDeviceClass = 2; - /** native declaration : headers\openvr_capi.h:437 */ - public static final int ETrackedPropertyError_TrackedProp_BufferTooSmall = 3; - /** native declaration : headers\openvr_capi.h:438 */ - public static final int ETrackedPropertyError_TrackedProp_UnknownProperty = 4; - /** native declaration : headers\openvr_capi.h:439 */ - public static final int ETrackedPropertyError_TrackedProp_InvalidDevice = 5; - /** native declaration : headers\openvr_capi.h:440 */ - public static final int ETrackedPropertyError_TrackedProp_CouldNotContactServer = 6; - /** native declaration : headers\openvr_capi.h:441 */ - public static final int ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice = 7; - /** native declaration : headers\openvr_capi.h:442 */ - public static final int ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength = 8; - /** native declaration : headers\openvr_capi.h:443 */ - public static final int ETrackedPropertyError_TrackedProp_NotYetAvailable = 9; - /** native declaration : headers\openvr_capi.h:444 */ - public static final int ETrackedPropertyError_TrackedProp_PermissionDenied = 10; - /** native declaration : headers\openvr_capi.h:445 */ - public static final int ETrackedPropertyError_TrackedProp_InvalidOperation = 11; - /** native declaration : headers\openvr_capi.h:446 */ - public static final int ETrackedPropertyError_TrackedProp_CannotWriteToWildcards = 12; - }; - /** - * native declaration : headers\openvr_capi.h:455
        - * enum values - */ - public static interface EVRSubmitFlags { - /** native declaration : headers\openvr_capi.h:449 */ - public static final int EVRSubmitFlags_Submit_Default = 0; - /** native declaration : headers\openvr_capi.h:450 */ - public static final int EVRSubmitFlags_Submit_LensDistortionAlreadyApplied = 1; - /** native declaration : headers\openvr_capi.h:451 */ - public static final int EVRSubmitFlags_Submit_GlRenderBuffer = 2; - /** native declaration : headers\openvr_capi.h:452 */ - public static final int EVRSubmitFlags_Submit_Reserved = 4; - /** native declaration : headers\openvr_capi.h:453 */ - public static final int EVRSubmitFlags_Submit_TextureWithPose = 8; - /** native declaration : headers\openvr_capi.h:454 */ - public static final int EVRSubmitFlags_Submit_TextureWithDepth = 16; - }; - /** - * native declaration : headers\openvr_capi.h:466
        - * enum values - */ - public static interface EVRState { - /** native declaration : headers\openvr_capi.h:457 */ - public static final int EVRState_VRState_Undefined = -1; - /** native declaration : headers\openvr_capi.h:458 */ - public static final int EVRState_VRState_Off = 0; - /** native declaration : headers\openvr_capi.h:459 */ - public static final int EVRState_VRState_Searching = 1; - /** native declaration : headers\openvr_capi.h:460 */ - public static final int EVRState_VRState_Searching_Alert = 2; - /** native declaration : headers\openvr_capi.h:461 */ - public static final int EVRState_VRState_Ready = 3; - /** native declaration : headers\openvr_capi.h:462 */ - public static final int EVRState_VRState_Ready_Alert = 4; - /** native declaration : headers\openvr_capi.h:463 */ - public static final int EVRState_VRState_NotReady = 5; - /** native declaration : headers\openvr_capi.h:464 */ - public static final int EVRState_VRState_Standby = 6; - /** native declaration : headers\openvr_capi.h:465 */ - public static final int EVRState_VRState_Ready_Alert_Low = 7; - }; - /** - * native declaration : headers\openvr_capi.h:616
        - * enum values - */ - public static interface EVREventType { - /** native declaration : headers\openvr_capi.h:468 */ - public static final int EVREventType_VREvent_None = 0; - /** native declaration : headers\openvr_capi.h:469 */ - public static final int EVREventType_VREvent_TrackedDeviceActivated = 100; - /** native declaration : headers\openvr_capi.h:470 */ - public static final int EVREventType_VREvent_TrackedDeviceDeactivated = 101; - /** native declaration : headers\openvr_capi.h:471 */ - public static final int EVREventType_VREvent_TrackedDeviceUpdated = 102; - /** native declaration : headers\openvr_capi.h:472 */ - public static final int EVREventType_VREvent_TrackedDeviceUserInteractionStarted = 103; - /** native declaration : headers\openvr_capi.h:473 */ - public static final int EVREventType_VREvent_TrackedDeviceUserInteractionEnded = 104; - /** native declaration : headers\openvr_capi.h:474 */ - public static final int EVREventType_VREvent_IpdChanged = 105; - /** native declaration : headers\openvr_capi.h:475 */ - public static final int EVREventType_VREvent_EnterStandbyMode = 106; - /** native declaration : headers\openvr_capi.h:476 */ - public static final int EVREventType_VREvent_LeaveStandbyMode = 107; - /** native declaration : headers\openvr_capi.h:477 */ - public static final int EVREventType_VREvent_TrackedDeviceRoleChanged = 108; - /** native declaration : headers\openvr_capi.h:478 */ - public static final int EVREventType_VREvent_WatchdogWakeUpRequested = 109; - /** native declaration : headers\openvr_capi.h:479 */ - public static final int EVREventType_VREvent_LensDistortionChanged = 110; - /** native declaration : headers\openvr_capi.h:480 */ - public static final int EVREventType_VREvent_PropertyChanged = 111; - /** native declaration : headers\openvr_capi.h:481 */ - public static final int EVREventType_VREvent_WirelessDisconnect = 112; - /** native declaration : headers\openvr_capi.h:482 */ - public static final int EVREventType_VREvent_WirelessReconnect = 113; - /** native declaration : headers\openvr_capi.h:483 */ - public static final int EVREventType_VREvent_ButtonPress = 200; - /** native declaration : headers\openvr_capi.h:484 */ - public static final int EVREventType_VREvent_ButtonUnpress = 201; - /** native declaration : headers\openvr_capi.h:485 */ - public static final int EVREventType_VREvent_ButtonTouch = 202; - /** native declaration : headers\openvr_capi.h:486 */ - public static final int EVREventType_VREvent_ButtonUntouch = 203; - /** native declaration : headers\openvr_capi.h:487 */ - public static final int EVREventType_VREvent_DualAnalog_Press = 250; - /** native declaration : headers\openvr_capi.h:488 */ - public static final int EVREventType_VREvent_DualAnalog_Unpress = 251; - /** native declaration : headers\openvr_capi.h:489 */ - public static final int EVREventType_VREvent_DualAnalog_Touch = 252; - /** native declaration : headers\openvr_capi.h:490 */ - public static final int EVREventType_VREvent_DualAnalog_Untouch = 253; - /** native declaration : headers\openvr_capi.h:491 */ - public static final int EVREventType_VREvent_DualAnalog_Move = 254; - /** native declaration : headers\openvr_capi.h:492 */ - public static final int EVREventType_VREvent_DualAnalog_ModeSwitch1 = 255; - /** native declaration : headers\openvr_capi.h:493 */ - public static final int EVREventType_VREvent_DualAnalog_ModeSwitch2 = 256; - /** native declaration : headers\openvr_capi.h:494 */ - public static final int EVREventType_VREvent_DualAnalog_Cancel = 257; - /** native declaration : headers\openvr_capi.h:495 */ - public static final int EVREventType_VREvent_MouseMove = 300; - /** native declaration : headers\openvr_capi.h:496 */ - public static final int EVREventType_VREvent_MouseButtonDown = 301; - /** native declaration : headers\openvr_capi.h:497 */ - public static final int EVREventType_VREvent_MouseButtonUp = 302; - /** native declaration : headers\openvr_capi.h:498 */ - public static final int EVREventType_VREvent_FocusEnter = 303; - /** native declaration : headers\openvr_capi.h:499 */ - public static final int EVREventType_VREvent_FocusLeave = 304; - /** native declaration : headers\openvr_capi.h:500 */ - public static final int EVREventType_VREvent_Scroll = 305; - /** native declaration : headers\openvr_capi.h:501 */ - public static final int EVREventType_VREvent_TouchPadMove = 306; - /** native declaration : headers\openvr_capi.h:502 */ - public static final int EVREventType_VREvent_OverlayFocusChanged = 307; - /** native declaration : headers\openvr_capi.h:503 */ - public static final int EVREventType_VREvent_InputFocusCaptured = 400; - /** native declaration : headers\openvr_capi.h:504 */ - public static final int EVREventType_VREvent_InputFocusReleased = 401; - /** native declaration : headers\openvr_capi.h:505 */ - public static final int EVREventType_VREvent_SceneFocusLost = 402; - /** native declaration : headers\openvr_capi.h:506 */ - public static final int EVREventType_VREvent_SceneFocusGained = 403; - /** native declaration : headers\openvr_capi.h:507 */ - public static final int EVREventType_VREvent_SceneApplicationChanged = 404; - /** native declaration : headers\openvr_capi.h:508 */ - public static final int EVREventType_VREvent_SceneFocusChanged = 405; - /** native declaration : headers\openvr_capi.h:509 */ - public static final int EVREventType_VREvent_InputFocusChanged = 406; - /** native declaration : headers\openvr_capi.h:510 */ - public static final int EVREventType_VREvent_SceneApplicationSecondaryRenderingStarted = 407; - /** native declaration : headers\openvr_capi.h:511 */ - public static final int EVREventType_VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408; - /** native declaration : headers\openvr_capi.h:512 */ - public static final int EVREventType_VREvent_ActionBindingReloaded = 409; - /** native declaration : headers\openvr_capi.h:513 */ - public static final int EVREventType_VREvent_HideRenderModels = 410; - /** native declaration : headers\openvr_capi.h:514 */ - public static final int EVREventType_VREvent_ShowRenderModels = 411; - /** native declaration : headers\openvr_capi.h:515 */ - public static final int EVREventType_VREvent_ConsoleOpened = 420; - /** native declaration : headers\openvr_capi.h:516 */ - public static final int EVREventType_VREvent_ConsoleClosed = 421; - /** native declaration : headers\openvr_capi.h:517 */ - public static final int EVREventType_VREvent_OverlayShown = 500; - /** native declaration : headers\openvr_capi.h:518 */ - public static final int EVREventType_VREvent_OverlayHidden = 501; - /** native declaration : headers\openvr_capi.h:519 */ - public static final int EVREventType_VREvent_DashboardActivated = 502; - /** native declaration : headers\openvr_capi.h:520 */ - public static final int EVREventType_VREvent_DashboardDeactivated = 503; - /** native declaration : headers\openvr_capi.h:521 */ - public static final int EVREventType_VREvent_DashboardThumbSelected = 504; - /** native declaration : headers\openvr_capi.h:522 */ - public static final int EVREventType_VREvent_DashboardRequested = 505; - /** native declaration : headers\openvr_capi.h:523 */ - public static final int EVREventType_VREvent_ResetDashboard = 506; - /** native declaration : headers\openvr_capi.h:524 */ - public static final int EVREventType_VREvent_RenderToast = 507; - /** native declaration : headers\openvr_capi.h:525 */ - public static final int EVREventType_VREvent_ImageLoaded = 508; - /** native declaration : headers\openvr_capi.h:526 */ - public static final int EVREventType_VREvent_ShowKeyboard = 509; - /** native declaration : headers\openvr_capi.h:527 */ - public static final int EVREventType_VREvent_HideKeyboard = 510; - /** native declaration : headers\openvr_capi.h:528 */ - public static final int EVREventType_VREvent_OverlayGamepadFocusGained = 511; - /** native declaration : headers\openvr_capi.h:529 */ - public static final int EVREventType_VREvent_OverlayGamepadFocusLost = 512; - /** native declaration : headers\openvr_capi.h:530 */ - public static final int EVREventType_VREvent_OverlaySharedTextureChanged = 513; - /** native declaration : headers\openvr_capi.h:531 */ - public static final int EVREventType_VREvent_ScreenshotTriggered = 516; - /** native declaration : headers\openvr_capi.h:532 */ - public static final int EVREventType_VREvent_ImageFailed = 517; - /** native declaration : headers\openvr_capi.h:533 */ - public static final int EVREventType_VREvent_DashboardOverlayCreated = 518; - /** native declaration : headers\openvr_capi.h:534 */ - public static final int EVREventType_VREvent_SwitchGamepadFocus = 519; - /** native declaration : headers\openvr_capi.h:535 */ - public static final int EVREventType_VREvent_RequestScreenshot = 520; - /** native declaration : headers\openvr_capi.h:536 */ - public static final int EVREventType_VREvent_ScreenshotTaken = 521; - /** native declaration : headers\openvr_capi.h:537 */ - public static final int EVREventType_VREvent_ScreenshotFailed = 522; - /** native declaration : headers\openvr_capi.h:538 */ - public static final int EVREventType_VREvent_SubmitScreenshotToDashboard = 523; - /** native declaration : headers\openvr_capi.h:539 */ - public static final int EVREventType_VREvent_ScreenshotProgressToDashboard = 524; - /** native declaration : headers\openvr_capi.h:540 */ - public static final int EVREventType_VREvent_PrimaryDashboardDeviceChanged = 525; - /** native declaration : headers\openvr_capi.h:541 */ - public static final int EVREventType_VREvent_RoomViewShown = 526; - /** native declaration : headers\openvr_capi.h:542 */ - public static final int EVREventType_VREvent_RoomViewHidden = 527; - /** native declaration : headers\openvr_capi.h:543 */ - public static final int EVREventType_VREvent_Notification_Shown = 600; - /** native declaration : headers\openvr_capi.h:544 */ - public static final int EVREventType_VREvent_Notification_Hidden = 601; - /** native declaration : headers\openvr_capi.h:545 */ - public static final int EVREventType_VREvent_Notification_BeginInteraction = 602; - /** native declaration : headers\openvr_capi.h:546 */ - public static final int EVREventType_VREvent_Notification_Destroyed = 603; - /** native declaration : headers\openvr_capi.h:547 */ - public static final int EVREventType_VREvent_Quit = 700; - /** native declaration : headers\openvr_capi.h:548 */ - public static final int EVREventType_VREvent_ProcessQuit = 701; - /** native declaration : headers\openvr_capi.h:549 */ - public static final int EVREventType_VREvent_QuitAborted_UserPrompt = 702; - /** native declaration : headers\openvr_capi.h:550 */ - public static final int EVREventType_VREvent_QuitAcknowledged = 703; - /** native declaration : headers\openvr_capi.h:551 */ - public static final int EVREventType_VREvent_DriverRequestedQuit = 704; - /** native declaration : headers\openvr_capi.h:552 */ - public static final int EVREventType_VREvent_ChaperoneDataHasChanged = 800; - /** native declaration : headers\openvr_capi.h:553 */ - public static final int EVREventType_VREvent_ChaperoneUniverseHasChanged = 801; - /** native declaration : headers\openvr_capi.h:554 */ - public static final int EVREventType_VREvent_ChaperoneTempDataHasChanged = 802; - /** native declaration : headers\openvr_capi.h:555 */ - public static final int EVREventType_VREvent_ChaperoneSettingsHaveChanged = 803; - /** native declaration : headers\openvr_capi.h:556 */ - public static final int EVREventType_VREvent_SeatedZeroPoseReset = 804; - /** native declaration : headers\openvr_capi.h:557 */ - public static final int EVREventType_VREvent_AudioSettingsHaveChanged = 820; - /** native declaration : headers\openvr_capi.h:558 */ - public static final int EVREventType_VREvent_BackgroundSettingHasChanged = 850; - /** native declaration : headers\openvr_capi.h:559 */ - public static final int EVREventType_VREvent_CameraSettingsHaveChanged = 851; - /** native declaration : headers\openvr_capi.h:560 */ - public static final int EVREventType_VREvent_ReprojectionSettingHasChanged = 852; - /** native declaration : headers\openvr_capi.h:561 */ - public static final int EVREventType_VREvent_ModelSkinSettingsHaveChanged = 853; - /** native declaration : headers\openvr_capi.h:562 */ - public static final int EVREventType_VREvent_EnvironmentSettingsHaveChanged = 854; - /** native declaration : headers\openvr_capi.h:563 */ - public static final int EVREventType_VREvent_PowerSettingsHaveChanged = 855; - /** native declaration : headers\openvr_capi.h:564 */ - public static final int EVREventType_VREvent_EnableHomeAppSettingsHaveChanged = 856; - /** native declaration : headers\openvr_capi.h:565 */ - public static final int EVREventType_VREvent_SteamVRSectionSettingChanged = 857; - /** native declaration : headers\openvr_capi.h:566 */ - public static final int EVREventType_VREvent_LighthouseSectionSettingChanged = 858; - /** native declaration : headers\openvr_capi.h:567 */ - public static final int EVREventType_VREvent_NullSectionSettingChanged = 859; - /** native declaration : headers\openvr_capi.h:568 */ - public static final int EVREventType_VREvent_UserInterfaceSectionSettingChanged = 860; - /** native declaration : headers\openvr_capi.h:569 */ - public static final int EVREventType_VREvent_NotificationsSectionSettingChanged = 861; - /** native declaration : headers\openvr_capi.h:570 */ - public static final int EVREventType_VREvent_KeyboardSectionSettingChanged = 862; - /** native declaration : headers\openvr_capi.h:571 */ - public static final int EVREventType_VREvent_PerfSectionSettingChanged = 863; - /** native declaration : headers\openvr_capi.h:572 */ - public static final int EVREventType_VREvent_DashboardSectionSettingChanged = 864; - /** native declaration : headers\openvr_capi.h:573 */ - public static final int EVREventType_VREvent_WebInterfaceSectionSettingChanged = 865; - /** native declaration : headers\openvr_capi.h:574 */ - public static final int EVREventType_VREvent_TrackersSectionSettingChanged = 866; - /** native declaration : headers\openvr_capi.h:575 */ - public static final int EVREventType_VREvent_StatusUpdate = 900; - /** native declaration : headers\openvr_capi.h:576 */ - public static final int EVREventType_VREvent_WebInterface_InstallDriverCompleted = 950; - /** native declaration : headers\openvr_capi.h:577 */ - public static final int EVREventType_VREvent_MCImageUpdated = 1000; - /** native declaration : headers\openvr_capi.h:578 */ - public static final int EVREventType_VREvent_FirmwareUpdateStarted = 1100; - /** native declaration : headers\openvr_capi.h:579 */ - public static final int EVREventType_VREvent_FirmwareUpdateFinished = 1101; - /** native declaration : headers\openvr_capi.h:580 */ - public static final int EVREventType_VREvent_KeyboardClosed = 1200; - /** native declaration : headers\openvr_capi.h:581 */ - public static final int EVREventType_VREvent_KeyboardCharInput = 1201; - /** native declaration : headers\openvr_capi.h:582 */ - public static final int EVREventType_VREvent_KeyboardDone = 1202; - /** native declaration : headers\openvr_capi.h:583 */ - public static final int EVREventType_VREvent_ApplicationTransitionStarted = 1300; - /** native declaration : headers\openvr_capi.h:584 */ - public static final int EVREventType_VREvent_ApplicationTransitionAborted = 1301; - /** native declaration : headers\openvr_capi.h:585 */ - public static final int EVREventType_VREvent_ApplicationTransitionNewAppStarted = 1302; - /** native declaration : headers\openvr_capi.h:586 */ - public static final int EVREventType_VREvent_ApplicationListUpdated = 1303; - /** native declaration : headers\openvr_capi.h:587 */ - public static final int EVREventType_VREvent_ApplicationMimeTypeLoad = 1304; - /** native declaration : headers\openvr_capi.h:588 */ - public static final int EVREventType_VREvent_ApplicationTransitionNewAppLaunchComplete = 1305; - /** native declaration : headers\openvr_capi.h:589 */ - public static final int EVREventType_VREvent_ProcessConnected = 1306; - /** native declaration : headers\openvr_capi.h:590 */ - public static final int EVREventType_VREvent_ProcessDisconnected = 1307; - /** native declaration : headers\openvr_capi.h:591 */ - public static final int EVREventType_VREvent_Compositor_MirrorWindowShown = 1400; - /** native declaration : headers\openvr_capi.h:592 */ - public static final int EVREventType_VREvent_Compositor_MirrorWindowHidden = 1401; - /** native declaration : headers\openvr_capi.h:593 */ - public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsShown = 1410; - /** native declaration : headers\openvr_capi.h:594 */ - public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsHidden = 1411; - /** native declaration : headers\openvr_capi.h:595 */ - public static final int EVREventType_VREvent_TrackedCamera_StartVideoStream = 1500; - /** native declaration : headers\openvr_capi.h:596 */ - public static final int EVREventType_VREvent_TrackedCamera_StopVideoStream = 1501; - /** native declaration : headers\openvr_capi.h:597 */ - public static final int EVREventType_VREvent_TrackedCamera_PauseVideoStream = 1502; - /** native declaration : headers\openvr_capi.h:598 */ - public static final int EVREventType_VREvent_TrackedCamera_ResumeVideoStream = 1503; - /** native declaration : headers\openvr_capi.h:599 */ - public static final int EVREventType_VREvent_TrackedCamera_EditingSurface = 1550; - /** native declaration : headers\openvr_capi.h:600 */ - public static final int EVREventType_VREvent_PerformanceTest_EnableCapture = 1600; - /** native declaration : headers\openvr_capi.h:601 */ - public static final int EVREventType_VREvent_PerformanceTest_DisableCapture = 1601; - /** native declaration : headers\openvr_capi.h:602 */ - public static final int EVREventType_VREvent_PerformanceTest_FidelityLevel = 1602; - /** native declaration : headers\openvr_capi.h:603 */ - public static final int EVREventType_VREvent_MessageOverlay_Closed = 1650; - /** native declaration : headers\openvr_capi.h:604 */ - public static final int EVREventType_VREvent_MessageOverlayCloseRequested = 1651; - /** native declaration : headers\openvr_capi.h:605 */ - public static final int EVREventType_VREvent_Input_HapticVibration = 1700; - /** native declaration : headers\openvr_capi.h:606 */ - public static final int EVREventType_VREvent_Input_BindingLoadFailed = 1701; - /** native declaration : headers\openvr_capi.h:607 */ - public static final int EVREventType_VREvent_Input_BindingLoadSuccessful = 1702; - /** native declaration : headers\openvr_capi.h:608 */ - public static final int EVREventType_VREvent_Input_ActionManifestReloaded = 1703; - /** native declaration : headers\openvr_capi.h:609 */ - public static final int EVREventType_VREvent_Input_ActionManifestLoadFailed = 1704; - /** native declaration : headers\openvr_capi.h:610 */ - public static final int EVREventType_VREvent_SpatialAnchors_PoseUpdated = 1800; - /** native declaration : headers\openvr_capi.h:611 */ - public static final int EVREventType_VREvent_SpatialAnchors_DescriptorUpdated = 1801; - /** native declaration : headers\openvr_capi.h:612 */ - public static final int EVREventType_VREvent_SpatialAnchors_RequestPoseUpdate = 1802; - /** native declaration : headers\openvr_capi.h:613 */ - public static final int EVREventType_VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803; - /** native declaration : headers\openvr_capi.h:614 */ - public static final int EVREventType_VREvent_VendorSpecific_Reserved_Start = 10000; - /** native declaration : headers\openvr_capi.h:615 */ - public static final int EVREventType_VREvent_VendorSpecific_Reserved_End = 19999; - }; - /** - * native declaration : headers\openvr_capi.h:623
        - * enum values - */ - public static interface EDeviceActivityLevel { - /** native declaration : headers\openvr_capi.h:618 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Unknown = -1; - /** native declaration : headers\openvr_capi.h:619 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Idle = 0; - /** native declaration : headers\openvr_capi.h:620 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction = 1; - /** native declaration : headers\openvr_capi.h:621 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction_Timeout = 2; - /** native declaration : headers\openvr_capi.h:622 */ - public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Standby = 3; - }; - /** - * native declaration : headers\openvr_capi.h:646
        - * enum values - */ - public static interface EVRButtonId { - /** native declaration : headers\openvr_capi.h:625 */ - public static final int EVRButtonId_k_EButton_System = 0; - /** native declaration : headers\openvr_capi.h:626 */ - public static final int EVRButtonId_k_EButton_ApplicationMenu = 1; - /** native declaration : headers\openvr_capi.h:627 */ - public static final int EVRButtonId_k_EButton_Grip = 2; - /** native declaration : headers\openvr_capi.h:628 */ - public static final int EVRButtonId_k_EButton_DPad_Left = 3; - /** native declaration : headers\openvr_capi.h:629 */ - public static final int EVRButtonId_k_EButton_DPad_Up = 4; - /** native declaration : headers\openvr_capi.h:630 */ - public static final int EVRButtonId_k_EButton_DPad_Right = 5; - /** native declaration : headers\openvr_capi.h:631 */ - public static final int EVRButtonId_k_EButton_DPad_Down = 6; - /** native declaration : headers\openvr_capi.h:632 */ - public static final int EVRButtonId_k_EButton_A = 7; - /** native declaration : headers\openvr_capi.h:633 */ - public static final int EVRButtonId_k_EButton_ProximitySensor = 31; - /** native declaration : headers\openvr_capi.h:634 */ - public static final int EVRButtonId_k_EButton_Axis0 = 32; - /** native declaration : headers\openvr_capi.h:635 */ - public static final int EVRButtonId_k_EButton_Axis1 = 33; - /** native declaration : headers\openvr_capi.h:636 */ - public static final int EVRButtonId_k_EButton_Axis2 = 34; - /** native declaration : headers\openvr_capi.h:637 */ - public static final int EVRButtonId_k_EButton_Axis3 = 35; - /** native declaration : headers\openvr_capi.h:638 */ - public static final int EVRButtonId_k_EButton_Axis4 = 36; - /** native declaration : headers\openvr_capi.h:639 */ - public static final int EVRButtonId_k_EButton_SteamVR_Touchpad = 32; - /** native declaration : headers\openvr_capi.h:640 */ - public static final int EVRButtonId_k_EButton_SteamVR_Trigger = 33; - /** native declaration : headers\openvr_capi.h:641 */ - public static final int EVRButtonId_k_EButton_Dashboard_Back = 2; - /** native declaration : headers\openvr_capi.h:642 */ - public static final int EVRButtonId_k_EButton_Knuckles_A = 2; - /** native declaration : headers\openvr_capi.h:643 */ - public static final int EVRButtonId_k_EButton_Knuckles_B = 1; - /** native declaration : headers\openvr_capi.h:644 */ - public static final int EVRButtonId_k_EButton_Knuckles_JoyStick = 35; - /** native declaration : headers\openvr_capi.h:645 */ - public static final int EVRButtonId_k_EButton_Max = 64; - }; - /** - * native declaration : headers\openvr_capi.h:651
        - * enum values - */ - public static interface EVRMouseButton { - /** native declaration : headers\openvr_capi.h:648 */ - public static final int EVRMouseButton_VRMouseButton_Left = 1; - /** native declaration : headers\openvr_capi.h:649 */ - public static final int EVRMouseButton_VRMouseButton_Right = 2; - /** native declaration : headers\openvr_capi.h:650 */ - public static final int EVRMouseButton_VRMouseButton_Middle = 4; - }; - /** - * native declaration : headers\openvr_capi.h:655
        - * enum values - */ - public static interface EDualAnalogWhich { - /** native declaration : headers\openvr_capi.h:653 */ - public static final int EDualAnalogWhich_k_EDualAnalog_Left = 0; - /** native declaration : headers\openvr_capi.h:654 */ - public static final int EDualAnalogWhich_k_EDualAnalog_Right = 1; - }; - /** - * native declaration : headers\openvr_capi.h:674
        - * enum values - */ - public static interface EVRInputError { - /** native declaration : headers\openvr_capi.h:657 */ - public static final int EVRInputError_VRInputError_None = 0; - /** native declaration : headers\openvr_capi.h:658 */ - public static final int EVRInputError_VRInputError_NameNotFound = 1; - /** native declaration : headers\openvr_capi.h:659 */ - public static final int EVRInputError_VRInputError_WrongType = 2; - /** native declaration : headers\openvr_capi.h:660 */ - public static final int EVRInputError_VRInputError_InvalidHandle = 3; - /** native declaration : headers\openvr_capi.h:661 */ - public static final int EVRInputError_VRInputError_InvalidParam = 4; - /** native declaration : headers\openvr_capi.h:662 */ - public static final int EVRInputError_VRInputError_NoSteam = 5; - /** native declaration : headers\openvr_capi.h:663 */ - public static final int EVRInputError_VRInputError_MaxCapacityReached = 6; - /** native declaration : headers\openvr_capi.h:664 */ - public static final int EVRInputError_VRInputError_IPCError = 7; - /** native declaration : headers\openvr_capi.h:665 */ - public static final int EVRInputError_VRInputError_NoActiveActionSet = 8; - /** native declaration : headers\openvr_capi.h:666 */ - public static final int EVRInputError_VRInputError_InvalidDevice = 9; - /** native declaration : headers\openvr_capi.h:667 */ - public static final int EVRInputError_VRInputError_InvalidSkeleton = 10; - /** native declaration : headers\openvr_capi.h:668 */ - public static final int EVRInputError_VRInputError_InvalidBoneCount = 11; - /** native declaration : headers\openvr_capi.h:669 */ - public static final int EVRInputError_VRInputError_InvalidCompressedData = 12; - /** native declaration : headers\openvr_capi.h:670 */ - public static final int EVRInputError_VRInputError_NoData = 13; - /** native declaration : headers\openvr_capi.h:671 */ - public static final int EVRInputError_VRInputError_BufferTooSmall = 14; - /** native declaration : headers\openvr_capi.h:672 */ - public static final int EVRInputError_VRInputError_MismatchedActionManifest = 15; - /** native declaration : headers\openvr_capi.h:673 */ - public static final int EVRInputError_VRInputError_MissingSkeletonData = 16; - }; - /** - * native declaration : headers\openvr_capi.h:690
        - * enum values - */ - public static interface EVRSpatialAnchorError { - /** native declaration : headers\openvr_capi.h:676 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Success = 0; - /** native declaration : headers\openvr_capi.h:677 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Internal = 1; - /** native declaration : headers\openvr_capi.h:678 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownHandle = 2; - /** native declaration : headers\openvr_capi.h:679 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_ArrayTooSmall = 3; - /** native declaration : headers\openvr_capi.h:680 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidDescriptorChar = 4; - /** native declaration : headers\openvr_capi.h:681 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotYetAvailable = 5; - /** native declaration : headers\openvr_capi.h:682 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotAvailableInThisUniverse = 6; - /** native declaration : headers\openvr_capi.h:683 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_PermanentlyUnavailable = 7; - /** native declaration : headers\openvr_capi.h:684 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_WrongDriver = 8; - /** native declaration : headers\openvr_capi.h:685 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_DescriptorTooLong = 9; - /** native declaration : headers\openvr_capi.h:686 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Unknown = 10; - /** native declaration : headers\openvr_capi.h:687 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NoRoomCalibration = 11; - /** native declaration : headers\openvr_capi.h:688 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidArgument = 12; - /** native declaration : headers\openvr_capi.h:689 */ - public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownDriver = 13; - }; - /** - * native declaration : headers\openvr_capi.h:696
        - * enum values - */ - public static interface EHiddenAreaMeshType { - /** native declaration : headers\openvr_capi.h:692 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard = 0; - /** native declaration : headers\openvr_capi.h:693 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Inverse = 1; - /** native declaration : headers\openvr_capi.h:694 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_LineLoop = 2; - /** native declaration : headers\openvr_capi.h:695 */ - public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Max = 3; - }; - /** - * native declaration : headers\openvr_capi.h:702
        - * enum values - */ - public static interface EVRControllerAxisType { - /** native declaration : headers\openvr_capi.h:698 */ - public static final int EVRControllerAxisType_k_eControllerAxis_None = 0; - /** native declaration : headers\openvr_capi.h:699 */ - public static final int EVRControllerAxisType_k_eControllerAxis_TrackPad = 1; - /** native declaration : headers\openvr_capi.h:700 */ - public static final int EVRControllerAxisType_k_eControllerAxis_Joystick = 2; - /** native declaration : headers\openvr_capi.h:701 */ - public static final int EVRControllerAxisType_k_eControllerAxis_Trigger = 3; - }; - /** - * native declaration : headers\openvr_capi.h:706
        - * enum values - */ - public static interface EVRControllerEventOutputType { - /** native declaration : headers\openvr_capi.h:704 */ - public static final int EVRControllerEventOutputType_ControllerEventOutput_OSEvents = 0; - /** native declaration : headers\openvr_capi.h:705 */ - public static final int EVRControllerEventOutputType_ControllerEventOutput_VREvents = 1; - }; - /** - * native declaration : headers\openvr_capi.h:714
        - * enum values - */ - public static interface ECollisionBoundsStyle { - /** native declaration : headers\openvr_capi.h:708 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_BEGINNER = 0; - /** native declaration : headers\openvr_capi.h:709 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_INTERMEDIATE = 1; - /** native declaration : headers\openvr_capi.h:710 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_SQUARES = 2; - /** native declaration : headers\openvr_capi.h:711 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_ADVANCED = 3; - /** native declaration : headers\openvr_capi.h:712 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_NONE = 4; - /** native declaration : headers\openvr_capi.h:713 */ - public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_COUNT = 5; - }; - /** - * native declaration : headers\openvr_capi.h:740
        - * enum values - */ - public static interface EVROverlayError { - /** native declaration : headers\openvr_capi.h:716 */ - public static final int EVROverlayError_VROverlayError_None = 0; - /** native declaration : headers\openvr_capi.h:717 */ - public static final int EVROverlayError_VROverlayError_UnknownOverlay = 10; - /** native declaration : headers\openvr_capi.h:718 */ - public static final int EVROverlayError_VROverlayError_InvalidHandle = 11; - /** native declaration : headers\openvr_capi.h:719 */ - public static final int EVROverlayError_VROverlayError_PermissionDenied = 12; - /** native declaration : headers\openvr_capi.h:720 */ - public static final int EVROverlayError_VROverlayError_OverlayLimitExceeded = 13; - /** native declaration : headers\openvr_capi.h:721 */ - public static final int EVROverlayError_VROverlayError_WrongVisibilityType = 14; - /** native declaration : headers\openvr_capi.h:722 */ - public static final int EVROverlayError_VROverlayError_KeyTooLong = 15; - /** native declaration : headers\openvr_capi.h:723 */ - public static final int EVROverlayError_VROverlayError_NameTooLong = 16; - /** native declaration : headers\openvr_capi.h:724 */ - public static final int EVROverlayError_VROverlayError_KeyInUse = 17; - /** native declaration : headers\openvr_capi.h:725 */ - public static final int EVROverlayError_VROverlayError_WrongTransformType = 18; - /** native declaration : headers\openvr_capi.h:726 */ - public static final int EVROverlayError_VROverlayError_InvalidTrackedDevice = 19; - /** native declaration : headers\openvr_capi.h:727 */ - public static final int EVROverlayError_VROverlayError_InvalidParameter = 20; - /** native declaration : headers\openvr_capi.h:728 */ - public static final int EVROverlayError_VROverlayError_ThumbnailCantBeDestroyed = 21; - /** native declaration : headers\openvr_capi.h:729 */ - public static final int EVROverlayError_VROverlayError_ArrayTooSmall = 22; - /** native declaration : headers\openvr_capi.h:730 */ - public static final int EVROverlayError_VROverlayError_RequestFailed = 23; - /** native declaration : headers\openvr_capi.h:731 */ - public static final int EVROverlayError_VROverlayError_InvalidTexture = 24; - /** native declaration : headers\openvr_capi.h:732 */ - public static final int EVROverlayError_VROverlayError_UnableToLoadFile = 25; - /** native declaration : headers\openvr_capi.h:733 */ - public static final int EVROverlayError_VROverlayError_KeyboardAlreadyInUse = 26; - /** native declaration : headers\openvr_capi.h:734 */ - public static final int EVROverlayError_VROverlayError_NoNeighbor = 27; - /** native declaration : headers\openvr_capi.h:735 */ - public static final int EVROverlayError_VROverlayError_TooManyMaskPrimitives = 29; - /** native declaration : headers\openvr_capi.h:736 */ - public static final int EVROverlayError_VROverlayError_BadMaskPrimitive = 30; - /** native declaration : headers\openvr_capi.h:737 */ - public static final int EVROverlayError_VROverlayError_TextureAlreadyLocked = 31; - /** native declaration : headers\openvr_capi.h:738 */ - public static final int EVROverlayError_VROverlayError_TextureLockCapacityReached = 32; - /** native declaration : headers\openvr_capi.h:739 */ - public static final int EVROverlayError_VROverlayError_TextureNotLocked = 33; - }; - /** - * native declaration : headers\openvr_capi.h:751
        - * enum values - */ - public static interface EVRApplicationType { - /** native declaration : headers\openvr_capi.h:742 */ - public static final int EVRApplicationType_VRApplication_Other = 0; - /** native declaration : headers\openvr_capi.h:743 */ - public static final int EVRApplicationType_VRApplication_Scene = 1; - /** native declaration : headers\openvr_capi.h:744 */ - public static final int EVRApplicationType_VRApplication_Overlay = 2; - /** native declaration : headers\openvr_capi.h:745 */ - public static final int EVRApplicationType_VRApplication_Background = 3; - /** native declaration : headers\openvr_capi.h:746 */ - public static final int EVRApplicationType_VRApplication_Utility = 4; - /** native declaration : headers\openvr_capi.h:747 */ - public static final int EVRApplicationType_VRApplication_VRMonitor = 5; - /** native declaration : headers\openvr_capi.h:748 */ - public static final int EVRApplicationType_VRApplication_SteamWatchdog = 6; - /** native declaration : headers\openvr_capi.h:749 */ - public static final int EVRApplicationType_VRApplication_Bootstrapper = 7; - /** native declaration : headers\openvr_capi.h:750 */ - public static final int EVRApplicationType_VRApplication_Max = 8; - }; - /** - * native declaration : headers\openvr_capi.h:756
        - * enum values - */ - public static interface EVRFirmwareError { - /** native declaration : headers\openvr_capi.h:753 */ - public static final int EVRFirmwareError_VRFirmwareError_None = 0; - /** native declaration : headers\openvr_capi.h:754 */ - public static final int EVRFirmwareError_VRFirmwareError_Success = 1; - /** native declaration : headers\openvr_capi.h:755 */ - public static final int EVRFirmwareError_VRFirmwareError_Fail = 2; - }; - /** - * native declaration : headers\openvr_capi.h:763
        - * enum values - */ - public static interface EVRNotificationError { - /** native declaration : headers\openvr_capi.h:758 */ - public static final int EVRNotificationError_VRNotificationError_OK = 0; - /** native declaration : headers\openvr_capi.h:759 */ - public static final int EVRNotificationError_VRNotificationError_InvalidNotificationId = 100; - /** native declaration : headers\openvr_capi.h:760 */ - public static final int EVRNotificationError_VRNotificationError_NotificationQueueFull = 101; - /** native declaration : headers\openvr_capi.h:761 */ - public static final int EVRNotificationError_VRNotificationError_InvalidOverlayHandle = 102; - /** native declaration : headers\openvr_capi.h:762 */ - public static final int EVRNotificationError_VRNotificationError_SystemWithUserValueAlreadyExists = 103; - }; - /** - * native declaration : headers\openvr_capi.h:767
        - * enum values - */ - public static interface EVRSkeletalMotionRange { - /** native declaration : headers\openvr_capi.h:765 */ - public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithController = 0; - /** native declaration : headers\openvr_capi.h:766 */ - public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithoutController = 1; - }; - /** - * native declaration : headers\openvr_capi.h:857
        - * enum values - */ - public static interface EVRInitError { - /** native declaration : headers\openvr_capi.h:769 */ - public static final int EVRInitError_VRInitError_None = 0; - /** native declaration : headers\openvr_capi.h:770 */ - public static final int EVRInitError_VRInitError_Unknown = 1; - /** native declaration : headers\openvr_capi.h:771 */ - public static final int EVRInitError_VRInitError_Init_InstallationNotFound = 100; - /** native declaration : headers\openvr_capi.h:772 */ - public static final int EVRInitError_VRInitError_Init_InstallationCorrupt = 101; - /** native declaration : headers\openvr_capi.h:773 */ - public static final int EVRInitError_VRInitError_Init_VRClientDLLNotFound = 102; - /** native declaration : headers\openvr_capi.h:774 */ - public static final int EVRInitError_VRInitError_Init_FileNotFound = 103; - /** native declaration : headers\openvr_capi.h:775 */ - public static final int EVRInitError_VRInitError_Init_FactoryNotFound = 104; - /** native declaration : headers\openvr_capi.h:776 */ - public static final int EVRInitError_VRInitError_Init_InterfaceNotFound = 105; - /** native declaration : headers\openvr_capi.h:777 */ - public static final int EVRInitError_VRInitError_Init_InvalidInterface = 106; - /** native declaration : headers\openvr_capi.h:778 */ - public static final int EVRInitError_VRInitError_Init_UserConfigDirectoryInvalid = 107; - /** native declaration : headers\openvr_capi.h:779 */ - public static final int EVRInitError_VRInitError_Init_HmdNotFound = 108; - /** native declaration : headers\openvr_capi.h:780 */ - public static final int EVRInitError_VRInitError_Init_NotInitialized = 109; - /** native declaration : headers\openvr_capi.h:781 */ - public static final int EVRInitError_VRInitError_Init_PathRegistryNotFound = 110; - /** native declaration : headers\openvr_capi.h:782 */ - public static final int EVRInitError_VRInitError_Init_NoConfigPath = 111; - /** native declaration : headers\openvr_capi.h:783 */ - public static final int EVRInitError_VRInitError_Init_NoLogPath = 112; - /** native declaration : headers\openvr_capi.h:784 */ - public static final int EVRInitError_VRInitError_Init_PathRegistryNotWritable = 113; - /** native declaration : headers\openvr_capi.h:785 */ - public static final int EVRInitError_VRInitError_Init_AppInfoInitFailed = 114; - /** native declaration : headers\openvr_capi.h:786 */ - public static final int EVRInitError_VRInitError_Init_Retry = 115; - /** native declaration : headers\openvr_capi.h:787 */ - public static final int EVRInitError_VRInitError_Init_InitCanceledByUser = 116; - /** native declaration : headers\openvr_capi.h:788 */ - public static final int EVRInitError_VRInitError_Init_AnotherAppLaunching = 117; - /** native declaration : headers\openvr_capi.h:789 */ - public static final int EVRInitError_VRInitError_Init_SettingsInitFailed = 118; - /** native declaration : headers\openvr_capi.h:790 */ - public static final int EVRInitError_VRInitError_Init_ShuttingDown = 119; - /** native declaration : headers\openvr_capi.h:791 */ - public static final int EVRInitError_VRInitError_Init_TooManyObjects = 120; - /** native declaration : headers\openvr_capi.h:792 */ - public static final int EVRInitError_VRInitError_Init_NoServerForBackgroundApp = 121; - /** native declaration : headers\openvr_capi.h:793 */ - public static final int EVRInitError_VRInitError_Init_NotSupportedWithCompositor = 122; - /** native declaration : headers\openvr_capi.h:794 */ - public static final int EVRInitError_VRInitError_Init_NotAvailableToUtilityApps = 123; - /** native declaration : headers\openvr_capi.h:795 */ - public static final int EVRInitError_VRInitError_Init_Internal = 124; - /** native declaration : headers\openvr_capi.h:796 */ - public static final int EVRInitError_VRInitError_Init_HmdDriverIdIsNone = 125; - /** native declaration : headers\openvr_capi.h:797 */ - public static final int EVRInitError_VRInitError_Init_HmdNotFoundPresenceFailed = 126; - /** native declaration : headers\openvr_capi.h:798 */ - public static final int EVRInitError_VRInitError_Init_VRMonitorNotFound = 127; - /** native declaration : headers\openvr_capi.h:799 */ - public static final int EVRInitError_VRInitError_Init_VRMonitorStartupFailed = 128; - /** native declaration : headers\openvr_capi.h:800 */ - public static final int EVRInitError_VRInitError_Init_LowPowerWatchdogNotSupported = 129; - /** native declaration : headers\openvr_capi.h:801 */ - public static final int EVRInitError_VRInitError_Init_InvalidApplicationType = 130; - /** native declaration : headers\openvr_capi.h:802 */ - public static final int EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps = 131; - /** native declaration : headers\openvr_capi.h:803 */ - public static final int EVRInitError_VRInitError_Init_WatchdogDisabledInSettings = 132; - /** native declaration : headers\openvr_capi.h:804 */ - public static final int EVRInitError_VRInitError_Init_VRDashboardNotFound = 133; - /** native declaration : headers\openvr_capi.h:805 */ - public static final int EVRInitError_VRInitError_Init_VRDashboardStartupFailed = 134; - /** native declaration : headers\openvr_capi.h:806 */ - public static final int EVRInitError_VRInitError_Init_VRHomeNotFound = 135; - /** native declaration : headers\openvr_capi.h:807 */ - public static final int EVRInitError_VRInitError_Init_VRHomeStartupFailed = 136; - /** native declaration : headers\openvr_capi.h:808 */ - public static final int EVRInitError_VRInitError_Init_RebootingBusy = 137; - /** native declaration : headers\openvr_capi.h:809 */ - public static final int EVRInitError_VRInitError_Init_FirmwareUpdateBusy = 138; - /** native declaration : headers\openvr_capi.h:810 */ - public static final int EVRInitError_VRInitError_Init_FirmwareRecoveryBusy = 139; - /** native declaration : headers\openvr_capi.h:811 */ - public static final int EVRInitError_VRInitError_Init_USBServiceBusy = 140; - /** native declaration : headers\openvr_capi.h:812 */ - public static final int EVRInitError_VRInitError_Init_VRWebHelperStartupFailed = 141; - /** native declaration : headers\openvr_capi.h:813 */ - public static final int EVRInitError_VRInitError_Init_TrackerManagerInitFailed = 142; - /** native declaration : headers\openvr_capi.h:814 */ - public static final int EVRInitError_VRInitError_Driver_Failed = 200; - /** native declaration : headers\openvr_capi.h:815 */ - public static final int EVRInitError_VRInitError_Driver_Unknown = 201; - /** native declaration : headers\openvr_capi.h:816 */ - public static final int EVRInitError_VRInitError_Driver_HmdUnknown = 202; - /** native declaration : headers\openvr_capi.h:817 */ - public static final int EVRInitError_VRInitError_Driver_NotLoaded = 203; - /** native declaration : headers\openvr_capi.h:818 */ - public static final int EVRInitError_VRInitError_Driver_RuntimeOutOfDate = 204; - /** native declaration : headers\openvr_capi.h:819 */ - public static final int EVRInitError_VRInitError_Driver_HmdInUse = 205; - /** native declaration : headers\openvr_capi.h:820 */ - public static final int EVRInitError_VRInitError_Driver_NotCalibrated = 206; - /** native declaration : headers\openvr_capi.h:821 */ - public static final int EVRInitError_VRInitError_Driver_CalibrationInvalid = 207; - /** native declaration : headers\openvr_capi.h:822 */ - public static final int EVRInitError_VRInitError_Driver_HmdDisplayNotFound = 208; - /** native declaration : headers\openvr_capi.h:823 */ - public static final int EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209; - /** native declaration : headers\openvr_capi.h:824 */ - public static final int EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds = 211; - /** native declaration : headers\openvr_capi.h:825 */ - public static final int EVRInitError_VRInitError_Driver_HmdDisplayMirrored = 212; - /** native declaration : headers\openvr_capi.h:826 */ - public static final int EVRInitError_VRInitError_IPC_ServerInitFailed = 300; - /** native declaration : headers\openvr_capi.h:827 */ - public static final int EVRInitError_VRInitError_IPC_ConnectFailed = 301; - /** native declaration : headers\openvr_capi.h:828 */ - public static final int EVRInitError_VRInitError_IPC_SharedStateInitFailed = 302; - /** native declaration : headers\openvr_capi.h:829 */ - public static final int EVRInitError_VRInitError_IPC_CompositorInitFailed = 303; - /** native declaration : headers\openvr_capi.h:830 */ - public static final int EVRInitError_VRInitError_IPC_MutexInitFailed = 304; - /** native declaration : headers\openvr_capi.h:831 */ - public static final int EVRInitError_VRInitError_IPC_Failed = 305; - /** native declaration : headers\openvr_capi.h:832 */ - public static final int EVRInitError_VRInitError_IPC_CompositorConnectFailed = 306; - /** native declaration : headers\openvr_capi.h:833 */ - public static final int EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse = 307; - /** native declaration : headers\openvr_capi.h:834 */ - public static final int EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308; - /** native declaration : headers\openvr_capi.h:835 */ - public static final int EVRInitError_VRInitError_Compositor_Failed = 400; - /** native declaration : headers\openvr_capi.h:836 */ - public static final int EVRInitError_VRInitError_Compositor_D3D11HardwareRequired = 401; - /** native declaration : headers\openvr_capi.h:837 */ - public static final int EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate = 402; - /** native declaration : headers\openvr_capi.h:838 */ - public static final int EVRInitError_VRInitError_Compositor_OverlayInitFailed = 403; - /** native declaration : headers\openvr_capi.h:839 */ - public static final int EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed = 404; - /** native declaration : headers\openvr_capi.h:840 */ - public static final int EVRInitError_VRInitError_Compositor_UnableToCreateDevice = 405; - /** native declaration : headers\openvr_capi.h:841 */ - public static final int EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000; - /** native declaration : headers\openvr_capi.h:842 */ - public static final int EVRInitError_VRInitError_VendorSpecific_WindowsNotInDevMode = 1001; - /** native declaration : headers\openvr_capi.h:843 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101; - /** native declaration : headers\openvr_capi.h:844 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102; - /** native declaration : headers\openvr_capi.h:845 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103; - /** native declaration : headers\openvr_capi.h:846 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104; - /** native declaration : headers\openvr_capi.h:847 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105; - /** native declaration : headers\openvr_capi.h:848 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106; - /** native declaration : headers\openvr_capi.h:849 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107; - /** native declaration : headers\openvr_capi.h:850 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108; - /** native declaration : headers\openvr_capi.h:851 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109; - /** native declaration : headers\openvr_capi.h:852 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110; - /** native declaration : headers\openvr_capi.h:853 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111; - /** native declaration : headers\openvr_capi.h:854 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError = 1112; - /** native declaration : headers\openvr_capi.h:855 */ - public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113; - /** native declaration : headers\openvr_capi.h:856 */ - public static final int EVRInitError_VRInitError_Steam_SteamInstallationNotFound = 2000; - }; - /** - * native declaration : headers\openvr_capi.h:865
        - * enum values - */ - public static interface EVRScreenshotType { - /** native declaration : headers\openvr_capi.h:859 */ - public static final int EVRScreenshotType_VRScreenshotType_None = 0; - /** native declaration : headers\openvr_capi.h:860 */ - public static final int EVRScreenshotType_VRScreenshotType_Mono = 1; - /** native declaration : headers\openvr_capi.h:861 */ - public static final int EVRScreenshotType_VRScreenshotType_Stereo = 2; - /** native declaration : headers\openvr_capi.h:862 */ - public static final int EVRScreenshotType_VRScreenshotType_Cubemap = 3; - /** native declaration : headers\openvr_capi.h:863 */ - public static final int EVRScreenshotType_VRScreenshotType_MonoPanorama = 4; - /** native declaration : headers\openvr_capi.h:864 */ - public static final int EVRScreenshotType_VRScreenshotType_StereoPanorama = 5; - }; - /** - * native declaration : headers\openvr_capi.h:869
        - * enum values - */ - public static interface EVRScreenshotPropertyFilenames { - /** native declaration : headers\openvr_capi.h:867 */ - public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_Preview = 0; - /** native declaration : headers\openvr_capi.h:868 */ - public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_VR = 1; - }; - /** - * native declaration : headers\openvr_capi.h:888
        - * enum values - */ - public static interface EVRTrackedCameraError { - /** native declaration : headers\openvr_capi.h:871 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_None = 0; - /** native declaration : headers\openvr_capi.h:872 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_OperationFailed = 100; - /** native declaration : headers\openvr_capi.h:873 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidHandle = 101; - /** native declaration : headers\openvr_capi.h:874 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameHeaderVersion = 102; - /** native declaration : headers\openvr_capi.h:875 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_OutOfHandles = 103; - /** native declaration : headers\openvr_capi.h:876 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_IPCFailure = 104; - /** native declaration : headers\openvr_capi.h:877 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_NotSupportedForThisDevice = 105; - /** native declaration : headers\openvr_capi.h:878 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedMemoryFailure = 106; - /** native declaration : headers\openvr_capi.h:879 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_FrameBufferingFailure = 107; - /** native declaration : headers\openvr_capi.h:880 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_StreamSetupFailure = 108; - /** native declaration : headers\openvr_capi.h:881 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidGLTextureId = 109; - /** native declaration : headers\openvr_capi.h:882 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidSharedTextureHandle = 110; - /** native declaration : headers\openvr_capi.h:883 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_FailedToGetGLTextureId = 111; - /** native declaration : headers\openvr_capi.h:884 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedTextureFailure = 112; - /** native declaration : headers\openvr_capi.h:885 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_NoFrameAvailable = 113; - /** native declaration : headers\openvr_capi.h:886 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidArgument = 114; - /** native declaration : headers\openvr_capi.h:887 */ - public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameBufferSize = 115; - }; - /** - * native declaration : headers\openvr_capi.h:894
        - * enum values - */ - public static interface EVRTrackedCameraFrameLayout { - /** native declaration : headers\openvr_capi.h:890 */ - public static final int EVRTrackedCameraFrameLayout_Mono = 1; - /** native declaration : headers\openvr_capi.h:891 */ - public static final int EVRTrackedCameraFrameLayout_Stereo = 2; - /** native declaration : headers\openvr_capi.h:892 */ - public static final int EVRTrackedCameraFrameLayout_VerticalLayout = 16; - /** native declaration : headers\openvr_capi.h:893 */ - public static final int EVRTrackedCameraFrameLayout_HorizontalLayout = 32; - }; - /** - * native declaration : headers\openvr_capi.h:900
        - * enum values - */ - public static interface EVRTrackedCameraFrameType { - /** native declaration : headers\openvr_capi.h:896 */ - public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Distorted = 0; - /** native declaration : headers\openvr_capi.h:897 */ - public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Undistorted = 1; - /** native declaration : headers\openvr_capi.h:898 */ - public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_MaximumUndistorted = 2; - /** native declaration : headers\openvr_capi.h:899 */ - public static final int EVRTrackedCameraFrameType_MAX_CAMERA_FRAME_TYPES = 3; - }; - /** - * native declaration : headers\openvr_capi.h:905
        - * enum values - */ - public static interface EVSync { - /** native declaration : headers\openvr_capi.h:902 */ - public static final int EVSync_VSync_None = 0; - /** native declaration : headers\openvr_capi.h:903 */ - public static final int EVSync_VSync_WaitRender = 1; - /** native declaration : headers\openvr_capi.h:904 */ - public static final int EVSync_VSync_NoWaitRender = 2; - }; - /** - * native declaration : headers\openvr_capi.h:909
        - * enum values - */ - public static interface EVRMuraCorrectionMode { - /** native declaration : headers\openvr_capi.h:907 */ - public static final int EVRMuraCorrectionMode_Default = 0; - /** native declaration : headers\openvr_capi.h:908 */ - public static final int EVRMuraCorrectionMode_NoCorrection = 1; - }; - /** - * native declaration : headers\openvr_capi.h:917
        - * enum values - */ - public static interface Imu_OffScaleFlags { - /** native declaration : headers\openvr_capi.h:911 */ - public static final int Imu_OffScaleFlags_OffScale_AccelX = 1; - /** native declaration : headers\openvr_capi.h:912 */ - public static final int Imu_OffScaleFlags_OffScale_AccelY = 2; - /** native declaration : headers\openvr_capi.h:913 */ - public static final int Imu_OffScaleFlags_OffScale_AccelZ = 4; - /** native declaration : headers\openvr_capi.h:914 */ - public static final int Imu_OffScaleFlags_OffScale_GyroX = 8; - /** native declaration : headers\openvr_capi.h:915 */ - public static final int Imu_OffScaleFlags_OffScale_GyroY = 16; - /** native declaration : headers\openvr_capi.h:916 */ - public static final int Imu_OffScaleFlags_OffScale_GyroZ = 32; - }; - /** - * native declaration : headers\openvr_capi.h:940
        - * enum values - */ - public static interface EVRApplicationError { - /** native declaration : headers\openvr_capi.h:919 */ - public static final int EVRApplicationError_VRApplicationError_None = 0; - /** native declaration : headers\openvr_capi.h:920 */ - public static final int EVRApplicationError_VRApplicationError_AppKeyAlreadyExists = 100; - /** native declaration : headers\openvr_capi.h:921 */ - public static final int EVRApplicationError_VRApplicationError_NoManifest = 101; - /** native declaration : headers\openvr_capi.h:922 */ - public static final int EVRApplicationError_VRApplicationError_NoApplication = 102; - /** native declaration : headers\openvr_capi.h:923 */ - public static final int EVRApplicationError_VRApplicationError_InvalidIndex = 103; - /** native declaration : headers\openvr_capi.h:924 */ - public static final int EVRApplicationError_VRApplicationError_UnknownApplication = 104; - /** native declaration : headers\openvr_capi.h:925 */ - public static final int EVRApplicationError_VRApplicationError_IPCFailed = 105; - /** native declaration : headers\openvr_capi.h:926 */ - public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyRunning = 106; - /** native declaration : headers\openvr_capi.h:927 */ - public static final int EVRApplicationError_VRApplicationError_InvalidManifest = 107; - /** native declaration : headers\openvr_capi.h:928 */ - public static final int EVRApplicationError_VRApplicationError_InvalidApplication = 108; - /** native declaration : headers\openvr_capi.h:929 */ - public static final int EVRApplicationError_VRApplicationError_LaunchFailed = 109; - /** native declaration : headers\openvr_capi.h:930 */ - public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyStarting = 110; - /** native declaration : headers\openvr_capi.h:931 */ - public static final int EVRApplicationError_VRApplicationError_LaunchInProgress = 111; - /** native declaration : headers\openvr_capi.h:932 */ - public static final int EVRApplicationError_VRApplicationError_OldApplicationQuitting = 112; - /** native declaration : headers\openvr_capi.h:933 */ - public static final int EVRApplicationError_VRApplicationError_TransitionAborted = 113; - /** native declaration : headers\openvr_capi.h:934 */ - public static final int EVRApplicationError_VRApplicationError_IsTemplate = 114; - /** native declaration : headers\openvr_capi.h:935 */ - public static final int EVRApplicationError_VRApplicationError_SteamVRIsExiting = 115; - /** native declaration : headers\openvr_capi.h:936 */ - public static final int EVRApplicationError_VRApplicationError_BufferTooSmall = 200; - /** native declaration : headers\openvr_capi.h:937 */ - public static final int EVRApplicationError_VRApplicationError_PropertyNotSet = 201; - /** native declaration : headers\openvr_capi.h:938 */ - public static final int EVRApplicationError_VRApplicationError_UnknownProperty = 202; - /** native declaration : headers\openvr_capi.h:939 */ - public static final int EVRApplicationError_VRApplicationError_InvalidParameter = 203; - }; - /** - * native declaration : headers\openvr_capi.h:959
        - * enum values - */ - public static interface EVRApplicationProperty { - /** native declaration : headers\openvr_capi.h:942 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Name_String = 0; - /** native declaration : headers\openvr_capi.h:943 */ - public static final int EVRApplicationProperty_VRApplicationProperty_LaunchType_String = 11; - /** native declaration : headers\openvr_capi.h:944 */ - public static final int EVRApplicationProperty_VRApplicationProperty_WorkingDirectory_String = 12; - /** native declaration : headers\openvr_capi.h:945 */ - public static final int EVRApplicationProperty_VRApplicationProperty_BinaryPath_String = 13; - /** native declaration : headers\openvr_capi.h:946 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Arguments_String = 14; - /** native declaration : headers\openvr_capi.h:947 */ - public static final int EVRApplicationProperty_VRApplicationProperty_URL_String = 15; - /** native declaration : headers\openvr_capi.h:948 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Description_String = 50; - /** native declaration : headers\openvr_capi.h:949 */ - public static final int EVRApplicationProperty_VRApplicationProperty_NewsURL_String = 51; - /** native declaration : headers\openvr_capi.h:950 */ - public static final int EVRApplicationProperty_VRApplicationProperty_ImagePath_String = 52; - /** native declaration : headers\openvr_capi.h:951 */ - public static final int EVRApplicationProperty_VRApplicationProperty_Source_String = 53; - /** native declaration : headers\openvr_capi.h:952 */ - public static final int EVRApplicationProperty_VRApplicationProperty_ActionManifestURL_String = 54; - /** native declaration : headers\openvr_capi.h:953 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsDashboardOverlay_Bool = 60; - /** native declaration : headers\openvr_capi.h:954 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsTemplate_Bool = 61; - /** native declaration : headers\openvr_capi.h:955 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsInstanced_Bool = 62; - /** native declaration : headers\openvr_capi.h:956 */ - public static final int EVRApplicationProperty_VRApplicationProperty_IsInternal_Bool = 63; - /** native declaration : headers\openvr_capi.h:957 */ - public static final int EVRApplicationProperty_VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64; - /** native declaration : headers\openvr_capi.h:958 */ - public static final int EVRApplicationProperty_VRApplicationProperty_LastLaunchTime_Uint64 = 70; - }; - /** - * native declaration : headers\openvr_capi.h:965
        - * enum values - */ - public static interface EVRApplicationTransitionState { - /** native declaration : headers\openvr_capi.h:961 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_None = 0; - /** native declaration : headers\openvr_capi.h:962 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_OldAppQuitSent = 10; - /** native declaration : headers\openvr_capi.h:963 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_WaitingForExternalLaunch = 11; - /** native declaration : headers\openvr_capi.h:964 */ - public static final int EVRApplicationTransitionState_VRApplicationTransition_NewAppLaunched = 20; - }; - /** - * native declaration : headers\openvr_capi.h:977
        - * enum values - */ - public static interface ChaperoneCalibrationState { - /** native declaration : headers\openvr_capi.h:967 */ - public static final int ChaperoneCalibrationState_OK = 1; - /** native declaration : headers\openvr_capi.h:968 */ - public static final int ChaperoneCalibrationState_Warning = 100; - /** native declaration : headers\openvr_capi.h:969 */ - public static final int ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101; - /** native declaration : headers\openvr_capi.h:970 */ - public static final int ChaperoneCalibrationState_Warning_BaseStationRemoved = 102; - /** native declaration : headers\openvr_capi.h:971 */ - public static final int ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103; - /** native declaration : headers\openvr_capi.h:972 */ - public static final int ChaperoneCalibrationState_Error = 200; - /** native declaration : headers\openvr_capi.h:973 */ - public static final int ChaperoneCalibrationState_Error_BaseStationUninitialized = 201; - /** native declaration : headers\openvr_capi.h:974 */ - public static final int ChaperoneCalibrationState_Error_BaseStationConflict = 202; - /** native declaration : headers\openvr_capi.h:975 */ - public static final int ChaperoneCalibrationState_Error_PlayAreaInvalid = 203; - /** native declaration : headers\openvr_capi.h:976 */ - public static final int ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204; - }; - /** - * native declaration : headers\openvr_capi.h:981
        - * enum values - */ - public static interface EChaperoneConfigFile { - /** native declaration : headers\openvr_capi.h:979 */ - public static final int EChaperoneConfigFile_Live = 1; - /** native declaration : headers\openvr_capi.h:980 */ - public static final int EChaperoneConfigFile_Temp = 2; - }; - /** - * native declaration : headers\openvr_capi.h:984
        - * enum values - */ - public static interface EChaperoneImportFlags { - /** native declaration : headers\openvr_capi.h:983 */ - public static final int EChaperoneImportFlags_EChaperoneImport_BoundsOnly = 1; - }; - /** - * native declaration : headers\openvr_capi.h:998
        - * enum values - */ - public static interface EVRCompositorError { - /** native declaration : headers\openvr_capi.h:986 */ - public static final int EVRCompositorError_VRCompositorError_None = 0; - /** native declaration : headers\openvr_capi.h:987 */ - public static final int EVRCompositorError_VRCompositorError_RequestFailed = 1; - /** native declaration : headers\openvr_capi.h:988 */ - public static final int EVRCompositorError_VRCompositorError_IncompatibleVersion = 100; - /** native declaration : headers\openvr_capi.h:989 */ - public static final int EVRCompositorError_VRCompositorError_DoNotHaveFocus = 101; - /** native declaration : headers\openvr_capi.h:990 */ - public static final int EVRCompositorError_VRCompositorError_InvalidTexture = 102; - /** native declaration : headers\openvr_capi.h:991 */ - public static final int EVRCompositorError_VRCompositorError_IsNotSceneApplication = 103; - /** native declaration : headers\openvr_capi.h:992 */ - public static final int EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice = 104; - /** native declaration : headers\openvr_capi.h:993 */ - public static final int EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat = 105; - /** native declaration : headers\openvr_capi.h:994 */ - public static final int EVRCompositorError_VRCompositorError_SharedTexturesNotSupported = 106; - /** native declaration : headers\openvr_capi.h:995 */ - public static final int EVRCompositorError_VRCompositorError_IndexOutOfRange = 107; - /** native declaration : headers\openvr_capi.h:996 */ - public static final int EVRCompositorError_VRCompositorError_AlreadySubmitted = 108; - /** native declaration : headers\openvr_capi.h:997 */ - public static final int EVRCompositorError_VRCompositorError_InvalidBounds = 109; - }; - /** - * native declaration : headers\openvr_capi.h:1003
        - * enum values - */ - public static interface EVRCompositorTimingMode { - /** native declaration : headers\openvr_capi.h:1000 */ - public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Implicit = 0; - /** native declaration : headers\openvr_capi.h:1001 */ - public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1; - /** native declaration : headers\openvr_capi.h:1002 */ - public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1008
        - * enum values - */ - public static interface VROverlayInputMethod { - /** native declaration : headers\openvr_capi.h:1005 */ - public static final int VROverlayInputMethod_None = 0; - /** native declaration : headers\openvr_capi.h:1006 */ - public static final int VROverlayInputMethod_Mouse = 1; - /** native declaration : headers\openvr_capi.h:1007 */ - public static final int VROverlayInputMethod_DualAnalog = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1014
        - * enum values - */ - public static interface VROverlayTransformType { - /** native declaration : headers\openvr_capi.h:1010 */ - public static final int VROverlayTransformType_VROverlayTransform_Absolute = 0; - /** native declaration : headers\openvr_capi.h:1011 */ - public static final int VROverlayTransformType_VROverlayTransform_TrackedDeviceRelative = 1; - /** native declaration : headers\openvr_capi.h:1012 */ - public static final int VROverlayTransformType_VROverlayTransform_SystemOverlay = 2; - /** native declaration : headers\openvr_capi.h:1013 */ - public static final int VROverlayTransformType_VROverlayTransform_TrackedComponent = 3; - }; - /** - * native declaration : headers\openvr_capi.h:1032
        - * enum values - */ - public static interface VROverlayFlags { - /** native declaration : headers\openvr_capi.h:1016 */ - public static final int VROverlayFlags_None = 0; - /** native declaration : headers\openvr_capi.h:1017 */ - public static final int VROverlayFlags_Curved = 1; - /** native declaration : headers\openvr_capi.h:1018 */ - public static final int VROverlayFlags_RGSS4X = 2; - /** native declaration : headers\openvr_capi.h:1019 */ - public static final int VROverlayFlags_NoDashboardTab = 3; - /** native declaration : headers\openvr_capi.h:1020 */ - public static final int VROverlayFlags_AcceptsGamepadEvents = 4; - /** native declaration : headers\openvr_capi.h:1021 */ - public static final int VROverlayFlags_ShowGamepadFocus = 5; - /** native declaration : headers\openvr_capi.h:1022 */ - public static final int VROverlayFlags_SendVRScrollEvents = 6; - /** native declaration : headers\openvr_capi.h:1023 */ - public static final int VROverlayFlags_SendVRTouchpadEvents = 7; - /** native declaration : headers\openvr_capi.h:1024 */ - public static final int VROverlayFlags_ShowTouchPadScrollWheel = 8; - /** native declaration : headers\openvr_capi.h:1025 */ - public static final int VROverlayFlags_TransferOwnershipToInternalProcess = 9; - /** native declaration : headers\openvr_capi.h:1026 */ - public static final int VROverlayFlags_SideBySide_Parallel = 10; - /** native declaration : headers\openvr_capi.h:1027 */ - public static final int VROverlayFlags_SideBySide_Crossed = 11; - /** native declaration : headers\openvr_capi.h:1028 */ - public static final int VROverlayFlags_Panorama = 12; - /** native declaration : headers\openvr_capi.h:1029 */ - public static final int VROverlayFlags_StereoPanorama = 13; - /** native declaration : headers\openvr_capi.h:1030 */ - public static final int VROverlayFlags_SortWithNonSceneOverlays = 14; - /** native declaration : headers\openvr_capi.h:1031 */ - public static final int VROverlayFlags_VisibleInDashboard = 15; - }; - /** - * native declaration : headers\openvr_capi.h:1041
        - * enum values - */ - public static interface VRMessageOverlayResponse { - /** native declaration : headers\openvr_capi.h:1034 */ - public static final int VRMessageOverlayResponse_ButtonPress_0 = 0; - /** native declaration : headers\openvr_capi.h:1035 */ - public static final int VRMessageOverlayResponse_ButtonPress_1 = 1; - /** native declaration : headers\openvr_capi.h:1036 */ - public static final int VRMessageOverlayResponse_ButtonPress_2 = 2; - /** native declaration : headers\openvr_capi.h:1037 */ - public static final int VRMessageOverlayResponse_ButtonPress_3 = 3; - /** native declaration : headers\openvr_capi.h:1038 */ - public static final int VRMessageOverlayResponse_CouldntFindSystemOverlay = 4; - /** native declaration : headers\openvr_capi.h:1039 */ - public static final int VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5; - /** native declaration : headers\openvr_capi.h:1040 */ - public static final int VRMessageOverlayResponse_ApplicationQuit = 6; - }; - /** - * native declaration : headers\openvr_capi.h:1046
        - * enum values - */ - public static interface EGamepadTextInputMode { - /** native declaration : headers\openvr_capi.h:1043 */ - public static final int EGamepadTextInputMode_k_EGamepadTextInputModeNormal = 0; - /** native declaration : headers\openvr_capi.h:1044 */ - public static final int EGamepadTextInputMode_k_EGamepadTextInputModePassword = 1; - /** native declaration : headers\openvr_capi.h:1045 */ - public static final int EGamepadTextInputMode_k_EGamepadTextInputModeSubmit = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1050
        - * enum values - */ - public static interface EGamepadTextInputLineMode { - /** native declaration : headers\openvr_capi.h:1048 */ - public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeSingleLine = 0; - /** native declaration : headers\openvr_capi.h:1049 */ - public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeMultipleLines = 1; - }; - /** - * native declaration : headers\openvr_capi.h:1057
        - * enum values - */ - public static interface EOverlayDirection { - /** native declaration : headers\openvr_capi.h:1052 */ - public static final int EOverlayDirection_OverlayDirection_Up = 0; - /** native declaration : headers\openvr_capi.h:1053 */ - public static final int EOverlayDirection_OverlayDirection_Down = 1; - /** native declaration : headers\openvr_capi.h:1054 */ - public static final int EOverlayDirection_OverlayDirection_Left = 2; - /** native declaration : headers\openvr_capi.h:1055 */ - public static final int EOverlayDirection_OverlayDirection_Right = 3; - /** native declaration : headers\openvr_capi.h:1056 */ - public static final int EOverlayDirection_OverlayDirection_Count = 4; - }; - /** - * native declaration : headers\openvr_capi.h:1061
        - * enum values - */ - public static interface EVROverlayIntersectionMaskPrimitiveType { - /** native declaration : headers\openvr_capi.h:1059 */ - public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Rectangle = 0; - /** native declaration : headers\openvr_capi.h:1060 */ - public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Circle = 1; - }; - /** - * native declaration : headers\openvr_capi.h:1076
        - * enum values - */ - public static interface EVRRenderModelError { - /** native declaration : headers\openvr_capi.h:1063 */ - public static final int EVRRenderModelError_VRRenderModelError_None = 0; - /** native declaration : headers\openvr_capi.h:1064 */ - public static final int EVRRenderModelError_VRRenderModelError_Loading = 100; - /** native declaration : headers\openvr_capi.h:1065 */ - public static final int EVRRenderModelError_VRRenderModelError_NotSupported = 200; - /** native declaration : headers\openvr_capi.h:1066 */ - public static final int EVRRenderModelError_VRRenderModelError_InvalidArg = 300; - /** native declaration : headers\openvr_capi.h:1067 */ - public static final int EVRRenderModelError_VRRenderModelError_InvalidModel = 301; - /** native declaration : headers\openvr_capi.h:1068 */ - public static final int EVRRenderModelError_VRRenderModelError_NoShapes = 302; - /** native declaration : headers\openvr_capi.h:1069 */ - public static final int EVRRenderModelError_VRRenderModelError_MultipleShapes = 303; - /** native declaration : headers\openvr_capi.h:1070 */ - public static final int EVRRenderModelError_VRRenderModelError_TooManyVertices = 304; - /** native declaration : headers\openvr_capi.h:1071 */ - public static final int EVRRenderModelError_VRRenderModelError_MultipleTextures = 305; - /** native declaration : headers\openvr_capi.h:1072 */ - public static final int EVRRenderModelError_VRRenderModelError_BufferTooSmall = 306; - /** native declaration : headers\openvr_capi.h:1073 */ - public static final int EVRRenderModelError_VRRenderModelError_NotEnoughNormals = 307; - /** native declaration : headers\openvr_capi.h:1074 */ - public static final int EVRRenderModelError_VRRenderModelError_NotEnoughTexCoords = 308; - /** native declaration : headers\openvr_capi.h:1075 */ - public static final int EVRRenderModelError_VRRenderModelError_InvalidTexture = 400; - }; - /** - * native declaration : headers\openvr_capi.h:1083
        - * enum values - */ - public static interface EVRComponentProperty { - /** native declaration : headers\openvr_capi.h:1078 */ - public static final int EVRComponentProperty_VRComponentProperty_IsStatic = 1; - /** native declaration : headers\openvr_capi.h:1079 */ - public static final int EVRComponentProperty_VRComponentProperty_IsVisible = 2; - /** native declaration : headers\openvr_capi.h:1080 */ - public static final int EVRComponentProperty_VRComponentProperty_IsTouched = 4; - /** native declaration : headers\openvr_capi.h:1081 */ - public static final int EVRComponentProperty_VRComponentProperty_IsPressed = 8; - /** native declaration : headers\openvr_capi.h:1082 */ - public static final int EVRComponentProperty_VRComponentProperty_IsScrolled = 16; - }; - /** - * native declaration : headers\openvr_capi.h:1088
        - * enum values - */ - public static interface EVRNotificationType { - /** native declaration : headers\openvr_capi.h:1085 */ - public static final int EVRNotificationType_Transient = 0; - /** native declaration : headers\openvr_capi.h:1086 */ - public static final int EVRNotificationType_Persistent = 1; - /** native declaration : headers\openvr_capi.h:1087 */ - public static final int EVRNotificationType_Transient_SystemWithUserValue = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1095
        - * enum values - */ - public static interface EVRNotificationStyle { - /** native declaration : headers\openvr_capi.h:1090 */ - public static final int EVRNotificationStyle_None = 0; - /** native declaration : headers\openvr_capi.h:1091 */ - public static final int EVRNotificationStyle_Application = 100; - /** native declaration : headers\openvr_capi.h:1092 */ - public static final int EVRNotificationStyle_Contact_Disabled = 200; - /** native declaration : headers\openvr_capi.h:1093 */ - public static final int EVRNotificationStyle_Contact_Enabled = 201; - /** native declaration : headers\openvr_capi.h:1094 */ - public static final int EVRNotificationStyle_Contact_Active = 202; - }; - /** - * native declaration : headers\openvr_capi.h:1103
        - * enum values - */ - public static interface EVRSettingsError { - /** native declaration : headers\openvr_capi.h:1097 */ - public static final int EVRSettingsError_VRSettingsError_None = 0; - /** native declaration : headers\openvr_capi.h:1098 */ - public static final int EVRSettingsError_VRSettingsError_IPCFailed = 1; - /** native declaration : headers\openvr_capi.h:1099 */ - public static final int EVRSettingsError_VRSettingsError_WriteFailed = 2; - /** native declaration : headers\openvr_capi.h:1100 */ - public static final int EVRSettingsError_VRSettingsError_ReadFailed = 3; - /** native declaration : headers\openvr_capi.h:1101 */ - public static final int EVRSettingsError_VRSettingsError_JsonParseFailed = 4; - /** native declaration : headers\openvr_capi.h:1102 */ - public static final int EVRSettingsError_VRSettingsError_UnsetSettingHasNoDefault = 5; - }; - /** - * native declaration : headers\openvr_capi.h:1111
        - * enum values - */ - public static interface EVRScreenshotError { - /** native declaration : headers\openvr_capi.h:1105 */ - public static final int EVRScreenshotError_VRScreenshotError_None = 0; - /** native declaration : headers\openvr_capi.h:1106 */ - public static final int EVRScreenshotError_VRScreenshotError_RequestFailed = 1; - /** native declaration : headers\openvr_capi.h:1107 */ - public static final int EVRScreenshotError_VRScreenshotError_IncompatibleVersion = 100; - /** native declaration : headers\openvr_capi.h:1108 */ - public static final int EVRScreenshotError_VRScreenshotError_NotFound = 101; - /** native declaration : headers\openvr_capi.h:1109 */ - public static final int EVRScreenshotError_VRScreenshotError_BufferTooSmall = 102; - /** native declaration : headers\openvr_capi.h:1110 */ - public static final int EVRScreenshotError_VRScreenshotError_ScreenshotAlreadyInProgress = 108; - }; - /** - * native declaration : headers\openvr_capi.h:1116
        - * enum values - */ - public static interface EVRSkeletalTransformSpace { - /** native declaration : headers\openvr_capi.h:1113 */ - public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Model = 0; - /** native declaration : headers\openvr_capi.h:1114 */ - public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Parent = 1; - /** native declaration : headers\openvr_capi.h:1115 */ - public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Additive = 2; - }; - /** - * native declaration : headers\openvr_capi.h:1120
        - * enum values - */ - public static interface EVRInputFilterCancelType { - /** native declaration : headers\openvr_capi.h:1118 */ - public static final int EVRInputFilterCancelType_VRInputFilterCancel_Timers = 0; - /** native declaration : headers\openvr_capi.h:1119 */ - public static final int EVRInputFilterCancelType_VRInputFilterCancel_Momentum = 1; - }; - /** - * native declaration : headers\openvr_capi.h:1129
        - * enum values - */ - public static interface EIOBufferError { - /** native declaration : headers\openvr_capi.h:1122 */ - public static final int EIOBufferError_IOBuffer_Success = 0; - /** native declaration : headers\openvr_capi.h:1123 */ - public static final int EIOBufferError_IOBuffer_OperationFailed = 100; - /** native declaration : headers\openvr_capi.h:1124 */ - public static final int EIOBufferError_IOBuffer_InvalidHandle = 101; - /** native declaration : headers\openvr_capi.h:1125 */ - public static final int EIOBufferError_IOBuffer_InvalidArgument = 102; - /** native declaration : headers\openvr_capi.h:1126 */ - public static final int EIOBufferError_IOBuffer_PathExists = 103; - /** native declaration : headers\openvr_capi.h:1127 */ - public static final int EIOBufferError_IOBuffer_PathDoesNotExist = 104; - /** native declaration : headers\openvr_capi.h:1128 */ - public static final int EIOBufferError_IOBuffer_Permission = 105; - }; - /** - * native declaration : headers\openvr_capi.h:1134
        - * enum values - */ - public static interface EIOBufferMode { - /** native declaration : headers\openvr_capi.h:1131 */ - public static final int EIOBufferMode_IOBufferMode_Read = 1; - /** native declaration : headers\openvr_capi.h:1132 */ - public static final int EIOBufferMode_IOBufferMode_Write = 2; - /** native declaration : headers\openvr_capi.h:1133 */ - public static final int EIOBufferMode_IOBufferMode_Create = 512; - }; - /** OpenVR Constants */ - public static final long k_nDriverNone = 4294967295L; - public static final int k_unMaxDriverDebugResponseSize = 32768; - public static final int k_unTrackedDeviceIndex_Hmd = 0; - public static final int k_unMaxTrackedDeviceCount = 64; - public static final int k_unTrackedDeviceIndexOther = -2; - public static final long k_unTrackedDeviceIndexInvalid = 4294967295L; - public static final long k_ulInvalidPropertyContainer = 0; - public static final int k_unInvalidPropertyTag = 0; - public static final long k_ulInvalidDriverHandle = 0; - public static final int k_unFloatPropertyTag = 1; - public static final int k_unInt32PropertyTag = 2; - public static final int k_unUint64PropertyTag = 3; - public static final int k_unBoolPropertyTag = 4; - public static final int k_unStringPropertyTag = 5; - public static final int k_unHmdMatrix34PropertyTag = 20; - public static final int k_unHmdMatrix44PropertyTag = 21; - public static final int k_unHmdVector3PropertyTag = 22; - public static final int k_unHmdVector4PropertyTag = 23; - public static final int k_unHiddenAreaPropertyTag = 30; - public static final int k_unPathHandleInfoTag = 31; - public static final int k_unActionPropertyTag = 32; - public static final int k_unInputValuePropertyTag = 33; - public static final int k_unWildcardPropertyTag = 34; - public static final int k_unHapticVibrationPropertyTag = 35; - public static final int k_unSkeletonPropertyTag = 36; - public static final int k_unSpatialAnchorPosePropertyTag = 40; - public static final int k_unOpenVRInternalReserved_Start = 1000; - public static final int k_unOpenVRInternalReserved_End = 10000; - public static final int k_unMaxPropertyStringSize = 32768; - public static final long k_ulInvalidActionHandle = 0; - public static final long k_ulInvalidActionSetHandle = 0; - public static final long k_ulInvalidInputValueHandle = 0; - public static final int k_unControllerStateAxisCount = 5; - public static final long k_ulOverlayHandleInvalid = 0; - public static final int k_unScreenshotHandleInvalid = 0; - public static final int k_unMaxApplicationKeyLength = 128; - public static final int k_unVROverlayMaxKeyLength = 128; - public static final int k_unVROverlayMaxNameLength = 128; - public static final int k_unMaxOverlayCount = 64; - public static final int k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; - public static final int k_unNotificationTextMaxSize = 256; - public static final int k_unMaxSettingsKeyLength = 128; - public static final int k_unMaxActionNameLength = 64; - public static final int k_unMaxActionSetNameLength = 64; - public static final int k_unMaxActionOriginCount = 16; - public static final long k_ulInvalidIOBufferHandle = 0; + + /** + * native declaration : headers\openvr_capi.h:229
        + * enum values + */ + public static interface EVREye { + /** native declaration : headers\openvr_capi.h:227 */ + public static final int EVREye_Eye_Left = 0; + /** native declaration : headers\openvr_capi.h:228 */ + public static final int EVREye_Eye_Right = 1; + }; + /** + * native declaration : headers\openvr_capi.h:239
        + * enum values + */ + public static interface ETextureType { + /** native declaration : headers\openvr_capi.h:231 */ + public static final int ETextureType_TextureType_Invalid = -1; + /** native declaration : headers\openvr_capi.h:232 */ + public static final int ETextureType_TextureType_DirectX = 0; + /** native declaration : headers\openvr_capi.h:233 */ + public static final int ETextureType_TextureType_OpenGL = 1; + /** native declaration : headers\openvr_capi.h:234 */ + public static final int ETextureType_TextureType_Vulkan = 2; + /** native declaration : headers\openvr_capi.h:235 */ + public static final int ETextureType_TextureType_IOSurface = 3; + /** native declaration : headers\openvr_capi.h:236 */ + public static final int ETextureType_TextureType_DirectX12 = 4; + /** native declaration : headers\openvr_capi.h:237 */ + public static final int ETextureType_TextureType_DXGISharedHandle = 5; + /** native declaration : headers\openvr_capi.h:238 */ + public static final int ETextureType_TextureType_Metal = 6; + }; + /** + * native declaration : headers\openvr_capi.h:244
        + * enum values + */ + public static interface EColorSpace { + /** native declaration : headers\openvr_capi.h:241 */ + public static final int EColorSpace_ColorSpace_Auto = 0; + /** native declaration : headers\openvr_capi.h:242 */ + public static final int EColorSpace_ColorSpace_Gamma = 1; + /** native declaration : headers\openvr_capi.h:243 */ + public static final int EColorSpace_ColorSpace_Linear = 2; + }; + /** + * native declaration : headers\openvr_capi.h:251
        + * enum values + */ + public static interface ETrackingResult { + /** native declaration : headers\openvr_capi.h:246 */ + public static final int ETrackingResult_TrackingResult_Uninitialized = 1; + /** native declaration : headers\openvr_capi.h:247 */ + public static final int ETrackingResult_TrackingResult_Calibrating_InProgress = 100; + /** native declaration : headers\openvr_capi.h:248 */ + public static final int ETrackingResult_TrackingResult_Calibrating_OutOfRange = 101; + /** native declaration : headers\openvr_capi.h:249 */ + public static final int ETrackingResult_TrackingResult_Running_OK = 200; + /** native declaration : headers\openvr_capi.h:250 */ + public static final int ETrackingResult_TrackingResult_Running_OutOfRange = 201; + }; + /** + * native declaration : headers\openvr_capi.h:260
        + * enum values + */ + public static interface ETrackedDeviceClass { + /** native declaration : headers\openvr_capi.h:253 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_Invalid = 0; + /** native declaration : headers\openvr_capi.h:254 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_HMD = 1; + /** native declaration : headers\openvr_capi.h:255 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_Controller = 2; + /** native declaration : headers\openvr_capi.h:256 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_GenericTracker = 3; + /** native declaration : headers\openvr_capi.h:257 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_TrackingReference = 4; + /** native declaration : headers\openvr_capi.h:258 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_DisplayRedirect = 5; + /** native declaration : headers\openvr_capi.h:259 */ + public static final int ETrackedDeviceClass_TrackedDeviceClass_Max = 6; + }; + /** + * native declaration : headers\openvr_capi.h:267
        + * enum values + */ + public static interface ETrackedControllerRole { + /** native declaration : headers\openvr_capi.h:262 */ + public static final int ETrackedControllerRole_TrackedControllerRole_Invalid = 0; + /** native declaration : headers\openvr_capi.h:263 */ + public static final int ETrackedControllerRole_TrackedControllerRole_LeftHand = 1; + /** native declaration : headers\openvr_capi.h:264 */ + public static final int ETrackedControllerRole_TrackedControllerRole_RightHand = 2; + /** native declaration : headers\openvr_capi.h:265 */ + public static final int ETrackedControllerRole_TrackedControllerRole_OptOut = 3; + /** native declaration : headers\openvr_capi.h:266 */ + public static final int ETrackedControllerRole_TrackedControllerRole_Max = 4; + }; + /** + * native declaration : headers\openvr_capi.h:272
        + * enum values + */ + public static interface ETrackingUniverseOrigin { + /** native declaration : headers\openvr_capi.h:269 */ + public static final int ETrackingUniverseOrigin_TrackingUniverseSeated = 0; + /** native declaration : headers\openvr_capi.h:270 */ + public static final int ETrackingUniverseOrigin_TrackingUniverseStanding = 1; + /** native declaration : headers\openvr_capi.h:271 */ + public static final int ETrackingUniverseOrigin_TrackingUniverseRawAndUncalibrated = 2; + }; + /** + * native declaration : headers\openvr_capi.h:432
        + * enum values + */ + public static interface ETrackedDeviceProperty { + /** native declaration : headers\openvr_capi.h:274 */ + public static final int ETrackedDeviceProperty_Prop_Invalid = 0; + /** native declaration : headers\openvr_capi.h:275 */ + public static final int ETrackedDeviceProperty_Prop_TrackingSystemName_String = 1000; + /** native declaration : headers\openvr_capi.h:276 */ + public static final int ETrackedDeviceProperty_Prop_ModelNumber_String = 1001; + /** native declaration : headers\openvr_capi.h:277 */ + public static final int ETrackedDeviceProperty_Prop_SerialNumber_String = 1002; + /** native declaration : headers\openvr_capi.h:278 */ + public static final int ETrackedDeviceProperty_Prop_RenderModelName_String = 1003; + /** native declaration : headers\openvr_capi.h:279 */ + public static final int ETrackedDeviceProperty_Prop_WillDriftInYaw_Bool = 1004; + /** native declaration : headers\openvr_capi.h:280 */ + public static final int ETrackedDeviceProperty_Prop_ManufacturerName_String = 1005; + /** native declaration : headers\openvr_capi.h:281 */ + public static final int ETrackedDeviceProperty_Prop_TrackingFirmwareVersion_String = 1006; + /** native declaration : headers\openvr_capi.h:282 */ + public static final int ETrackedDeviceProperty_Prop_HardwareRevision_String = 1007; + /** native declaration : headers\openvr_capi.h:283 */ + public static final int ETrackedDeviceProperty_Prop_AllWirelessDongleDescriptions_String = 1008; + /** native declaration : headers\openvr_capi.h:284 */ + public static final int ETrackedDeviceProperty_Prop_ConnectedWirelessDongle_String = 1009; + /** native declaration : headers\openvr_capi.h:285 */ + public static final int ETrackedDeviceProperty_Prop_DeviceIsWireless_Bool = 1010; + /** native declaration : headers\openvr_capi.h:286 */ + public static final int ETrackedDeviceProperty_Prop_DeviceIsCharging_Bool = 1011; + /** native declaration : headers\openvr_capi.h:287 */ + public static final int ETrackedDeviceProperty_Prop_DeviceBatteryPercentage_Float = 1012; + /** native declaration : headers\openvr_capi.h:288 */ + public static final int ETrackedDeviceProperty_Prop_StatusDisplayTransform_Matrix34 = 1013; + /** native declaration : headers\openvr_capi.h:289 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_UpdateAvailable_Bool = 1014; + /** native declaration : headers\openvr_capi.h:290 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdate_Bool = 1015; + /** native declaration : headers\openvr_capi.h:291 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ManualUpdateURL_String = 1016; + /** native declaration : headers\openvr_capi.h:292 */ + public static final int ETrackedDeviceProperty_Prop_HardwareRevision_Uint64 = 1017; + /** native declaration : headers\openvr_capi.h:293 */ + public static final int ETrackedDeviceProperty_Prop_FirmwareVersion_Uint64 = 1018; + /** native declaration : headers\openvr_capi.h:294 */ + public static final int ETrackedDeviceProperty_Prop_FPGAVersion_Uint64 = 1019; + /** native declaration : headers\openvr_capi.h:295 */ + public static final int ETrackedDeviceProperty_Prop_VRCVersion_Uint64 = 1020; + /** native declaration : headers\openvr_capi.h:296 */ + public static final int ETrackedDeviceProperty_Prop_RadioVersion_Uint64 = 1021; + /** native declaration : headers\openvr_capi.h:297 */ + public static final int ETrackedDeviceProperty_Prop_DongleVersion_Uint64 = 1022; + /** native declaration : headers\openvr_capi.h:298 */ + public static final int ETrackedDeviceProperty_Prop_BlockServerShutdown_Bool = 1023; + /** native declaration : headers\openvr_capi.h:299 */ + public static final int ETrackedDeviceProperty_Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024; + /** native declaration : headers\openvr_capi.h:300 */ + public static final int ETrackedDeviceProperty_Prop_ContainsProximitySensor_Bool = 1025; + /** native declaration : headers\openvr_capi.h:301 */ + public static final int ETrackedDeviceProperty_Prop_DeviceProvidesBatteryStatus_Bool = 1026; + /** native declaration : headers\openvr_capi.h:302 */ + public static final int ETrackedDeviceProperty_Prop_DeviceCanPowerOff_Bool = 1027; + /** native declaration : headers\openvr_capi.h:303 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ProgrammingTarget_String = 1028; + /** native declaration : headers\openvr_capi.h:304 */ + public static final int ETrackedDeviceProperty_Prop_DeviceClass_Int32 = 1029; + /** native declaration : headers\openvr_capi.h:305 */ + public static final int ETrackedDeviceProperty_Prop_HasCamera_Bool = 1030; + /** native declaration : headers\openvr_capi.h:306 */ + public static final int ETrackedDeviceProperty_Prop_DriverVersion_String = 1031; + /** native declaration : headers\openvr_capi.h:307 */ + public static final int ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool = 1032; + /** native declaration : headers\openvr_capi.h:308 */ + public static final int ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool = 1033; + /** native declaration : headers\openvr_capi.h:309 */ + public static final int ETrackedDeviceProperty_Prop_ParentDriver_Uint64 = 1034; + /** native declaration : headers\openvr_capi.h:310 */ + public static final int ETrackedDeviceProperty_Prop_ResourceRoot_String = 1035; + /** native declaration : headers\openvr_capi.h:311 */ + public static final int ETrackedDeviceProperty_Prop_RegisteredDeviceType_String = 1036; + /** native declaration : headers\openvr_capi.h:312 */ + public static final int ETrackedDeviceProperty_Prop_InputProfilePath_String = 1037; + /** native declaration : headers\openvr_capi.h:313 */ + public static final int ETrackedDeviceProperty_Prop_NeverTracked_Bool = 1038; + /** native declaration : headers\openvr_capi.h:314 */ + public static final int ETrackedDeviceProperty_Prop_NumCameras_Int32 = 1039; + /** native declaration : headers\openvr_capi.h:315 */ + public static final int ETrackedDeviceProperty_Prop_CameraFrameLayout_Int32 = 1040; + /** native declaration : headers\openvr_capi.h:316 */ + public static final int ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool = 2000; + /** native declaration : headers\openvr_capi.h:317 */ + public static final int ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float = 2001; + /** native declaration : headers\openvr_capi.h:318 */ + public static final int ETrackedDeviceProperty_Prop_DisplayFrequency_Float = 2002; + /** native declaration : headers\openvr_capi.h:319 */ + public static final int ETrackedDeviceProperty_Prop_UserIpdMeters_Float = 2003; + /** native declaration : headers\openvr_capi.h:320 */ + public static final int ETrackedDeviceProperty_Prop_CurrentUniverseId_Uint64 = 2004; + /** native declaration : headers\openvr_capi.h:321 */ + public static final int ETrackedDeviceProperty_Prop_PreviousUniverseId_Uint64 = 2005; + /** native declaration : headers\openvr_capi.h:322 */ + public static final int ETrackedDeviceProperty_Prop_DisplayFirmwareVersion_Uint64 = 2006; + /** native declaration : headers\openvr_capi.h:323 */ + public static final int ETrackedDeviceProperty_Prop_IsOnDesktop_Bool = 2007; + /** native declaration : headers\openvr_capi.h:324 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCType_Int32 = 2008; + /** native declaration : headers\openvr_capi.h:325 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCOffset_Float = 2009; + /** native declaration : headers\openvr_capi.h:326 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCScale_Float = 2010; + /** native declaration : headers\openvr_capi.h:327 */ + public static final int ETrackedDeviceProperty_Prop_EdidVendorID_Int32 = 2011; + /** native declaration : headers\openvr_capi.h:328 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageLeft_String = 2012; + /** native declaration : headers\openvr_capi.h:329 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageRight_String = 2013; + /** native declaration : headers\openvr_capi.h:330 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCBlackClamp_Float = 2014; + /** native declaration : headers\openvr_capi.h:331 */ + public static final int ETrackedDeviceProperty_Prop_EdidProductID_Int32 = 2015; + /** native declaration : headers\openvr_capi.h:332 */ + public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransform_Matrix34 = 2016; + /** native declaration : headers\openvr_capi.h:333 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCType_Int32 = 2017; + /** native declaration : headers\openvr_capi.h:334 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCOffset_Float = 2018; + /** native declaration : headers\openvr_capi.h:335 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCScale_Float = 2019; + /** native declaration : headers\openvr_capi.h:336 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCPrescale_Float = 2020; + /** native declaration : headers\openvr_capi.h:337 */ + public static final int ETrackedDeviceProperty_Prop_DisplayGCImage_String = 2021; + /** native declaration : headers\openvr_capi.h:338 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterLeftU_Float = 2022; + /** native declaration : headers\openvr_capi.h:339 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterLeftV_Float = 2023; + /** native declaration : headers\openvr_capi.h:340 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterRightU_Float = 2024; + /** native declaration : headers\openvr_capi.h:341 */ + public static final int ETrackedDeviceProperty_Prop_LensCenterRightV_Float = 2025; + /** native declaration : headers\openvr_capi.h:342 */ + public static final int ETrackedDeviceProperty_Prop_UserHeadToEyeDepthMeters_Float = 2026; + /** native declaration : headers\openvr_capi.h:343 */ + public static final int ETrackedDeviceProperty_Prop_CameraFirmwareVersion_Uint64 = 2027; + /** native declaration : headers\openvr_capi.h:344 */ + public static final int ETrackedDeviceProperty_Prop_CameraFirmwareDescription_String = 2028; + /** native declaration : headers\openvr_capi.h:345 */ + public static final int ETrackedDeviceProperty_Prop_DisplayFPGAVersion_Uint64 = 2029; + /** native declaration : headers\openvr_capi.h:346 */ + public static final int ETrackedDeviceProperty_Prop_DisplayBootloaderVersion_Uint64 = 2030; + /** native declaration : headers\openvr_capi.h:347 */ + public static final int ETrackedDeviceProperty_Prop_DisplayHardwareVersion_Uint64 = 2031; + /** native declaration : headers\openvr_capi.h:348 */ + public static final int ETrackedDeviceProperty_Prop_AudioFirmwareVersion_Uint64 = 2032; + /** native declaration : headers\openvr_capi.h:349 */ + public static final int ETrackedDeviceProperty_Prop_CameraCompatibilityMode_Int32 = 2033; + /** native declaration : headers\openvr_capi.h:350 */ + public static final int ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034; + /** native declaration : headers\openvr_capi.h:351 */ + public static final int ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035; + /** native declaration : headers\openvr_capi.h:352 */ + public static final int ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool = 2036; + /** native declaration : headers\openvr_capi.h:353 */ + public static final int ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool = 2037; + /** native declaration : headers\openvr_capi.h:354 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32 = 2038; + /** native declaration : headers\openvr_capi.h:355 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32 = 2039; + /** native declaration : headers\openvr_capi.h:356 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32 = 2040; + /** native declaration : headers\openvr_capi.h:357 */ + public static final int ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary = 2041; + /** native declaration : headers\openvr_capi.h:358 */ + public static final int ETrackedDeviceProperty_Prop_SecondsFromPhotonsToVblank_Float = 2042; + /** native declaration : headers\openvr_capi.h:359 */ + public static final int ETrackedDeviceProperty_Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043; + /** native declaration : headers\openvr_capi.h:360 */ + public static final int ETrackedDeviceProperty_Prop_DisplayDebugMode_Bool = 2044; + /** native declaration : headers\openvr_capi.h:361 */ + public static final int ETrackedDeviceProperty_Prop_GraphicsAdapterLuid_Uint64 = 2045; + /** native declaration : headers\openvr_capi.h:362 */ + public static final int ETrackedDeviceProperty_Prop_DriverProvidedChaperonePath_String = 2048; + /** native declaration : headers\openvr_capi.h:363 */ + public static final int ETrackedDeviceProperty_Prop_ExpectedTrackingReferenceCount_Int32 = 2049; + /** native declaration : headers\openvr_capi.h:364 */ + public static final int ETrackedDeviceProperty_Prop_ExpectedControllerCount_Int32 = 2050; + /** native declaration : headers\openvr_capi.h:365 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerLeftDeviceOff_String = 2051; + /** native declaration : headers\openvr_capi.h:366 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathControllerRightDeviceOff_String = 2052; + /** native declaration : headers\openvr_capi.h:367 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053; + /** native declaration : headers\openvr_capi.h:368 */ + public static final int ETrackedDeviceProperty_Prop_DoNotApplyPrediction_Bool = 2054; + /** native declaration : headers\openvr_capi.h:369 */ + public static final int ETrackedDeviceProperty_Prop_CameraToHeadTransforms_Matrix34_Array = 2055; + /** native declaration : headers\openvr_capi.h:370 */ + public static final int ETrackedDeviceProperty_Prop_DistortionMeshResolution_Int32 = 2056; + /** native declaration : headers\openvr_capi.h:371 */ + public static final int ETrackedDeviceProperty_Prop_DriverIsDrawingControllers_Bool = 2057; + /** native declaration : headers\openvr_capi.h:372 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestsApplicationPause_Bool = 2058; + /** native declaration : headers\openvr_capi.h:373 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestsReducedRendering_Bool = 2059; + /** native declaration : headers\openvr_capi.h:374 */ + public static final int ETrackedDeviceProperty_Prop_MinimumIpdStepMeters_Float = 2060; + /** native declaration : headers\openvr_capi.h:375 */ + public static final int ETrackedDeviceProperty_Prop_AudioBridgeFirmwareVersion_Uint64 = 2061; + /** native declaration : headers\openvr_capi.h:376 */ + public static final int ETrackedDeviceProperty_Prop_ImageBridgeFirmwareVersion_Uint64 = 2062; + /** native declaration : headers\openvr_capi.h:377 */ + public static final int ETrackedDeviceProperty_Prop_ImuToHeadTransform_Matrix34 = 2063; + /** native declaration : headers\openvr_capi.h:378 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroBias_Vector3 = 2064; + /** native declaration : headers\openvr_capi.h:379 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryGyroScale_Vector3 = 2065; + /** native declaration : headers\openvr_capi.h:380 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerBias_Vector3 = 2066; + /** native declaration : headers\openvr_capi.h:381 */ + public static final int ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerScale_Vector3 = 2067; + /** native declaration : headers\openvr_capi.h:382 */ + public static final int ETrackedDeviceProperty_Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069; + /** native declaration : headers\openvr_capi.h:383 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200; + /** native declaration : headers\openvr_capi.h:384 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201; + /** native declaration : headers\openvr_capi.h:385 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202; + /** native declaration : headers\openvr_capi.h:386 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203; + /** native declaration : headers\openvr_capi.h:387 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204; + /** native declaration : headers\openvr_capi.h:388 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205; + /** native declaration : headers\openvr_capi.h:389 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206; + /** native declaration : headers\openvr_capi.h:390 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207; + /** native declaration : headers\openvr_capi.h:391 */ + public static final int ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208; + /** native declaration : headers\openvr_capi.h:392 */ + public static final int ETrackedDeviceProperty_Prop_AttachedDeviceId_String = 3000; + /** native declaration : headers\openvr_capi.h:393 */ + public static final int ETrackedDeviceProperty_Prop_SupportedButtons_Uint64 = 3001; + /** native declaration : headers\openvr_capi.h:394 */ + public static final int ETrackedDeviceProperty_Prop_Axis0Type_Int32 = 3002; + /** native declaration : headers\openvr_capi.h:395 */ + public static final int ETrackedDeviceProperty_Prop_Axis1Type_Int32 = 3003; + /** native declaration : headers\openvr_capi.h:396 */ + public static final int ETrackedDeviceProperty_Prop_Axis2Type_Int32 = 3004; + /** native declaration : headers\openvr_capi.h:397 */ + public static final int ETrackedDeviceProperty_Prop_Axis3Type_Int32 = 3005; + /** native declaration : headers\openvr_capi.h:398 */ + public static final int ETrackedDeviceProperty_Prop_Axis4Type_Int32 = 3006; + /** native declaration : headers\openvr_capi.h:399 */ + public static final int ETrackedDeviceProperty_Prop_ControllerRoleHint_Int32 = 3007; + /** native declaration : headers\openvr_capi.h:400 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewLeftDegrees_Float = 4000; + /** native declaration : headers\openvr_capi.h:401 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewRightDegrees_Float = 4001; + /** native declaration : headers\openvr_capi.h:402 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewTopDegrees_Float = 4002; + /** native declaration : headers\openvr_capi.h:403 */ + public static final int ETrackedDeviceProperty_Prop_FieldOfViewBottomDegrees_Float = 4003; + /** native declaration : headers\openvr_capi.h:404 */ + public static final int ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float = 4004; + /** native declaration : headers\openvr_capi.h:405 */ + public static final int ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float = 4005; + /** native declaration : headers\openvr_capi.h:406 */ + public static final int ETrackedDeviceProperty_Prop_ModeLabel_String = 4006; + /** native declaration : headers\openvr_capi.h:407 */ + public static final int ETrackedDeviceProperty_Prop_IconPathName_String = 5000; + /** native declaration : headers\openvr_capi.h:408 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String = 5001; + /** native declaration : headers\openvr_capi.h:409 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String = 5002; + /** native declaration : headers\openvr_capi.h:410 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String = 5003; + /** native declaration : headers\openvr_capi.h:411 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String = 5004; + /** native declaration : headers\openvr_capi.h:412 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String = 5005; + /** native declaration : headers\openvr_capi.h:413 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String = 5006; + /** native declaration : headers\openvr_capi.h:414 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String = 5007; + /** native declaration : headers\openvr_capi.h:415 */ + public static final int ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String = 5008; + /** native declaration : headers\openvr_capi.h:416 */ + public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start = 5100; + /** native declaration : headers\openvr_capi.h:417 */ + public static final int ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End = 5150; + /** native declaration : headers\openvr_capi.h:418 */ + public static final int ETrackedDeviceProperty_Prop_ParentContainer = 5151; + /** native declaration : headers\openvr_capi.h:419 */ + public static final int ETrackedDeviceProperty_Prop_UserConfigPath_String = 6000; + /** native declaration : headers\openvr_capi.h:420 */ + public static final int ETrackedDeviceProperty_Prop_InstallPath_String = 6001; + /** native declaration : headers\openvr_capi.h:421 */ + public static final int ETrackedDeviceProperty_Prop_HasDisplayComponent_Bool = 6002; + /** native declaration : headers\openvr_capi.h:422 */ + public static final int ETrackedDeviceProperty_Prop_HasControllerComponent_Bool = 6003; + /** native declaration : headers\openvr_capi.h:423 */ + public static final int ETrackedDeviceProperty_Prop_HasCameraComponent_Bool = 6004; + /** native declaration : headers\openvr_capi.h:424 */ + public static final int ETrackedDeviceProperty_Prop_HasDriverDirectModeComponent_Bool = 6005; + /** native declaration : headers\openvr_capi.h:425 */ + public static final int ETrackedDeviceProperty_Prop_HasVirtualDisplayComponent_Bool = 6006; + /** native declaration : headers\openvr_capi.h:426 */ + public static final int ETrackedDeviceProperty_Prop_HasSpatialAnchorsSupport_Bool = 6007; + /** native declaration : headers\openvr_capi.h:427 */ + public static final int ETrackedDeviceProperty_Prop_ControllerType_String = 7000; + /** native declaration : headers\openvr_capi.h:428 */ + public static final int ETrackedDeviceProperty_Prop_LegacyInputProfile_String = 7001; + /** native declaration : headers\openvr_capi.h:429 */ + public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start = 10000; + /** native declaration : headers\openvr_capi.h:430 */ + public static final int ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End = 10999; + /** native declaration : headers\openvr_capi.h:431 */ + public static final int ETrackedDeviceProperty_Prop_TrackedDeviceProperty_Max = 1000000; + }; + /** + * native declaration : headers\openvr_capi.h:447
        + * enum values + */ + public static interface ETrackedPropertyError { + /** native declaration : headers\openvr_capi.h:434 */ + public static final int ETrackedPropertyError_TrackedProp_Success = 0; + /** native declaration : headers\openvr_capi.h:435 */ + public static final int ETrackedPropertyError_TrackedProp_WrongDataType = 1; + /** native declaration : headers\openvr_capi.h:436 */ + public static final int ETrackedPropertyError_TrackedProp_WrongDeviceClass = 2; + /** native declaration : headers\openvr_capi.h:437 */ + public static final int ETrackedPropertyError_TrackedProp_BufferTooSmall = 3; + /** native declaration : headers\openvr_capi.h:438 */ + public static final int ETrackedPropertyError_TrackedProp_UnknownProperty = 4; + /** native declaration : headers\openvr_capi.h:439 */ + public static final int ETrackedPropertyError_TrackedProp_InvalidDevice = 5; + /** native declaration : headers\openvr_capi.h:440 */ + public static final int ETrackedPropertyError_TrackedProp_CouldNotContactServer = 6; + /** native declaration : headers\openvr_capi.h:441 */ + public static final int ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice = 7; + /** native declaration : headers\openvr_capi.h:442 */ + public static final int ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength = 8; + /** native declaration : headers\openvr_capi.h:443 */ + public static final int ETrackedPropertyError_TrackedProp_NotYetAvailable = 9; + /** native declaration : headers\openvr_capi.h:444 */ + public static final int ETrackedPropertyError_TrackedProp_PermissionDenied = 10; + /** native declaration : headers\openvr_capi.h:445 */ + public static final int ETrackedPropertyError_TrackedProp_InvalidOperation = 11; + /** native declaration : headers\openvr_capi.h:446 */ + public static final int ETrackedPropertyError_TrackedProp_CannotWriteToWildcards = 12; + }; + /** + * native declaration : headers\openvr_capi.h:455
        + * enum values + */ + public static interface EVRSubmitFlags { + /** native declaration : headers\openvr_capi.h:449 */ + public static final int EVRSubmitFlags_Submit_Default = 0; + /** native declaration : headers\openvr_capi.h:450 */ + public static final int EVRSubmitFlags_Submit_LensDistortionAlreadyApplied = 1; + /** native declaration : headers\openvr_capi.h:451 */ + public static final int EVRSubmitFlags_Submit_GlRenderBuffer = 2; + /** native declaration : headers\openvr_capi.h:452 */ + public static final int EVRSubmitFlags_Submit_Reserved = 4; + /** native declaration : headers\openvr_capi.h:453 */ + public static final int EVRSubmitFlags_Submit_TextureWithPose = 8; + /** native declaration : headers\openvr_capi.h:454 */ + public static final int EVRSubmitFlags_Submit_TextureWithDepth = 16; + }; + /** + * native declaration : headers\openvr_capi.h:466
        + * enum values + */ + public static interface EVRState { + /** native declaration : headers\openvr_capi.h:457 */ + public static final int EVRState_VRState_Undefined = -1; + /** native declaration : headers\openvr_capi.h:458 */ + public static final int EVRState_VRState_Off = 0; + /** native declaration : headers\openvr_capi.h:459 */ + public static final int EVRState_VRState_Searching = 1; + /** native declaration : headers\openvr_capi.h:460 */ + public static final int EVRState_VRState_Searching_Alert = 2; + /** native declaration : headers\openvr_capi.h:461 */ + public static final int EVRState_VRState_Ready = 3; + /** native declaration : headers\openvr_capi.h:462 */ + public static final int EVRState_VRState_Ready_Alert = 4; + /** native declaration : headers\openvr_capi.h:463 */ + public static final int EVRState_VRState_NotReady = 5; + /** native declaration : headers\openvr_capi.h:464 */ + public static final int EVRState_VRState_Standby = 6; + /** native declaration : headers\openvr_capi.h:465 */ + public static final int EVRState_VRState_Ready_Alert_Low = 7; + }; + /** + * native declaration : headers\openvr_capi.h:616
        + * enum values + */ + public static interface EVREventType { + /** native declaration : headers\openvr_capi.h:468 */ + public static final int EVREventType_VREvent_None = 0; + /** native declaration : headers\openvr_capi.h:469 */ + public static final int EVREventType_VREvent_TrackedDeviceActivated = 100; + /** native declaration : headers\openvr_capi.h:470 */ + public static final int EVREventType_VREvent_TrackedDeviceDeactivated = 101; + /** native declaration : headers\openvr_capi.h:471 */ + public static final int EVREventType_VREvent_TrackedDeviceUpdated = 102; + /** native declaration : headers\openvr_capi.h:472 */ + public static final int EVREventType_VREvent_TrackedDeviceUserInteractionStarted = 103; + /** native declaration : headers\openvr_capi.h:473 */ + public static final int EVREventType_VREvent_TrackedDeviceUserInteractionEnded = 104; + /** native declaration : headers\openvr_capi.h:474 */ + public static final int EVREventType_VREvent_IpdChanged = 105; + /** native declaration : headers\openvr_capi.h:475 */ + public static final int EVREventType_VREvent_EnterStandbyMode = 106; + /** native declaration : headers\openvr_capi.h:476 */ + public static final int EVREventType_VREvent_LeaveStandbyMode = 107; + /** native declaration : headers\openvr_capi.h:477 */ + public static final int EVREventType_VREvent_TrackedDeviceRoleChanged = 108; + /** native declaration : headers\openvr_capi.h:478 */ + public static final int EVREventType_VREvent_WatchdogWakeUpRequested = 109; + /** native declaration : headers\openvr_capi.h:479 */ + public static final int EVREventType_VREvent_LensDistortionChanged = 110; + /** native declaration : headers\openvr_capi.h:480 */ + public static final int EVREventType_VREvent_PropertyChanged = 111; + /** native declaration : headers\openvr_capi.h:481 */ + public static final int EVREventType_VREvent_WirelessDisconnect = 112; + /** native declaration : headers\openvr_capi.h:482 */ + public static final int EVREventType_VREvent_WirelessReconnect = 113; + /** native declaration : headers\openvr_capi.h:483 */ + public static final int EVREventType_VREvent_ButtonPress = 200; + /** native declaration : headers\openvr_capi.h:484 */ + public static final int EVREventType_VREvent_ButtonUnpress = 201; + /** native declaration : headers\openvr_capi.h:485 */ + public static final int EVREventType_VREvent_ButtonTouch = 202; + /** native declaration : headers\openvr_capi.h:486 */ + public static final int EVREventType_VREvent_ButtonUntouch = 203; + /** native declaration : headers\openvr_capi.h:487 */ + public static final int EVREventType_VREvent_DualAnalog_Press = 250; + /** native declaration : headers\openvr_capi.h:488 */ + public static final int EVREventType_VREvent_DualAnalog_Unpress = 251; + /** native declaration : headers\openvr_capi.h:489 */ + public static final int EVREventType_VREvent_DualAnalog_Touch = 252; + /** native declaration : headers\openvr_capi.h:490 */ + public static final int EVREventType_VREvent_DualAnalog_Untouch = 253; + /** native declaration : headers\openvr_capi.h:491 */ + public static final int EVREventType_VREvent_DualAnalog_Move = 254; + /** native declaration : headers\openvr_capi.h:492 */ + public static final int EVREventType_VREvent_DualAnalog_ModeSwitch1 = 255; + /** native declaration : headers\openvr_capi.h:493 */ + public static final int EVREventType_VREvent_DualAnalog_ModeSwitch2 = 256; + /** native declaration : headers\openvr_capi.h:494 */ + public static final int EVREventType_VREvent_DualAnalog_Cancel = 257; + /** native declaration : headers\openvr_capi.h:495 */ + public static final int EVREventType_VREvent_MouseMove = 300; + /** native declaration : headers\openvr_capi.h:496 */ + public static final int EVREventType_VREvent_MouseButtonDown = 301; + /** native declaration : headers\openvr_capi.h:497 */ + public static final int EVREventType_VREvent_MouseButtonUp = 302; + /** native declaration : headers\openvr_capi.h:498 */ + public static final int EVREventType_VREvent_FocusEnter = 303; + /** native declaration : headers\openvr_capi.h:499 */ + public static final int EVREventType_VREvent_FocusLeave = 304; + /** native declaration : headers\openvr_capi.h:500 */ + public static final int EVREventType_VREvent_Scroll = 305; + /** native declaration : headers\openvr_capi.h:501 */ + public static final int EVREventType_VREvent_TouchPadMove = 306; + /** native declaration : headers\openvr_capi.h:502 */ + public static final int EVREventType_VREvent_OverlayFocusChanged = 307; + /** native declaration : headers\openvr_capi.h:503 */ + public static final int EVREventType_VREvent_InputFocusCaptured = 400; + /** native declaration : headers\openvr_capi.h:504 */ + public static final int EVREventType_VREvent_InputFocusReleased = 401; + /** native declaration : headers\openvr_capi.h:505 */ + public static final int EVREventType_VREvent_SceneFocusLost = 402; + /** native declaration : headers\openvr_capi.h:506 */ + public static final int EVREventType_VREvent_SceneFocusGained = 403; + /** native declaration : headers\openvr_capi.h:507 */ + public static final int EVREventType_VREvent_SceneApplicationChanged = 404; + /** native declaration : headers\openvr_capi.h:508 */ + public static final int EVREventType_VREvent_SceneFocusChanged = 405; + /** native declaration : headers\openvr_capi.h:509 */ + public static final int EVREventType_VREvent_InputFocusChanged = 406; + /** native declaration : headers\openvr_capi.h:510 */ + public static final int EVREventType_VREvent_SceneApplicationSecondaryRenderingStarted = 407; + /** native declaration : headers\openvr_capi.h:511 */ + public static final int EVREventType_VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408; + /** native declaration : headers\openvr_capi.h:512 */ + public static final int EVREventType_VREvent_ActionBindingReloaded = 409; + /** native declaration : headers\openvr_capi.h:513 */ + public static final int EVREventType_VREvent_HideRenderModels = 410; + /** native declaration : headers\openvr_capi.h:514 */ + public static final int EVREventType_VREvent_ShowRenderModels = 411; + /** native declaration : headers\openvr_capi.h:515 */ + public static final int EVREventType_VREvent_ConsoleOpened = 420; + /** native declaration : headers\openvr_capi.h:516 */ + public static final int EVREventType_VREvent_ConsoleClosed = 421; + /** native declaration : headers\openvr_capi.h:517 */ + public static final int EVREventType_VREvent_OverlayShown = 500; + /** native declaration : headers\openvr_capi.h:518 */ + public static final int EVREventType_VREvent_OverlayHidden = 501; + /** native declaration : headers\openvr_capi.h:519 */ + public static final int EVREventType_VREvent_DashboardActivated = 502; + /** native declaration : headers\openvr_capi.h:520 */ + public static final int EVREventType_VREvent_DashboardDeactivated = 503; + /** native declaration : headers\openvr_capi.h:521 */ + public static final int EVREventType_VREvent_DashboardThumbSelected = 504; + /** native declaration : headers\openvr_capi.h:522 */ + public static final int EVREventType_VREvent_DashboardRequested = 505; + /** native declaration : headers\openvr_capi.h:523 */ + public static final int EVREventType_VREvent_ResetDashboard = 506; + /** native declaration : headers\openvr_capi.h:524 */ + public static final int EVREventType_VREvent_RenderToast = 507; + /** native declaration : headers\openvr_capi.h:525 */ + public static final int EVREventType_VREvent_ImageLoaded = 508; + /** native declaration : headers\openvr_capi.h:526 */ + public static final int EVREventType_VREvent_ShowKeyboard = 509; + /** native declaration : headers\openvr_capi.h:527 */ + public static final int EVREventType_VREvent_HideKeyboard = 510; + /** native declaration : headers\openvr_capi.h:528 */ + public static final int EVREventType_VREvent_OverlayGamepadFocusGained = 511; + /** native declaration : headers\openvr_capi.h:529 */ + public static final int EVREventType_VREvent_OverlayGamepadFocusLost = 512; + /** native declaration : headers\openvr_capi.h:530 */ + public static final int EVREventType_VREvent_OverlaySharedTextureChanged = 513; + /** native declaration : headers\openvr_capi.h:531 */ + public static final int EVREventType_VREvent_ScreenshotTriggered = 516; + /** native declaration : headers\openvr_capi.h:532 */ + public static final int EVREventType_VREvent_ImageFailed = 517; + /** native declaration : headers\openvr_capi.h:533 */ + public static final int EVREventType_VREvent_DashboardOverlayCreated = 518; + /** native declaration : headers\openvr_capi.h:534 */ + public static final int EVREventType_VREvent_SwitchGamepadFocus = 519; + /** native declaration : headers\openvr_capi.h:535 */ + public static final int EVREventType_VREvent_RequestScreenshot = 520; + /** native declaration : headers\openvr_capi.h:536 */ + public static final int EVREventType_VREvent_ScreenshotTaken = 521; + /** native declaration : headers\openvr_capi.h:537 */ + public static final int EVREventType_VREvent_ScreenshotFailed = 522; + /** native declaration : headers\openvr_capi.h:538 */ + public static final int EVREventType_VREvent_SubmitScreenshotToDashboard = 523; + /** native declaration : headers\openvr_capi.h:539 */ + public static final int EVREventType_VREvent_ScreenshotProgressToDashboard = 524; + /** native declaration : headers\openvr_capi.h:540 */ + public static final int EVREventType_VREvent_PrimaryDashboardDeviceChanged = 525; + /** native declaration : headers\openvr_capi.h:541 */ + public static final int EVREventType_VREvent_RoomViewShown = 526; + /** native declaration : headers\openvr_capi.h:542 */ + public static final int EVREventType_VREvent_RoomViewHidden = 527; + /** native declaration : headers\openvr_capi.h:543 */ + public static final int EVREventType_VREvent_Notification_Shown = 600; + /** native declaration : headers\openvr_capi.h:544 */ + public static final int EVREventType_VREvent_Notification_Hidden = 601; + /** native declaration : headers\openvr_capi.h:545 */ + public static final int EVREventType_VREvent_Notification_BeginInteraction = 602; + /** native declaration : headers\openvr_capi.h:546 */ + public static final int EVREventType_VREvent_Notification_Destroyed = 603; + /** native declaration : headers\openvr_capi.h:547 */ + public static final int EVREventType_VREvent_Quit = 700; + /** native declaration : headers\openvr_capi.h:548 */ + public static final int EVREventType_VREvent_ProcessQuit = 701; + /** native declaration : headers\openvr_capi.h:549 */ + public static final int EVREventType_VREvent_QuitAborted_UserPrompt = 702; + /** native declaration : headers\openvr_capi.h:550 */ + public static final int EVREventType_VREvent_QuitAcknowledged = 703; + /** native declaration : headers\openvr_capi.h:551 */ + public static final int EVREventType_VREvent_DriverRequestedQuit = 704; + /** native declaration : headers\openvr_capi.h:552 */ + public static final int EVREventType_VREvent_ChaperoneDataHasChanged = 800; + /** native declaration : headers\openvr_capi.h:553 */ + public static final int EVREventType_VREvent_ChaperoneUniverseHasChanged = 801; + /** native declaration : headers\openvr_capi.h:554 */ + public static final int EVREventType_VREvent_ChaperoneTempDataHasChanged = 802; + /** native declaration : headers\openvr_capi.h:555 */ + public static final int EVREventType_VREvent_ChaperoneSettingsHaveChanged = 803; + /** native declaration : headers\openvr_capi.h:556 */ + public static final int EVREventType_VREvent_SeatedZeroPoseReset = 804; + /** native declaration : headers\openvr_capi.h:557 */ + public static final int EVREventType_VREvent_AudioSettingsHaveChanged = 820; + /** native declaration : headers\openvr_capi.h:558 */ + public static final int EVREventType_VREvent_BackgroundSettingHasChanged = 850; + /** native declaration : headers\openvr_capi.h:559 */ + public static final int EVREventType_VREvent_CameraSettingsHaveChanged = 851; + /** native declaration : headers\openvr_capi.h:560 */ + public static final int EVREventType_VREvent_ReprojectionSettingHasChanged = 852; + /** native declaration : headers\openvr_capi.h:561 */ + public static final int EVREventType_VREvent_ModelSkinSettingsHaveChanged = 853; + /** native declaration : headers\openvr_capi.h:562 */ + public static final int EVREventType_VREvent_EnvironmentSettingsHaveChanged = 854; + /** native declaration : headers\openvr_capi.h:563 */ + public static final int EVREventType_VREvent_PowerSettingsHaveChanged = 855; + /** native declaration : headers\openvr_capi.h:564 */ + public static final int EVREventType_VREvent_EnableHomeAppSettingsHaveChanged = 856; + /** native declaration : headers\openvr_capi.h:565 */ + public static final int EVREventType_VREvent_SteamVRSectionSettingChanged = 857; + /** native declaration : headers\openvr_capi.h:566 */ + public static final int EVREventType_VREvent_LighthouseSectionSettingChanged = 858; + /** native declaration : headers\openvr_capi.h:567 */ + public static final int EVREventType_VREvent_NullSectionSettingChanged = 859; + /** native declaration : headers\openvr_capi.h:568 */ + public static final int EVREventType_VREvent_UserInterfaceSectionSettingChanged = 860; + /** native declaration : headers\openvr_capi.h:569 */ + public static final int EVREventType_VREvent_NotificationsSectionSettingChanged = 861; + /** native declaration : headers\openvr_capi.h:570 */ + public static final int EVREventType_VREvent_KeyboardSectionSettingChanged = 862; + /** native declaration : headers\openvr_capi.h:571 */ + public static final int EVREventType_VREvent_PerfSectionSettingChanged = 863; + /** native declaration : headers\openvr_capi.h:572 */ + public static final int EVREventType_VREvent_DashboardSectionSettingChanged = 864; + /** native declaration : headers\openvr_capi.h:573 */ + public static final int EVREventType_VREvent_WebInterfaceSectionSettingChanged = 865; + /** native declaration : headers\openvr_capi.h:574 */ + public static final int EVREventType_VREvent_TrackersSectionSettingChanged = 866; + /** native declaration : headers\openvr_capi.h:575 */ + public static final int EVREventType_VREvent_StatusUpdate = 900; + /** native declaration : headers\openvr_capi.h:576 */ + public static final int EVREventType_VREvent_WebInterface_InstallDriverCompleted = 950; + /** native declaration : headers\openvr_capi.h:577 */ + public static final int EVREventType_VREvent_MCImageUpdated = 1000; + /** native declaration : headers\openvr_capi.h:578 */ + public static final int EVREventType_VREvent_FirmwareUpdateStarted = 1100; + /** native declaration : headers\openvr_capi.h:579 */ + public static final int EVREventType_VREvent_FirmwareUpdateFinished = 1101; + /** native declaration : headers\openvr_capi.h:580 */ + public static final int EVREventType_VREvent_KeyboardClosed = 1200; + /** native declaration : headers\openvr_capi.h:581 */ + public static final int EVREventType_VREvent_KeyboardCharInput = 1201; + /** native declaration : headers\openvr_capi.h:582 */ + public static final int EVREventType_VREvent_KeyboardDone = 1202; + /** native declaration : headers\openvr_capi.h:583 */ + public static final int EVREventType_VREvent_ApplicationTransitionStarted = 1300; + /** native declaration : headers\openvr_capi.h:584 */ + public static final int EVREventType_VREvent_ApplicationTransitionAborted = 1301; + /** native declaration : headers\openvr_capi.h:585 */ + public static final int EVREventType_VREvent_ApplicationTransitionNewAppStarted = 1302; + /** native declaration : headers\openvr_capi.h:586 */ + public static final int EVREventType_VREvent_ApplicationListUpdated = 1303; + /** native declaration : headers\openvr_capi.h:587 */ + public static final int EVREventType_VREvent_ApplicationMimeTypeLoad = 1304; + /** native declaration : headers\openvr_capi.h:588 */ + public static final int EVREventType_VREvent_ApplicationTransitionNewAppLaunchComplete = 1305; + /** native declaration : headers\openvr_capi.h:589 */ + public static final int EVREventType_VREvent_ProcessConnected = 1306; + /** native declaration : headers\openvr_capi.h:590 */ + public static final int EVREventType_VREvent_ProcessDisconnected = 1307; + /** native declaration : headers\openvr_capi.h:591 */ + public static final int EVREventType_VREvent_Compositor_MirrorWindowShown = 1400; + /** native declaration : headers\openvr_capi.h:592 */ + public static final int EVREventType_VREvent_Compositor_MirrorWindowHidden = 1401; + /** native declaration : headers\openvr_capi.h:593 */ + public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsShown = 1410; + /** native declaration : headers\openvr_capi.h:594 */ + public static final int EVREventType_VREvent_Compositor_ChaperoneBoundsHidden = 1411; + /** native declaration : headers\openvr_capi.h:595 */ + public static final int EVREventType_VREvent_TrackedCamera_StartVideoStream = 1500; + /** native declaration : headers\openvr_capi.h:596 */ + public static final int EVREventType_VREvent_TrackedCamera_StopVideoStream = 1501; + /** native declaration : headers\openvr_capi.h:597 */ + public static final int EVREventType_VREvent_TrackedCamera_PauseVideoStream = 1502; + /** native declaration : headers\openvr_capi.h:598 */ + public static final int EVREventType_VREvent_TrackedCamera_ResumeVideoStream = 1503; + /** native declaration : headers\openvr_capi.h:599 */ + public static final int EVREventType_VREvent_TrackedCamera_EditingSurface = 1550; + /** native declaration : headers\openvr_capi.h:600 */ + public static final int EVREventType_VREvent_PerformanceTest_EnableCapture = 1600; + /** native declaration : headers\openvr_capi.h:601 */ + public static final int EVREventType_VREvent_PerformanceTest_DisableCapture = 1601; + /** native declaration : headers\openvr_capi.h:602 */ + public static final int EVREventType_VREvent_PerformanceTest_FidelityLevel = 1602; + /** native declaration : headers\openvr_capi.h:603 */ + public static final int EVREventType_VREvent_MessageOverlay_Closed = 1650; + /** native declaration : headers\openvr_capi.h:604 */ + public static final int EVREventType_VREvent_MessageOverlayCloseRequested = 1651; + /** native declaration : headers\openvr_capi.h:605 */ + public static final int EVREventType_VREvent_Input_HapticVibration = 1700; + /** native declaration : headers\openvr_capi.h:606 */ + public static final int EVREventType_VREvent_Input_BindingLoadFailed = 1701; + /** native declaration : headers\openvr_capi.h:607 */ + public static final int EVREventType_VREvent_Input_BindingLoadSuccessful = 1702; + /** native declaration : headers\openvr_capi.h:608 */ + public static final int EVREventType_VREvent_Input_ActionManifestReloaded = 1703; + /** native declaration : headers\openvr_capi.h:609 */ + public static final int EVREventType_VREvent_Input_ActionManifestLoadFailed = 1704; + /** native declaration : headers\openvr_capi.h:610 */ + public static final int EVREventType_VREvent_SpatialAnchors_PoseUpdated = 1800; + /** native declaration : headers\openvr_capi.h:611 */ + public static final int EVREventType_VREvent_SpatialAnchors_DescriptorUpdated = 1801; + /** native declaration : headers\openvr_capi.h:612 */ + public static final int EVREventType_VREvent_SpatialAnchors_RequestPoseUpdate = 1802; + /** native declaration : headers\openvr_capi.h:613 */ + public static final int EVREventType_VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803; + /** native declaration : headers\openvr_capi.h:614 */ + public static final int EVREventType_VREvent_VendorSpecific_Reserved_Start = 10000; + /** native declaration : headers\openvr_capi.h:615 */ + public static final int EVREventType_VREvent_VendorSpecific_Reserved_End = 19999; + }; + /** + * native declaration : headers\openvr_capi.h:623
        + * enum values + */ + public static interface EDeviceActivityLevel { + /** native declaration : headers\openvr_capi.h:618 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Unknown = -1; + /** native declaration : headers\openvr_capi.h:619 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Idle = 0; + /** native declaration : headers\openvr_capi.h:620 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction = 1; + /** native declaration : headers\openvr_capi.h:621 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction_Timeout = 2; + /** native declaration : headers\openvr_capi.h:622 */ + public static final int EDeviceActivityLevel_k_EDeviceActivityLevel_Standby = 3; + }; + /** + * native declaration : headers\openvr_capi.h:646
        + * enum values + */ + public static interface EVRButtonId { + /** native declaration : headers\openvr_capi.h:625 */ + public static final int EVRButtonId_k_EButton_System = 0; + /** native declaration : headers\openvr_capi.h:626 */ + public static final int EVRButtonId_k_EButton_ApplicationMenu = 1; + /** native declaration : headers\openvr_capi.h:627 */ + public static final int EVRButtonId_k_EButton_Grip = 2; + /** native declaration : headers\openvr_capi.h:628 */ + public static final int EVRButtonId_k_EButton_DPad_Left = 3; + /** native declaration : headers\openvr_capi.h:629 */ + public static final int EVRButtonId_k_EButton_DPad_Up = 4; + /** native declaration : headers\openvr_capi.h:630 */ + public static final int EVRButtonId_k_EButton_DPad_Right = 5; + /** native declaration : headers\openvr_capi.h:631 */ + public static final int EVRButtonId_k_EButton_DPad_Down = 6; + /** native declaration : headers\openvr_capi.h:632 */ + public static final int EVRButtonId_k_EButton_A = 7; + /** native declaration : headers\openvr_capi.h:633 */ + public static final int EVRButtonId_k_EButton_ProximitySensor = 31; + /** native declaration : headers\openvr_capi.h:634 */ + public static final int EVRButtonId_k_EButton_Axis0 = 32; + /** native declaration : headers\openvr_capi.h:635 */ + public static final int EVRButtonId_k_EButton_Axis1 = 33; + /** native declaration : headers\openvr_capi.h:636 */ + public static final int EVRButtonId_k_EButton_Axis2 = 34; + /** native declaration : headers\openvr_capi.h:637 */ + public static final int EVRButtonId_k_EButton_Axis3 = 35; + /** native declaration : headers\openvr_capi.h:638 */ + public static final int EVRButtonId_k_EButton_Axis4 = 36; + /** native declaration : headers\openvr_capi.h:639 */ + public static final int EVRButtonId_k_EButton_SteamVR_Touchpad = 32; + /** native declaration : headers\openvr_capi.h:640 */ + public static final int EVRButtonId_k_EButton_SteamVR_Trigger = 33; + /** native declaration : headers\openvr_capi.h:641 */ + public static final int EVRButtonId_k_EButton_Dashboard_Back = 2; + /** native declaration : headers\openvr_capi.h:642 */ + public static final int EVRButtonId_k_EButton_Knuckles_A = 2; + /** native declaration : headers\openvr_capi.h:643 */ + public static final int EVRButtonId_k_EButton_Knuckles_B = 1; + /** native declaration : headers\openvr_capi.h:644 */ + public static final int EVRButtonId_k_EButton_Knuckles_JoyStick = 35; + /** native declaration : headers\openvr_capi.h:645 */ + public static final int EVRButtonId_k_EButton_Max = 64; + }; + /** + * native declaration : headers\openvr_capi.h:651
        + * enum values + */ + public static interface EVRMouseButton { + /** native declaration : headers\openvr_capi.h:648 */ + public static final int EVRMouseButton_VRMouseButton_Left = 1; + /** native declaration : headers\openvr_capi.h:649 */ + public static final int EVRMouseButton_VRMouseButton_Right = 2; + /** native declaration : headers\openvr_capi.h:650 */ + public static final int EVRMouseButton_VRMouseButton_Middle = 4; + }; + /** + * native declaration : headers\openvr_capi.h:655
        + * enum values + */ + public static interface EDualAnalogWhich { + /** native declaration : headers\openvr_capi.h:653 */ + public static final int EDualAnalogWhich_k_EDualAnalog_Left = 0; + /** native declaration : headers\openvr_capi.h:654 */ + public static final int EDualAnalogWhich_k_EDualAnalog_Right = 1; + }; + /** + * native declaration : headers\openvr_capi.h:674
        + * enum values + */ + public static interface EVRInputError { + /** native declaration : headers\openvr_capi.h:657 */ + public static final int EVRInputError_VRInputError_None = 0; + /** native declaration : headers\openvr_capi.h:658 */ + public static final int EVRInputError_VRInputError_NameNotFound = 1; + /** native declaration : headers\openvr_capi.h:659 */ + public static final int EVRInputError_VRInputError_WrongType = 2; + /** native declaration : headers\openvr_capi.h:660 */ + public static final int EVRInputError_VRInputError_InvalidHandle = 3; + /** native declaration : headers\openvr_capi.h:661 */ + public static final int EVRInputError_VRInputError_InvalidParam = 4; + /** native declaration : headers\openvr_capi.h:662 */ + public static final int EVRInputError_VRInputError_NoSteam = 5; + /** native declaration : headers\openvr_capi.h:663 */ + public static final int EVRInputError_VRInputError_MaxCapacityReached = 6; + /** native declaration : headers\openvr_capi.h:664 */ + public static final int EVRInputError_VRInputError_IPCError = 7; + /** native declaration : headers\openvr_capi.h:665 */ + public static final int EVRInputError_VRInputError_NoActiveActionSet = 8; + /** native declaration : headers\openvr_capi.h:666 */ + public static final int EVRInputError_VRInputError_InvalidDevice = 9; + /** native declaration : headers\openvr_capi.h:667 */ + public static final int EVRInputError_VRInputError_InvalidSkeleton = 10; + /** native declaration : headers\openvr_capi.h:668 */ + public static final int EVRInputError_VRInputError_InvalidBoneCount = 11; + /** native declaration : headers\openvr_capi.h:669 */ + public static final int EVRInputError_VRInputError_InvalidCompressedData = 12; + /** native declaration : headers\openvr_capi.h:670 */ + public static final int EVRInputError_VRInputError_NoData = 13; + /** native declaration : headers\openvr_capi.h:671 */ + public static final int EVRInputError_VRInputError_BufferTooSmall = 14; + /** native declaration : headers\openvr_capi.h:672 */ + public static final int EVRInputError_VRInputError_MismatchedActionManifest = 15; + /** native declaration : headers\openvr_capi.h:673 */ + public static final int EVRInputError_VRInputError_MissingSkeletonData = 16; + }; + /** + * native declaration : headers\openvr_capi.h:690
        + * enum values + */ + public static interface EVRSpatialAnchorError { + /** native declaration : headers\openvr_capi.h:676 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Success = 0; + /** native declaration : headers\openvr_capi.h:677 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Internal = 1; + /** native declaration : headers\openvr_capi.h:678 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownHandle = 2; + /** native declaration : headers\openvr_capi.h:679 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_ArrayTooSmall = 3; + /** native declaration : headers\openvr_capi.h:680 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidDescriptorChar = 4; + /** native declaration : headers\openvr_capi.h:681 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotYetAvailable = 5; + /** native declaration : headers\openvr_capi.h:682 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NotAvailableInThisUniverse = 6; + /** native declaration : headers\openvr_capi.h:683 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_PermanentlyUnavailable = 7; + /** native declaration : headers\openvr_capi.h:684 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_WrongDriver = 8; + /** native declaration : headers\openvr_capi.h:685 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_DescriptorTooLong = 9; + /** native declaration : headers\openvr_capi.h:686 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_Unknown = 10; + /** native declaration : headers\openvr_capi.h:687 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_NoRoomCalibration = 11; + /** native declaration : headers\openvr_capi.h:688 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_InvalidArgument = 12; + /** native declaration : headers\openvr_capi.h:689 */ + public static final int EVRSpatialAnchorError_VRSpatialAnchorError_UnknownDriver = 13; + }; + /** + * native declaration : headers\openvr_capi.h:696
        + * enum values + */ + public static interface EHiddenAreaMeshType { + /** native declaration : headers\openvr_capi.h:692 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard = 0; + /** native declaration : headers\openvr_capi.h:693 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Inverse = 1; + /** native declaration : headers\openvr_capi.h:694 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_LineLoop = 2; + /** native declaration : headers\openvr_capi.h:695 */ + public static final int EHiddenAreaMeshType_k_eHiddenAreaMesh_Max = 3; + }; + /** + * native declaration : headers\openvr_capi.h:702
        + * enum values + */ + public static interface EVRControllerAxisType { + /** native declaration : headers\openvr_capi.h:698 */ + public static final int EVRControllerAxisType_k_eControllerAxis_None = 0; + /** native declaration : headers\openvr_capi.h:699 */ + public static final int EVRControllerAxisType_k_eControllerAxis_TrackPad = 1; + /** native declaration : headers\openvr_capi.h:700 */ + public static final int EVRControllerAxisType_k_eControllerAxis_Joystick = 2; + /** native declaration : headers\openvr_capi.h:701 */ + public static final int EVRControllerAxisType_k_eControllerAxis_Trigger = 3; + }; + /** + * native declaration : headers\openvr_capi.h:706
        + * enum values + */ + public static interface EVRControllerEventOutputType { + /** native declaration : headers\openvr_capi.h:704 */ + public static final int EVRControllerEventOutputType_ControllerEventOutput_OSEvents = 0; + /** native declaration : headers\openvr_capi.h:705 */ + public static final int EVRControllerEventOutputType_ControllerEventOutput_VREvents = 1; + }; + /** + * native declaration : headers\openvr_capi.h:714
        + * enum values + */ + public static interface ECollisionBoundsStyle { + /** native declaration : headers\openvr_capi.h:708 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_BEGINNER = 0; + /** native declaration : headers\openvr_capi.h:709 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_INTERMEDIATE = 1; + /** native declaration : headers\openvr_capi.h:710 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_SQUARES = 2; + /** native declaration : headers\openvr_capi.h:711 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_ADVANCED = 3; + /** native declaration : headers\openvr_capi.h:712 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_NONE = 4; + /** native declaration : headers\openvr_capi.h:713 */ + public static final int ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_COUNT = 5; + }; + /** + * native declaration : headers\openvr_capi.h:740
        + * enum values + */ + public static interface EVROverlayError { + /** native declaration : headers\openvr_capi.h:716 */ + public static final int EVROverlayError_VROverlayError_None = 0; + /** native declaration : headers\openvr_capi.h:717 */ + public static final int EVROverlayError_VROverlayError_UnknownOverlay = 10; + /** native declaration : headers\openvr_capi.h:718 */ + public static final int EVROverlayError_VROverlayError_InvalidHandle = 11; + /** native declaration : headers\openvr_capi.h:719 */ + public static final int EVROverlayError_VROverlayError_PermissionDenied = 12; + /** native declaration : headers\openvr_capi.h:720 */ + public static final int EVROverlayError_VROverlayError_OverlayLimitExceeded = 13; + /** native declaration : headers\openvr_capi.h:721 */ + public static final int EVROverlayError_VROverlayError_WrongVisibilityType = 14; + /** native declaration : headers\openvr_capi.h:722 */ + public static final int EVROverlayError_VROverlayError_KeyTooLong = 15; + /** native declaration : headers\openvr_capi.h:723 */ + public static final int EVROverlayError_VROverlayError_NameTooLong = 16; + /** native declaration : headers\openvr_capi.h:724 */ + public static final int EVROverlayError_VROverlayError_KeyInUse = 17; + /** native declaration : headers\openvr_capi.h:725 */ + public static final int EVROverlayError_VROverlayError_WrongTransformType = 18; + /** native declaration : headers\openvr_capi.h:726 */ + public static final int EVROverlayError_VROverlayError_InvalidTrackedDevice = 19; + /** native declaration : headers\openvr_capi.h:727 */ + public static final int EVROverlayError_VROverlayError_InvalidParameter = 20; + /** native declaration : headers\openvr_capi.h:728 */ + public static final int EVROverlayError_VROverlayError_ThumbnailCantBeDestroyed = 21; + /** native declaration : headers\openvr_capi.h:729 */ + public static final int EVROverlayError_VROverlayError_ArrayTooSmall = 22; + /** native declaration : headers\openvr_capi.h:730 */ + public static final int EVROverlayError_VROverlayError_RequestFailed = 23; + /** native declaration : headers\openvr_capi.h:731 */ + public static final int EVROverlayError_VROverlayError_InvalidTexture = 24; + /** native declaration : headers\openvr_capi.h:732 */ + public static final int EVROverlayError_VROverlayError_UnableToLoadFile = 25; + /** native declaration : headers\openvr_capi.h:733 */ + public static final int EVROverlayError_VROverlayError_KeyboardAlreadyInUse = 26; + /** native declaration : headers\openvr_capi.h:734 */ + public static final int EVROverlayError_VROverlayError_NoNeighbor = 27; + /** native declaration : headers\openvr_capi.h:735 */ + public static final int EVROverlayError_VROverlayError_TooManyMaskPrimitives = 29; + /** native declaration : headers\openvr_capi.h:736 */ + public static final int EVROverlayError_VROverlayError_BadMaskPrimitive = 30; + /** native declaration : headers\openvr_capi.h:737 */ + public static final int EVROverlayError_VROverlayError_TextureAlreadyLocked = 31; + /** native declaration : headers\openvr_capi.h:738 */ + public static final int EVROverlayError_VROverlayError_TextureLockCapacityReached = 32; + /** native declaration : headers\openvr_capi.h:739 */ + public static final int EVROverlayError_VROverlayError_TextureNotLocked = 33; + }; + /** + * native declaration : headers\openvr_capi.h:751
        + * enum values + */ + public static interface EVRApplicationType { + /** native declaration : headers\openvr_capi.h:742 */ + public static final int EVRApplicationType_VRApplication_Other = 0; + /** native declaration : headers\openvr_capi.h:743 */ + public static final int EVRApplicationType_VRApplication_Scene = 1; + /** native declaration : headers\openvr_capi.h:744 */ + public static final int EVRApplicationType_VRApplication_Overlay = 2; + /** native declaration : headers\openvr_capi.h:745 */ + public static final int EVRApplicationType_VRApplication_Background = 3; + /** native declaration : headers\openvr_capi.h:746 */ + public static final int EVRApplicationType_VRApplication_Utility = 4; + /** native declaration : headers\openvr_capi.h:747 */ + public static final int EVRApplicationType_VRApplication_VRMonitor = 5; + /** native declaration : headers\openvr_capi.h:748 */ + public static final int EVRApplicationType_VRApplication_SteamWatchdog = 6; + /** native declaration : headers\openvr_capi.h:749 */ + public static final int EVRApplicationType_VRApplication_Bootstrapper = 7; + /** native declaration : headers\openvr_capi.h:750 */ + public static final int EVRApplicationType_VRApplication_Max = 8; + }; + /** + * native declaration : headers\openvr_capi.h:756
        + * enum values + */ + public static interface EVRFirmwareError { + /** native declaration : headers\openvr_capi.h:753 */ + public static final int EVRFirmwareError_VRFirmwareError_None = 0; + /** native declaration : headers\openvr_capi.h:754 */ + public static final int EVRFirmwareError_VRFirmwareError_Success = 1; + /** native declaration : headers\openvr_capi.h:755 */ + public static final int EVRFirmwareError_VRFirmwareError_Fail = 2; + }; + /** + * native declaration : headers\openvr_capi.h:763
        + * enum values + */ + public static interface EVRNotificationError { + /** native declaration : headers\openvr_capi.h:758 */ + public static final int EVRNotificationError_VRNotificationError_OK = 0; + /** native declaration : headers\openvr_capi.h:759 */ + public static final int EVRNotificationError_VRNotificationError_InvalidNotificationId = 100; + /** native declaration : headers\openvr_capi.h:760 */ + public static final int EVRNotificationError_VRNotificationError_NotificationQueueFull = 101; + /** native declaration : headers\openvr_capi.h:761 */ + public static final int EVRNotificationError_VRNotificationError_InvalidOverlayHandle = 102; + /** native declaration : headers\openvr_capi.h:762 */ + public static final int EVRNotificationError_VRNotificationError_SystemWithUserValueAlreadyExists = 103; + }; + /** + * native declaration : headers\openvr_capi.h:767
        + * enum values + */ + public static interface EVRSkeletalMotionRange { + /** native declaration : headers\openvr_capi.h:765 */ + public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithController = 0; + /** native declaration : headers\openvr_capi.h:766 */ + public static final int EVRSkeletalMotionRange_VRSkeletalMotionRange_WithoutController = 1; + }; + /** + * native declaration : headers\openvr_capi.h:857
        + * enum values + */ + public static interface EVRInitError { + /** native declaration : headers\openvr_capi.h:769 */ + public static final int EVRInitError_VRInitError_None = 0; + /** native declaration : headers\openvr_capi.h:770 */ + public static final int EVRInitError_VRInitError_Unknown = 1; + /** native declaration : headers\openvr_capi.h:771 */ + public static final int EVRInitError_VRInitError_Init_InstallationNotFound = 100; + /** native declaration : headers\openvr_capi.h:772 */ + public static final int EVRInitError_VRInitError_Init_InstallationCorrupt = 101; + /** native declaration : headers\openvr_capi.h:773 */ + public static final int EVRInitError_VRInitError_Init_VRClientDLLNotFound = 102; + /** native declaration : headers\openvr_capi.h:774 */ + public static final int EVRInitError_VRInitError_Init_FileNotFound = 103; + /** native declaration : headers\openvr_capi.h:775 */ + public static final int EVRInitError_VRInitError_Init_FactoryNotFound = 104; + /** native declaration : headers\openvr_capi.h:776 */ + public static final int EVRInitError_VRInitError_Init_InterfaceNotFound = 105; + /** native declaration : headers\openvr_capi.h:777 */ + public static final int EVRInitError_VRInitError_Init_InvalidInterface = 106; + /** native declaration : headers\openvr_capi.h:778 */ + public static final int EVRInitError_VRInitError_Init_UserConfigDirectoryInvalid = 107; + /** native declaration : headers\openvr_capi.h:779 */ + public static final int EVRInitError_VRInitError_Init_HmdNotFound = 108; + /** native declaration : headers\openvr_capi.h:780 */ + public static final int EVRInitError_VRInitError_Init_NotInitialized = 109; + /** native declaration : headers\openvr_capi.h:781 */ + public static final int EVRInitError_VRInitError_Init_PathRegistryNotFound = 110; + /** native declaration : headers\openvr_capi.h:782 */ + public static final int EVRInitError_VRInitError_Init_NoConfigPath = 111; + /** native declaration : headers\openvr_capi.h:783 */ + public static final int EVRInitError_VRInitError_Init_NoLogPath = 112; + /** native declaration : headers\openvr_capi.h:784 */ + public static final int EVRInitError_VRInitError_Init_PathRegistryNotWritable = 113; + /** native declaration : headers\openvr_capi.h:785 */ + public static final int EVRInitError_VRInitError_Init_AppInfoInitFailed = 114; + /** native declaration : headers\openvr_capi.h:786 */ + public static final int EVRInitError_VRInitError_Init_Retry = 115; + /** native declaration : headers\openvr_capi.h:787 */ + public static final int EVRInitError_VRInitError_Init_InitCanceledByUser = 116; + /** native declaration : headers\openvr_capi.h:788 */ + public static final int EVRInitError_VRInitError_Init_AnotherAppLaunching = 117; + /** native declaration : headers\openvr_capi.h:789 */ + public static final int EVRInitError_VRInitError_Init_SettingsInitFailed = 118; + /** native declaration : headers\openvr_capi.h:790 */ + public static final int EVRInitError_VRInitError_Init_ShuttingDown = 119; + /** native declaration : headers\openvr_capi.h:791 */ + public static final int EVRInitError_VRInitError_Init_TooManyObjects = 120; + /** native declaration : headers\openvr_capi.h:792 */ + public static final int EVRInitError_VRInitError_Init_NoServerForBackgroundApp = 121; + /** native declaration : headers\openvr_capi.h:793 */ + public static final int EVRInitError_VRInitError_Init_NotSupportedWithCompositor = 122; + /** native declaration : headers\openvr_capi.h:794 */ + public static final int EVRInitError_VRInitError_Init_NotAvailableToUtilityApps = 123; + /** native declaration : headers\openvr_capi.h:795 */ + public static final int EVRInitError_VRInitError_Init_Internal = 124; + /** native declaration : headers\openvr_capi.h:796 */ + public static final int EVRInitError_VRInitError_Init_HmdDriverIdIsNone = 125; + /** native declaration : headers\openvr_capi.h:797 */ + public static final int EVRInitError_VRInitError_Init_HmdNotFoundPresenceFailed = 126; + /** native declaration : headers\openvr_capi.h:798 */ + public static final int EVRInitError_VRInitError_Init_VRMonitorNotFound = 127; + /** native declaration : headers\openvr_capi.h:799 */ + public static final int EVRInitError_VRInitError_Init_VRMonitorStartupFailed = 128; + /** native declaration : headers\openvr_capi.h:800 */ + public static final int EVRInitError_VRInitError_Init_LowPowerWatchdogNotSupported = 129; + /** native declaration : headers\openvr_capi.h:801 */ + public static final int EVRInitError_VRInitError_Init_InvalidApplicationType = 130; + /** native declaration : headers\openvr_capi.h:802 */ + public static final int EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps = 131; + /** native declaration : headers\openvr_capi.h:803 */ + public static final int EVRInitError_VRInitError_Init_WatchdogDisabledInSettings = 132; + /** native declaration : headers\openvr_capi.h:804 */ + public static final int EVRInitError_VRInitError_Init_VRDashboardNotFound = 133; + /** native declaration : headers\openvr_capi.h:805 */ + public static final int EVRInitError_VRInitError_Init_VRDashboardStartupFailed = 134; + /** native declaration : headers\openvr_capi.h:806 */ + public static final int EVRInitError_VRInitError_Init_VRHomeNotFound = 135; + /** native declaration : headers\openvr_capi.h:807 */ + public static final int EVRInitError_VRInitError_Init_VRHomeStartupFailed = 136; + /** native declaration : headers\openvr_capi.h:808 */ + public static final int EVRInitError_VRInitError_Init_RebootingBusy = 137; + /** native declaration : headers\openvr_capi.h:809 */ + public static final int EVRInitError_VRInitError_Init_FirmwareUpdateBusy = 138; + /** native declaration : headers\openvr_capi.h:810 */ + public static final int EVRInitError_VRInitError_Init_FirmwareRecoveryBusy = 139; + /** native declaration : headers\openvr_capi.h:811 */ + public static final int EVRInitError_VRInitError_Init_USBServiceBusy = 140; + /** native declaration : headers\openvr_capi.h:812 */ + public static final int EVRInitError_VRInitError_Init_VRWebHelperStartupFailed = 141; + /** native declaration : headers\openvr_capi.h:813 */ + public static final int EVRInitError_VRInitError_Init_TrackerManagerInitFailed = 142; + /** native declaration : headers\openvr_capi.h:814 */ + public static final int EVRInitError_VRInitError_Driver_Failed = 200; + /** native declaration : headers\openvr_capi.h:815 */ + public static final int EVRInitError_VRInitError_Driver_Unknown = 201; + /** native declaration : headers\openvr_capi.h:816 */ + public static final int EVRInitError_VRInitError_Driver_HmdUnknown = 202; + /** native declaration : headers\openvr_capi.h:817 */ + public static final int EVRInitError_VRInitError_Driver_NotLoaded = 203; + /** native declaration : headers\openvr_capi.h:818 */ + public static final int EVRInitError_VRInitError_Driver_RuntimeOutOfDate = 204; + /** native declaration : headers\openvr_capi.h:819 */ + public static final int EVRInitError_VRInitError_Driver_HmdInUse = 205; + /** native declaration : headers\openvr_capi.h:820 */ + public static final int EVRInitError_VRInitError_Driver_NotCalibrated = 206; + /** native declaration : headers\openvr_capi.h:821 */ + public static final int EVRInitError_VRInitError_Driver_CalibrationInvalid = 207; + /** native declaration : headers\openvr_capi.h:822 */ + public static final int EVRInitError_VRInitError_Driver_HmdDisplayNotFound = 208; + /** native declaration : headers\openvr_capi.h:823 */ + public static final int EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209; + /** native declaration : headers\openvr_capi.h:824 */ + public static final int EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds = 211; + /** native declaration : headers\openvr_capi.h:825 */ + public static final int EVRInitError_VRInitError_Driver_HmdDisplayMirrored = 212; + /** native declaration : headers\openvr_capi.h:826 */ + public static final int EVRInitError_VRInitError_IPC_ServerInitFailed = 300; + /** native declaration : headers\openvr_capi.h:827 */ + public static final int EVRInitError_VRInitError_IPC_ConnectFailed = 301; + /** native declaration : headers\openvr_capi.h:828 */ + public static final int EVRInitError_VRInitError_IPC_SharedStateInitFailed = 302; + /** native declaration : headers\openvr_capi.h:829 */ + public static final int EVRInitError_VRInitError_IPC_CompositorInitFailed = 303; + /** native declaration : headers\openvr_capi.h:830 */ + public static final int EVRInitError_VRInitError_IPC_MutexInitFailed = 304; + /** native declaration : headers\openvr_capi.h:831 */ + public static final int EVRInitError_VRInitError_IPC_Failed = 305; + /** native declaration : headers\openvr_capi.h:832 */ + public static final int EVRInitError_VRInitError_IPC_CompositorConnectFailed = 306; + /** native declaration : headers\openvr_capi.h:833 */ + public static final int EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse = 307; + /** native declaration : headers\openvr_capi.h:834 */ + public static final int EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308; + /** native declaration : headers\openvr_capi.h:835 */ + public static final int EVRInitError_VRInitError_Compositor_Failed = 400; + /** native declaration : headers\openvr_capi.h:836 */ + public static final int EVRInitError_VRInitError_Compositor_D3D11HardwareRequired = 401; + /** native declaration : headers\openvr_capi.h:837 */ + public static final int EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate = 402; + /** native declaration : headers\openvr_capi.h:838 */ + public static final int EVRInitError_VRInitError_Compositor_OverlayInitFailed = 403; + /** native declaration : headers\openvr_capi.h:839 */ + public static final int EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed = 404; + /** native declaration : headers\openvr_capi.h:840 */ + public static final int EVRInitError_VRInitError_Compositor_UnableToCreateDevice = 405; + /** native declaration : headers\openvr_capi.h:841 */ + public static final int EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000; + /** native declaration : headers\openvr_capi.h:842 */ + public static final int EVRInitError_VRInitError_VendorSpecific_WindowsNotInDevMode = 1001; + /** native declaration : headers\openvr_capi.h:843 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101; + /** native declaration : headers\openvr_capi.h:844 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102; + /** native declaration : headers\openvr_capi.h:845 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103; + /** native declaration : headers\openvr_capi.h:846 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104; + /** native declaration : headers\openvr_capi.h:847 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105; + /** native declaration : headers\openvr_capi.h:848 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106; + /** native declaration : headers\openvr_capi.h:849 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107; + /** native declaration : headers\openvr_capi.h:850 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108; + /** native declaration : headers\openvr_capi.h:851 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109; + /** native declaration : headers\openvr_capi.h:852 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110; + /** native declaration : headers\openvr_capi.h:853 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111; + /** native declaration : headers\openvr_capi.h:854 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError = 1112; + /** native declaration : headers\openvr_capi.h:855 */ + public static final int EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113; + /** native declaration : headers\openvr_capi.h:856 */ + public static final int EVRInitError_VRInitError_Steam_SteamInstallationNotFound = 2000; + }; + /** + * native declaration : headers\openvr_capi.h:865
        + * enum values + */ + public static interface EVRScreenshotType { + /** native declaration : headers\openvr_capi.h:859 */ + public static final int EVRScreenshotType_VRScreenshotType_None = 0; + /** native declaration : headers\openvr_capi.h:860 */ + public static final int EVRScreenshotType_VRScreenshotType_Mono = 1; + /** native declaration : headers\openvr_capi.h:861 */ + public static final int EVRScreenshotType_VRScreenshotType_Stereo = 2; + /** native declaration : headers\openvr_capi.h:862 */ + public static final int EVRScreenshotType_VRScreenshotType_Cubemap = 3; + /** native declaration : headers\openvr_capi.h:863 */ + public static final int EVRScreenshotType_VRScreenshotType_MonoPanorama = 4; + /** native declaration : headers\openvr_capi.h:864 */ + public static final int EVRScreenshotType_VRScreenshotType_StereoPanorama = 5; + }; + /** + * native declaration : headers\openvr_capi.h:869
        + * enum values + */ + public static interface EVRScreenshotPropertyFilenames { + /** native declaration : headers\openvr_capi.h:867 */ + public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_Preview = 0; + /** native declaration : headers\openvr_capi.h:868 */ + public static final int EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_VR = 1; + }; + /** + * native declaration : headers\openvr_capi.h:888
        + * enum values + */ + public static interface EVRTrackedCameraError { + /** native declaration : headers\openvr_capi.h:871 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_None = 0; + /** native declaration : headers\openvr_capi.h:872 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_OperationFailed = 100; + /** native declaration : headers\openvr_capi.h:873 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidHandle = 101; + /** native declaration : headers\openvr_capi.h:874 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameHeaderVersion = 102; + /** native declaration : headers\openvr_capi.h:875 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_OutOfHandles = 103; + /** native declaration : headers\openvr_capi.h:876 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_IPCFailure = 104; + /** native declaration : headers\openvr_capi.h:877 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_NotSupportedForThisDevice = 105; + /** native declaration : headers\openvr_capi.h:878 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedMemoryFailure = 106; + /** native declaration : headers\openvr_capi.h:879 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_FrameBufferingFailure = 107; + /** native declaration : headers\openvr_capi.h:880 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_StreamSetupFailure = 108; + /** native declaration : headers\openvr_capi.h:881 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidGLTextureId = 109; + /** native declaration : headers\openvr_capi.h:882 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidSharedTextureHandle = 110; + /** native declaration : headers\openvr_capi.h:883 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_FailedToGetGLTextureId = 111; + /** native declaration : headers\openvr_capi.h:884 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_SharedTextureFailure = 112; + /** native declaration : headers\openvr_capi.h:885 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_NoFrameAvailable = 113; + /** native declaration : headers\openvr_capi.h:886 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidArgument = 114; + /** native declaration : headers\openvr_capi.h:887 */ + public static final int EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameBufferSize = 115; + }; + /** + * native declaration : headers\openvr_capi.h:894
        + * enum values + */ + public static interface EVRTrackedCameraFrameLayout { + /** native declaration : headers\openvr_capi.h:890 */ + public static final int EVRTrackedCameraFrameLayout_Mono = 1; + /** native declaration : headers\openvr_capi.h:891 */ + public static final int EVRTrackedCameraFrameLayout_Stereo = 2; + /** native declaration : headers\openvr_capi.h:892 */ + public static final int EVRTrackedCameraFrameLayout_VerticalLayout = 16; + /** native declaration : headers\openvr_capi.h:893 */ + public static final int EVRTrackedCameraFrameLayout_HorizontalLayout = 32; + }; + /** + * native declaration : headers\openvr_capi.h:900
        + * enum values + */ + public static interface EVRTrackedCameraFrameType { + /** native declaration : headers\openvr_capi.h:896 */ + public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Distorted = 0; + /** native declaration : headers\openvr_capi.h:897 */ + public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Undistorted = 1; + /** native declaration : headers\openvr_capi.h:898 */ + public static final int EVRTrackedCameraFrameType_VRTrackedCameraFrameType_MaximumUndistorted = 2; + /** native declaration : headers\openvr_capi.h:899 */ + public static final int EVRTrackedCameraFrameType_MAX_CAMERA_FRAME_TYPES = 3; + }; + /** + * native declaration : headers\openvr_capi.h:905
        + * enum values + */ + public static interface EVSync { + /** native declaration : headers\openvr_capi.h:902 */ + public static final int EVSync_VSync_None = 0; + /** native declaration : headers\openvr_capi.h:903 */ + public static final int EVSync_VSync_WaitRender = 1; + /** native declaration : headers\openvr_capi.h:904 */ + public static final int EVSync_VSync_NoWaitRender = 2; + }; + /** + * native declaration : headers\openvr_capi.h:909
        + * enum values + */ + public static interface EVRMuraCorrectionMode { + /** native declaration : headers\openvr_capi.h:907 */ + public static final int EVRMuraCorrectionMode_Default = 0; + /** native declaration : headers\openvr_capi.h:908 */ + public static final int EVRMuraCorrectionMode_NoCorrection = 1; + }; + /** + * native declaration : headers\openvr_capi.h:917
        + * enum values + */ + public static interface Imu_OffScaleFlags { + /** native declaration : headers\openvr_capi.h:911 */ + public static final int Imu_OffScaleFlags_OffScale_AccelX = 1; + /** native declaration : headers\openvr_capi.h:912 */ + public static final int Imu_OffScaleFlags_OffScale_AccelY = 2; + /** native declaration : headers\openvr_capi.h:913 */ + public static final int Imu_OffScaleFlags_OffScale_AccelZ = 4; + /** native declaration : headers\openvr_capi.h:914 */ + public static final int Imu_OffScaleFlags_OffScale_GyroX = 8; + /** native declaration : headers\openvr_capi.h:915 */ + public static final int Imu_OffScaleFlags_OffScale_GyroY = 16; + /** native declaration : headers\openvr_capi.h:916 */ + public static final int Imu_OffScaleFlags_OffScale_GyroZ = 32; + }; + /** + * native declaration : headers\openvr_capi.h:940
        + * enum values + */ + public static interface EVRApplicationError { + /** native declaration : headers\openvr_capi.h:919 */ + public static final int EVRApplicationError_VRApplicationError_None = 0; + /** native declaration : headers\openvr_capi.h:920 */ + public static final int EVRApplicationError_VRApplicationError_AppKeyAlreadyExists = 100; + /** native declaration : headers\openvr_capi.h:921 */ + public static final int EVRApplicationError_VRApplicationError_NoManifest = 101; + /** native declaration : headers\openvr_capi.h:922 */ + public static final int EVRApplicationError_VRApplicationError_NoApplication = 102; + /** native declaration : headers\openvr_capi.h:923 */ + public static final int EVRApplicationError_VRApplicationError_InvalidIndex = 103; + /** native declaration : headers\openvr_capi.h:924 */ + public static final int EVRApplicationError_VRApplicationError_UnknownApplication = 104; + /** native declaration : headers\openvr_capi.h:925 */ + public static final int EVRApplicationError_VRApplicationError_IPCFailed = 105; + /** native declaration : headers\openvr_capi.h:926 */ + public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyRunning = 106; + /** native declaration : headers\openvr_capi.h:927 */ + public static final int EVRApplicationError_VRApplicationError_InvalidManifest = 107; + /** native declaration : headers\openvr_capi.h:928 */ + public static final int EVRApplicationError_VRApplicationError_InvalidApplication = 108; + /** native declaration : headers\openvr_capi.h:929 */ + public static final int EVRApplicationError_VRApplicationError_LaunchFailed = 109; + /** native declaration : headers\openvr_capi.h:930 */ + public static final int EVRApplicationError_VRApplicationError_ApplicationAlreadyStarting = 110; + /** native declaration : headers\openvr_capi.h:931 */ + public static final int EVRApplicationError_VRApplicationError_LaunchInProgress = 111; + /** native declaration : headers\openvr_capi.h:932 */ + public static final int EVRApplicationError_VRApplicationError_OldApplicationQuitting = 112; + /** native declaration : headers\openvr_capi.h:933 */ + public static final int EVRApplicationError_VRApplicationError_TransitionAborted = 113; + /** native declaration : headers\openvr_capi.h:934 */ + public static final int EVRApplicationError_VRApplicationError_IsTemplate = 114; + /** native declaration : headers\openvr_capi.h:935 */ + public static final int EVRApplicationError_VRApplicationError_SteamVRIsExiting = 115; + /** native declaration : headers\openvr_capi.h:936 */ + public static final int EVRApplicationError_VRApplicationError_BufferTooSmall = 200; + /** native declaration : headers\openvr_capi.h:937 */ + public static final int EVRApplicationError_VRApplicationError_PropertyNotSet = 201; + /** native declaration : headers\openvr_capi.h:938 */ + public static final int EVRApplicationError_VRApplicationError_UnknownProperty = 202; + /** native declaration : headers\openvr_capi.h:939 */ + public static final int EVRApplicationError_VRApplicationError_InvalidParameter = 203; + }; + /** + * native declaration : headers\openvr_capi.h:959
        + * enum values + */ + public static interface EVRApplicationProperty { + /** native declaration : headers\openvr_capi.h:942 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Name_String = 0; + /** native declaration : headers\openvr_capi.h:943 */ + public static final int EVRApplicationProperty_VRApplicationProperty_LaunchType_String = 11; + /** native declaration : headers\openvr_capi.h:944 */ + public static final int EVRApplicationProperty_VRApplicationProperty_WorkingDirectory_String = 12; + /** native declaration : headers\openvr_capi.h:945 */ + public static final int EVRApplicationProperty_VRApplicationProperty_BinaryPath_String = 13; + /** native declaration : headers\openvr_capi.h:946 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Arguments_String = 14; + /** native declaration : headers\openvr_capi.h:947 */ + public static final int EVRApplicationProperty_VRApplicationProperty_URL_String = 15; + /** native declaration : headers\openvr_capi.h:948 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Description_String = 50; + /** native declaration : headers\openvr_capi.h:949 */ + public static final int EVRApplicationProperty_VRApplicationProperty_NewsURL_String = 51; + /** native declaration : headers\openvr_capi.h:950 */ + public static final int EVRApplicationProperty_VRApplicationProperty_ImagePath_String = 52; + /** native declaration : headers\openvr_capi.h:951 */ + public static final int EVRApplicationProperty_VRApplicationProperty_Source_String = 53; + /** native declaration : headers\openvr_capi.h:952 */ + public static final int EVRApplicationProperty_VRApplicationProperty_ActionManifestURL_String = 54; + /** native declaration : headers\openvr_capi.h:953 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsDashboardOverlay_Bool = 60; + /** native declaration : headers\openvr_capi.h:954 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsTemplate_Bool = 61; + /** native declaration : headers\openvr_capi.h:955 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsInstanced_Bool = 62; + /** native declaration : headers\openvr_capi.h:956 */ + public static final int EVRApplicationProperty_VRApplicationProperty_IsInternal_Bool = 63; + /** native declaration : headers\openvr_capi.h:957 */ + public static final int EVRApplicationProperty_VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64; + /** native declaration : headers\openvr_capi.h:958 */ + public static final int EVRApplicationProperty_VRApplicationProperty_LastLaunchTime_Uint64 = 70; + }; + /** + * native declaration : headers\openvr_capi.h:965
        + * enum values + */ + public static interface EVRApplicationTransitionState { + /** native declaration : headers\openvr_capi.h:961 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_None = 0; + /** native declaration : headers\openvr_capi.h:962 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_OldAppQuitSent = 10; + /** native declaration : headers\openvr_capi.h:963 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_WaitingForExternalLaunch = 11; + /** native declaration : headers\openvr_capi.h:964 */ + public static final int EVRApplicationTransitionState_VRApplicationTransition_NewAppLaunched = 20; + }; + /** + * native declaration : headers\openvr_capi.h:977
        + * enum values + */ + public static interface ChaperoneCalibrationState { + /** native declaration : headers\openvr_capi.h:967 */ + public static final int ChaperoneCalibrationState_OK = 1; + /** native declaration : headers\openvr_capi.h:968 */ + public static final int ChaperoneCalibrationState_Warning = 100; + /** native declaration : headers\openvr_capi.h:969 */ + public static final int ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101; + /** native declaration : headers\openvr_capi.h:970 */ + public static final int ChaperoneCalibrationState_Warning_BaseStationRemoved = 102; + /** native declaration : headers\openvr_capi.h:971 */ + public static final int ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103; + /** native declaration : headers\openvr_capi.h:972 */ + public static final int ChaperoneCalibrationState_Error = 200; + /** native declaration : headers\openvr_capi.h:973 */ + public static final int ChaperoneCalibrationState_Error_BaseStationUninitialized = 201; + /** native declaration : headers\openvr_capi.h:974 */ + public static final int ChaperoneCalibrationState_Error_BaseStationConflict = 202; + /** native declaration : headers\openvr_capi.h:975 */ + public static final int ChaperoneCalibrationState_Error_PlayAreaInvalid = 203; + /** native declaration : headers\openvr_capi.h:976 */ + public static final int ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204; + }; + /** + * native declaration : headers\openvr_capi.h:981
        + * enum values + */ + public static interface EChaperoneConfigFile { + /** native declaration : headers\openvr_capi.h:979 */ + public static final int EChaperoneConfigFile_Live = 1; + /** native declaration : headers\openvr_capi.h:980 */ + public static final int EChaperoneConfigFile_Temp = 2; + }; + /** + * native declaration : headers\openvr_capi.h:984
        + * enum values + */ + public static interface EChaperoneImportFlags { + /** native declaration : headers\openvr_capi.h:983 */ + public static final int EChaperoneImportFlags_EChaperoneImport_BoundsOnly = 1; + }; + /** + * native declaration : headers\openvr_capi.h:998
        + * enum values + */ + public static interface EVRCompositorError { + /** native declaration : headers\openvr_capi.h:986 */ + public static final int EVRCompositorError_VRCompositorError_None = 0; + /** native declaration : headers\openvr_capi.h:987 */ + public static final int EVRCompositorError_VRCompositorError_RequestFailed = 1; + /** native declaration : headers\openvr_capi.h:988 */ + public static final int EVRCompositorError_VRCompositorError_IncompatibleVersion = 100; + /** native declaration : headers\openvr_capi.h:989 */ + public static final int EVRCompositorError_VRCompositorError_DoNotHaveFocus = 101; + /** native declaration : headers\openvr_capi.h:990 */ + public static final int EVRCompositorError_VRCompositorError_InvalidTexture = 102; + /** native declaration : headers\openvr_capi.h:991 */ + public static final int EVRCompositorError_VRCompositorError_IsNotSceneApplication = 103; + /** native declaration : headers\openvr_capi.h:992 */ + public static final int EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice = 104; + /** native declaration : headers\openvr_capi.h:993 */ + public static final int EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat = 105; + /** native declaration : headers\openvr_capi.h:994 */ + public static final int EVRCompositorError_VRCompositorError_SharedTexturesNotSupported = 106; + /** native declaration : headers\openvr_capi.h:995 */ + public static final int EVRCompositorError_VRCompositorError_IndexOutOfRange = 107; + /** native declaration : headers\openvr_capi.h:996 */ + public static final int EVRCompositorError_VRCompositorError_AlreadySubmitted = 108; + /** native declaration : headers\openvr_capi.h:997 */ + public static final int EVRCompositorError_VRCompositorError_InvalidBounds = 109; + }; + /** + * native declaration : headers\openvr_capi.h:1003
        + * enum values + */ + public static interface EVRCompositorTimingMode { + /** native declaration : headers\openvr_capi.h:1000 */ + public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Implicit = 0; + /** native declaration : headers\openvr_capi.h:1001 */ + public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1; + /** native declaration : headers\openvr_capi.h:1002 */ + public static final int EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1008
        + * enum values + */ + public static interface VROverlayInputMethod { + /** native declaration : headers\openvr_capi.h:1005 */ + public static final int VROverlayInputMethod_None = 0; + /** native declaration : headers\openvr_capi.h:1006 */ + public static final int VROverlayInputMethod_Mouse = 1; + /** native declaration : headers\openvr_capi.h:1007 */ + public static final int VROverlayInputMethod_DualAnalog = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1014
        + * enum values + */ + public static interface VROverlayTransformType { + /** native declaration : headers\openvr_capi.h:1010 */ + public static final int VROverlayTransformType_VROverlayTransform_Absolute = 0; + /** native declaration : headers\openvr_capi.h:1011 */ + public static final int VROverlayTransformType_VROverlayTransform_TrackedDeviceRelative = 1; + /** native declaration : headers\openvr_capi.h:1012 */ + public static final int VROverlayTransformType_VROverlayTransform_SystemOverlay = 2; + /** native declaration : headers\openvr_capi.h:1013 */ + public static final int VROverlayTransformType_VROverlayTransform_TrackedComponent = 3; + }; + /** + * native declaration : headers\openvr_capi.h:1032
        + * enum values + */ + public static interface VROverlayFlags { + /** native declaration : headers\openvr_capi.h:1016 */ + public static final int VROverlayFlags_None = 0; + /** native declaration : headers\openvr_capi.h:1017 */ + public static final int VROverlayFlags_Curved = 1; + /** native declaration : headers\openvr_capi.h:1018 */ + public static final int VROverlayFlags_RGSS4X = 2; + /** native declaration : headers\openvr_capi.h:1019 */ + public static final int VROverlayFlags_NoDashboardTab = 3; + /** native declaration : headers\openvr_capi.h:1020 */ + public static final int VROverlayFlags_AcceptsGamepadEvents = 4; + /** native declaration : headers\openvr_capi.h:1021 */ + public static final int VROverlayFlags_ShowGamepadFocus = 5; + /** native declaration : headers\openvr_capi.h:1022 */ + public static final int VROverlayFlags_SendVRScrollEvents = 6; + /** native declaration : headers\openvr_capi.h:1023 */ + public static final int VROverlayFlags_SendVRTouchpadEvents = 7; + /** native declaration : headers\openvr_capi.h:1024 */ + public static final int VROverlayFlags_ShowTouchPadScrollWheel = 8; + /** native declaration : headers\openvr_capi.h:1025 */ + public static final int VROverlayFlags_TransferOwnershipToInternalProcess = 9; + /** native declaration : headers\openvr_capi.h:1026 */ + public static final int VROverlayFlags_SideBySide_Parallel = 10; + /** native declaration : headers\openvr_capi.h:1027 */ + public static final int VROverlayFlags_SideBySide_Crossed = 11; + /** native declaration : headers\openvr_capi.h:1028 */ + public static final int VROverlayFlags_Panorama = 12; + /** native declaration : headers\openvr_capi.h:1029 */ + public static final int VROverlayFlags_StereoPanorama = 13; + /** native declaration : headers\openvr_capi.h:1030 */ + public static final int VROverlayFlags_SortWithNonSceneOverlays = 14; + /** native declaration : headers\openvr_capi.h:1031 */ + public static final int VROverlayFlags_VisibleInDashboard = 15; + }; + /** + * native declaration : headers\openvr_capi.h:1041
        + * enum values + */ + public static interface VRMessageOverlayResponse { + /** native declaration : headers\openvr_capi.h:1034 */ + public static final int VRMessageOverlayResponse_ButtonPress_0 = 0; + /** native declaration : headers\openvr_capi.h:1035 */ + public static final int VRMessageOverlayResponse_ButtonPress_1 = 1; + /** native declaration : headers\openvr_capi.h:1036 */ + public static final int VRMessageOverlayResponse_ButtonPress_2 = 2; + /** native declaration : headers\openvr_capi.h:1037 */ + public static final int VRMessageOverlayResponse_ButtonPress_3 = 3; + /** native declaration : headers\openvr_capi.h:1038 */ + public static final int VRMessageOverlayResponse_CouldntFindSystemOverlay = 4; + /** native declaration : headers\openvr_capi.h:1039 */ + public static final int VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5; + /** native declaration : headers\openvr_capi.h:1040 */ + public static final int VRMessageOverlayResponse_ApplicationQuit = 6; + }; + /** + * native declaration : headers\openvr_capi.h:1046
        + * enum values + */ + public static interface EGamepadTextInputMode { + /** native declaration : headers\openvr_capi.h:1043 */ + public static final int EGamepadTextInputMode_k_EGamepadTextInputModeNormal = 0; + /** native declaration : headers\openvr_capi.h:1044 */ + public static final int EGamepadTextInputMode_k_EGamepadTextInputModePassword = 1; + /** native declaration : headers\openvr_capi.h:1045 */ + public static final int EGamepadTextInputMode_k_EGamepadTextInputModeSubmit = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1050
        + * enum values + */ + public static interface EGamepadTextInputLineMode { + /** native declaration : headers\openvr_capi.h:1048 */ + public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeSingleLine = 0; + /** native declaration : headers\openvr_capi.h:1049 */ + public static final int EGamepadTextInputLineMode_k_EGamepadTextInputLineModeMultipleLines = 1; + }; + /** + * native declaration : headers\openvr_capi.h:1057
        + * enum values + */ + public static interface EOverlayDirection { + /** native declaration : headers\openvr_capi.h:1052 */ + public static final int EOverlayDirection_OverlayDirection_Up = 0; + /** native declaration : headers\openvr_capi.h:1053 */ + public static final int EOverlayDirection_OverlayDirection_Down = 1; + /** native declaration : headers\openvr_capi.h:1054 */ + public static final int EOverlayDirection_OverlayDirection_Left = 2; + /** native declaration : headers\openvr_capi.h:1055 */ + public static final int EOverlayDirection_OverlayDirection_Right = 3; + /** native declaration : headers\openvr_capi.h:1056 */ + public static final int EOverlayDirection_OverlayDirection_Count = 4; + }; + /** + * native declaration : headers\openvr_capi.h:1061
        + * enum values + */ + public static interface EVROverlayIntersectionMaskPrimitiveType { + /** native declaration : headers\openvr_capi.h:1059 */ + public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Rectangle = 0; + /** native declaration : headers\openvr_capi.h:1060 */ + public static final int EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Circle = 1; + }; + /** + * native declaration : headers\openvr_capi.h:1076
        + * enum values + */ + public static interface EVRRenderModelError { + /** native declaration : headers\openvr_capi.h:1063 */ + public static final int EVRRenderModelError_VRRenderModelError_None = 0; + /** native declaration : headers\openvr_capi.h:1064 */ + public static final int EVRRenderModelError_VRRenderModelError_Loading = 100; + /** native declaration : headers\openvr_capi.h:1065 */ + public static final int EVRRenderModelError_VRRenderModelError_NotSupported = 200; + /** native declaration : headers\openvr_capi.h:1066 */ + public static final int EVRRenderModelError_VRRenderModelError_InvalidArg = 300; + /** native declaration : headers\openvr_capi.h:1067 */ + public static final int EVRRenderModelError_VRRenderModelError_InvalidModel = 301; + /** native declaration : headers\openvr_capi.h:1068 */ + public static final int EVRRenderModelError_VRRenderModelError_NoShapes = 302; + /** native declaration : headers\openvr_capi.h:1069 */ + public static final int EVRRenderModelError_VRRenderModelError_MultipleShapes = 303; + /** native declaration : headers\openvr_capi.h:1070 */ + public static final int EVRRenderModelError_VRRenderModelError_TooManyVertices = 304; + /** native declaration : headers\openvr_capi.h:1071 */ + public static final int EVRRenderModelError_VRRenderModelError_MultipleTextures = 305; + /** native declaration : headers\openvr_capi.h:1072 */ + public static final int EVRRenderModelError_VRRenderModelError_BufferTooSmall = 306; + /** native declaration : headers\openvr_capi.h:1073 */ + public static final int EVRRenderModelError_VRRenderModelError_NotEnoughNormals = 307; + /** native declaration : headers\openvr_capi.h:1074 */ + public static final int EVRRenderModelError_VRRenderModelError_NotEnoughTexCoords = 308; + /** native declaration : headers\openvr_capi.h:1075 */ + public static final int EVRRenderModelError_VRRenderModelError_InvalidTexture = 400; + }; + /** + * native declaration : headers\openvr_capi.h:1083
        + * enum values + */ + public static interface EVRComponentProperty { + /** native declaration : headers\openvr_capi.h:1078 */ + public static final int EVRComponentProperty_VRComponentProperty_IsStatic = 1; + /** native declaration : headers\openvr_capi.h:1079 */ + public static final int EVRComponentProperty_VRComponentProperty_IsVisible = 2; + /** native declaration : headers\openvr_capi.h:1080 */ + public static final int EVRComponentProperty_VRComponentProperty_IsTouched = 4; + /** native declaration : headers\openvr_capi.h:1081 */ + public static final int EVRComponentProperty_VRComponentProperty_IsPressed = 8; + /** native declaration : headers\openvr_capi.h:1082 */ + public static final int EVRComponentProperty_VRComponentProperty_IsScrolled = 16; + }; + /** + * native declaration : headers\openvr_capi.h:1088
        + * enum values + */ + public static interface EVRNotificationType { + /** native declaration : headers\openvr_capi.h:1085 */ + public static final int EVRNotificationType_Transient = 0; + /** native declaration : headers\openvr_capi.h:1086 */ + public static final int EVRNotificationType_Persistent = 1; + /** native declaration : headers\openvr_capi.h:1087 */ + public static final int EVRNotificationType_Transient_SystemWithUserValue = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1095
        + * enum values + */ + public static interface EVRNotificationStyle { + /** native declaration : headers\openvr_capi.h:1090 */ + public static final int EVRNotificationStyle_None = 0; + /** native declaration : headers\openvr_capi.h:1091 */ + public static final int EVRNotificationStyle_Application = 100; + /** native declaration : headers\openvr_capi.h:1092 */ + public static final int EVRNotificationStyle_Contact_Disabled = 200; + /** native declaration : headers\openvr_capi.h:1093 */ + public static final int EVRNotificationStyle_Contact_Enabled = 201; + /** native declaration : headers\openvr_capi.h:1094 */ + public static final int EVRNotificationStyle_Contact_Active = 202; + }; + /** + * native declaration : headers\openvr_capi.h:1103
        + * enum values + */ + public static interface EVRSettingsError { + /** native declaration : headers\openvr_capi.h:1097 */ + public static final int EVRSettingsError_VRSettingsError_None = 0; + /** native declaration : headers\openvr_capi.h:1098 */ + public static final int EVRSettingsError_VRSettingsError_IPCFailed = 1; + /** native declaration : headers\openvr_capi.h:1099 */ + public static final int EVRSettingsError_VRSettingsError_WriteFailed = 2; + /** native declaration : headers\openvr_capi.h:1100 */ + public static final int EVRSettingsError_VRSettingsError_ReadFailed = 3; + /** native declaration : headers\openvr_capi.h:1101 */ + public static final int EVRSettingsError_VRSettingsError_JsonParseFailed = 4; + /** native declaration : headers\openvr_capi.h:1102 */ + public static final int EVRSettingsError_VRSettingsError_UnsetSettingHasNoDefault = 5; + }; + /** + * native declaration : headers\openvr_capi.h:1111
        + * enum values + */ + public static interface EVRScreenshotError { + /** native declaration : headers\openvr_capi.h:1105 */ + public static final int EVRScreenshotError_VRScreenshotError_None = 0; + /** native declaration : headers\openvr_capi.h:1106 */ + public static final int EVRScreenshotError_VRScreenshotError_RequestFailed = 1; + /** native declaration : headers\openvr_capi.h:1107 */ + public static final int EVRScreenshotError_VRScreenshotError_IncompatibleVersion = 100; + /** native declaration : headers\openvr_capi.h:1108 */ + public static final int EVRScreenshotError_VRScreenshotError_NotFound = 101; + /** native declaration : headers\openvr_capi.h:1109 */ + public static final int EVRScreenshotError_VRScreenshotError_BufferTooSmall = 102; + /** native declaration : headers\openvr_capi.h:1110 */ + public static final int EVRScreenshotError_VRScreenshotError_ScreenshotAlreadyInProgress = 108; + }; + /** + * native declaration : headers\openvr_capi.h:1116
        + * enum values + */ + public static interface EVRSkeletalTransformSpace { + /** native declaration : headers\openvr_capi.h:1113 */ + public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Model = 0; + /** native declaration : headers\openvr_capi.h:1114 */ + public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Parent = 1; + /** native declaration : headers\openvr_capi.h:1115 */ + public static final int EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Additive = 2; + }; + /** + * native declaration : headers\openvr_capi.h:1120
        + * enum values + */ + public static interface EVRInputFilterCancelType { + /** native declaration : headers\openvr_capi.h:1118 */ + public static final int EVRInputFilterCancelType_VRInputFilterCancel_Timers = 0; + /** native declaration : headers\openvr_capi.h:1119 */ + public static final int EVRInputFilterCancelType_VRInputFilterCancel_Momentum = 1; + }; + /** + * native declaration : headers\openvr_capi.h:1129
        + * enum values + */ + public static interface EIOBufferError { + /** native declaration : headers\openvr_capi.h:1122 */ + public static final int EIOBufferError_IOBuffer_Success = 0; + /** native declaration : headers\openvr_capi.h:1123 */ + public static final int EIOBufferError_IOBuffer_OperationFailed = 100; + /** native declaration : headers\openvr_capi.h:1124 */ + public static final int EIOBufferError_IOBuffer_InvalidHandle = 101; + /** native declaration : headers\openvr_capi.h:1125 */ + public static final int EIOBufferError_IOBuffer_InvalidArgument = 102; + /** native declaration : headers\openvr_capi.h:1126 */ + public static final int EIOBufferError_IOBuffer_PathExists = 103; + /** native declaration : headers\openvr_capi.h:1127 */ + public static final int EIOBufferError_IOBuffer_PathDoesNotExist = 104; + /** native declaration : headers\openvr_capi.h:1128 */ + public static final int EIOBufferError_IOBuffer_Permission = 105; + }; + /** + * native declaration : headers\openvr_capi.h:1134
        + * enum values + */ + public static interface EIOBufferMode { + /** native declaration : headers\openvr_capi.h:1131 */ + public static final int EIOBufferMode_IOBufferMode_Read = 1; + /** native declaration : headers\openvr_capi.h:1132 */ + public static final int EIOBufferMode_IOBufferMode_Write = 2; + /** native declaration : headers\openvr_capi.h:1133 */ + public static final int EIOBufferMode_IOBufferMode_Create = 512; + }; + /** OpenVR Constants */ + public static final long k_nDriverNone = 4294967295L; + public static final int k_unMaxDriverDebugResponseSize = 32768; + public static final int k_unTrackedDeviceIndex_Hmd = 0; + public static final int k_unMaxTrackedDeviceCount = 64; + public static final int k_unTrackedDeviceIndexOther = -2; + public static final long k_unTrackedDeviceIndexInvalid = 4294967295L; + public static final long k_ulInvalidPropertyContainer = 0; + public static final int k_unInvalidPropertyTag = 0; + public static final long k_ulInvalidDriverHandle = 0; + public static final int k_unFloatPropertyTag = 1; + public static final int k_unInt32PropertyTag = 2; + public static final int k_unUint64PropertyTag = 3; + public static final int k_unBoolPropertyTag = 4; + public static final int k_unStringPropertyTag = 5; + public static final int k_unHmdMatrix34PropertyTag = 20; + public static final int k_unHmdMatrix44PropertyTag = 21; + public static final int k_unHmdVector3PropertyTag = 22; + public static final int k_unHmdVector4PropertyTag = 23; + public static final int k_unHiddenAreaPropertyTag = 30; + public static final int k_unPathHandleInfoTag = 31; + public static final int k_unActionPropertyTag = 32; + public static final int k_unInputValuePropertyTag = 33; + public static final int k_unWildcardPropertyTag = 34; + public static final int k_unHapticVibrationPropertyTag = 35; + public static final int k_unSkeletonPropertyTag = 36; + public static final int k_unSpatialAnchorPosePropertyTag = 40; + public static final int k_unOpenVRInternalReserved_Start = 1000; + public static final int k_unOpenVRInternalReserved_End = 10000; + public static final int k_unMaxPropertyStringSize = 32768; + public static final long k_ulInvalidActionHandle = 0; + public static final long k_ulInvalidActionSetHandle = 0; + public static final long k_ulInvalidInputValueHandle = 0; + public static final int k_unControllerStateAxisCount = 5; + public static final long k_ulOverlayHandleInvalid = 0; + public static final int k_unScreenshotHandleInvalid = 0; + public static final int k_unMaxApplicationKeyLength = 128; + public static final int k_unVROverlayMaxKeyLength = 128; + public static final int k_unVROverlayMaxNameLength = 128; + public static final int k_unMaxOverlayCount = 64; + public static final int k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; + public static final int k_unNotificationTextMaxSize = 256; + public static final int k_unMaxSettingsKeyLength = 128; + public static final int k_unMaxActionNameLength = 64; + public static final int k_unMaxActionSetNameLength = 64; + public static final int k_unMaxActionOriginCount = 16; + public static final long k_ulInvalidIOBufferHandle = 0; public static final int k_ulInvalidSpatialAnchorHandle = 0; @@ -2228,104 +2227,106 @@ public static interface EIOBufferMode { public static final String IVRIOBuffer_Version = "IVRIOBuffer_001"; public static final String IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; - - /** - * Global entry points
        - * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
        - * native declaration : headers\openvr_capi.h:2378
        - * @deprecated use the safer methods {@link #VR_InitInternal(java.nio.IntBuffer, int)} and {@link #VR_InitInternal(com.sun.jna.ptr.IntByReference, int)} instead - */ - @Deprecated - public static native IntByReference VR_InitInternal(IntByReference peError, int eType); - /** - * Global entry points
        - * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
        - * native declaration : headers\openvr_capi.h:2378 - */ - public static native IntByReference VR_InitInternal(IntBuffer peError, int eType); - /** - * Original signature : void VR_ShutdownInternal()
        - * native declaration : headers\openvr_capi.h:2380 - */ - public static native void VR_ShutdownInternal(); - /** - * Original signature : bool VR_IsHmdPresent()
        - * native declaration : headers\openvr_capi.h:2382 - */ - public static native byte VR_IsHmdPresent(); - /** - * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
        - * native declaration : headers\openvr_capi.h:2384
        - * @deprecated use the safer methods {@link #VR_GetGenericInterface(java.lang.String, java.nio.IntBuffer)} and {@link #VR_GetGenericInterface(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead - */ - @Deprecated - public static native IntByReference VR_GetGenericInterface(Pointer pchInterfaceVersion, IntByReference peError); - /** - * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
        - * native declaration : headers\openvr_capi.h:2384 - */ - public static native IntByReference VR_GetGenericInterface(String pchInterfaceVersion, IntByReference peError); - /** - * Original signature : bool VR_IsRuntimeInstalled()
        - * native declaration : headers\openvr_capi.h:2386 - */ - public static native byte VR_IsRuntimeInstalled(); - /** - * Original signature : char* VR_GetVRInitErrorAsSymbol(EVRInitError)
        - * native declaration : headers\openvr_capi.h:2388 - */ - public static native Pointer VR_GetVRInitErrorAsSymbol(int error); - /** - * Original signature : char* VR_GetVRInitErrorAsEnglishDescription(EVRInitError)
        - * native declaration : headers\openvr_capi.h:2390 - */ - public static native Pointer VR_GetVRInitErrorAsEnglishDescription(int error); - public static class VkQueue_T extends PointerType { - public VkQueue_T(Pointer address) { - super(address); - } - public VkQueue_T() { - super(); - } - }; - public static class VkPhysicalDevice_T extends PointerType { - public VkPhysicalDevice_T(Pointer address) { - super(address); - } - public VkPhysicalDevice_T() { - super(); - } - }; - public static class VkInstance_T extends PointerType { - public VkInstance_T(Pointer address) { - super(address); - } - public VkInstance_T() { - super(); - } - }; - public static class ID3D12CommandQueue extends PointerType { - public ID3D12CommandQueue(Pointer address) { - super(address); - } - public ID3D12CommandQueue() { - super(); - } - }; - public static class ID3D12Resource extends PointerType { - public ID3D12Resource(Pointer address) { - super(address); - } - public ID3D12Resource() { - super(); - } - }; - public static class VkDevice_T extends PointerType { - public VkDevice_T(Pointer address) { - super(address); - } - public VkDevice_T() { - super(); - } - }; + + /** + * Global entry points
        + * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
        + * native declaration : headers\openvr_capi.h:2378
        + * @deprecated use the safer methods {@link #VR_InitInternal(java.nio.IntBuffer, int)} and {@link #VR_InitInternal(com.sun.jna.ptr.IntByReference, int)} instead + */ + @Deprecated + public static native IntByReference VR_InitInternal(IntByReference peError, int eType); + /** + * Global entry points
        + * Original signature : intptr_t VR_InitInternal(EVRInitError*, EVRApplicationType)
        + * native declaration : headers\openvr_capi.h:2378 + */ + public static native IntByReference VR_InitInternal(IntBuffer peError, int eType); + /** + * Original signature : void VR_ShutdownInternal()
        + * native declaration : headers\openvr_capi.h:2380 + */ + public static native void VR_ShutdownInternal(); + /** + * Original signature : bool VR_IsHmdPresent()
        + * native declaration : headers\openvr_capi.h:2382 + */ + public static native byte VR_IsHmdPresent(); + /** + * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
        + * native declaration : headers\openvr_capi.h:2384
        + * @deprecated use the safer method + * {@link #VR_GetGenericInterface(java.lang.String, com.sun.jna.ptr.IntByReference)} + * instead + */ + @Deprecated + public static native IntByReference VR_GetGenericInterface(Pointer pchInterfaceVersion, IntByReference peError); + /** + * Original signature : intptr_t VR_GetGenericInterface(const char*, EVRInitError*)
        + * native declaration : headers\openvr_capi.h:2384 + */ + public static native IntByReference VR_GetGenericInterface(String pchInterfaceVersion, IntByReference peError); + /** + * Original signature : bool VR_IsRuntimeInstalled()
        + * native declaration : headers\openvr_capi.h:2386 + */ + public static native byte VR_IsRuntimeInstalled(); + /** + * Original signature : char* VR_GetVRInitErrorAsSymbol(EVRInitError)
        + * native declaration : headers\openvr_capi.h:2388 + */ + public static native Pointer VR_GetVRInitErrorAsSymbol(int error); + /** + * Original signature : char* VR_GetVRInitErrorAsEnglishDescription(EVRInitError)
        + * native declaration : headers\openvr_capi.h:2390 + */ + public static native Pointer VR_GetVRInitErrorAsEnglishDescription(int error); + public static class VkQueue_T extends PointerType { + public VkQueue_T(Pointer address) { + super(address); + } + public VkQueue_T() { + super(); + } + }; + public static class VkPhysicalDevice_T extends PointerType { + public VkPhysicalDevice_T(Pointer address) { + super(address); + } + public VkPhysicalDevice_T() { + super(); + } + }; + public static class VkInstance_T extends PointerType { + public VkInstance_T(Pointer address) { + super(address); + } + public VkInstance_T() { + super(); + } + }; + public static class ID3D12CommandQueue extends PointerType { + public ID3D12CommandQueue(Pointer address) { + super(address); + } + public ID3D12CommandQueue() { + super(); + } + }; + public static class ID3D12Resource extends PointerType { + public ID3D12Resource(Pointer address) { + super(address); + } + public ID3D12Resource() { + super(); + } + }; + public static class VkDevice_T extends PointerType { + public VkDevice_T(Pointer address) { + super(address); + } + public VkDevice_T() { + super(); + } + }; } diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/Texture_t.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/Texture_t.java index a81f3a6fc0..1999af2d19 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/Texture_t.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/Texture_t.java @@ -4,54 +4,52 @@ import java.util.Arrays; import java.util.List; /** - * native declaration : headers\openvr_capi.h:1247
        - * This file was autogenerated by JNAerator,
        - * a tool written by Olivier Chafik that uses a few opensource projects..
        - * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class Texture_t extends Structure { + * native declaration : headers\openvr_capi.h:1247
        + * This file was autogenerated by JNAerator,
        + * a tool written by Olivier Chafik that uses a few opensource projects..
        + * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class Texture_t extends Structure { /** - * void *
        - * C type : void* - */ - public int handle; + * void *
        + * C type : void* + */ + public int handle; /** - * @see ETextureType
        - * C type : ETextureType - */ - public int eType; + * C type : ETextureType + */ + public int eType; /** - * @see EColorSpace
        - * C type : EColorSpace - */ - public int eColorSpace; - public Texture_t() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("handle", "eType", "eColorSpace"); - } + * C type : EColorSpace + */ + public int eColorSpace; + public Texture_t() { + super(); + } + protected List getFieldOrder() { + return Arrays.asList("handle", "eType", "eColorSpace"); + } /** - * @param handle void *
        - * C type : void*
        - * @param eType @see ETextureType
        - * C type : ETextureType
        - * @param eColorSpace @see EColorSpace
        - * C type : EColorSpace - */ - public Texture_t(int handle, int eType, int eColorSpace) { - super(); - this.handle = handle; - this.eType = eType; - this.eColorSpace = eColorSpace; - } - public Texture_t(Pointer peer) { - super(peer); - } - public static class ByReference extends Texture_t implements Structure.ByReference { - - }; - public static class ByValue extends Texture_t implements Structure.ByValue { - - }; + * @param handle void *
        + * C type : void*
        + * @param eType @see ETextureType
        + * C type : ETextureType
        + * @param eColorSpace @see EColorSpace
        + * C type : EColorSpace + */ + public Texture_t(int handle, int eType, int eColorSpace) { + super(); + this.handle = handle; + this.eType = eType; + this.eColorSpace = eColorSpace; + } + public Texture_t(Pointer peer) { + super(peer); + } + public static class ByReference extends Texture_t implements Structure.ByReference { + + }; + public static class ByValue extends Texture_t implements Structure.ByValue { + + }; } diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java index 97bbe24313..fc0f3fd9f2 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/TrackedDevicePose_t.java @@ -4,54 +4,53 @@ import java.util.Arrays; import java.util.List; /** - * native declaration : headers\openvr_capi.h:1257
        - * This file was autogenerated by JNAerator,
        - * a tool written by Olivier Chafik that uses a few opensource projects..
        - * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class TrackedDevicePose_t extends Structure { - /** C type : HmdMatrix34_t */ - public HmdMatrix34_t mDeviceToAbsoluteTracking; - /** C type : HmdVector3_t */ - public HmdVector3_t vVelocity; - /** C type : HmdVector3_t */ - public HmdVector3_t vAngularVelocity; + * native declaration : headers\openvr_capi.h:1257
        + * This file was autogenerated by JNAerator,
        + * a tool written by Olivier Chafik that uses a few opensource projects..
        + * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class TrackedDevicePose_t extends Structure { + /** C type : HmdMatrix34_t */ + public HmdMatrix34_t mDeviceToAbsoluteTracking; + /** C type : HmdVector3_t */ + public HmdVector3_t vVelocity; + /** C type : HmdVector3_t */ + public HmdVector3_t vAngularVelocity; /** - * @see ETrackingResult
        - * C type : ETrackingResult - */ - public int eTrackingResult; - public byte bPoseIsValid; - public byte bDeviceIsConnected; - public TrackedDevicePose_t() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("mDeviceToAbsoluteTracking", "vVelocity", "vAngularVelocity", "eTrackingResult", "bPoseIsValid", "bDeviceIsConnected"); - } + * C type : ETrackingResult + */ + public int eTrackingResult; + public byte bPoseIsValid; + public byte bDeviceIsConnected; + public TrackedDevicePose_t() { + super(); + } + protected List getFieldOrder() { + return Arrays.asList("mDeviceToAbsoluteTracking", "vVelocity", "vAngularVelocity", "eTrackingResult", "bPoseIsValid", "bDeviceIsConnected"); + } /** - * @param mDeviceToAbsoluteTracking C type : HmdMatrix34_t
        - * @param vVelocity C type : HmdVector3_t
        - * @param vAngularVelocity C type : HmdVector3_t
        - * @param eTrackingResult @see ETrackingResult
        - * C type : ETrackingResult - */ - public TrackedDevicePose_t(HmdMatrix34_t mDeviceToAbsoluteTracking, HmdVector3_t vVelocity, HmdVector3_t vAngularVelocity, int eTrackingResult, byte bPoseIsValid, byte bDeviceIsConnected) { - super(); - this.mDeviceToAbsoluteTracking = mDeviceToAbsoluteTracking; - this.vVelocity = vVelocity; - this.vAngularVelocity = vAngularVelocity; - this.eTrackingResult = eTrackingResult; - this.bPoseIsValid = bPoseIsValid; - this.bDeviceIsConnected = bDeviceIsConnected; - } - public TrackedDevicePose_t(Pointer peer) { - super(peer); - } - public static class ByReference extends TrackedDevicePose_t implements Structure.ByReference { - - }; - public static class ByValue extends TrackedDevicePose_t implements Structure.ByValue { - - }; + * @param mDeviceToAbsoluteTracking C type : HmdMatrix34_t
        + * @param vVelocity C type : HmdVector3_t
        + * @param vAngularVelocity C type : HmdVector3_t
        + * @param eTrackingResult @see ETrackingResult
        + * C type : ETrackingResult + */ + public TrackedDevicePose_t(HmdMatrix34_t mDeviceToAbsoluteTracking, HmdVector3_t vVelocity, HmdVector3_t vAngularVelocity, int eTrackingResult, byte bPoseIsValid, byte bDeviceIsConnected) { + super(); + this.mDeviceToAbsoluteTracking = mDeviceToAbsoluteTracking; + this.vVelocity = vVelocity; + this.vAngularVelocity = vAngularVelocity; + this.eTrackingResult = eTrackingResult; + this.bPoseIsValid = bPoseIsValid; + this.bDeviceIsConnected = bDeviceIsConnected; + } + public TrackedDevicePose_t(Pointer peer) { + super(peer); + } + public static class ByReference extends TrackedDevicePose_t implements Structure.ByReference { + + }; + public static class ByValue extends TrackedDevicePose_t implements Structure.ByValue { + + }; } diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java index b6a528d3be..8bcb1a3730 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_DualAnalog_t.java @@ -15,7 +15,6 @@ public class VREvent_DualAnalog_t extends Structure { public float transformedX; public float transformedY; /** - * @see EDualAnalogWhich
        * C type : EDualAnalogWhich */ public int which; diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java index fe51252f7a..bf8d6e3194 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VREvent_Property_t.java @@ -4,42 +4,41 @@ import java.util.Arrays; import java.util.List; /** - * native declaration : headers\openvr_capi.h:1386
        - * This file was autogenerated by JNAerator,
        - * a tool written by Olivier Chafik that uses a few opensource projects..
        - * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VREvent_Property_t extends Structure { - /** C type : PropertyContainerHandle_t */ - public long container; + * native declaration : headers\openvr_capi.h:1386
        + * This file was autogenerated by JNAerator,
        + * a tool written by Olivier Chafik that uses a few opensource projects..
        + * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VREvent_Property_t extends Structure { + /** C type : PropertyContainerHandle_t */ + public long container; /** - * @see ETrackedDeviceProperty
        - * C type : ETrackedDeviceProperty - */ - public int prop; - public VREvent_Property_t() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("container", "prop"); - } + * C type : ETrackedDeviceProperty + */ + public int prop; + public VREvent_Property_t() { + super(); + } + protected List getFieldOrder() { + return Arrays.asList("container", "prop"); + } /** - * @param container C type : PropertyContainerHandle_t
        - * @param prop @see ETrackedDeviceProperty
        - * C type : ETrackedDeviceProperty - */ - public VREvent_Property_t(long container, int prop) { - super(); - this.container = container; - this.prop = prop; - } - public VREvent_Property_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VREvent_Property_t implements Structure.ByReference { - - }; - public static class ByValue extends VREvent_Property_t implements Structure.ByValue { - - }; + * @param container C type : PropertyContainerHandle_t
        + * @param prop @see ETrackedDeviceProperty
        + * C type : ETrackedDeviceProperty + */ + public VREvent_Property_t(long container, int prop) { + super(); + this.container = container; + this.prop = prop; + } + public VREvent_Property_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VREvent_Property_t implements Structure.ByReference { + + }; + public static class ByValue extends VREvent_Property_t implements Structure.ByValue { + + }; } diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java index e9c7e5934a..6996ec78aa 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionMaskPrimitive_t.java @@ -4,42 +4,41 @@ import java.util.Arrays; import java.util.List; /** - * native declaration : headers\openvr_capi.h:1702
        - * This file was autogenerated by JNAerator,
        - * a tool written by Olivier Chafik that uses a few opensource projects..
        - * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VROverlayIntersectionMaskPrimitive_t extends Structure { + * native declaration : headers\openvr_capi.h:1702
        + * This file was autogenerated by JNAerator,
        + * a tool written by Olivier Chafik that uses a few opensource projects..
        + * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VROverlayIntersectionMaskPrimitive_t extends Structure { /** - * @see EVROverlayIntersectionMaskPrimitiveType
        - * C type : EVROverlayIntersectionMaskPrimitiveType - */ - public int m_nPrimitiveType; - /** C type : VROverlayIntersectionMaskPrimitive_Data_t */ - public VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; - public VROverlayIntersectionMaskPrimitive_t() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("m_nPrimitiveType", "m_Primitive"); - } + * C type : EVROverlayIntersectionMaskPrimitiveType + */ + public int m_nPrimitiveType; + /** C type : VROverlayIntersectionMaskPrimitive_Data_t */ + public VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; + public VROverlayIntersectionMaskPrimitive_t() { + super(); + } + protected List getFieldOrder() { + return Arrays.asList("m_nPrimitiveType", "m_Primitive"); + } /** - * @param m_nPrimitiveType @see EVROverlayIntersectionMaskPrimitiveType
        - * C type : EVROverlayIntersectionMaskPrimitiveType
        - * @param m_Primitive C type : VROverlayIntersectionMaskPrimitive_Data_t - */ - public VROverlayIntersectionMaskPrimitive_t(int m_nPrimitiveType, VROverlayIntersectionMaskPrimitive_Data_t m_Primitive) { - super(); - this.m_nPrimitiveType = m_nPrimitiveType; - this.m_Primitive = m_Primitive; - } - public VROverlayIntersectionMaskPrimitive_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByReference { - - }; - public static class ByValue extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByValue { - - }; + * @param m_nPrimitiveType @see EVROverlayIntersectionMaskPrimitiveType
        + * C type : EVROverlayIntersectionMaskPrimitiveType
        + * @param m_Primitive C type : VROverlayIntersectionMaskPrimitive_Data_t + */ + public VROverlayIntersectionMaskPrimitive_t(int m_nPrimitiveType, VROverlayIntersectionMaskPrimitive_Data_t m_Primitive) { + super(); + this.m_nPrimitiveType = m_nPrimitiveType; + this.m_Primitive = m_Primitive; + } + public VROverlayIntersectionMaskPrimitive_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByReference { + + }; + public static class ByValue extends VROverlayIntersectionMaskPrimitive_t implements Structure.ByValue { + + }; } diff --git a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java index e430f22351..7b2ff945ce 100644 --- a/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java +++ b/jme3-vr/src/main/java/com/jme3/system/jopenvr/VROverlayIntersectionParams_t.java @@ -4,46 +4,45 @@ import java.util.Arrays; import java.util.List; /** - * native declaration : headers\openvr_capi.h:1535
        - * This file was autogenerated by JNAerator,
        - * a tool written by Olivier Chafik that uses a few opensource projects..
        - * For help, please visit NativeLibs4Java , Rococoa, or JNA. - */ -public class VROverlayIntersectionParams_t extends Structure { - /** C type : HmdVector3_t */ - public HmdVector3_t vSource; - /** C type : HmdVector3_t */ - public HmdVector3_t vDirection; + * native declaration : headers\openvr_capi.h:1535
        + * This file was autogenerated by JNAerator,
        + * a tool written by Olivier Chafik that uses a few opensource projects..
        + * For help, please visit NativeLibs4Java , Rococoa, or JNA. + */ +public class VROverlayIntersectionParams_t extends Structure { + /** C type : HmdVector3_t */ + public HmdVector3_t vSource; + /** C type : HmdVector3_t */ + public HmdVector3_t vDirection; /** - * @see ETrackingUniverseOrigin
        - * C type : ETrackingUniverseOrigin - */ - public int eOrigin; - public VROverlayIntersectionParams_t() { - super(); - } - protected List getFieldOrder() { - return Arrays.asList("vSource", "vDirection", "eOrigin"); - } + * C type : ETrackingUniverseOrigin + */ + public int eOrigin; + public VROverlayIntersectionParams_t() { + super(); + } + protected List getFieldOrder() { + return Arrays.asList("vSource", "vDirection", "eOrigin"); + } /** - * @param vSource C type : HmdVector3_t
        - * @param vDirection C type : HmdVector3_t
        - * @param eOrigin @see ETrackingUniverseOrigin
        - * C type : ETrackingUniverseOrigin - */ - public VROverlayIntersectionParams_t(HmdVector3_t vSource, HmdVector3_t vDirection, int eOrigin) { - super(); - this.vSource = vSource; - this.vDirection = vDirection; - this.eOrigin = eOrigin; - } - public VROverlayIntersectionParams_t(Pointer peer) { - super(peer); - } - public static class ByReference extends VROverlayIntersectionParams_t implements Structure.ByReference { - - }; - public static class ByValue extends VROverlayIntersectionParams_t implements Structure.ByValue { - - }; + * @param vSource C type : HmdVector3_t
        + * @param vDirection C type : HmdVector3_t
        + * @param eOrigin @see ETrackingUniverseOrigin
        + * C type : ETrackingUniverseOrigin + */ + public VROverlayIntersectionParams_t(HmdVector3_t vSource, HmdVector3_t vDirection, int eOrigin) { + super(); + this.vSource = vSource; + this.vDirection = vDirection; + this.eOrigin = eOrigin; + } + public VROverlayIntersectionParams_t(Pointer peer) { + super(peer); + } + public static class ByReference extends VROverlayIntersectionParams_t implements Structure.ByReference { + + }; + public static class ByValue extends VROverlayIntersectionParams_t implements Structure.ByValue { + + }; } diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java index 6c5b32e031..dd8792e399 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientkit/OsvrClientKitLibrary.java @@ -19,41 +19,45 @@ public class OsvrClientKitLibrary implements Library { Native.register(OsvrClientKitLibrary.class, OsvrClientKitLibrary.JNA_NATIVE_LIB); } /** - * @brief Initialize the library.
        + * Initialize the library. * @param applicationIdentifier A null terminated string identifying your
        * application. Reverse DNS format strongly suggested.
        * @param flags initialization options (reserved) - pass 0 for now.
        - * @returns Client context - will be needed for subsequent calls
        + * @return Client context - will be needed for subsequent calls
        * Original signature : OSVR_ClientContext osvrClientInit(const char[], uint32_t)
        - * @deprecated use the safer methods {@link #osvrClientInit(byte[], int)} and {@link #osvrClientInit(com.sun.jna.Pointer, int)} instead + * @deprecated use the safer method + * {@link #osvrClientInit(byte[], int)} + * instead */ @Deprecated public static native OsvrClientKitLibrary.OSVR_ClientContext osvrClientInit(Pointer applicationIdentifier, int flags); /** - * @brief Initialize the library.
        + * Initialize the library. * @param applicationIdentifier A null terminated string identifying your
        * application. Reverse DNS format strongly suggested.
        * @param flags initialization options (reserved) - pass 0 for now.
        - * @returns Client context - will be needed for subsequent calls
        + * @return Client context - will be needed for subsequent calls
        * Original signature : OSVR_ClientContext osvrClientInit(const char[], uint32_t) */ public static native OsvrClientKitLibrary.OSVR_ClientContext osvrClientInit(byte applicationIdentifier[], int flags); /** - * @brief Updates the state of the context - call regularly in your mainloop.
        + * Updates the state of the context - call regularly in your mainloop. * @param ctx Client context
        * Original signature : OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext)
        - * @deprecated use the safer methods {@link #osvrClientUpdate(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext)} and {@link #osvrClientUpdate(com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientUpdate(OsvrClientKitLibrary.OSVR_ClientContext)} + * instead */ @Deprecated public static native byte osvrClientUpdate(Pointer ctx); /** - * @brief Updates the state of the context - call regularly in your mainloop.
        + * Updates the state of the context - call regularly in your mainloop. * @param ctx Client context
        * Original signature : OSVR_ReturnCode osvrClientUpdate(OSVR_ClientContext) */ public static native byte osvrClientUpdate(OsvrClientKitLibrary.OSVR_ClientContext ctx); /** - * @brief Checks to see if the client context is fully started up and connected
        + * Checks to see if the client context is fully started up and connected * properly to a server.
        * If this reports that the client context is not OK, there may not be a server
        * running, or you may just have to call osvrClientUpdate() a few times to
        @@ -63,12 +67,14 @@ public class OsvrClientKitLibrary implements Library { * @return OSVR_RETURN_FAILURE if not yet fully connected/initialized, or if
        * some other error (null context) occurs.
        * Original signature : OSVR_ReturnCode osvrClientCheckStatus(OSVR_ClientContext)
        - * @deprecated use the safer methods {@link #osvrClientCheckStatus(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext)} and {@link #osvrClientCheckStatus(com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientCheckStatus(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext)} + * instead */ @Deprecated public static native byte osvrClientCheckStatus(Pointer ctx); /** - * @brief Checks to see if the client context is fully started up and connected
        + * Checks to see if the client context is fully started up and connected * properly to a server.
        * If this reports that the client context is not OK, there may not be a server
        * running, or you may just have to call osvrClientUpdate() a few times to
        @@ -81,77 +87,85 @@ public class OsvrClientKitLibrary implements Library { */ public static native byte osvrClientCheckStatus(OsvrClientKitLibrary.OSVR_ClientContext ctx); /** - * @brief Shutdown the library.
        + * Shut down the library. * @param ctx Client context
        * Original signature : OSVR_ReturnCode osvrClientShutdown(OSVR_ClientContext)
        - * @deprecated use the safer methods {@link #osvrClientShutdown(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext)} and {@link #osvrClientShutdown(com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientShutdown(OsvrClientKitLibrary.OSVR_ClientContext)} + * instead */ @Deprecated public static native byte osvrClientShutdown(Pointer ctx); /** - * @brief Shutdown the library.
        + * Shut down the library. * @param ctx Client context
        * Original signature : OSVR_ReturnCode osvrClientShutdown(OSVR_ClientContext) */ public static native byte osvrClientShutdown(OsvrClientKitLibrary.OSVR_ClientContext ctx); /** - * @brief Log a message from the client.
        + * Log a message from the client. * Original signature : void osvrClientLog(OSVR_ClientContext, OSVR_LogLevel, const char*)
        - * @deprecated use the safer methods {@link #osvrClientLog(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, int, java.lang.String)} and {@link #osvrClientLog(com.sun.jna.Pointer, int, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientLog(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, int, java.lang.String)} + * instead */ @Deprecated public static native void osvrClientLog(Pointer ctx, int severity, Pointer message); /** - * @brief Log a message from the client.
        + * Log a message from the client. * Original signature : void osvrClientLog(OSVR_ClientContext, OSVR_LogLevel, const char*) */ public static native void osvrClientLog(OsvrClientKitLibrary.OSVR_ClientContext ctx, int severity, String message); /** - * @brief Get the interface associated with the given path.
        + * Get the interface associated with the given path. * @param ctx Client context
        * @param path A resource path (null-terminated string)
        - * @param[out] iface The interface object. May be freed when no longer needed,
        + * @param iface The interface object. May be freed when no longer needed,
        * otherwise it will be freed when the context is closed.
        * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*)
        - * @deprecated use the safer methods {@link #osvrClientGetInterface(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, byte[], com.sun.jna.ptr.PointerByReference)} and {@link #osvrClientGetInterface(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.ptr.PointerByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetInterface(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, byte[], com.sun.jna.ptr.PointerByReference)} + * instead */ @Deprecated public static native byte osvrClientGetInterface(Pointer ctx, Pointer path, Pointer iface); /** - * @brief Get the interface associated with the given path.
        + * Get the interface associated with the given path. * @param ctx Client context
        * @param path A resource path (null-terminated string)
        - * @param[out] iface The interface object. May be freed when no longer needed,
        + * @param iface The interface object. May be freed when no longer needed,
        * otherwise it will be freed when the context is closed.
        * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*) */ public static native byte osvrClientGetInterface(OsvrClientKitLibrary.OSVR_ClientContext ctx, byte path[], PointerByReference iface); /** - * @brief Get the interface associated with the given path.
        + * Get the interface associated with the given path. * @param ctx Client context
        * @param path A resource path (null-terminated string)
        - * @param[out] iface The interface object. May be freed when no longer needed,
        + * @param iface The interface object. May be freed when no longer needed,
        * otherwise it will be freed when the context is closed.
        * Original signature : OSVR_ReturnCode osvrClientGetInterface(OSVR_ClientContext, const char[], OSVR_ClientInterface*) */ public static native byte osvrClientGetInterface(Pointer ctx, Pointer path, PointerByReference iface); /** - * @brief Free an interface object before context closure.
        + * Free an interface object before context closure. * @param ctx Client context
        * @param iface The interface object
        - * @returns OSVR_RETURN_SUCCESS unless a null context or interface was passed
        + * @return OSVR_RETURN_SUCCESS unless a null context or interface was passed
        * or the given interface was not found in the context (i.e. had already been
        * freed)
        * Original signature : OSVR_ReturnCode osvrClientFreeInterface(OSVR_ClientContext, OSVR_ClientInterface)
        - * @deprecated use the safer methods {@link #osvrClientFreeInterface(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface)} and {@link #osvrClientFreeInterface(com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientFreeInterface(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface)} + * instead */ @Deprecated public static native byte osvrClientFreeInterface(Pointer ctx, Pointer iface); /** - * @brief Free an interface object before context closure.
        + * Free an interface object before context closure. * @param ctx Client context
        * @param iface The interface object
        - * @returns OSVR_RETURN_SUCCESS unless a null context or interface was passed
        + * @return OSVR_RETURN_SUCCESS unless a null context or interface was passed
        * or the given interface was not found in the context (i.e. had already been
        * freed)
        * Original signature : OSVR_ReturnCode osvrClientFreeInterface(OSVR_ClientContext, OSVR_ClientInterface) @@ -159,7 +173,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrClientFreeInterface(OsvrClientKitLibrary.OSVR_ClientContext ctx, OsvrClientKitLibrary.OSVR_ClientInterface iface); /** * Original signature : OSVR_ReturnCode osvrRegisterPoseCallback(OSVR_ClientInterface, OSVR_PoseCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterPoseCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterPoseCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterPoseCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterPoseCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -167,7 +183,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterPoseCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterPositionCallback(OSVR_ClientInterface, OSVR_PositionCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterPositionCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterPositionCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterPositionCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -175,7 +193,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterOrientationCallback(OSVR_ClientInterface, OSVR_OrientationCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterOrientationCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterOrientationCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterOrientationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterOrientationCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -183,7 +203,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterOrientationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterVelocityCallback(OSVR_ClientInterface, OSVR_VelocityCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterVelocityCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterVelocityCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -191,7 +213,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterLinearVelocityCallback(OSVR_ClientInterface, OSVR_LinearVelocityCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterLinearVelocityCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterLinearVelocityCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterLinearVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterLinearVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -199,7 +223,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterLinearVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterAngularVelocityCallback(OSVR_ClientInterface, OSVR_AngularVelocityCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterAngularVelocityCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterAngularVelocityCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterAngularVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterAngularVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -207,7 +233,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterAngularVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterAccelerationCallback(OSVR_ClientInterface, OSVR_AccelerationCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterAccelerationCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterAccelerationCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -215,7 +243,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterLinearAccelerationCallback(OSVR_ClientInterface, OSVR_LinearAccelerationCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterLinearAccelerationCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterLinearAccelerationCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterLinearAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterLinearAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -223,7 +253,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterLinearAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterAngularAccelerationCallback(OSVR_ClientInterface, OSVR_AngularAccelerationCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterAngularAccelerationCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterAngularAccelerationCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterAngularAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterAngularAccelerationCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -231,7 +263,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterAngularAccelerationCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterButtonCallback(OSVR_ClientInterface, OSVR_ButtonCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterButtonCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterButtonCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterButtonCallback(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Callback, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterButtonCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -239,7 +273,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterButtonCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Callback cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterAnalogCallback(OSVR_ClientInterface, OSVR_AnalogCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterAnalogCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterAnalogCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterAnalogCallback(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Callback, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterAnalogCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -247,7 +283,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterAnalogCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Callback cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterImagingCallback(OSVR_ClientInterface, OSVR_ImagingCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterImagingCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterImagingCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterImagingCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterImagingCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -255,7 +293,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterImagingCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterLocation2DCallback(OSVR_ClientInterface, OSVR_Location2DCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterLocation2DCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterLocation2DCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterLocation2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterLocation2DCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -263,7 +303,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterLocation2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterDirectionCallback(OSVR_ClientInterface, OSVR_DirectionCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterDirectionCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterDirectionCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterDirectionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterDirectionCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -271,7 +313,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterDirectionCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterEyeTracker2DCallback(OSVR_ClientInterface, OSVR_EyeTracker2DCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterEyeTracker2DCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterEyeTracker2DCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterEyeTracker2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterEyeTracker2DCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -279,7 +323,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterEyeTracker2DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterEyeTracker3DCallback(OSVR_ClientInterface, OSVR_EyeTracker3DCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterEyeTracker3DCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterEyeTracker3DCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterEyeTracker3DCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterEyeTracker3DCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -287,7 +333,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterEyeTracker3DCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterEyeTrackerBlinkCallback(OSVR_ClientInterface, OSVR_EyeTrackerBlinkCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterEyeTrackerBlinkCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterEyeTrackerBlinkCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterEyeTrackerBlinkCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterEyeTrackerBlinkCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -295,7 +343,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterEyeTrackerBlinkCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterNaviVelocityCallback(OSVR_ClientInterface, OSVR_NaviVelocityCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterNaviVelocityCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterNaviVelocityCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterNaviVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterNaviVelocityCallback(Pointer iface, Pointer cb, Pointer userdata); @@ -303,7 +353,9 @@ public class OsvrClientKitLibrary implements Library { public static native byte osvrRegisterNaviVelocityCallback(OsvrClientKitLibrary.OSVR_ClientInterface iface, Pointer cb, Pointer userdata); /** * Original signature : OSVR_ReturnCode osvrRegisterNaviPositionCallback(OSVR_ClientInterface, OSVR_NaviPositionCallback, void*)
        - * @deprecated use the safer methods {@link #osvrRegisterNaviPositionCallback(osvrclientkit.OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} and {@link #osvrRegisterNaviPositionCallback(com.sun.jna.Pointer, com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrRegisterNaviPositionCallback(OsvrClientKitLibrary.OSVR_ClientInterface, com.sun.jna.Pointer, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrRegisterNaviPositionCallback(Pointer iface, Pointer cb, Pointer userdata); diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java index 7933cdefee..9f8f1ea765 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrclientreporttypes/OsvrClientReportTypesLibrary.java @@ -33,7 +33,7 @@ public class OsvrClientReportTypesLibrary implements Library { /** Original signature : void osvrVec3SetZ(OSVR_Vec3*, double) */ public static native void osvrVec3SetZ(OSVR_Vec3 v, double val); /** - * @brief Set a Vec3 to the zero vector
        + * Set a Vec3 to the zero vector. * Original signature : void osvrVec3Zero(OSVR_Vec3*) */ public static native void osvrVec3Zero(OSVR_Vec3 v); @@ -54,12 +54,12 @@ public class OsvrClientReportTypesLibrary implements Library { /** Original signature : void osvrQuatSetZ(OSVR_Quaternion*, double) */ public static native void osvrQuatSetZ(OSVR_Quaternion q, double val); /** - * @brief Set a quaternion to the identity rotation
        + * Set a quaternion to the identity rotation. * Original signature : void osvrQuatSetIdentity(OSVR_Quaternion*) */ public static native void osvrQuatSetIdentity(OSVR_Quaternion q); /** - * @brief Set a pose to identity
        + * Set a pose to identity. * Original signature : void osvrPose3SetIdentity(OSVR_Pose3*) */ public static native void osvrPose3SetIdentity(OSVR_Pose3 pose); @@ -72,7 +72,7 @@ public class OsvrClientReportTypesLibrary implements Library { /** Original signature : void osvrVec2SetY(OSVR_Vec2*, double) */ public static native void osvrVec2SetY(OSVR_Vec2 v, double val); /** - * @brief Set a Vec2 to the zero vector
        + * Set a Vec2 to the zero vector. * Original signature : void osvrVec2Zero(OSVR_Vec2*) */ public static native void osvrVec2Zero(OSVR_Vec2 v); diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java index 38489ecdfc..f3ef251407 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrdisplay/OsvrDisplayLibrary.java @@ -27,7 +27,7 @@ public class OsvrDisplayLibrary implements Library { Native.register(OsvrDisplayLibrary.class, OsvrDisplayLibrary.JNA_NATIVE_LIB); } /** - * @brief Allocates a display configuration object populated with data from the
        + * Allocates a display configuration object populated with data from the
        * OSVR system.
        * Before this call will succeed, your application will need to be correctly
        * and fully connected to an OSVR server. You may consider putting this call in
        @@ -55,19 +55,21 @@ public class OsvrDisplayLibrary implements Library { * practice, typically more) osvrClientUpdate() must be performed before a new
        * tracker report is available to populate that state. See
        * osvrClientCheckDisplayStartup() to query if all startup data is available.
        - * @todo Decide if relative viewport should be constant in a display config,
        + * todo Decide if relative viewport should be constant in a display config,
        * and update docs accordingly.
        - * @todo Decide if distortion params should be constant in a display config,
        + * todo Decide if distortion params should be constant in a display config,
        * and update docs accordingly.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
        * error occurred, in which case the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetDisplay(OSVR_ClientContext, OSVR_DisplayConfig*)
        - * @deprecated use the safer methods {@link #osvrClientGetDisplay(osvrdisplay.OsvrDisplayLibrary.OSVR_ClientContext, com.sun.jna.ptr.PointerByReference)} and {@link #osvrClientGetDisplay(com.sun.jna.Pointer, com.sun.jna.ptr.PointerByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetDisplay(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, com.sun.jna.ptr.PointerByReference)} + * instead */ @Deprecated public static native byte osvrClientGetDisplay(Pointer ctx, Pointer disp); /** - * @brief Allocates a display configuration object populated with data from the
        + * Allocates a display configuration object populated with data from the
        * OSVR system.
        * Before this call will succeed, your application will need to be correctly
        * and fully connected to an OSVR server. You may consider putting this call in
        @@ -95,9 +97,9 @@ public class OsvrDisplayLibrary implements Library { * practice, typically more) osvrClientUpdate() must be performed before a new
        * tracker report is available to populate that state. See
        * osvrClientCheckDisplayStartup() to query if all startup data is available.
        - * @todo Decide if relative viewport should be constant in a display config,
        + * todo Decide if relative viewport should be constant in a display config,
        * and update docs accordingly.
        - * @todo Decide if distortion params should be constant in a display config,
        + * todo Decide if distortion params should be constant in a display config,
        * and update docs accordingly.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
        * error occurred, in which case the output argument is unmodified.
        @@ -105,7 +107,7 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetDisplay(OsvrClientKitLibrary.OSVR_ClientContext ctx, PointerByReference disp); /** - * @brief Allocates a display configuration object populated with data from the
        + * Allocates a display configuration object populated with data from the
        * OSVR system.
        * Before this call will succeed, your application will need to be correctly
        * and fully connected to an OSVR server. You may consider putting this call in
        @@ -133,9 +135,9 @@ public class OsvrDisplayLibrary implements Library { * practice, typically more) osvrClientUpdate() must be performed before a new
        * tracker report is available to populate that state. See
        * osvrClientCheckDisplayStartup() to query if all startup data is available.
        - * @todo Decide if relative viewport should be constant in a display config,
        + * todo Decide if relative viewport should be constant in a display config,
        * and update docs accordingly.
        - * @todo Decide if distortion params should be constant in a display config,
        + * todo Decide if distortion params should be constant in a display config,
        * and update docs accordingly.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or some other
        * error occurred, in which case the output argument is unmodified.
        @@ -143,19 +145,21 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetDisplay(Pointer ctx, PointerByReference disp); /** - * @brief Frees a display configuration object. The corresponding context must
        + * Frees a display configuration object. The corresponding context must
        * still be open.
        * If you fail to call this, it will be automatically called as part of
        * clean-up when the corresponding context is closed.
        * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
        * display object was already freed.
        * Original signature : OSVR_ReturnCode osvrClientFreeDisplay(OSVR_DisplayConfig)
        - * @deprecated use the safer methods {@link #osvrClientFreeDisplay(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} and {@link #osvrClientFreeDisplay(com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientFreeDisplay(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} + * instead */ @Deprecated public static native byte osvrClientFreeDisplay(Pointer disp); /** - * @brief Frees a display configuration object. The corresponding context must
        + * Frees a display configuration object. The corresponding context must
        * still be open.
        * If you fail to call this, it will be automatically called as part of
        * clean-up when the corresponding context is closed.
        @@ -165,7 +169,7 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientFreeDisplay(OsvrDisplayLibrary.OSVR_DisplayConfig disp); /** - * @brief Checks to see if a display is fully configured and ready, including
        + * Checks to see if a display is fully configured and ready, including
        * having received its first pose update.
        * Once this first succeeds, it will continue to succeed for the lifetime of
        * the display config object, so it is not necessary to keep calling once you
        @@ -173,12 +177,14 @@ public class OsvrDisplayLibrary implements Library { * @return OSVR_RETURN_FAILURE if a null config was passed, or if the given
        * display config object was otherwise not ready for full use.
        * Original signature : OSVR_ReturnCode osvrClientCheckDisplayStartup(OSVR_DisplayConfig)
        - * @deprecated use the safer methods {@link #osvrClientCheckDisplayStartup(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} and {@link #osvrClientCheckDisplayStartup(com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientCheckDisplayStartup(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig)} + * instead */ @Deprecated public static native byte osvrClientCheckDisplayStartup(Pointer disp); /** - * @brief Checks to see if a display is fully configured and ready, including
        + * Checks to see if a display is fully configured and ready, including
        * having received its first pose update.
        * Once this first succeeds, it will continue to succeed for the lifetime of
        * the display config object, so it is not necessary to keep calling once you
        @@ -189,97 +195,97 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientCheckDisplayStartup(OsvrDisplayLibrary.OSVR_DisplayConfig disp); /** - * @brief A display config can have one or more display inputs to pass pixels
        + * A display config can have one or more display inputs to pass pixels
        * over (HDMI/DVI connections, etc): retrieve the number of display inputs in
        * the current configuration.
        * @param disp Display config object.
        - * @param[out] numDisplayInputs Number of display inputs in the logical display
        + * @param numDisplayInputs Number of display inputs in the logical display
        * topology, **constant** throughout the active, valid lifetime of a display
        * config object.
        - * @sa OSVR_DisplayInputCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
        * which case the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumDisplayInputs(OSVR_DisplayConfig, OSVR_DisplayInputCount*)
        - * @deprecated use the safer methods {@link #osvrClientGetNumDisplayInputs(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer)} and {@link #osvrClientGetNumDisplayInputs(com.sun.jna.Pointer, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetNumDisplayInputs(Pointer disp, Pointer numDisplayInputs); /** - * @brief A display config can have one or more display inputs to pass pixels
        + * A display config can have one or more display inputs to pass pixels
        * over (HDMI/DVI connections, etc): retrieve the number of display inputs in
        * the current configuration.
        * @param disp Display config object.
        - * @param[out] numDisplayInputs Number of display inputs in the logical display
        + * @param numDisplayInputs Number of display inputs in the logical display
        * topology, **constant** throughout the active, valid lifetime of a display
        * config object.
        - * @sa OSVR_DisplayInputCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
        * which case the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumDisplayInputs(OSVR_DisplayConfig, OSVR_DisplayInputCount*) */ public static native byte osvrClientGetNumDisplayInputs(OsvrDisplayLibrary.OSVR_DisplayConfig disp, ByteBuffer numDisplayInputs); /** - * @brief Retrieve the pixel dimensions of a given display input for a display
        + * Retrieve the pixel dimensions of a given display input for a display
        * config
        * @param disp Display config object.
        * @param displayInputIndex The zero-based index of the display input.
        - * @param[out] width Width (in pixels) of the display input.
        - * @param[out] height Height (in pixels) of the display input.
        + * @param width Width (in pixels) of the display input.
        + * @param height Height (in pixels) of the display input.
        * The out parameters are **constant** throughout the active, valid lifetime of
        * a display config object.
        - * @sa OSVR_DisplayDimension
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
        * which case the output arguments are unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetDisplayDimensions(OSVR_DisplayConfig, OSVR_DisplayInputCount, OSVR_DisplayDimension*, OSVR_DisplayDimension*)
        - * @deprecated use the safer methods {@link #osvrClientGetDisplayDimensions(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, byte, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #osvrClientGetDisplayDimensions(com.sun.jna.Pointer, byte, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetDisplayDimensions(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, byte, java.nio.IntBuffer, java.nio.IntBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetDisplayDimensions(Pointer disp, byte displayInputIndex, IntByReference width, IntByReference height); /** - * @brief Retrieve the pixel dimensions of a given display input for a display
        + * Retrieve the pixel dimensions of a given display input for a display
        * config
        * @param disp Display config object.
        * @param displayInputIndex The zero-based index of the display input.
        - * @param[out] width Width (in pixels) of the display input.
        - * @param[out] height Height (in pixels) of the display input.
        + * @param width Width (in pixels) of the display input.
        + * @param height Height (in pixels) of the display input.
        * The out parameters are **constant** throughout the active, valid lifetime of
        * a display config object.
        - * @sa OSVR_DisplayDimension
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in
        * which case the output arguments are unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetDisplayDimensions(OSVR_DisplayConfig, OSVR_DisplayInputCount, OSVR_DisplayDimension*, OSVR_DisplayDimension*) */ public static native byte osvrClientGetDisplayDimensions(OsvrDisplayLibrary.OSVR_DisplayConfig disp, byte displayInputIndex, IntBuffer width, IntBuffer height); /** - * @brief A display config can have one (or theoretically more) viewers:
        + * A display config can have one (or theoretically more) viewers:
        * retrieve the viewer count.
        * @param disp Display config object.
        - * @param[out] viewers Number of viewers in the logical display topology,
        + * @param viewers Number of viewers in the logical display topology,
        * *constant** throughout the active, valid lifetime of a display config
        * object.
        - * @sa OSVR_ViewerCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumViewers(OSVR_DisplayConfig, OSVR_ViewerCount*)
        - * @deprecated use the safer methods {@link #osvrClientGetNumViewers(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.IntBuffer)} and {@link #osvrClientGetNumViewers(com.sun.jna.Pointer, com.sun.jna.ptr.IntByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetNumViewers(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.IntBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetNumViewers(Pointer disp, IntByReference viewers); /** - * @brief A display config can have one (or theoretically more) viewers:
        + * A display config can have one (or theoretically more) viewers:
        * retrieve the viewer count.
        * @param disp Display config object.
        - * @param[out] viewers Number of viewers in the logical display topology,
        + * @param viewers Number of viewers in the logical display topology,
        * *constant** throughout the active, valid lifetime of a display config
        * object.
        - * @sa OSVR_ViewerCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumViewers(OSVR_DisplayConfig, OSVR_ViewerCount*) */ public static native byte osvrClientGetNumViewers(OsvrDisplayLibrary.OSVR_DisplayConfig disp, IntBuffer viewers); /** - * @brief Get the pose of a viewer in a display config.
        + * Get the pose of a viewer in a display config.
        * Note that there may not necessarily be any surfaces rendered from this pose
        * (it's the unused "center" eye in a stereo configuration, for instance) so
        * only use this if it makes integration into your engine or existing
        @@ -288,12 +294,14 @@ public class OsvrDisplayLibrary implements Library { * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
        * yet available, in which case the pose argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerPose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_Pose3*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerPose(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, com.sun.jna.Pointer)} and {@link #osvrClientGetViewerPose(com.sun.jna.Pointer, int, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerPose(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerPose(Pointer disp, int viewer, Pointer pose); /** - * @brief Get the pose of a viewer in a display config.
        + * Get the pose of a viewer in a display config.
        * Note that there may not necessarily be any surfaces rendered from this pose
        * (it's the unused "center" eye in a stereo configuration, for instance) so
        * only use this if it makes integration into your engine or existing
        @@ -305,89 +313,93 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetViewerPose(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, Pointer pose); /** - * @brief Each viewer in a display config can have one or more "eyes" which
        + * Each viewer in a display config can have one or more "eyes" which
        * have a substantially similar pose: get the count.
        * @param disp Display config object.
        * @param viewer Viewer ID
        - * @param[out] eyes Number of eyes for this viewer in the logical display
        + * @param eyes Number of eyes for this viewer in the logical display
        * topology, **constant** throughout the active, valid lifetime of a display
        * config object
        - * @sa OSVR_EyeCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumEyesForViewer(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount*)
        - * @deprecated use the safer methods {@link #osvrClientGetNumEyesForViewer(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, java.nio.ByteBuffer)} and {@link #osvrClientGetNumEyesForViewer(com.sun.jna.Pointer, int, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientGetNumEyesForViewer(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, java.nio.ByteBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetNumEyesForViewer(Pointer disp, int viewer, Pointer eyes); /** - * @brief Each viewer in a display config can have one or more "eyes" which
        + * Each viewer in a display config can have one or more "eyes" which
        * have a substantially similar pose: get the count.
        * @param disp Display config object.
        * @param viewer Viewer ID
        - * @param[out] eyes Number of eyes for this viewer in the logical display
        + * @param eyes Number of eyes for this viewer in the logical display
        * topology, **constant** throughout the active, valid lifetime of a display
        * config object
        - * @sa OSVR_EyeCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumEyesForViewer(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount*) */ public static native byte osvrClientGetNumEyesForViewer(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, ByteBuffer eyes); /** - * @brief Get the "viewpoint" for the given eye of a viewer in a display
        + * Get the "viewpoint" for the given eye of a viewer in a display
        * config.
        * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        - * @param[out] pose Room-space pose (not relative to pose of the viewer)
        + * @param pose Room-space pose (not relative to pose of the viewer)
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
        * yet available, in which case the pose argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyePose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_Pose3*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyePose(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, com.sun.jna.Pointer)} and {@link #osvrClientGetViewerEyePose(com.sun.jna.Pointer, int, byte, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyePose(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyePose(Pointer disp, int viewer, byte eye, Pointer pose); /** - * @brief Get the "viewpoint" for the given eye of a viewer in a display
        + * Get the "viewpoint" for the given eye of a viewer in a display
        * config.
        * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        - * @param[out] pose Room-space pose (not relative to pose of the viewer)
        + * @param pose Room-space pose (not relative to pose of the viewer)
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
        * yet available, in which case the pose argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyePose(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_Pose3*) */ public static native byte osvrClientGetViewerEyePose(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, Pointer pose); /** - * @brief Get the view matrix (inverse of pose) for the given eye of a
        + * Get the view matrix (inverse of pose) for the given eye of a
        * viewer in a display config - matrix of **doubles**.
        * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
        + * @param mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
        * matrix from room space to eye space (not relative to pose of the viewer)
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
        * yet available, in which case the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, double*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeViewMatrixd(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.DoubleBuffer)} and {@link #osvrClientGetViewerEyeViewMatrixd(com.sun.jna.Pointer, int, byte, short, com.sun.jna.ptr.DoubleByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeViewMatrixd(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.DoubleBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeViewMatrixd(Pointer disp, int viewer, byte eye, short flags, DoubleByReference mat); /** - * @brief Get the view matrix (inverse of pose) for the given eye of a
        + * Get the view matrix (inverse of pose) for the given eye of a
        * viewer in a display config - matrix of **doubles**.
        * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
        + * @param mat Pass a double[::OSVR_MATRIX_SIZE] to get the transformation
        * matrix from room space to eye space (not relative to pose of the viewer)
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
        * yet available, in which case the output argument is unmodified.
        @@ -395,31 +407,33 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetViewerEyeViewMatrixd(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, short flags, DoubleBuffer mat); /** - * @brief Get the view matrix (inverse of pose) for the given eye of a
        + * Get the view matrix (inverse of pose) for the given eye of a
        * viewer in a display config - matrix of **floats**.
        * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
        + * @param mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
        * matrix from room space to eye space (not relative to pose of the viewer)
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
        * yet available, in which case the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeViewMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_MatrixConventions, float*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeViewMatrixf(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.FloatBuffer)} and {@link #osvrClientGetViewerEyeViewMatrixf(com.sun.jna.Pointer, int, byte, short, com.sun.jna.ptr.FloatByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeViewMatrixf(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, short, java.nio.FloatBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeViewMatrixf(Pointer disp, int viewer, byte eye, short flags, FloatByReference mat); /** - * @brief Get the view matrix (inverse of pose) for the given eye of a
        + * Get the view matrix (inverse of pose) for the given eye of a
        * viewer in a display config - matrix of **floats**.
        * Will only succeed if osvrClientCheckDisplayStartup() succeeds.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
        + * @param mat Pass a float[::OSVR_MATRIX_SIZE] to get the transformation
        * matrix from room space to eye space (not relative to pose of the viewer)
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed or no pose was
        * yet available, in which case the output argument is unmodified.
        @@ -427,39 +441,39 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetViewerEyeViewMatrixf(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, short flags, FloatBuffer mat); /** - * @brief Each eye of each viewer in a display config has one or more surfaces
        + * Each eye of each viewer in a display config has one or more surfaces
        * (aka "screens") on which content should be rendered.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        - * @param[out] surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
        + * @param surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
        * given viewer and eye. **Constant** throughout the active, valid lifetime of
        * a display config object.
        - * @sa OSVR_SurfaceCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount*)
        - * @deprecated use the safer methods {@link #osvrClientGetNumSurfacesForViewerEye(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, java.nio.IntBuffer)} and {@link #osvrClientGetNumSurfacesForViewerEye(com.sun.jna.Pointer, int, byte, com.sun.jna.ptr.IntByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetNumSurfacesForViewerEye(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, java.nio.IntBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetNumSurfacesForViewerEye(Pointer disp, int viewer, byte eye, IntByReference surfaces); /** - * @brief Each eye of each viewer in a display config has one or more surfaces
        + * Each eye of each viewer in a display config has one or more surfaces
        * (aka "screens") on which content should be rendered.
        * @param disp Display config object
        * @param viewer Viewer ID
        * @param eye Eye ID
        - * @param[out] surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
        + * @param surfaces Number of surfaces (numbered [0, surfaces - 1]) for the
        * given viewer and eye. **Constant** throughout the active, valid lifetime of
        * a display config object.
        - * @sa OSVR_SurfaceCount
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetNumSurfacesForViewerEye(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount*) */ public static native byte osvrClientGetNumSurfacesForViewerEye(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, IntBuffer surfaces); /** - * @brief Get the dimensions/location of the viewport **within the display
        + * Get the dimensions/location of the viewport **within the display
        * input** for a surface seen by an eye of a viewer in a display config. (This
        * does not include other video inputs that may be on a single virtual desktop,
        * etc. or explicitly account for display configurations that use multiple
        @@ -470,21 +484,23 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] left Output: Distance in pixels from the left of the video input
        + * @param left Output: Distance in pixels from the left of the video input
        * to the left of the viewport.
        - * @param[out] bottom Output: Distance in pixels from the bottom of the video
        + * @param bottom Output: Distance in pixels from the bottom of the video
        * input to the bottom of the viewport.
        - * @param[out] width Output: Width of viewport in pixels.
        - * @param[out] height Output: Height of viewport in pixels.
        + * @param width Output: Width of viewport in pixels.
        + * @param height Output: Height of viewport in pixels.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output arguments are unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*)
        - * @deprecated use the safer methods {@link #osvrClientGetRelativeViewportForViewerEyeSurface(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer)} and {@link #osvrClientGetRelativeViewportForViewerEyeSurface(com.sun.jna.Pointer, int, byte, int, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetRelativeViewportForViewerEyeSurface(Pointer disp, int viewer, byte eye, int surface, IntByReference left, IntByReference bottom, IntByReference width, IntByReference height); /** - * @brief Get the dimensions/location of the viewport **within the display
        + * Get the dimensions/location of the viewport **within the display
        * input** for a surface seen by an eye of a viewer in a display config. (This
        * does not include other video inputs that may be on a single virtual desktop,
        * etc. or explicitly account for display configurations that use multiple
        @@ -495,19 +511,19 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] left Output: Distance in pixels from the left of the video input
        + * @param left Output: Distance in pixels from the left of the video input
        * to the left of the viewport.
        - * @param[out] bottom Output: Distance in pixels from the bottom of the video
        + * @param bottom Output: Distance in pixels from the bottom of the video
        * input to the bottom of the viewport.
        - * @param[out] width Output: Width of viewport in pixels.
        - * @param[out] height Output: Height of viewport in pixels.
        + * @param width Output: Width of viewport in pixels.
        + * @param height Output: Height of viewport in pixels.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output arguments are unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetRelativeViewportForViewerEyeSurface(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*, OSVR_ViewportDimension*) */ public static native byte osvrClientGetRelativeViewportForViewerEyeSurface(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, IntBuffer left, IntBuffer bottom, IntBuffer width, IntBuffer height); /** - * @brief Get the index of the display input for a surface seen by an eye of a
        + * Get the index of the display input for a surface seen by an eye of a
        * viewer in a display config.
        * This is the OSVR-assigned display input: it may not (and in practice,
        * usually will not) match any platform-specific display indices. This function
        @@ -517,21 +533,23 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] displayInput Zero-based index of the display input pixels for
        + * @param displayInput Zero-based index of the display input pixels for
        * this surface are tranmitted over.
        * This association is **constant** throughout the active, valid lifetime of a
        * display config object.
        - * @sa osvrClientGetNumDisplayInputs(),
        - * osvrClientGetRelativeViewportForViewerEyeSurface()
        + * @see #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer) + * @see #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer) * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which
        * case the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceDisplayInputIndex(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DisplayInputCount*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeSurfaceDisplayInputIndex(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} and {@link #osvrClientGetViewerEyeSurfaceDisplayInputIndex(com.sun.jna.Pointer, int, byte, int, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceDisplayInputIndex(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(Pointer disp, int viewer, byte eye, int surface, Pointer displayInput); /** - * @brief Get the index of the display input for a surface seen by an eye of a
        + * Get the index of the display input for a surface seen by an eye of a
        * viewer in a display config.
        * This is the OSVR-assigned display input: it may not (and in practice,
        * usually will not) match any platform-specific display indices. This function
        @@ -541,19 +559,19 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] displayInput Zero-based index of the display input pixels for
        + * @param displayInput Zero-based index of the display input pixels for
        * this surface are tranmitted over.
        * This association is **constant** throughout the active, valid lifetime of a
        * display config object.
        - * @sa osvrClientGetNumDisplayInputs(),
        - * osvrClientGetRelativeViewportForViewerEyeSurface()
        + * @see #osvrClientGetNumDisplayInputs(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, java.nio.ByteBuffer) + * @see #osvrClientGetRelativeViewportForViewerEyeSurface(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer, java.nio.IntBuffer) * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which
        * case the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceDisplayInputIndex(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DisplayInputCount*) */ public static native byte osvrClientGetViewerEyeSurfaceDisplayInputIndex(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, ByteBuffer displayInput); /** - * @brief Get the projection matrix for a surface seen by an eye of a viewer
        + * Get the projection matrix for a surface seen by an eye of a viewer
        * in a display config. (double version)
        * @param disp Display config object
        * @param viewer Viewer ID
        @@ -564,17 +582,19 @@ public class OsvrDisplayLibrary implements Library { * @param far Distance from viewpoint to far clipping plane - must be positive
        * and not equal to near, typically greater than near.
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] matrix Output projection matrix: supply an array of 16
        + * @param matrix Output projection matrix: supply an array of 16
        * (::OSVR_MATRIX_SIZE) doubles.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixd(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double, double, OSVR_MatrixConventions, double*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixd(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, double, double, short, java.nio.DoubleBuffer)} and {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixd(com.sun.jna.Pointer, int, byte, int, double, double, short, com.sun.jna.ptr.DoubleByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixd(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, double, double, short, java.nio.DoubleBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(Pointer disp, int viewer, byte eye, int surface, double near, double far, short flags, DoubleByReference matrix); /** - * @brief Get the projection matrix for a surface seen by an eye of a viewer
        + * Get the projection matrix for a surface seen by an eye of a viewer
        * in a display config. (double version)
        * @param disp Display config object
        * @param viewer Viewer ID
        @@ -585,7 +605,7 @@ public class OsvrDisplayLibrary implements Library { * @param far Distance from viewpoint to far clipping plane - must be positive
        * and not equal to near, typically greater than near.
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] matrix Output projection matrix: supply an array of 16
        + * @param matrix Output projection matrix: supply an array of 16
        * (::OSVR_MATRIX_SIZE) doubles.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        @@ -593,7 +613,7 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixd(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, double near, double far, short flags, DoubleBuffer matrix); /** - * @brief Get the projection matrix for a surface seen by an eye of a viewer
        + * Get the projection matrix for a surface seen by an eye of a viewer
        * in a display config. (float version)
        * @param disp Display config object
        * @param viewer Viewer ID
        @@ -604,17 +624,19 @@ public class OsvrDisplayLibrary implements Library { * @param far Distance to far clipping plane - must be nonzero, typically
        * positive and greater than near.
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] matrix Output projection matrix: supply an array of 16
        + * @param matrix Output projection matrix: supply an array of 16
        * (::OSVR_MATRIX_SIZE) floats.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionMatrixf(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, float, float, OSVR_MatrixConventions, float*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixf(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, float, float, short, java.nio.FloatBuffer)} and {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixf(com.sun.jna.Pointer, int, byte, int, float, float, short, com.sun.jna.ptr.FloatByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceProjectionMatrixf(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, float, float, short, java.nio.FloatBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(Pointer disp, int viewer, byte eye, int surface, float near, float far, short flags, FloatByReference matrix); /** - * @brief Get the projection matrix for a surface seen by an eye of a viewer
        + * Get the projection matrix for a surface seen by an eye of a viewer
        * in a display config. (float version)
        * @param disp Display config object
        * @param viewer Viewer ID
        @@ -625,7 +647,7 @@ public class OsvrDisplayLibrary implements Library { * @param far Distance to far clipping plane - must be nonzero, typically
        * positive and greater than near.
        * @param flags Bitwise OR of matrix convention flags (see @ref MatrixFlags)
        - * @param[out] matrix Output projection matrix: supply an array of 16
        + * @param matrix Output projection matrix: supply an array of 16
        * (::OSVR_MATRIX_SIZE) floats.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        @@ -633,7 +655,7 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetViewerEyeSurfaceProjectionMatrixf(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, float near, float far, short flags, FloatBuffer matrix); /** - * @brief Get the clipping planes (positions at unit distance) for a surface
        + * Get the clipping planes (positions at unit distance) for a surface
        * seen by an eye of a viewer
        * in a display config.
        * This is only for use in integrations that cannot accept a fully-formulated
        @@ -648,19 +670,21 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] left Distance to left clipping plane
        - * @param[out] right Distance to right clipping plane
        - * @param[out] bottom Distance to bottom clipping plane
        - * @param[out] top Distance to top clipping plane
        + * @param left Distance to left clipping plane
        + * @param right Distance to right clipping plane
        + * @param bottom Distance to bottom clipping plane
        + * @param top Distance to top clipping plane
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output arguments are unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double*, double*, double*, double*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer)} and {@link #osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(com.sun.jna.Pointer, int, byte, int, com.sun.jna.ptr.DoubleByReference, com.sun.jna.ptr.DoubleByReference, com.sun.jna.ptr.DoubleByReference, com.sun.jna.ptr.DoubleByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer, java.nio.DoubleBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(Pointer disp, int viewer, byte eye, int surface, DoubleByReference left, DoubleByReference right, DoubleByReference bottom, DoubleByReference top); /** - * @brief Get the clipping planes (positions at unit distance) for a surface
        + * Get the clipping planes (positions at unit distance) for a surface
        * seen by an eye of a viewer
        * in a display config.
        * This is only for use in integrations that cannot accept a fully-formulated
        @@ -675,17 +699,17 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] left Distance to left clipping plane
        - * @param[out] right Distance to right clipping plane
        - * @param[out] bottom Distance to bottom clipping plane
        - * @param[out] top Distance to top clipping plane
        + * @param left Distance to left clipping plane
        + * @param right Distance to right clipping plane
        + * @param bottom Distance to bottom clipping plane
        + * @param top Distance to top clipping plane
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output arguments are unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, double*, double*, double*, double*) */ public static native byte osvrClientGetViewerEyeSurfaceProjectionClippingPlanes(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, DoubleBuffer left, DoubleBuffer right, DoubleBuffer bottom, DoubleBuffer top); /** - * @brief Determines if a surface seen by an eye of a viewer in a display
        + * Determines if a surface seen by an eye of a viewer in a display
        * config requests some distortion to be performed.
        * This simply reports true or false, and does not specify which kind of
        * distortion implementations have been parameterized for this display. For
        @@ -695,18 +719,20 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] distortionRequested Output parameter: whether distortion is
        + * @param distortionRequested Output parameter: whether distortion is
        * requested. **Constant** throughout the active, valid lifetime of a display
        * config object.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientDoesViewerEyeSurfaceWantDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_CBool*)
        - * @deprecated use the safer methods {@link #osvrClientDoesViewerEyeSurfaceWantDistortion(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} and {@link #osvrClientDoesViewerEyeSurfaceWantDistortion(com.sun.jna.Pointer, int, byte, int, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientDoesViewerEyeSurfaceWantDistortion(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.ByteBuffer)} + * instead */ @Deprecated public static native byte osvrClientDoesViewerEyeSurfaceWantDistortion(Pointer disp, int viewer, byte eye, int surface, Pointer distortionRequested); /** - * @brief Determines if a surface seen by an eye of a viewer in a display
        + * Determines if a surface seen by an eye of a viewer in a display
        * config requests some distortion to be performed.
        * This simply reports true or false, and does not specify which kind of
        * distortion implementations have been parameterized for this display. For
        @@ -716,7 +742,7 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] distortionRequested Output parameter: whether distortion is
        + * @param distortionRequested Output parameter: whether distortion is
        * requested. **Constant** throughout the active, valid lifetime of a display
        * config object.
        * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        @@ -725,7 +751,7 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientDoesViewerEyeSurfaceWantDistortion(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, ByteBuffer distortionRequested); /** - * @brief Returns the priority/availability of radial distortion parameters for
        + * Returns the priority/availability of radial distortion parameters for
        * a surface seen by an eye of a viewer in a display config.
        * If osvrClientDoesViewerEyeSurfaceWantDistortion() reports false, then the
        * display does not request distortion of any sort, and thus neither this nor
        @@ -735,7 +761,7 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] priority Output: the priority level. Negative values
        + * @param priority Output: the priority level. Negative values
        * (canonically OSVR_DISTORTION_PRIORITY_UNAVAILABLE) indicate this technique
        * not available, higher values indicate higher preference for the given
        * technique based on the device's description. **Constant** throughout the
        @@ -743,12 +769,14 @@ public class OsvrDisplayLibrary implements Library { * @return OSVR_RETURN_FAILURE if invalid parameters were passed, in which case
        * the output argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_DistortionPriority*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeSurfaceRadialDistortionPriority(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer)} and {@link #osvrClientGetViewerEyeSurfaceRadialDistortionPriority(com.sun.jna.Pointer, int, byte, int, com.sun.jna.ptr.IntByReference)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceRadialDistortionPriority(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, java.nio.IntBuffer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(Pointer disp, int viewer, byte eye, int surface, IntByReference priority); /** - * @brief Returns the priority/availability of radial distortion parameters for
        + * Returns the priority/availability of radial distortion parameters for
        * a surface seen by an eye of a viewer in a display config.
        * If osvrClientDoesViewerEyeSurfaceWantDistortion() reports false, then the
        * display does not request distortion of any sort, and thus neither this nor
        @@ -758,7 +786,7 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] priority Output: the priority level. Negative values
        + * @param priority Output: the priority level. Negative values
        * (canonically OSVR_DISTORTION_PRIORITY_UNAVAILABLE) indicate this technique
        * not available, higher values indicate higher preference for the given
        * technique based on the device's description. **Constant** throughout the
        @@ -769,7 +797,7 @@ public class OsvrDisplayLibrary implements Library { */ public static native byte osvrClientGetViewerEyeSurfaceRadialDistortionPriority(OsvrDisplayLibrary.OSVR_DisplayConfig disp, int viewer, byte eye, int surface, IntBuffer priority); /** - * @brief Returns the radial distortion parameters, if known/requested, for a
        + * Returns the radial distortion parameters, if known/requested, for a
        * surface seen by an eye of a viewer in a display config.
        * Will only succeed if osvrClientGetViewerEyeSurfaceRadialDistortionPriority()
        * reports a non-negative priority.
        @@ -777,17 +805,19 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] params Output: the parameters for radial distortion
        + * @param params Output: the parameters for radial distortion
        * @return OSVR_RETURN_FAILURE if this surface does not have these parameters
        * described, or if invalid parameters were passed, in which case the output
        * argument is unmodified.
        * Original signature : OSVR_ReturnCode osvrClientGetViewerEyeSurfaceRadialDistortion(OSVR_DisplayConfig, OSVR_ViewerCount, OSVR_EyeCount, OSVR_SurfaceCount, OSVR_RadialDistortionParameters*)
        - * @deprecated use the safer methods {@link #osvrClientGetViewerEyeSurfaceRadialDistortion(osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, com.sun.jna.Pointer)} and {@link #osvrClientGetViewerEyeSurfaceRadialDistortion(com.sun.jna.Pointer, int, byte, int, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrClientGetViewerEyeSurfaceRadialDistortion(com.jme3.system.osvr.osvrdisplay.OsvrDisplayLibrary.OSVR_DisplayConfig, int, byte, int, com.sun.jna.Pointer)} + * instead */ @Deprecated public static native byte osvrClientGetViewerEyeSurfaceRadialDistortion(Pointer disp, int viewer, byte eye, int surface, Pointer params); /** - * @brief Returns the radial distortion parameters, if known/requested, for a
        + * Returns the radial distortion parameters, if known/requested, for a
        * surface seen by an eye of a viewer in a display config.
        * Will only succeed if osvrClientGetViewerEyeSurfaceRadialDistortionPriority()
        * reports a non-negative priority.
        @@ -795,7 +825,7 @@ public class OsvrDisplayLibrary implements Library { * @param viewer Viewer ID
        * @param eye Eye ID
        * @param surface Surface ID
        - * @param[out] params Output: the parameters for radial distortion
        + * @param params Output: the parameters for radial distortion
        * @return OSVR_RETURN_FAILURE if this surface does not have these parameters
        * described, or if invalid parameters were passed, in which case the output
        * argument is unmodified.
        diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java index e32f3813a0..dde9fe4102 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrmatrixconventions/OsvrMatrixConventionsLibrary.java @@ -63,7 +63,7 @@ public static interface OSVR_ProjectionMatrixZFlags { /** Original signature : void osvrVec3SetZ(OSVR_Vec3*, double) */ public static native void osvrVec3SetZ(OSVR_Vec3 v, double val); /** - * @brief Set a Vec3 to the zero vector
        + * Set a Vec3 to the zero vector
        * Original signature : void osvrVec3Zero(OSVR_Vec3*) */ public static native void osvrVec3Zero(OSVR_Vec3 v); @@ -84,89 +84,99 @@ public static interface OSVR_ProjectionMatrixZFlags { /** Original signature : void osvrQuatSetZ(OSVR_Quaternion*, double) */ public static native void osvrQuatSetZ(OSVR_Quaternion q, double val); /** - * @brief Set a quaternion to the identity rotation
        + * Set a quaternion to the identity rotation
        * Original signature : void osvrQuatSetIdentity(OSVR_Quaternion*) */ public static native void osvrQuatSetIdentity(OSVR_Quaternion q); /** - * @brief Set a pose to identity
        + * Set a pose to identity
        * Original signature : void osvrPose3SetIdentity(OSVR_Pose3*) */ public static native void osvrPose3SetIdentity(OSVR_Pose3 pose); /** - * @brief Set a matrix of doubles based on a Pose3.
        + * Set a matrix of doubles based on a Pose3.
        * @param pose The Pose3 to convert
        * @param flags Memory ordering flag - see @ref MatrixFlags
        - * @param[out] mat an array of 16 doubles
        + * @param mat an array of 16 doubles
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrixd(const OSVR_Pose3*, OSVR_MatrixConventions, double*)
        - * @deprecated use the safer methods {@link #osvrPose3ToMatrixd(osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} and {@link #osvrPose3ToMatrixd(osvrmatrixconventions.OSVR_Pose3, short, com.sun.jna.ptr.DoubleByReference)} instead + * @deprecated use the safer method + * {@link #osvrPose3ToMatrixd(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} + * instead */ @Deprecated public static native byte osvrPose3ToMatrixd(OSVR_Pose3 pose, short flags, DoubleByReference mat); /** - * @brief Set a matrix of doubles based on a Pose3.
        + * Set a matrix of doubles based on a Pose3.
        * @param pose The Pose3 to convert
        * @param flags Memory ordering flag - see @ref MatrixFlags
        - * @param[out] mat an array of 16 doubles
        + * @param mat an array of 16 doubles
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrixd(const OSVR_Pose3*, OSVR_MatrixConventions, double*) */ public static native byte osvrPose3ToMatrixd(OSVR_Pose3 pose, short flags, DoubleBuffer mat); /** - * @brief Set a matrix of floats based on a Pose3.
        + * Set a matrix of floats based on a Pose3.
        * @param pose The Pose3 to convert
        * @param flags Memory ordering flag - see @ref MatrixFlags
        - * @param[out] mat an array of 16 floats
        + * @param mat an array of 16 floats
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrixf(const OSVR_Pose3*, OSVR_MatrixConventions, float*)
        - * @deprecated use the safer methods {@link #osvrPose3ToMatrixf(osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} and {@link #osvrPose3ToMatrixf(osvrmatrixconventions.OSVR_Pose3, short, com.sun.jna.ptr.FloatByReference)} instead + * @deprecated use the safer method + * {@link #osvrPose3ToMatrixf(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} + * instead */ @Deprecated public static native byte osvrPose3ToMatrixf(OSVR_Pose3 pose, short flags, FloatByReference mat); /** - * @brief Set a matrix of floats based on a Pose3.
        + * Set a matrix of floats based on a Pose3.
        * @param pose The Pose3 to convert
        * @param flags Memory ordering flag - see @ref MatrixFlags
        - * @param[out] mat an array of 16 floats
        + * @param mat an array of 16 floats
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrixf(const OSVR_Pose3*, OSVR_MatrixConventions, float*) */ public static native byte osvrPose3ToMatrixf(OSVR_Pose3 pose, short flags, FloatBuffer mat); /** - * @brief Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        * type)
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, double*)
        - * @deprecated use the safer methods {@link #osvrPose3ToMatrix(osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} and {@link #osvrPose3ToMatrix(osvrmatrixconventions.OSVR_Pose3, short, com.sun.jna.ptr.DoubleByReference)} instead + * @deprecated use the safer method + * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} + * instead */ @Deprecated public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, DoubleByReference mat); /** - * @brief Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        * type)
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, double*) */ public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, DoubleBuffer mat); /** - * @brief Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        * type)
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, float*)
        - * @deprecated use the safer methods {@link #osvrPose3ToMatrix(osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} and {@link #osvrPose3ToMatrix(osvrmatrixconventions.OSVR_Pose3, short, com.sun.jna.ptr.FloatByReference)} instead + * @deprecated use the safer method + * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.FloatBuffer)} + * instead */ @Deprecated public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, FloatByReference mat); /** - * @brief Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        + * Set a matrix based on a Pose3. (C++-only overload - detecting scalar
        * type)
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, float*) */ public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, FloatBuffer mat); /** - * @brief Set a matrix based on a Pose3. (C++-only overload - detects scalar
        + * Set a matrix based on a Pose3. (C++-only overload - detects scalar
        * and takes array rather than pointer)
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, Scalar[OSVR_MATRIX_SIZE])
        - * @deprecated use the safer methods {@link #osvrPose3ToMatrix(osvrmatrixconventions.OSVR_Pose3, short, osvrmatrixconventions.OsvrMatrixConventionsLibrary.Scalar[])} and {@link #osvrPose3ToMatrix(osvrmatrixconventions.OSVR_Pose3, short, com.sun.jna.Pointer)} instead + * @deprecated use the safer method + * {@link #osvrPose3ToMatrix(com.jme3.system.osvr.osvrmatrixconventions.OSVR_Pose3, short, java.nio.DoubleBuffer)} + * instead */ @Deprecated public static native byte osvrPose3ToMatrix(OSVR_Pose3 pose, short flags, Pointer mat); /** - * @brief Set a matrix based on a Pose3. (C++-only overload - detects scalar
        + * Set a matrix based on a Pose3. (C++-only overload - detects scalar
        * and takes array rather than pointer)
        * Original signature : OSVR_ReturnCode osvrPose3ToMatrix(const OSVR_Pose3*, OSVR_MatrixConventions, Scalar[OSVR_MATRIX_SIZE]) */ diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java index 64e71afc6d..649c222d26 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanager/OsvrRenderManagerLibrary.java @@ -28,12 +28,12 @@ public static interface OSVR_OpenStatus { public static final int OSVR_OPEN_STATUS_COMPLETE = 2; }; /** - * @todo OSVR_RenderTimingInfo
        + * todo OSVR_RenderTimingInfo. * Original signature : OSVR_ReturnCode osvrDestroyRenderManager(OSVR_RenderManager) */ public static native byte osvrDestroyRenderManager(Pointer renderManager); /** - * @todo Make this actually cache, for now it does not.
        + * todo Make this actually cache, for now it does not.
        * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfo(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCount*) */ public static native byte osvrRenderManagerGetNumRenderInfo(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, NativeSizeByReference numRenderInfoOut); diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java index 7032d84576..e2bd8e7d6d 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OSVR_OpenResultsOpenGL.java @@ -10,7 +10,6 @@ */ public class OSVR_OpenResultsOpenGL extends Structure { /** - * @see OSVR_OpenStatus
        * C type : OSVR_OpenStatus */ public int status; diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java index 2e706c31d8..6b3a02f065 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrrendermanageropengl/OsvrRenderManagerOpenGLLibrary.java @@ -33,12 +33,12 @@ public static interface OSVR_OpenStatus { public static final int OSVR_OPEN_STATUS_COMPLETE = 2; }; /** - * @todo OSVR_RenderTimingInfo
        + * todo OSVR_RenderTimingInfo
        * Original signature : OSVR_ReturnCode osvrDestroyRenderManager(OSVR_RenderManager) */ public static native byte osvrDestroyRenderManager(Pointer renderManager); /** - * @todo Make this actually cache, for now it does not.
        + * todo Make this actually cache, for now it does not.
        * Original signature : OSVR_ReturnCode osvrRenderManagerGetNumRenderInfo(OSVR_RenderManager, OSVR_RenderParams, OSVR_RenderInfoCount*) */ public static native byte osvrRenderManagerGetNumRenderInfo(Pointer renderManager, OSVR_RenderParams.ByValue renderParams, NativeSizeByReference numRenderInfoOut); @@ -121,7 +121,9 @@ public static interface OSVR_OpenStatus { public static native byte OSVR_Projection_to_Unreal(FloatBuffer Unreal_out, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_ProjectionMatrix.ByValue projection_in); /** * Original signature : OSVR_ReturnCode osvrCreateRenderManagerOpenGL(OSVR_ClientContext, const char[], OSVR_GraphicsLibraryOpenGL, OSVR_RenderManager*, OSVR_RenderManagerOpenGL*)
        - * @deprecated use the safer methods {@link #osvrCreateRenderManagerOpenGL(com.jme3.system.osvr.osvrrendermanageropengl.OsvrRenderManagerOpenGLLibrary.OSVR_ClientContext, byte[], com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue, com.sun.jna.ptr.PointerByReference, com.sun.jna.ptr.PointerByReference)} and {@link #osvrCreateRenderManagerOpenGL(com.sun.jna.Pointer, com.sun.jna.Pointer, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue, com.sun.jna.ptr.PointerByReference, com.sun.jna.ptr.PointerByReference)} instead + * @deprecated use the safer method + * {@link #osvrCreateRenderManagerOpenGL(com.jme3.system.osvr.osvrclientkit.OsvrClientKitLibrary.OSVR_ClientContext, byte[], com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue, com.sun.jna.ptr.PointerByReference, com.sun.jna.ptr.PointerByReference)} + * instead */ @Deprecated public static native byte osvrCreateRenderManagerOpenGL(Pointer clientContext, Pointer graphicsLibraryName, com.jme3.system.osvr.osvrrendermanageropengl.OSVR_GraphicsLibraryOpenGL.ByValue graphicsLibrary, PointerByReference renderManagerOut, PointerByReference renderManagerOpenGLOut); diff --git a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java index 886c16d8f6..36382c7ae5 100644 --- a/jme3-vr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java +++ b/jme3-vr/src/main/java/com/jme3/system/osvr/osvrtimevalue/OsvrTimeValueLibrary.java @@ -19,12 +19,12 @@ public class OsvrTimeValueLibrary implements Library { public static final int OSVR_TRUE = (int)(1); public static final int OSVR_FALSE = (int)(0); /** - * @brief Gets the current time in the TimeValue. Parallel to gettimeofday.
        + * Gets the current time in the TimeValue. Parallel to gettimeofday. * Original signature : void osvrTimeValueGetNow(OSVR_TimeValue*) */ public static native void osvrTimeValueGetNow(OSVR_TimeValue dest); /** - * @brief Converts from a TimeValue struct to your system's struct timeval.
        + * Converts from a TimeValue struct to your system's struct timeval. * @param dest Pointer to an empty struct timeval for your platform.
        * @param src A pointer to an OSVR_TimeValue you'd like to convert from.
        * If either parameter is NULL, the function will return without doing
        @@ -33,7 +33,7 @@ public class OsvrTimeValueLibrary implements Library { */ public static native void osvrTimeValueToStructTimeval(OsvrTimeValueLibrary.timeval dest, OSVR_TimeValue src); /** - * @brief Converts from a TimeValue struct to your system's struct timeval.
        + * Converts from a TimeValue struct to your system's struct timeval. * @param dest An OSVR_TimeValue destination pointer.
        * @param src Pointer to a struct timeval you'd like to convert from.
        * The result is normalized.
        @@ -43,7 +43,7 @@ public class OsvrTimeValueLibrary implements Library { */ public static native void osvrStructTimevalToTimeValue(OSVR_TimeValue dest, OsvrTimeValueLibrary.timeval src); /** - * @brief "Normalizes" a time value so that the absolute number of microseconds
        + * "Normalizes" a time value so that the absolute number of microseconds * is less than 1,000,000, and that the sign of both components is the same.
        * @param tv Address of a struct TimeValue to normalize in place.
        * If the given pointer is NULL, this function returns without doing anything.
        @@ -51,7 +51,7 @@ public class OsvrTimeValueLibrary implements Library { */ public static native void osvrTimeValueNormalize(OSVR_TimeValue tv); /** - * @brief Sums two time values, replacing the first with the result.
        + * Sums two time values, replacing the first with the result. * @param tvA Destination and first source.
        * @param tvB second source
        * If a given pointer is NULL, this function returns without doing anything.
        @@ -60,7 +60,7 @@ public class OsvrTimeValueLibrary implements Library { */ public static native void osvrTimeValueSum(OSVR_TimeValue tvA, OSVR_TimeValue tvB); /** - * @brief Computes the difference between two time values, replacing the first
        + * Computes the difference between two time values, replacing the first * with the result.
        * Effectively, `*tvA = *tvA - *tvB`
        * @param tvA Destination and first source.
        @@ -71,7 +71,7 @@ public class OsvrTimeValueLibrary implements Library { */ public static native void osvrTimeValueDifference(OSVR_TimeValue tvA, OSVR_TimeValue tvB); /** - * @brief Compares two time values (assumed to be normalized), returning
        + * Compares two time values (assumed to be normalized), returning * the same values as strcmp
        * @return <0 if A is earlier than B, 0 if they are the same, and >0 if A
        * is later than B.
        @@ -79,7 +79,7 @@ public class OsvrTimeValueLibrary implements Library { */ public static native int osvrTimeValueCmp(OSVR_TimeValue tvA, OSVR_TimeValue tvB); /** - * @brief Compute the difference between the two time values, returning the
        + * Compute the difference between the two time values, returning the * duration as a double-precision floating-point number of seconds.
        * Effectively, `ret = *tvA - *tvB`
        * @param tvA first source.
        @@ -89,7 +89,7 @@ public class OsvrTimeValueLibrary implements Library { */ public static native double osvrTimeValueDurationSeconds(OSVR_TimeValue tvA, OSVR_TimeValue tvB); /** - * @brief True if A is later than B
        + * True if A is later than B. * Original signature : OSVR_CBool osvrTimeValueGreater(const OSVR_TimeValue*, const OSVR_TimeValue*) */ public static native byte osvrTimeValueGreater(OSVR_TimeValue tvA, OSVR_TimeValue tvB);