コード例 #1
0
ファイル: Light.cpp プロジェクト: pviswanathan/DynamO
  void 
  RLight::pickingRender(const magnet::GL::Camera& cam, 
			const uint32_t offset)
  {
    if (!_visible) return;
    
    using namespace magnet::GL;

    magnet::math::Vector loc = getEyeLocationObjSpace();
    GLfloat pos[3] = {loc[0], loc[1], loc[2]};
    std::vector<GLfloat> position(pos, pos + 3);
    _glposition.init(position);
    
    _context->cleanupAttributeArrays();
    //Set the normals to zero so it is fully illuminated
    _context->setAttribute(Context::instanceScaleAttrIndex, 0.05, 0.05, 0.05, 1);
    
    _context->setAttribute(Context::vertexColorAttrIndex, 
			   (offset % 256) / 255.0, 
			   ((offset / 256) % 256) / 255.0, 
			   (((offset / 256) / 256) % 256) / 255.0, 
			   ((((offset / 256) / 256) / 256) % 256) / 255.0);
    
    _sphereShader.attach();
    _sphereShader["ProjectionMatrix"] = cam.getProjectionMatrix();
    _sphereShader["ViewMatrix"] = cam.getViewMatrix();
    _sphereShader["global_scale"] = GLfloat(1.0);
    _glposition.drawArray(magnet::GL::element_type::POINTS, 3);
    _sphereShader.detach();
  }
コード例 #2
0
ファイル: Light.hpp プロジェクト: MarkRunWu/DynamO
    /*! \brief Returns a projected light position.
     */
    magnet::math::Vector getEyespacePosition(const magnet::GL::Camera& camera) const
    {
      magnet::math::Vector vec = getPosition();
      std::tr1::array<GLfloat, 4> lightPos = {{GLfloat(vec[0]), GLfloat(vec[1]), GLfloat(vec[2]), 1.0f}};
      std::tr1::array<GLfloat, 4> lightPos_eyespace
	= camera.getViewMatrix() * lightPos;
      return magnet::math::Vector(lightPos_eyespace[0], lightPos_eyespace[1], 
				  lightPos_eyespace[2]);
    }
コード例 #3
0
ファイル: Light.cpp プロジェクト: pviswanathan/DynamO
  void 
  RLight::glRender(const magnet::GL::Camera& cam, 
		   RenderMode mode)
  {
    if (!_visible) return;
    
    using namespace magnet::GL;

    if (mode & RenderObj::COLOR)
      {
	magnet::math::Vector loc = getEyeLocationObjSpace();
	GLfloat pos[3] = {loc[0], loc[1], loc[2]};
	std::vector<GLfloat> position(pos, pos + 3);
	_glposition.init(position);

	_context->cleanupAttributeArrays();
	//Set the normals to zero so it is fully illuminated
	_context->setAttribute(Context::instanceScaleAttrIndex, 0.05, 0.05, 0.05, 1);
	_context->setAttribute(Context::vertexColorAttrIndex, 1, 1, 1, 1);
	
	if (_context->testExtension("GL_ARB_sample_shading"))
	  {
#ifndef GL_SAMPLE_SHADING
# define GL_SAMPLE_SHADING GL_SAMPLE_SHADING_ARB
#endif
	    glEnable(GL_SAMPLE_SHADING);
	    glMinSampleShadingARB(1.0);
	  }

	_sphereShader.attach();
	_sphereShader["ProjectionMatrix"] = cam.getProjectionMatrix();
	_sphereShader["ViewMatrix"] = cam.getViewMatrix();
	_sphereShader["global_scale"] = GLfloat(1.0);
	_glposition.drawArray(magnet::GL::element_type::POINTS, 3);
	_sphereShader.detach();

	if (_context->testExtension("GL_ARB_sample_shading"))
	  glDisable(GL_SAMPLE_SHADING);
      }
  }
コード例 #4
0
ファイル: SSAO.cpp プロジェクト: BigMacchia/DynamO
  void SSAOWrapper::invoke(GLint colorTextureUnit, 
			   size_t width, size_t height,
			   const magnet::GL::Camera& vp)
  {
    glActiveTextureARB(GL_TEXTURE7);
    glBindTexture(GL_TEXTURE_2D, _randomTexture);

    _filter.attach();

    _filter["radius"] = _radius;
    _filter["totStrength"] = _totStrength;
    _filter["depthDropoff"] = _dropoff;
    _filter["offset"] = GLfloat(std::max(width, height)) / _randomTextureSize;
    _filter["NormalsTex"] = 1;
    _filter["EyePosTex"] = 2;
    _filter["rnm"] = 7;
    _filter["ProjectionMatrix"] = vp.getProjectionMatrix();
    _filter["ViewMatrix"] = vp.getViewMatrix();

    _filter.invoke();
    _filter.detach();
  }