コード例 #1
0
void display(void)
{
    m1c = tball.getFullTrackballMatrix();

    if(move_obj == true)
    {
        scene_trans->editSFMatrix()->setValue( m1c );
    }
    else
    {
        cam_trans->editSFMatrix()->setValue( m1c );
    }

    commitChanges();

    win->render(rentravact);
}
コード例 #2
0
void display(void)
{
    Matrix m1, m2, m3;
    Quaternion q1;

    tball.getRotation().getValue(m3);

    q1.setValue(m3);

    m1.setRotate(q1);
    
    m2.setTranslate( tball.getPosition() );
    
    m1.mult( m2 );

    cam_trans->editSFMatrix()->setValue(m1);

    
#if 0
    m1c.setIdentity();

    Matrix m2c, m3c;
    Quaternion q1c;

    tcamball.getRotation().getValue(m3c);

    q1c.setValue(m3c);

    m1c.setRotate(q1c);
    
    m2c.setTranslate( tcamball.getPosition() );
    
    m1c.mult( m2c );
#else
    m1c.setIdentity();

    float fLat  = xPoints[0][1] + (xPoints[1][1] - xPoints[0][1]) * t;
    float fLong = xPoints[0][0] + (xPoints[1][0] - xPoints[0][0]) * t;

//    fprintf(stderr, "%f %f\n", fLat, fLong);

    if(bAnimate == true)
    {
        t += tStep;
        
        if(t > 1)
        {
            tStep = -tStep;
            t     = 1;
        }
        else if(t < 0)
        {
            tStep = -tStep;
            t     = 0;
        }
    }

    Pnt3f p1;

    projectPnt(p1, fLat, fLong, 50);

    m1c[3][0] = p1[0];
    m1c[3][1] = p1[1];
    m1c[3][2] = p1[2];

#endif

    scene_trans->editSFMatrix()->setValue(m1c);

    Vec3f x1(m1c[3][0],
             m1c[3][1],
             m1c[3][2]);
    Vec3f x2;

    backProjectPnt(x2, x1);


/*
    fprintf(stderr, "%f %f %f\n", 
            osgRad2Degree(x2[0]), 
            x2[2],
            osgRad2Degree(x2[1]));
 */

/* -285.728333 -285.728333 | 494.500488 494.500488 */

    const BbqDataSourceInformation &tInfo = 
        pSource->getInformation();

    m4c.setIdentity();

    m4c[3][0] = osgRad2Degree(x2[0]);
    m4c[3][1] = 0; //x2[2];
//    m4c[3][2] = -45.f - (osgRad2Degree(x2[1]) + 40.f);
//    m4c[3][2] = -(osgRad2Degree(x2[1]) + 40.f);
    m4c[3][2] = osgRad2Degree(x2[1]);

//    fprintf(stderr, "%f %f\n", 
//            -(osgRad2Degree(x2[1]) + 40.f),
//           -45.f - (osgRad2Degree(x2[1]) + 40.f));
//    (571.45666/ 5.f)
//   (- 285.728333 - (170.f * fUnitScale))

//    m4c[3][0] = m4c[3][0] * fUnitScale + vUnitOffset[0]; 
    m4c[3][0] = m4c[3][0] * tInfo.vScale[0] + tInfo.vOffset[0]; 

//    m4c[3][2] = (-m4c[3][2] - 40.f) * fUnitScale - 285.728333; 
//    m4c[3][2] = m4c[3][2] * fUnitScale1 + vUnitOffset[1];
    m4c[3][2] = m4c[3][2] * tInfo.vScale[1] + tInfo.vOffset[1];

    ref_trans->editSFMatrix()->setValue(m4c);

    commitChanges();

//    win->render(rentravact);

//    fprintf(stderr, "Frame\n==========================================\n");

    win->activate ();
    win->frameInit();    // query recently registered GL extensions
    
    win->renderAllViewports(rentravact);

    win->swap     ();
    win->frameExit();    // after frame cleanup: delete GL objects, if needed

}