本文整理汇总了C++中osg::Vec3类的典型用法代码示例。如果您正苦于以下问题:C++ Vec3类的具体用法?C++ Vec3怎么用?C++ Vec3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vec3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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));
}
示例6: 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());
}
示例7: acos
double MultitouchNavigation::angleBetween3DVectors(osg::Vec3 v1, osg::Vec3 v2)
{
// http://codered.sat.qc.ca/redmine/projects/spinframework/repository/revisions/b6245189c19a7c6ba4fdb126940321c41c44e228/raw/src/spin/osgUtil.cpp
// normalize vectors (note: this must be done alone, not within any vector arithmetic. why?!)
v1.normalize();
v2.normalize();
// Get the dot product of the vectors
double dotProduct = v1 * v2;
// for acos, the value has to be between -1.0 and 1.0, but due to numerical imprecisions it sometimes comes outside this range
if (dotProduct > 1.0)
dotProduct = 1.0;
if (dotProduct < -1.0)
dotProduct = -1.0;
// Get the angle in radians between the 2 vectors (should this be -acos ? ie, negative?)
double angle = acos(dotProduct);
// Here we make sure that the angle is not a -1.#IND0000000 number, which means indefinite
if (std::isnan(angle)) //__isnand(x)
return 0;
// Return the angle in radians
return (angle);
}
示例8: 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);
}
示例9:
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;
}
示例10:
float HfT_osg_Plugin01_ParametricSurface::abstand(osg::Vec3 startPickPos, int i)
{
float x = (*mp_Points_Geom)[i].x() - startPickPos.x();
float y = (*mp_Points_Geom)[i].y() - startPickPos.y();
float z = (*mp_Points_Geom)[i].z() - startPickPos.z();
float abst = (float)sqrt(x * x + y * y + z * z);
return abst;
}
示例11: getElement
bool Uniform::getElement( unsigned int index, osg::Vec3& v3 ) const
{
if( index>=getNumElements() || !isCompatibleType(FLOAT_VEC3) ) return false;
unsigned int j = index * getTypeNumComponents(getType());
v3.x() = (*_floatArray)[j];
v3.y() = (*_floatArray)[j+1];
v3.z() = (*_floatArray)[j+2];
return true;
}
示例12: writeFloat
void DataOutputStream::writeVec3(const osg::Vec3& v){
// std::cout << "write " << _ostream->tellp() << std::endl;
writeFloat(v.x());
writeFloat(v.y());
writeFloat(v.z());
if (_verboseOutput) std::cout<<"read/writeVec3() ["<<v<<"]"<<std::endl;
}
示例13: 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
}
示例14: addHit
void VELOModel::addHit(osg::Vec3& coords){
osg::ref_ptr<osg::MatrixTransform> t1 = new osg::MatrixTransform;
t1->setMatrix( osg::Matrix::translate(
coords.x() - HIT_RADIUS,
coords.y(),
coords.z()) );
t1->addChild( _hitGeode.get() );
hits->addChild( t1.get() );
}
示例15:
inline osg::Vec3 ReaderWriterOBJ::transformNormal(const osg::Vec3& vec, const bool rotate) const
{
if(rotate==true)
{
return osg::Vec3(vec.x(),-vec.z(),vec.y());
}
else
{
return vec;
}
}