About Store Forum Documentation Contact



Post Reply 
Simple overview of custom object creation in Esenthel
Author Message
Pixel Perfect Offline
Member

Post: #1
Simple overview of custom object creation in Esenthel
I've spent a bit of time digging into the Bloody Massacre code and other examples and also watched Scarlet Thread's excellent video on game objects (many thanks Ken ... you saved me a lot of time) and have come up with a basic overview of how the system appears to work in Esenthel to get it straight in my mind.

I thought a written exploration of it might be useful to others and also allow people to put me straight on any misconceptions or glaring admissions. Please feel free to comment/correct/add detail.

I would recommend people watch Scarlet's video for detailed implementation.


Overview

Esenthel's underlying framework supports the generation of game objects based on a base object game::obj that adds some base functionality (interface) for game objects which is inherited by objects derived from it. This functionality is declared in the following file and definitely worth examining:

Esenthel Engine\Game\Object.h

There are a series of classes and objects already derived from this and present in the engine by default which include for example:

Game::Static
Game::Kinematic
Game::Chr
Game::Item

along with others.

Game::obj and the other classes derived from it can be used as the basis of your own classes for game objects as most of their functions are virtual and can be overriden in your own classes to provide the functionality you need and extend the underlying objects.

Note, some of the functions are abstract and as such have to be implemented in your derived classes.


Implementation in the Esenthel Editor

The new game object classes are created under your application folder as new Code items. Code the class functionality overriding virtual functions where needed and adding the functionality you require. For example:

Class MyTestClass : public Game::obj
{
...
}

Create a new Object Class item and give it a representative name for your class and add any parameters you want objects based on this class to have by default.

For example:

OBJ_MYTESTCLASS

The framework handles the passing of parameters to your objects via the struct ObjParams which is defined in:

Esenthel Engine\Game\Object Params.h

Once you have created the Object Class you can create new objects based on this by assigning your new class to them in the Object Editor params screen. You can set values or override default ones for parameters or define additional parameters specific to this object.

Instances of these objects can then be dropped into your game world in the Editor.


Relationship between the Class code and the Class Objects

This is not immediately obvious other than the fact that they have been created to work with each other. Two additional steps are required as follows:

You need to create a memory container in your code to hold the objects of your class. This is done by declaring a global container. For example:

Game::ObjMemx< MyTestClass > MyTestClassObjs;

Then a second function placed before you load the world tells the World Manager which container to use for your Object Class items in the world and hence which class to use to instantiate those items as the world is loaded. For example:

Game.World.setObjType(MyTestClassObjs, OBJ_MYTESTCLASS);

Place these for each object class before:

Game.World.New()

since that is when the world manager will be allocating objects to those memory locations.

This is a really cool system, I like it a lot!

[EDIT] Included Ozmodian's observations below. Many thanks!
(This post was last modified: 05-05-2013 06:28 PM by Pixel Perfect.)
05-05-2013 11:54 AM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #2
RE: Simple overview of custom object creation in Esenthel
Hi Pixel,

Great summary, it is always good to have clean basic overviews for new people to read. Awesome job!

2 very minor things you might want to add to the last section:

1) Game::ObjMemx< MyTestClass > MyTestClassObjs; This must be set as a global variable. Declaring it in a local space would eventually cause your application to crash (I discovered this the hard way)

2) Game.World.setObjType(MyTestClassObjs, OBJ_MYTESTCLASS); This must be called for each object class before Game.World.New() since that is when the world manager will be allocating objects to those memory locations.
05-05-2013 05:22 PM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #3
RE: Simple overview of custom object creation in Esenthel
Cheers for spotting those, I'll update the post to reflect that.

I'm currently ploughing my way through the character class prior to starting to code for animation. If people think these kinds of summaries are useful then I'll continue as I go through my learning curve.

With people picking up on where I get it wrong or miss things we could end up with some reasonable overview reference material for people new to the engine.
05-05-2013 06:21 PM
Find all posts by this user Quote this message in a reply
treavor09 Offline
Member

Post: #4
RE: Simple overview of custom object creation in Esenthel
great stuff def. gonna use this as a refrence
05-09-2013 07:45 PM
Find all posts by this user Quote this message in a reply
Post Reply