christmas cookies

posted in Programmology
Published December 19, 2005
Advertisement
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.
Previous Entry Factories
Next Entry streams
0 likes 1 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement