6 #include "../render/renderer.h"     7 #include "../scene/node.h"     9 #include "interaction.h"    11 #include "transformer.h"    12 #include "workspace.h"    16 TrackBase::TrackBase() {}
    18 float srgbGamma2Linear(
float srgb) {
    19   if (srgb < 0.04045f) {
    20     return srgb * (25.0f / 232.0f);
    22     return std::pow((200.0 * srgb + 11.0f) * (1.0f / 211.0f), 12.0 / 5.0);
    26 std::vector<std::string> WorldDisplay::_listFrames(
const Property &) {
    27   auto ret = 
LockScope()->document()->display()->transformer->list();
    28   std::sort(ret.begin(), ret.end());
    32 bool Display::interact(
    38 static Eigen::Vector3f srgb2Linear(
const Eigen::Vector3f &srgb) {
    39   return Eigen::Vector3f(srgbGamma2Linear(srgb.x()), srgbGamma2Linear(srgb.y()),
    40                          srgbGamma2Linear(srgb.z()));
    43 Eigen::Vector4f Color4::toLinearVector4f()
 const {
    46       srgb2Linear(Eigen::Vector3f((
float)r(), (
float)g(), (
float)b()));
    51 WorldDisplay::WorldDisplay() {
    52   transformer = std::make_shared<Transformer>();
    57   transformer->update(fixedFrame());
    58   DisplayGroupBase::renderSync(context);
    62         backgroundColor().toLinearVector4f().head(3) * (float)ambientLighting();
    63     light.type = (uint32_t)LightType::Ambient;
    64     context.render_list->push(light);
    98   DisplayGroupBase::renderAsync(context);
   106   for (
auto &display : displays()) {
   107     display->renderSyncRecursive(context);
   111 Eigen::Isometry3d Orientation::toIsometry3d()
 const {
   112   return Eigen::Translation3d(0, 0, 0) *
   113          Eigen::AngleAxisd(yaw() * (M_PI / 180.0), Eigen::Vector3d::UnitZ()) *
   114          Eigen::AngleAxisd(pitch() * (M_PI / 180.0), Eigen::Vector3d::UnitY()) *
   115          Eigen::AngleAxisd(roll() * (M_PI / 180.0), Eigen::Vector3d::UnitX());
   118 Eigen::Isometry3d Pose::toIsometry3d()
 const {
   119   return Eigen::Translation3d(position()) *
   120          Eigen::AngleAxisd(orientation().yaw() * (M_PI / 180.0),
   121                            Eigen::Vector3d::UnitZ()) *
   122          Eigen::AngleAxisd(orientation().pitch() * (M_PI / 180.0),
   123                            Eigen::Vector3d::UnitY()) *
   124          Eigen::AngleAxisd(orientation().roll() * (M_PI / 180.0),
   125                            Eigen::Vector3d::UnitX());
   128 void Pose::fromIsometry3d(
const Eigen::Isometry3d &pose) {
   129   position() = pose.translation();
   130   Eigen::Vector3d angles = pose.linear().eulerAngles(2, 1, 0);
   131   orientation().yaw() = angles.x() * (180.0 / M_PI);
   132   orientation().pitch() = angles.y() * (180.0 / M_PI);
   133   orientation().roll() = angles.z() * (180.0 / M_PI);
   136 void Display::refreshRecursive() { refresh(); }
   138 void Display::refresh() {}
   140 void DisplayGroupBase::refreshRecursive() {
   141   for (
auto &display : displays()) {
   142     display->refreshRecursive();