关于旋转和旋转轴
参考:Android使用OpenGL ES 3.0实现随手指旋转3D立方体
glm库
下载 https://github.com/g-truc/glm/releases/download/0.9.9.8/glm-0.9.9.8.zip
使用
新建一个cpp项目或者module
解压glm 把 glm拷贝到include目录
配置CMakeLists.txt
使用
#include <jni.h> #include <string> #include <android/log.h> #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> #define TAG "GLM-JNI-TAG" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,TAG , __VA_ARGS__); #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,TAG , __VA_ARGS__); #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,TAG , __VA_ARGS__);extern "C" JNIEXPORT jfloatArray JNICALL Java_com_xx_libglm_GlmLib_cross(JNIEnv *env, jobject thiz, jfloat x, jfloat y, jfloat z, jfloat x2, jfloat y2, jfloat z2) { glm::vec3 cross = glm::cross(glm::vec3(x,y,z), glm::vec3(x2,y2, z2)); jfloatArray result = env->NewFloatArray(3); float* data = glm::value_ptr(cross); env->SetFloatArrayRegion(result,0,3,data); return result; }
Java
public class GlmLib { // Used to load the 'libglm' library on application startup. static { System.loadLibrary("libglm"); } /** * A native method that is implemented by the 'libglm' native library, * which is packaged with this application. */ public native String stringFromJNI(); public native float[] cross(float x,float y, float z,float x2,float y2,float z2); }标签:__,glm,记录,opengles,jfloat,float,TAG,Android,include From: https://www.cnblogs.com/Jieth/p/17203149.html