#define _USE_MATH_DEFINES // for M_PI
#include <cmath>
#include <iostream>
#include <sstream>
#include <sstream>
#include <fstream>
#include <iostream>
#include "vecmath.h"
#include "utils.h"
#include "primitives.h"
#include "textures.h"
#include "xmlwriter.h"
#ifdef UNICODE
#define tcout std::wcout
#else
#define tcout std::cout
#endif
int _tmain(int argc, _TCHAR* argv[])
{
try {
#if defined(WIN32)
#else
#endif
std::basic_string<TCHAR> floorMatName(_T("FloorMaterial"));
ILBMeshHandle floorMesh = bex::createPlaneMultiUV(bmh, _T(
"Floor"), floorMatName);
bex::Matrix4x4 floorTrans = bex::scaleTranslation(bex::Vec3(10.0f, 1.0f, 10.0f),
bex::Vec3(0.0f, -5.0f, 0.0f));
bex::apiCall(
ILBCreateInstance(scene, floorMesh, _T(
"FloorInstance"), &floorTrans, &floorInstance));
ILBTextureHandle floorTex = bex::createTestColorTexture(bmh, _T(
"TestColorTexture"));
bex::Vec3 pos(0.0, 1.0f, 0.0f);
bex::Vec3 lookAt(0.0f, 0.0f, 0.0f);
bex::Matrix4x4 spotMatrix = bex::setSpotlightMatrix(pos, lookAt - pos);
_T("Light"),
&spotMatrix,
&bex::ColorRGB(1.0f, 1.0f, 1.0f),
&light));
_T("Camera"),
&bex::setCameraMatrix(bex::Vec3(.3f, 3.0f, 20.0f),
bex::Vec3(.1f, -0.3f, -1.0f),
bex::Vec3(0.0f, 1.0f, 0.0f)),
&camera));
bex::apiCall(
ILBSetFov(camera, static_cast<float>(M_PI) / 4.0f, 1.0f));
std::string xmlFileName = "../../data/uvset.xml";
{
using namespace bex;
std::ofstream ofs(xmlFileName.c_str(), std::ios_base::out | std::ios_base::trunc);
XMLWriter xml(ofs);
{ScopedTag _x(xml, "ILConfig");
{ScopedTag _x(xml, "AASettings");
xml.data("minSampleRate", -1);
xml.data("maxSampleRate", 1);
}
}
}
bex::apiCall(
ILBCreateJob(bmh, _T(
"UVSetJob"), scene, xmlFileName.c_str(), &job));
if(!bex::renderJob(job, tcout)) {
return 1;
}
return 0;
} catch(bex::Exception& ex) {
tcout << "Beast API error" << std::endl;
tcout << "Error: " << bex::convertStringHandle(errorString) << std::endl;
tcout << "Info: " << bex::convertStringHandle(extendedError) << std::endl;
return 1;
} catch(std::exception& ex) {
tcout << "Standard exception" << std::endl;
tcout << "Error: " << ex.what() << std::endl;;
return 1;
}
}