Пример #1
0
	virtual void main()
	{
		//init
		QString psname = getString("psname");
		if (psname=="") psname = getInfile("in");

		//load
		VariantList variants;
		variants.load(getInfile("in"));

		//annotate
		bool test = getFlag("test");
		QString mode = getEnum("mode");
		if(mode=="germline")
		{
			NGSD(test).annotate(variants, psname);
		}
		else if(mode=="somatic")
		{
			NGSD(test).annotateSomatic(variants, psname);
		}

		//store
		variants.store(getOutfile("out"));
	}
Пример #2
0
  Query* FuzzyQuery::rewrite(IndexReader* reader) {
	  FilteredTermEnum* enumerator = getEnum(reader);
	  const size_t maxClauseCount = BooleanQuery::getMaxClauseCount();
	  ScoreTermQueue* stQueue = _CLNEW ScoreTermQueue(maxClauseCount);
	  ScoreTerm* reusableST = NULL;

	  try {
		  do {
			  float_t score = 0.0f;
			  Term* t = enumerator->term();
			  if (t != NULL) {
				  score = enumerator->difference();
				  if (reusableST == NULL) {
					  reusableST = _CLNEW ScoreTerm(t, score);
				  } else if (score >= reusableST->score) {
					  // reusableST holds the last "rejected" entry, so, if
					  // this new score is not better than that, there's no
					  // need to try inserting it
					  reusableST->score = score;
					  reusableST->term = t;
				  } else {
					  continue;
				  }

				  reusableST = stQueue->insertWithOverflow(reusableST);
			  }
		  } while (enumerator->next());
	  } _CLFINALLY({
		  enumerator->close();
		  _CLLDELETE(enumerator);
          //_CLLDELETE(reusableST);
	  });
Пример #3
0
void TheaRenderer::defineIBLNode(TheaSDK::XML::EnvironmentOptions::IBLMap& iblMap, const char *attName)
{
	MFnDependencyNode depFn(getRenderGlobalsNode());
	std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;
	std::shared_ptr<TheaRenderer> renderer = std::static_pointer_cast<TheaRenderer>(MayaTo::getWorldPtr()->worldRendererPtr);

	MObject fileNodeObject = getConnectedFileTextureObject(MString(attName), depFn);
	if(fileNodeObject != MObject::kNullObj)
	{
		MFnDependencyNode fileNode(fileNodeObject);
		MString fileName;
		getString(MString("fileTextureName"), fileNode, fileName); 
		if( fileName.length() > 1)
		{	
			iblMap.bitmapFilename = fileName.asChar();
			float intensity = 0.0f, rotation = 0.0f;
			getFloat("mtth_file_iblIntensity", fileNode, intensity);
			iblMap.intensity = intensity;
			getFloat("mtth_file_iblRotation", fileNode, rotation);
			iblMap.rotation = rotation;
			int wrapping = 0;
			getEnum(MString("mtth_file_iblWrapping"), fileNode, wrapping);
			iblMap.wrapping = (TheaSDK::IBLWrapping)wrapping;
			iblMap.enabled = true;
			return;
		}
	}
	iblMap.enabled = false;
}
Пример #4
0
	virtual void main()
	{
		//input
		BedFile in;
		in.load(getInfile("in"));
		BedFile in2;
		in2.load(getInfile("in2"));
		
		//calculate
		QString mode = getEnum("mode");
		if (mode=="intersect")
		{
			if (!in2.isMergedAndSorted()) in2.merge();
			in.intersect(in2);
			in.store(getOutfile("out"));
		}
		else if (mode=="in")
		{
			if (!in2.isMergedAndSorted()) in2.merge();
			in.overlapping(in2);
			in.store(getOutfile("out"));
		}
		else if (mode=="in2")
		{
			if (!in.isMergedAndSorted()) in.merge();
			in2.overlapping(in);
			in2.store(getOutfile("out"));
		}
	}
Пример #5
0
Val_t convertValue(char *val, Atta_t key) {
  Val_t value = {0, S, {0}};
  char *tok;
  value.key = key;
  s57key_t *valkey = &keys[value.key];
  if (value.key != 0) {
    value.type = valkey->type;
    switch (value.type) {
      case S:
      case A:
        value.val.s = strdup(val);
        break;
      case L:
        value.val.l = NULL;
        Lst_t *llst = NULL;
        for (tok = strtok(val, ";"); tok != NULL; tok = strtok(NULL, ";")) {
          Lst_t *lst = malloc(sizeof(Lst_t));
          lst->val = getEnum(valkey->val, tok);
          lst->next = NULL;
          if (llst == NULL)
            value.val.l = lst;
          else llst->next = lst;
          llst = lst;
        }
        break;
      case E:
        tok = strtok(val, ";");
        value.val.e = getEnum(valkey->val, tok);
        break;
      case F:
        value.val.f = atof(val);
        break;
      case I:
        value.val.i = atoi(val);
        break;
    }

  }
  return value;
}
Пример #6
0
	virtual void main()
	{
		//init
		NGSD db(getFlag("test"));

		//load input file
		BedFile in;
		in.load(getInfile("in"));
		in.merge();

		//look up genes overlapping the input region
		QStringList genes;
		for(int i=0; i<in.count(); ++i)
		{
			BedLine& line = in[i];
			genes << db.genesOverlapping(line.chr(), line.start(), line.end(), 0);
		}
		genes.removeDuplicates();

		//output header
		QStringList output;
		output.append("#gene\tsize\toverlap\tpercentage");

		//process
		BedFile reg_unassigned = in;
		foreach(QString gene, genes)
		{
			//create gene-specific regions
			QTextStream messages(stderr);
			BedFile reg_gene = db.genesToRegions(QStringList() << gene, getEnum("source"), "exon", &messages);
			reg_gene.merge();

			//append output line
            long long bases_gene = reg_gene.baseCount();
			if (bases_gene==0) continue; //non-coding gene => skip
			reg_gene.intersect(in);
            long long bases_covered = reg_gene.baseCount();
			if (bases_covered==0) continue; //wrong coding range in UCSC => gene does not really overlap => skip

			output.append(gene + "\t" + QString::number(bases_gene) + "\t" + QString::number(bases_covered) + "\t" + QString::number(100.0*bases_covered/bases_gene, 'f', 2));

			//update unassigned regions
			reg_gene.sort();
			reg_unassigned.subtract(reg_gene);
		}
Пример #7
0
QueryPtr FuzzyQuery::rewrite(const IndexReaderPtr& reader) {
    if (!termLongEnough) { // can only match if it's exact
        return newLucene<TermQuery>(term);
    }

    int32_t maxSize = BooleanQuery::getMaxClauseCount();
    ScoreTermQueuePtr stQueue(newLucene<ScoreTermQueue>(maxSize + 1));
    FilteredTermEnumPtr enumerator(getEnum(reader));
    LuceneException finally;
    try {
        ScoreTermPtr st = newLucene<ScoreTerm>();
        do {
            TermPtr t(enumerator->term());
            if (!t) {
                break;
            }
            double score = enumerator->difference();
            // ignore uncompetitive hits
            if (stQueue->size() >= maxSize && score <= stQueue->top()->score) {
                continue;
            }
            // add new entry in PQ
            st->term = t;
            st->score = score;
            stQueue->add(st);
            // possibly drop entries from queue
            st = (stQueue->size() > maxSize) ? stQueue->pop() : newLucene<ScoreTerm>();
        } while (enumerator->next());
    } catch (LuceneException& e) {
        finally = e;
    }
    enumerator->close();
    finally.throwException();

    BooleanQueryPtr query(newLucene<BooleanQuery>(true));
    int32_t size = stQueue->size();
    for (int32_t i = 0; i < size; ++i) {
        ScoreTermPtr st(stQueue->pop());
        TermQueryPtr tq(newLucene<TermQuery>(st->term)); // found a match
        tq->setBoost(getBoost() * st->score); // set the boost
        query->add(tq, BooleanClause::SHOULD); // add to query
    }

    return query;
}
Пример #8
0
Type Type::fetchRawType(EmojicodeChar name, EmojicodeChar enamespace, bool optional, const Token *token, bool *existent){
    *existent = true;
    if(enamespace == globalNamespace){
        switch (name) {
            case E_OK_HAND_SIGN:
                return Type(TT_BOOLEAN, optional);
            case E_INPUT_SYMBOL_FOR_SYMBOLS:
                return Type(TT_SYMBOL, optional);
            case E_STEAM_LOCOMOTIVE:
                return Type(TT_INTEGER, optional);
            case E_ROCKET:
                return Type(TT_DOUBLE, optional);
            case E_MEDIUM_WHITE_CIRCLE:
                if (optional) {
                    compilerWarning(token, "🍬⚪️ is identical to ⚪️. Do not specify 🍬.");
                }
                return Type(TT_SOMETHING, false);
            case E_LARGE_BLUE_CIRCLE:
                return Type(TT_SOMEOBJECT, optional);
            case E_SPARKLES:
                compilerError(token, "The Nothingness type may not be referenced to.");
        }
    }
    
    Class *eclass = getClass(name, enamespace);
    if (eclass) {
        Type t = Type(eclass, optional);
        t.optional = optional;
        return t;
    }
    
    Protocol *protocol = getProtocol(name, enamespace);
    if(protocol){
        return Type(protocol, optional);
    }
    
    Enum *eenum = getEnum(name, enamespace);
    if(eenum){
        return Type(eenum, optional);
    }
    
    *existent = false;
    return typeNothingness;
}
Пример #9
0
State* State::currentState()
{
    State* state = new State(DeferredMode);

    std::vector<GLenum> capabilities = {
        GL_BLEND,
        GL_COLOR_LOGIC_OP,
        GL_CULL_FACE,
        GL_DEPTH_CLAMP,
        GL_DEPTH_TEST,
        GL_DITHER,
        GL_FRAMEBUFFER_SRGB,
        GL_LINE_SMOOTH,
        GL_MULTISAMPLE,
        GL_POLYGON_OFFSET_FILL,
        GL_POLYGON_OFFSET_LINE,
        GL_POLYGON_OFFSET_POINT,
        GL_POLYGON_SMOOTH,
        GL_PROGRAM_POINT_SIZE,
        GL_RASTERIZER_DISCARD,
        GL_SAMPLE_ALPHA_TO_COVERAGE,
        GL_SAMPLE_ALPHA_TO_ONE,
        GL_SAMPLE_COVERAGE,
        GL_SAMPLE_MASK,
        GL_SCISSOR_TEST,
        GL_STENCIL_TEST
    };

    if (Version::current() >= Version(3, 1))
    {
        capabilities.push_back(GL_PRIMITIVE_RESTART);
        if (hasExtension(GLOW_ARB_ES3_compatibility))
        {
            capabilities.push_back(GL_PRIMITIVE_RESTART_FIXED_INDEX);
        }
        state->primitiveRestartIndex(getInteger(GL_PRIMITIVE_RESTART_INDEX));

        if (hasExtension(GLOW_ARB_sample_shading))
        {
            capabilities.push_back(GL_SAMPLE_SHADING);
        }
        if (hasExtension(GLOW_ARB_seamless_cube_map))
        {
            capabilities.push_back(GL_TEXTURE_CUBE_MAP_SEAMLESS);
        }
        if (hasExtension(GLOW_ARB_provoking_vertex))
        {
            state->provokingVertex(getEnum(GL_PROVOKING_VERTEX));
        }
        if (hasExtension(GLOW_KHR_debug)) {
            capabilities.push_back(GL_DEBUG_OUTPUT);
            capabilities.push_back(GL_DEBUG_OUTPUT_SYNCHRONOUS);
        }
    }

    for (GLenum capability : capabilities)
    {
        state->setEnabled(capability, glow::isEnabled(capability));
    }

    state->blendColor(getFloats<4>(GL_BLEND_COLOR));
    state->blendFuncSeparate(getEnum(GL_BLEND_SRC_RGB), getEnum(GL_BLEND_DST_RGB), getEnum(GL_BLEND_SRC_ALPHA), getEnum(GL_BLEND_DST_ALPHA));
    state->clearColor(getFloats<4>(GL_COLOR_CLEAR_VALUE));
    state->clearDepth(getFloat(GL_DEPTH_CLEAR_VALUE));
    state->clearStencil(getInteger(GL_STENCIL_CLEAR_VALUE));
    state->colorMask(getBooleans<4>(GL_COLOR_WRITEMASK));
    state->cullFace(getInteger(GL_CULL_FACE_MODE));
    state->depthFunc(getInteger(GL_DEPTH_FUNC));
    state->depthRange(getFloats<2>(GL_DEPTH_RANGE));
    state->frontFace(getEnum(GL_FRONT_FACE));
    state->logicOp(getInteger(GL_LOGIC_OP_MODE));
    state->pointParameter(GL_POINT_FADE_THRESHOLD_SIZE, getEnum(GL_POINT_FADE_THRESHOLD_SIZE));
    state->pointParameter(GL_POINT_SPRITE_COORD_ORIGIN, getEnum(GL_POINT_SPRITE_COORD_ORIGIN));
    state->pointSize(getFloat(GL_POINT_SIZE));
    state->polygonMode(GL_FRONT_AND_BACK, getInteger(GL_POLYGON_MODE)); // is it right to only set GL_FRONT_AND_BACK?
    state->polygonOffset(getFloat(GL_POLYGON_OFFSET_FACTOR), getFloat(GL_POLYGON_OFFSET_UNITS));
    state->sampleCoverage(getFloat(GL_SAMPLE_COVERAGE_VALUE), getBoolean(GL_SAMPLE_COVERAGE_INVERT));
    state->scissor(getIntegers<4>(GL_SCISSOR_BOX));
    state->stencilFuncSeparate(GL_FRONT, getEnum(GL_STENCIL_FUNC), getEnum(GL_STENCIL_REF), getEnum(GL_STENCIL_VALUE_MASK));
    state->stencilOpSeparate(GL_FRONT, getEnum(GL_STENCIL_FAIL), getEnum(GL_STENCIL_PASS_DEPTH_FAIL), getEnum(GL_STENCIL_PASS_DEPTH_PASS));
    state->stencilMaskSeparate(GL_FRONT, getEnum(GL_STENCIL_WRITEMASK));
    state->stencilFuncSeparate(GL_BACK, getEnum(GL_STENCIL_BACK_FUNC), getEnum(GL_STENCIL_BACK_REF), getEnum(GL_STENCIL_BACK_VALUE_MASK));
    state->stencilOpSeparate(GL_BACK, getEnum(GL_STENCIL_BACK_FAIL), getEnum(GL_STENCIL_BACK_PASS_DEPTH_FAIL), getEnum(GL_STENCIL_BACK_PASS_DEPTH_PASS));
    state->stencilMaskSeparate(GL_BACK, getEnum(GL_STENCIL_BACK_WRITEMASK));

    // pixel store
    std::vector<GLenum> pixelstoreParameters = {
        GL_PACK_SWAP_BYTES,
        GL_PACK_LSB_FIRST,
        GL_PACK_ROW_LENGTH,
        GL_PACK_IMAGE_HEIGHT,
        GL_PACK_SKIP_PIXELS,
        GL_PACK_SKIP_ROWS,
        GL_PACK_SKIP_IMAGES,
        GL_PACK_ALIGNMENT,
        GL_UNPACK_SWAP_BYTES,
        GL_UNPACK_LSB_FIRST,
        GL_UNPACK_ROW_LENGTH,
        GL_UNPACK_IMAGE_HEIGHT,
        GL_UNPACK_SKIP_PIXELS,
        GL_UNPACK_SKIP_ROWS,
        GL_UNPACK_SKIP_IMAGES,
        GL_UNPACK_ALIGNMENT
    };
    for (GLenum param : pixelstoreParameters)
    {
        state->pixelStore(param, getInteger(param));
    }

    return state;
}
Пример #10
0
void TheaRenderer::defineCamera()
{
    std::shared_ptr<MayaScene> mayaScene = MayaTo::getWorldPtr()->worldScenePtr;
    std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;

    for (auto obj : mayaScene->camList)
    {
        MFnCamera camFn(obj->mobject);

        if (!isCameraRenderable(obj->mobject) && (!(obj->dagPath == mayaScene->uiCamera)))
        {
            continue;
        }

        MMatrix m = obj->transformMatrices[0] * renderGlobals->globalConversionMatrix;
        uint width, height;
        int width_, height_;
        renderGlobals->getWidthHeight(width_, height_);
        width = width_;
        height = height_;
        bool success = true;
        float focalLen = camFn.focalLength();
        float focusDistance = getFloatAttr("focusDistance", camFn, 10.0f);
        focusDistance *= renderGlobals->scaleFactor;
        float fStop = getFloatAttr("fStop", camFn, 5.6f);

        TheaSDK::Transform cameraPos;
        matrixToTransform(m, cameraPos);

        TheaSDK::Transform tn;
        cameraPos = cameraPos * tn.RotateX(-DegToRad(180.0));

        if( renderGlobals->exportSceneFile )
        {
            TheaSDK::XML::Camera cam;
            cam.name = obj->shortName.asChar();
            cam.frame = cameraPos;
            cam.focalLength = focalLen;
            cam.pixels = width;
            cam.lines = height;
            cam.filmHeight = getFloatAttr("verticalFilmAperture", camFn, .9f) * 2.54f * 10.0f;
            cam.shutterSpeed = getFloatAttr("mtth_shutter_speed", camFn, 250.0);

            if( getBoolAttr("depthOfField", camFn, false))
            {
                if( renderGlobals->doDof)
                {
                    cam.focusDistance = focusDistance;
                    cam.depthOfField = getFloatAttr("mtth_focusRange", camFn, 0.1);
                    cam.autofocus = getBoolAttr("mtth_autoFocus", camFn, false);
                    //cam.depthOfField = (focusDistance-nearFocusPlane)/focusDistance;
                    cam.blades = getIntAttr("mtth_diaphragm_blades", camFn, 4);
                    int diaType;
                    getEnum(MString("mtth_diaphragm_type"), camFn, diaType);
                    if( diaType == 0)
                        cam.diaphragm = TheaSDK::Diaphragm::CircularDiaphragm;
                    else
                        cam.diaphragm = TheaSDK::Diaphragm::PolygonalDiaphragm;
                    cam.fNumber = fStop;
                }
            }

            sceneXML.addCamera(cam);
        } else {
            TheaSDK::CameraPointer cameraPtr = TheaSDK::AddStandardCamera(obj->shortName.asChar(), cameraPos, focalLen, width, height);
        }
        break; // only 1 cam at the moment
    }
}
Пример #11
0
bool mt@_RenderGlobals::getMt@Globals()
{
	logger.debug("mt@_RenderGlobals::get@Globals");

	MSelectionList @GlobalsList;
	@GlobalsList.add("@Globals");

	if( @GlobalsList.length() == 0 )
	{
		logger.debug("@Globals not found. Stopping.");
		return false;
	}
	MObject node;
	@GlobalsList.getDependNode(0, node);
	MFnDependencyNode @Globals(node);
	renderGlobalsMobject = node;

	try{

		if(!getInt(MString("translatorVerbosity"), @Globals, this->translatorVerbosity))
			throw("problem reading @Globals.translatorVerbosity");
		switch(this->translatorVerbosity)
		{
		case 0:
			logger.setLogLevel(Logging::Info);
			break;
		case 1:
			logger.setLogLevel(Logging::Error);
			break;
		case 2:
			logger.setLogLevel(Logging::Warning);
			break;
		case 3:
			logger.setLogLevel(Logging::Progress);
			break;
		case 4:
			logger.setLogLevel(Logging::Debug);
			break;
		}

//	------------- automatically created attributes start ----------- // 
//	------------- automatically created attributes end ----------- // 
		
		if(!getFloat(MString("filtersize"), @Globals, this->filterSize))
			throw("problem reading @Globals.filtersize");

		if(!getFloat(MString("gamma"), @Globals, this->gamma))
			throw("problem reading @Globals.gamma");

		if(!getInt(MString("samplesX"), @Globals, this->samplesX))
			throw("problem reading @Globals.samplesX");

		if(!getInt(MString("samplesY"), @Globals, this->samplesY))
			throw("problem reading @Globals.samplesY");

		if(!getInt(MString("minSamples"), @Globals, this->minSamples))
			throw("problem reading @Globals.minSamples");

		if(!getInt(MString("maxSamples"), @Globals, this->maxSamples))
			throw("problem reading @Globals.maxSamples");

		if(!getInt(MString("bitdepth"), @Globals, this->bitdepth))
			throw("problem reading @Globals.bitdepth");
	
		if(!getInt(MString("translatorVerbosity"), @Globals, this->translatorVerbosity))
			throw("problem reading @Globals.translatorVerbosity");

		if(!getInt(MString("rendererVerbosity"), @Globals, this->rendererVerbosity))
			throw("problem reading @Globals.rendererVerbosity");

		if(!getInt(MString("tilesize"), @Globals, this->tilesize))
			throw("problem reading @Globals.tilesize");

		if(!getInt(MString("threads"), @Globals, this->threads))
			throw("problem reading @Globals.threads");

		if(!getInt(MString("geotimesamples"), @Globals, this->geotimesamples))
			throw("problem reading @Globals.geotimesamples");

		if(!getInt(MString("xftimesamples"), @Globals, this->xftimesamples))
			throw("problem reading @Globals.xftimesamples");

		if(!getInt(MString("maxTraceDepth"), @Globals, this->maxTraceDepth))
			throw("problem reading @Globals.maxTraceDepth");

		if(!getBool(MString("createDefaultLight"), @Globals, this->createDefaultLight))
			throw("problem reading @Globals.createDefaultLight");

		if(!getBool(MString("detectShapeDeform"), @Globals, this->detectShapeDeform))
			throw("problem reading @Globals.detectShapeDeform");

		if(!getString(MString("optimizedTexturePath"), @Globals, this->optimizedTexturePath))
			throw("problem reading @Globals.optimizedTexturePath");

		if(!getString(MString("basePath"), @Globals, this->basePath))
			throw("problem reading @Globals.basePath");

		if(!getString(MString("imagePath"), @Globals, this->imagePath))
			throw("problem reading @Globals.imagePath");

		int id = 0;
		if(!getEnum(MString("imageFormat"),  @Globals, id, this->imageFormatString))
			throw("problem reading  @Globals.imageFormat");

		if(!getBool(MString("exportSceneFile"), @Globals, this->exportSceneFile))
			throw("problem reading @Globals.exportSceneFile");

		if(!getString(MString("exportSceneFileName"), @Globals, this->exportSceneFileName))
			throw("problem reading @Globals.exportSceneFileName");

		if(!getString(MString("imageName"), @Globals, this->imageName))
			throw("problem reading @Globals.imageName");

		if(!getBool(MString("adaptiveSampling"), @Globals, this->adaptiveSampling))
			throw("problem reading @Globals.adaptiveSampling");

		if(!getBool(MString("doMotionBlur"), @Globals, this->doMb))
			throw("problem reading @Globals.doMotionBlur");

		if(!getBool(MString("doDof"), @Globals, this->doDof))
			throw("problem reading @Globals.doDof");

		if(!getFloat(MString("sceneScale"), @Globals, this->sceneScale))
			throw("problem reading @Globals.sceneScale");

		this->sceneScaleMatrix.setToIdentity();
		this->sceneScaleMatrix.matrix[0][0] = this->sceneScale;
		this->sceneScaleMatrix.matrix[1][1] = this->sceneScale;
		this->sceneScaleMatrix.matrix[2][2] = this->sceneScale;

	}catch(char *errorMsg){

		logger.error(errorMsg);
		this->good = false;
		return false;	
	}
	return true;	

}
Пример #12
0
bool getEnum(const char *plugName, MFnDependencyNode& dn, int& id, MString& value)
{
	return getEnum(MString(plugName), dn, id, value);
}
Пример #13
0
	uint64_t DeltaCodeArr::lookup(uint64_t pos) const {
		Enum e;
		getEnum(pos, &e);
		return e.next();
	}
Пример #14
0
int32_t ZrtpConfigure::removeAlgo(AlgoTypes algoType, AlgorithmEnum& algo) {

    return removeAlgo(getEnum(algoType), algo);
}
Пример #15
0
int32_t ZrtpConfigure::addAlgoAt(AlgoTypes algoType, AlgorithmEnum& algo, int32_t index) {

    return addAlgoAt(getEnum(algoType), algo, index);
}
Пример #16
0
void CoronaRenderer::updateLight(std::shared_ptr<MayaObject> mobj)
{
	std::shared_ptr<mtco_MayaObject> obj(std::static_pointer_cast<mtco_MayaObject>(mobj));

	if (obj->lightShader != nullptr)
	{
		if (this->context.scene->hasLightShader(obj->lightShader))
			this->context.scene->deleteLightShader(obj->lightShader);
	}
	if (obj->removed)
		return;

	if (MayaTo::getWorldPtr()->renderType == MayaTo::MayaToWorld::WorldRenderType::IPRRENDER)
	{
		obj->transformMatrices.clear();
		obj->transformMatrices.push_back(obj->dagPath.inclusiveMatrix());
	}
	MFnDependencyNode rGlNode(getRenderGlobalsNode());
	MObject coronaGlobals = getRenderGlobalsNode();
	std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;
	std::shared_ptr<MayaScene> mayaScene = MayaTo::getWorldPtr()->worldScenePtr;

	MObjectArray nodeList;
	MStatus stat;

	MFnDependencyNode glFn(getRenderGlobalsNode());
	Corona::Rgb bgRgb = toCorona(getColorAttr("bgColor", glFn));
	int bgType = getEnumInt("bgType", glFn);

	MayaObject *sunLight = nullptr;

	MFnDependencyNode depFn(obj->mobject);

	if (obj->mobject.hasFn(MFn::kPointLight))
	{
		MColor col;
		getColor("color", depFn, col);
		float intensity = 1.0f;
		getFloat("intensity", depFn, intensity);
		int decay = 0;
		getEnum(MString("decayRate"), depFn, decay);
		MMatrix m = obj->transformMatrices[0] * renderGlobals->globalConversionMatrix;
		Corona::Pos LP(m[3][0], m[3][1], m[3][2]);
		PointLight *pl = new PointLight;
		pl->LP = LP;
		pl->distFactor = 1.0 / renderGlobals->scaleFactor;
		pl->lightColor = Corona::Rgb(col.r, col.g, col.b);
		pl->lightIntensity = intensity;
		getEnum(MString("decayRate"), depFn, pl->decayType);
		pl->lightRadius = getFloatAttr("lightRadius", depFn, 0.0) * renderGlobals->scaleFactor;
		pl->doShadows = getBoolAttr("useRayTraceShadows", depFn, true);
		col = getColorAttr("shadowColor", depFn);
		pl->shadowColor = Corona::Rgb(col.r, col.g, col.b);
		for (auto excludedObj : obj->excludedObjects)
		{
			pl->excludeList.nodes.push(excludedObj.get());
		}
		this->context.scene->addLightShader(pl);
		obj->lightShader = pl;
	}
	if (obj->mobject.hasFn(MFn::kSpotLight))
	{
		MVector lightDir(0, 0, -1);
		MColor col;
		getColor("color", depFn, col);
		float intensity = 1.0f;
		getFloat("intensity", depFn, intensity);
		MMatrix m = obj->transformMatrices[0] * renderGlobals->globalConversionMatrix;
		lightDir *= obj->transformMatrices[0] * renderGlobals->globalConversionMatrix;
		lightDir.normalize();
		Corona::Pos LP(m[3][0], m[3][1], m[3][2]);
		SpotLight *sl = new SpotLight;
		sl->LP = LP;
		sl->lightColor = Corona::Rgb(col.r, col.g, col.b);
		sl->lightIntensity = intensity;
		sl->LD = Corona::Dir(lightDir.x, lightDir.y, lightDir.z);
		sl->angle = 45.0f;
		sl->distFactor = 1.0 / renderGlobals->scaleFactor;
		getEnum(MString("decayRate"), depFn, sl->decayType);
		getFloat("coneAngle", depFn, sl->angle);
		getFloat("penumbraAngle", depFn, sl->penumbraAngle);
		getFloat("dropoff", depFn, sl->dropoff);
		sl->lightRadius = getFloatAttr("lightRadius", depFn, 0.0) * renderGlobals->scaleFactor;
		sl->doShadows = getBoolAttr("useRayTraceShadows", depFn, true);
		col = getColorAttr("shadowColor", depFn);
		sl->shadowColor = Corona::Rgb(col.r, col.g, col.b);
		for (auto excludedObj : obj->excludedObjects)
		{
			sl->excludeList.nodes.push(excludedObj.get());
		}
		Corona::AffineTm tm;
		setTransformationMatrix(sl->lightWorldInverseMatrix, m);
		ShadingNetwork network(obj->mobject);
		sl->lightColorMap = defineAttribute(MString("color"), depFn, network, oslRenderer);
		this->context.scene->addLightShader(sl);
		obj->lightShader = sl;
	}
	if (obj->mobject.hasFn(MFn::kDirectionalLight))
	{
		if (getBoolAttr("mtco_useAsSun", depFn, false))
		{
			if (sunLight != nullptr)
			{
				Logging::error(MString("A sun light is already defined, ignoring ") + obj->shortName);
				return;
			}
			sunLight = obj.get();
			MVector lightDir(0, 0, 1); // default dir light dir
			lightDir *= obj->transformMatrices[0];
			lightDir *= renderGlobals->globalConversionMatrix;
			lightDir.normalize();

			MColor sunColor(1);
			MFnDependencyNode sunNode(obj->mobject);
			getColor("color", sunNode, sunColor);
			sunColor *= getFloatAttr("intensity", sunNode, 1.0f);
			//float colorMultiplier colorMultiplier = getFloatAttr("mtco_sun_multiplier", sunNode, 1.0f);
			const float intensityFactor = (1.f - cos(Corona::SUN_PROJECTED_HALF_ANGLE)) / (1.f - cos(getFloatAttr("sunSizeMulti", rGlNode, 1.0f) * Corona::SUN_PROJECTED_HALF_ANGLE));
			sunColor *= intensityFactor * 1.0;// 2000000;
			Corona::Sun sun;

			Corona::ColorOrMap bgCoMap = this->context.scene->getBackground();
			SkyMap *sky = dynamic_cast<SkyMap *>(bgCoMap.getMap());
			Corona::Rgb avgColor(1, 1, 1);
			if (sky != nullptr)
			{
				avgColor = sky->sc();
			}

			Corona::Rgb sColor(sunColor.r, sunColor.g, sunColor.b);
			sun.color = sColor * avgColor;
			sun.active = true;
			sun.dirTo = Corona::Dir(lightDir.x, lightDir.y, lightDir.z).getNormalized();
			//sun.color = Corona::Rgb(sunColor.r,sunColor.g,sunColor.b);
			sun.visibleDirect = true;
			sun.visibleReflect = true;
			sun.visibleRefract = true;
			sun.sizeMultiplier = getFloatAttr("sunSizeMulti", rGlNode, 1.0);
			this->context.scene->getSun() = sun;
			if (sky != nullptr)
			{
				sky->initSky();
				this->context.scene->setBackground(bgCoMap);
				avgColor = sky->sc();
				this->context.scene->getSun().color = sColor * avgColor;
			}
		}
		else{
			MVector lightDir(0, 0, -1);
			MVector lightDirTangent(1, 0, 0);
			MVector lightDirBiTangent(0, 1, 0);
			MColor col;
			getColor("color", depFn, col);
			float intensity = 1.0f;
			getFloat("intensity", depFn, intensity);
			MMatrix m = obj->transformMatrices[0] * renderGlobals->globalConversionMatrix;
			lightDir *= m;
			lightDirTangent *= m;
			lightDirBiTangent *= m;
			lightDir.normalize();

			Corona::Pos LP(m[3][0], m[3][1], m[3][2]);
			DirectionalLight *dl = new DirectionalLight;
			dl->LP = LP;
			dl->lightColor = Corona::Rgb(col.r, col.g, col.b);
			dl->lightIntensity = intensity;
			dl->LD = Corona::Dir(lightDir.x, lightDir.y, lightDir.z);
			dl->LT = Corona::Dir(lightDirTangent.x, lightDirTangent.y, lightDirTangent.z);
			dl->LBT = Corona::Dir(lightDirBiTangent.x, lightDirBiTangent.y, lightDirBiTangent.z);
			dl->lightAngle = getFloatAttr("lightAngle", depFn, 0.0);
			dl->doShadows = getBoolAttr("useRayTraceShadows", depFn, true);
			col = getColorAttr("shadowColor", depFn);
			dl->shadowColor = Corona::Rgb(col.r, col.g, col.b);
			for (auto excludedObj : obj->excludedObjects)
			{
				dl->excludeList.nodes.push(excludedObj.get());
			}

			this->context.scene->addLightShader(dl);
			obj->lightShader = dl;
		}
	}
	if (obj->mobject.hasFn(MFn::kAreaLight))
	{
		MMatrix m = obj->transformMatrices[0] * renderGlobals->globalConversionMatrix;
		if ( obj->geom == nullptr)
			obj->geom = defineStdPlane();
		obj->geom->deleteAllInstances();

		Corona::AnimatedAffineTm atm;
		this->setAnimatedTransformationMatrix(atm, obj);
		obj->instance = obj->geom->addInstance(atm, nullptr, nullptr);
		if (getBoolAttr("mtco_envPortal", depFn, false))
		{
			Corona::EnviroPortalMtlData data;
			Corona::SharedPtr<Corona::IMaterial> mat = data.createMaterial();
			Corona::IMaterialSet ms = Corona::IMaterialSet(mat);
			obj->instance->addMaterial(ms);
		}
		else{
			Corona::NativeMtlData data;
			MColor lightColor = getColorAttr("color", depFn);
			float intensity = getFloatAttr("intensity", depFn, 1.0f);
			lightColor *= intensity;
			Corona::ColorOrMap com;
			// experimental direct corona texture
			if (getBoolAttr("mtco_noOSL", depFn, false))
			{
				MObject fileNode = getConnectedInNode(obj->mobject, "color");
				if ((fileNode != MObject::kNullObj) && (fileNode.hasFn(MFn::kFileTexture)))
				{
					MFnDependencyNode fileDep(fileNode);
					mtco_MapLoader loader(fileNode);
					Corona::SharedPtr<Corona::Abstract::Map> texmap = loader.loadBitmap("");
					com = Corona::ColorOrMap(bgRgb, texmap);
				}
			}
			else
			{
				com = defineAttribute(MString("color"), obj->mobject, oslRenderer);
				OSLMap *oslmap = (OSLMap *)com.getMap();
				if (oslmap != nullptr)
				{
					oslmap->multiplier = intensity;
				}
				else{
					Corona::Rgb col = com.getConstantColor() * intensity;
					com.setColor(col);
				}
			}

			data.emission.color = com;
			data.castsShadows = getBoolAttr("mtco_castShadows", depFn, false);

			for (auto excludedObj : obj->excludedObjects)
			{
				data.emission.excluded.nodes.push(excludedObj.get());
			}
			data.emission.disableSampling = false;
			data.emission.useTwoSidedEmission = getBoolAttr("mtco_doubleSided", depFn, false);

			Corona::SharedPtr<Corona::IMaterial> mat = data.createMaterial();
			Corona::IMaterialSet ms = Corona::IMaterialSet(mat);
			ms.visibility.direct = getBoolAttr("mtco_areaVisible", depFn, true);
			ms.visibility.reflect = getBoolAttr("mtco_visibleInReflection", depFn, true);
			ms.visibility.refract = getBoolAttr("mtco_visibleInRefraction", depFn, true);

			obj->instance->addMaterial(ms);
		}
	}
}
Пример #17
0
void TextureUnit::activate() const {
    if (!assigned_)
        assignUnit();
    glActiveTexture(getEnum());
}
Пример #18
0
void CoronaRenderer::defineLights()
{
	// first get the globals node and serach for a directional light connection
	MObject coronaGlobals = objectFromName(MString("coronaGlobals"));
	MObjectArray nodeList;
	MStatus stat;

	if( this->mtco_renderGlobals->useSunLightConnection )
	{
		getConnectedInNodes(MString("sunLightConnection"), coronaGlobals, nodeList);
		if( nodeList.length() > 0)
		{
			MObject sunObj = nodeList[0];
			if(sunObj.hasFn(MFn::kTransform))
			{
				// we suppose what's connected here is a dir light transform
				MVector lightDir(0, 0, 1); // default dir light dir
				MFnDagNode sunDagNode(sunObj);
				lightDir *= sunDagNode.transformationMatrix();
				lightDir *= this->mtco_renderGlobals->globalConversionMatrix;
				lightDir.normalize();
		
				MObject sunDagObj =	sunDagNode.child(0, &stat);
				if( !stat )
					logger.error("no child 0");
				MColor sunColor(1);
				float colorMultiplier = 1.0f;
				if(sunDagObj.hasFn(MFn::kDirectionalLight))
				{
					MFnDependencyNode sunNode(sunDagObj);
					getColor("color", sunNode, sunColor);
					getFloat("mtco_sun_multiplier", sunNode, colorMultiplier);
				}else{
					logger.warning(MString("Sun connection is not a directional light - using transform only."));
				}
				sunColor *= colorMultiplier * 10000.0;
				Corona::Sun sun;
				sun.active = true;
				sun.dirTo = Corona::Dir(lightDir.x, lightDir.y, lightDir.z).getNormalized();
				sun.color = Corona::Rgb(sunColor.r,sunColor.g,sunColor.b);
				sun.visibleDirect = true;
				sun.visibleReflect = true;
				sun.visibleRefract = true;
				sun.sizeMultiplier = 2.0f;
				this->context.scene->getSun() = sun;
			}
		}
	}

	for( size_t lightId = 0; lightId < this->mtco_scene->lightList.size();  lightId++)
	{
		mtco_MayaObject *obj =  (mtco_MayaObject *)this->mtco_scene->lightList[lightId];
		if(!obj->visible)
			continue;

		if( this->isSunLight(obj))
			continue;
		
		MFnDependencyNode depFn(obj->mobject);

		if( obj->mobject.hasFn(MFn::kPointLight))
		{
			MColor col;
			getColor("color", depFn, col);
			float intensity = 1.0f;
			getFloat("intensity", depFn, intensity);
			int decay = 0;
			getEnum(MString("decayRate"), depFn, decay);
			MMatrix m = obj->transformMatrices[0] * this->mtco_renderGlobals->globalConversionMatrix;
			Corona::Pos LP(m[3][0],m[3][1],m[3][2]);
			PointLight *pl = new PointLight;
			pl->LP = LP;
			pl->distFactor = 1.0/this->mtco_renderGlobals->scaleFactor;
			pl->lightColor = Corona::Rgb(col.r, col.g, col.b);
			pl->lightIntensity = intensity;
			getEnum(MString("decayRate"), depFn, pl->decayType);
			this->context.scene->addLightShader(pl);
		}
		if( obj->mobject.hasFn(MFn::kSpotLight))
		{
			MVector lightDir(0, 0, -1);
			MColor col;
			getColor("color", depFn, col);
			float intensity = 1.0f;
			getFloat("intensity", depFn, intensity);
			MMatrix m = obj->transformMatrices[0] * this->mtco_renderGlobals->globalConversionMatrix;
			lightDir *= obj->transformMatrices[0] * this->mtco_renderGlobals->globalConversionMatrix;
			lightDir.normalize();

			Corona::Pos LP(m[3][0],m[3][1],m[3][2]);
			SpotLight *sl = new SpotLight;
			sl->LP = LP;
			sl->lightColor = Corona::Rgb(col.r, col.g, col.b);
			sl->lightIntensity = intensity;
			sl->LD = Corona::Dir(lightDir.x, lightDir.y, lightDir.z);
			sl->angle = 45.0f;
			sl->distFactor = 1.0/this->mtco_renderGlobals->scaleFactor;
			getEnum(MString("decayRate"), depFn, sl->decayType);
			getFloat("coneAngle", depFn, sl->angle);
			getFloat("penumbraAngle", depFn, sl->penumbraAngle);
			getFloat("dropoff", depFn, sl->dropoff);
			this->context.scene->addLightShader(sl);
		}
		if( obj->mobject.hasFn(MFn::kDirectionalLight))
		{
			MVector lightDir(0, 0, -1);
			MColor col;
			getColor("color", depFn, col);
			float intensity = 1.0f;
			getFloat("intensity", depFn, intensity);
			MMatrix m = obj->transformMatrices[0] * this->mtco_renderGlobals->globalConversionMatrix;
			lightDir *= m;
			lightDir.normalize();

			Corona::Pos LP(m[3][0],m[3][1],m[3][2]);
			DirectionalLight *dl = new DirectionalLight;
			dl->LP = LP;
			dl->lightColor = Corona::Rgb(col.r, col.g, col.b);
			dl->lightIntensity = intensity;
			dl->LD = Corona::Dir(lightDir.x, lightDir.y, lightDir.z);
			this->context.scene->addLightShader(dl);
		}
		if( obj->mobject.hasFn(MFn::kAreaLight))
		{
			logger.warning(MString("Area light: ") + obj->shortName + " not yet supported.");
			MMatrix m = obj->transformMatrices[0] * this->mtco_renderGlobals->globalConversionMatrix;
			obj->geom = defineStdPlane();
			Corona::AnimatedAffineTm atm;
			this->setAnimatedTransformationMatrix(atm, obj);
			obj->instance = obj->geom->addInstance(atm, NULL, NULL);
			//this->defineMaterial(obj->instance, obj);

		}
	}


}
Пример #19
0
uint64_t DiffArray<IntArray>::lookup(uint64_t pos) const {
	Enum e;
	getEnum(pos, &e);
	return e.next();
}
Пример #20
0
	//------------------------------------
	DEnumPtr BinaryService::getEnum(const std::string& name) const {
		// If the separator is present, split group - typename
		std::pair<string, string> path = splitPath(name);

		return getEnum(path.first, path.second);
	}
Пример #21
0
bool ZrtpConfigure::containsAlgo(AlgoTypes algoType, AlgorithmEnum& algo) {

    return containsAlgo(getEnum(algoType), algo);
}
Пример #22
0
	void SolverParams::setStrategy(const char* strategyName)
	{
		strategy = getEnum(strategyName, strategiesG, cmdName, "--search");
	}
Пример #23
0
AlgorithmEnum& ZrtpConfigure::getAlgoAt(AlgoTypes algoType, int32_t index) {

    return getAlgoAt(getEnum(algoType), index);
}
Пример #24
0
Enum_t getVal(s57val_t *key, char *val) {
  return (key[getEnum(key, val)].atvl);
}
Пример #25
0
int32_t ZrtpConfigure::getNumConfiguredAlgos(AlgoTypes algoType) {

    return getNumConfiguredAlgos(getEnum(algoType));
}
Пример #26
0
void IndigoRenderer::defineCamera()
{
	std::shared_ptr<MayaScene> mayaScene = MayaTo::getWorldPtr()->worldScenePtr;
	std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;

	for (auto mobj : mayaScene->camList)
	{
		std::shared_ptr<mtin_MayaObject> icam(std::static_pointer_cast<mtin_MayaObject>(mobj));
		MFnCamera camFn(icam->dagPath);
		float lensRadius = 0.01;
		getFloat(MString("mtin_lensRadius"), camFn, lensRadius); 
		bool autoFocus = false;
		getBool(MString("mtin_autoFocus"), camFn, autoFocus); 

		MVector camUp = camFn.upDirection(MSpace::kWorld);
		MVector camView = camFn.viewDirection(MSpace::kWorld);
		MPoint camPos = camFn.eyePoint(MSpace::kWorld);

		MMatrix m = icam->transformMatrices[0];
		MPoint pos, rot, scale;
		getMatrixComponents(m, pos, rot, scale);
		camPos *= renderGlobals->globalConversionMatrix;
		camUp *= renderGlobals->globalConversionMatrix;
		camView *=  renderGlobals->globalConversionMatrix;
		camUp.normalize();
		camView.normalize();

		double focusDistance = camFn.focusDistance();
		double horizFilmAperture = camFn.horizontalFilmAperture();
		double focalLen = camFn.focalLength();

		logger.debug(MString("Using camera: ") + icam->fullName);

		Indigo::SceneNodeCameraRef cam(new Indigo::SceneNodeCamera());
		if( renderGlobals->doDof )
			cam->lens_radius = lensRadius;
		else
			cam->lens_radius = lensRadius / 10000.0;
		//apertureRadius = $iFocalLength / ($FStop * 2.0);
		float exposureDuration = 0.333f;
		getFloat("mtin_exposureDuration", camFn, exposureDuration);
		cam->exposure_duration = exposureDuration;
		cam->focus_distance = focusDistance * scale.x; // scale by global matrix scale
		cam->lens_sensor_dist = focalLen/1000.0;
		cam->autofocus = autoFocus;
		
		//cam->lens_shift_right_distance = 0;
		//cam->lens_shift_up_distance = 0;
	
		cam->sensor_width = (horizFilmAperture * 2.54 * 10.0) / 1000.0;
		cam->camera_type = Indigo::SceneNodeCamera::CameraType_ThinLensPerspective;

		cam->forwards = Indigo::Vec3d(camView.x, camView.y, camView.z);
		cam->up = Indigo::Vec3d(camUp.x, camUp.y, camUp.z);
		cam->setPos(Indigo::Vec3d(camPos.x, camPos.y, camPos.z));

		int appShape = 0;
		getEnum(MString("mtin_apertureShape"), camFn, appShape);
		if( appShape == 0) // circle
			cam->aperture_shape = new Indigo::ApertureCircular();
		if( appShape == 1) // generated
		{
			int numBlades = 5;
			float startAngle = 0.0f;
			float offset = 0.0f;
			float radius = 0.0f;
			getInt("mtin_numBlades", camFn, numBlades);
			getFloat("mtin_startAngle", camFn, startAngle);
			getFloat("mtin_bladeOffset", camFn, offset);
			getFloat("mtin_bladeCurvatureRadius", camFn, radius);
			cam->aperture_shape = new Indigo::ApertureGenerated(numBlades, offset, radius, startAngle);
		}
		if( appShape == 2) // image
		{
			MString fileName;
			getString(MString("mtin_appFile"), camFn, fileName);
			if( fileName.length() > 4)
				cam->aperture_shape = new Indigo::ApertureImage(fileName.asChar());
		}

		sceneRootRef->addChildNode(cam);
	}
}
Пример #27
0
void ZrtpConfigure::printConfiguredAlgos(AlgoTypes algoType) {

    return printConfiguredAlgos(getEnum(algoType));
}
Пример #28
0
void IndigoRenderer::defineEnvironment()
{

	std::shared_ptr<MayaScene> mayaScene = MayaTo::getWorldPtr()->worldScenePtr;
	std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;

	MFnDependencyNode gFn(getRenderGlobalsNode());

	switch (getEnumInt("environmentType", gFn))
	{
		case 0: // off
		{ 
			break;
		}
		case 1: // environment light map
		{
			MString texName;
			bool useTexture = false;
			Indigo::String texturePath = "";
			MObject fileTexObj;
			if( getConnectedFileTexturePath(MString("environmentColor"), MString("indigoGlobals"), texName, fileTexObj) )
			{
				useTexture = true;
				texturePath = texName.asChar();
			}
			MFnDependencyNode fileTexNode(fileTexObj);
			MColor bgColor = getColorAttr("environmentColor", gFn);
			int mapType = getIntAttr("environmentMapType", gFn, 0);
			Indigo::SceneNodeBackgroundSettingsRef background_settings(new Indigo::SceneNodeBackgroundSettings());
			Reference<Indigo::DiffuseMaterial> mat(new Indigo::DiffuseMaterial());
			// Albedo should be zero.
			mat->albedo = Reference<Indigo::WavelengthDependentParam>(new Indigo::ConstantWavelengthDependentParam(Reference<Indigo::Spectrum>(new Indigo::UniformSpectrum(0))));
			Indigo::Texture texture;

			if( useTexture )
			{
				texture.path = texturePath;
				texture.exponent = 1; // Since we will usually use a HDR image, the exponent (gamma) should be set to one.
				MColor colorGain(1,1,1);
				getColor("colorGain", fileTexNode, colorGain);
				MColor colorOffset(0,0,0);
				getColor("colorOffset", fileTexNode, colorOffset);
				double cg = (colorGain.r + colorGain.g + colorGain.b) / 3.0;
				double co = (colorOffset.r + colorOffset.g + colorOffset.b) / 3.0;
				texture.a = 0.0;
				texture.b = cg;
				texture.c = co;
				texture.tex_coord_generation = Reference<Indigo::TexCoordGenerator>(new Indigo::SphericalTexCoordGenerator(Reference<Indigo::Rotation>(new Indigo::MatrixRotation())));
				if( mapType == 1 )
				{
					texture.tex_coord_generation = Reference<Indigo::TexCoordGenerator>(new Indigo::SphericalEnvTexCoordGenerator(Reference<Indigo::Rotation>(new Indigo::MatrixRotation())));
				}
				mat->emission = Reference<Indigo::WavelengthDependentParam>(new Indigo::TextureWavelengthDependentParam(0));
				mat->textures.push_back(texture);
			}else{
				Indigo::RGBSpectrum *iBgColor = new Indigo::RGBSpectrum(Indigo::Vec3d(bgColor.r,bgColor.g,bgColor.b), 2.2);
				mat->emission = Reference<Indigo::WavelengthDependentParam>(new Indigo::ConstantWavelengthDependentParam(Reference<Indigo::Spectrum>(iBgColor)));
			}

			// Base emission is the emitted spectral radiance. No effect here?
			double multiplier = (double)getFloatAttr("environmentMapMultiplier", gFn, 1.0) * 1000.0;
			mat->base_emission = Reference<Indigo::WavelengthDependentParam>(new Indigo::ConstantWavelengthDependentParam(Reference<Indigo::Spectrum>(new Indigo::UniformSpectrum(multiplier))));

			background_settings->background_material = mat;
			sceneRootRef->addChildNode(background_settings);
			break;
		}
		case 2: // sun/sky
		{
			// first get the globals node and serach for a directional light connection
			MObjectArray nodeList;
			getConnectedInNodes(MString("sunLightConnection"), gFn.object(), nodeList);
			if( nodeList.length() > 0)
			{
				MObject sunObj = nodeList[0];
				if(sunObj.hasFn(MFn::kTransform))
				{
					// we suppose what's connected here is a dir light transform
					MVector lightDir(0,0,1); // default dir light dir
					MFnDagNode sunDagNode(sunObj);
					lightDir *= sunDagNode.transformationMatrix() * renderGlobals->globalConversionMatrix;
					lightDir.normalize();

					Indigo::SceneNodeBackgroundSettingsRef background_settings_node(new Indigo::SceneNodeBackgroundSettings());
					Reference<Indigo::SunSkyMaterial> sun_sky_mat(new Indigo::SunSkyMaterial());
					
					MString sky_model;
					int modelId;
					getEnum("sky_model", gFn, modelId, sky_model);
					sun_sky_mat->model = sky_model.asChar();
					sun_sky_mat->enable_sky = true;
					getBool("extra_atmospheric", gFn, sun_sky_mat->extra_atmospheric);
					sun_sky_mat->name = "sunsky";
					getUInt("sky_layer", gFn, sun_sky_mat->sky_layer);
					getUInt("sun_layer", gFn, sun_sky_mat->sun_layer);
					getDouble(MString("turbidity"), gFn, sun_sky_mat->turbidity);

					sun_sky_mat->sundir = Indigo::Vec3d(lightDir.x, lightDir.y, lightDir.z); // Direction to sun.

					background_settings_node->background_material = sun_sky_mat;
					sceneRootRef->addChildNode(background_settings_node);
				}
			}

			break;
		}
	}
}