StevEngine
StevEngine is a customizable C++ game engine.
Loading...
Searching...
No Matches
Primitive.hpp
1#pragma once
2#include "visuals/renderer/Object.hpp"
3#ifdef StevEngine_RENDERER_GL
4#include "renderer/RenderComponent.hpp"
5#include "utilities/Vertex.hpp"
6#include "visuals/Material.hpp"
7
8#define CUBE_PRIMITIVE_TYPE "CubePrimitive"
9#define UVSPHERE_PRIMITIVE_TYPE "UVSpherePrimitive"
10#define ICOSPHERE_PRIMITIVE_TYPE "IcoSpherePrimitive"
11#define CYLINDER_PRIMITIVE_TYPE "CylinderPrimitive"
12#define CAPSULE_PRIMITIVE_TYPE "CapsulePrimitive"
13
14#define RADIUS 0.5
15
16namespace StevEngine {
17 namespace Visuals {
21 enum TextureType {
22 REPEAT,
23 COVER
24 };
25
29 const std::vector<Utilities::Vertex> CubeVertices(TextureType textureType);
30
38 public:
52 const Material& material = Material(),
53 TextureType textureType = REPEAT,
54 Renderer::RenderType renderType = Renderer::SOLID
55 );
56
62
67 std::string GetType() const { return CUBE_PRIMITIVE_TYPE; }
68
74 Utilities::Stream Export(Utilities::StreamType type) const;
75
76 const Visuals::TextureType textureType;
77 };
78
82 const std::vector<Utilities::Vertex> UVSphereVertices(TextureType textureType, bool smooth, int detail = 30, float height = RADIUS);
83
91 public:
106 Material material = Material(),
107 bool smooth = true,
108 TextureType textureType = COVER,
109 Renderer::RenderType renderType = Renderer::SOLID
110 );
111
117
122 std::string GetType() const { return UVSPHERE_PRIMITIVE_TYPE; }
123
129 Utilities::Stream Export(Utilities::StreamType type) const;
130
131 const Visuals::TextureType textureType;
132 const bool smooth;
133 };
134
138 const std::vector<Utilities::Vertex> IcosphereVertices(TextureType textureType, bool smooth, int detail = 3);
139
147 public:
162 Material material = Material(),
163 bool smooth = true,
164 TextureType textureType = COVER,
165 Renderer::RenderType renderType = Renderer::SOLID
166 );
167
173
178 std::string GetType() const { return ICOSPHERE_PRIMITIVE_TYPE; }
179
185 Utilities::Stream Export(Utilities::StreamType type) const;
186
187 const Visuals::TextureType textureType;
188 const bool smooth;
189 };
190
194 const std::vector<Utilities::Vertex> CylinderVertices(TextureType textureType, bool smooth, int detail = 30, double height = RADIUS);
195
203 public:
218 Material material = Material(),
219 bool smooth = true,
220 TextureType textureType = COVER,
221 Renderer::RenderType renderType = Renderer::SOLID
222 );
223
229
234 std::string GetType() const { return CYLINDER_PRIMITIVE_TYPE; }
235
241 Utilities::Stream Export(Utilities::StreamType type) const;
242
243 const Visuals::TextureType textureType;
244 const bool smooth;
245 };
246
250 const std::vector<Utilities::Vertex> CapsuleVertices(TextureType textureType, bool smooth, int detail = 30);
251
259 public:
274 Material material = Material(),
275 bool smooth = true,
276 TextureType textureType = COVER,
277 Renderer::RenderType renderType = Renderer::SOLID
278 );
279
285
290 std::string GetType() const { return CAPSULE_PRIMITIVE_TYPE; }
291
297 Utilities::Stream Export(Utilities::StreamType type) const;
298
299 const Visuals::TextureType textureType;
300 const bool smooth;
301 };
302
304 inline bool cube = CreateComponents::RegisterComponentType<CubePrimitive>(CUBE_PRIMITIVE_TYPE);
305 inline bool sphere = CreateComponents::RegisterComponentType<UVSpherePrimitive>(UVSPHERE_PRIMITIVE_TYPE);
306 inline bool icosphere = CreateComponents::RegisterComponentType<IcospherePrimitive>(ICOSPHERE_PRIMITIVE_TYPE);
307 inline bool cylinder = CreateComponents::RegisterComponentType<CylinderPrimitive>(CYLINDER_PRIMITIVE_TYPE);
308 inline bool capsule = CreateComponents::RegisterComponentType<CapsulePrimitive>(CAPSULE_PRIMITIVE_TYPE);
309 }
310}
311#endif
static bool RegisterComponentType(std::string type)
Register a component type for creation.
Definition Component.hpp:133
Base component for renderable objects.
Definition RenderComponent.hpp:19
Utilities::Quaternion rotation
Local position offset.
Definition RenderComponent.hpp:51
Utilities::Vector3 scale
Local rotation offset.
Definition RenderComponent.hpp:52
Quaternion for 3D rotations.
Definition Quaternion.hpp:19
Stream for serialization of data.
Definition Stream.hpp:20
3D vector class
Definition Vector3.hpp:19
std::string GetType() const
Get component type.
Definition Primitive.hpp:290
Utilities::Stream Export(Utilities::StreamType type) const
Serialize component to a stream.
Definition Primitive.cpp:654
const bool smooth
Whether to use smooth shading.
Definition Primitive.hpp:300
CapsulePrimitive(Utilities::Vector3 position=Utilities::Vector3(), Utilities::Quaternion rotation=Utilities::Quaternion(), Utilities::Vector3 scale=Utilities::Vector3(1), Material material=Material(), bool smooth=true, TextureType textureType=COVER, Renderer::RenderType renderType=Renderer::SOLID)
Create capsule primitive.
Definition Primitive.cpp:647
const Visuals::TextureType textureType
Texture mapping mode.
Definition Primitive.hpp:299
Utilities::Stream Export(Utilities::StreamType type) const
Serialize component to a stream.
Definition Primitive.cpp:118
const Visuals::TextureType textureType
Texture mapping mode.
Definition Primitive.hpp:76
std::string GetType() const
Get component type.
Definition Primitive.hpp:67
CubePrimitive(Utilities::Vector3 position=Utilities::Vector3(), Utilities::Quaternion rotation=Utilities::Quaternion(), Utilities::Vector3 scale=Utilities::Vector3(1), const Material &material=Material(), TextureType textureType=REPEAT, Renderer::RenderType renderType=Renderer::SOLID)
Create cube primitive.
Definition Primitive.cpp:109
Utilities::Stream Export(Utilities::StreamType type) const
Serialize component to a stream.
Definition Primitive.cpp:585
std::string GetType() const
Get component type.
Definition Primitive.hpp:234
const bool smooth
Whether to use smooth shading.
Definition Primitive.hpp:244
CylinderPrimitive(Utilities::Vector3 position=Utilities::Vector3(), Utilities::Quaternion rotation=Utilities::Quaternion(), Utilities::Vector3 scale=Utilities::Vector3(1), Material material=Material(), bool smooth=true, TextureType textureType=COVER, Renderer::RenderType renderType=Renderer::SOLID)
Create cylinder primitive.
Definition Primitive.cpp:577
const Visuals::TextureType textureType
Texture mapping mode.
Definition Primitive.hpp:243
IcospherePrimitive(Utilities::Vector3 position=Utilities::Vector3(), Utilities::Quaternion rotation=Utilities::Quaternion(), Utilities::Vector3 scale=Utilities::Vector3(1), Material material=Material(), bool smooth=true, TextureType textureType=COVER, Renderer::RenderType renderType=Renderer::SOLID)
Create icosphere primitive.
Definition Primitive.cpp:445
Utilities::Stream Export(Utilities::StreamType type) const
Serialize component to a stream.
Definition Primitive.cpp:454
const Visuals::TextureType textureType
Texture mapping mode.
Definition Primitive.hpp:187
const bool smooth
Whether to use smooth shading.
Definition Primitive.hpp:188
std::string GetType() const
Get component type.
Definition Primitive.hpp:178
Material properties for rendering.
Definition Material.hpp:14
UVSpherePrimitive(Utilities::Vector3 position=Utilities::Vector3(), Utilities::Quaternion rotation=Utilities::Quaternion(), Utilities::Vector3 scale=Utilities::Vector3(1), Material material=Material(), bool smooth=true, TextureType textureType=COVER, Renderer::RenderType renderType=Renderer::SOLID)
Create UV sphere primitive.
Definition Primitive.cpp:252
std::string GetType() const
Get component type.
Definition Primitive.hpp:122
Utilities::Stream Export(Utilities::StreamType type) const
Serialize component to a stream.
Definition Primitive.cpp:261
const bool smooth
Whether to use smooth shading.
Definition Primitive.hpp:132
const Visuals::TextureType textureType
Texture mapping mode.
Definition Primitive.hpp:131