• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ osg::Matrixd类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中osg::Matrixd的典型用法代码示例。如果您正苦于以下问题:C++ Matrixd类的具体用法?C++ Matrixd怎么用?C++ Matrixd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Matrixd类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: if

void MinimalShadowMap::ViewData::clampProjection
                    ( osg::Matrixd & projection, float new_near, float new_far )
{
    double r, l, t, b, n, f;
    bool perspective = projection.getFrustum( l, r, b, t, n, f );
    if( !perspective && !projection.getOrtho( l, r, b, t, n, f ) )
    {
        // What to do here ?
        osg::notify( osg::WARN ) 
            << "MinimalShadowMap::clampProjectionFarPlane failed - non standard matrix"
            << std::endl;

    } else if( n < new_near || new_far < f ) {

        if( n < new_near && new_near < f ) {
            if( perspective ) {
                l *= new_near / n;
                r *= new_near / n;
                b *= new_near / n;
                t *= new_near / n;
            }
            n = new_near;
        } 

        if( n < new_far && new_far < f ) {
            f = new_far;             
        }

        if( perspective )
            projection.makeFrustum( l, r, b, t, n, f );
        else
            projection.makeOrtho( l, r, b, t, n, f );                     
    }
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:34,代码来源:MinimalShadowMap.cpp


示例2: atan2

void ViroManipulator::setByMatrix(const osg::Matrixd& matrix){
	this->Disable(GRAVITY);
	_speed    = 0.0;
	_padEvent = NAVPAD_NONE;

	_vEye = matrix.getTrans();
	osg::Quat q = matrix.getRotate();

	double qx,qy,qz,qw;

	qx = q.x();
	qy = q.y();
	qz = q.z();
	qw = q.w();

	_yaw   = atan2( 2*qy*qw-2*qx*qz , 1 - 2*qy*qy - 2*qz*qz);
	_pitch = asin(2*qx*qy + 2*qz*qw);
	_roll  = atan2(2*qx*qw-2*qy*qz , 1 - 2*qx*qz - 2*qz*qz);

	osg::Quat rot = osg::Quat( (_pitch+osg::PI_2), osg::X_AXIS) * osg::Quat(0.0/*(_roll) */, osg::Y_AXIS) * osg::Quat( (_yaw), osg::Z_AXIS);
	_qRotation    = rot;

	//matrix.decompose(_vEye, Q, vScale, q);

	//osg::Matrixd M,Ms;
	//M = matrix;
	//M.makeScale(-vScale);
	
	//_qRotation = M.getRotate();

	/*
	osg::Vec3d vScale,E,T,U;
	osg::Quat Q;
	matrix.getLookAt(E, T, U );
	matrix.decompose(_vEye, _qRotation, vScale, Q);

	_vEye = matrix.getTrans();
	//osg::Vec3d vLook = -osg::Z_AXIS * matrix;
	//vLook = matrix.getScale() ^ (-vLook);
	//_vTarget = vLook + _vEye;


	//_vUp  = osg::Z_AXIS;
	//matrix.getScale();
	//matrix.get( _qRotation );
	//matrix.getLookAt( _vEye, _vTarget, _vUp );
	//computePosition( _vEye, _vTarget, osg::Z_AXIS );
	//_qRotation.set( matrix );
	//SyncData( matrix.getRotate() );

	//SyncData(_qRotation);
	computePosition( _vEye, T, U );
	SyncData();
	//computePosition( matrix.getTrans(), (matrix.getTrans()+matrix.get), osg::Z_AXIS );
	*/
	SyncData();
}
开发者ID:flyskyosg,项目名称:virtualrome,代码行数:57,代码来源:ViroManipulator.cpp


示例3: fromMatrix

void Math::fromMatrix(const osg::Matrixd& mx, double& x, double& y, double& z, double& h, double& p, double& r)
{
    x = mx.getTrans().x();
    y = mx.getTrans().y();
    z = mx.getTrans().z();

    osg::Vec3 hpr = fromQuat(mx.getRotate());
    h = osg::RadiansToDegrees(hpr.x());
    p = osg::RadiansToDegrees(hpr.y())-90.0;
    r = osg::RadiansToDegrees(hpr.z());
}
开发者ID:qqdiguo,项目名称:MuseOpenIG,代码行数:11,代码来源:mathematics.cpp


示例4: getZNearZFarProj

void ViewingCore::getZNearZFarProj(double &zNear, double &zFar, osg::Matrixd &projMat)
{
    projMat = computeProjection();

    if( getOrtho() ) {
        double l, r, b, t;
        projMat.getOrtho( l, r, b, t, zNear, zFar );
    } else {
        double fovy, aspect;
        projMat.getPerspective( fovy, aspect, zNear, zFar );
    }
}
开发者ID:iraytrace,项目名称:osgTreeWidget,代码行数:12,代码来源:ViewingCore.cpp


示例5: atan

void MxCore::updateFovy( osg::Matrixd& proj ) const
{
    if( _ortho )
    {
        osg::notify( osg::WARN ) << "MxCore::updateFovy: Ortho is not yet implemented. TBD." << std::endl;
    }
    else
    {
        double left, right, bottom, top, near, far;
        proj.getFrustum( left, right, bottom, top, near, far );

        const double fovBottom = atan( bottom / near );
        const double fovTop = atan( top / near );

        const double fovyRatio = getFovyRadians() /
            ( osg::absolute< double >( fovBottom ) + osg::absolute< double >( fovTop ) );

        const double newBottom = tan( fovBottom * fovyRatio ) * near;
        const double newTop = tan( fovTop * fovyRatio ) * near;
        const double xScale = newTop / top;
        left *= xScale;
        right *= xScale;
        proj = osg::Matrixd::frustum( left, right, newBottom, newTop, near, far );
    }
}
开发者ID:kubark42,项目名称:osgworks,代码行数:25,代码来源:MxCore.cpp


示例6: getElement

bool Uniform::getElement( unsigned int index, osg::Matrixd& m4 ) const
{
    if( index>=getNumElements() || !isCompatibleType(FLOAT_MAT4) ) return false;
    unsigned int j = index * getTypeNumComponents(getType());
    m4.set( &((*_floatArray)[j]) );
    return true;
}
开发者ID:aalex,项目名称:osg,代码行数:7,代码来源:Uniform.cpp


示例7: setElement

bool Uniform::setElement( unsigned int index, const osg::Matrixd& m4 )
{
    if( index>=getNumElements() || !isCompatibleType(FLOAT_MAT4) ) return false;
    unsigned int j = index * getTypeNumComponents(getType());
    const Matrixd::value_type* p = m4.ptr();
    for( int i = 0; i < 16; ++i ) (*_floatArray)[j+i] = static_cast<float>(p[i]);
    dirty();
    return true;
}
开发者ID:aalex,项目名称:osg,代码行数:9,代码来源:Uniform.cpp


示例8:

bool
SpatialReference::createWorldToLocal(const osg::Vec3d& xyz, osg::Matrixd& out_world2local ) const
{
    osg::Matrixd local2world;
    if ( !createLocalToWorld(xyz, local2world) )
        return false;
    out_world2local.invert(local2world);
    return true;
}
开发者ID:mysticbob,项目名称:osgearth,代码行数:9,代码来源:SpatialReference.cpp


示例9: setByMatrix

/** Set the position of the manipulator using a 4x4 matrix.*/
void OrbitManipulator::setByMatrix( const osg::Matrixd& matrix )
{
    _center = osg::Vec3d( 0., 0., -_distance ) * matrix;
    _rotation = matrix.getRotate();

    // fix current rotation
    if( getVerticalAxisFixed() )
        fixVerticalAxis( _center, _rotation, true );
}
开发者ID:AdriCS,项目名称:osg,代码行数:10,代码来源:OrbitManipulator.cpp


示例10: ComputeBoundingBoxByRotation

void ComputeBoundingBoxByRotation(osg::BoundingBox & InOut,osg::Vec3 BBCenter,float BBSize,osg::Matrixd Rotation)
{
	osg::BoundingBox bb;
	bb.set(BBCenter.x()-BBSize,BBCenter.y()-BBSize,BBCenter.z()-BBSize,BBCenter.x()+BBSize,BBCenter.y()+BBSize,BBCenter.z()+BBSize);
    osg::BoundingBox Tbb;
	for(unsigned int i=0;i<8;i++)
    {
        Tbb.expandBy(Rotation.preMult(bb.corner(i)));
    }
	InOut.set(Tbb.xMin(),Tbb.yMin(),Tbb.zMin(),Tbb.xMax(),Tbb.yMax(),Tbb.zMax());
}
开发者ID:Sjith,项目名称:Multi-User_Android_3D_Drawing,代码行数:11,代码来源:AuxFunc.cpp


示例11: vMin

void MinimalShadowMap::ViewData::extendProjection
    ( osg::Matrixd & projection, osg::Viewport * viewport, const osg::Vec2& margin )
{
  double l,r,b,t,n,f;

  //osg::Matrix projection = camera.getProjectionMatrix();

  bool frustum = projection.getFrustum( l,r,b,t,n,f );

  if( !frustum && !projection.getOrtho( l,r,b,t,n,f ) ) {
    osg::notify( osg::WARN )
        << " Awkward projection matrix. ComputeExtendedProjection failed"
        << std::endl;
    return;
  }

  osg::Matrix window = viewport->computeWindowMatrix();
 
  osg::Vec3 vMin( viewport->x() - margin.x(), 
                 viewport->y() - margin.y(), 
                 0.0 );

  osg::Vec3 vMax( viewport->width() + margin.x() * 2  + vMin.x(), 
                  viewport->height() + margin.y() * 2  + vMin.y(), 
                  0.0 );
  
  osg::Matrix inversePW = osg::Matrix::inverse( projection * window );

  vMin = vMin * inversePW;
  vMax = vMax * inversePW;
  
  l = vMin.x(); 
  r = vMax.x();
  b = vMin.y(); 
  t = vMax.y();

  if( frustum )
    projection.makeFrustum( l,r,b,t,n,f );
  else 
    projection.makeOrtho( l,r,b,t,n,f );
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:41,代码来源:MinimalShadowMap.cpp


示例12:

void
FeaturesToNodeFilter::computeLocalizers( const FilterContext& context, const osgEarth::GeoExtent &extent, osg::Matrixd &out_w2l, osg::Matrixd &out_l2w )
{
    if ( context.isGeoreferenced() )
    {
        if ( context.getSession()->getMapInfo().isGeocentric() )
        {
            const SpatialReference* geogSRS = context.profile()->getSRS()->getGeographicSRS();
            GeoExtent geodExtent = extent.transform( geogSRS );
            if ( geodExtent.width() < 180.0 )
            {
                osg::Vec3d centroid, centroidECEF;
                geodExtent.getCentroid( centroid.x(), centroid.y() );
                geogSRS->transform( centroid, geogSRS->getECEF(), centroidECEF );
                geogSRS->getECEF()->createLocalToWorld( centroidECEF, out_l2w );
                out_w2l.invert( out_l2w );
            }
        }

        else // projected
        {
            if ( extent.isValid() )
            {
                osg::Vec3d centroid;
                extent.getCentroid(centroid.x(), centroid.y());

                extent.getSRS()->transform(
                    centroid,
                    context.getSession()->getMapInfo().getProfile()->getSRS(),
                    centroid );

                out_w2l.makeTranslate( -centroid );
                out_l2w.invert( out_w2l );
            }
        }
    }
}
开发者ID:Brucezhou1979,项目名称:osgearth,代码行数:37,代码来源:Filter.cpp


示例13: getWKT

OGR_SpatialReference::OGR_SpatialReference(void* _handle, 
                                           bool _delete_handle,
                                           const osg::Matrixd& _ref_frame )
{
	handle        = _handle;
	owns_handle   = _delete_handle;
    ref_frame     = _ref_frame;
    inv_ref_frame = _ref_frame.isIdentity()? _ref_frame : osg::Matrixd::inverse( _ref_frame );
    getWKT();

    // intialize the basis ellipsoid
    OGR_SCOPE_LOCK();
    int err;
    double semi_major_axis = OSRGetSemiMajor( handle, &err );
    double semi_minor_axis = OSRGetSemiMinor( handle, &err );
    ellipsoid = Ellipsoid( semi_major_axis, semi_minor_axis );
    
    is_geographic = OSRIsGeographic( handle ) != 0;
    is_projected = OSRIsProjected( handle ) != 0;
}
开发者ID:aarnchng,项目名称:osggis,代码行数:20,代码来源:OGR_SpatialReference.cpp


示例14:

void MinimalShadowMap::ViewData::trimProjection
    ( osg::Matrixd & projectionMatrix, osg::BoundingBox bb, unsigned int trimMask )
{
#if 1
    if( !bb.valid() || !( trimMask & (1|2|4|8|16|32) ) ) return;
    double l = -1, r = 1, b = -1, t = 1, n = 1, f = -1;

#if 0
    // make sure bounding box does not extend beyond unit frustum clip range
    for( int i = 0; i < 3; i ++ ) {
        if( bb._min[i] < -1 ) bb._min[i] = -1;
        if( bb._max[i] >  1 ) bb._max[i] =  1;
    }
#endif

    if( trimMask & 1 ) l = bb._min[0];
    if( trimMask & 2 ) r = bb._max[0];
    if( trimMask & 4 ) b = bb._min[1];
    if( trimMask & 8 ) t = bb._max[1];
    if( trimMask & 16 ) n = -bb._min[2];
    if( trimMask & 32 ) f = -bb._max[2];

    projectionMatrix.postMult( osg::Matrix::ortho( l,r,b,t,n,f ) );
#else
    if( !bb.valid() || !( trimMask & (1|2|4|8|16|32) ) ) return;
    double l, r, t, b, n, f;
    bool ortho = projectionMatrix.getOrtho( l, r, b, t, n, f ); 
    if( !ortho && !projectionMatrix.getFrustum( l, r, b, t, n, f ) )
        return; // rotated or skewed or other crooked projection - give up

    // make sure bounding box does not extend beyond unit frustum clip range
    for( int i = 0; i < 3; i ++ ) {
        if( bb._min[i] < -1 ) bb._min[i] = -1;
        if( bb._max[i] >  1 ) bb._max[i] =  1;
    }

    osg::Matrix projectionToView = osg::Matrix::inverse( projectionMatrix );
    
    osg::Vec3 min =
        osg::Vec3( bb._min[0], bb._min[1], bb._min[2] ) * projectionToView;

    osg::Vec3 max =
        osg::Vec3( bb._max[0], bb._max[1], bb._max[2] ) * projectionToView;

    if( trimMask & 16 ) { // trim near
        if( !ortho ) { // recalc frustum corners on new near plane
            l *= -min[2] / n;
            r *= -min[2] / n;
            b *= -min[2] / n;
            t *= -min[2] / n;
        }
        n = -min[2];
    }

    if( trimMask & 32 ) // trim far
        f = -max[2];

    if( !ortho ) {
        min[0] *=  -n / min[2];
        min[1] *=  -n / min[2];
        max[0] *=  -n / max[2];
        max[1] *=  -n / max[2];
    }

    if( l < r ) { // check for inverted X range
        if( l < min[0] && ( trimMask & 1 ) ) l = min[0];
        if( r > max[0] && ( trimMask & 2 ) ) r = max[0];
    } else {
        if( l > min[0] && ( trimMask & 1 ) ) l = min[0];
        if( r < max[0] && ( trimMask & 2 ) ) r = max[0];
    }

    if( b < t ) { // check for inverted Y range
        if( b < min[1] && ( trimMask & 4 ) ) b = min[1];
        if( t > max[1] && ( trimMask & 8 ) ) t = max[1];
    } else {
        if( b > min[1] && ( trimMask & 4 ) ) b = min[1];
        if( t < max[1] && ( trimMask & 8 ) ) t = max[1];
    }

    if( ortho ) 
        projectionMatrix.makeOrtho( l, r, b, t, n, f );
    else 
        projectionMatrix.makeFrustum( l, r, b, t, n, f );
#endif
}
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:86,代码来源:MinimalShadowMap.cpp


示例15: apply

 virtual void apply(const osg::Matrixd& value)   { for(unsigned int i=0; i<16; ++i) _stream << (value.ptr())[i]; }
开发者ID:ChrisWC,项目名称:OpenSceneGraph,代码行数:1,代码来源:OscSendingDevice.cpp


示例16: setByMatrix

void KeyPadCameraManipulator::setByMatrix(const osg::Matrixd& matrix)
{
    _pos = matrix.getTrans();
    _ori = getHPRfromQuat(matrix.getRotate());

}
开发者ID:wangfeilong321,项目名称:MuseOpenIG,代码行数:6,代码来源:keypad.cpp


示例17: setByMatrix

void GliderManipulator::setByMatrix(const osg::Matrixd& matrix)
{
    _eye = matrix.getTrans();
    _rotation = matrix.getRotate();
    _distance = 1.0f;
}
开发者ID:yueying,项目名称:osg,代码行数:6,代码来源:GliderManipulator.cpp


示例18: setByMatrix

void NodeTrackerManipulator::setByMatrix(const osg::Matrixd& matrix)
{
    osg::Vec3d eye,center,up;
    matrix.getLookAt(eye,center,up,_distance);
    computePosition(eye,center,up);
}
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:6,代码来源:NodeTrackerManipulator.cpp


示例19:

void Vwr::CameraManipulator::setByMatrix(const osg::Matrixd& matrix)
{
    _center = osg::Vec3(0.0f,0.0f,-_distance)*matrix;
    _rotation = matrix.getRotate();
}
开发者ID:Cecko,项目名称:3dsoftviz,代码行数:5,代码来源:CameraManipulator.cpp


示例20: set

osg::Matrixf::Matrixf( const osg::Matrixd& mat )
{
    set(mat.ptr());
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:4,代码来源:Matrixf.cpp



注:本文中的osg::Matrixd类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ osg::Node类代码示例发布时间:2022-05-31
下一篇:
C++ osg::Matrix类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap