基本调通 回调

This commit is contained in:
xsl
2025-11-29 23:44:22 +08:00
parent 1859706412
commit 835f768a4a
8 changed files with 311 additions and 76 deletions
+32 -13
View File
@@ -39,6 +39,12 @@ std::wstring ReadFileWithChinesePath(const std::wstring& filePath) {
return AppBase::UTF8ToWideString(context);
}
FaceApp* g_app;
void CppCallback(const string& motion_type)
{
g_app->changeMotion(motion_type.c_str());
}
int main() {
@@ -51,23 +57,23 @@ int main() {
Motion motion;
motion.type = "4";
motion.png_names.push_back("4.png");
//for (int i = 0; i < 25; ++i)
//{
// if (i < 10)
// {
// motion.png_names.push_back("00000" + std::to_string(i) + ".png");
// }
// else
// {
// motion.png_names.push_back("0000" + std::to_string(i) + ".png");
for (int i = 0; i < 25; ++i)
{
if (i < 10)
{
motion.png_names.push_back("00000" + std::to_string(i) + ".png");
}
else
{
motion.png_names.push_back("0000" + std::to_string(i) + ".png");
// }
//
//}
}
}
#
init_arg.motion = motion;
//init_arg.motion = motion;
init_arg.action_fps = 10;
@@ -76,9 +82,22 @@ int main() {
string json_str = json(init_arg).dump();
FaceApp app;
g_app = &app;
app.SetInitArg(json_str.c_str());
app.initVulkan();
app._running = true;
auto motion_json = json(motion);
if (!motion_json.is_object()) {
std::cout << "Invalid JSON structure" << std::endl;
}
std::string motion_str = motion_json.dump();
// 添加完整性检查
if (motion_str.empty()) {
std::cout << "Warning: Empty motion string" << std::endl;
}
app.preReadyMotion(motion_str, CppCallback);
app.mainLoop();
//try {
// app.mainLoop();