leocad/common/lc_scene.h

106 lines
2.1 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
{
2019-11-23 01:47:58 +01:00
NORMAL,
SELECTED,
FOCUSED,
DISABLED,
HIGHLIGHT
};
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;
}
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:
2019-11-23 01:47:58 +01:00
void DrawOpaqueMeshes(lcContext* Context, bool DrawLit, int PrimitiveTypes) const;
void DrawTranslucentMeshes(lcContext* Context, bool DrawLit) const;
void DrawDebugNormals(lcContext* Context, lcMesh* Mesh) const;
2017-04-02 01:53:54 +02:00
lcMatrix44 mViewMatrix;
lcMatrix44 mActiveSubmodelTransform;
lcPiece* mActiveSubmodelInstance;
bool mDrawInterface;
bool mAllowWireframe;
bool mAllowLOD;
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;
};