#include "primitives.h"
#include "textures.h"
#include "xmlwriter.h"
#include <sstream>
#include <fstream>
#include <iostream>
#define _USE_MATH_DEFINES // for M_PI
#include <math.h>
const unsigned int SPHERES = 50;
const float SPHERE_RADIUS = 1.0f;
int main(char argc, char** argv) {
try {
#if defined(WIN32)
#else
#endif
std::string sphereMatName = "SphereMaterial";
std::string floorMatName = "FloorMaterial";
ILBMeshHandle sphereMesh = bex::createSphere(bmh,
"Sphere", sphereMatName, 32, 32);
ILBMeshHandle floorMesh = bex::createPlane(bmh,
"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,
"FloorInstance", &floorTrans, &floorInstance));
"Sun",
&bex::directionalLightOrientation(bex::Vec3(1.0, -1.0f, -1.0f)),
&bex::ColorRGB(1.0f, 1.0f, .8f),
&light));
"SkyLight",
&bex::identity(),
&bex::ColorRGB(1.0f, 0.0f, 0.0f),
&skyLight));
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-5.0f, z));
std::stringstream sphereName;
sphereName << "SphereInstance_" << i;
bex::apiCall(
ILBCreateInstance(scene, sphereMesh, sphereName.str().c_str(), &trans, &tempInstance));
}
std::string xmlFileName = "../../data/baking.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);
}
{ScopedTag _x(xml, "GISettings");
xml.data("enableGI", true);
xml.data("fgRays", 1000);
xml.data("fgContrastThreshold", 0.1);
xml.data("fgInterpolationPoints", 15);
xml.data("primaryIntegrator", "FinalGather");
xml.data("secondaryIntegrator", "None");
}
}
}
bex::apiCall(
ILBCreateJob(bmh, _T(
"TestJob"), scene, xmlFileName.c_str(), &job));
if(!bex::renderJob(job, std::cout)) {
return 1;
}
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;
}
}