예제 #1
0
void MNSurfaceProperties::preRender( Renderer& renderer, const MaterialInstance& instance, const MaterialEntity& entity ) const
{
   const SurfaceProperties& props = instance.getSurfaceProperties();
   m_ambient->setValue( instance.data(), ( const Vector& )props.getAmbientColor() );
   m_diffuse->setValue( instance.data(), ( const Vector& )props.getDiffuseColor() );
   m_specular->setValue( instance.data(), ( const Vector& )props.getSpecularColor() );
   m_emissive->setValue( instance.data(), ( const Vector& )props.getEmissiveColor() );
   m_specularPower->setValue( instance.data(), props.getPower() );
}
예제 #2
0
void MaterialNode::createLayout( const MaterialInstance& host ) const
{
    for( OutputsMap::const_iterator it = m_outputs.begin(); it != m_outputs.end(); ++it )
    {
        (*it)->createLayout( host.data() );
    }

    onCreateLayout( host );
}
예제 #3
0
void MNCamera::preRender( Renderer& renderer, const MaterialInstance& instance, const MaterialEntity& entity ) const
{
   Camera& camera = renderer.getActiveCamera();

   RuntimeDataBuffer& data = instance.data();
   m_nearZ->setValue( data, camera.getNearClippingPlane() );
   m_farZ->setValue( data, camera.getFarClippingPlane() );
   m_viewportWidth->setValue( data, (float)renderer.getViewportWidth() );
   m_viewportHeight->setValue( data, (float)renderer.getViewportHeight() );

   Matrix invMtx, transInvMtx;

   const Matrix& viewMtx = camera.getViewMtx();
   invMtx.setInverse( viewMtx );
   transInvMtx.setTransposed( invMtx );
   m_invView->setValue( data, transInvMtx );

   const Matrix& projMtx = camera.getProjectionMtx();
   invMtx.setInverse( projMtx );
   transInvMtx.setTransposed( invMtx );
   m_invProj->setValue( data, transInvMtx );
}
예제 #4
0
void MNSpatialEntity::preRender( Renderer& renderer, const MaterialInstance& instance, const MaterialEntity& entity ) const
{
   RuntimeDataBuffer& data = instance.data();
   SpatialEntity* parentNode = data[ m_parentNode ];
   if ( !parentNode )
   {
      // initialize the parent entity if it wasn't initialized yet
      parentNode = DynamicCast< SpatialEntity >( entity.getParent() );
      data[ m_parentNode ] = parentNode;
   }

   if ( parentNode )
   {
      Camera& camera = renderer.getActiveCamera();

      const Matrix& worldMtx = parentNode->getGlobalMtx();
      m_worldMtx->setValue( data, worldMtx );

      Matrix worldView;
      worldView.setMul( worldMtx, camera.getViewMtx() );
      m_worldViewMtx->setValue( data, worldView );
   }
}
예제 #5
0
void MNBool::preRender( Renderer& renderer, const MaterialInstance& instance, const MaterialEntity& entity ) const
{
    m_output->setValue( instance.data(), m_value );
}
예제 #6
0
void MNSpatialEntity::onCreateLayout( const MaterialInstance& host ) const
{
   RuntimeDataBuffer& data = host.data();
   data.registerVar( m_parentNode );
   data[ m_parentNode ] = NULL;
}