• Advertisement
Sign in to follow this  
  • entries
    73
  • comments
    131
  • views
    54868

christmas cookies

Sign in to follow this  

222 views

looks like those mods felt like they could change my journal appearances again ;) Abuse of power, I say!

Totally just kidding... I like this Christmasy theme!

Been working on scene management tools. I'm currently struggling with how far I want to abstract things. I'm also trying to think of the best way to handle entity creation and configuration. Here's the basic entity creator that I've come up with:


shared_ptr CreateEntity(string Name, entity_type Type, string Parameters) {
switch(type) {
case ENTITY_GEOMETRY: return shared_ptr(new AXMeshInstance(Name, Parameters));
case ENTITY_LIGHT: return shared_ptr(new AXLight(Name, Parameters));
/* ... more ... */
}

EntityMap[Name] = out;
}


Parameters is a string of configuration variables. For a mesh, you could pass "name=ball;shader=effect01". It gets a little messier with a light with so many options. I don't really think I like this way (I haven't spent anytime implementing it either because of this). Though it's appealing because I wouldn't really need to serialize configurations.

So, I guess the function could just return a default object. The annoying thing about this is that it returns an AXEntity object, so you'd have to cast it to your requested type to configure it (using dynamic_cast of course).

The only way around it is doing something like this, but I typically don't like this style for some reason. perhaps it's because I have to declare the variable beforehand.


void CreateEntity(string Name, entity_type Type, shared_ptr &EntityOut);


Hmm.. gonna think of how I want all this to look a little bit more.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement