当前位置: 首页>>代码示例>>C++>>正文


C++ Vec3::z方法代码示例

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


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

示例1: setCenterPos

/***************************************************************
* Function: setCenterPos()
***************************************************************/
void CAVEGroupReferencePlane::setCenterPos(const osg::Vec3 &center)
{
    /* snap 'center' vector with respect to mUnitGridSize */
    Vec3 centerRounded;
    float snapUnitX, snapUnitY, snapUnitZ;
    snapUnitX = snapUnitY = snapUnitZ = mUnitGridSize;
    if (center.x() < 0) snapUnitX = -mUnitGridSize;
    if (center.y() < 0) snapUnitY = -mUnitGridSize;
    if (center.z() < 0) snapUnitZ = -mUnitGridSize;
    int xSeg = (int)(abs((int)((center.x() + 0.5 * snapUnitX) / mUnitGridSize)));
    int ySeg = (int)(abs((int)((center.y() + 0.5 * snapUnitY) / mUnitGridSize)));
    int zSeg = (int)(abs((int)((center.z() + 0.5 * snapUnitZ) / mUnitGridSize)));
    centerRounded.x() = xSeg * snapUnitX;
    centerRounded.y() = ySeg * snapUnitY;
    centerRounded.z() = zSeg * snapUnitZ;

    /* set highlights of either XZ plane or YZ plane */
    Vec3 offset = centerRounded - mCenter;
    float offx = offset.x() * offset.x();
    float offy = offset.y() * offset.y();
    if (offx > offy) mYZPlaneGeode->setAlpha(1.0f);
    else mYZPlaneGeode->setAlpha(0.4f);
    if (offx < offy) mXZPlaneGeode->setAlpha(1.0f);
    else mXZPlaneGeode->setAlpha(0.4f);

    mCenter = centerRounded;
    Matrixf transMat;
    transMat.makeTranslate(mCenter);
    mMatrixTrans->setMatrix(transMat);
}
开发者ID:aprudhomme,项目名称:calvr_plugins,代码行数:33,代码来源:CAVEGroupReference.cpp

示例2: writeUpdateTransformElements

void daeWriter::writeUpdateTransformElements(const osg::Vec3 &pos, const osg::Quat &q,    const osg::Vec3 &s)
{
    // Make a scale place element
    domScale *scale = daeSafeCast< domScale >( currentNode->add( COLLADA_ELEMENT_SCALE ) );
    scale->setSid("scale");
    scale->getValue().append3( s.x(), s.y(), s.z() );

    // Make a three rotate place elements for the euler angles
    // TODO decompose quaternion into three euler angles
    osg::Quat::value_type angle;
    osg::Vec3 axis;
    q.getRotate( angle, axis );

    domRotate *rot = daeSafeCast< domRotate >( currentNode->add( COLLADA_ELEMENT_ROTATE ) );
    rot->setSid("rotateZ");
    rot->getValue().append4( 0, 0, 1, osg::RadiansToDegrees(angle) );

    rot = daeSafeCast< domRotate >( currentNode->add( COLLADA_ELEMENT_ROTATE ) );
    rot->setSid("rotateY");
    rot->getValue().append4( 0, 1, 0, osg::RadiansToDegrees(angle) );

    rot = daeSafeCast< domRotate >( currentNode->add( COLLADA_ELEMENT_ROTATE ) );
    rot->setSid("rotateX");
    rot->getValue().append4( 1, 0, 0, osg::RadiansToDegrees(angle) );

    // Make a translate place element
    domTranslate *trans = daeSafeCast< domTranslate >( currentNode->add( COLLADA_ELEMENT_TRANSLATE ) );
    trans->setSid("translate");
    trans->getValue().append3( pos.x(), pos.y(), pos.z() );
}
开发者ID:IsemanTech,项目名称:osg,代码行数:30,代码来源:daeWTransforms.cpp

示例3: rotation

void osgParticle::Particle::render(osg::RenderInfo& renderInfo, const osg::Vec3& xpos, const osg::Vec3& xrot) const
{
#if defined(OSG_GL_MATRICES_AVAILABLE)
    if (_drawable.valid())
    {
        bool requiresRotation = (xrot.x()!=0.0f || xrot.y()!=0.0f || xrot.z()!=0.0f);
        glColor4f(_current_color.x(),
                  _current_color.y(),
                  _current_color.z(),
                  _current_color.w() * _current_alpha);
        glPushMatrix();
        glTranslatef(xpos.x(), xpos.y(), xpos.z());
        if (requiresRotation)
        {
            osg::Quat rotation(xrot.x(), osg::X_AXIS, xrot.y(), osg::Y_AXIS, xrot.z(), osg::Z_AXIS);
#if defined(OSG_GLES1_AVAILABLE)
            glMultMatrixf(osg::Matrixf(rotation).ptr());
#else
            glMultMatrixd(osg::Matrixd(rotation).ptr());
#endif
        }
        _drawable->draw(renderInfo);
        glPopMatrix();
    }
#else
    OSG_NOTICE<<"Warning: Particle::render(..) not supported for user-defined shape."<<std::endl;
#endif
}
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:28,代码来源:Particle.cpp

示例4: setInitPosition

/***************************************************************
* Function: setInitPosition()
***************************************************************/
void CAVEGeodeSnapSolidshape::setInitPosition(const osg::Vec3 &initPos, bool snap)
{
    if (snap)
    {
        /* round intersected position to integer multiples of 'mSnappingUnitDist' */
        Vec3 initPosRounded;
        float snapUnitX, snapUnitY, snapUnitZ;
        snapUnitX = snapUnitY = snapUnitZ = mSnappingUnitDist;
        if (initPos.x() < 0) 
            snapUnitX = -mSnappingUnitDist;
        if (initPos.y() < 0) 
            snapUnitY = -mSnappingUnitDist;
        if (initPos.z() < 0) 
            snapUnitZ = -mSnappingUnitDist;

        int xSeg = (int)(abs((int)((initPos.x() + 0.5 * snapUnitX) / mSnappingUnitDist)));
        int ySeg = (int)(abs((int)((initPos.y() + 0.5 * snapUnitY) / mSnappingUnitDist)));
        int zSeg = (int)(abs((int)((initPos.z() + 0.5 * snapUnitZ) / mSnappingUnitDist)));

        initPosRounded.x() = xSeg * snapUnitX;
        initPosRounded.y() = ySeg * snapUnitY;
        initPosRounded.z() = zSeg * snapUnitZ;

        mInitPosition = initPosRounded;
    }
    else
    {
        mInitPosition = initPos;
    }
}
开发者ID:Peachychan,项目名称:calvr_plugins,代码行数:33,代码来源:CAVEGeodeSnapSolidshape.cpp

示例5: createOffOriginOSGBox

osg::MatrixTransform* createOffOriginOSGBox( osg::Vec3 size )
{
    const osg::Vec3 dim( size * 2 );

    osg::Geode * geode = new osg::Geode;
    osg::Geometry * geom = new osg::Geometry;
    osg::Vec3Array * v = new osg::Vec3Array;

    v->resize( 8 );
    ( *v )[ 0 ] = osg::Vec3( 0, 0, 0 );
    ( *v )[ 1 ] = osg::Vec3( 0, dim.y(), 0 );
    ( *v )[ 2 ] = osg::Vec3( dim.x(), dim.y(), 0 );
    ( *v )[ 3 ] = osg::Vec3( dim.x(), 0, 0 );
    ( *v )[ 4 ] = osg::Vec3( 0, 0, dim.z() );
    ( *v )[ 5 ] = osg::Vec3( dim.x(), 0, dim.z() );
    ( *v )[ 6 ] = osg::Vec3( dim.x(), dim.y(), dim.z() );
    ( *v )[ 7 ] = osg::Vec3( 0, dim.y(), dim.z() );
    geom->setVertexArray( v );

    osg::Vec3Array * n = new osg::Vec3Array;
    n->resize( 6 );
    ( *n )[ 0 ] = osg::Vec3( 0, 0, -1 );
    ( *n )[ 1 ] = osg::Vec3( 0, 0, 1 );
    ( *n )[ 2 ] = osg::Vec3( -1, 0, 0 );
    ( *n )[ 3 ] = osg::Vec3( 1, 0, 0 );
    ( *n )[ 4 ] = osg::Vec3( 0, -1, 0 );
    ( *n )[ 5 ] = osg::Vec3( 0, 1, 0 );
    geom->setNormalArray( n );
    geom->setNormalBinding( osg::Geometry::BIND_PER_PRIMITIVE );

    osg::Vec4Array * c = new osg::Vec4Array;
    c->resize( 8 );
    ( *c )[ 0 ] = osg::Vec4( 1, 1, 1, 1 );
    ( *c )[ 1 ] = osg::Vec4( .6, 0, 0, 1 );
    ( *c )[ 2 ] = osg::Vec4( .6, 0, 0, 1 );
    ( *c )[ 3 ] = osg::Vec4( .6, 0, 0, 1 );
    ( *c )[ 4 ] = osg::Vec4( .6, 0, 0, 1 );
    ( *c )[ 5 ] = osg::Vec4( .6, 0, 0, 1 );
    ( *c )[ 6 ] = osg::Vec4( .6, 0, 0, 1 );
    ( *c )[ 7 ] = osg::Vec4( .6, 0, 0, 1 );
    geom->setColorArray( c );
    geom->setColorBinding( osg::Geometry::BIND_PER_VERTEX );

    GLushort indices[] =
    {
        0, 1, 2, 3,
        4, 5, 6, 7,
        0, 4, 7, 1,
        3, 2, 6, 5,
        0, 3, 5, 4,
        1, 7, 6, 2
    };
    geom->addPrimitiveSet( new osg::DrawElementsUShort( GL_QUADS, 24, indices ) );
    geode->addDrawable( geom );

    osg::MatrixTransform * mt = new osg::MatrixTransform();
    mt->addChild( geode );
    return( mt );
}
开发者ID:uji-ros-pkg,项目名称:uwsim_osgbullet,代码行数:59,代码来源:com.cpp

示例6: setZoom

void PanoDrawableLOD::setZoom(osg::Vec3 dir, float k)
{
    for(std::map<int,sph_model*>::iterator it = _pdi->modelMap.begin(); it!= _pdi->modelMap.end(); it++)
    {
	it->second->set_zoom(dir.x(),dir.y(),dir.z(),k);
    }

    for(std::map<int,sph_model*>::iterator it = _pdi->transitionModelMap.begin(); it!= _pdi->transitionModelMap.end(); it++)
    {
	it->second->set_zoom(dir.x(),dir.y(),dir.z(),k);
    }
}
开发者ID:TheNumenorean,项目名称:calvr_plugins,代码行数:12,代码来源:PanoDrawableLOD.cpp

示例7: loadSound

void AudioHandler::loadSound(int soundID, osg::Vec3 &dir, osg::Vec3 &pos)
{
    if (!_isConnected)
        return;

    uint8_t packet[256];
    int32_t size;

    float yaw, pitch, roll;

/*    yaw = acos(dir.x());
    if (dir.y() < 0) 
        yaw = M_PI * 2 - yaw;
    yaw += M_PI * 0.5;
    if (yaw > M_PI * 2) 
        yaw -= M_PI * 2;*/

    float val;
    if(dir.x() >= 0)
    {
        if(dir.y() >= 0)
        {
            val = acos( dir.x() );
        }
        else
        {
            val = 2*M_PI - acos( dir.x() );
        }
    }
    else
    {
        if(dir.y() >= 0)
        {
            val = M_PI - acos( -dir.x() );
        }
        else
        {
            val = M_PI + acos( -dir.x() );
        }
    }
    yaw = val;

    pitch = M_PI * 0.5 - atan(dir.z());
    roll = 0.0f;

    size = oscpack(packet, "/sc.elevators/pose", "iffffff", soundID, 
        pos.x() / 1000, pos.y() / 1000, pos.z() / 1000, yaw, pitch, roll);

    if (send(_sock, (char *) packet, size, 0))
    {
        //std::cerr << "AudioHandler  Viewer's info: " << viewPos.x() << " " << viewPos.y() << " " << viewPos.z() << std::endl;	
    }
}
开发者ID:Peachychan,项目名称:calvr_plugins,代码行数:53,代码来源:AudioHandler.cpp

示例8: dHashSpaceCreate

TouchSensor::TouchSensor(dSpaceID odeSpace, dBodyID sensorBody, float mass,
		osg::Vec3 pos, float x, float y, float z, std::string label) :
		collideSpace_(odeSpace), label_(label) {
	// create own space to avoid physical collisions with other objects
	sensorSpace_ = dHashSpaceCreate(0);
	// create Sensor geom in this different space
	dMass massOde;
	dMassSetBoxTotal(&massOde, mass, x, y, z);
	dBodySetMass(sensorBody, &massOde);
	sensorGeometry_ = dCreateBox(sensorSpace_, x, y, z);
	dBodySetPosition(sensorBody, pos.x(), pos.y(), pos.z());
	dGeomSetPosition(sensorGeometry_, pos.x(), pos.y(), pos.z());
	dGeomSetBody(sensorGeometry_, sensorBody);
}
开发者ID:Arpic,项目名称:robogen,代码行数:14,代码来源:TouchSensor.cpp

示例9:

osg::Vec3  CVehicle::calIntersectionPoint(const osg::Vec3& pa1,const osg::Vec3& pa2,const osg::Vec3& pb1,const osg::Vec3& pb2)
{
	osg::Vec3 intersectionPoint,pa12,pb12;
	double t;
	pa12 = pa2 - pa1;
	pb12 = pb2 - pb1;

	double temp =  (pa12.y() * pb12.x()) - (pb12.y() * pa12.x());
	if(temp < 0.001)
		return pa2;
	else
		t =( (pb1.y() - pa1.y()) * pb12.x() + (pa1.x() - pb1.x()) * pb12.y() ) / temp;

	double x,y,z;
	x = pa1.x() + pa12.x() * t;
	y = pa1.y() + pa12.y() * t;
	z = pa1.z() + pa12.z() * t;
	intersectionPoint.set(x,y,z);

	return intersectionPoint;



		



}
开发者ID:HOUWEI,项目名称:VirtualCity,代码行数:28,代码来源:Vehicle.cpp

示例10: getFloat

osg::Vec3 ConfigManager::getVec3(std::string attributeX, std::string attributeY,
        std::string attributeZ, std::string path, osg::Vec3 def, bool * found)
{
    bool hasEntry = false;
    bool isFound;

    osg::Vec3 result;
    result.x() = getFloat(attributeX,path,def.x(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.y() = getFloat(attributeY,path,def.y(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }
    result.z() = getFloat(attributeZ,path,def.z(),&isFound);
    if(isFound)
    {
        hasEntry = true;
    }

    if(found)
    {
        *found = hasEntry;
    }
    return result;
}
开发者ID:CalVR,项目名称:calvr,代码行数:29,代码来源:ConfigManager.cpp

示例11: calcCoordReprojTrans

osg::Vec2 calcCoordReprojTrans(const osg::Vec3 &vert,const osg::Matrix &trans,const osg::Matrix &viewProj,const osg::Vec2 &size,const osg::Vec4 &ratio){
    osg::Vec4 v(vert.x(),vert.y(),vert.z(),1.0);
    v=v*trans;
    v=v*viewProj;
    v.x() /= v.w();
    v.y() /= v.w();
    v.z() /= v.w();
    v.w() /= v.w();
    //std::cout << "Pre shift " << v << std::endl;
    v.x() /= size.x();;
    v.y() /= size.y();


    v.x() -= (ratio.x()/size.x());
    v.y() -= (ratio.y()/size.y());
    //std::cout << "Post shift " << v << std::endl;


    //  std::cout << "PP shift " << v << std::endl;


    osg::Vec2 tc(v.x(),v.y());
    tc.x() *= ratio.z();
    tc.y() *=ratio.w();
    //tc.x()*=ratio.x();
    //tc.y()*=ratio.y();
    tc.x()/=(ratio.z());
    tc.y()/=(ratio.w());


    return tc;

}
开发者ID:SorinS,项目名称:structured,代码行数:33,代码来源:imageNode.cpp

示例12: getValue

bool HeightFieldLayer::getValue(unsigned int i, unsigned int j, osg::Vec3& value) const
{
    value.x() = _heightField->getHeight(i,j);
    value.y() = _defaultValue.y();
    value.z() = _defaultValue.z();
    return true;
}
开发者ID:dev2dev,项目名称:OpenSceneGraph-port-to-IOS,代码行数:7,代码来源:Layer.cpp

示例13: addRandomClouds

void addRandomClouds(osg::Group* model, std::vector<Ref<CloudModel> >& clouds, osg::Vec3 dimensions, int count) {
	std::vector<Ref<CloudModel> >::size_type cloudIndex = 0;
	for(int i=0;i<count;++i, ++cloudIndex) {
		// Wrap around when there is no more clouds.
		if(cloudIndex >= clouds.size())
			cloudIndex = 0;

		float x = GenerateRandomNumber(0 - dimensions.x(), dimensions.x());
		float y = GenerateRandomNumber(0 - dimensions.y(), dimensions.y());
		float z = GenerateRandomNumber(0 - dimensions.z(), dimensions.z());

		osg::ref_ptr<osg::MatrixTransform> transformation = new osg::MatrixTransform();
		transformation->setMatrix(osg::Matrix::translate(x, y, z));
		transformation->addChild(clouds.at(cloudIndex)->getNode());
		model->addChild(transformation.get());
	}
}
开发者ID:nsmoooose,项目名称:csp,代码行数:17,代码来源:Program.cpp

示例14: makeQuat

osg::Quat makeQuat(const osg::Vec3& radians, ERotationOrder fbxRotOrder)
{
    fbxDouble3 degrees(
        osg::RadiansToDegrees(radians.x()),
        osg::RadiansToDegrees(radians.y()),
        osg::RadiansToDegrees(radians.z()));
    return makeQuat(degrees, fbxRotOrder);
}
开发者ID:dev2dev,项目名称:OpenSceneGraph-port-to-IOS,代码行数:8,代码来源:fbxRAnimation.cpp

示例15: addTrack

void VELOModel::addTrack(osg::Vec3& v1, osg::Vec3& v2){
	float d = sqrt(pow(v2.x()-v1.x(), 2) + pow(v2.y()-v1.y(), 2) + pow(v2.z()-v1.z(), 2));
	
	osg::ref_ptr<osg::MatrixTransform> t2 = new osg::MatrixTransform;
	t2->setMatrix( osg::Matrix::scale(1.0f, 1.0f, d) );
	t2->addChild( _trackGeode.get() );
	
	osg::ref_ptr<osg::MatrixTransform> t3 = new osg::MatrixTransform;
	t3->setMatrix( osg::Matrix::rotate(osg::Vec3f(0.0f, 0.0f, 1.0f), v2 - v1) );
	t3->addChild( t2.get() );

	osg::ref_ptr<osg::MatrixTransform> t1 = new osg::MatrixTransform;
	t1->setMatrix( osg::Matrix::translate(osg::Vec3f(((v2.x() - v1.x()) / 2.0f) + v1.x(), ((v2.y() - v1.y()) / 2.0f) + v1.y(), ((v2.z() - v1.z()) / 2.0f) + v1.z())) );
	t1->addChild( t3.get() );

	tracks->addChild( t1.get() );
}
开发者ID:albertgumi,项目名称:tracking,代码行数:17,代码来源:VELOModel.cpp


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