|
@@ -59,7 +59,7 @@ import java.util.Set;
|
|
|
* Pointer comparison will fail.
|
|
|
*/
|
|
|
public final class Jassimp {
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* The default wrapper provider using built in types.
|
|
|
*/
|
|
@@ -91,6 +91,8 @@ public final class Jassimp {
|
|
|
public static AiScene importFile(String filename,
|
|
|
Set<AiPostProcessSteps> postProcessing) throws IOException {
|
|
|
|
|
|
+ loadLibrary();
|
|
|
+
|
|
|
return aiImportFile(filename, AiPostProcessSteps.toRawValue(
|
|
|
postProcessing));
|
|
|
}
|
|
@@ -177,6 +179,11 @@ public final class Jassimp {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static void setLibraryLoader(JassimpLibraryLoader libraryLoader) {
|
|
|
+ s_libraryLoader = libraryLoader;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Helper method for wrapping a matrix.<p>
|
|
|
*
|
|
@@ -264,6 +271,35 @@ public final class Jassimp {
|
|
|
return s_wrapperProvider.wrapSceneNode(parent, matrix, meshRefs, name);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Helper method to load the library using the provided JassimpLibraryLoader.<p>
|
|
|
+ *
|
|
|
+ * Synchronized to avoid race conditions.
|
|
|
+ */
|
|
|
+ private static void loadLibrary()
|
|
|
+ {
|
|
|
+ if(!s_libraryLoaded)
|
|
|
+ {
|
|
|
+ synchronized(s_libraryLoadingLock)
|
|
|
+ {
|
|
|
+ if(!s_libraryLoaded)
|
|
|
+ {
|
|
|
+ s_libraryLoader.loadLibrary();
|
|
|
+ NATIVE_AIVEKTORKEY_SIZE = getVKeysize();
|
|
|
+ NATIVE_AIQUATKEY_SIZE = getQKeysize();
|
|
|
+ NATIVE_AIVEKTOR3D_SIZE = getV3Dsize();
|
|
|
+ NATIVE_FLOAT_SIZE = getfloatsize();
|
|
|
+ NATIVE_INT_SIZE = getintsize();
|
|
|
+ NATIVE_UINT_SIZE = getuintsize();
|
|
|
+ NATIVE_DOUBLE_SIZE = getdoublesize();
|
|
|
+ NATIVE_LONG_SIZE = getlongsize();
|
|
|
+
|
|
|
+ s_libraryLoaded = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* The native interface.
|
|
@@ -284,6 +320,25 @@ public final class Jassimp {
|
|
|
new AiBuiltInWrapperProvider();
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * The library loader to load the native library.
|
|
|
+ */
|
|
|
+ private static JassimpLibraryLoader s_libraryLoader =
|
|
|
+ new JassimpLibraryLoader();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Status flag if the library is loaded.
|
|
|
+ *
|
|
|
+ * Volatile to avoid problems with double checked locking.
|
|
|
+ *
|
|
|
+ */
|
|
|
+ private static volatile boolean s_libraryLoaded = false;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Lock for library loading.
|
|
|
+ */
|
|
|
+ private static final Object s_libraryLoadingLock = new Object();
|
|
|
+
|
|
|
/**
|
|
|
* Pure static class, no accessible constructor.
|
|
|
*/
|
|
@@ -291,24 +346,13 @@ public final class Jassimp {
|
|
|
/* nothing to do */
|
|
|
}
|
|
|
|
|
|
- public static final int NATIVE_AIVEKTORKEY_SIZE;
|
|
|
- public static final int NATIVE_AIQUATKEY_SIZE;
|
|
|
- public static final int NATIVE_AIVEKTOR3D_SIZE;
|
|
|
- public static final int NATIVE_FLOAT_SIZE;
|
|
|
- public static final int NATIVE_INT_SIZE;
|
|
|
- public static final int NATIVE_UINT_SIZE;
|
|
|
- public static final int NATIVE_DOUBLE_SIZE;
|
|
|
- public static final int NATIVE_LONG_SIZE;
|
|
|
+ public static int NATIVE_AIVEKTORKEY_SIZE;
|
|
|
+ public static int NATIVE_AIQUATKEY_SIZE;
|
|
|
+ public static int NATIVE_AIVEKTOR3D_SIZE;
|
|
|
+ public static int NATIVE_FLOAT_SIZE;
|
|
|
+ public static int NATIVE_INT_SIZE;
|
|
|
+ public static int NATIVE_UINT_SIZE;
|
|
|
+ public static int NATIVE_DOUBLE_SIZE;
|
|
|
+ public static int NATIVE_LONG_SIZE;
|
|
|
|
|
|
- static {
|
|
|
-// System.loadLibrary("jassimp");
|
|
|
- NATIVE_AIVEKTORKEY_SIZE = getVKeysize();
|
|
|
- NATIVE_AIQUATKEY_SIZE = getQKeysize();
|
|
|
- NATIVE_AIVEKTOR3D_SIZE = getV3Dsize();
|
|
|
- NATIVE_FLOAT_SIZE = getfloatsize();
|
|
|
- NATIVE_INT_SIZE = getintsize();
|
|
|
- NATIVE_UINT_SIZE = getuintsize();
|
|
|
- NATIVE_DOUBLE_SIZE = getdoublesize();
|
|
|
- NATIVE_LONG_SIZE = getlongsize();
|
|
|
- }
|
|
|
}
|