Ejemplo n.º 1
0
Particle::Particle(
	IGameDef *gamedef,
	scene::ISceneManager* smgr,
	LocalPlayer *player,
	ClientEnvironment *env,
	v3f pos,
	v3f velocity,
	v3f acceleration,
	float expirationtime,
	float size,
	bool collisiondetection,
	bool vertical,
	video::ITexture *texture,
	v2f texpos,
	v2f texsize
):
	scene::ISceneNode(smgr->getRootSceneNode(), smgr)
{
	// Misc
	m_gamedef = gamedef;
	m_env = env;

	// Texture
	m_material.setFlag(video::EMF_LIGHTING, false);
	m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
	m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
	m_material.setFlag(video::EMF_FOG_ENABLE, true);
	m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
	m_material.setTexture(0, texture);
	m_texpos = texpos;
	m_texsize = texsize;


	// Particle related
	m_pos = pos;
	m_velocity = velocity;
	m_acceleration = acceleration;
	m_expiration = expirationtime;
	m_time = 0;
	m_player = player;
	m_size = size;
	m_collisiondetection = collisiondetection;
	m_vertical = vertical;

	// Irrlicht stuff
	m_collisionbox = core::aabbox3d<f32>
			(-size/2,-size/2,-size/2,size/2,size/2,size/2);
	this->setAutomaticCulling(scene::EAC_OFF);

	// Init lighting
	updateLight();

	// Init model
	updateVertices();
}
Ejemplo n.º 2
0
void Mentalism::update(float dt) {
	_time += dt;
	if(_time >= 13.0f) {
		_time = 0.0f;
	}
	_value = (int) _time;
	for(int i = 1; i <= SIZE; i++) {
		_light[SIZE - i] = _value % 2;
		_value /= 2; 
	}
	updateLight();
}
Ejemplo n.º 3
0
void QOgreDirectionalLightWidget::addLight()
{
    if (mSceneMgr->hasLight(name))
    {
        updateInfo();
    }
    else
    {
        Ogre::Light *light = mSceneMgr->createLight(name);
        light->setType(Ogre::Light::LT_DIRECTIONAL);
        updateLight();
    }
}
Ejemplo n.º 4
0
void QOgreSpotLightWidget::addLight()
{
    if (mSceneMgr->hasLight(name))
    {
        updateInfo();
    }
    else
    {
        Ogre::Light *light = mSceneMgr->createLight(name);
        light->setType(Ogre::Light::LT_SPOTLIGHT);
        updateLight();
    }
}
Ejemplo n.º 5
0
		buildOffscreenCommandBuffer();
		prepared = true;
	}

	virtual void render()
	{
		if (!prepared)
			return;
		vkDeviceWaitIdle(device);
		draw();
		vkDeviceWaitIdle(device);
		if (!paused)
		{
			updateLight();
Ejemplo n.º 6
0
      void MultiSetupPreview::paintGL()
      {
        if (!session()) return;

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
        visual::viewport(this);

        this->setupCamera();

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        updateLight();

        visual::with_current_context([&](QOpenGLFunctions& _)
        {
          auto* _canvas = session()->canvas();

          _.glEnable(GL_LIGHTING);
          _.glEnable(GL_DEPTH_TEST);
          if (_canvas)
          {
            glColor4f(1.0,1.0,1.0,1.0);
            _canvas->draw();
          }

          _.glDisable(GL_DEPTH_TEST);
          _.glDisable(GL_LIGHTING);
          for (auto& _projector : projectorViz_)
          {
            _projector.draw();
            _projector.drawPositioning(_canvas ? _canvas->center() : QVector3D(0,0,0));
          }

          for (auto& _projector : projectors_)
            session_->drawFrustumIntersection(_projector,"#00ccff",ProjectorViewMode::BOTH);

          _.glEnable(GL_DEPTH_TEST);

          for (auto& _projector : projectorViz_)
            _projector.drawHalo();
        });
      }
Ejemplo n.º 7
0
void Light::setLightType(LIGHT_TYPE type)
{
    lightType = type;

    if(lightType == LIGHT_SPOT)
    {
        position[3] = 1.0f;
    }
    else if (lightType == LIGHT_POINT)
    {
        position[3] = 1.0f;
        setCutoff(180.0f);
    }
    else if(lightType == LIGHT_DIRECTIONAL)
    {
        position[3] = 0.0f;
    }

    updateLight();
}
Ejemplo n.º 8
0
void ArnoldAnimationPatch::workerRender(FrameDeviceInfo frame) {
	std::stringstream ss;
	ss << "Received new frame: " << frame.time << "(" << frame.mode << ")";
	Logger::log(LDEBUG, ss.str());

	updateLight(frame.devices);
	bool success = ArnoldPatch::renderLoop(frame.devices);

#ifdef USE_ARNOLD
	// Dumps only when the image was rendered successfully for rendering.
	// If the worker was reset while rendering, doesn't dump.
	if (success && frame.mode == SimulationAnimationMode::RENDERING) {
		m_mem_frameManager->dump(frame.time, getBufferPointer(),
			getWidth(), getHeight());
		if (m_file_frameManager)
			m_file_frameManager->dump(frame.time, getBufferPointer(),
			getWidth(), getHeight());
	}
#endif
}
Ejemplo n.º 9
0
void Particle::step(float dtime)
{
	m_time += dtime;
	if (m_collisiondetection) {
		aabb3f box = m_collisionbox;
		v3f p_pos = m_pos * BS;
		v3f p_velocity = m_velocity * BS;
		collisionMoveResult r = collisionMoveSimple(m_env,
			m_gamedef, BS * 0.5, box, 0, dtime, &p_pos,
			&p_velocity, m_acceleration * BS);
		if (m_collision_removal && r.collides) {
			// force expiration of the particle
			m_expiration = -1.0;
		} else {
			m_pos = p_pos / BS;
			m_velocity = p_velocity / BS;
		}
	} else {
		m_velocity += m_acceleration * dtime;
		m_pos += m_velocity * dtime;
	}
	if (m_animation.type != TAT_NONE) {
		m_animation_time += dtime;
		int frame_length_i, frame_count;
		m_animation.determineParams(
				m_material.getTexture(0)->getSize(),
				&frame_count, &frame_length_i, NULL);
		float frame_length = frame_length_i / 1000.0;
		while (m_animation_time > frame_length) {
			m_animation_frame++;
			m_animation_time -= frame_length;
		}
	}

	// Update lighting
	updateLight();

	// Update model
	updateVertices();
}
Ejemplo n.º 10
0
void ArnoldAnimationPatch::renderSingleFrameToBuffer(const set<Device*>& devices, unsigned char* buff, int w, int h) {
  if (m_mode != SimulationAnimationMode::STOPPED)
    disableContinuousRenderMode();

  FrameDeviceInfo frame;

  // Fulls time and mode for frame info.
  createFrameInfoHeader(frame);
  createFrameInfoBody(devices, frame, true);

  std::stringstream ss;
  ss << "Rendering single frame: " << frame.time;
  Logger::log(LDEBUG, ss.str());

  // Interrupts the current rendering if in the interactive mode.
  if (m_mode == SimulationAnimationMode::INTERACTIVE ||
    m_mode == SimulationAnimationMode::RECORDING) {
    interruptRender();
  }

  // Render immediately.
  if (!m_interface->isDistributedOpen()) {
	  m_interface->init(this->toJSON());

	  // Check if we were able to open a connection
	  if (!m_interface->isDistributedOpen()) {
		  std::cerr << "Connection could not be established. " <<
			  "Check to make sure your host and port " <<
			  "parameters are correct and that nobody " <<
			  "else is currently using the remote renderer" << std::endl;

		  return;
	  }
  }

  bool success = false;
  float* bp = nullptr;
  int cid;

  if (CachingArnoldInterface* ci = dynamic_cast<CachingArnoldInterface*>(m_interface)) {
#ifdef USE_ARNOLD
    success = ci->render(devices, w, h, cid) == AI_SUCCESS;
#else
    success = ci->render(devices, w, h, cid) == 0;
#endif
    // we need to pull the proper buffer from the right context
    bp = ci->getBufferForContext(cid);
    frame.clear();
  }
  else {
    updateLight(devices);
    success = ArnoldPatch::renderLoop(devices);
    frame.clear();
    bp = getBufferPointer();
  }

  if (success) {
    for (int j = 0; j < h; j++) {
      for (int i = 0; i < w; i++) {
        int offset = (j * w + i) * 4;

        // convert to bytes
        buff[offset] = static_cast<unsigned char>(bp[offset + 2] * 0xff);
        buff[offset + 1] = static_cast<unsigned char>(bp[offset + 1] * 0xff);
        buff[offset + 2] = static_cast<unsigned char>(bp[offset + 0] * 0xff);
        buff[offset + 3] = static_cast<unsigned char>(bp[offset + 3] * 0xff);
      }
    }
  }

  if (CachingArnoldInterface* ci = dynamic_cast<CachingArnoldInterface*>(m_interface)) {
    ci->closeContext(cid);
  }
}
Ejemplo n.º 11
0
void ArnoldAnimationPatch::renderSingleFrame(const set<Device*>& devices, string basepath, string filename) {
  if (m_mode != SimulationAnimationMode::STOPPED)
    disableContinuousRenderMode();

  FrameDeviceInfo frame;

  // Fulls time and mode for frame info.
  createFrameInfoHeader(frame);
  createFrameInfoBody(devices, frame);

  std::stringstream ss;
  ss << "Rendering single frame: " << frame.time;
  Logger::log(LDEBUG, ss.str());

  // Interrupts the current rendering if in the interactive mode.
  if (m_mode == SimulationAnimationMode::INTERACTIVE ||
    m_mode == SimulationAnimationMode::RECORDING) {
    interruptRender();
  }

  // Render immediately.
  if (!m_interface->isDistributedOpen()) {
	  m_interface->init(this->toJSON());
	  
	  // Check if we were able to open a connection
	  if (!m_interface->isDistributedOpen()) {
		  std::cerr << "Connection could not be established. " << 
			  "Check to make sure your host and port " << 
			  "parameters are correct and that nobody " << 
			  "else is currently using the remote renderer" << std::endl;

		  return;
	  }
  }

  bool success = false;
  float* bp = nullptr;
  int cid;
  int w = getWidth();
  int h = getHeight();

  if (CachingArnoldInterface* ci = dynamic_cast<CachingArnoldInterface*>(m_interface)) {
#ifdef USE_ARNOLD
    success = ci->render(devices, w, h, cid) == AI_SUCCESS;
#else
    success = ci->render(devices, w, h, cid) == 0;
#endif
    // we need to pull the proper buffer from the right context
    bp = ci->getBufferForContext(cid);
    frame.clear();
  }
  else {
    updateLight(devices);
    success = ArnoldPatch::renderLoop(devices);
    frame.clear();
    bp = getBufferPointer();
  }

  if (success) {
    unsigned char *bytes = new unsigned char[w * h * 4];
    floats_to_bytes(bytes, bp, w, h);

    string file = basepath + "/" + filename + ".png";

    if (!imageio_save_image(file.c_str(), bytes, getWidth(), getHeight())) {
      std::stringstream err_ss;
      err_ss << "Error to write png: " << filename;
      Logger::log(ERR, err_ss.str());
    }
  }

  if (CachingArnoldInterface* ci = dynamic_cast<CachingArnoldInterface*>(m_interface)) {
    ci->closeContext(cid);
  }
}
Ejemplo n.º 12
0
void NGLDraw::timerEvent( )
{
  updateLight();
}
Ejemplo n.º 13
0
/* Render::renderScene: render scene */
void Render::renderScene(PMDObject *objs, const short *order, int num, Stage *stage, bool useMMDLikeCartoon, bool useCartoonRendering, float lightIntensity, const float *lightDirection, const float *lightColor, float shadowMappingFloorDensity)
{
   short i;
   bool toonLight = true;

   /* clear rendering buffer */
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

   glEnable(GL_CULL_FACE);
   glEnable(GL_BLEND);

   /* set model viwe matrix */
   glLoadIdentity();
   glMultMatrixf(m_rotMatrix);

   /* stage and shadhow */
   /* background */
   stage->renderBackground();
   /* enable stencil */
   glEnable(GL_STENCIL_TEST);
   glStencilFunc(GL_ALWAYS, 1, ~0);
   /* make stencil tag true */
   glStencilOp(GL_KEEP, GL_KEEP , GL_REPLACE);
   /* render floor */
   stage->renderFloor();
   /* render shadow stencil */
   glColorMask(0, 0, 0, 0) ;
   glDepthMask(0);
   glEnable(GL_STENCIL_TEST);
   glStencilFunc(GL_EQUAL, 1, ~0);
   /* increment 1 pixel stencil */
   glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
   /* render moodel */
   glDisable(GL_DEPTH_TEST);
   glPushMatrix();
   glMultMatrixf(stage->getShadowMatrix());
   for (i = 0; i < num; i++) {
      if (objs[order[i]].isEnable() == true) {
         objs[order[i]].getPMDModel()->renderForShadow();
      }
   }
   glPopMatrix();
   glEnable(GL_DEPTH_TEST);
   glColorMask(1, 1, 1, 1);
   glDepthMask(1);
   /* if stencil is 2, render shadow with blend on */
   glStencilFunc(GL_EQUAL, 2, ~0);
   glDisable(GL_LIGHTING);
   glColor4f(0.1f, 0.1f, 0.1f, shadowMappingFloorDensity);
   glDisable(GL_DEPTH_TEST);
   stage->renderFloor();
   glEnable(GL_DEPTH_TEST);
   glDisable(GL_STENCIL_TEST);
   glEnable(GL_LIGHTING);

   /* render model */
   for (i = 0; i < num; i++) {
      if (objs[order[i]].isEnable() == true) {
         if (objs[order[i]].getPMDModel()->getToonFlag() == false && toonLight == true) {
            /* disable toon lighting */
            updateLight(true, false, lightIntensity, lightDirection, lightColor);
            toonLight = false;
         } else if (objs[order[i]].getPMDModel()->getToonFlag() == true && toonLight == false) {
            /* enable toon lighting */
            updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
            toonLight = true;
         }
         objs[order[i]].getPMDModel()->renderModel();
         objs[order[i]].getPMDModel()->renderEdge();
      }
   }
   if (toonLight == false) {
      /* restore toon lighting */
      updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
   }
}
Ejemplo n.º 14
0
/* Render::renderSceneShadowMap: shadow mapping */
void Render::renderSceneShadowMap(PMDObject *objs, const short *order, int num, Stage *stage, bool useMMDLikeCartoon, bool useCartoonRendering, float lightIntensity, const float *lightDirection, const float *lightColor, int shadowMappingTextureSize, bool shadowMappingLightFirst, float shadowMappingSelfDensity)
{
   short i;
   GLint viewport[4]; /* store viewport */
   GLdouble modelview[16]; /* store model view transform */
   GLdouble projection[16]; /* store projection transform */
   bool toonLight = true;

#ifdef RENDER_SHADOWAUTOVIEW
   float eyeDist;
   btVector3 v;
#endif /* RENDER_SHADOWAUTOVIEW */

   static GLfloat lightdim[] = { 0.2f, 0.2f, 0.2f, 1.0f };
   static const GLfloat lightblk[] = { 0.0f, 0.0f, 0.0f, 1.0f };

   /* render the depth texture */
   /* store the current viewport */
   glGetIntegerv(GL_VIEWPORT, viewport);

   /* store the current projection matrix */
   glGetDoublev(GL_PROJECTION_MATRIX, projection);

   /* switch to FBO for depth buffer rendering */
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboID);

   /* clear the buffer */
   /* clear only the depth buffer, since other buffers will not be used */
   glClear(GL_DEPTH_BUFFER_BIT);

   /* set the viewport to the required texture size */
   glViewport(0, 0, shadowMappingTextureSize, shadowMappingTextureSize);

   /* reset the projection matrix */
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();

   /* set the model view matrix to make the light position as eye point and capture the whole scene in the view */
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();

#ifdef RENDER_SHADOWAUTOVIEW
   /* set the distance to cover all the model range */
   eyeDist = m_shadowMapAutoViewRadius / sinf(RENDER_SHADOWAUTOVIEWANGLE * 0.5f * 3.1415926f / 180.0f);
   /* set the perspective */
   gluPerspective(RENDER_SHADOWAUTOVIEWANGLE, 1.0, 1.0, eyeDist + m_shadowMapAutoViewRadius + 50.0f); /* +50.0f is needed to cover the background */
   /* the viewpoint should be at eyeDist far toward light direction from the model center */
   v = m_lightVec * eyeDist + m_shadowMapAutoViewEyePoint;
   gluLookAt(v.x(), v.y(), v.z(), m_shadowMapAutoViewEyePoint.x(), m_shadowMapAutoViewEyePoint.y(), m_shadowMapAutoViewEyePoint.z(), 0.0, 1.0, 0.0);
#else
   /* fixed view */
   gluPerspective(25.0, 1.0, 1.0, 120.0);
   gluLookAt(30.0, 77.0, 30.0, 0.0, 17.0, 0.0, 0.0, 1.0, 0.0);
#endif /* RENDER_SHADOWAUTOVIEW */

   /* keep the current model view for later process */
   glGetDoublev(GL_MODELVIEW_MATRIX, modelview);

   /* do not write into frame buffer other than depth information */
   glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

   /* also, lighting is not needed */
   glDisable(GL_LIGHTING);

   /* disable rendering the front surface to get the depth of back face */
   glCullFace(GL_FRONT);

   /* disable alpha test */
   glDisable(GL_ALPHA_TEST);

   /* we are now writing to depth texture using FBO, so disable the depth texture mapping here */
   glActiveTextureARB(GL_TEXTURE3_ARB);
   glDisable(GL_TEXTURE_2D);
   glActiveTextureARB(GL_TEXTURE0_ARB);

   /* set polygon offset to avoid "moire" */
   glEnable(GL_POLYGON_OFFSET_FILL);
   glPolygonOffset(4.0, 4.0);

   /* render objects for depth */
   /* only objects that wants to drop shadow should be rendered here */
   for (i = 0; i < num; i++) {
      if (objs[order[i]].isEnable() == true) {
         objs[order[i]].getPMDModel()->renderForShadow();
      }
   }

   /* reset the polygon offset */
   glDisable(GL_POLYGON_OFFSET_FILL);

   /* switch to default FBO */
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

   /* revert configurations to normal rendering */
   glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
   glMatrixMode(GL_PROJECTION);
   glLoadMatrixd(projection);
   glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
   glEnable(GL_LIGHTING);
   glCullFace(GL_BACK);
   glEnable(GL_ALPHA_TEST);

   /* clear all the buffers */
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

   /* render the full scene */
   /* set model view matrix, as the same as normal rendering */
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glMultMatrixf(m_rotMatrix);

   /* render the whole scene */
   if (shadowMappingLightFirst) {
      /* render light setting, later render only the shadow part with dark setting */
      stage->renderBackground();
      stage->renderFloor();
      for (i = 0; i < num; i++) {
         if (objs[order[i]].isEnable() == true) {
            if (objs[order[i]].getPMDModel()->getToonFlag() == false && toonLight == true) {
               /* disable toon lighting */
               updateLight(true, false, lightIntensity, lightDirection, lightColor);
               toonLight = false;
            } else if (objs[order[i]].getPMDModel()->getToonFlag() == true && toonLight == false) {
               /* enable toon lighting */
               updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
               toonLight = true;
            }
            objs[order[i]].getPMDModel()->renderModel();
            objs[order[i]].getPMDModel()->renderEdge();
         }
      }
      if (toonLight == false) {
         /* restore toon lighting */
         updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
      }
   } else {
      /* render in dark setting, later render only the non-shadow part with light setting */
      /* light setting for non-toon objects */
      lightdim[0] = lightdim[1] = lightdim[2] = 0.55f - 0.2f * shadowMappingSelfDensity;
      glLightfv(GL_LIGHT0, GL_DIFFUSE, lightdim);
      glLightfv(GL_LIGHT0, GL_AMBIENT, lightdim);
      glLightfv(GL_LIGHT0, GL_SPECULAR, lightblk);

      /* render the non-toon objects (back, floor, non-toon models) */
      stage->renderBackground();
      stage->renderFloor();
      for (i = 0; i < num; i++) {
         if (objs[order[i]].isEnable() == true && objs[order[i]].getPMDModel()->getToonFlag() == false)
            objs[order[i]].getPMDModel()->renderModel();
      }

      /* for toon objects, they should apply the model-defined toon texture color at texture coordinates (0, 0) for shadow rendering */
      /* so restore the light setting */
      if (useCartoonRendering == true)
         updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
      /* render the toon objects */
      for (i = 0; i < num; i++) {
         if (objs[order[i]].isEnable() == true && objs[order[i]].getPMDModel()->getToonFlag() == true) {
            /* set texture coordinates for shadow mapping */
            objs[order[i]].getPMDModel()->updateShadowColorTexCoord(shadowMappingSelfDensity);
            /* tell model to render with the shadow corrdinates */
            objs[order[i]].getPMDModel()->setSelfShadowDrawing(true);
            /* render model and edge */
            objs[order[i]].getPMDModel()->renderModel();
            objs[order[i]].getPMDModel()->renderEdge();
            /* disable shadow rendering */
            objs[order[i]].getPMDModel()->setSelfShadowDrawing(false);
         }
      }
      if (useCartoonRendering == false)
         updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
   }

   /* render the part clipped by the depth texture */
   /* activate the texture unit for shadow mapping and make it current */
   glActiveTextureARB(GL_TEXTURE3_ARB);

   /* set texture matrix (note: matrices should be set in reverse order) */
   glMatrixMode(GL_TEXTURE);
   glLoadIdentity();
   /* move the range from [-1,1] to [0,1] */
   glTranslated(0.5, 0.5, 0.5);
   glScaled(0.5, 0.5, 0.5);
   /* multiply the model view matrix when the depth texture was rendered */
   glMultMatrixd(modelview);
   /* multiply the inverse matrix of current model view matrix */
   glMultMatrixf(m_rotMatrixInv);

   /* revert to model view matrix mode */
   glMatrixMode(GL_MODELVIEW);

   /* enable texture mapping with texture coordinate generation */
   glEnable(GL_TEXTURE_2D);
   glEnable(GL_TEXTURE_GEN_S);
   glEnable(GL_TEXTURE_GEN_T);
   glEnable(GL_TEXTURE_GEN_R);
   glEnable(GL_TEXTURE_GEN_Q);

   /* bind the depth texture rendered at the first step */
   glBindTexture(GL_TEXTURE_2D, m_depthTextureID);

   /* depth texture set up was done, now switch current texture unit to default */
   glActiveTextureARB(GL_TEXTURE0_ARB);

   /* set depth func to allow overwrite for the same surface in the following rendering */
   glDepthFunc(GL_LEQUAL);

   if (shadowMappingLightFirst) {
      /* the area clipped by depth texture by alpha test is dark part */
      glAlphaFunc(GL_GEQUAL, 0.1f);

      /* light setting for non-toon objects */
      lightdim[0] = lightdim[1] = lightdim[2] = 0.55f - 0.2f * shadowMappingSelfDensity;
      glLightfv(GL_LIGHT0, GL_DIFFUSE, lightdim);
      glLightfv(GL_LIGHT0, GL_AMBIENT, lightdim);
      glLightfv(GL_LIGHT0, GL_SPECULAR, lightblk);

      /* render the non-toon objects (back, floor, non-toon models) */
      stage->renderBackground();
      stage->renderFloor();
      for (i = 0; i < num; i++) {
         if (objs[order[i]].isEnable() == true && objs[order[i]].getPMDModel()->getToonFlag() == false)
            objs[order[i]].getPMDModel()->renderModel();
      }

      /* for toon objects, they should apply the model-defined toon texture color at texture coordinates (0, 0) for shadow rendering */
      /* so restore the light setting */
      if (useCartoonRendering == true)
         updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
      /* render the toon objects */
      for (i = 0; i < num; i++) {
         if (objs[order[i]].isEnable() == true && objs[order[i]].getPMDModel()->getToonFlag() == true) {
            /* set texture coordinates for shadow mapping */
            objs[order[i]].getPMDModel()->updateShadowColorTexCoord(shadowMappingSelfDensity);
            /* tell model to render with the shadow corrdinates */
            objs[order[i]].getPMDModel()->setSelfShadowDrawing(true);
            /* render model and edge */
            objs[order[i]].getPMDModel()->renderModel();
            /* disable shadow rendering */
            objs[order[i]].getPMDModel()->setSelfShadowDrawing(false);
         }
      }
      if (useCartoonRendering == false)
         updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
   } else {
      /* the area clipped by depth texture by alpha test is light part */
      glAlphaFunc(GL_GEQUAL, 0.001f);
      stage->renderBackground();
      stage->renderFloor();
      for (i = 0; i < num; i++) {
         if (objs[order[i]].isEnable() == true) {
            if (objs[order[i]].getPMDModel()->getToonFlag() == false && toonLight == true) {
               /* disable toon lighting */
               updateLight(true, false, lightIntensity, lightDirection, lightColor);
               toonLight = false;
            } else if (objs[order[i]].getPMDModel()->getToonFlag() == true && toonLight == false) {
               /* enable toon lighting */
               updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
               toonLight = true;
            }
            objs[order[i]].getPMDModel()->renderModel();
         }
      }
      if (toonLight == false) {
         /* restore toon lighting */
         updateLight(useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor);
      }
   }

   /* reset settings */
   glDepthFunc(GL_LESS);
   glAlphaFunc(GL_GEQUAL, 0.05f);

   glActiveTextureARB(GL_TEXTURE3_ARB);
   glDisable(GL_TEXTURE_GEN_S);
   glDisable(GL_TEXTURE_GEN_T);
   glDisable(GL_TEXTURE_GEN_R);
   glDisable(GL_TEXTURE_GEN_Q);
   glDisable(GL_TEXTURE_2D);
   glActiveTextureARB(GL_TEXTURE0_ARB);
}
Ejemplo n.º 15
0
//!
//! Clones an Ogre::MovableObject.
//!
//! Is needed because OGRE does not provide clone functions for cameras and
//! lights.
//!
//! \param movableObject The object to clone.
//! \param name The name to use for the object.
//! \param sceneManager The scene manager to use for creating the object.
//! \return The cloned object.
//!
Ogre::MovableObject * OgreTools::cloneMovableObject ( Ogre::MovableObject *movableObject, const QString &name, Ogre::SceneManager *sceneManager /* =  0 */ )
{
    // make sure the given object is valid
    if (!movableObject) {
        Log::error("The given movable object is invalid.", "OgreTools::cloneMovableObject");
        return 0;
    }

    // make sure a valid scene manager is available
    if (!sceneManager)
        sceneManager = movableObject->_getManager();
    if (!sceneManager) {
        Log::error("No valid scene manager available.", "OgreTools::cloneMovableObject");
        return 0;
    }

    Ogre::MovableObject *result = 0;
    Ogre::String typeName = movableObject->getMovableType();
    if (typeName == "Entity") {
        // clone entity
        Ogre::Entity *entity = dynamic_cast<Ogre::Entity *>(movableObject);
        //movableObjectCopy = entity->clone(name.toStdString());
        Ogre::Entity *entityCopy = sceneManager->createEntity(name.toStdString(), entity->getMesh()->getName());
        Ogre::AnimationStateSet *animationStateSet = entity->getAllAnimationStates();
        Ogre::AnimationStateSet *animationStateSetCopy  = entityCopy->getAllAnimationStates();
        // set the same blend mode on entity copy
        if (entity && entityCopy) {
            if (entity->hasSkeleton() && entityCopy->hasSkeleton()) {
                Ogre::Skeleton *skeleton = entity->getSkeleton();
                Ogre::Skeleton *skeletonCopy = entityCopy->getSkeleton();
                skeletonCopy->setBlendMode(skeleton->getBlendMode());
            }
        }
        // copy all animation states
        if (animationStateSet && animationStateSetCopy) {
            Ogre::AnimationStateIterator animationStateIter = animationStateSet->getAnimationStateIterator();
            Ogre::AnimationStateIterator animationStateCopyIter = animationStateSetCopy->getAnimationStateIterator();
            while (animationStateIter.hasMoreElements()) {
                if (!animationStateCopyIter.hasMoreElements())
                    break;
                Ogre::AnimationState *animationState = animationStateIter.getNext();
                Ogre::AnimationState *animationStateCopy = animationStateCopyIter.getNext();
                animationStateCopy->setLoop(animationState->getLoop());
                //bool enabled = animationState->getEnabled();
                //animationStateCopy->setEnabled(animationState->getEnabled());
                animationStateCopy->setEnabled(true);
                animationStateCopy->setTimePosition(animationState->getTimePosition());
            }
        }

        // create a new container for the cloned entity
        OgreContainer *entityCopyContainer = new OgreContainer(entityCopy);
        entityCopy->setUserAny(Ogre::Any(entityCopyContainer));
        if (!entity->getUserAny().isEmpty()) {
            OgreContainer *entityContainer = Ogre::any_cast<OgreContainer *>(entity->getUserAny());
			if (entityContainer) {
                QObject::connect(entityContainer, SIGNAL(animationStateUpdated(const QString &, double)), entityCopyContainer, SLOT(updateAnimationState(const QString &, double)));
				QObject::connect(entityContainer, SIGNAL(boneTransformUpdated(const QString &, double, double, double, double, double, double)), entityCopyContainer, SLOT(updateBoneTransform(const QString &, double, double, double, double, double, double)));
			}
        }
        result = dynamic_cast<Ogre::MovableObject *>(entityCopy);
    } else if (typeName == "Light") {
        // clone light
        Ogre::Light *light = dynamic_cast<Ogre::Light *>(movableObject);
        Ogre::Light *lightCopy = sceneManager->createLight(name.toStdString());
        lightCopy->setType(light->getType());
        lightCopy->setDiffuseColour(light->getDiffuseColour());
        lightCopy->setSpecularColour(light->getSpecularColour());
        lightCopy->setAttenuation(light->getAttenuationRange(), light->getAttenuationConstant(), light->getAttenuationLinear(), light->getAttenuationQuadric());
        lightCopy->setPosition(light->getPosition());
        lightCopy->setDirection(light->getDirection());
        if (lightCopy->getType() == Ogre::Light::LT_SPOTLIGHT)
            lightCopy->setSpotlightRange(light->getSpotlightInnerAngle(), light->getSpotlightOuterAngle(), light->getSpotlightFalloff());
        lightCopy->setPowerScale(light->getPowerScale());
        lightCopy->setCastShadows(light->getCastShadows());

        // create a new container for the cloned light
        OgreContainer *lightCopyContainer = new OgreContainer(lightCopy);
        lightCopy->setUserAny(Ogre::Any(lightCopyContainer));
        if (!light->getUserAny().isEmpty()) {
            OgreContainer *lightContainer = Ogre::any_cast<OgreContainer *>(light->getUserAny());
            if (lightContainer)
                QObject::connect(lightContainer, SIGNAL(sceneNodeUpdated()), lightCopyContainer, SLOT(updateLight()));
        }
        result = dynamic_cast<Ogre::MovableObject *>(lightCopy);
    } else if (typeName == "Camera") {
        // clone camera
        Ogre::Camera *camera = dynamic_cast<Ogre::Camera *>(movableObject);
        Ogre::Camera *cameraCopy = sceneManager->createCamera(name.toStdString());
        //cameraCopy->setCustomParameter(0, camera->getCustomParameter(0));
        cameraCopy->setAspectRatio(camera->getAspectRatio());
        cameraCopy->setAutoAspectRatio(camera->getAutoAspectRatio());
        //cameraCopy->setAutoTracking(...);
        cameraCopy->setCastShadows(camera->getCastsShadows());
        //cameraCopy->setCullingFrustum(camera->getCullingFrustum());
        //cameraCopy->setCustomParameter(...);
        //cameraCopy->setCustomProjectionMatrix(..);
        //cameraCopy->setCustomViewMatrix(..);
        //cameraCopy->setDebugDisplayEnabled(...);
        //cameraCopy->setDefaultQueryFlags(...);
        //cameraCopy->setDefaultVisibilityFlags(...);
        cameraCopy->setDirection(camera->getDirection());
        //cameraCopy->setFixedYawAxis(...);
        cameraCopy->setFocalLength(camera->getFocalLength());
        cameraCopy->setFOVy(camera->getFOVy());

        //Ogre::Real left;
        //Ogre::Real right;
        //Ogre::Real top;
        //Ogre::Real bottom;
        //camera->getFrustumExtents(left, right, top, bottom);
        //cameraCopy->setFrustumExtents(left, right, top, bottom);
        //cameraCopy->setFrustumOffset(camera->getFrustumOffset());
        //cameraCopy->setListener(camera->getListener());
        cameraCopy->setLodBias(camera->getLodBias());
        //cameraCopy->setLodCamera(camera->getLodCamera());
        cameraCopy->setNearClipDistance(camera->getNearClipDistance());
        cameraCopy->setFarClipDistance(camera->getFarClipDistance());
        cameraCopy->setOrientation(camera->getOrientation());
        //cameraCopy->setOrthoWindow(...);
        //cameraCopy->setOrthoWindowHeight(...);
        //cameraCopy->setOrthoWindowWidth(...);
        cameraCopy->setPolygonMode(camera->getPolygonMode());
        cameraCopy->setPolygonModeOverrideable(camera->getPolygonModeOverrideable());
        cameraCopy->setPosition(camera->getPosition());
        cameraCopy->setProjectionType(camera->getProjectionType());
        cameraCopy->setQueryFlags(camera->getQueryFlags());
        cameraCopy->setRenderingDistance(camera->getRenderingDistance());
        cameraCopy->setRenderQueueGroup(camera->getRenderQueueGroup());
        //cameraCopy->setRenderSystemData(camera->getRenderSystemData());
        cameraCopy->setUseIdentityProjection(camera->getUseIdentityProjection());
        cameraCopy->setUseIdentityView(camera->getUseIdentityView());
        //cameraCopy->setUserAny(camera->getUserAny());
        cameraCopy->setUseRenderingDistance(camera->getUseRenderingDistance());
        //cameraCopy->setUserObject(camera->getUserObject());
        cameraCopy->setVisibilityFlags(camera->getVisibilityFlags());
        cameraCopy->setVisible(camera->getVisible());
        //cameraCopy->setWindow(...);

        if (!movableObject->getUserAny().isEmpty()) {
            CameraInfo *sourceCameraInfo = Ogre::any_cast<CameraInfo *>(movableObject->getUserAny());
            if (sourceCameraInfo) {
                CameraInfo *targetCameraInfo = new CameraInfo();
                targetCameraInfo->width = sourceCameraInfo->width;
                targetCameraInfo->height = sourceCameraInfo->height;
                dynamic_cast<Ogre::MovableObject *>(cameraCopy)->setUserAny(Ogre::Any(targetCameraInfo));
            }
        }

        //// Setup connections for instances
        //SceneNode *targetSceneNode = new SceneNode(cameraCopy);
        //((Ogre::MovableObject *)cameraCopy)->setUserAny(Ogre::Any(targetSceneNode));
        //if (!((Ogre::MovableObject *)camera)->getUserAny().isEmpty()) {
        //    SceneNode *sourceSceneNode = Ogre::any_cast<SceneNode *>(((Ogre::MovableObject *)camera)->getUserAny());
        //    if (sourceSceneNode) {
        //        QObject::connect(sourceSceneNode, SIGNAL(sceneNodeUpdated()), targetSceneNode, SLOT(updateSceneNode()));
        //    }
        //}

        result = dynamic_cast<Ogre::MovableObject *>(cameraCopy);
    }

    if (!result)
        Log::error(QString("Could not clone movable object \"%1\" of type \"%2\".").arg(movableObject->getName().c_str()).arg(typeName.c_str()), "OgreTools::cloneMovableObject");

    return result;
}
Ejemplo n.º 16
0
Particle::Particle(
	IGameDef *gamedef,
	LocalPlayer *player,
	ClientEnvironment *env,
	v3f pos,
	v3f velocity,
	v3f acceleration,
	float expirationtime,
	float size,
	bool collisiondetection,
	bool collision_removal,
	bool object_collision,
	bool vertical,
	video::ITexture *texture,
	v2f texpos,
	v2f texsize,
	const struct TileAnimationParams &anim,
	u8 glow,
	video::SColor color
):
	scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
		RenderingEngine::get_scene_manager())
{
	// Misc
	m_gamedef = gamedef;
	m_env = env;

	// Texture
	m_material.setFlag(video::EMF_LIGHTING, false);
	m_material.setFlag(video::EMF_BACK_FACE_CULLING, false);
	m_material.setFlag(video::EMF_BILINEAR_FILTER, false);
	m_material.setFlag(video::EMF_FOG_ENABLE, true);
	m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
	m_material.setTexture(0, texture);
	m_texpos = texpos;
	m_texsize = texsize;
	m_animation = anim;

	// Color
	m_base_color = color;
	m_color = color;

	// Particle related
	m_pos = pos;
	m_velocity = velocity;
	m_acceleration = acceleration;
	m_expiration = expirationtime;
	m_player = player;
	m_size = size;
	m_collisiondetection = collisiondetection;
	m_collision_removal = collision_removal;
	m_object_collision = object_collision;
	m_vertical = vertical;
	m_glow = glow;

	// Irrlicht stuff
	m_collisionbox = aabb3f
			(-size/2,-size/2,-size/2,size/2,size/2,size/2);
	this->setAutomaticCulling(scene::EAC_OFF);

	// Init lighting
	updateLight();

	// Init model
	updateVertices();
}
Ejemplo n.º 17
0
void CoronaRenderer::defineLights()
{
	//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 depFn(getRenderGlobalsNode());
	//Corona::Rgb bgRgb = toCorona(getColorAttr("bgColor", depFn));
	//int bgType = getEnumInt("bgType", depFn);

	MayaObject *sunLight = nullptr;
	for (auto mobj : mayaScene->lightList)
	{
		std::shared_ptr<mtco_MayaObject> obj(std::static_pointer_cast<mtco_MayaObject>(mobj));

		if(!obj->visible)
			continue;

		MFnDependencyNode depFn(obj->mobject);
		if (getBoolAttr("mtco_useAsSun", depFn, false))
		{
			if (sunLight != nullptr)
			{
				Logging::error(MString("A sun light is already defined, ignoring ") + obj->shortName);
				continue;
			}
			sunLight = mobj.get();
		}
		updateLight(mobj);

		//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);
		//}
		//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);
		//}
		//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);
		//			continue;
		//		}
		//		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;
		//		sky->initSky();
		//		if (sky != nullptr)
		//		{
		//			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);
		//	}
		//}
		//if( obj->mobject.hasFn(MFn::kAreaLight))
		//{
		//	MMatrix m = obj->transformMatrices[0] * renderGlobals->globalConversionMatrix;
		//	obj->geom = defineStdPlane();
		//	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);
		//	}
		//}
	}
}