bool C4DefGraphics::LoadSkeleton(C4Group &hGroup, const char* szFileName, StdMeshSkeletonLoader& loader)
{
	char* buf = NULL;
	size_t size;

	try
	{
		if (!hGroup.LoadEntry(szFileName, &buf, &size, 1)) return false;

		// delete skeleton from the map for reloading, or else if you delete or rename
		// a skeleton file in the folder the old skeleton will still exist in the map
		loader.RemoveSkeleton(hGroup.GetName(), szFileName);

		if (SEqualNoCase(GetExtension(szFileName), "xml"))
		{
			loader.LoadSkeletonXml(hGroup.GetName(), szFileName, buf, size);
		}
		else
		{
			loader.LoadSkeletonBinary(hGroup.GetName(), szFileName, buf, size);
		}

		delete[] buf;
	}
	catch (const std::runtime_error& ex)
	{
		DebugLogF("Failed to load skeleton in definition %s: %s", hGroup.GetName(), ex.what());
		delete[] buf;
		return false;
	}

	return true;
}
Example #2
0
bool C4DefGraphics::LoadSkeleton(C4Group &hGroup, const char* szFileName, StdMeshSkeletonLoader& loader)
{
	char* buf = NULL;
	size_t size;

	try
	{
		if (!hGroup.LoadEntry(szFileName, &buf, &size, 1)) return false;

		StdCopyStrBuf filename = StdCopyStrBuf();
		StdMeshSkeletonLoader::MakeFullSkeletonPath(filename, hGroup.GetName(), szFileName);

		if (SEqualNoCase(GetExtension(szFileName), "xml"))
		{
			loader.LoadSkeletonXml(filename, buf, size);
		}
		else
		{
			loader.LoadSkeletonBinary(filename, buf, size);
		}

		delete[] buf;
	}
	catch (const std::runtime_error& ex)
	{
		DebugLogF("Failed to load skeleton in definition %s: %s", hGroup.GetName(), ex.what());
		delete[] buf;
		return false;
	}

	return true;
}
Example #3
0
StdMeshAnimationUpdate::StdMeshAnimationUpdate(const StdMeshSkeletonLoader& skeleton_loader)
{
	// Store all animation names of all skeletons by pointer, we need those when
	// updating the animation state of mesh instances after the update.
	for(StdMeshSkeletonLoader::skeleton_iterator iter = skeleton_loader.skeletons_begin(); iter != skeleton_loader.skeletons_end(); ++iter)
	{
		const StdMeshSkeleton& skeleton = *iter->second;
		for (const auto & Animation : skeleton.Animations)
		{
			AnimationNames[&Animation.second] = Animation.first;
		}
	}
}