Jordan Bonser
  • Home
  • CV
  • University Work
    • Second Year Work >
      • Top-Down Shooter
    • Third Year Work >
      • Terrain Analysis Project >
        • Terrain Analysis Tool
        • Game Demonstration
      • Post Processing
      • Android Application - Sports Centre
  • Projects
    • Unity Development >
      • Lerpz Tutorial
      • Dare to be Digital Entry - "Lit"
      • Unity Game
    • Geometry Instancing
    • Road to Eldorado
    • Level Editor
    • OpenGL Work
    • JBEngine
  • Blog
  • Tutorials
    • Flask Session Timeout

Development Blog

JBEngine: Entity Component System Messaging

31/1/2015

0 Comments

 
So after a long while fighting with templates I have finally got a decent implementation of the ECS. I now have Systems, Components and Component Pools.

There is a Component Pool for each component and that holds every single component of that type.

Each System keeps track of each of the entities that is registered for it and then on update the system loops through all the entities getting the components that it needs for that entity and performing the actions on it.

This new way of doing things, having systems work on their own will give me the opportunity to add thread pools once that is necessary. This will allow me to use worker threads for sections of entities registered for the system.

So that is the general usage of the Systems and Components. The next part I will talk about is messaging, this has been a very tricky part of the Entity System.

I have again used CRTP to accomplish this, and I believe allowing a system to register for messages is easier than ever now.

The Messaging system is technically something completely seperate from the Entity System/Component architecture and because of this it is not just Systems that can listen for messages.

Okay so how does it work?

So the Message class is where the CRTP occurs, each derived message type will supply itself as the template parameter for the base class:
  class DerivedMessage : public Message
{
public:
DerivedMessage();
virtual ~DerivedMessage(){};
protected:

};
This allows for much easier dispatch of the messages now to show how to make a class receive messages:

first of all you have to derive the class that will listen to the messages from the MessageListener class supplying the message you will be using:
  template < class MessageType >
class MessageListener
{
public:
virtual void HandleMessage(MessageType* message) = 0;
};


class MovementSystem : public System< MovementSystem>,
public MessageListener< MovementMessage>,
public MessageListener< RotationMessage>
{
public:
MovementSystem(MessageManager* msgManager);

virtual void Update();
virtual ~MovementSystem(void);
void HandleMessage(MovementMessage* message);
void HandleMessage(RotationMessage* message);
virtual void RegisterMessages();

};
The next step is merely to register to receive the messages of a certain type in the RegisterMessages function. This is called just after creation of any System.
  void MovementSystem::RegisterMessages()
{
mMessageManager->RegisterListener< MovementMessage>(this);
mMessageManager->RegisterListener< RotationMessage>(this);
}
and then of course all that is left is to handle the messages with each of the HandleMessage functions.

Finally this is a little demo program that shows the use of the ECS and messaging:
  int _tmain(int argc, _TCHAR* argv[])
{
MessageManager messManager;
EntityManager manager(& messManager);

Entity* newEnt = manager.CreateEntity( string( "MyFirstEntity" ) );

newEnt->AddComponent< PositionComponent>( newEnt );
newEnt->AddComponent< VelocityComponent>( newEnt );

newEnt->AddSystem< MovementSystem>();

messManager.SendMessage< MovementMessage>( 40.0f, 0.2f, 0.0f );
messManager.SendMessage< RotationdMessage>( 20.0f, 0.0f, 0.0f );

return 0;
}
I have used variadic templates throughout to make creating Messages and Components really simple.

So I believe this is a fairly flexible approach, there are probably a few more things that I could do to make this better but for now I am going to leave it as it is and try and re-implement all the functionality that is in my previous version of the ECS. Once this is all integrated back into my Engine then I will run some tests and see if there is need for any more changes.

All is going well after a lot of frustrating times with templates. There are still some things that need tidying up to ensure the system is a little more robust but I am very happy with the progress.

Thanks  :)
0 Comments

Level Editor Export and a massive refactor!

26/1/2015

0 Comments

 

Exporting...

On Thursday I managed to get the Export of the Levels to work. This involves exporting the Assets ( Meshes, Textures, Sounds ) and the Entities( Components, Data Components ). After doing this the only thing I had left to do is allow editing of the rotation of the entities, which posed a problem. Up until now I had been directly editing the Matrix of the Mesh Instance I had selected. This was fine except to do rotation I would need to store the Euler Angles that could be edited from the User Interface.

This got me thinking, I should be using the Entity Component System(ECS) for all of this data realistically, and I will also be wanting to edit values of the Data Components from within the Level Editor as this will make entity creation much better. In my current system for ECS there isn't any way of getting a Data Component for an Entity without doing a dynamic cast based on some sort of ID which could potentially go wrong. So I started looking at different solutions for ECS since my first initial implementation. I came across this post: ECS, Component, Entities and Systems, which suggests the use of the Curiously Recurring Template Pattern(CRTP) for the ECS. 

First Attempt

Most of Thursday night was spent refactoring my current ECS from a virtual inheritance style hierarchy to this CRTP version. Needless to say after a lot of Linking Errors and all sorts of crazy going on I decided to scrap it and revert my changes.

Second Attempt

So for my second attempt I decided to create a seperate project for my ECS and get it all set up with the templates before integrating it into the engine. I am part way through this, I've got all the Components and Data Components working I just haven't dealt with the messaging yet. I have really mixed things up, instead of storing Components within the entity I have created pools of all the same types and they just have reference to their entity. This way has a few benefits such as cache coherency, 

the updates will also be Component Priority dependant rather than Entity Creation dependant. This approach will also give me better opportunity to perform multi-threading when the time comes, each pool could use worker threads to update chunks of the Components. 

One thing I am likely to change is the wording I previously used, in most descriptions of an ECS the words System and Component are used where as mine uses Component and Data Component which really confuses things as:

Component = Data Component
System = Component

For the sake of anyone wanting to use the Engine and reading up on Component Systems it seems more appropriate to use the most common terminology.

Okay so finally a demo of what access to the new Components will look like:

auto posComponent = entity->GetComponent<PositionComponent>();

also as I have used Variadic templates so the adding of Components to entities is clean and simple:

entity->AddComponent<PositionComponent>( x, y, z );

Okay so there is still a lot of work to be done but I'm hoping to get this all nailed pretty soon so I can really start using the ECS.

Cheers :)

0 Comments

Level Editor Entity Creation

21/1/2015

0 Comments

 
Work is progressing massively each day at the moment. I have just implemented the Entity creation code and added the extra functionality to the GUI. 

The rate at which I am creating the GUI is increasing rapidly as I'm getting better with JQuery and also I have now implemented a reload feature so I can just tweak the JavaScript and then reload the GUI without having to stop and start the program. 

Anyway enough chit chat here is a demo of the entity creation in action:
So I have managed to get a couple of things off my check list from the last post off already which is great I now just need to add 

The rotation and scale support and then hook in the export code again and I will have a fully usable Level Editor.

On target to get this nailed by the end of this week and it's about time :)
0 Comments

Level Editor and Game GUI working!

20/1/2015

0 Comments

 
I have just been implementing the two different GUI's for the Level Editor and the game project. Currently they aren't that impressive, although the Level Editor GUI does let you alter Entities positions in the scene which is great.
The Game's GUI is just a simple box that lets you choose whether you want to start a Client or Server Game so it does pretty much exactly what the old GUI did ( Except it looks a lot more shiny :) ). 

Anyway enough talking here is a quick video of the two GUI's in use:
Things are really starting to come along and my aim for this week is to have a bare bones Level Editor up and running. This seems like quite a lot from what is already there but the only things I need to implement are:
  • Rotation and Scale applied to models  ( Will need to store Euler Angles )
  • Add GUI functionality for displaying all loaded meshes
  • Add GUI functionality for adding one of the meshes to the scene ( Might just spawn at 0,0,0 )
  • Make the assets export on one of the File Menu drop down buttons

I would say the largest chunk of work is going to be the parts with the GUI, particularly as I'm still new at using JavaScript but I should be able to throw something together pretty quickly. 

It is all very exciting, as an added note I have decided I am going to go with the .md3 .md4 .md5 model files for import into my engine. There seems to be pretty solid exporters out there for blender and it is the most stable file format that works with my engine, specifically the animations. 

I should also mention I have used models from another project as placeholders for now, here is a link to the sourceforge project: Mundo Game

Anyway until next time,
Cheers :)
0 Comments

Awesomium Library and a massive tidy up!

14/1/2015

0 Comments

 
So I managed to get most of the awesomium refactoring done last night. I now have an Awesomium library that depends on the JBEngine library. the JBEngine now makes use of a IGUIManger object and I have created a new AwesomiumGUIManager in the Awesomium Library. 

So this is now much more abstract and I will be able to very easily create a different GUI for the Game project simply by linking the new awesomium project and adding a new HTML page. I will make a video of the two different GUI's in use as soon as I get them up and running. 

There is still quite a lot more to do before the Awesomium code is flexible enough that I am happy with it. I need some standard way of communication between the GUI Layer and the Game Logic. As soon as I have that set in stone I can really start to make full use of the user interface.

Project Includes and Libraries

After realising how large my project had slowly become I thought it was time to see where I could trim it down.

First of all I realised that a lot of my include files for each project were repeated, and so were my static library files. just checking a couple of these I realised that had to change as some of the libraries were 50-100mb which is just not reasonable to have dotted all over the place.

I have now created Include and Lib Folders at the solution level of my directory. This will also reduce the risk of having different versions of a library or include files for different projects in my solution. All in all it seems like a good move. I have also tried to get rid of any files/directories that projects wouldn't need to know about. There were a few that were left over from copying project files and directories when creating new projects.

All this changing round has taken me a while though, flicking through different projects altering Lib and Include Directories actually takes a large portion of time.

I'm pretty damn motivated at the moment which is great :) 

hoping to get something a little more impressive to show fairly soon. 

Cheers.
0 Comments

New Job: Inspired Gaming and getting back on track...

12/1/2015

0 Comments

 
Over the past couple of months there has been quite a lot going on in my life, namely moving to Manchester City Centre and then more recently getting a new job. Unfortunately with everything going on something had to give, and that ended up being my project development. 

Now I am a little more settled I am hoping to start back up again and with extra experience I have gained since starting my new job. So far I have really enjoyed working at Inspired, I am finally able to use Visual Studio again for my day to day work which is a massive plus! 

In terms of the work I am doing at Inspired I'm not sure I am allowed to divulge exactly what it is, but It is all exciting stuff and I'm really looking forward to the direction that the company is heading. 

Back to work: Awesomium continuation...

Okay so I need to re-motivate myself and what better way to do it that with a little refactoring. I have given myself a couple of hours tonight to crack on with getting the awesomium code into it's own library and creating an abstract way of creating User Interfaces.

Currently the Awesomium code is all dumped in the Level Editor project, which means I can't even use this stuff within the game at the moment. The Awesomium code makes use of the Texture and GUI Classes which I am thinking I would like to change. I will keep the old method of creating a GUI but I am now going to have an Interface IGUIManager which I will then derive a new manager for dealing just with the Awesomium GUI.

The main reasons for this is because the other GUI Manager has lots of features which are just not necessary for the Awesomium stuff and it will just bulk up the source code. I am hoping to get rid of the old GUI code all together once I clarify that the Awesomium code does everything I need.

So there is the plan, wish me good luck :)


0 Comments

    Archives

    May 2020
    April 2020
    January 2020
    November 2019
    October 2019
    September 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    August 2018
    July 2018
    June 2018
    March 2018
    January 2018
    June 2017
    February 2017
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    February 2016
    January 2016
    December 2015
    November 2015
    September 2015
    August 2015
    July 2015
    June 2015
    March 2015
    January 2015
    November 2014
    October 2014
    September 2014
    August 2014
    July 2014
    June 2014
    May 2014
    February 2014
    January 2014
    December 2013
    November 2013
    October 2013
    July 2013
    June 2013
    May 2013
    April 2013
    March 2013
    February 2013
    January 2013
    December 2012
    October 2012
    September 2012
    August 2012
    July 2012
    June 2012
    May 2012

    Categories

    All
    2D
    3rd Year Project
    Agile
    Android
    Angular
    Animation
    API
    Apple
    Apps
    Arden
    Async
    Awesomium
    C#
    CI/CD
    Clean Code
    CMake
    Cocos2d-x
    Colour Match
    Compilers
    Cross Compiling
    Cross-Compiling
    Databases
    Design
    Development Tools
    Docker
    Electronics
    Examples
    Flask
    Flask-Login
    Fmod
    Game Development
    Godot
    GUI
    Hackathon
    Hacktoberfest
    Hardware
    Home Life
    IBM
    Inspired Gaming
    Instancing
    Ios
    Javascript
    Jbengine
    Kata
    Level Editor
    Linux
    Microsoft
    Mobile Development
    Monogame
    Moodster
    Motivation
    Networking
    Objective C
    Opengl
    Open Source
    Organisation
    Physics
    Physx
    Pi
    Planning
    Post Mortem
    PyGame
    Python
    Quart
    Quasar
    RakNet
    React
    Road To Eldoarado
    Scripting
    Scrum Master
    Sessions
    Session Timeout
    Social
    Sound
    Space Invaders
    Squash Game
    Squash Game
    Streaming
    TDD
    Team Leading
    Test
    Test Driven Development
    Travis
    Unity
    Unity Development
    VSCode
    Vulkan
    Web Applications
    Worklife
    WSL
    XML
    XNA / C#

    RSS Feed

Powered by Create your own unique website with customizable templates.
  • Home
  • CV
  • University Work
    • Second Year Work >
      • Top-Down Shooter
    • Third Year Work >
      • Terrain Analysis Project >
        • Terrain Analysis Tool
        • Game Demonstration
      • Post Processing
      • Android Application - Sports Centre
  • Projects
    • Unity Development >
      • Lerpz Tutorial
      • Dare to be Digital Entry - "Lit"
      • Unity Game
    • Geometry Instancing
    • Road to Eldorado
    • Level Editor
    • OpenGL Work
    • JBEngine
  • Blog
  • Tutorials
    • Flask Session Timeout