本文整理汇总了C++中osg::Vec2::y方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec2::y方法的具体用法?C++ Vec2::y怎么用?C++ Vec2::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Vec2
的用法示例。
在下文中一共展示了Vec2::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: projectWindowXYIntoObject
bool PointerInfo::projectWindowXYIntoObject(const osg::Vec2& windowCoord, osg::Vec3& nearPoint, osg::Vec3& farPoint) const
{
nearPoint = osg::Vec3(windowCoord.x(),windowCoord.y(),0.0f)*_inverseMVPW;
farPoint = osg::Vec3(windowCoord.x(),windowCoord.y(),1.0f)*_inverseMVPW;
return true;
}
示例2: operator
void Selector::operator ()(osg::Vec2 start, osg::Vec2 stop, bool select) {
if (!this->m_viewer || !this->m_model) return;
osg::ref_ptr<osgUtil::PolytopeIntersector> picker = new osgUtil::PolytopeIntersector(
osgUtil::Intersector::CoordinateFrame::WINDOW, start.x(), start.y(), stop.x(), stop.y());
picker->setDimensionMask(this->m_selection->mask());
osgUtil::IntersectionVisitor visitor(picker);
visitor.setTraversalMask(Role::Node::Pickable);
this->m_viewer->getCamera()->accept(visitor);
OcclusionTester tester(this->m_model);
if (this->m_model->kdTree().valid()) {
osg::Vec3 position(0.0f, 0.0f, 0.0f);
this->m_viewer->getCamera()->getViewMatrixAsLookAt(position, osg::Vec3(), osg::Vec3());
tester.setMask(this->m_selection->mask());
tester.setPosition(algo::Util::toPoint(position));
}
if (picker->containsIntersections()) {
const osgUtil::PolytopeIntersector::Intersections &intersections(picker->getIntersections());
if (select) {
for (osgUtil::PolytopeIntersector::Intersections::const_iterator iter = intersections.begin(); iter != intersections.end(); ++iter) {
if (tester.occluded(iter->primitiveIndex)) continue;
this->m_selection->indices().insert(iter->primitiveIndex);
}
} else {
for (osgUtil::PolytopeIntersector::Intersections::const_iterator iter = intersections.begin(); iter != intersections.end(); ++iter) {
if (tester.occluded(iter->primitiveIndex)) continue;
this->m_selection->indices().remove(iter->primitiveIndex);
}
}
}
this->m_selection->update();
}
示例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: setPosition
/**
* \fn void MenuButton::setPosition(osg::Vec2 pos)
*
* \brief Sets a position of button.
*
* \param pos The position.
*/
void MenuButton::setPosition(osg::Vec2 pos)
{
osg::Vec3Array* verts = new osg::Vec3Array(4);
(*verts)[0] = osg::Vec3( pos.x() - 0.5, 0, pos.y() - 0.5);
(*verts)[1] = osg::Vec3( pos.x() + 0.5, 0, pos.y() - 0.5);
(*verts)[2] = osg::Vec3( pos.x() + 0.5, 0, pos.y() + 0.5);
(*verts)[3] = osg::Vec3( pos.x() - 0.5, 0, pos.y() + 0.5);
this->setVertexArray(verts);
}
示例5: Create
bool TextRegion::Create(osg::Vec2 corner, osg::Vec2 size, RegionStyle* style )
{
//set ref height for scaling in setsize
_scaleHeightRef = size.y();
//
//
bool ret = StrokeRegion::Create(corner,size,style);
//set ref height for scaling in setsize
_scaleHeightRef = size.y();
this->SetSize(_size);
return ret;
}
示例6: osgImage
osg::Matrix vpb::MyDataSet::getImageSection(vips::VImage &in,const osg::Vec2 minT, const osg::Vec2 maxT,int origX,int origY,osg::Vec4 &texsize,const osg::Matrix &toTex,osg::ref_ptr<osg::Image> &image,osg::Vec4 &ratio,int level){
double downsampleFactor=pow(2,level);
double downsampleRatio=1.0/downsampleFactor;
// std::cout<< minT << " " << maxT<<std::endl;
// printf("%f %f\n",downsampleRatio,downsampleRatio);
int x=(int)std::max((int)floor(minT.x()),0);
int y=(int)std::max((int)floor(minT.y()),0);
int xMax=(int)std::min((int)ceil(maxT.x()),origX);
int yMax=(int)std::min((int)ceil(maxT.y()),origY);
int xRange=(xMax-x);
int yRange=(yMax-y);
//printf("X:%d -- %d Y:%d -- %d ",x,xMax,y,yMax);
//Need bias of 1.0 or will round down
double maxSide=std::max(osg::Image::computeNearestPowerOfTwo(xRange,1.0),osg::Image::computeNearestPowerOfTwo(yRange,1.0));
osg::Vec2 subSize=osg::Vec2(maxSide,maxSide);
if(downsampleRatio*maxSide < 1.0){
printf("Clipping %f %f to",downsampleRatio,downsampleFactor);
downsampleRatio=1.0/maxSide;
downsampleFactor=maxSide;
printf("%f %f\n",downsampleRatio,downsampleFactor);
}
texsize[0]=origX;
texsize[1]=origY;
texsize[2]=subSize.x();
texsize[3]=subSize.y();
osg::Vec2 downsampleSize(subSize.x(),subSize.y());
downsampleSize.x()*=downsampleRatio;
downsampleSize.y()*=downsampleRatio;
// printf("Range %d %d\n",xRange,yRange);
// printf("%f %f %f %f\n",subSize.x(),subSize.y(),downsampleSize.x(),downsampleSize.y());
image = new osg::Image;
image->allocateImage(downsampleSize.x(),downsampleSize.y(), 1, GL_RGB,GL_UNSIGNED_BYTE);
if(image->data() == 0 ){
fprintf(stderr,"Failed to allocate\n");
exit(-1);
}
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_imageMutex);
vips::VImage osgImage(image->data(),downsampleSize.x(),downsampleSize.y(),3,vips::VImage::FMTUCHAR);
in.extract_area(x,y,xRange,yRange).embed(1,0,0,subSize.x(),subSize.y()).shrink(downsampleFactor,downsampleFactor).write(osgImage);
}
ratio=osg::Vec4(x,y,subSize.x(),subSize.y());
//osg::Vec2 f(xRange-subSize.x(),yRange-subSize.y());
//std::cout << f<<std::endl;
return toTex;
}
示例7: SetSize
//overload SetSize so we can set the texts pixelheight independantly
void TextRegion::SetSize(const osg::Vec2& size)
{
StrokeRegion::SetSize(size);
//set the texts max sizes to the new size
_text->setMaximumHeight(size.y());
_text->setMaximumWidth(size.x());
float scaler = 1.0f / _scaleHeightRef;
float sizeScale = size.y()*scaler;
_textScale->setMatrix(osg::Matrix::scale(osg::Vec3(sizeScale,sizeScale,sizeScale)));
//set new centered position
this->SetAlignment(_alignmentMode);
}
示例8: moveTo
void moveTo(const osg::Vec2& pos)
{
completeCurrentPrimitiveSet();
addVertex( osg::Vec3(pos.x(),pos.y(),0) );
}
示例9: updateRandomNumber
void HUDView::updateRandomNumber(std::string number, osg::Vec2 normalizedPosition)
{
if (number == "")
{
m_randomNumberText->setText("");
m_backgroundGeode->setNodeMask(0); //invisible
return;
}
float offset = m_width / 15;
float halfextent = m_backgroundGeode->getBound().radius();
float max_x = m_width - offset - halfextent;
float max_y = m_height - offset;
float p_x = clamp(halfextent, max_x, (normalizedPosition.x() * m_width));
float p_y = clamp(halfextent + offset, max_y, (normalizedPosition.y() * m_height));
osg::Vec2 position(p_x, p_y);
m_backgroundGeode->setNodeMask(0xffffffff); //visible
m_backgroundTransform->setMatrix(osg::Matrix::translate(osg::Vec3(position, 0)));
m_randomNumberText->setPosition(osg::Vec3(position,0.0));
m_randomNumberText->setText(number);
}
示例10: getElement
bool Uniform::getElement( unsigned int index, osg::Vec2& v2 ) const
{
if( index>=getNumElements() || !isCompatibleType(FLOAT_VEC2) ) return false;
unsigned int j = index * getTypeNumComponents(getType());
v2.x() = (*_floatArray)[j];
v2.y() = (*_floatArray)[j+1];
return true;
}
示例11:
osg::Vec2 CityModel::pixelToWorld(osg::Vec2 pixel)
{
osg::Vec2 levelSize = pairToVec2(getLevelSize());
osg::Vec2 picSize = osg::Vec2(m_collisionImage.width(), m_collisionImage.height());
double x = ((pixel.x() / picSize.x()) * levelSize.x()) - levelSize.x() / 2;
double y = ((pixel.y() / picSize.y()) * levelSize.y()) - levelSize.y() / 2;
return osg::Vec2(x, y);
}
示例12: conicTo
void conicTo(const osg::Vec2& control, const osg::Vec2& pos)
{
osg::Vec3 p0 = _previous;
osg::Vec3 p1 = osg::Vec3(control.x(),control.y(),0);
osg::Vec3 p2 = osg::Vec3(pos.x(),pos.y(),0);
double dt = 1.0/_numSteps;
double u=0;
for (int i=0; i<=_numSteps; ++i)
{
double w = 1;
double bs = 1.0/( (1-u)*(1-u)+2*(1-u)*u*w +u*u );
osg::Vec3 p = (p0*((1-u)*(1-u)) + p1*(2*(1-u)*u*w) + p2*(u*u))*bs;
addVertex( p );
u += dt;
}
}
示例13:
void Utility::SelectBox::Show(osg::Vec2 point1,osg::Vec2 point2 )
{
if(!m_initialized) return;
osg::Geometry* geom = m_selectbox->getDrawable(0)->asGeometry();
if(geom)
{
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geom->getVertexArray());
vertices->at(0) = osg::Vec3(point1.x(),point1.y(),0.0);
vertices->at(1) = osg::Vec3(point2.x(),point1.y(),0.0);
vertices->at(2) = osg::Vec3(point2.x(),point2.y(),0.0);
vertices->at(3) = osg::Vec3(point1.x(),point2.y(),0.0);
m_selectbox->setNodeMask(CLASSCODE::PseudMouseDrawBox);
geom->dirtyBound();
geom->dirtyDisplayList();
}
}
示例14: getValue
bool ContourLayer::getValue(unsigned int i, unsigned int j, osg::Vec2& value) const
{
if (!_tf) return false;
const osg::Vec4& v = _tf->getPixelValue(i);
value.x() = v.x();
value.y() = v.y();
return true;
}
示例15: 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 );
}