Ejemplo n.º 1
0
void ClickSoundViewer::postSelection(const QPoint&)
{
    selTriId_ = selectedName();
    //cout << "selected triangle ID:  " << selTriId_ << endl;

    //// Now synthesize sound and play
    {
        qglviewer::Vec cam = camera()->position();
        const Point3d camPos( cam.x, cam.y, cam.z );

        const vector<Point3d>&  vtx = mesh_.vertices();
        const vector<Tuple3ui>& tgl = mesh_.surface_indices();
        Vector3d nml = Triangle<double>::normal( 
                vtx[tgl[selTriId_].x], 
                vtx[tgl[selTriId_].y], 
                vtx[tgl[selTriId_].z] );
        nml.normalize();
        audio_->play( mesh_.triangle_ids(selTriId_), nml, camPos );
    }
    
    if ( selTriId_ >= 0 ) update();
}