#ifndef SAMPLESCOMMON_H
#define SAMPLESCOMMON_H
#include "vecmath.h"
#include "utils.h"
#include "primitives.h"
#include "textures.h"
#include <map>
namespace bex {
typedef std::map<tstring, ILBInstanceHandle> InstanceMap;
#if defined(WIN32)
#else
#endif
tstringstream ss;
ss << _T("../../../temp/") << testName;
return bmh;
}
tstring defaultMaterialName(_T("DefaultMaterial"));
bex::apiCall(
ILBCreateShader(bmh, _T(
"DefaultShader"),
"../../data/default.osl", &defaultShader));
tstringstream dummyStream;
if (!findCachedMesh(bmh, _T("Sphere"), sphereMesh, dummyStream)) {
sphereMesh = bex::createSphere(bmh, _T("Sphere"), defaultMaterialName, 50, 30);
}
if (!findCachedMesh(bmh, _T("Floor"), floorMesh, dummyStream)) {
floorMesh = bex::createPlane(bmh, _T("Floor"), defaultMaterialName);
}
const int numSpheres = 7;
const float sphereRad = 2.0f;
const float sphereDist = 5.0f;
const float sphereLineWidth = (numSpheres-1)*sphereDist+sphereRad*2.0f;
bex::Matrix4x4 floorTrans = bex::scaleTranslation(bex::Vec3(sphereLineWidth/2.0f+5.0f, 1.0f, 8.0f),
bex::Vec3(0.0f, -5.0f, 0.0f));
bex::apiCall(
ILBCreateInstance(scene, floorMesh, _T(
"FloorInstance"), &floorTrans, &floorInstance));
createdInstances[_T("FloorInstance")] = floorInstance;
std::vector<ILBInstanceHandle> sphereInstances;
for(int gx = 0; gx < numSpheres; ++gx) {
const float x = -sphereLineWidth/2.0f + gx * sphereDist + sphereRad;
bex::Matrix4x4 trans = bex::scaleTranslation(bex::Vec3(sphereRad, sphereRad, sphereRad),
bex::Vec3(x, -3.0f, 0.0f));
tstringstream sphereName;
sphereName << _T("SphereInstance_") << gx;
bex::apiCall(
ILBCreateInstance(scene, sphereMesh, sphereName.str().c_str(), &trans, &tempInstance));
sphereInstances.push_back(tempInstance);
createdInstances[sphereName.str()] = tempInstance;
}
_T("Sun"),
&bex::directionalLightOrientation(bex::Vec3(1.0, -1.0f, -1.0f)),
&bex::ColorRGB(0.9f, 0.9f, .7f),
&light));
_T("SkyLight"),
&bex::identity(),
&bex::ColorRGB(0.21f, 0.21f, 0.3f),
&skyLight));
bex::apiCall(
ILBCreateShader(bmh, _T(
"EmissiveShader"),
"../../data/emissive.osl", &emissiveShader));
bex::apiCall(
ILBCreateShader(bmh, _T(
"PhongishShader"),
"../../data/phongish.osl", &phongishShader));
bex::apiCall(
ILBCreateShader(bmh, _T(
"MirrorShader"),
"../../data/mirror.osl", &mirrorShader));
bex::apiCall(
ILBCreateShader(bmh, _T(
"SlickShader"),
"../../data/slick.osl", &slickShader));
ILBTextureHandle xorTexture = bex::createXorTexture(bmh, _T(
"Tex1"), bex::ColorRGB(1.0f, 1.0f, 1.0f));
}
bex::Vec3 camPos(0.0f, 5.0f, 48.0f);
bex::Vec3 lookAt(0.0f, -3.0f, 0.0f);
_T("Camera"),
&bex::setCameraMatrix(camPos,
normalize(lookAt - camPos),
bex::Vec3(0.0f, 0.0f, -1.0f)),
&camera));
bex::apiCall(
ILBSetFov(camera, static_cast<float>(M_PI) / 4.0f, 1.0f));
return camera;
}
}
#endif // SAMPLESCOMMON_H