Example #1
0
/// hum. read the doc, then come back here. then try to figure.
void
dxfInsert::drawScene(scene* sc)
{
    // INSERTs can be nested. So pull the current matrix
    // and push it back after we fill our context
    // This is a snapshot in time. I will rewrite all this to be cleaner,
    // but for now, it seems working fine
    // (with the files I have, the results are equal to Voloview,
    // and better than Deep Exploration and Lightwave).

    // sanity check (useful when no block remains after all unsupported entities have been filtered out)
    if (!_block)
        return;

    Matrixd back = sc->backMatrix();
    Matrixd m;
    m.makeIdentity();
    sc->pushMatrix(m, true);
    Vec3d trans = _block->getPosition();
    sc->blockOffset(-trans);
    if (_rotation) {
        sc->pushMatrix(Matrixd::rotate(osg::DegreesToRadians(_rotation), 0,0,1));
    }
    sc->pushMatrix(Matrixd::scale(_scale.x(), _scale.y(), _scale.z()));
    sc->pushMatrix(Matrixd::translate(_point.x(), _point.y(), _point.z()));
    getOCSMatrix(_ocs, m);
    sc->pushMatrix(m);
    sc->pushMatrix(back);

    EntityList& l = _block->getEntityList();
    for (EntityList::iterator itr = l.begin(); itr != l.end(); ++itr) {
        dxfBasicEntity* e = (*itr)->getEntity();
        if (e) {
            e->drawScene(sc);
        }
    }

    sc->popMatrix(); // ocs
    sc->popMatrix(); // translate
    sc->popMatrix(); // scale
    if (_rotation) {
        sc->popMatrix(); // rotate
    }
    sc->popMatrix(); // identity
    sc->popMatrix(); // back
    sc->blockOffset(Vec3d(0,0,0));

}
void CAVEGeodeIconToolkitRotate::setMatrixTrans(osg::MatrixTransform *matTrans)
{
    Matrixd rotMat;

    if (mAxisAlignment == X_AXIS)
    {
	rotMat = Matrixd(Quat(M_PI * 0.5, Vec3(0, 1, 0)));
    }
    else if (mAxisAlignment == Y_AXIS)
    {
	rotMat = Matrixd(Quat(M_PI * 0.5, Vec3(1, 0, 0)));
    }
    else rotMat.makeIdentity();

    matTrans->setMatrix(rotMat);
}
void CAVEGeodeIconToolkitMove::setMatrixTrans(MatrixTransform *matTrans)
{
    Matrixd rotMat;

    if (mFaceOrient == FRONT_BACK)
    {
	rotMat = Matrixd(Quat(M_PI * 0.5, Vec3(1, 0, 0)));
    }
    else if (mFaceOrient == LEFT_RIGHT)
    {
	rotMat = Matrixd(Quat(M_PI * 0.5, Vec3(0, 1, 0)));
    }
    else rotMat.makeIdentity();

    matTrans->setMatrix(rotMat);
}