动画编码完成
This commit is contained in:
@@ -20,7 +20,7 @@ void Application::initWindow()
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
|
||||
window = glfwCreateWindow(480*2, 480*2, "Vulkan", nullptr, nullptr);
|
||||
window = glfwCreateWindow(480, 480, "Vulkan", nullptr, nullptr);
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
+9
-9
@@ -460,16 +460,16 @@ void FaceApp::setup_descriptor_pool()
|
||||
{
|
||||
// 保守估计:假设每个描述符集可能有多个绑定
|
||||
const uint32_t setsCount = kMaxTexture;
|
||||
const uint32_t multiplier = 3; // 安全系数
|
||||
//const uint32_t multiplier = 3; // 安全系数
|
||||
|
||||
std::vector<VkDescriptorPoolSize> pool_sizes = {
|
||||
{
|
||||
.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
||||
.descriptorCount = setsCount * multiplier
|
||||
.descriptorCount = 3
|
||||
},
|
||||
{
|
||||
.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
|
||||
.descriptorCount = setsCount * multiplier
|
||||
.descriptorCount = setsCount + 4
|
||||
},
|
||||
// 如果需要其他类型的描述符,在这里添加
|
||||
};
|
||||
@@ -478,7 +478,7 @@ void FaceApp::setup_descriptor_pool()
|
||||
descriptor_pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
||||
descriptor_pool_info.poolSizeCount = static_cast<uint32_t>(pool_sizes.size());
|
||||
descriptor_pool_info.pPoolSizes = pool_sizes.data();
|
||||
descriptor_pool_info.maxSets = setsCount * 2; // 额外预留一些集合
|
||||
descriptor_pool_info.maxSets = setsCount + 7; // 额外预留一些集合
|
||||
descriptor_pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
|
||||
|
||||
VK_CHECK(vkCreateDescriptorPool(device, &descriptor_pool_info, nullptr, &descriptor_pool));
|
||||
@@ -652,7 +652,7 @@ void FaceApp::render(VkCommandBuffer commandBuffer, long long frameTime)
|
||||
if (game_time > actionTime)
|
||||
{
|
||||
_curTexIndex++;
|
||||
if (_curTexIndex >= _curMotion.png_num)
|
||||
if (_curTexIndex >= _curMotion.png_names.size())
|
||||
{
|
||||
_curTexIndex = 0;
|
||||
}
|
||||
@@ -1151,23 +1151,23 @@ void FaceApp::changeMotion(Motion& motion)
|
||||
return;
|
||||
}
|
||||
_curMotion = motion;
|
||||
for (int i = 0; i < _curMotion.png_num; ++i)
|
||||
for (int i = 0; i < _curMotion.png_names.size(); ++i)
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
//string path = _curMotion.type + "/" + _curMotion.technique + "/" + _curMotion.step + "/" + _curMotion.show_type;
|
||||
string path = "pic";
|
||||
string path_name = path + "/" + _curMotion.png_name;// +std::to_string(i) + ".png";
|
||||
string path_name = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i];// +std::to_string(i) + ".png";
|
||||
loadTextureExample(UTF8ToWideString(path_name), m_texs[i], true);
|
||||
if (kThick)
|
||||
{
|
||||
string path_name_ex = path + "/" + _curMotion.png_name + std::to_string(i) + "_thick.png";
|
||||
string path_name_ex = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i] + std::to_string(i) + "_thick.png";
|
||||
loadTextureExample(UTF8ToWideString(path_name_ex), m_texs_ex[i], true);
|
||||
}
|
||||
#else
|
||||
//string path = _curMotion.type + "/" + _curMotion.technique + "/" + _curMotion.step + "/" + _curMotion.show_type;
|
||||
string path = "pic";
|
||||
string path_name = path + "/" + _curMotion.png_name;// +std::to_string(i) + ".png";
|
||||
string path_name = path + "/" + _curMotion.type + "/" + _curMotion.png_names[i];// +std::to_string(i) + ".png";
|
||||
loadTexture(path_name, m_texs[i], true);
|
||||
if (kThick)
|
||||
{
|
||||
|
||||
+4
-8
@@ -13,15 +13,11 @@ using json = nlohmann::json;
|
||||
|
||||
struct Motion {
|
||||
string type;
|
||||
string technique;
|
||||
string step;
|
||||
string show_type;
|
||||
string png_name;
|
||||
int png_num;
|
||||
vector<string> png_names;
|
||||
string getMotionId() {
|
||||
return type + technique + step + show_type + png_name;
|
||||
return type;
|
||||
}
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Motion, type, technique, step, show_type, png_name, png_num)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(Motion, type, png_names)
|
||||
};
|
||||
|
||||
struct InitArg
|
||||
@@ -104,7 +100,7 @@ private:
|
||||
VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE;
|
||||
VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE;
|
||||
vector<VkDescriptorSet> m_descriptor_sets;
|
||||
const int kMaxTexture = 2;
|
||||
const int kMaxTexture = 30;
|
||||
vector<Texture> m_texs;
|
||||
vector<Texture> m_texs_ex;
|
||||
|
||||
|
||||
+16
-13
@@ -49,24 +49,27 @@ int main() {
|
||||
|
||||
InitArg init_arg;
|
||||
Motion motion;
|
||||
motion.type = "底妆";
|
||||
motion.technique = "基础上妆";
|
||||
motion.step = "2按压";
|
||||
motion.show_type = "方向示意图";
|
||||
motion.png_name = "4.png";
|
||||
motion.png_num = 1;
|
||||
motion.type = "action24";
|
||||
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;
|
||||
|
||||
//motion.type = "底妆";
|
||||
//motion.technique = "基础上妆";
|
||||
//motion.step = "2按压";
|
||||
//motion.show_type = "区域";
|
||||
//motion.png_name = "pic";
|
||||
//motion.png_num = 1;
|
||||
|
||||
init_arg.action_fps = 3;
|
||||
init_arg.action_fps = 10;
|
||||
init_arg.zoom = 1.5f;
|
||||
|
||||
string json_str = json(init_arg).dump();
|
||||
|
||||
Reference in New Issue
Block a user