FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_objLight.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_OBJLIGHT_HPP_INCLUDED
18#define _FGE_C_OBJLIGHT_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "C_lightSystem.hpp"
22#include "C_objRenderMap.hpp"
23#include "C_object.hpp"
24#include "FastEngine/C_scene.hpp"
25#include "FastEngine/accessor/C_texture.hpp"
26
27#define FGE_OBJLIGHT_CLASSNAME "FGE:OBJ:LIGHT"
28
29namespace fge
30{
31
32class FGE_API ObjLight : public fge::Object, public fge::LightComponent
33{
34public:
35 ObjLight();
36 explicit ObjLight(fge::Texture const& texture, fge::Vector2f const& position = fge::Vector2f());
37 ObjLight(fge::Texture const& texture,
38 fge::RectInt const& rectangle,
39 fge::Vector2f const& position = fge::Vector2f());
40
41 FGE_OBJ_DEFAULT_COPYMETHOD(fge::ObjLight)
42
43 void setBlendMode(fge::vulkan::BlendMode const& blendMode);
44 fge::vulkan::BlendMode const& getBlendMode() const;
45
46 void setTexture(fge::Texture const& texture, bool resetRect = false);
47 void setTextureRect(fge::RectInt const& rectangle);
48
49 void setRenderObject(fge::ObjectDataShared const& obj);
50 fge::ObjectDataShared const& getRenderObject() const;
51
52 void setColor(fge::Color const& color);
53
54 fge::Texture const& getTexture() const;
55 fge::RectInt const& getTextureRect() const;
56
57 fge::Color getColor() const;
58
59 void first(fge::Scene& scene) override;
60 FGE_OBJ_UPDATE_DECLARE
61 FGE_OBJ_DRAW_DECLARE
62
63 void save(nlohmann::json& jsonObject, fge::Scene* scene) override;
64 void load(nlohmann::json& jsonObject, fge::Scene* scene) override;
65 void pack(fge::net::Packet& pck) override;
66 void unpack(fge::net::Packet const& pck) override;
67
68 char const* getClassName() const override;
69 char const* getReadableClassName() const override;
70
73
74private:
75 void updatePositions();
76 void updateTexCoords();
77
78 fge::vulkan::VertexBuffer g_vertexBuffer;
79 fge::Texture g_texture;
80 fge::RectInt g_textureRect;
81
82 fge::ObjectDataShared g_renderObject;
83
84 mutable std::vector<fge::vulkan::VertexBuffer> g_obstacleHulls;
85
86#ifndef FGE_DEF_SERVER
87 fge::ObjRenderMap g_renderMap;
88#endif //FGE_DEF_SERVER
89 fge::vulkan::BlendMode g_blendMode;
90};
91
92} // namespace fge
93
94#endif // _FGE_C_OBJLIGHT_HPP_INCLUDED
Definition C_color.hpp:35
A base class that define a light component.
Definition C_lightSystem.hpp:56
Definition C_objLight.hpp:33
void unpack(fge::net::Packet const &pck) override
Unpack the object from a packet.
char const * getReadableClassName() const override
Get a readable version of the class name.
fge::RectFloat getGlobalBounds() const override
Get the global bounds of the object.
void pack(fge::net::Packet &pck) override
Pack the object into a packet.
void first(fge::Scene &scene) override
Method called when the object is added to a scene for initialization purposes.
void load(nlohmann::json &jsonObject, fge::Scene *scene) override
Load the object from a json object.
fge::RectFloat getLocalBounds() const override
Get the local bounds of the object (without any transformations)
void save(nlohmann::json &jsonObject, fge::Scene *scene) override
Save the object to a json object.
char const * getClassName() const override
Get the unique class name of the object.
Definition C_objRenderMap.hpp:31
The Object class is the base class for all objects in the engine.
Definition C_object.hpp:102
A scene contain a collection of object and handle them.
Definition C_scene.hpp:450
This class is a wrapper for the texture manager to allow easy manipulation.
Definition C_texture.hpp:36
Definition C_packet.hpp:70
Definition C_vertexBuffer.hpp:45
This is a simple abstraction class for VkBlendFactor, VkBlendOp.
Definition C_blendMode.hpp:37