122 lines
3.7 KiB
C++
122 lines
3.7 KiB
C++
#pragma once
|
|
#include <vlGraphics/Framebuffer.hpp>
|
|
#include <vlGraphics/Rendering.hpp>
|
|
#include <vlGraphics/SceneManagerActorTree.hpp>
|
|
#include <vlGraphics/OpenGLContext.hpp>
|
|
#include <vlGraphics/TrackballManipulator.hpp>
|
|
#include <vlGraphics/RayIntersector.hpp>
|
|
#include <vlVG/VectorGraphics.hpp>
|
|
#include <vlVG/SceneManagerVectorGraphics.hpp>
|
|
//#include "../job/FileProcessor.h"
|
|
#include "BPData.h"
|
|
|
|
using namespace vl;
|
|
|
|
enum RenderMode {
|
|
RenderMode2D,
|
|
RenderMode3D
|
|
};
|
|
|
|
enum PlatformShape {
|
|
PS_SQUARE = 0,
|
|
PS_ROUND,
|
|
};
|
|
|
|
class TrackBall;
|
|
class VLRenderer : public vl::OpenGLContext
|
|
{
|
|
friend class TrackBall;
|
|
public:
|
|
VLRenderer();
|
|
~VLRenderer();
|
|
|
|
void makeCurrent() {}
|
|
void swapBuffers() {}
|
|
void Init(void);
|
|
void update(void) { Render(); }
|
|
unsigned int GetTexture(void) { return mTexture->handle(); }
|
|
bool UpdateSize(unsigned int w, unsigned int h);
|
|
void Render(void);
|
|
void AddActor(vl::ref<vl::Actor> actor);
|
|
//void UpdateCurrentLayer();
|
|
//void ReloadCurrentLayer();
|
|
void InitScene();
|
|
void UpdateScene(void);
|
|
void ClearScene(bool ClearJosb = false);
|
|
void SetPlatformShape(PlatformShape shape);
|
|
void SetPlatfromSize(double width, double depth = 100.0, double height = 100.0);
|
|
void SetCurrentLayer(unsigned int layer);
|
|
void SetPreviewLayer(unsigned int layer);
|
|
//void SetJob(FileProcessor * jfp);
|
|
//FileProcessor* GetJob() { return m_BPData->GetJobFileProcessor(); }
|
|
void SetRenderMode(RenderMode mode);
|
|
RenderMode GetRenderMode(void) { return m_RenderMode; }
|
|
// std::vector<Part *>* GetParts(void);
|
|
std::map<int, Part*>* GetPartMap();
|
|
int PartSelected(void) { return m_PartSelected; }
|
|
void UpdateGlobalOffset(double offset_x, double offset_y);
|
|
void ResetCamera(void);
|
|
//void EnableMove(void);
|
|
Part* GetSelectedPart(void) { if (!m_BPData) return nullptr; return m_BPData->GetSelectedPart(); }
|
|
double GetWorldDis(double *p0, double *p1);
|
|
BPData* GetBPData(void) { return m_BPData; }
|
|
Part* GetPart(unsigned int index);
|
|
|
|
//void AddPart(MetaData::Part* part);
|
|
//void DelPart(MetaData::Part* part);
|
|
//vl::ref<vl::VectorGraphics> VLRenderer::GetVG(void) { return mvg; }
|
|
public:
|
|
enum {
|
|
DATATYPE_UNKNOW = 0,
|
|
DATATYPE_BP,
|
|
};
|
|
|
|
private:
|
|
const vl::Rendering* rendering() const { return mRendering.get(); }
|
|
vl::Rendering* rendering() { return mRendering.get(); }
|
|
const vl::OpenGLContext* openglContext() const { return this; }
|
|
vl::OpenGLContext* openglContext() { return this; }
|
|
vl::ref<Geometry> MakePlatform(const vec3& origin, vl::real xside, vl::real yside, int x, int z, bool gen_texcoords = false, fvec2 uv0 = fvec2(0, 0), fvec2 uv1 = fvec2(1, 1), bool center = true);
|
|
vl::ref<Geometry> MakePlatform(const vec3& origin, vl::real diameter, unsigned int phi);
|
|
|
|
private:
|
|
BPData* m_BPData;
|
|
vl::ref<vl::Rendering> mRendering;
|
|
vl::ref<vl::SceneManagerActorTree> mSceneManager;
|
|
std::vector<vl::ref<vl::Framebuffer> > m_framebuffer;
|
|
vl::ref<vl::Texture> mTexture;
|
|
vl::ref<vl::Transform> mCubeTransform;
|
|
vl::ref<vl::FramebufferObject> mFBO;
|
|
vl::ref<vl::FBODepthBufferAttachment> mFBODB;
|
|
//vl::ref<vl::VectorGraphics> mvg;
|
|
int m_Width;
|
|
int m_Height;
|
|
int m_PartSelected;
|
|
RenderMode m_RenderMode;
|
|
double m_PlatformWidth = 280.0;
|
|
double m_PlatformDepth = 280.0;
|
|
double m_PlatformHeight = 280.0;
|
|
double m_PlatformThickness = 2.0;
|
|
uint16_t m_GridSize = 10;
|
|
double m_GlobalOffsetX;
|
|
double m_GlobalOffsetY;
|
|
unsigned int m_DataType;
|
|
std::vector<vl::ref<vl::Actor>> m_actors;
|
|
vl::ref<TrackBall> trackball;
|
|
static bool m_IsInit;
|
|
PlatformShape m_PlatformShape;
|
|
};
|
|
|
|
class TrackBall : public TrackballManipulator
|
|
{
|
|
public:
|
|
void mouseDownEvent(EMouseButton btn, int x, int y);
|
|
void mouseMoveEvent(int x, int y);
|
|
void mouseWheelEvent(int delta);
|
|
public:
|
|
VLRenderer* mVLRenderer;
|
|
private:
|
|
int mCurrentX;
|
|
int mCurrentY;
|
|
};
|