#define _USE_MATH_DEFINES // for M_PI
#include <math.h>
#include "primitives.h"
#include "textures.h"
#include "xmlwriter.h"
#include <sstream>
#include <fstream>
#include <iostream>
const unsigned int SPHERES = 3;
const float SPHERE_RADIUS = 3.0f;
int main(char argc, char** argv) {
try {
#if defined(WIN32)
#else
#endif
std::string sphereMatName = "SphereMaterial";
std::string boxMatName = "boxMaterial";
ILBMeshHandle sphereMesh = bex::createSphere(bmh,
"Sphere", sphereMatName, 32, 32);
ILBMeshHandle cornellMesh = bex::createCornellBox(bmh,
"Cornell", boxMatName);
bex::Matrix4x4 cornellTrans = bex::scaleTranslation(bex::Vec3(10.0f, 10.0f, 10.0f),
bex::Vec3(0.0f, 0.0f, 0.0f));
bex::apiCall(
ILBCreateInstance(scene, cornellMesh,
"CornellInstance", &cornellTrans, &cornellInstance));
bex::Vec3 pos = bex::Vec3(0.0f, 9.0f, 0.0f);
bex::Vec3 lookAt(0.0f, 0.0f, 0.0f);
bex::Matrix4x4 matrix = bex::setAreaLightMatrix(pos,
lookAt - pos,
bex::Vec3(1.0f, 0.0f, 0.0f),
bex::Vec2(2.0f, 2.0f));
_T("Light"),
&matrix,
&bex::ColorRGB(1.0f, 1.0f, 1.0f),
&light));
const float spherePosRadius = 10.0f - 2.0f*SPHERE_RADIUS;
for(int i = 0; i < SPHERES; ++i) {
float x = (bex::frand() - 0.5f) * spherePosRadius * 2.0f;
float z = (bex::frand() - 0.5f) * spherePosRadius * 2.0f;
bex::Matrix4x4 trans = bex::scaleTranslation(bex::Vec3(SPHERE_RADIUS, SPHERE_RADIUS, SPHERE_RADIUS),
bex::Vec3(x, SPHERE_RADIUS-10.0f, z));
std::stringstream sphereName;
sphereName << "SphereInstance_" << i;
bex::apiCall(
ILBCreateInstance(scene, sphereMesh, sphereName.str().c_str(), &trans, &tempInstance));
}
bex::Vec3 camPos(0.0f, 0.0f, -20.0f);
bex::Vec3 camLookAt(0.0f, -3.0f, 0.0f);
_T("Camera"),
&bex::setCameraMatrix(camPos, camLookAt-camPos, bex::Vec3(0.0f, 1.0f, 0.0f)),
&camera));
std::string xmlFileName = "../../data/lua.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", 0);
xml.data("maxSampleRate", 2);
}
{ScopedTag _x(xml, "RenderSettings");
xml.data("bias", 0.00001f);
}
}
}
bex::apiCall(
ILBCreateJob(bmh, _T(
"TestJob"), scene, xmlFileName.c_str(), &job));
bex::apiCall(
ILBCreateLuaPass(job, _T(
"LUA"),
"../../data/rnm_3.lua", &luaPass));
bex::apiCall(
ILBCreateLuaPass(job, _T(
"LUA2"),
"../../data/rnm_3.lua", &luaPass));
return 1;
}
int32 channelCount;
std::cout << "Channel count: " << channelCount << std::endl;
for (int i = 0; i < channelCount; i++) {
std::cout << i << ": " << bex::convertStringHandle(sth) << std::endl;
}
return 0;
} catch(bex::Exception& ex) {
std::cout << "Beast API error" << std::endl;
std::cout << "Error: " << bex::convertStringHandle(errorString) << std::endl;
std::cout << "Info: " << bex::convertStringHandle(extendedError) << std::endl;
return 1;
} catch(std::exception& ex) {
std::cout << "Standard exception" << std::endl;
std::cout << "Error: " << ex.what() << std::endl;;
return 1;
}
}