// Reads an AMC file in each bone's frames array
void Skeleton::readAMC(FILE* amcFile) {
	clearChanges();

	char buffer[100];
	for (int i = 0; i < 3; i++) {
		fgets(buffer, 100, amcFile);}


	// Initialise variables
	char name[20] = {0};
	float rx = 0;
	float ry = 0;
	float rz = 0;
	float tx = 0;
	float ty = 0;
	float tz = 0;

	int count = 0;

	printf("Loading AMC File... \n");
	while (fgets(buffer, 100, amcFile)) {

		sscanf(buffer, "%s %f %f %f\n", name, &rx, &ry, &rz);
		// Use this scan format if scanning a root.
		if (strcmp(name, "root")== 0)
			sscanf(buffer, "%s %f %f %f %f %f %f\n", name, &tx, &ty, &tz, &rx, &ry, &rz);

		// Check if new frame is starting
		if (isdigit(name[0])) {
			count++;
			continue;
		}

		bone* b = getBoneFromName(name);

		// Store new frame
		b->frames[count-1].rx = rx;
		b->frames[count-1].ry = ry;
		b->frames[count-1].rz = rz;

		b->frames[count-1].tx = tx;
		b->frames[count-1].ty = ty;
		b->frames[count-1].tz = tz;

		// Reset varaibles
		memset(&name[0], 0, sizeof(name));
		rx = 0;
		ry = 0;
		rz = 0;
		tx = 0;
		ty = 0;
		tz = 0;
	}

	numOfFrames = count;
}
Exemplo n.º 2
0
void collision_detection::WorldDiff::reset()
{
  clearChanges();

  WorldPtr old_world = world_.lock();
  if (old_world)
    old_world->removeObserver(observer_handle_);

  world_.reset();
}
Exemplo n.º 3
0
void collision_detection::WorldDiff::reset(const WorldPtr& world)
{
  clearChanges();

  WorldPtr old_world = world_.lock();
  if (old_world)
    old_world->removeObserver(observer_handle_);

  boost::weak_ptr<World>(world).swap(world_);
  observer_handle_ = world->addObserver(boost::bind(&WorldDiff::notify, this, _1, _2));
}