#include <assert.h>
#include "utils.h"
#include "primitives.h"
#ifdef UNICODE
#define tcout std::wcout
#else
#define tcout std::cout
#endif
typedef std::vector<ILBMeshHandle> MeshHandleVector;
class UnwrapMeshJob {
protected:
typedef std::pair<ILBTargetHandle, ILBTargetEntityHandle> UnwrappingHandle;
public:
UnwrapMeshJob(
ILBManagerHandle manager,
const std::wstring& jobName,
const MeshHandleVector& meshes) :
m_sourceMeshes(meshes)
{
const float texelsPerWorldUnit = 5.0f;
std::stringstream str;
str << "unwrapTarget" << 0;
const bex::tstring targetName = bex::string2tstring(str.str());
for (unsigned int i = 0; i < m_sourceMeshes.size(); i++) {
m_unwrappingHandles.push_back(UnwrappingHandle(unwrappingTarget, unwrappingEntity));
}
}
bool run() {
ILBBool isCompleted =
false, isRunning =
true;
while (isRunning) {
if (!isCompleted) {
if (isCompleted) {
tcout << "Job is completed. It might still be running if the user has selected ILB_SR_KEEP_OPEN." << std::endl;
}
}
if (isRunning) {
if (newProgress) {
int32 progress;
if (newActivity) {
std::basic_string<TCHAR> jobNameString = bex::convertStringHandle(taskName);
tcout << jobNameString << std::endl;
}
tcout << "Progress " << progress << "%" << std::endl;
tcout.flush();
}
}
}
switch(status) {
tcout << "User canceled rendering" << std::endl;
break;
tcout << "Problem with the Beast License!" << std::endl;
break;
tcout << "Error parsing Beast command line!" << std::endl;
break;
tcout << "Error parsing Beast config files!" << std::endl;
break;
tcout << "Error: Beast crashed!" << std::endl;
break;
tcout << "Other error running Beast." << std::endl;
break;
}
return false;
}
reportResult();
return true;
}
private:
void reportResult() {
for (size_t i = 0; i < m_unwrappingHandles.size(); i++) {
int32 uvLayerSize, uvLayerIndexSize;
int32 j;
for (j = 0; j < uvLayerSize; ++j) {
tcout << L
"UV value " << j << L
" = (" << uv.
x << L
", " << uv.
y << L
")" << std::endl;
}
for (j = 0; j < uvLayerIndexSize; ++j) {
int32 uvIndex = 0;
tcout << L"UV index value " << j << L" = " << uvIndex << std::endl;
}
int32 width = 0;
int32 height = 0;
tcout << L"Size of packed UV layout = " << width << L" " << height << std::endl;
}
}
private:
MeshHandleVector m_sourceMeshes;
std::vector<UnwrappingHandle> m_unwrappingHandles;
};
int main(char argc, char** argv) {
try {
#if defined(WIN32)
#else
#endif
std::basic_string<TCHAR> sphereMaterialName(_T("SphereMaterial"));
std::basic_string<TCHAR> boxMaterialName(_T("FloorMaterial"));
ILBMeshHandle sphereMesh = bex::createSphere(beastManagerHandle, _T(
"Sphere"), sphereMaterialName, 30, 15);
ILBMeshHandle boxMesh0 = bex::createCornellBox(beastManagerHandle, _T(
"Box0"), boxMaterialName);
ILBMeshHandle boxMesh1 = bex::createCornellBox(beastManagerHandle, _T(
"Box1"), boxMaterialName);
MeshHandleVector meshes;
meshes.push_back(sphereMesh);
meshes.push_back(boxMesh0);
meshes.push_back(boxMesh1);
UnwrapMeshJob job(beastManagerHandle, _T("UnwrapJob"), meshes);
if (!job.run()) {
return 1;
}
return 0;
} catch(bex::Exception& ex) {
tcout << L"Beast API error" << std::endl;
tcout << L"Error: " << bex::convertStringHandle(errorString) << std::endl;
tcout << L"Info: " << bex::convertStringHandle(extendedError) << std::endl;
throw;
return 1;
} catch(std::exception& ex) {
tcout << L"Standard exception" << std::endl;
tcout << L"Error: " << ex.what() << std::endl;;
throw;
return 1;
}
}