Ejemplo n.º 1
0
Symbol *
ShadingContext::symbol (ShaderUse use, ustring name)
{
    ShaderGroup &sgroup (*attribs());
    int nlayers = sgroup.nlayers ();
    if (sgroup.llvm_compiled_version()) {
        for (int layer = nlayers-1;  layer >= 0;  --layer) {
            int symidx = sgroup[layer]->findsymbol (name);
            if (symidx >= 0)
                return sgroup[layer]->symbol (symidx);
        }
    }
    return NULL;
}
Ejemplo n.º 2
0
/*
 * Format:
 * `METHOD {signature} {return type}` (all freestanding methods)
 * \BLANK\
 * `CLASS {name} {size in bytes}`
 *   `MEMBER {name} {typeName} {offset in bytes}`
 *   `METHOD {signature} {return type}` (actual methods)
 * (a `CLASS` starts a new class)
 *
 * NOTE: Everything's going to be Access::PUBLIC automatically, because this is an API
 */
void LibGenerator::AddFromFile(const std::string& path)
{
  std::cout << "Adding library: " << path << std::endl;
  std::vector<std::string> lines = Util::Split(Util::LoadFile(path), '\n');
  bool isInClass = false;
  ClassDef* currentClass;

  for (auto& line : lines)
  {
    if (line.empty())
      continue;

    auto lineSplit = Util::Split(line, ' ');

    if (lineSplit[0] == "CLASS")
    {
      currentClass = new ClassDef(lineSplit[1], Attribs(), true);
      currentClass->typeSize = std::atoi(lineSplit[2].c_str());
      m_parse.classes.push_back(currentClass);
    }
    else if (lineSplit[0] == "MEMBER")
    {
      VariableDef* varDef = new VariableDef(lineSplit[1], lineSplit[2], Attribs(), false);
      varDef->offset = std::atoi(lineSplit[3].c_str());
      currentClass->memberVars.push_back(varDef);
    }
    else if (lineSplit[0] == "METHOD")
    {
      // TODO
      std::vector<VariableDef*> params;
      std::vector<VariableDef*> locals;
   
      Attribs attribs(Attribs::Access::PUBLIC, false, false); 
      MethodDef* method = new MethodDef(lineSplit[1], attribs, params, locals, lineSplit[2], nullptr, true);

      if (isInClass)
        currentClass->methods.push_back(method);
      else
        m_parse.methods.push_back(method);
    }
    else
    {
      std::cerr << "WARNING: Malformed library file (" << path << ") - skipping this library!" << std::endl;
      return;
    }
  }
}
void Outlined_object_renderer::render( const std::shared_ptr<Visible_object>& object )
{
    // make sure the models have been created and exist in
    // the data maps
    auto iter = m_object_data_map.find( object );
    if (iter == m_object_data_map.end()){
        m_object_data_map[object] = 0;
        m_flat_model_map[object] = 0;
        construct_model(object);
        iter = m_object_data_map.find( object );
    }
    if (!m_context_store->call_list_exists( iter->second )) {
        construct_model(object);
    }

    // retrieve the models from the ContextStore
    unsigned int gl_handle		= m_context_store->get_call_list( iter->second );
    unsigned int gl_flat_handle	= m_context_store->get_call_list( m_flat_model_map[object] ); 

    // move the GL Context to the correct position and rotation
    Open_gl_matrix gl_matrix;
    Open_gl_commands::translate( Math::to_vector(object->coordinate_space().position()) );
    float m[16];
    object->coordinate_space().get_matrix( m );
    Open_gl_commands::mult_matrix( m );

    // draw the actual object
    Open_gl_attributes attribs( Open_gl_attributes::ENABLE_BIT | Open_gl_attributes::HINT_BIT | Open_gl_attributes::POLYGON_BIT, false );
    attribs.enable( Open_gl_attributes::LINE_SMOOTH );
    attribs.enable( Open_gl_attributes::CULL_FACE );
    Open_gl_commands::cull_face( GL_BACK );		
    Open_gl_commands::polygon_mode( GL_BACK, GL_FILL ); 
    attribs.enable( Open_gl_attributes::BLEND );
    Open_gl_commands::call_list( gl_handle );	

    // draw the outline
    Open_gl_commands::line_width( 4 );
    Open_gl_commands::polygon_mode( GL_BACK, GL_LINE );
    Open_gl_commands::cull_face( GL_FRONT );
    attribs.depth_func( GL_LEQUAL );
    Open_gl_commands::call_list( gl_flat_handle );	

    // reset some of the quirky settings
    // failure to do this results in weirdness
    Open_gl_commands::polygon_mode( GL_BACK, GL_FILL );
}
PUBLIC
bool
Vm_vmx_ept::v_lookup(Mem_space::Vaddr virt, Mem_space::Phys_addr *phys,
                     Mem_space::Page_order *order, Mem_space::Attr *page_attribs)
{
  auto i = _ept->walk(virt);
  if (order) *order = Mem_space::Page_order(i.page_order());

  if (!i.is_valid())
    return false;

  // FIXME: we may get a problem on 32 bit systems and using more than 4G ram
  if (phys) *phys = Mem_space::Phys_addr(i.page_addr());
  if (page_attribs) *page_attribs = i.attribs();

  return true;
}
Ejemplo n.º 5
0
PixelSampler* XMLReader::LoadPixelSampler(QXmlStreamReader &xml_reader)
{
    PixelSampler* result;
    //First check what type of pixel sampler we're supposed to load
    QXmlStreamAttributes attribs(xml_reader.attributes());
    QStringRef type = attribs.value(QString(), QString("type"));
    if(QStringRef::compare(type, QString("uniform")) == 0)
    {
        result = new UniformPixelSampler();
    }
    else if(QStringRef::compare(type, QString("stratified")) == 0)
    {
        result = new StratifiedPixelSampler();
    }
    else if(QStringRef::compare(type, QString("random")) == 0)
    {
        result = new RandomPixelSampler();
    }
    else if(QStringRef::compare(type, QString("bestcandidate")) == 0)
    {
        result = new BestCandidateSampler();
    }
    else
    {
        std::cout << "Could not parse the pixel sampler!" << std::endl;
        return NULL;
    }

    while(!xml_reader.isEndElement() || QStringRef::compare(xml_reader.name(), QString("pixelSampler")) != 0)
    {
        xml_reader.readNext();

        QString tag(xml_reader.name().toString());
        if(QString::compare(tag, QString("samples")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                result->SetSampleCount(xml_reader.text().toInt());
            }
            xml_reader.readNext();
        }
    }
    return result;
}
Ejemplo n.º 6
0
static EGLConfig
ChooseConfig(GLContext* gl,
             GLLibraryEGL* egl,
             const SurfaceCaps& caps)
{
    MOZ_ASSERT(egl);
    MOZ_ASSERT(caps.color);

    // We might want 24-bit depth, but we're only (fairly) sure to get 16-bit.
    int depthBits = caps.depth ? 16 : 0;
    int stencilBits = caps.stencil ? 8 : 0;

    // Ok, now we have everything.
    nsTArray<EGLint> attribs(32);
    FillPBufferAttribs_BySizes(attribs,
                               caps.bpp16, caps.alpha,
                               depthBits, stencilBits);

    // Time to try to get this config:
    EGLConfig configs[64];
    int numConfigs = sizeof(configs)/sizeof(EGLConfig);
    int foundConfigs = 0;

    if (!egl->fChooseConfig(egl->Display(),
                            attribs.Elements(),
                            configs, numConfigs,
                            &foundConfigs) ||
        !foundConfigs)
    {
        NS_WARNING("No configs found for the requested formats.");
        return EGL_NO_CONFIG;
    }

    // TODO: Pick a config progamatically instead of hoping that
    // the first config will be minimally matching our request.
    EGLConfig config = configs[0];

    if (gl->DebugMode()) {
        egl->DumpEGLConfig(config);
    }

    return config;
}
Ejemplo n.º 7
0
bool EglOnXBackend::initBufferConfigs()
{
    const EGLint config_attribs[] = {
        EGL_SURFACE_TYPE,         EGL_WINDOW_BIT|EGL_SWAP_BEHAVIOR_PRESERVED_BIT,
        EGL_RED_SIZE,             1,
        EGL_GREEN_SIZE,           1,
        EGL_BLUE_SIZE,            1,
        EGL_ALPHA_SIZE,           0,
#ifdef KWIN_HAVE_OPENGLES
        EGL_RENDERABLE_TYPE,      EGL_OPENGL_ES2_BIT,
#else
        EGL_RENDERABLE_TYPE,      EGL_OPENGL_BIT,
#endif
        EGL_CONFIG_CAVEAT,        EGL_NONE,
        EGL_NONE,
    };

    EGLint count;
    EGLConfig configs[1024];
    if (eglChooseConfig(dpy, config_attribs, configs, 1024, &count) == EGL_FALSE) {
        qCritical() << "choose config failed";
        return false;
    }

    Xcb::WindowAttributes attribs(rootWindow());
    if (!attribs) {
        qCritical() << "Failed to get window attributes of root window";
        return false;
    }

    config = configs[0];
    for (int i = 0; i < count; i++) {
        EGLint val;
        if (eglGetConfigAttrib(dpy, configs[i], EGL_NATIVE_VISUAL_ID, &val) == EGL_FALSE) {
            qCritical() << "egl get config attrib failed";
        }
        if (uint32_t(val) == attribs->visual) {
            config = configs[i];
            break;
        }
    }
    return true;
}
Ejemplo n.º 8
0
void *
ShadingContext::symbol_data (Symbol &sym)
{
    ShaderGroup &sgroup (*attribs());
    if (! sgroup.llvm_compiled_version())
        return NULL;   // can't retrieve symbol if we didn't JIT and runit

    if (sym.dataoffset() >= 0 && (int)m_heap.size() > sym.dataoffset()) {
        // lives on the heap
        return &m_heap[sym.dataoffset()];
    }

    // doesn't live on the heap
    if ((sym.symtype() == SymTypeParam || sym.symtype() == SymTypeOutputParam) &&
        (sym.valuesource() == Symbol::DefaultVal || sym.valuesource() == Symbol::InstanceVal)) {
        ASSERT (sym.data());
        return sym.data() ? sym.data() : NULL;
    }

    return NULL;  // not something we can retrieve
}
Ejemplo n.º 9
0
    /**
        Opens a file stream assuming the file is encoded according to the system locale

        \param[in]  file    The file to open
        \param[in]  mode    How to open it, explicitly.
        \throws     SCXFilePathNotFoundException
        \throws     SCXUnauthorizedFileSystemAccessException
        \throws     SCXNotSupportedException
        \throws     InvalidArgumentException Arguments
        Unlike STL there is no implicit (default) mode, the requested mode has to explicitly stated.
        The content of the file is assumed to be encoded according to system default.
     */
    SCXHandle<std::wfstream> SCXFile::OpenWFstream(const SCXFilePath& file, std::ios_base::openmode mode) {
        if (!(mode & std::ios::in) && !(mode & std::ios::out)) {
            throw SCXInvalidArgumentException(L"mode", L"Specify ios::in or ios::out, or both", SCXSRCLOCATION);
        }
        if (mode & std::ios::binary) {
            throw SCXNotSupportedException(L"wide streams must not be binary", SCXSRCLOCATION);
        }
#if defined(WIN32)
        SCXHandle<std::wfstream> streamPtr(new std::wfstream(file.Get().c_str(), mode));
#elif defined(SCX_UNIX)
        SCXHandle<std::wfstream> streamPtr(new std::wfstream(SCXFileSystem::EncodePath(file).c_str(), mode));
#else
#error
#endif
        if (streamPtr->good()) {
            SCXFileSystem::Attributes attribs(SCXFileSystem::GetAttributes(file));
            if (attribs.count(SCXFileSystem::eDirectory) > 0) {
                throw SCXUnauthorizedFileSystemAccessException(file, attribs, SCXSRCLOCATION);
            }
        } else {
            SCXFileInfo info(file);
            if (mode & std::ios::in) {
                if (!info.PathExists()) {
                    throw SCXFilePathNotFoundException(file, SCXSRCLOCATION);
                } else {
                    throw SCXUnauthorizedFileSystemAccessException(file,
                            SCXFileSystem::GetAttributes(file), SCXSRCLOCATION);
                }
            } else if (mode & std::ios::out) {
                throw SCXUnauthorizedFileSystemAccessException(file,
                    SCXFileSystem::GetAttributes(file), SCXSRCLOCATION);
            } else {
                SCXASSERT(!"Invalid mode");
            }
        }
        return streamPtr;
    }
void Outlined_object_renderer::construct_model( const std::shared_ptr<Visible_object>& object )
{
    Open_gl_attributes attribs( Open_gl_attributes::ENABLE_BIT, false );
    {
        Call_list_handle handle = m_context_store->create_call_list( 1 );
        unsigned int gl_handle = m_context_store->get_call_list( handle );
        Open_gl_commands::new_list( gl_handle, GL_COMPILE );
        attribs.disable( Open_gl_attributes::TEXTURE_2D );
        render_model( *object->model(), false );
        Open_gl_commands::end_list();
        m_object_data_map[object] = handle;
    }
    {
        Call_list_handle handle = m_context_store->create_call_list( 1 );
        unsigned int gl_handle = m_context_store->get_call_list( handle );
        Open_gl_commands::new_list( gl_handle, GL_COMPILE );
        attribs.disable( Open_gl_attributes::TEXTURE_2D );
        Open_gl_commands::material( GL_AMBIENT, Color::BLACK );
        Open_gl_commands::material( GL_DIFFUSE, Color::BLACK );
        render_model( *object->model(), true );
        Open_gl_commands::end_list();
        m_flat_model_map[object] = handle;
    }
}
Ejemplo n.º 11
0
static inline void
dumpTransformFeedback(StateWriter &writer, GLint program)
{
    GLint transform_feedback_varyings = 0;
    glGetProgramiv(program, GL_TRANSFORM_FEEDBACK_VARYINGS, &transform_feedback_varyings);
    if (!transform_feedback_varyings) {
        return;
    }

    GLint max_name_length = 0;
    glGetProgramiv(program, GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, &max_name_length);
    std::vector<GLchar> name(max_name_length);

    GLint buffer_mode = GL_INTERLEAVED_ATTRIBS;
    glGetProgramiv(program, GL_TRANSFORM_FEEDBACK_BUFFER_MODE, &buffer_mode);

    std::vector<TransformFeedbackAttrib> attribs(transform_feedback_varyings);

    // Calculate the offsets and strides of each attribute according to
    // the value of GL_TRANSFORM_FEEDBACK_BUFFER_MODE
    GLsizei cum_attrib_offset = 0;
    for (GLint slot = 0; slot < transform_feedback_varyings; ++slot) {
        TransformFeedbackAttrib & attrib = attribs[slot];

        GLsizei length = 0;
        GLsizei size = 0;
        GLenum type = GL_NONE;
        glGetTransformFeedbackVarying(program, slot, max_name_length, &length, &size, &type, &name[0]);

        attrib.name = &name[0];

        const AttribDesc & desc = attrib.desc = AttribDesc(type, size);
        if (!desc) {
            return;
        }

        attrib.size = desc.arrayStride;

        switch (buffer_mode) {
        case GL_INTERLEAVED_ATTRIBS:
            attrib.offset = cum_attrib_offset;
            break;
        case GL_SEPARATE_ATTRIBS:
            attrib.offset = 0;
            attrib.stride = desc.arrayStride;
            break;
        default:
            assert(0);
            attrib.offset = 0;
            attrib.stride = 0;
        }

        cum_attrib_offset += desc.arrayStride;
    }
    if (buffer_mode == GL_INTERLEAVED_ATTRIBS) {
        for (GLint slot = 0; slot < transform_feedback_varyings; ++slot) {
            TransformFeedbackAttrib & attrib = attribs[slot];
            attrib.stride = cum_attrib_offset;
        }
    }

    GLint previous_tbo = 0;
    glGetIntegerv(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, &previous_tbo);

    // Map the buffers and calculate how many vertices can they hold
    // XXX: We currently limit to 1024, or things can get significantly slow.
    unsigned numVertices = 16*1024;
    for (GLint slot = 0; slot < transform_feedback_varyings; ++slot) {
        TransformFeedbackAttrib & attrib = attribs[slot];
        attrib.map = NULL;
        if (slot == 0 || buffer_mode != GL_INTERLEAVED_ATTRIBS) {
            GLint tbo = 0;
            glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_BINDING, slot, &tbo);
            if (!tbo) {
                numVertices = 0;
                continue;
            }

            GLint start = 0;
            glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_START, slot, &start);
            GLint size = 0;
            glGetIntegeri_v(GL_TRANSFORM_FEEDBACK_BUFFER_SIZE, slot, &size);

            glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tbo);

            if (size == 0) {
                glGetBufferParameteriv(GL_TRANSFORM_FEEDBACK_BUFFER, GL_BUFFER_SIZE, &size);
                assert(size >= start);
                size -= start;
            }

            unsigned numAttribVertices = calcNumElements(size,
                                                         attrib.offset,
                                                         attrib.size,
                                                         attrib.stride);
            numVertices = std::min(numVertices, numAttribVertices);

            attrib.map = (const GLbyte *)attrib.mapping.map(GL_TRANSFORM_FEEDBACK_BUFFER, tbo) + start;
        } else {
            attrib.map = attribs[0].map;
        }
    }
    glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, previous_tbo);

    // Actually dump the vertices
    writer.beginMember("GL_TRANSFORM_FEEDBACK");
    writer.beginArray();
    for (unsigned vertex = 0; vertex < numVertices; ++vertex) {
        writer.beginObject();
        for (GLint slot = 0; slot < transform_feedback_varyings; ++slot) {
            TransformFeedbackAttrib & attrib = attribs[slot];
            if (!attrib.map) {
                continue;
            }

            const AttribDesc & desc = attrib.desc;
            assert(desc);

            const GLbyte *vertex_data = attrib.map + attrib.stride*vertex + attrib.offset;
            dumpAttribArray(writer, attrib.name, desc, vertex_data);
        }
        writer.endObject();
    }
    writer.endArray();
    writer.endMember();
}
Ejemplo n.º 12
0
bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream)
{
   BSOCK *sd = jcr->store_bsock;
   POOL_MEM attribs(PM_NAME),
            attribsExBuf(PM_NAME);
   char *attribsEx = NULL;
   int attr_stream;
   int comp_len;
   bool status;
   int hangup = get_hangup();
#ifdef FD_NO_SEND_TEST
   return true;
#endif

   Dmsg1(300, "encode_and_send_attrs fname=%s\n", ff_pkt->fname);
   /** Find what data stream we will use, then encode the attributes */
   if ((data_stream = select_data_stream(ff_pkt, me->compatible)) == STREAM_NONE) {
      /* This should not happen */
      Jmsg0(jcr, M_FATAL, 0, _("Invalid file flags, no supported data stream type.\n"));
      return false;
   }
   encode_stat(attribs.c_str(), &ff_pkt->statp, sizeof(ff_pkt->statp), ff_pkt->LinkFI, data_stream);

   /** Now possibly extend the attributes */
   if (IS_FT_OBJECT(ff_pkt->type)) {
      attr_stream = STREAM_RESTORE_OBJECT;
   } else {
      attribsEx = attribsExBuf.c_str();
      attr_stream = encode_attribsEx(jcr, attribsEx, ff_pkt);
   }

   Dmsg3(300, "File %s\nattribs=%s\nattribsEx=%s\n", ff_pkt->fname, attribs.c_str(), attribsEx);

   jcr->lock();
   jcr->JobFiles++;                    /* increment number of files sent */
   ff_pkt->FileIndex = jcr->JobFiles;  /* return FileIndex */
   pm_strcpy(jcr->last_fname, ff_pkt->fname);
   jcr->unlock();

   /*
    * Debug code: check if we must hangup
    */
   if (hangup && (jcr->JobFiles > (uint32_t)hangup)) {
      jcr->setJobStatus(JS_Incomplete);
      Jmsg1(jcr, M_FATAL, 0, "Debug hangup requested after %d files.\n", hangup);
      set_hangup(0);
      return false;
   }

   /**
    * Send Attributes header to Storage daemon
    *    <file-index> <stream> <info>
    */
   if (!sd->fsend("%ld %d 0", jcr->JobFiles, attr_stream)) {
      if (!jcr->is_canceled() && !jcr->is_incomplete()) {
         Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror());
      }
      return false;
   }
   Dmsg1(300, ">stored: attrhdr %s", sd->msg);

   /**
    * Send file attributes to Storage daemon
    *   File_index
    *   File type
    *   Filename (full path)
    *   Encoded attributes
    *   Link name (if type==FT_LNK or FT_LNKSAVED)
    *   Encoded extended-attributes (for Win32)
    *   Delta Sequence Number
    *
    * or send Restore Object to Storage daemon
    *   File_index
    *   File_type
    *   Object_index
    *   Object_len  (possibly compressed)
    *   Object_full_len (not compressed)
    *   Object_compression
    *   Plugin_name
    *   Object_name
    *   Binary Object data
    *
    * For a directory, link is the same as fname, but with trailing
    * slash. For a linked file, link is the link.
    */
   if (!IS_FT_OBJECT(ff_pkt->type) && ff_pkt->type != FT_DELETED) { /* already stripped */
      strip_path(ff_pkt);
   }
   switch (ff_pkt->type) {
   case FT_JUNCTION:
   case FT_LNK:
   case FT_LNKSAVED:
      Dmsg3(300, "Link %d %s to %s\n", jcr->JobFiles, ff_pkt->fname, ff_pkt->link);
      status = sd->fsend("%ld %d %s%c%s%c%s%c%s%c%u%c", jcr->JobFiles,
                         ff_pkt->type, ff_pkt->fname, 0, attribs.c_str(), 0,
                         ff_pkt->link, 0, attribsEx, 0, ff_pkt->delta_seq, 0);
      break;
   case FT_DIREND:
   case FT_REPARSE:
      /* Here link is the canonical filename (i.e. with trailing slash) */
      status = sd->fsend("%ld %d %s%c%s%c%c%s%c%u%c", jcr->JobFiles,
                         ff_pkt->type, ff_pkt->link, 0, attribs.c_str(), 0, 0,
                         attribsEx, 0, ff_pkt->delta_seq, 0);
      break;
   case FT_PLUGIN_CONFIG:
   case FT_RESTORE_FIRST:
      comp_len = ff_pkt->object_len;
      ff_pkt->object_compression = 0;

      if (ff_pkt->object_len > 1000) {
         /*
          * Big object, compress it
          */
         comp_len = compressBound(ff_pkt->object_len);
         POOLMEM *comp_obj = get_memory(comp_len);
         /*
          * FIXME: check Zdeflate error
          */
         Zdeflate(ff_pkt->object, ff_pkt->object_len, comp_obj, comp_len);
         if (comp_len < ff_pkt->object_len) {
            ff_pkt->object = comp_obj;
            ff_pkt->object_compression = 1;    /* zlib level 9 compression */
         } else {
            /*
             * Uncompressed object smaller, use it
             */
            comp_len = ff_pkt->object_len;
         }
         Dmsg2(100, "Object compressed from %d to %d bytes\n", ff_pkt->object_len, comp_len);
      }

      sd->msglen = Mmsg(sd->msg, "%d %d %d %d %d %d %s%c%s%c",
                        jcr->JobFiles, ff_pkt->type, ff_pkt->object_index,
                        comp_len, ff_pkt->object_len, ff_pkt->object_compression,
                        ff_pkt->fname, 0, ff_pkt->object_name, 0);
      sd->msg = check_pool_memory_size(sd->msg, sd->msglen + comp_len + 2);
      memcpy(sd->msg + sd->msglen, ff_pkt->object, comp_len);

      /*
       * Note we send one extra byte so Dir can store zero after object
       */
      sd->msglen += comp_len + 1;
      status = sd->send();
      if (ff_pkt->object_compression) {
         free_and_null_pool_memory(ff_pkt->object);
      }
      break;
   case FT_REG:
      status = sd->fsend("%ld %d %s%c%s%c%c%s%c%d%c", jcr->JobFiles,
                         ff_pkt->type, ff_pkt->fname, 0, attribs.c_str(), 0, 0,
                         attribsEx, 0, ff_pkt->delta_seq, 0);
      break;
   default:
      status = sd->fsend("%ld %d %s%c%s%c%c%s%c%u%c", jcr->JobFiles,
                         ff_pkt->type, ff_pkt->fname, 0, attribs.c_str(), 0, 0,
                         attribsEx, 0, ff_pkt->delta_seq, 0);
      break;
   }

   if (!IS_FT_OBJECT(ff_pkt->type) && ff_pkt->type != FT_DELETED) {
      unstrip_path(ff_pkt);
   }

   Dmsg2(300, ">stored: attr len=%d: %s\n", sd->msglen, sd->msg);
   if (!status && !jcr->is_job_canceled()) {
      Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), sd->bstrerror());
   }

   sd->signal(BNET_EOD);            /* indicate end of attributes data */

   return status;
}
Ejemplo n.º 13
0
Geometry* XMLReader::LoadGeometry(QXmlStreamReader &xml_reader, QMap<QString, QList<Geometry*>> &map, const QStringRef &local_path)
{
    Geometry* result = NULL;

    //First check what type of geometry we're supposed to load
    QXmlStreamAttributes attribs(xml_reader.attributes());
    QStringRef type = attribs.value(QString(), QString("type"));
    bool is_mesh = false;
    if(QStringRef::compare(type, QString("obj")) == 0)
    {
        result = new Mesh();
        is_mesh = true;
    }
    else if(QStringRef::compare(type, QString("sphere")) == 0)
    {
        result = new Sphere();
    }
    else if(QStringRef::compare(type, QString("square")) == 0)
    {
        result = new SquarePlane();
    }
    else if(QStringRef::compare(type, QString("cube")) == 0)
    {
        result = new Cube();
    }
    else
    {
        std::cout << "Could not parse the geometry!" << std::endl;
        return NULL;
    }
    QStringRef name = attribs.value(QString(), QString("name"));
    result->name = name.toString();

    while(!xml_reader.isEndElement() || QStringRef::compare(xml_reader.name(), QString("geometry")) != 0)
    {
        xml_reader.readNext();// xml_reader.readNext();

        QString tag(xml_reader.name().toString());
        if(is_mesh && QString::compare(tag, QString("filename")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                ((Mesh*)result)->LoadOBJ(xml_reader.text(), local_path);
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("transform")) == 0)
        {
            result->transform = LoadTransform(xml_reader);
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("material")) == 0)
        {
            //Add the geometry to the map of material names to geometries so that we can assign it a material later
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                QString material_name = xml_reader.text().toString();
                QList<Geometry*> list = map.value(material_name);
                list.append(result);
                map.insert(material_name, list);
                xml_reader.readNext();

            }
//            attribs = QXmlStreamAttributes(xml_reader.attributes());
//            QString name = attribs.value(QString(), QString("value")).toString();
//            QList<Geometry*> list = map.value(name);
//            list.append(result);
//            map.insert(name, list);
//            xml_reader.readNext();
        }
    }
    return result;
}
Ejemplo n.º 14
0
Material* XMLReader::LoadMaterial(QXmlStreamReader &xml_reader, const QStringRef &local_path)
{
    Material* result;
    //First check what type of material we're supposed to load
    QXmlStreamAttributes attribs(xml_reader.attributes());
    QStringRef type = attribs.value(QString(), QString("type"));
    if(QStringRef::compare(type, QString("lambert")) == 0)
    {
        result = new LambertMaterial();
    }
    else if(QStringRef::compare(type, QString("phong")) == 0)
    {
        result = new PhongMaterial();
        QStringRef spec_pow = attribs.value(QString(), QString("specularPower"));
        if(QStringRef::compare(spec_pow, QString("")) != 0)
        {
            ((PhongMaterial*)result)->specular_power = spec_pow.toFloat();
        }
    }
    else
    {
        std::cout << "Could not parse the material!" << std::endl;
        return NULL;
    }

    result->name = attribs.value(QString(), QString("name")).toString();

    while(!xml_reader.isEndElement() || QStringRef::compare(xml_reader.name(), QString("material")) != 0)
    {
        xml_reader.readNext();
        QString tag(xml_reader.name().toString());
        if(QString::compare(tag, QString("baseColor")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                result->base_color = ToVec3(xml_reader.text());
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("reflectivity")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                result->reflectivity = xml_reader.text().toFloat();
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("iorIn")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                result->refract_idx_in = xml_reader.text().toFloat();
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("iorOut")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                result->refract_idx_out = xml_reader.text().toFloat();
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("emissive")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                if(QStringRef::compare(xml_reader.text(), QString("false"), Qt::CaseInsensitive) == 0)
                {
                    result->emissive = false;
                }
                else if(QStringRef::compare(xml_reader.text(), QString("true"), Qt::CaseInsensitive) == 0)
                {
                    result->emissive = true;
                }
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("texture")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                QString img_filepath = local_path.toString().append(xml_reader.text().toString());
                QImage* texture = new QImage(img_filepath);
                result->texture = texture;
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("normalMap")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                QString img_filepath = local_path.toString().append(xml_reader.text().toString());
                QImage* texture = new QImage(img_filepath);
                result->normal_map = texture;
            }
            xml_reader.readNext();
        }
    }
    return result;
}
Ejemplo n.º 15
0
void CReplayPlayer::Replay(bool serializationtest, bool ooslog)
{
	ENSURE(m_Stream);

	new CProfileViewer;
	new CProfileManager;
	g_ScriptStatsTable = new CScriptStatsTable;
	g_ProfileViewer.AddRootTable(g_ScriptStatsTable);
	
	const int runtimeSize = 384 * 1024 * 1024;
	const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024;
	g_ScriptRuntime = ScriptInterface::CreateRuntime(shared_ptr<ScriptRuntime>(), runtimeSize, heapGrowthBytesGCTrigger);

	g_Game = new CGame(true);
	if (serializationtest)
		g_Game->GetSimulation2()->EnableSerializationTest();
	if (ooslog)
		g_Game->GetSimulation2()->EnableOOSLog();

	// Need some stuff for terrain movement costs:
	// (TODO: this ought to be independent of any graphics code)
	new CTerrainTextureManager;
	g_TexMan.LoadTerrainTextures();

	// Initialise h_mgr so it doesn't crash when emitting sounds
	h_mgr_init();

	std::vector<SimulationCommand> commands;
	u32 turn = 0;
	u32 turnLength = 0;

	{
	JSContext* cx = g_Game->GetSimulation2()->GetScriptInterface().GetContext();
	JSAutoRequest rq(cx);
	std::string type;
	while ((*m_Stream >> type).good())
	{
		if (type == "start")
		{
			std::string line;
			std::getline(*m_Stream, line);
			JS::RootedValue attribs(cx);
			ENSURE(g_Game->GetSimulation2()->GetScriptInterface().ParseJSON(line, &attribs));

			g_Game->StartGame(&attribs, "");

			// TODO: Non progressive load can fail - need a decent way to handle this
			LDR_NonprogressiveLoad();

			PSRETURN ret = g_Game->ReallyStartGame();
			ENSURE(ret == PSRETURN_OK);
		}
		else if (type == "turn")
		{
			*m_Stream >> turn >> turnLength;
			debug_printf("Turn %u (%u)...\n", turn, turnLength);
		}
		else if (type == "cmd")
		{
			player_id_t player;
			*m_Stream >> player;

			std::string line;
			std::getline(*m_Stream, line);
			JS::RootedValue data(cx);
			g_Game->GetSimulation2()->GetScriptInterface().ParseJSON(line, &data);

			commands.emplace_back(SimulationCommand(player, cx, data));
		}
Ejemplo n.º 16
0
Material* XMLReader::LoadMaterial(QXmlStreamReader &xml_reader, const QStringRef &local_path, QMap<QString, QList<Material *> > &map)
{
    Material* result;
    bool weighted_material = false;
    //First check what type of material we're supposed to load
    QXmlStreamAttributes attribs(xml_reader.attributes());
    QStringRef type = attribs.value(QString(), QString("type"));
    if(QStringRef::compare(type, QString("default")) == 0)
    {
        result = new Material();
    }
    else if(QStringRef::compare(type, QString("light")) == 0)
    {
        result = new LightMaterial();
        result->is_light_source = true;
        QStringRef intensity = attribs.value(QString(), QString("intensity"));
        if(QStringRef::compare(intensity, QString("")) != 0)
        {
            result->intensity = intensity.toFloat();
        }
    }
    else if(QStringRef::compare(type, QString("weighted")) == 0)
    {
        result = new WeightedMaterial();
        weighted_material = true;
        //weights are handled below
    }
    else
    {
        std::cout << "Could not parse the material!" << std::endl;
        return NULL;
    }

    result->name = attribs.value(QString(), QString("name")).toString();

    while(!xml_reader.isEndElement() || QStringRef::compare(xml_reader.name(), QString("material")) != 0)
    {
        xml_reader.readNext();
        QString tag(xml_reader.name().toString());
        if(QString::compare(tag, QString("baseColor")) == 0)
        {
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                result->base_color = ToVec3(xml_reader.text());
            }
            xml_reader.readNext();
        }
        else if(QString::compare(tag, QString("bxdf")) == 0)
        {
            //Add the Material to the map of BxDF names to Materials so that we can assign it a BxDF later
            xml_reader.readNext();
            if(xml_reader.isCharacters())
            {
                QString bxdf_name = xml_reader.text().toString();
                QList<Material*> list = map.value(bxdf_name);
                list.append(result);
                map.insert(bxdf_name, list);
                xml_reader.readNext();

            }
        }
        else if(QString::compare(tag, QString("texture")) == 0)
        {
            result->texture = LoadTextureFile(xml_reader, local_path);
        }
        else if(QString::compare(tag, QString("normalMap")) == 0)
        {
            result->normal_map = LoadTextureFile(xml_reader, local_path);
        }
        else if(QString::compare(tag, QString("weight")) == 0 && weighted_material)
        {
            xml_reader.readNext();
            float weight;
            if(xml_reader.isCharacters())
            {
                weight = xml_reader.text().toFloat();
            }
            ((WeightedMaterial*)result)->bxdf_weights.append(weight);
            xml_reader.readNext(); // add this line
        }
    }
    return result;
}
Ejemplo n.º 17
0
/*
 * Called here by find() for each file.
 *
 *  Find the file, compute the MD5 or SHA1 and send it back to the Director
 */
static int verify_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
{
   POOL_MEM attribs(PM_NAME),
            attribsEx(PM_NAME);
   int digest_stream = STREAM_NONE;
   int status;
   DIGEST *digest = NULL;
   BSOCK *dir;

   if (job_canceled(jcr)) {
      return 0;
   }

   dir = jcr->dir_bsock;
   jcr->num_files_examined++;         /* bump total file count */

   switch (ff_pkt->type) {
   case FT_LNKSAVED:                  /* Hard linked, file already saved */
      Dmsg2(30, "FT_LNKSAVED saving: %s => %s\n", ff_pkt->fname, ff_pkt->link);
      break;
   case FT_REGE:
      Dmsg1(30, "FT_REGE saving: %s\n", ff_pkt->fname);
      break;
   case FT_REG:
      Dmsg1(30, "FT_REG saving: %s\n", ff_pkt->fname);
      break;
   case FT_LNK:
      Dmsg2(30, "FT_LNK saving: %s -> %s\n", ff_pkt->fname, ff_pkt->link);
      break;
   case FT_DIRBEGIN:
      jcr->num_files_examined--;      /* correct file count */
      return 1;                       /* ignored */
   case FT_REPARSE:
   case FT_JUNCTION:
   case FT_DIREND:
      Dmsg1(30, "FT_DIR saving: %s\n", ff_pkt->fname);
      break;
   case FT_SPEC:
      Dmsg1(30, "FT_SPEC saving: %s\n", ff_pkt->fname);
      break;
   case FT_RAW:
      Dmsg1(30, "FT_RAW saving: %s\n", ff_pkt->fname);
      break;
   case FT_FIFO:
      Dmsg1(30, "FT_FIFO saving: %s\n", ff_pkt->fname);
      break;
   case FT_NOACCESS: {
      berrno be;
      be.set_errno(ff_pkt->ff_errno);
      Jmsg(jcr, M_NOTSAVED, 1, _("     Could not access %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror());
      jcr->JobErrors++;
      return 1;
   }
   case FT_NOFOLLOW: {
      berrno be;
      be.set_errno(ff_pkt->ff_errno);
      Jmsg(jcr, M_NOTSAVED, 1, _("     Could not follow link %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror());
      jcr->JobErrors++;
      return 1;
   }
   case FT_NOSTAT: {
      berrno be;
      be.set_errno(ff_pkt->ff_errno);
      Jmsg(jcr, M_NOTSAVED, 1, _("     Could not stat %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror());
      jcr->JobErrors++;
      return 1;
   }
   case FT_DIRNOCHG:
   case FT_NOCHG:
      Jmsg(jcr, M_SKIPPED, 1, _("     Unchanged file skipped: %s\n"), ff_pkt->fname);
      return 1;
   case FT_ISARCH:
      Jmsg(jcr, M_SKIPPED, 1, _("     Archive file skipped: %s\n"), ff_pkt->fname);
      return 1;
   case FT_NORECURSE:
      Jmsg(jcr, M_SKIPPED, 1, _("     Recursion turned off. Directory skipped: %s\n"), ff_pkt->fname);
      ff_pkt->type = FT_DIREND;     /* directory entry was backed up */
      break;
   case FT_NOFSCHG:
      Jmsg(jcr, M_SKIPPED, 1, _("     File system change prohibited. Directory skipped: %s\n"), ff_pkt->fname);
      return 1;
   case FT_PLUGIN_CONFIG:
   case FT_RESTORE_FIRST:
      return 1;                       /* silently skip */
   case FT_NOOPEN: {
      berrno be;
      be.set_errno(ff_pkt->ff_errno);
      Jmsg(jcr, M_NOTSAVED, 1, _("     Could not open directory %s: ERR=%s\n"), ff_pkt->fname, be.bstrerror());
      jcr->JobErrors++;
      return 1;
   }
   default:
      Jmsg(jcr, M_NOTSAVED, 0, _("     Unknown file type %d: %s\n"), ff_pkt->type, ff_pkt->fname);
      jcr->JobErrors++;
      return 1;
   }

   /* Encode attributes and possibly extend them */
   encode_stat(attribs.c_str(), &ff_pkt->statp, sizeof(ff_pkt->statp), ff_pkt->LinkFI, 0);
   encode_attribsEx(jcr, attribsEx.c_str(), ff_pkt);

   jcr->lock();
   jcr->JobFiles++;                  /* increment number of files sent */
   pm_strcpy(jcr->last_fname, ff_pkt->fname);
   jcr->unlock();

   /*
    * Send file attributes to Director
    *   File_index
    *   Stream
    *   Verify Options
    *   Filename (full path)
    *   Encoded attributes
    *   Link name (if type==FT_LNK)
    * For a directory, link is the same as fname, but with trailing
    * slash. For a linked file, link is the link.
    */
   /* Send file attributes to Director (note different format than for Storage) */
   Dmsg2(400, "send ATTR inx=%d fname=%s\n", jcr->JobFiles, ff_pkt->fname);
   if (ff_pkt->type == FT_LNK || ff_pkt->type == FT_LNKSAVED) {
      status = dir->fsend("%d %d %s %s%c%s%c%s%c", jcr->JobFiles,
                          STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->fname,
                          0, attribs.c_str(), 0, ff_pkt->link, 0);
   } else if (ff_pkt->type == FT_DIREND || ff_pkt->type == FT_REPARSE ||
              ff_pkt->type == FT_JUNCTION) {
      /* Here link is the canonical filename (i.e. with trailing slash) */
      status = dir->fsend("%d %d %s %s%c%s%c%c", jcr->JobFiles,
                          STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->link,
                          0, attribs.c_str(), 0, 0);
   } else {
      status = dir->fsend("%d %d %s %s%c%s%c%c", jcr->JobFiles,
                          STREAM_UNIX_ATTRIBUTES, ff_pkt->VerifyOpts, ff_pkt->fname,
                          0, attribs.c_str(), 0, 0);
   }
   Dmsg2(20, "filed>dir: attribs len=%d: msg=%s\n", dir->msglen, dir->msg);
   if (!status) {
      Jmsg(jcr, M_FATAL, 0, _("Network error in send to Director: ERR=%s\n"), bnet_strerror(dir));
      return 0;
   }

   /*
    * The remainder of the function is all about getting the checksum.
    * First we initialise, then we read files, other streams and Finder Info.
    */
   if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) &&
            ff_pkt->flags & (FO_MD5|FO_SHA1|FO_SHA256|FO_SHA512))) {
      /*
       * Create our digest context. If this fails, the digest will be set to NULL
       * and not used.
       */
      if (ff_pkt->flags & FO_MD5) {
         digest = crypto_digest_new(jcr, CRYPTO_DIGEST_MD5);
         digest_stream = STREAM_MD5_DIGEST;

      } else if (ff_pkt->flags & FO_SHA1) {
         digest = crypto_digest_new(jcr, CRYPTO_DIGEST_SHA1);
         digest_stream = STREAM_SHA1_DIGEST;

      } else if (ff_pkt->flags & FO_SHA256) {
         digest = crypto_digest_new(jcr, CRYPTO_DIGEST_SHA256);
         digest_stream = STREAM_SHA256_DIGEST;

      } else if (ff_pkt->flags & FO_SHA512) {
         digest = crypto_digest_new(jcr, CRYPTO_DIGEST_SHA512);
         digest_stream = STREAM_SHA512_DIGEST;
      }

      /* Did digest initialization fail? */
      if (digest_stream != STREAM_NONE && digest == NULL) {
         Jmsg(jcr, M_WARNING, 0, _("%s digest initialization failed\n"),
              stream_to_ascii(digest_stream));
      }

      /* compute MD5 or SHA1 hash */
      if (digest) {
         char md[CRYPTO_DIGEST_MAX_SIZE];
         uint32_t size;

         size = sizeof(md);

         if (digest_file(jcr, ff_pkt, digest) != 0) {
            jcr->JobErrors++;
            goto good_rtn;
         }

         if (crypto_digest_finalize(digest, (uint8_t *)md, &size)) {
            char *digest_buf;
            const char *digest_name;

            digest_buf = (char *)malloc(BASE64_SIZE(size));
            digest_name = crypto_digest_name(digest);

            bin_to_base64(digest_buf, BASE64_SIZE(size), md, size, true);
            Dmsg3(400, "send inx=%d %s=%s\n", jcr->JobFiles, digest_name, digest_buf);
            dir->fsend("%d %d %s *%s-%d*", jcr->JobFiles, digest_stream, digest_buf,
                       digest_name, jcr->JobFiles);
            Dmsg3(20, "filed>dir: %s len=%d: msg=%s\n", digest_name,
                  dir->msglen, dir->msg);

            free(digest_buf);
         }
      }
   }

good_rtn:
   if (digest) {
      crypto_digest_free(digest);
   }
   return 1;
}
Ejemplo n.º 18
0
BxDF* XMLReader::LoadBxDF(QXmlStreamReader &xml_reader)
{
    BxDF* result = NULL;
    //First check what type of material we're supposed to load
    QXmlStreamAttributes attribs(xml_reader.attributes());
    QStringRef type = attribs.value(QString(), QString("type"));
    if(QStringRef::compare(type, QString("lambert")) == 0)
    {
        glm::vec3 diffuseColor(0.5f);
        QStringRef color = attribs.value(QString(), QString("diffuseColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            diffuseColor = ToVec3(color);
        }
        result = new LambertBxDF(diffuseColor);
    }
    else if(QStringRef::compare(type, QString("specularReflection")) == 0)
    {
        glm::vec3 refl_color(0.5f);
        QStringRef color = attribs.value(QString(), QString("reflectionColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            refl_color = ToVec3(color);
        }
        result = new SpecularReflectionBxDF(refl_color);
    }
    else if(QStringRef::compare(type, QString("blinnMicrofacet")) == 0)
    {
        glm::vec3 refl_color(0.5f);
        QStringRef color = attribs.value(QString(), QString("reflectionColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            refl_color = ToVec3(color);
        }
        result = new BlinnMicrofacetBxDF(refl_color);

        QStringRef exponent = attribs.value(QString(), QString("exponent"));
        if(QStringRef::compare(exponent, QString("")) != 0)
        {
            ((BlinnMicrofacetBxDF*)result)->exponent = exponent.toFloat();
        }
    }

    else if(QStringRef::compare(type, QString("anisotropic")) == 0)
    {
        glm::vec3 refl_color(0.5f);
        QStringRef color = attribs.value(QString(), QString("reflectionColor"));
        if(QStringRef::compare(color, QString("")) != 0)
        {
            refl_color = ToVec3(color);
        }

        float exp1 = 4.0f;
        QStringRef e1 = attribs.value(QString(), QString("exponent1"));
        if(QStringRef::compare(e1, QString("")) != 0)
        {
            exp1 =  e1.toFloat();
        }

        float exp2 = 20.0f;
        QStringRef e2 = attribs.value(QString(), QString("exponent2"));
        if(QStringRef::compare(e2, QString("")) != 0)
        {
            exp2 =  e2.toFloat();
        }
        result = new AnisotropicBxDF(refl_color, exp1, exp2);
    }

    else if(QStringRef::compare(type, QString("phong")) == 0)
    {
        glm::vec3 diffuseColor(0.5f);
        QStringRef diffuse_color = attribs.value(QString(), QString("diffuseColor"));
        if(QStringRef::compare(diffuse_color, QString("")) != 0)
        {
            diffuseColor = ToVec3(diffuse_color);
        }

        glm::vec3 specularColor(1);
        QStringRef specular_color = attribs.value(QString(), QString("specularColor"));
        if(QStringRef::compare(specular_color, QString("")) != 0)
        {
            specularColor = ToVec3(specular_color);
        }

        float specularPower = 5.0f;
        QStringRef specular_power = attribs.value(QString(), QString("specularPower"));
        if(QStringRef::compare(specular_power, QString("")) != 0)
        {
            specularPower = specular_power.toFloat();
        }

        result = new PhongBxDF(diffuseColor, specularColor, specularPower);
    }
    else if(QStringRef::compare(type, QString("transmission")) == 0)
    {

        float ei = 1.0f;
        float et = 1.0f;

        QStringRef eta_i = attribs.value(QString(), QString("etai"));
        if(QStringRef::compare(eta_i, QString("")) != 0)
        {
            ei = eta_i.toFloat();
        }

        QStringRef eta_t = attribs.value(QString(), QString("etat"));
        if(QStringRef::compare(eta_i, QString("")) != 0)
        {
            et = eta_t.toFloat();
        }

        glm::vec3 transmissionColor(1);
        QStringRef trans = attribs.value(QString(), QString("transmissionColor"));
        if(QStringRef::compare(trans, QString("")) != 0)
        {
            transmissionColor = ToVec3(trans);
        }

        result = new TransmissionBxDF(ei,et,transmissionColor);
    }
    else
    {
        std::cout << "Could not parse the BxDF!" << std::endl;
        return NULL;
    }
    result->name = attribs.value(QString(), QString("name")).toString();
    return result;
}