本文整理汇总了C++中osg::Vec3::x方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3::x方法的具体用法?C++ Vec3::x怎么用?C++ Vec3::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Vec3
的用法示例。
在下文中一共展示了Vec3::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例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
double 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() );
}
示例3: 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 );
}
示例4: 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());
}
示例5: 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);
}
}
示例6: 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);
}
示例7: 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;
}
示例8: setMinMax
void setMinMax(const osg::Vec3& pos)
{
_maxY = std::max(_maxY, (double) pos.y());
_minY = std::min(_minY, (double) pos.y());
_maxX = std::max(_maxX, (double) pos.x());
_minX = std::min(_minX, (double) pos.x());
}
示例9: addEdgePlane
void addEdgePlane(const osg::Vec3& corner, const osg::Vec3& edge)
{
osg::Vec3 normal( edge.y(), -edge.x(), 0.0f);
normal.normalize();
add(osg::Plane(normal, corner));
}
示例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;
}
示例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;
}
示例12: 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);
}
示例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());
}
}
示例14:
osg::Vec3 Particle_Viewer::fixPosition(osg::Vec3 position)
{
osg::Vec3 fixPosition;
fixPosition.x()=position.x();
fixPosition.y()=position.z();
fixPosition.z()=position.y();
return fixPosition;
}
示例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() );
}