2017-04-02 01:53:54 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "lc_mesh.h"
|
|
|
|
|
2019-11-23 01:47:58 +01:00
|
|
|
enum class lcRenderMeshState : int
|
2019-11-13 00:11:03 +01:00
|
|
|
{
|
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;
|
2019-11-13 00:11:03 +01:00
|
|
|
};
|
|
|
|
|
2017-04-02 01:53:54 +02:00
|
|
|
class lcScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
lcScene();
|
|
|
|
|
2018-04-08 02:17:32 +02:00
|
|
|
void SetActiveSubmodelInstance(lcPiece* ActiveSubmodelInstance, const lcMatrix44& ActiveSubmodelTransform)
|
2018-04-07 20:45:00 +02:00
|
|
|
{
|
|
|
|
mActiveSubmodelInstance = ActiveSubmodelInstance;
|
2018-04-08 02:17:32 +02:00
|
|
|
mActiveSubmodelTransform = ActiveSubmodelTransform;
|
2018-04-07 20:45:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
lcPiece* GetActiveSubmodelInstance() const
|
|
|
|
{
|
|
|
|
return mActiveSubmodelInstance;
|
|
|
|
}
|
|
|
|
|
2019-11-16 21:15:49 +01:00
|
|
|
const lcMatrix44& GetViewMatrix() const
|
|
|
|
{
|
|
|
|
return mViewMatrix;
|
|
|
|
}
|
|
|
|
|
2018-04-07 20:45:00 +02:00
|
|
|
void SetDrawInterface(bool DrawInterface)
|
|
|
|
{
|
|
|
|
mDrawInterface = DrawInterface;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetDrawInterface() const
|
|
|
|
{
|
|
|
|
return mDrawInterface;
|
|
|
|
}
|
|
|
|
|
2021-01-10 01:02:23 +01:00
|
|
|
void SetShadingMode(lcShadingMode ShadingMode)
|
2018-04-08 00:28:44 +02:00
|
|
|
{
|
2021-01-10 01:02:23 +01:00
|
|
|
mShadingMode = ShadingMode;
|
2018-04-08 00:28:44 +02:00
|
|
|
}
|
|
|
|
|
2019-11-28 21:47:19 +01:00
|
|
|
void SetAllowLOD(bool AllowLOD)
|
|
|
|
{
|
|
|
|
mAllowLOD = AllowLOD;
|
|
|
|
}
|
|
|
|
|
2020-08-16 01:16:26 +02:00
|
|
|
void SetLODDistance(float Distance)
|
|
|
|
{
|
|
|
|
mMeshLODDistance = Distance;
|
|
|
|
}
|
|
|
|
|
2019-11-30 20:38:11 +01:00
|
|
|
void SetPreTranslucentCallback(std::function<void()> Callback)
|
|
|
|
{
|
|
|
|
mPreTranslucentCallback = Callback;
|
|
|
|
}
|
|
|
|
|
2018-04-08 02:17:32 +02:00
|
|
|
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)
|
|
|
|
{
|
2024-05-11 21:44:06 +02:00
|
|
|
mInterfaceObjects.emplace_back(Object);
|
2017-04-02 01:53:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2018-04-08 02:17:32 +02:00
|
|
|
lcMatrix44 mActiveSubmodelTransform;
|
2018-04-07 20:45:00 +02:00
|
|
|
lcPiece* mActiveSubmodelInstance;
|
2021-01-10 01:02:23 +01:00
|
|
|
lcShadingMode mShadingMode;
|
2018-04-07 20:45:00 +02:00
|
|
|
bool mDrawInterface;
|
2019-11-28 21:47:19 +01:00
|
|
|
bool mAllowLOD;
|
2020-08-16 01:16:26 +02:00
|
|
|
float mMeshLODDistance;
|
2020-04-25 21:16:37 +02:00
|
|
|
|
|
|
|
lcVector4 mFadeColor;
|
|
|
|
lcVector4 mHighlightColor;
|
2020-04-25 03:13:53 +02:00
|
|
|
bool mHasFadedParts;
|
2020-04-25 21:16:37 +02:00
|
|
|
bool mTranslucentFade;
|
2018-04-07 20:45:00 +02:00
|
|
|
|
2019-11-30 20:38:11 +01:00
|
|
|
std::function<void()> mPreTranslucentCallback;
|
2024-05-11 21:44:06 +02:00
|
|
|
std::vector<lcRenderMesh> mRenderMeshes;
|
|
|
|
std::vector<int> mOpaqueMeshes;
|
|
|
|
std::vector<lcTranslucentMeshInstance> mTranslucentMeshes;
|
|
|
|
std::vector<const lcObject*> mInterfaceObjects;
|
2017-04-02 01:53:54 +02:00
|
|
|
};
|