完成动画序列播放
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 16 KiB |
@@ -16,7 +16,7 @@ layout (location = 0) out vec4 outFragColor;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 pos = vec2(pushConstants.ux/2880.f, pushConstants.uy/2880.f);
|
vec2 pos = vec2(pushConstants.ux/2048.f, pushConstants.uy/2048.f);
|
||||||
vec2 uv = pos + vec2(inUV.x/8.f, inUV.y/8.f);
|
vec2 uv = pos + vec2(inUV.x/8.f, inUV.y/8.f);
|
||||||
vec4 color = texture(samplerColor, uv);
|
vec4 color = texture(samplerColor, uv);
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ void CppCallback()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
||||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnLoadActionFinished", "(Ljava/lang/String;)V");
|
jmethodID methodId = env->GetMethodID(callbackClass, "OnLoadMotionListFinished", "(Ljava/lang/String;)V");
|
||||||
if (methodId == nullptr) {
|
if (methodId == nullptr) {
|
||||||
env->ExceptionDescribe(); // 打印异常
|
env->ExceptionDescribe(); // 打印异常
|
||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
@@ -258,7 +258,7 @@ void CppAnimationFinishedCallback()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
||||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnAnimationFinished", "()V");
|
jmethodID methodId = env->GetMethodID(callbackClass, "OnPlayMotionListFinished", "()V");
|
||||||
if (methodId == nullptr) {
|
if (methodId == nullptr) {
|
||||||
env->ExceptionDescribe(); // 打印异常
|
env->ExceptionDescribe(); // 打印异常
|
||||||
env->ExceptionClear();
|
env->ExceptionClear();
|
||||||
@@ -313,6 +313,25 @@ Java_com_hmwl_face_1sdk_FaceActivity_PreReadAction(JNIEnv *env, jobject thiz, js
|
|||||||
return env->NewStringUTF(ret.c_str());
|
return env->NewStringUTF(ret.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char DELIMITER = 0x1F; // same as \u001F
|
||||||
|
|
||||||
|
std::vector<std::string> splitMotionString(const std::string& input) {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
if (input.empty()) return result;
|
||||||
|
|
||||||
|
size_t start = 0;
|
||||||
|
size_t pos = input.find(DELIMITER);
|
||||||
|
|
||||||
|
while (pos != std::string::npos) {
|
||||||
|
result.push_back(input.substr(start, pos - start));
|
||||||
|
start = pos + 1;
|
||||||
|
pos = input.find(DELIMITER, start);
|
||||||
|
}
|
||||||
|
// Add last part
|
||||||
|
result.push_back(input.substr(start));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
@@ -336,6 +355,18 @@ Java_com_hmwl_face_1sdk_FaceActivity_ChangeMotionCpp(JNIEnv *env, jobject thiz,
|
|||||||
|
|
||||||
if(g_Application->isInited())
|
if(g_Application->isInited())
|
||||||
{
|
{
|
||||||
g_Application->changeMotionList(CppAnimationFinishedCallback, loop);
|
std::vector<std::string> motions = splitMotionString(nativeString);
|
||||||
|
g_Application->changeMotionList(motions, CppAnimationFinishedCallback, loop);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_hmwl_face_1sdk_FaceActivity_StopMotionNative(JNIEnv *env, jobject thiz) {
|
||||||
|
g_Application->StopMotion();
|
||||||
|
}
|
||||||
|
extern "C"
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_com_hmwl_face_1sdk_FaceActivity_ResumeMotionNative(JNIEnv *env, jobject thiz) {
|
||||||
|
// TODO: implement ResumeMotionNative()
|
||||||
|
g_Application->ResumeMotion();
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,6 @@ import android.Manifest;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -31,7 +30,6 @@ import java.util.List;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.LandmarkerListener {
|
public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.LandmarkerListener {
|
||||||
private static final String TAG = "FaceActivity";
|
private static final String TAG = "FaceActivity";
|
||||||
@@ -141,6 +139,16 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
|||||||
StopRunning();
|
StopRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private native void StopMotionNative();
|
||||||
|
public void StopMotion(){
|
||||||
|
StopMotionNative();
|
||||||
|
}
|
||||||
|
|
||||||
|
private native void ResumeMotionNative();
|
||||||
|
public void ResumeMotion(){
|
||||||
|
ResumeMotionNative();
|
||||||
|
}
|
||||||
|
|
||||||
private native void StopRunning();
|
private native void StopRunning();
|
||||||
|
|
||||||
// Native 方法
|
// Native 方法
|
||||||
@@ -282,27 +290,39 @@ public class FaceActivity extends GameActivity implements FaceLandmarkerHelper.L
|
|||||||
|
|
||||||
protected native void SetCppInitArg(String json);
|
protected native void SetCppInitArg(String json);
|
||||||
|
|
||||||
protected void SetInitArg(String json)
|
public void SetInitArg(String json)
|
||||||
{
|
{
|
||||||
SetCppInitArg(json);
|
SetCppInitArg(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface CallbackInterface {
|
public interface LoadMotionListFinishedCallback {
|
||||||
void OnLoadActionFinished(String result);
|
void OnLoadMotionListFinished(String result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface AnimationFinishedCallbackInterface {
|
public interface PlayMotionListFinishedCallback {
|
||||||
void OnAnimationFinished();
|
void OnPlayMotionListFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected native String PreReadAction(String motion, CallbackInterface callback);
|
protected native String PreReadAction(String motion, LoadMotionListFinishedCallback callback);
|
||||||
protected String PreLoadAction(String json, CallbackInterface callback){
|
public String PreLoadAction(String json, LoadMotionListFinishedCallback callback){
|
||||||
return PreReadAction(json, callback);
|
return PreReadAction(json, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected native void ChangeMotionCpp(String json, AnimationFinishedCallbackInterface callback, boolean loop);
|
protected native void ChangeMotionCpp(String json, PlayMotionListFinishedCallback callback, boolean loop);
|
||||||
protected void ChangeMotionList(AnimationFinishedCallbackInterface callback, boolean loop){
|
public void PlayMotionList(List<String> motionList, boolean loop, PlayMotionListFinishedCallback callback)
|
||||||
ChangeMotionCpp("", callback, loop);
|
{
|
||||||
|
if(callback == null)
|
||||||
|
{
|
||||||
|
callback = new PlayMotionListFinishedCallback() {
|
||||||
|
@Override
|
||||||
|
public void OnPlayMotionListFinished() {
|
||||||
|
Log.i(TAG, "OnPlayMotionListFinished: ");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
final String DELIMITER = "\u001F"; // ASCII Unit Separator
|
||||||
|
String motion_list_str = String.join(DELIMITER, motionList);
|
||||||
|
ChangeMotionCpp(motion_list_str, callback, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加这个缺失的方法
|
// 添加这个缺失的方法
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 4.2 KiB |