示例#1
0
void FaceParts::PickFaceParts(FaceDescriptor &inout_face, const Uint32 seed)
{
	Random rand(seed);

	_pick(rand, inout_face.species, NumSpecies());
	_pick(rand, inout_face.race, NumRaces(inout_face.species));
	_pick(rand, inout_face.gender, NumGenders(inout_face.species));

	const Uint32 selector = _make_selector(inout_face.species, inout_face.race, inout_face.gender);

	_pick(rand, inout_face.head, _count_parts(s_partdb->heads, selector));
	_pick(rand, inout_face.eyes, _count_parts(s_partdb->eyes, selector));
	_pick(rand, inout_face.nose, _count_parts(s_partdb->noses, selector));
	_pick(rand, inout_face.mouth, _count_parts(s_partdb->mouths, selector));
	_pick(rand, inout_face.hairstyle, _count_parts(s_partdb->hairstyles, selector));

	const bool has_accessories = (rand.Int32() & 1);
	_pick(rand, inout_face.accessories, _count_parts(s_partdb->accessories, selector));
	if (!has_accessories) {
		inout_face.accessories = 0;
	}

	_pick(rand, inout_face.clothes, _count_parts(s_partdb->clothes, selector));
	_pick(rand, inout_face.armour, _count_parts(s_partdb->armour, selector));
}
示例#2
0
//static
void FaceGenManager::BlitFaceIm(SDLSurfacePtr &faceim, Sint8 &genderOut, const Uint32 flags, const Uint32 seed)
{
	Random rand(seed);

	const int species = (m_species.size()==1) ? 0 : rand.Int32(0,m_species.size()-1);
	const int race = rand.Int32(0,NumRaces(species)-1);

	int gender;
	switch (flags & GENDER_MASK) {
		case GENDER_MALE:
			gender = 0;
			break;
		case GENDER_FEMALE:
			gender = 1;
			break;
		case GENDER_RAND:
		default:
			gender = rand.Int32(0,NumGenders(species)-1);
			break;
	}
	genderOut = gender;

	const int head  = rand.Int32(0,NumHeads(species,race)-1);
	const int eyes  = rand.Int32(0,NumEyes(species,race)-1);
	const int nose  = rand.Int32(0,NumNoses(species,race)-1);
	const int mouth = rand.Int32(0,NumMouths(species,race)-1);
	const int hair  = rand.Int32(0,NumHairstyles(species,race)-1);

	const int clothes     = rand.Int32(0,NumClothes(species)-1);
	const int armour      = rand.Int32(0,NumArmour(species)-1);
	const int accessories = rand.Int32(0,NumAccessories(species)-1);
	const int background  = rand.Int32(0,NumBackground(species)-1);

	FaceGenManager::TQueryResult res;
	FaceGenManager::GetImagesForCharacter(res, species, race, gender, head, eyes,
		nose, mouth, hair, clothes, armour, accessories, background);

	_blit_image(faceim, res.mBackground, 0, 0);
	_blit_image(faceim, res.mHead, 0, 0);

	if (!(flags & ARMOUR)) {
		_blit_image(faceim, res.mClothes, 0, 135);
	}

	_blit_image(faceim, res.mEyes, 0, 41);
	_blit_image(faceim, res.mNose, 1, 89);
	_blit_image(faceim, res.mMouth, 0, 155);

	if (!(flags & ARMOUR)) {
		if (rand.Int32(0,1)>0)
			_blit_image(faceim, res.mAccessories, 0, 0);

		_blit_image(faceim, res.mHairstyle, 0, 0);
	}
	else {
		_blit_image(faceim, res.mArmour, 0, 0);
	}
}