Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.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 #include <OGRE/OgreManualObject2.h>
6 
7 #include <Strings/components/classes/events/events.h>
8 #include <Strings/components/classes/vector/vector.h>
10 
11 #ifdef BLAM_EXPORTS
12 #define BLAM_EXT_API __declspec(dllexport)
13 #else
14 #define BLAM_EXT_API __declspec(dllimport)
15 #endif
16 
17 class BlamWorldState;
18 class BlamTagData;
19 class TickEvent;
20 
22 {
23  Tag,
24  Primitive,
26 };
27 
29 {
30  Cuboid,
31  Cylinder,
32  Sphere,
33  Plane
34 };
35 
43 {
44 public:
45  std::string name = "unnamed";
46  std::string description = "";
47  int editor_folder_id = 0;
48  uint64_t id = 0;
49 
50  BlamWorldState* world = nullptr;
51  BlamVector3 position = { 0, 0, 0 };
52  BlamVector3 rotation = { 0, 0, 0 };
53  BlamVector3 scale = { 1, 1, 1 };
54 
56 
64  virtual ~BlamWorldObject() {};
65 
69  virtual void Render();
70 };
71 
79 {
80 public:
81  BlamTagData* tag_data = nullptr;
82 
89  BlamWorldObject_Tag(BlamTagData* _tag_data, BlamWorldState* _world);
90 
91  void Render();
92 };
93 
104 {
105 private:
106  float cached_radius_0 = 1.0f;
107  float cached_radius_1 = 1.0f;
108  int cached_resolution = 5;
109 
110  BlamVector3 cached_position = { 0, 0, 0 };
111  BlamVector3 cached_rotation = { 0, 0, 0 };
112  BlamVector3 cached_scale = { 1, 1, 1 };
113  BlamColor cached_color = BlamColor(255, 255, 255);
114  bool cached_solid = true;
115 
116  void CreateManualObject();
117 
118 public:
120  Ogre::ManualObject* manual_object = nullptr;
121  Ogre::SceneNode* node = nullptr;
122  Ogre::HlmsDatablock* datablock = nullptr;
123 
124  float radius_0 = 1.0f;
125  float radius_1 = 1.0f;
126  int resolution = 5;
127  BlamColor color = BlamColor(255, 255, 255);
128  bool solid = true;
129 
137 
139 
140  void Render();
141 };
142 
149 class BLAM_EXT_API BlamWorldState : public BlamEventListener
150 {
151 private:
152  std::vector<BlamWorldObject*> objects = std::vector<BlamWorldObject*>();
153 
154 public:
158  BlamWorldState();
159 
163  ~BlamWorldState();
164 
165  void AddObject(BlamWorldObject* object);
166 
167  void RemoveObject(uint64_t object_id);
168 
169  int GetObjectCount();
170 
171  bool HasObject(uint64_t object_id);
172 
173  BlamWorldObject* GetObjectAtIndex(int index);
174 
175  BlamWorldObject* GetObjectById(uint64_t object_id);
176 
187  bool Drop(BlamTagData* tag_data, BlamVector3 position);
188 
189  void OnTickEvent(TickEvent* event);
190 
191  void RenderObjects();
192 };
BLAM_EXT_API
#define BLAM_EXT_API
Definition: world_objects.h:14
BlamRendering::OGRE::Materials::CreateDefaultUnlitDatablockForPrimitives
BLAM Ogre::HlmsUnlitDatablock * CreateDefaultUnlitDatablockForPrimitives(std::string id)
Definition: materials.cpp:916
tag_io.h
BlamTagInstance::parent_tag
BlamTagData * parent_tag
Definition: tags.h:164
BlamWorldState::RenderObjects
void RenderObjects()
Definition: BlamWorldState.cpp:151
BlamWorldObject_Primitive::node
Ogre::SceneNode * node
Definition: world_objects.h:121
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:45
BlamWorldObject::position
BlamVector3 position
The position of this object in world space.
Definition: world_objects.h:51
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:142
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:359
BlamWorldObject_Primitive::primitive_type
Blam3DPrimitiveType primitive_type
The type of primitive this object represents.
Definition: world_objects.h:119
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
BlamRendering::GetCurrentRenderingEngine
BLAM BlamRenderingEngine GetCurrentRenderingEngine()
Retrieves the current rendering engine being used.
Definition: rendering_abstraction.cpp:104
Blam::API::v1::HS::Drop
void Drop(std::string tag_name)
Definition: hs.cpp:44
BlamWorldObject_Primitive::color
BlamColor color
Definition: world_objects.h:127
BlamWorldObject_Primitive::solid
bool solid
Definition: world_objects.h:128
BlamRendering::OGRE::GetGraphicsSystem
BLAM Demo::GraphicsSystem * GetGraphicsSystem()
Definition: ogre.cpp:343
BlamWorldObjectType
BlamWorldObjectType
Definition: world_objects.h:21
OGRE
@ OGRE
Definition: rendering.h:41
primitives.h
BlamTagData::path
char path[256]
The tag's path.
Definition: tags.h:84
BlamWorldObject::rotation
BlamVector3 rotation
The rotation of this object in world space.
Definition: world_objects.h:52
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:120
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:81
Demo::GraphicsSystem::getSceneManager
Ogre::SceneManager * getSceneManager(void) const
Definition: GraphicsSystem.h:146
BlamRendering::BGFX::Primitives::DrawCuboid
BLAM void DrawCuboid(BlamVector3 position, BlamVector3 rotation, BlamVector3 scale)
Renders a cuboid to the screen.
Definition: cuboid.cpp:12
BlamWorldObjectType::Unspecified
@ Unspecified
BlamWorldObject_Tag
Class representing a tag-based world object.
Definition: world_objects.h:78
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:88
BlamTagData::SetTagPath
bool SetTagPath(std::string new_path)
Updates the tag path.
Definition: BlamTagData.cpp:31
BlamRendering::BGFX::Primitives::DrawCylinder
BLAM void DrawCylinder(BlamVector3 position, BlamVector3 rotation, BlamVector3 scale, int resolution, int radius_top, int radius_bottom)
Renders a cylinder to the screen.
Definition: cylinder.cpp:28
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)
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:48
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:64
BlamWorldObject::scale
BlamVector3 scale
The scale/size of the object.
Definition: world_objects.h:53
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:55
BlamTagInstance::identifier
std::string identifier
Definition: tags.h:165
BlamWorldObject_Primitive::datablock
Ogre::HlmsDatablock * datablock
Definition: world_objects.h:122
BlamWorldState::OnTickEvent
void OnTickEvent(TickEvent *event)
Definition: BlamWorldState.cpp:146
BlamWorldObject_Primitive
Class representing a primitive-based world object.
Definition: world_objects.h:103
BlamTagInstance
Definition: tags.h:162
BlamWorldObject
Class representing a world object.
Definition: world_objects.h:42
Blam3DPrimitiveType::Cylinder
@ Cylinder
BlamWorldObject::BlamWorldObject
BlamWorldObject(BlamWorldState *_world, BlamWorldObjectType _type)
Creates a new world object.
Definition: BlamWorldObject.cpp:3
BlamWorldObject_Primitive::radius_1
float radius_1
A secondary radius of the primitive. Only used in cylinders.
Definition: world_objects.h:125
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:124
BlamWorldObject_Primitive::resolution
int resolution
The level of detail to use for the primitive. Only used in cylinders.
Definition: world_objects.h:126
tags.h
tags.h
BlamTagData
Class used to contain and access tag data.
Definition: tags.h:68
BlamWorldState::RemoveObject
void RemoveObject(uint64_t object_id)
Definition: BlamWorldState.cpp:85
Blam3DPrimitiveType
Blam3DPrimitiveType
Definition: world_objects.h:28
BGFX
@ BGFX
Definition: rendering.h:40
BlamTagInstance::instance
BlamTagData * instance
Definition: tags.h:166
BlamWorldObject::world
BlamWorldState * world
The world state this object belongs to.
Definition: world_objects.h:50
BlamWorldObject_Primitive::~BlamWorldObject_Primitive
~BlamWorldObject_Primitive()
Definition: BlamWorldObject_Primitive.cpp:36
BlamWorldObject_Primitive::Render
void Render()
Renders the object to the screen.
Definition: BlamWorldObject_Primitive.cpp:306
BlamWorldState
Class representing a world state.
Definition: world_objects.h:149
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:85