ForCAX/entry/src/main/cpp/NativeEGLOCCT/NativeRenderThread.h
JackLee 6a4e702dbd 增加视图切换功能,但是需要归一化操作.
目前只是实现了功能.需要对初始世界坐标进行标定
2026-03-22 22:38:16 +08:00

84 lines
2.1 KiB
C++

#ifndef NATIVE_RENDER_THREAD_H
#define NATIVE_RENDER_THREAD_H
#include <thread>
#include <atomic>
#include <mutex>
#include <condition_variable>
#include <queue>
#include <functional>
#include "EGLCore.h"
#include "NativeRender.h"
namespace NativeOpenCAX {
class NativeRenderThread {
public:
NativeRenderThread();
~NativeRenderThread();
bool start(OHNativeWindow* window);
void stop();
void loadModel(const std::string& filePath);
void setCameraRotationMode(bool state);
void setRotation(float xAngle, float yAngle);
void setTranslation(float x, float y);
void resetView();
void setClearColor(float r, float g, float b, float a);
void resizeWindow(int width, int height);
void swicthView(std::string strView);
using Callback = std::function<void()>;
void registerRenderCompleteCallback(Callback callback);
private:
void renderLoop();
std::thread renderThread_;
std::atomic<bool> isRunning_;
OHNativeWindow* nativeWindow_;
EGLCore* eglCore_;
NativeRender renderer_;
std::mutex commandMutex_;
std::condition_variable commandCondition_;
enum CommandType {
CMD_LOAD_MODEL,
CMD_SET_ROTATION,
CMD_SET_TRANSLATION,
CMD_RESET_VIEW,
CMD_SET_CLEAR_COLOR,
CMD_RESIZE,
//视图枚举
CMD_VIEW_FRONT,
CMD_VIEW_TOP,
CMD_VIEW_LEFT_SIDE,
CMD_VIEW_RIGHT_SIDE,
CMD_VIEW_BOTTOM,
CMD_VIEW_REAR,
CMD_VIEW_ISO,
CMD_VIEW_DIM,
CMD_EXIT
};
struct RenderCommand {
CommandType type;
std::string param1; // For file path
float param2, param3, param4, param5;
bool param6;
RenderCommand() : type(CMD_EXIT), param1(""), param2(0.0f), param3(0.0f), param4(0.0f), param5(0.0f) {}
RenderCommand(CommandType t) : type(t), param1(""), param2(0), param3(0), param4(0), param5(0),param6(true) {}
};
std::queue<RenderCommand> commandQueue_;
std::mutex callbackMutex_;
Callback renderCompleteCallback_;
int windowWidth_;
int windowHeight_;
};
} // namespace NaitveRenderThread
#endif //NATIVE_RENDER_THREAD_H