Polyphase Game Engine
Loading...
Searching...
No Matches
ImagePlaneBuilder.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include "EngineTypes.h"
6#include "Maths.h"
8
9struct Vertex;
10struct AssetStub;
11class StaticMesh;
12class MaterialLite;
13class Texture;
14
15enum class ImagePlanePivot
16{
17 Center,
18 BottomCenter,
19 TopLeft,
20
21 Count
22};
23
24enum class ImagePlaneSizeMode
25{
26 AspectWidth1,
27 AspectHeight1,
28 PixelsPerUnit,
29
30 Count
31};
32
33struct ImagePlaneParams
34{
35 Texture* mSourceTexture = nullptr;
36 glm::vec2 mUvMin = { 0.0f, 0.0f };
37 glm::vec2 mUvMax = { 1.0f, 1.0f };
38 ImagePlanePivot mPivot = ImagePlanePivot::Center;
39 ImagePlaneSizeMode mSizeMode = ImagePlaneSizeMode::AspectWidth1;
40 float mPixelsPerUnit = 100.0f;
41 ShadingModel mShadingModel = ShadingModel::Unlit;
42 BlendMode mBlendMode = BlendMode::Opaque;
43 bool mTwoSided = false;
44};
45
46void BuildImagePlaneGeometry(const ImagePlaneParams& params, Vertex outVerts[4], IndexType outIndices[6]);
47
48void ApplyImagePlaneToAssets(const ImagePlaneParams& params, StaticMesh* mesh, MaterialLite* material);
49
50bool IsImagePlaneCandidate(StaticMesh* mesh);
51
52bool ExtractImagePlaneParams(StaticMesh* mesh, ImagePlaneParams& outParams);
53
54// Returns an AssetStub for an image-plane StaticMesh that fronts the given
55// texture, creating the SM_<base> + M_<base> assets with default params
56// (Unlit / Opaque / Center / AspectWidth1 / full UV) if no matching
57// image-plane mesh already exists. Drag-and-drop entry points use this so
58// dropping a Texture into the scene behaves like dropping a StaticMesh.
59// Returns nullptr if generation isn't possible (texture not loaded, target
60// directory is read-only, etc.).
61AssetStub* FindOrCreateImagePlaneStubForTexture(AssetStub* textureStub);
62
63#endif // EDITOR
ShadingModel
Definition EngineTypes.h:104
BlendMode
Definition EngineTypes.h:113
uint16_t IndexType
Definition GraphicsTypes.h:122
Definition MaterialLite.h:51
Definition StaticMesh.h:18
Definition Texture.h:10
Definition Asset.h:88
Definition Vertex.h:20