leocad/common/lc_scene.h

112 lines
2.4 KiB
C
Raw Normal View History

2017-04-02 01:53:54 +02:00
#pragma once
#include "lc_mesh.h"
#include "lc_array.h"
2019-11-23 01:47:58 +01:00
enum class lcRenderMeshState : int
{
2020-01-02 02:06:17 +01:00
Default,
Selected,
Focused,
Faded,
Highlighted
2019-11-23 01:47:58 +01:00
};
struct lcRenderMesh
{
lcMatrix44 WorldMatrix;
lcMesh* Mesh;
int ColorIndex;
int LodIndex;
lcRenderMeshState State;
};
struct lcTranslucentMeshInstance
{
const lcMeshSection* Section;
int RenderMeshIndex;
float Distance;
};
2017-04-02 01:53:54 +02:00
class lcScene
{
public:
lcScene();
void SetActiveSubmodelInstance(lcPiece* ActiveSubmodelInstance, const lcMatrix44& ActiveSubmodelTransform)
{
mActiveSubmodelInstance = ActiveSubmodelInstance;
mActiveSubmodelTransform = ActiveSubmodelTransform;
}
lcPiece* GetActiveSubmodelInstance() const
{
return mActiveSubmodelInstance;
}
const lcMatrix44& GetViewMatrix() const
{
return mViewMatrix;
}
void SetDrawInterface(bool DrawInterface)
{
mDrawInterface = DrawInterface;
}
bool GetDrawInterface() const
{
return mDrawInterface;
}
void SetAllowWireframe(bool AllowWireframe)
{
mAllowWireframe = AllowWireframe;
}
void SetAllowLOD(bool AllowLOD)
{
mAllowLOD = AllowLOD;
}
void SetPreTranslucentCallback(std::function<void()> Callback)
{
mPreTranslucentCallback = Callback;
}
lcMatrix44 ApplyActiveSubmodelTransform(const lcMatrix44& WorldMatrix) const
{
return !mActiveSubmodelInstance ? WorldMatrix : lcMul(WorldMatrix, mActiveSubmodelTransform);
}
2017-04-02 01:53:54 +02:00
void Begin(const lcMatrix44& ViewMatrix);
void End();
2019-07-21 17:56:37 +02:00
void AddMesh(lcMesh* Mesh, const lcMatrix44& WorldMatrix, int ColorIndex, lcRenderMeshState State);
2017-04-02 01:53:54 +02:00
void AddInterfaceObject(const lcObject* Object)
{
mInterfaceObjects.Add(Object);
}
void Draw(lcContext* Context) const;
void DrawInterfaceObjects(lcContext* Context) const;
protected:
2020-04-20 05:21:18 +02:00
void DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTypes, bool DrawFaded, bool DrawNonFaded) const;
void DrawTranslucentMeshes(lcContext* Context, bool DrawLit, bool DrawFadePrepass, bool DrawFaded, bool DrawNonFaded) const;
2020-03-23 04:18:52 +01:00
void DrawDebugNormals(lcContext* Context, const lcMesh* Mesh) const;
2017-04-02 01:53:54 +02:00
lcMatrix44 mViewMatrix;
lcMatrix44 mActiveSubmodelTransform;
lcPiece* mActiveSubmodelInstance;
bool mDrawInterface;
bool mAllowWireframe;
bool mAllowLOD;
std::function<void()> mPreTranslucentCallback;
2017-04-02 01:53:54 +02:00
lcArray<lcRenderMesh> mRenderMeshes;
lcArray<int> mOpaqueMeshes;
2019-11-23 01:47:58 +01:00
lcArray<lcTranslucentMeshInstance> mTranslucentMeshes;
2017-04-02 01:53:54 +02:00
lcArray<const lcObject*> mInterfaceObjects;
};