diff --git a/CMakeLists.txt b/CMakeLists.txt index 248c860..4167589 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4 FATAL_ERROR) cmake_policy(VERSION 2.8) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") -set(NAME games_106) +set(NAME PlumageRender) project(${NAME}) diff --git a/base/VulkanTools.cpp b/base/VulkanTools.cpp index dc3e8bf..33bb259 100644 --- a/base/VulkanTools.cpp +++ b/base/VulkanTools.cpp @@ -3,14 +3,34 @@ #if !(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK)) // iOS & macOS: VulkanExampleBase::getAssetPath() implemented externally to allow access to Objective-C components + const std::string getAssetPath() { #if defined(VK_USE_PLATFORM_ANDROID_KHR) return ""; #elif defined(VK_EXAMPLE_DATA_DIR) - return VK_EXAMPLE_DATA_DIR; -#else - return "./../data/"; + + if (_access("./../data/", 0) != -1) + { + + return "./../data/"; + } + else if (_access("./data/", 0) != -1) + { + + return "./data/"; + } + else if (_access("./../../data/", 0) != -1) + { + + return "../../data/"; + } + else + { + + return VK_EXAMPLE_DATA_DIR; + } + #endif } #endif diff --git a/base/ui.hpp b/base/ui.hpp index b01d924..53bec17 100644 --- a/base/ui.hpp +++ b/base/ui.hpp @@ -1,4 +1,4 @@ -/* +/* * Vulkan Example - Physical based rendering a glTF 2.0 model with image based lighting * * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de @@ -68,7 +68,7 @@ public: delete[] fontAsset; #else std::string ttfFilePath = getAssetPath() + "/STXINWEI.TTF"; - io.Fonts->AddFontFromFileTTF(ttfFilePath.data(), 16.0f); + io.Fonts->AddFontFromFileTTF(ttfFilePath.data(), 16.0f,NULL, io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); #endif io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight); fontTexture.loadFromBuffer(fontData, texWidth * texHeight * 4 * sizeof(char), VK_FORMAT_R8G8B8A8_UNORM, texWidth, texHeight, vulkanDevice, queue); diff --git a/src/render/render.cpp b/src/render/render.cpp index dc39d91..be54f49 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -1,4 +1,4 @@ - + #ifndef TINYGLTF_IMPLEMENTATION @@ -222,7 +222,12 @@ PlumageRender::PlumageRender() if (_access(assetpath.c_str(),0) != 0) { std::string msg = "Could not locate asset path in \"" + assetpath + "\".\nMake sure binary is run from correct relative directory!"; std::cerr << msg << std::endl; - exit(-1); + system("pause"); + //exit(-1); + } + else { + std::string msg = "asset path get " + assetpath; + std::cout << msg << std::endl; } readDirectory(assetpath + "environments", "*.ktx", environments, false); @@ -1679,9 +1684,9 @@ PlumageRender::PlumageRender() gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS)); - - if (gui->header("model")) { - if (gui->button(gui->string_to_utf8("open gltf model").c_str())) { + // TO DO : language switch + if (gui->header(chineseUI.model)) { + if (gui->button(chineseUI.openNewModel)) { std::string filename = ""; char buffer[MAX_PATH]; OPENFILENAME ofn; @@ -1703,7 +1708,7 @@ PlumageRender::PlumageRender() updateCBs = true; } } - if (gui->combo("Environment", selectedEnvironment, environments)) { + if (gui->combo(chineseUI.environmentMap, selectedEnvironment, environments)) { vkDeviceWaitIdle(device); loadEnvironment(environments[selectedEnvironment]); setupDescriptors(); @@ -1711,7 +1716,7 @@ PlumageRender::PlumageRender() } } - if (gui->header("Environment")) { + if (gui->header(chineseUI.environment)) { if (gui->checkbox("Background", &displayBackground)) { updateShaderParams = true; } @@ -1730,27 +1735,27 @@ PlumageRender::PlumageRender() const std::vector debugNamesInputs = { "none", "Base color", "Normal", "Occlusion", "Emissive", "Metallic", "Roughness" }; - if (gui->combo("input", &debugViewInputs, debugNamesInputs)) { + if (gui->combo(chineseUI.debugInput, &debugViewInputs, debugNamesInputs)) { shaderData.debugViewInputs = static_cast(debugViewInputs); updateShaderParams = true; } const std::vector debugNamesEquation = { "none", "Diff (l,n)", "F (l,h)", "G (l,v,h)", "D (h)", "Specular" }; - if (gui->combo("PBR equation", &debugViewEquation, debugNamesEquation)) { + if (gui->combo(chineseUI.debugPBREquation, &debugViewEquation, debugNamesEquation)) { shaderData.debugViewEquation = static_cast(debugViewEquation); updateShaderParams = true; } } if (models.scene.animations.size() > 0) { - if (gui->header("animation")) { - gui->checkbox("pause", &animate); + if (gui->header(chineseUI.animation)) { + gui->checkbox(chineseUI.pauseAnimation, &animate); std::vector animationNames; for (auto animation : models.scene.animations) { animationNames.push_back(animation.name); } - gui->combo("animation", &animationIndex, animationNames); + gui->combo(chineseUI.animationSeq, &animationIndex, animationNames); } } diff --git a/src/render/render.h b/src/render/render.h index ac1c411..aeeeac6 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include @@ -62,15 +62,15 @@ public: } shaderData; struct ChinesesUI { - const char * model = "u8ģ"; - const char* openNewModel = "gltfģ"; - const char* environmentMap = "ͼ"; - const char* environment = ""; - const char* debugInput = ""; - const char* debugPBREquation = "PBR"; - const char* animation = ""; - const char* pauseAnimation = "ͣ"; - const char* animationSeq = ""; + const char * model = "模型"; + const char* openNewModel = "打开新gltf模型"; + const char* environmentMap = "环境贴图"; + const char* environment = "环境光照"; + const char* debugInput = "输入"; + const char* debugPBREquation = "PBR计算参数"; + const char* animation = "动画"; + const char* pauseAnimation = "启用动画"; + const char* animationSeq = "动画序列"; }chineseUI; struct UniformBufferSet {