Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
world_objects.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <Strings/components/classes/events/events.h>
7 #include <Strings/components/classes/vector/vector.h>
9 
10 #ifdef BLAM_EXPORTS
11 #define BLAM_EXT_API __declspec(dllexport)
12 #else
13 #define BLAM_EXT_API __declspec(dllimport)
14 #endif
15 
16 namespace Ogre
17 {
18  class ManualObject;
19  class SceneNode;
20  class HlmsDatablock;
21 }
22 
23 class BlamWorldState;
24 class BlamTagData;
25 class TickEvent;
26 
28 {
29  Tag,
30  Primitive,
32 };
33 
35 {
36  Cuboid,
37  Cylinder,
38  Sphere,
39  Capsule,
40  Plane
41 };
42 
50 {
51 public:
52  std::string name = "unnamed";
53  std::string description = "";
54  int editor_folder_id = 0;
55  uint64_t id = 0;
56 
57  BlamWorldState* world = nullptr;
58  BlamVector3 position = { 0, 0, 0 };
59  BlamVector3 rotation = { 0, 0, 0 };
60  BlamVector3 scale = { 1, 1, 1 };
61 
63 
71  virtual ~BlamWorldObject() {};
72 
76  virtual void Render();
77 };
78 
86 {
87 public:
88  BlamTagData* tag_data = nullptr;
89 
96  BlamWorldObject_Tag(BlamTagData* _tag_data, BlamWorldState* _world);
97 
98  void Render();
99 };
100 
111 {
112 private:
113  float cached_radius_0 = 1.0f;
114  float cached_radius_1 = 1.0f;
115  int cached_resolution = 5;
116 
117  BlamVector3 cached_position = { 0, 0, 0 };
118  BlamVector3 cached_rotation = { 0, 0, 0 };
119  BlamVector3 cached_scale = { 1, 1, 1 };
120  BlamColor cached_color = BlamColor(255, 255, 255);
121  bool cached_solid = true;
122 
123  void CreateManualObject();
124 
125 public:
127  Ogre::ManualObject* manual_object = nullptr;
128  Ogre::SceneNode* node = nullptr;
129  Ogre::HlmsDatablock* datablock = nullptr;
130 
131  float radius_0 = 1.0f;
132  float radius_1 = 1.0f;
133  int resolution = 5;
134  BlamColor color = BlamColor(255, 255, 255);
135  bool solid = true;
136 
144 
146 
147  void Render();
148 };
149 
156 class BLAM_EXT_API BlamWorldState : public BlamEventListener
157 {
158 private:
159  std::vector<BlamWorldObject*> objects = std::vector<BlamWorldObject*>();
160 
161 public:
165  BlamWorldState();
166 
170  ~BlamWorldState();
171 
172  void AddObject(BlamWorldObject* object);
173 
174  void RemoveObject(uint64_t object_id);
175 
176  int GetObjectCount();
177 
178  bool HasObject(uint64_t object_id);
179 
180  BlamWorldObject* GetObjectAtIndex(int index);
181 
182  BlamWorldObject* GetObjectById(uint64_t object_id);
183 
194  bool Drop(BlamTagData* tag_data, BlamVector3 position);
195 
196  void OnTickEvent(TickEvent* event);
197 
198  void RenderObjects();
199 };
BLAM_EXT_API
#define BLAM_EXT_API
Definition: world_objects.h:13
tag_io.h
BlamTagInstance::parent_tag
BlamTagData * parent_tag
Definition: tags.h:221
BlamWorldState::RenderObjects
void RenderObjects()
Definition: BlamWorldState.cpp:151
BlamWorldObject_Primitive::node
Ogre::SceneNode * node
Definition: world_objects.h:128
Blam::Rendering::Materials::CreateDefaultUnlitDatablockForPrimitives
BLAM Ogre::HlmsUnlitDatablock * CreateDefaultUnlitDatablockForPrimitives(std::string id)
Creates a default Unlit datablock for use with 2D and 3D primitives.
Definition: materials.cpp:966
BlamWorldState::AddObject
void AddObject(BlamWorldObject *object)
Definition: BlamWorldState.cpp:70
BlamWorldObject::name
std::string name
The unique name of this object.
Definition: world_objects.h:52
BlamWorldObject::position
BlamVector3 position
The position of this object in world space.
Definition: world_objects.h:58
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:416
BlamWorldObject_Primitive::primitive_type
Blam3DPrimitiveType primitive_type
The type of primitive this object represents.
Definition: world_objects.h:126
logger.h
BlamWorldState::Drop
bool Drop(BlamTagData *tag_data, BlamVector3 position)
Drops a tag into the world at the specified coordinates.
Definition: BlamWorldState.cpp:32
Blam::API::v1::HS::Drop
void Drop(std::string tag_name)
Definition: hs.cpp:44
BlamWorldObject_Primitive::color
BlamColor color
Definition: world_objects.h:134
BlamWorldObject_Primitive::solid
bool solid
Definition: world_objects.h:135
BlamWorldObjectType
BlamWorldObjectType
Definition: world_objects.h:27
BlamTagData::path
char path[256]
The tag's path.
Definition: tags.h:141
BlamWorldObject::rotation
BlamVector3 rotation
The rotation of this object in world space.
Definition: world_objects.h:59
BlamTagFieldType::Unspecified
@ Unspecified
Indicates that the field's type is not specified. Fields with this type should be considered invalid.
Blam3DPrimitiveType::Plane
@ Plane
BlamWorldState::GetObjectCount
int GetObjectCount()
Definition: BlamWorldState.cpp:101
rendering.h
BlamWorldObject_Primitive::manual_object
Ogre::ManualObject * manual_object
Definition: world_objects.h:127
BlamTagData::BlamTagData
BlamTagData()
Definition: BlamTagData.cpp:8
bitmap_filtering_mode::point
@ point
BlamWorldObject_Tag::tag_data
BlamTagData * tag_data
Pointer to the tag data associated with this object.
Definition: world_objects.h:88
Demo::GraphicsSystem::getSceneManager
Ogre::SceneManager * getSceneManager(void) const
Definition: GraphicsSystem.h:146
BlamWorldObjectType::Unspecified
@ Unspecified
BlamWorldObject_Tag
Class representing a tag-based world object.
Definition: world_objects.h:85
uint64_t
unsigned long long uint64_t
Definition: stdint.h:18
ImGui::Render
IMGUI_API void Render()
Definition: imgui.cpp:4248
BlamTagData::~BlamTagData
~BlamTagData()
Definition: BlamTagData.cpp:15
BlamTagData::instances
std::vector< BlamTagInstance * > instances
Definition: tags.h:145
BlamTagData::SetTagPath
bool SetTagPath(std::string new_path)
Updates the tag path.
Definition: BlamTagData.cpp:31
Blam3DPrimitiveType::Cuboid
@ Cuboid
BlamWorldState::GetObjectAtIndex
BlamWorldObject * GetObjectAtIndex(int index)
Definition: BlamWorldState.cpp:122
BlamWorldObject_Tag::Render
void Render()
Renders the object to the screen.
Definition: BlamWorldObject_Tag.cpp:8
Blam::Content::Tags::CloneTag
BLAM BlamTagData * CloneTag(BlamTagData *original_tag_data)
Creates a copy of a tag in memory.
Definition: tag_io.cpp:825
BlamWorldState::GetObjectById
BlamWorldObject * GetObjectById(uint64_t object_id)
Definition: BlamWorldState.cpp:130
BlamWorldObject::id
uint64_t id
A unique identifier for this object. Used to identify objects during runtime.
Definition: world_objects.h:55
BlamTagData::GetInstance
BlamTagInstance * GetInstance(std::string identifier)
Definition: BlamTagData.cpp:64
BlamWorldObject::Render
virtual void Render()
Renders the object to the screen.
Definition: BlamWorldObject.cpp:9
BlamWorldObject::~BlamWorldObject
virtual ~BlamWorldObject()
Definition: world_objects.h:71
BlamWorldObject::scale
BlamVector3 scale
The scale/size of the object.
Definition: world_objects.h:60
BlamWorldState::HasObject
bool HasObject(uint64_t object_id)
Definition: BlamWorldState.cpp:106
BlamWorldObject::type
BlamWorldObjectType type
The type of this world object.
Definition: world_objects.h:62
BlamTagInstance::identifier
std::string identifier
Definition: tags.h:222
BlamWorldObject_Primitive::datablock
Ogre::HlmsDatablock * datablock
Definition: world_objects.h:129
BlamWorldState::OnTickEvent
void OnTickEvent(TickEvent *event)
Definition: BlamWorldState.cpp:146
Blam::Rendering::GetGraphicsSystem
BLAM Demo::GraphicsSystem * GetGraphicsSystem()
Retrieves the graphics system used by OGRE.
Definition: ogre.cpp:336
BlamWorldObject_Primitive
Class representing a primitive-based world object.
Definition: world_objects.h:110
BlamTagInstance
Definition: tags.h:219
BlamWorldObject
Class representing a world object.
Definition: world_objects.h:49
Blam3DPrimitiveType::Cylinder
@ Cylinder
BlamWorldObject::BlamWorldObject
BlamWorldObject(BlamWorldState *_world, BlamWorldObjectType _type)
Creates a new world object.
Definition: BlamWorldObject.cpp:3
Blam3DPrimitiveType::Capsule
@ Capsule
BlamWorldObject_Primitive::radius_1
float radius_1
A secondary radius of the primitive. Only used in cylinders.
Definition: world_objects.h:132
BlamWorldObject_Tag::BlamWorldObject_Tag
BlamWorldObject_Tag(BlamTagData *_tag_data, BlamWorldState *_world)
Creates a new tag-based world object.
Definition: BlamWorldObject_Tag.cpp:3
BlamWorldState::~BlamWorldState
~BlamWorldState()
Destroys the world state.
Definition: BlamWorldState.cpp:16
Blam3DPrimitiveType::Sphere
@ Sphere
BlamTagData::CreateNewInstance
BlamTagInstance * CreateNewInstance()
Definition: BlamTagData.cpp:51
BlamWorldObjectType::Primitive
@ Primitive
BlamWorldObject_Primitive::radius_0
float radius_0
The radius of the primitive. Only used in cylinders.
Definition: world_objects.h:131
BlamWorldObject_Primitive::resolution
int resolution
The level of detail to use for the primitive. Only used in cylinders.
Definition: world_objects.h:133
Ogre
Definition: world_objects.h:16
tags.h
tags.h
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:125
BlamWorldState::RemoveObject
void RemoveObject(uint64_t object_id)
Definition: BlamWorldState.cpp:85
Blam3DPrimitiveType
Blam3DPrimitiveType
Definition: world_objects.h:34
BlamTagInstance::instance
BlamTagData * instance
Definition: tags.h:223
BlamWorldObject::world
BlamWorldState * world
The world state this object belongs to.
Definition: world_objects.h:57
BlamWorldObject_Primitive::~BlamWorldObject_Primitive
~BlamWorldObject_Primitive()
Definition: BlamWorldObject_Primitive.cpp:32
BlamWorldObject_Primitive::Render
void Render()
Renders the object to the screen.
Definition: BlamWorldObject_Primitive.cpp:299
BlamWorldState
Class representing a world state.
Definition: world_objects.h:156
name
ARPHIC PUBLIC LICENSE Ltd Yung Chi Taiwan All rights reserved except as specified below Everyone is permitted to copy and distribute verbatim copies of this license but changing it is forbidden Preamble The licenses for most software are designed to take away your freedom to share and change it By the ARPHIC PUBLIC LICENSE specifically permits and encourages you to use this provided that you give the recipients all the rights that we gave you and make sure they can get the modifications of this software Legal Terms Font means the TrueType fonts AR PL Mingti2L AR PL KaitiM AR PL KaitiM and the derivatives of those fonts created through any modification including modifying reordering converting changing font name
Definition: ARPHICPL.TXT:16
BlamWorldObjectType::Tag
@ Tag
BlamWorldObject_Primitive::BlamWorldObject_Primitive
BlamWorldObject_Primitive(Blam3DPrimitiveType _primitive_type, BlamWorldState *_world)
Creates a new primitive world object.
Definition: BlamWorldObject_Primitive.cpp:15
BlamWorldState::BlamWorldState
BlamWorldState()
Initializes a new world state.
Definition: BlamWorldState.cpp:8
BlamTagData::tag_class
std::string tag_class
The tag's short class name.
Definition: tags.h:142