Commit 0c2a19e0 authored by Nicolas Van der Noot's avatar Nicolas Van der Noot
Browse files

mac os visu launch

parent 2937a0b7
......@@ -19,56 +19,7 @@ if (APPLE)
# possible paths for: 'j3dcore.jar'
set(TRIAL_PATHS_DLL
/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_41.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_42.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_43.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_44.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_46.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_47.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_48.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_49.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_50.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_52.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_53.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_54.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_56.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_57.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_58.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_59.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_61.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_62.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_63.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_64.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_65.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_66.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_68.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_69.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_70.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_73.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_74.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_76.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_77.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_78.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_81.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_82.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_83.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_84.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_85.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_86.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_87.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_88.jdk/Contents/Home/jre/lib/ext
/Library/Java/JavaVirtualMachines/jdk1.7.0_89.jdk/Contents/Home/jre/lib/ext
${ROBOTRAN_SOURCE_DIR}/mbsyspad_mac_os/lib
)
find_path(J3D_PATH j3dcore.jar ${TRIAL_PATHS_DLL})
......@@ -155,6 +106,16 @@ set(TRIAL_PATHS_DLL
C:/Program\ Files/Java/jdk1.7.0_87/jre/bin
C:/Program\ Files/Java/jdk1.7.0_88/jre/bin
C:/Program\ Files/Java/jdk1.7.0_89/jre/bin
C:/Program\ Files/Java/jdk1.7.0_90/jre/bin
C:/Program\ Files/Java/jdk1.7.0_91/jre/bin
C:/Program\ Files/Java/jdk1.7.0_92/jre/bin
C:/Program\ Files/Java/jdk1.7.0_93/jre/bin
C:/Program\ Files/Java/jdk1.7.0_94/jre/bin
C:/Program\ Files/Java/jdk1.7.0_95/jre/bin
C:/Program\ Files/Java/jdk1.7.0_96/jre/bin
C:/Program\ Files/Java/jdk1.7.0_97/jre/bin
C:/Program\ Files/Java/jdk1.7.0_98/jre/bin
C:/Program\ Files/Java/jdk1.7.0_99/jre/bin
C:/Program\ Files/Java/jdk1.8.0/jre/bin
C:/Program\ Files/Java/Java3D/1.5.2/bin
)
......
This diff is collapsed.
......@@ -34,10 +34,11 @@ find_path(SDL2_INCLUDE_PATH SDL_assert.h ${TRIAL_PATHS_INC_SDL_ASSERT})
find_library(SDL2_LIBRARIES SDL2)
if (NOT SDL2_LIBRARIES)
find_library(SDL2_LIBRARIES_SDL2 libSDL2.dylib ${TRIAL_PATHS_LIB_SDL2})
set(SDL2_LIBRARIES ${SDL2_LIBRARIES_SDL2} "-framework Cocoa")
find_library(SDL2_LIBRARIES libSDL2.dylib ${TRIAL_PATHS_LIB_SDL2})
endif ( )
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} "-framework Cocoa")
## ---------------- ##
......
......@@ -49,7 +49,11 @@ if (FLAG_VISU)
include_directories("./java")
increment_src( ${PROJECT_SOURCE_DIR}/java )
set(JAR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../mbsyspad/MBsysPad.jar)
if (APPLE)
set(JAR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../mbsyspad_mac_os/MBsysPad.jar)
else ( )
set(JAR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../mbsyspad/MBsysPad.jar)
endif ( )
configure_file (
"./java/conf/cmake_java_config.h.in"
......
......@@ -7,18 +7,16 @@
#include <stdlib.h>
#if defined(__APPLE__) || defined(__MACH__)
#define APPLE_VISU
#ifdef APPLE_VISU
#include <unistd.h>
#include <CoreFoundation/CoreFoundation.h>
#include <pthread.h>
pid_t pid_fork; ///< PID of the fork
#endif
// version of the JDK
#define JNI_VERSION JNI_VERSION_1_6
// path to the jar file containing mbsyspad bynary code
//#define JAR_PATH ROBOTRAN_SOURCE_DIR"/mbsyspad/MBsysPad.jar"
#define START_VIEWPOINT 0 ///< default initial viewpoint
/*! \brief instantiate a java virtual machine so as to access to the 3D animation facilities of MBSysPad
......@@ -83,11 +81,19 @@ JNIEnv* create_vm()
*
* \param[in,out] jni_in_out inputs and output of the JNI structure
*/
void* start_jni(JNI_in_out *jni_in_out)
#ifdef APPLE_VISU
void* start_jni(void *args)
#else
void start_jni(JNI_in_out *jni_in_out)
#endif
{
// - - - - - - - - - - - - - - - - -
// declaration for 3D view with JNI
#ifdef APPLE_VISU
JNI_in_out *jni_in_out;
#endif
jclass animFrameClass, PadModelClass, MbsModelJ3DClass;
jmethodID constructor;
jmethodID loadMethod, setLocMethod;
......@@ -103,6 +109,10 @@ void* start_jni(JNI_in_out *jni_in_out)
// - - - - - - - - - - - - - - - - - - - - - - -
// initialise jni variable for 3D visualisation
#ifdef APPLE_VISU
jni_in_out = (JNI_in_out*) args;
#endif
env = create_vm();
animFrameClass = (*env)->FindClass(env, "be/robotran/test/LiveSimAnimFrame");
......@@ -163,6 +173,11 @@ void* start_jni(JNI_in_out *jni_in_out)
jni_in_out->jni_struct->obj = obj;
jni_in_out->jni_struct->setVpMethod = setVpMethod;
jni_in_out->jni_struct->model3D = model3D;
#ifdef APPLE_VISU
return (0);
#endif
}
/*! \brief initialize the JNI structure
......@@ -177,6 +192,10 @@ void init_jni(Realtime_java *java, int nb_q, double *q_vec, char *mbs_file, int
JNI_in_out jni_in_out;
JNI_struct *jni_struct;
#ifdef APPLE_VISU
pthread_t thr;
#endif
// inputs
jni_in_out.nb_q = nb_q;
jni_in_out.start_viewpoint = start_viewpoint;
......@@ -204,12 +223,17 @@ void init_jni(Realtime_java *java, int nb_q, double *q_vec, char *mbs_file, int
if (!pid_fork) // son, in charge of the visualization
{
close(jni_in_out.jni_struct->tube[1]);
java->jni_struct = jni_in_out.jni_struct;
// JNI initialization
start_jni(&jni_in_out);
close(jni_in_out.jni_struct->tube[1]);
java->jni_struct = jni_in_out.jni_struct;
// JNI run
if (pthread_create(&thr, NULL, start_jni, &jni_in_out))
{
printf("Error: JNI thread not properly created !\n");
exit(EXIT_FAILURE);
}
CFRunLoopRun();
}
else // father, in charge of all simulation, except visualization
{
......
......@@ -13,6 +13,10 @@
#include "realtime.h"
#include "mbs_data.h"
#if defined(__APPLE__) || defined(__MACH__)
#define APPLE_VISU
#endif
// -- Structures -- //
/*! \brief JNI (Java Native Interface) main structure
......@@ -26,7 +30,7 @@ typedef struct JNI_struct
jmethodID setVpMethod; ///< used to define the viewpoint
jobject model3D; ///< model 3D
#if defined(__APPLE__) || defined(__MACH__)
#ifdef APPLE_VISU
int tube[2]; ///< descriptor tube
#endif
......@@ -49,7 +53,12 @@ typedef struct JNI_in_out
JNIEnv* create_vm(void);
void init_jni(Realtime_java *java, int nb_q, double *q_vec, char *mbs_file, int start_viewpoint);
void* start_jni(JNI_in_out *jni_in_out);
#ifdef APPLE_VISU
void* start_jni(void *args);
#else
void start_jni(JNI_in_out *jni_in_out);
#endif
void update_jni(JNI_struct *jni_struct, Realtime_java *java, int nb_q, double *q_vec);
void free_jni(JNI_struct *jni_struct);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment