Beispiel #1
0
void ClickSoundViewer::draw_obj()
{
    const vector<Point3d>&  vtx = mesh_.vertices();
    const vector<Tuple3ui>& tgl = mesh_.surface_indices();
    const vector<Vector3d>& nml = mesh_.normals();

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);

    glVertexPointer(3, GL_DOUBLE, 0, (const GLvoid*)(vtx.data()));
    glNormalPointer(GL_DOUBLE, 0, (const GLvoid*)(nml.data()));
    glDrawElements(GL_TRIANGLES, tgl.size()*3, GL_UNSIGNED_INT, (const GLvoid*)(tgl.data()));
}
Beispiel #2
0
void ClickSoundViewer::drawWithNames()
{
    glEnableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);

    glVertexPointer(3, GL_DOUBLE, 0, (const GLvoid*)(mesh_.vertices().data()));
    const vector< Tuple3ui >& tgl = mesh_.triangles();
    for(size_t i = 0;i < tgl.size();++ i)
    {
        glPushName(i);
        glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, (const GLvoid*)&tgl[i]); 
        glPopName();
    }
}
Beispiel #3
0
void ClickSoundViewer::draw_triangle_normal()
{
    const int tid = selTriId_;
    const vector<Point3d>&  vtx = mesh_.vertices();
    const vector<Tuple3ui>& tgl = mesh_.surface_indices();

    const Point3d ctr  = (vtx[tgl[tid].x] + vtx[tgl[tid].y] + vtx[tgl[tid].z])*(1./3.);
    Vector3d nml = Triangle<double>::weighted_normal( vtx[tgl[tid].x], vtx[tgl[tid].y], vtx[tgl[tid].z] );
    double area = nml.normalize2();
    const double len = 0.05;     ///// HARD coded value here!!!
    const Point3d end  = ctr + nml * len;

    glColor3f(1.f, 0.f, 0.f);
    drawArrow( qglviewer::Vec(end.x, end.y, end.z), 
               qglviewer::Vec(ctr.x, ctr.y, ctr.z),
               sqrt(area)*0.8 );
}
Beispiel #4
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();
}