完成
This commit is contained in:
@@ -572,7 +572,7 @@ void TextureLoading::build_command_buffers()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
draw_point_cloud(draw_cmd_buffers[i]);
|
//draw_point_cloud(draw_cmd_buffers[i]);
|
||||||
//draw_point_cloud_line(draw_cmd_buffers[i]);
|
//draw_point_cloud_line(draw_cmd_buffers[i]);
|
||||||
|
|
||||||
|
|
||||||
@@ -582,7 +582,11 @@ void TextureLoading::build_command_buffers()
|
|||||||
VkDeviceSize offsets[1] = { 0 };
|
VkDeviceSize offsets[1] = { 0 };
|
||||||
vkCmdBindVertexBuffers(draw_cmd_buffers[i], 0, 1, vertex_buffer->get(), offsets);
|
vkCmdBindVertexBuffers(draw_cmd_buffers[i], 0, 1, vertex_buffer->get(), offsets);
|
||||||
vkCmdBindIndexBuffer(draw_cmd_buffers[i], index_buffer->get_handle(), 0, VK_INDEX_TYPE_UINT32);
|
vkCmdBindIndexBuffer(draw_cmd_buffers[i], index_buffer->get_handle(), 0, VK_INDEX_TYPE_UINT32);
|
||||||
vkCmdDrawIndexed(draw_cmd_buffers[i], index_count, 1, 0, 0, 0);
|
|
||||||
|
if (getCurrentTimeMillis() - last_update_time < 1000)
|
||||||
|
{
|
||||||
|
vkCmdDrawIndexed(draw_cmd_buffers[i], index_count, 1, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
//draw_ui(draw_cmd_buffers[i]);
|
//draw_ui(draw_cmd_buffers[i]);
|
||||||
|
|
||||||
@@ -692,7 +696,7 @@ bool TextureLoading::LoadOBJ(const std::string& filename,
|
|||||||
float u, v;
|
float u, v;
|
||||||
iss >> u >> v;
|
iss >> u >> v;
|
||||||
temp_texcoords.push_back(u);
|
temp_texcoords.push_back(u);
|
||||||
temp_texcoords.push_back(v);
|
temp_texcoords.push_back(1-v);
|
||||||
}
|
}
|
||||||
else if (type == "vn") { // 法线
|
else if (type == "vn") { // 法线
|
||||||
float nx, ny, nz;
|
float nx, ny, nz;
|
||||||
@@ -1659,6 +1663,8 @@ bool TextureLoading::prepare(const vkb::ApplicationOptions& options)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_update_time = getCurrentTimeMillis();
|
||||||
|
|
||||||
myFloatValue = 1.5f;
|
myFloatValue = 1.5f;
|
||||||
|
|
||||||
// --- 加载前景纹理 (示例) ---
|
// --- 加载前景纹理 (示例) ---
|
||||||
@@ -1692,9 +1698,9 @@ bool TextureLoading::prepare(const vkb::ApplicationOptions& options)
|
|||||||
dataSize = lineImage.size();
|
dataSize = lineImage.size();
|
||||||
processWithVulkan(lineImage.data(), width, height, rowStride, dataSize, texture_point_line);
|
processWithVulkan(lineImage.data(), width, height, rowStride, dataSize, texture_point_line);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char* filename_test = "assets/test_trans.png";
|
const char* filename_test = "assets/DemoHeadBaseColor.png";
|
||||||
#else
|
#else
|
||||||
const char* filename_test = "/sdcard/Android/data/com.khronos.vulkan_samples/files/assets/test_trans.png";
|
const char* filename_test = "/sdcard/Android/data/com.khronos.vulkan_samples/files/assets/DemoHeadBaseColor.png";
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
|
|
||||||
@@ -1844,7 +1850,7 @@ void ReceiveFacePoint(float* pos, int pointCount, int width, int height)
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
//debug_str += "]";
|
//debug_str += "]";
|
||||||
|
|
||||||
TextureLoading* self = TextureLoading::Get();
|
TextureLoading* self = TextureLoading::Get();
|
||||||
if (self != nullptr)
|
if (self != nullptr)
|
||||||
{
|
{
|
||||||
@@ -1923,6 +1929,8 @@ void TextureLoading::extendPoint(float* pos, int start_id, int end_id, float rat
|
|||||||
|
|
||||||
void TextureLoading::update_face_vertex_buffer(float* pos, int pointCount)
|
void TextureLoading::update_face_vertex_buffer(float* pos, int pointCount)
|
||||||
{
|
{
|
||||||
|
last_update_time = getCurrentTimeMillis();
|
||||||
|
|
||||||
extendPoint(pos, 68, 54);
|
extendPoint(pos, 68, 54);
|
||||||
extendPoint(pos, 104, 103);
|
extendPoint(pos, 104, 103);
|
||||||
extendPoint(pos, 69, 67);
|
extendPoint(pos, 69, 67);
|
||||||
|
|||||||
@@ -1,24 +1,4 @@
|
|||||||
/* Copyright (c) 2019-2024, Sascha Willems
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 the "License";
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Texture loading (and display) example (including mip maps)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ktx.h>
|
#include <ktx.h>
|
||||||
@@ -26,6 +6,8 @@
|
|||||||
#include "api_vulkan_sample.h"
|
#include "api_vulkan_sample.h"
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <chrono>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
// Vertex layout for this example
|
// Vertex layout for this example
|
||||||
struct TextureLoadingVertexStructure
|
struct TextureLoadingVertexStructure
|
||||||
@@ -220,6 +202,13 @@ private:
|
|||||||
std::thread workerThread;
|
std::thread workerThread;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
|
|
||||||
|
long long getCurrentTimeMillis() {
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
auto duration = now.time_since_epoch();
|
||||||
|
return std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
|
||||||
|
}
|
||||||
|
|
||||||
|
long long last_update_time;
|
||||||
public:
|
public:
|
||||||
//void run();
|
//void run();
|
||||||
//void start();
|
//void start();
|
||||||
|
|||||||
Reference in New Issue
Block a user