Exemple #1
0
void SkeletalCreature::creatureAged() {
	// TODO: adjust position to account for any changes..

	processGenes();
	skeletonInit();
	recalculateSkeleton();
}
Exemple #2
0
void SkeletalCreature::setPose(unsigned int p) {
	posedirection = 0;
	for (int i = 0; i < SkeletalPartCount(); i++)
		pose[i] = p;
	recalculateSkeleton();
}
Exemple #3
0
void SkeletalCreature::setPose(std::string s) {
	switch (s[0]) {
		case '?':
			switch (direction) {
				case 0: break; // north, TODO
				case 1: break; // south, TODO
				case 2: posedirection = 0; break; // right
				case 3: posedirection = 1; break; // left
				default: assert(false);
			}
			break;
		case '!':
			switch (direction) {
				case 0: break; // north, TODO
				case 1: break; // south, TODO
				case 2: posedirection = 1; break; // right
				case 3: posedirection = 0; break; // left
				default: assert(false);
			}
			break;
		case '0': posedirection = 3; break;
		case '1': posedirection = 2; break;
		case '2': posedirection = 0; break;
		case '3': posedirection = 1; break;
		case 'X': break; // do nothing
		default: 
			std::cout << "internal warning: SkeletalCreature::setPose didn't understand direction " << s[0] << " in pose '" << s << "'." << std::endl;
			break;
	}

	for (int i = 0; i < 14; i++) {
		int newpose;

		switch (s[i + 1]) {
			case '0': newpose = 0 + (posedirection * 4); break;
			case '1': newpose = 1 + (posedirection * 4); break;
			case '2': newpose = 2 + (posedirection * 4); break;
			case '3': newpose = 3 + (posedirection * 4); break;
			case '?': assert(i == 0); {
					// make the head look in the posedirection of _IT_
					float attachmenty = attachmentY(1, 0) + y; // head attachment point, which we'll use to 'look' from atm
					
					// TODO: this is horrible, but i have no idea how the head angle is calculated
					AgentRef attention = creature->getAttentionFocus();
					if (attention && attention->y > (attachmenty + 30)) newpose = 0;
					else if (attention && attention->y < (attachmenty - 70)) newpose = 3;
					else if (attention && attention->y < (attachmenty - 30)) newpose = 2;
					else newpose = 1;
					newpose += (posedirection * 4);
				}
				break;
			// TODO: '!' also?
			case 'X': continue; // do nothing
			default:
				  std::cout << "internal warning: SkeletalCreature::setPose didn't understand " << s[i + 1] << " in pose '" << s << "'." << std::endl;
				  continue;
		}

		pose[cee_lookup[i]] = newpose;

		// TODO: this is some hackery for CV, 
		if (world.gametype != "cv") continue;
		if (i == 0) { // head
			pose[14] = newpose; pose[15] = newpose; // ears
			pose[16] = newpose; // hair
		} else if (i == 1) {
			pose[6] = newpose; // tail root
			pose[13] = newpose; // tail tip
		}
	}
		
	recalculateSkeleton();
}
Exemple #4
0
void SkeletalCreature::setPose(std::string s) {
	switch (s[0]) {
		case '?': // towards object of attention
			switch (direction) {
				case 0: posedirection = 3; break; // north, TODO
				case 1: posedirection = 2; break; // south, TODO
				case 2: posedirection = 0; break; // right
				case 3: posedirection = 1; break; // left
				default: assert(false);
			}
			break;
		case '!': // away from object of attention
			switch (direction) {
				case 0: posedirection = 2; break; // north, TODO
				case 1: posedirection = 3; break; // south, TODO
				case 2: posedirection = 1; break; // right
				case 3: posedirection = 0; break; // left
				default: assert(false);
			}
			break;
		case '0': posedirection = 3; break;
		case '1': posedirection = 2; break;
		case '2': posedirection = 0; break;
		case '3': posedirection = 1; break;
		case 'X': break; // do nothing
		default: 
			std::cout << "internal warning: SkeletalCreature::setPose didn't understand direction " << s[0] << " in pose '" << s << "'." << std::endl;
			break;
	}

	for (int i = 0; i < 14; i++) {
		int newpose = -1;

		switch (s[i + 1]) {
			case '0': newpose = 0; break;
			case '1': newpose = 1; break;
			case '2': newpose = 2; break;
			case '3': newpose = 3; break;
			case '4': newpose = (engine.version < 3) ? 8 : 10; break; // 'to camera'
			case '?': assert(i == 0); { // TODO
					// make the head look in the posedirection of _IT_
					float attachmenty = attachmentY(1, 0) + y; // head attachment point, which we'll use to 'look' from atm
					
					// TODO: this is horrible, but i have no idea how the head angle is calculated
					AgentRef attention = creature->getAttentionFocus();
					if (attention && attention->y > (attachmenty + 30)) newpose = 0;
					else if (attention && attention->y < (attachmenty - 70)) newpose = 3;
					else if (attention && attention->y < (attachmenty - 30)) newpose = 2;
					else newpose = 1;
				}
				break;
			// TODO: '!' also?
			case 'X': continue; // do nothing
			default:
				  std::cout << "internal warning: SkeletalCreature::setPose didn't understand " << s[i + 1] << " in pose '" << s << "'." << std::endl;
				  continue;
		}

		assert(newpose != -1);

		if (newpose < 4) {
			// newpose gives the angle, now we need to add the offset for left/right/forward/back.

			if (engine.version < 3 && posedirection > 1)
				newpose = 6 + posedirection; // only one forward/back pose in c1/c2
			else
				newpose += (posedirection * 4);
		}

		pose[cee_lookup[i]] = newpose;

		// TODO: this is some hackery for CV, 
		if (world.gametype != "cv") continue;
		if (i == 0) { // head
			pose[14] = newpose; pose[15] = newpose; // ears
			pose[16] = newpose; // hair
		} else if (i == 1) {
			pose[6] = newpose; // tail root
			pose[13] = newpose; // tail tip
		}
	}
		
	recalculateSkeleton();
}