Eegeo::m44 ExampleMeshRenderable::CalcModelViewProjection(const Eegeo::dv3& ecefCameraPosition, const Eegeo::m44& viewProjection, const float environmentFlatteningScale) const
    {
        const Eegeo::dv3& flattenedEcefPosition = m_environmentFlattenTranslate
            ? Eegeo::Rendering::EnvironmentFlatteningService::GetScaledPointEcef(GetEcefPosition(), environmentFlatteningScale)
            : GetEcefPosition();
        
        const Eegeo::v3& cameraRelativeModelOrigin = (flattenedEcefPosition - ecefCameraPosition).ToSingle();
        Eegeo::m44 translateRotate;
        translateRotate.SetFromBasis(m_orientationEcef.GetRow(0), m_orientationEcef.GetRow(1), m_orientationEcef.GetRow(2), cameraRelativeModelOrigin);

        Eegeo::m44 scale;
        if (m_environmentFlattenScale)
        {
            scale.Scale(Eegeo::v3(1.0f, environmentFlatteningScale, 1.0f));
        }
        else
        {
            scale.Identity();
        }
        
        Eegeo::m44 orientedCameraRelativeModel;
        Eegeo::m44::Mul(orientedCameraRelativeModel, translateRotate, scale);
        
        
        Eegeo::m44 modelViewProjection;
        Eegeo::m44::Mul(modelViewProjection, viewProjection, orientedCameraRelativeModel);
        return modelViewProjection;
    }
 void BoundsVisualiser::Draw(const Eegeo::v3& minExtents, const Eegeo::v3& maxExtents)
 {
     Build(minExtents, maxExtents);
     
     Eegeo_GL(glUseProgram(m_pShader->m_programHandle));
     
     Eegeo::m44 mvp;
     Eegeo::m44 w;
     w.Identity();
     Eegeo::m44::Mul(mvp, renderContext.GetViewProjectionMatrix(), w);
     
     Eegeo_GL(glUniformMatrix4fv(m_pShader->m_mvpUniform, 1, 0, (const GLfloat*)&mvp));
     
     Eegeo_GL(glEnableVertexAttribArray(m_pShader->m_positionSlot));
     
     Eegeo_GL(glBindBuffer(GL_ARRAY_BUFFER, m_glVertexBuffer));
     Eegeo_GL(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_glIndexBuffer));
     
     Eegeo_GL(glVertexAttribPointer(m_pShader->m_positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0));
     
     for(u32 j = 0; j < NumIndices; j+=3)
     {
         Eegeo_GL(glDrawElements(GL_LINE_LOOP, 3, GL_UNSIGNED_SHORT, (void*)(j * 2)));
     }
     
     Eegeo_GL(glBindBuffer (GL_ARRAY_BUFFER, 0));
     Eegeo_GL(glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0));
     
     DestroyGeometry();
 }