Map specific unit models

Map specific unit models

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Map specific unit models

Post by Gnomre »

Well, I asked for it to be done, then took a shot at it myself. I got it working, though probably not in the most efficient way possible. Remember, I'm not a great coder so I'm just going to list everything I did so I don't confuse anyone. Also, this is built off the last officially released version of the engine source, so depending on the new map format things may need modified. Here goes.

Non-source changes
1. Add the line "GenericWorld=x;" (where x is a number, currently 0, 1, or 2) to the map's SMD, under the [MAPS] section (not any sub sections). Not all maps require this, as it will default to 0 if not there.

2. Add the lines "Objectgrass=modelNameForGrassCamo;", "Objectsnow=modelname;" etc to the target unit's FBI (currently those are the only ones I put in).

Source changes
3. ReadMap.h
Add "int genericWorld;" to the CReadMap class.

4. BFReadMap.cpp
Add "mapDefParser.GetDef(genericWorld, "0", "MAP\\GenericWorld");" to CBFReadmap::ParseSMD.

5. UnitDefHandler.cpp
Here's the big one. Change this:

Code: Select all

std::string objectname;
	sunparser.GetDef(objectname, "", "UNITINFO\\Objectname");
	ud.model.modelpath = "objects3d\\" + objectname + ".3do";
	ud.model.modelname = objectname;
to this:

Code: Select all

std::string objectname;
	std::string objectgrass;
	std::string objectsnow;
	sunparser.GetDef(objectname, "", "UNITINFO\\Objectname");
	sunparser.GetDef(objectgrass, objectname, "UNITINFO\\objectgrass");
	sunparser.GetDef(objectsnow, objectname, "UNITINFO\\objectsnow");

	if(readmap->genericWorld == 1) {
		ud.model.modelpath = "objects3d\\" + objectgrass + ".3do";
		ud.model.modelname = objectname;
	}
	else if(readmap->genericWorld == 2) {
		ud.model.modelpath = "objects3d\\" + objectsnow + ".3do";
		ud.model.modelname = objectname;
	}
	else {
		ud.model.modelpath = "objects3d\\" + objectname + ".3do";
		ud.model.modelname = objectname;
	}
Obviously, for more world support, more std::strings and else ifs and crap would be necessary. This is where I think someone could code it more efficiently. Also, I couldn't get it to work using names for the worlds, only numbers, but I am certain that is just a lack of skill issue on my part.

This should be fairly simple to follow. It'll load the camo model for the world defined in the SMD if there is a model for that world defined in the FBI for the particular unit. If there isn't one defined, it just uses the default model.

I know I and the real world mod people would appreciate it if this (or a streamlined version of this) made its way in officially, and well... There's the framework for the code. Just make sure there's support for plenty of various world types ;)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Or rather instead of ObjectGrass, Objectsnow etc, you could just do Object1, Object2 and so on....
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

Of course, but that's really just getting down to being nitpicky. I just used words so I wouldn't confuse myself ;)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Well you could extend this so that model1 for world 1, and apply effects to maps with type 1 worlds etc
so value fo 2 would give snowy units and snow effects and snow background sounds, footsteps etc.
Gnomre
Imperial Winter Developer
Posts: 1754
Joined: 06 Feb 2005, 13:42

Post by Gnomre »

Ah, I get you. That sounds fair enough, as long as the numbers are documented. So, great and wonderful SYs, any chance of this making it into the game?
User avatar
GrOuNd_ZeRo
Posts: 1370
Joined: 30 Apr 2005, 01:10

Post by GrOuNd_ZeRo »

-thumbs up-

Great plan here Gnome! would be great for TA mods and OTA alike!
Post Reply

Return to “Engine”