Beispiel #1
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);
}
Beispiel #2
0
void Sphere::loadMatricesToShader(ngl::TransformStack &_tx, const ngl::Mat4 &_globalTx, 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() * _globalTx;
  MV=M*_cam->getViewMatrix() ;
  MVP=MV*_cam->getProjectionMatrix();
  normalMatrix=MV;
  normalMatrix.inverse();
  shader->setShaderParamFromMat4("MVP",MVP);
  shader->setShaderParamFromMat3("normalMatrix",normalMatrix);
  shader->setRegisteredUniformFromColour("Colour",m_colour);

}
Beispiel #3
0
//----------------------------------------------------------------------------------------------------------------------
// 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);
}