重构point 代码
This commit is contained in:
@@ -35,31 +35,14 @@ struct TextureLoadingVertexStructure
|
||||
float normal[3];
|
||||
};
|
||||
|
||||
struct PointVertex {
|
||||
float x, y, z; // 位置
|
||||
float r, g, b; // 颜色 (可以根据需要修改)
|
||||
};
|
||||
|
||||
class TextureLoading : public ApiVulkanSample
|
||||
{
|
||||
public:
|
||||
// --- 新增:用于点云渲染的结构 ---
|
||||
struct PointVertex {
|
||||
float x, y, z; // 位置
|
||||
float r, g, b; // 颜色 (可以根据需要修改)
|
||||
};
|
||||
|
||||
std::unique_ptr<vkb::core::BufferC> point_vertex_buffer;
|
||||
uint32_t point_count = 0;
|
||||
VkPipeline point_pipeline;
|
||||
VkPipelineLayout point_pipeline_layout;
|
||||
VkDescriptorSetLayout point_descriptor_set_layout;
|
||||
VkDescriptorSet point_descriptor_set;
|
||||
|
||||
void setup_point_descriptor_set_layout();
|
||||
void setup_point_descriptor_set();
|
||||
void prepare_point_pipeline();
|
||||
void update_point_vertex_buffer(float* pos, int pointCount);
|
||||
void draw_point_cloud(VkCommandBuffer command_buffer);
|
||||
void update_point_descriptor_set();
|
||||
|
||||
|
||||
|
||||
struct Texture
|
||||
{
|
||||
VkSampler sampler;
|
||||
@@ -72,13 +55,15 @@ public:
|
||||
};
|
||||
|
||||
Texture texture = { 0 };
|
||||
Texture texture_point = { 0 };
|
||||
Texture cam_text = { 0 };
|
||||
|
||||
std::unique_ptr<vkb::core::BufferC> vertex_buffer;
|
||||
std::unique_ptr<vkb::core::BufferC> index_buffer;
|
||||
uint32_t index_count;
|
||||
|
||||
std::unique_ptr<vkb::core::BufferC> uniform_buffer_vs;
|
||||
std::unique_ptr<vkb::core::BufferC> vertex_buffer_point;
|
||||
uint32_t point_count = 0;
|
||||
|
||||
struct
|
||||
{
|
||||
@@ -88,27 +73,39 @@ public:
|
||||
float lod_bias = 0.0f;
|
||||
} ubo_vs;
|
||||
|
||||
std::unique_ptr<vkb::core::BufferC> point_uniform_vs;
|
||||
struct
|
||||
{
|
||||
glm::mat4 projection;
|
||||
glm::mat4 model;
|
||||
glm::mat4 view;
|
||||
} point_ubo;
|
||||
} ubo_vs_point;
|
||||
|
||||
std::unique_ptr<vkb::core::BufferC> uniform_buffer_vs;
|
||||
std::unique_ptr<vkb::core::BufferC> uniform_buffer_vs_point;
|
||||
|
||||
|
||||
glm::vec3 camear_pos_point;
|
||||
glm::vec3 pos_point;
|
||||
|
||||
struct
|
||||
{
|
||||
VkPipeline solid;
|
||||
VkPipeline background;
|
||||
VkPipeline point;
|
||||
} pipelines;
|
||||
|
||||
|
||||
VkPipelineLayout pipeline_layout;
|
||||
VkPipelineLayout pipeline_layout_bg;
|
||||
VkPipelineLayout pipeline_layout_point;
|
||||
|
||||
VkDescriptorSet descriptor_set;
|
||||
VkDescriptorSet descriptor_set_bg;
|
||||
VkDescriptorSet descriptor_set_point;
|
||||
|
||||
VkDescriptorSetLayout descriptor_set_layout;
|
||||
VkDescriptorSetLayout descriptor_set_layout_bg;
|
||||
VkDescriptorSetLayout descriptor_set_layout_point;
|
||||
|
||||
static TextureLoading* Get() {
|
||||
return this_instance;
|
||||
@@ -122,16 +119,28 @@ public:
|
||||
void load_texture();
|
||||
void destroy_texture(Texture texture);
|
||||
void build_command_buffers() override;
|
||||
|
||||
void draw();
|
||||
void draw_point_cloud(VkCommandBuffer command_buffer);
|
||||
void generate_quad();
|
||||
|
||||
void setup_descriptor_pool();
|
||||
void setup_descriptor_set_layout();
|
||||
void setup_descriptor_set_layout_bg();
|
||||
void setup_descriptor_set_layout_point();
|
||||
|
||||
void setup_descriptor_set();
|
||||
void setup_descriptor_set_bg();
|
||||
void setup_descriptor_set_point();
|
||||
|
||||
void prepare_pipelines();
|
||||
void prepare_pipeline_bg();
|
||||
void prepare_pipeline_point();
|
||||
|
||||
void prepare_uniform_buffers();
|
||||
void update_uniform_buffers();
|
||||
void prepare_uniform_buffers_point();
|
||||
void update_uniform_buffers_point();
|
||||
bool prepare(const vkb::ApplicationOptions& options) override;
|
||||
virtual void render(float delta_time) override;
|
||||
virtual void view_changed() override;
|
||||
@@ -146,7 +155,8 @@ public:
|
||||
void transitionImageLayout(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout oldLayout, VkImageLayout newLayout);
|
||||
|
||||
public:
|
||||
void prepare_pipeline_bg();
|
||||
|
||||
void update_point_vertex_buffer(float* pos, int pointCount);
|
||||
private:
|
||||
std::thread workerThread;
|
||||
bool running = false;
|
||||
|
||||
Reference in New Issue
Block a user