Cogs.Core
Image360System.h
1#pragma once
2#include "Rendering/Common.h"
3#include "Rendering/IGraphicsDevice.h"
4
5#include "Renderer/IRenderer.h"
6#include "Resources/MeshStreamsLayout.h"
7#include "Systems/ComponentSystem.h"
8#include "Scene/GetBounds.h"
9#include "Scene/RayPick.h"
10
11#include "Image360.h"
12#include "Image360Component.h"
13
14namespace Cogs::Core
15{
16 struct Image360System;
17 struct Image360Data;
18
19 namespace Image360 {
20
21 struct Bounds final : public IGetBounds {
22 public:
23 explicit Bounds(Image360System* im360System);
24 void getBounds(Context* context, Cogs::Geometry::BoundingBox& bounds) override;
25 bool getBounds(Context* context, const Cogs::ComponentModel::Entity* entity, Cogs::Geometry::BoundingBox& bounds, bool ignoreVisibility) const override;
26
27 private:
28 Image360System* im360System = nullptr;
29 };
30
32 {
33 public:
34 void initialize(Context* context, IGraphicsDevice* device) override;
35 void release();
36 void handleEvent(uint32_t eventId, const DrawContext* renderingContext) override;
37 void generateCommands(const RenderTaskContext* renderingContext, RenderList* renderList) override;
38 void releaseRenderingResources(RendererExtensionData& im360Data);
39
40 Context* context = nullptr;
41 IGraphicsDevice* device = nullptr;
42 Image360System* im360System = nullptr;
43
45
46 struct {
47 MeshStreamsLayout streamsLayout;
49 Cogs::BufferHandle paramBuffer;
50 } fullScreenTriangle;
51
52 // WebGL on VR headsets have an issue with copy/blits from texture arrays, so we use shader instead
53 struct {
54 struct {
60 } f;
61
62 struct {
68 } u;
69
75 } atlasBlit;
76
77 };
78
80 {
81 RayPickExtension(Image360System* im360System);
82
83 bool pickCamera(Context* context,
84 const CameraComponent& camera,
85 const glm::vec2& normPosition,
86 float /*rayLength*/,
87 float /*radius*/,
88 PickingFlags pickingFlags,
89 PicksReturned returnFlag,
90 const RayPicking::RayPickFilter& filter,
91 std::vector<RayPicking::RayPickHit>& hits) override;
92
93 Image360System* im360System = nullptr;
94 };
95
96 }
97
99 {
100 enum struct State {
101 Uninitialized,
102 Error,
103 WaitingForJson,
104 JsonParsed,
105 WaitingForBaseLevel,
106 Running
107 };
108 State state = State::Uninitialized;
109
110 std::string source;
111 uint32_t valueChannel = 0;
112 bool hasDepth = false;
113
114 MaterialInstanceHandle materialInstance;
115
116 Image360::Config config;
117 Image360::Fetcher fetcher;
118 Image360::Cache cache;
121 };
122
123 struct Image360System : public ComponentSystemWithDataPool<Image360Component, Image360Data>
124 {
126
127 Image360System(Memory::Allocator* allocator, SizeType capacity) : ComponentSystemWithDataPool(allocator, capacity) {}
128
130
131 void initialize(Context* context) override;
132
133 void update(Context* context) override;
134
136 void destroyComponent(ComponentHandle component) override;
137
138 MaterialHandle material;
139 uint32_t instanceCounter = 1;
140
141 private:
142 Image360::RendererExtension* renderer = nullptr;
143 Image360::Bounds* bounds = nullptr;
144 Image360::RayPickExtension* picker = nullptr;
145 };
146
147
148}
Container for components, providing composition of dynamic entities.
Definition: Entity.h:18
Context * context
Pointer to the Context instance the system lives in.
void update()
Updates the system state to that of the current frame.
Component system with parallel data per component stored in a pool similar to how the components them...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Definition: Context.h:83
Interface for modules implementing custom picking.
Definition: RayPick.h:140
Defines an extension to the renderer, capable of doing custom rendering.
Definition: IRenderer.h:123
Represents a graphics device used to manage graphics resources and issue drawing commands.
Base allocator implementation.
Definition: Allocator.h:30
Contains the Engine, Renderer, resource managers and other systems needed to run Cogs....
PicksReturned
  * Options for returning picking hits.
Definition: PickingFlags.h:40
PickingFlags
Options for COGS picking.
Definition: PickingFlags.h:12
ComponentIndex SizeType
Type used to track the size of pools.
Definition: Component.h:19
Handle to a Component instance.
Definition: Component.h:67
void initialize(Context *context) override
Initialize the system.
ComponentHandle createComponent() override
void destroyComponent(ComponentHandle component) override
void getBounds(Context *context, Cogs::Geometry::BoundingBox &bounds) override
Expand bounds including bounds of all entities in this system in world coordinates.
Definition: Bounds.cpp:33
bool pickCamera(Context *context, const CameraComponent &camera, const glm::vec2 &normPosition, float, float, PickingFlags pickingFlags, PicksReturned returnFlag, const RayPicking::RayPickFilter &filter, std::vector< RayPicking::RayPickHit > &hits) override
Do a ray pick from a normalized screen space position in the camera direction and return all hits.
void handleEvent(uint32_t eventId, const DrawContext *renderingContext) override
Called when rendering events occur.
void initialize(Context *context, IGraphicsDevice *device) override
Initialize the extension using the given context and device.
static const Handle_t NoHandle
Represents a handle to nothing.
Definition: Common.h:77