Exemplo n.º 1
0
//----------------------------------------------------------------------------------------------------------------------
void GLWindow::loadMatricesToShader(
                                     ngl::TransformStack &_tx
                                   )
{
  ngl::ShaderLib *shader=ngl::ShaderLib::instance();

  ngl::Mat4 MV;
  ngl::Mat4 MVP;
  ngl::Mat3 normalMatrix;
  ngl::Mat4 M;
  M=_tx.getCurrAndGlobal().getMatrix();
  MV= _tx.getCurrAndGlobal().getMatrix()*m_cam->getViewMatrix();
  MVP= M*m_cam->getVPMatrix();
  normalMatrix=MV;
  normalMatrix.inverse();
  shader->setShaderParamFromMat4("MV",MV);
  shader->setShaderParamFromMat4("MVP",MVP);
  shader->setShaderParamFromMat3("normalMatrix",normalMatrix);
  shader->setShaderParamFromMat4("M",M);
}
Exemplo n.º 2
0
//----------------------------------------------------------------------------------------------------------------------
void Axis::loadMatricesToShader(ngl::TransformStack &_tx)
{
  ngl::ShaderLib *shader=ngl::ShaderLib::instance();
  (*shader)["Surface"]->use();
  ngl::Matrix MV;
  ngl::Matrix MVP;
  ngl::Matrix M;
  M=_tx.getCurrentTransform().getMatrix();
  MV=  _tx.getCurrAndGlobal().getMatrix()*m_cam->getViewMatrix();
  MVP=  MV*m_cam->getProjectionMatrix();
  shader->setShaderParamFromMatrix("MVP",MVP);
}
Exemplo n.º 3
0
Arquivo: Body.cpp Projeto: NCCA/webgl
//----------------------------------------------------------------------------------------------------------------------
// Funtion to load matrices to shader for the body sphere's created
//----------------------------------------------------------------------------------------------------------------------
void Body::loadMatricesToShader(
                                ngl::TransformStack &_tx,
                                ngl::Camera *_cam
                               ) const
{
  ngl::ShaderLib *shader=ngl::ShaderLib::instance();

  ngl::Mat4 MV;
  ngl::Mat4 MVP;
  ngl::Mat3 normalMatrix;
  ngl::Mat4 M;
  M=_tx.getCurrentTransform().getMatrix();
  MV=_tx.getCurrAndGlobal().getMatrix()*_cam->getViewMatrix() ;
  MVP=MV*_cam->getProjectionMatrix();
  normalMatrix=MV;
  normalMatrix.inverse();
  shader->setShaderParamFromMat4("MV",MV);
  shader->setShaderParamFromMat4("MVP",MVP);
  shader->setShaderParamFromMat3("normalMatrix",normalMatrix);
  shader->setShaderParamFromMat4("M",M);
}