Exemplo n.º 1
0
bool Channel::configInit( const eq::uint128_t& initID )
{
    if( !eq::Channel::configInit( initID ))
        return false;

    setNearFar( 0.001f, 10.0f );
    return true;
}
Exemplo n.º 2
0
void Channel::_updateNearFar( const mesh::BoundingSphere& boundingSphere )
{
    // compute dynamic near/far plane of whole model
    const FrameData& frameData = _getFrameData();

    const eq::Matrix4f& rotation     = frameData.getCameraRotation();
    const eq::Matrix4f headTransform = getHeadTransform() * rotation;

    eq::Matrix4f modelInv;
    compute_inverse( headTransform, modelInv );

    const eq::Vector3f zero  = modelInv * eq::Vector3f::ZERO;
    eq::Vector3f       front = modelInv * eq::Vector3f( 0.0f, 0.0f, -1.0f );

    front -= zero;
    front.normalize();
    front *= boundingSphere.w();

    const eq::Vector3f center =  
        frameData.getCameraPosition().get_sub_vector< 3 >() -
        boundingSphere.get_sub_vector< 3 >();
    const eq::Vector3f nearPoint  = headTransform * ( center - front );
    const eq::Vector3f farPoint   = headTransform * ( center + front );

    if( useOrtho( ))
    {
        LBASSERTINFO( fabs( farPoint.z() - nearPoint.z() ) > 
                      std::numeric_limits< float >::epsilon(),
                      nearPoint << " == " << farPoint );
        setNearFar( -nearPoint.z(), -farPoint.z() );
    }
    else
    {
        // estimate minimal value of near plane based on frustum size
        const eq::Frustumf& frustum = getFrustum();
        const float width  = fabs( frustum.right() - frustum.left() );
        const float height = fabs( frustum.top() - frustum.bottom() );
        const float size   = LB_MIN( width, height );
        const float minNear = frustum.near_plane() / size * .001f;

        const float zNear = LB_MAX( minNear, -nearPoint.z() );
        const float zFar  = LB_MAX( zNear * 2.f, -farPoint.z() );

        setNearFar( zNear, zFar );
    }
}
Exemplo n.º 3
0
bool Channel::configInit( const eq::uint128_t& initID )
{
    if( !eq::Channel::configInit( initID ))
        return false;

    setNearFar( 0.1f, 10.0f );
    _model = 0;
    _modelID = lunchbox::UUID::ZERO;
    return true;
}
Camera::Camera()
{
	// initialize your data here
	aspect_ratio = 1.0;
	height = 600;
	width = 800;

	setFrom(Point3(3.0, 2.0, 6.0));
	setAt(Point3(0.0, 0.0, 0.0));
	setUp(Vector3(0.0, 1.0, 0.0));
	setZoom(90.0);
	setNearFar(0.1, 30.0);
}
Exemplo n.º 5
0
void Renderer::updateNearFar( const Vector4f& boundingSphere )
{
    const Matrix4f& view = getViewMatrix();
    Matrix4f viewInv;
    compute_inverse( view, viewInv );

    const Vector3f& zero  = viewInv * Vector3f::ZERO;
    Vector3f        front = viewInv * Vector3f( 0.0f, 0.0f, -1.0f );
    front -= zero;
    front.normalize();
    front *= boundingSphere.w();

    const Vector3f& translation = getModelMatrix().get_translation();
    const Vector3f& center = translation - boundingSphere.get_sub_vector< 3 >();
    const Vector3f& nearPoint  = view * ( center - front );
    const Vector3f& farPoint   = view * ( center + front );

    if( _impl->useOrtho( ))
    {
        LBASSERTINFO( fabs( farPoint.z() - nearPoint.z() ) >
                      std::numeric_limits< float >::epsilon(),
                      nearPoint << " == " << farPoint );
        setNearFar( -nearPoint.z(), -farPoint.z() );
    }
    else
    {
        // estimate minimal value of near plane based on frustum size
        const eq::Frustumf& frustum = _impl->getFrustum();
        const float width  = fabs( frustum.right() - frustum.left() );
        const float height = fabs( frustum.top() - frustum.bottom() );
        const float size   = LB_MIN( width, height );
        const float minNear = frustum.near_plane() / size * .001f;

        const float zNear = LB_MAX( minNear, -nearPoint.z() );
        const float zFar  = LB_MAX( zNear * 2.f, -farPoint.z() );

        setNearFar( zNear, zFar );
    }
}
Exemplo n.º 6
0
bool Channel::configInit( const eq::uint128_t& initID )
{
    if( !eq::Channel::configInit( initID ))
        return false;

    setNearFar( 0.001f, 10.0f );

    if( getenv( "EQ_TAINT_CHANNELS" ))
    {
        _bgColor = getUniqueColor();
        _bgColor /= 255.f;
    }

    return true;
}
Exemplo n.º 7
0
void Channel::_draw( const eq::uint128_t& spin )
{
    glPushAttrib( GL_ALL_ATTRIB_BITS );

    eq::Channel::frameDraw( spin );

    glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
    glEnable( GL_DEPTH_TEST );

#if 0
    setNearFar( 0.5f, 5.0f );
    const GLfloat lightPosition[]    = {5.0f, 0.0f, 5.0f, 0.0f};
    const GLfloat lightDiffuse[]     = {0.8f, 0.8f, 0.8f, 1.0f};

    const GLfloat materialDiffuse[]  = {0.8f, 0.8f, 0.8f, 1.0f};

    glLightfv( GL_LIGHT0, GL_POSITION, lightPosition );
    glLightfv( GL_LIGHT0, GL_DIFFUSE,  lightDiffuse  );

    glMaterialfv( GL_FRONT, GL_DIFFUSE,   materialDiffuse );

    eq::Matrix4f rotation;
    eq::Vector3f translation;

    translation   = eq::Vector3f::ZERO;
    translation.z = -2.f;
    rotation = eq::Matrix4f::IDENTITY;
    rotation.rotate_x( static_cast<float>( -M_PI_2 ));
    rotation.rotate_y( static_cast<float>( -M_PI_2 ));

    glTranslatef( translation.x, translation.y, translation.z );
    glMultMatrixf( rotation.ml );

    glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
    glColor3f( 1.f, 1.f, 0.f );
    glNormal3f( 1.f, -1.f, 0.f );
    glBegin( GL_TRIANGLE_STRIP );
        glVertex3f(  1.f, 10.f,  2.5f );
        glVertex3f( -1.f, 10.f,  2.5f );
        glVertex3f(  1.f,-10.f, -2.5f );
        glVertex3f( -1.f,-10.f, -2.5f );
    glEnd();

#else

    const float lightPos[] = { 0.0f, 0.0f, 1.0f, 0.0f };
    glLightfv( GL_LIGHT0, GL_POSITION, lightPos );

    const float lightAmbient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
    glLightfv( GL_LIGHT0, GL_AMBIENT, lightAmbient );

    // rotate scene around the origin
    glRotatef( static_cast< float >( spin.low() + 3 ) * 10, 1.0f, 0.5f, 0.25f );

    // render six axis-aligned colored quads around the origin
    //  front
    glColor3f( 1.0f, 0.5f, 0.5f );
    glNormal3f( 0.0f, 0.0f, 1.0f );
    glBegin( GL_TRIANGLE_STRIP );
    glVertex3f(  .7f,  .7f, -1.0f );
    glVertex3f( -.7f,  .7f, -1.0f );
    glVertex3f(  .7f, -.7f, -1.0f );
    glVertex3f( -.7f, -.7f, -1.0f );
    glEnd();

    //  bottom
    glColor3f( 0.5f, 1.0f, 0.5f );
    glNormal3f( 0.0f, 1.0f, 0.0f );
    glBegin( GL_TRIANGLE_STRIP );
    glVertex3f(  .7f, -1.0f,  .7f );
    glVertex3f( -.7f, -1.0f,  .7f );
    glVertex3f(  .7f, -1.0f, -.7f );
    glVertex3f( -.7f, -1.0f, -.7f );
    glEnd();

    //  back
    glColor3f( 0.5f, 0.5f, 1.0f );
    glNormal3f( 0.0f, 0.0f, -1.0f );
    glBegin( GL_TRIANGLE_STRIP );
    glVertex3f(  .7f,  .7f, 1.0f );
    glVertex3f( -.7f,  .7f, 1.0f );
    glVertex3f(  .7f, -.7f, 1.0f );
    glVertex3f( -.7f, -.7f, 1.0f );
    glEnd();

    //  top
    glColor3f( 1.0f, 1.0f, 0.5f );
    glNormal3f( 0.f, -1.f, 0.f );
    glBegin( GL_TRIANGLE_STRIP );
    glVertex3f(  .7f, 1.0f,  .7f );
    glVertex3f( -.7f, 1.0f,  .7f );
    glVertex3f(  .7f, 1.0f, -.7f );
    glVertex3f( -.7f, 1.0f, -.7f );
    glEnd();

    //  right
    glColor3f( 1.0f, 0.5f, 1.0f );
    glNormal3f( -1.f, 0.f, 0.f );
    glBegin( GL_TRIANGLE_STRIP );
    glVertex3f( 1.0f,  .7f,  .7f );
    glVertex3f( 1.0f, -.7f,  .7f );
    glVertex3f( 1.0f,  .7f, -.7f );
    glVertex3f( 1.0f, -.7f, -.7f );
    glEnd();

    //  left
    glColor3f( 0.5f, 1.0f, 1.0f );
    glNormal3f( 1.f, 0.f, 0.f );
    glBegin( GL_TRIANGLE_STRIP );
    glVertex3f( -1.0f,  .7f,  .7f );
    glVertex3f( -1.0f, -.7f,  .7f );
    glVertex3f( -1.0f,  .7f, -.7f );
    glVertex3f( -1.0f, -.7f, -.7f );
    glEnd();

#endif

    glPopAttrib( );
}