Setting up a UV unwrap job

Setting up a UV unwrap job is similar to setting up a Beast bake job. A new job is created, a target for the job is created, and target entities are added to the target. In the case of a UV unwrap job, the target entities are the meshes that will be unwrapped.

Coordinate systems

Your meshes can be expressed in global space or in object space, in your choice of coordinate systems, with your choice of units. The Beast API does not enforce any particular requirements. It is up to you to determine which system you want to use, and to take care of performing any transformations yourself for the mesh or for the configuration parameters you provide (such as the texelPerUnit setting).

To set up a UV unwrap job

  1. Create a new job with a call to ILBCreateUVJob().
  2. Create UV unwrap targets using ILBCreateUVUnwrapTarget(). The texelPerUnit setting in this function is used to set the number of texels used per unit when baking the mesh (see Adjusting Chart Packing).
  3. Add the meshes that will be unwrapped to this target using the ILBAddMeshToTarget() function.
  4. Run the job—the same way as a regular baking job—by calling ILBStartJob(), and using job functions to retrieve job status and progress information; see Monitoring Jobs and Retrieving Updates.

Distribution is not currently supported for unwrapping jobs. The distribution flag in ILBStartJob() is ignored (for unwrapping jobs), and the job is only executed locally. Calculations are multi-threaded on a mesh-by-mesh basis; if multiple meshes are added to an unwrap target, the unwrapping will be run in parallel on multiple cores.

Code Example

ILBMeshHandle mesh = createMyMesh();

ILBJobHandle unwrapJob();
ILBCreateUVJob(beastManager, _T("MyUnwrapJob"), &unwrapJob);

const float texelsPerUnit = 5.0f;

ILBTargetHandle unwrapTarget;
ILBCreateUVUnwrapTarget(unwrapJob, _T("MyUnwrapTarget"), texelsPerUnit, &unwrapTarget);

ILBTargetEntityHandle unwrapEntity;
ILBAddMeshToTarget(unwrapTarget, mesh, &unwrapEntity);

ILBStartJob(unwrapJob, ILB_SR_CLOSE_WHEN_DONE, ILB_RD_AUTODETECT);

ILBBool isRunning = true;
while (isRunning) {
	ILBWaitJobDone(unwrapJob, 0xffffffff);
	ILBIsJobRunning(unwrapJob, &isRunning);

	if (isRunning) {
		ILBBool newProgress, newActivity;
		ILBJobHasNewProgress(unwrapJob, &newActivity, &newProgress);
		if (newProgress) {
			ILBStringHandle taskName;
			int32 progress;
			ILBGetJobProgress(unwrapJob, &taskName, &progress);
			if (newActivity) {
				cout << taskName << endl;
			}
			cout << "Progress " << progress << "%" << endl;
		}
	}
}