Thoughts

Published July 28, 2006
Advertisement
I've been quite busy lately, working on a variety of things, except what I should really be working on: 4e5 [grin]

1. Since my 4e5 game will be slightly fantasy based, and I'm going for a graphical style similar to Warcraft3, I figured I'd just write a loader for Warcraft3 models to use as temp art. So said, so started. Unfortunately, the format is barely documented. I did find one document which describes all the blocks, though not what they are for. Bar a few errors in that, I've been able to load the static base mesh, and am now in progress of loading the bones for the animation (I think). Will post screenies once I've actually added code to convert to my internal model format.

2. Abstracting renderer into DLL. I've always wanted to try this, so I decided to give it a go. My renderer was already quite self-contained because I work for multiple platforms, so it shouldn't be too much of a problem. I got the basic D3D sample off internet, and made it into a DLL. With a little help from Dave with compiling it, it seems to work. It doesn't do much yet, but it does work.

3. Something else I've been thinking a lot about lately is materials and vertex streams. Since my code is meant to work on machines which differ in power greatly, I need to get this right else it'll be a mess in client code. My current idea is to keep models and materials internal to the rendering system (which is modular) since it wouldn't usually be needed outside of that. I'm not going to worry about physics just yet [grin].

4. I've been using RakNet to add some multiplayer to my 4e5 entry. It'll make it easier to test the gamelogic and balancing while there is no AI yet. Connecting works, next step is to actually share the commands.

5. boost::any rocks! I figured I needed something to allow me to pass some arbitrary data into the DLLs for setup routines. I vaguely remembered boost had something, so I did a quick search. It turns out boost::any is exactly what I needed. Observe:

PropertyList:
#include #include #include class PropertyList{public:	void Insert( const std::string& name, boost::any value )	{		propertyMap_[name] = value;	}	void Remove( const std::string& name )	{		std::map::iterator iter = propertyMap_.find(name);		if(iter!=propertyMap_.end())			propertyMap_.erase(iter);	}	template< class T >	bool GetValue( const std::string& name, T& value )	{		std::map::const_iterator iter = propertyMap_.find(name);		if(iter!=propertyMap_.end())		{			try			{				value = boost::any_cast(iter->second);				return true;			}			catch(const boost::bad_any_cast &)			{				return false;			}		}		else			return false;	}private:	std::map propertyMap_;};


Usage:
PropertyList myList;myList.Insert("astring", std::string("mytext"));myList.Insert("anint", 5);myList.Insert("afloat", 3.5f);std::string st;int i;float f;double d;bool success = myList.GetValue("astring", st);		// returns truesuccess = myList.GetValue("afloat", d);			// returns false, and doesn't modify dsuccess = myList.GetValue("anint", i);			// returns truesuccess = myList.GetValue("adouble", d);		// returns false, and doesn't modify dmyList.Remove("astring");myList.GetValue("astring", st);				// returns false, since astring removedmyList.Remove("me");					// no-op since "me" isn't there


It allows you to store any data in the PropertyList and access it extremely easily.
Previous Entry 4e5 #1
Next Entry Awesome app idea
0 likes 2 comments

Comments

superpig
I wonder if you could integrate boost::lexical_cast into that as well - so that you can put something in as a int and get it back as a string without problems.
July 28, 2006 09:47 AM
rick_appleton
Although that seems like something nice, I'm not sure it's possible.

The syntax would theoretically be something like:

std::string myString = boost::lexical_cast<std::string>( boost::any_cast<int>( iter->second ) );


The problem being that you then need to store the type inside the boost::any (to pull out the correct type to put into the any_cast). At a quick glance, boost::any can return a std::type_info, but I don't know if you can use that to do the boost::any_cast<type here>.

You'd need to pass the actual type to the GetValue function as well, at which point, you could just as well do the lexical_cast after getting the value. Maybe someone with more experience with RTTI can help here?
July 28, 2006 12:05 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

OpenGL 3.0

1267 views

Awesome app idea

1206 views

Thoughts

1230 views

4e5 #1

1242 views

Daedalus progress

1101 views

Almost there ...

1076 views

GBA Renderer

1134 views
Advertisement