/** * Check whether the location is inside the box. * * @pre Location must be defined. * @pre Box must be defined. */ bool contains(const osmium::Location& location) const noexcept { assert(bottom_left()); assert(top_right()); assert(location); return location.x() >= bottom_left().x() && location.y() >= bottom_left().y() && location.x() <= top_right().x() && location.y() <= top_right().y(); }
bool MapReader::GetRoadsInBounds(IPosition::GPS top_left, IPosition::GPS bottom_right, std::vector<std::string> & street_names) { IPosition::GPS bottom_left(bottom_right.lat, top_left.lon, 0.0); IPosition::GPS top_right(top_left.lat, bottom_right.lon, 0.0); for (unsigned i = 0; i < ways.size(); i++) { const Way & way = ways[i]; IPosition::GPS way_lower_left, way_upper_right; GetWayBounds(way, way_lower_left, way_upper_right); bool left_in_bounds = way_lower_left.lon > bottom_left.lon && way_lower_left.lon < top_right.lon; bool right_in_bounds = way_upper_right.lon > bottom_left.lon && way_upper_right.lon < top_right.lon; bool top_in_bounds = way_upper_right.lat > bottom_left.lat && way_upper_right.lat < top_right.lat; bool bottom_in_bounds = way_lower_left.lat > bottom_left.lat && way_lower_left.lat < top_right.lat; if ((left_in_bounds && (top_in_bounds || bottom_in_bounds)) || (right_in_bounds && (top_in_bounds || bottom_in_bounds))) { if (std::find(street_names.begin(), street_names.end(), way.name) == street_names.end()) { street_names.push_back(way.name); } } } return true; }
worksheet::const_iterator worksheet::cend() const { auto dimensions = calculate_dimension(); auto past_end_row_index = dimensions.get_bottom_right().get_row() + 1; cell_reference bottom_left(dimensions.get_top_left().get_column_index(), past_end_row_index); cell_reference bottom_right(dimensions.get_bottom_right().get_column_index(), past_end_row_index); return const_iterator(*this, range_reference(bottom_left, bottom_right), major_order::row); }
bool aabr_smallest_subaabr_containing_line (aabr const& r, move2 const& line, aabr& res__aabr) { real2 p1,p2; real unused, thouShaltNotPass; if( line_intersection(r, line, p1, unused, p2, thouShaltNotPass) ) { real2 bottom_left( MIN(p1.x,p2.x), MIN(p1.y,p2.y)); real2 top_right( MAX(p1.x,p2.x), MAX(p1.y,p2.y)); res__aabr = aabr( bottom_left, top_right - bottom_left ); return true; } else return false; }
//------------------------------------------------------------------------------ void QLabel::CalculateSize( void) { CCPoint bottom_left( 0.0f, 0.0f); CCSize content_size = m_CCFontNode->getContentSize(); CCPoint top_right( content_size.width, content_size.height); CCAffineTransform to_parent = CCAffineTransformConcat(m_CCFontNode->nodeToParentTransform(), m_CCNode->nodeToParentTransform()); bottom_left = CCPointApplyAffineTransform( bottom_left, to_parent); top_right = CCPointApplyAffineTransform( top_right, to_parent); xText = bottom_left.x; yText = bottom_left.y; wText = top_right.x - bottom_left.x; hText = top_right.y - bottom_left.y; }
int ccc_win_main() { Point top_left(1, 3); Point top_right(1, 4); Point bottom_left(2, 3); Line horizontal(top_left, top_right); Line vertical(top_left, bottom_left); cwin << horizontal << vertical; horizontal.move(1, 0); vertical.move(0, 1); cwin << horizontal << vertical; return 0; }
OrientedBoxInterface::OrientedBoxInterface(const InputParameters & parameters) : _center(parameters.get<Point>("center")) { const std::string & name = parameters.get<std::string>("_object_name"); // Define the bounding box Real xmax = 0.5 * parameters.get<Real>("width"); Real ymax = 0.5 * parameters.get<Real>("length"); Real zmax = 0.5 * parameters.get<Real>("height"); Point bottom_left(-xmax, -ymax, -zmax); Point top_right(xmax, ymax, zmax); _bounding_box = new MeshTools::BoundingBox(bottom_left, top_right); /* * now create the rotation matrix that rotates the oriented * box's width direction to "x", its length direction to "y" * and its height direction to "z" */ RealVectorValue w = parameters.get<RealVectorValue>("width_direction"); RealVectorValue l = parameters.get<RealVectorValue>("length_direction"); /* * Normalize the width and length directions in readiness for * insertion into the rotation matrix */ Real len = w.norm(); if (len == 0.0) mooseError("Length of width_direction vector is zero in " << name); w /= len; len = l.norm(); if (len == 0.0) mooseError("Length of length_direction vector is zero in " << name); l /= len; if (w*l > 1E-10) mooseError("width_direction and length_direction are not perpendicular in " << name); // The rotation matrix! _rot_matrix = new RealTensorValue(w, l, w.cross(l)); }
HudMainPanel::HudMainPanel(const FRect &rect) :HudLayer(rect) { float2 bottom_left(spacing, rect.height() - spacing); FRect char_rect(s_hud_char_icon_size); char_rect += bottom_left - float2(0, char_rect.height()); FRect weapon_rect(s_hud_weapon_size); weapon_rect += float2(char_rect.max.x + spacing, bottom_left.y - weapon_rect.height()); m_hud_char_icon = make_shared<HudCharIcon>(char_rect); m_hud_weapon = make_shared<HudWeapon>(weapon_rect); { FRect stance_rect(s_hud_stance_size); stance_rect += float2(weapon_rect.max.x + spacing, bottom_left.y - s_hud_stance_size.y); for(int n = 0; n < arraySize(s_stance_buttons); n++) { PHudButton stance(new HudRadioButton(stance_rect, (int)s_stance_buttons[n].stance_id, 1)); stance->setIcon(s_stance_buttons[n].icon_id); m_hud_stances.push_back(std::move(stance)); stance_rect += float2(0.0f, -s_hud_stance_size.y - spacing); } } { FRect button_rect = align(FRect(s_hud_button_size), char_rect, align_top, spacing); button_rect += float2(char_rect.min.x - button_rect.min.x, 0.0f); for(int n = 0; n < arraySize(s_buttons); n++) { PHudButton button(new HudToggleButton(button_rect, s_buttons[n].layer_id)); button->setLabel(s_buttons[n].name); m_hud_buttons.emplace_back(std::move(button)); button_rect += float2(button_rect.width() + spacing, 0.0f); } } attach(m_hud_weapon); attach(m_hud_char_icon); for(int n = 0; n < (int)m_hud_buttons.size(); n++) attach(m_hud_buttons[n]); for(int n = 0; n < (int)m_hud_stances.size(); n++) attach(m_hud_stances[n]); }
osg::Node* createWrapWall(osg::BoundingBox& bb,const std::string& filename) { osg::Group* group = new osg::Group; // left hand side of bounding box. osg::Vec3 top_left(bb.xMax(),bb.yMax(),bb.zMax()); osg::Vec3 bottom_left(bb.xMax(),bb.yMax(),bb.zMin()); osg::Vec3 bottom_right(bb.xMax(),bb.yMin(),bb.zMin()); osg::Vec3 top_right(bb.xMax(),bb.yMin(),bb.zMax()); osg::Vec3 center(bb.xMax(),(bb.yMin()+bb.yMax())*0.5f,(bb.zMin()+bb.zMax())*0.5f); float height = bb.zMax()-bb.zMin(); // create the geometry for the wall. osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* vertices = new osg::Vec3Array(4); (*vertices)[0] = top_left; (*vertices)[1] = bottom_left; (*vertices)[2] = bottom_right; (*vertices)[3] = top_right; geom->setVertexArray(vertices); osg::Vec2Array* texcoords = new osg::Vec2Array(4); (*texcoords)[0].set(-1.0f,2.0f); (*texcoords)[1].set(-1.0f,-1.0f); (*texcoords)[2].set(2.0f,-1.0f); (*texcoords)[3].set(2.0f,2.0f); geom->setTexCoordArray(0,texcoords); osg::Vec3Array* normals = new osg::Vec3Array(1); (*normals)[0].set(-1.0f,0.0f,0.0f); geom->setNormalArray(normals, osg::Array::BIND_OVERALL); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0].set(1.0f,1.0f,1.0f,1.0f); geom->setColorArray(colors, osg::Array::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); osg::Geode* geom_geode = new osg::Geode; geom_geode->addDrawable(geom); group->addChild(geom_geode); // set up the texture state. osg::Texture2D* texture = new osg::Texture2D; texture->setDataVariance(osg::Object::DYNAMIC); // protect from being optimized away as static state. texture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,0.5f)); // only used when wrap is set to CLAMP_TO_BORDER texture->setImage(osgDB::readRefImageFile(filename)); osg::StateSet* stateset = geom->getOrCreateStateSet(); stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); stateset->setMode(GL_BLEND,osg::StateAttribute::ON); stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); // create the text label. osgText::Text* text = new osgText::Text; text->setDataVariance(osg::Object::DYNAMIC); text->setFont("fonts/arial.ttf"); text->setPosition(center); text->setCharacterSize(height*0.03f); text->setAlignment(osgText::Text::CENTER_CENTER); text->setAxisAlignment(osgText::Text::YZ_PLANE); osg::Geode* text_geode = new osg::Geode; text_geode->addDrawable(text); osg::StateSet* text_stateset = text_geode->getOrCreateStateSet(); text_stateset->setAttributeAndModes(new osg::PolygonOffset(-1.0f,-1.0f),osg::StateAttribute::ON); group->addChild(text_geode); // set the update callback to cycle through the various min and mag filter modes. group->setUpdateCallback(new WrapCallback(texture,text)); return group; }
JNIEXPORT void JNICALL Java_org_openscenegraph_osg_core_Geode_nativeGetTextureRectangle2( JNIEnv *env, jclass, jlong cptr, jlong imagecptr, jfloat width, jfloat height) { osg::Geode *geode = reinterpret_cast<osg::Geode *>(cptr); osg::Image *image = reinterpret_cast<osg::Image *>(imagecptr); osg::BoundingBox bb(0.0f,0.0f,0.0f,width,height,0.0f); osg::Vec3 top_left(bb.xMin(),bb.yMax(),bb.zMax()); osg::Vec3 bottom_left(bb.xMin(),bb.yMin(),bb.zMax()); osg::Vec3 bottom_right(bb.xMax(),bb.yMin(),bb.zMax()); osg::Vec3 top_right(bb.xMax(),bb.yMax(),bb.zMax()); // create geometry osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* vertices = new osg::Vec3Array(6); (*vertices)[0] = top_left; (*vertices)[1] = bottom_left; (*vertices)[2] = bottom_right; (*vertices)[3] = bottom_right; (*vertices)[4] = top_right; (*vertices)[5] = top_left; geom->setVertexArray(vertices); osg::Vec2Array* texcoords = new osg::Vec2Array(6); (*texcoords)[0].set(0.0f, 0.0f); (*texcoords)[1].set(0.0f, 1.0f); (*texcoords)[2].set(1.0f, 1.0f); (*texcoords)[3].set(1.0f, 1.0f); (*texcoords)[4].set(1.0f, 0.0f); (*texcoords)[5].set(0.0f, 0.0f); geom->setTexCoordArray(0,texcoords); osg::Vec3Array* normals = new osg::Vec3Array(1); (*normals)[0].set(0.0f,-1.0f,0.0f); geom->setNormalArray(normals); geom->setNormalBinding(osg::Geometry::BIND_OVERALL); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0].set(1.0f,1.0f,1.0f,1.0f); geom->setColorArray(colors); geom->setColorBinding(osg::Geometry::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLES, 0, 6)); // disable display list so our modified tex coordinates show up geom->setUseDisplayList(false); // setup texture osg::Texture2D* texture = new osg::Texture2D(image); texture->setDataVariance(osg::Object::DYNAMIC); /*/////////////////////kookmin start/////////////////////*/ // setup state osg::StateSet* state = geom->getOrCreateStateSet(); state->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); /*/////////////////////kookmin start/////////////////////*/ // turn off lighting state->setMode(GL_LIGHTING, osg::StateAttribute::OFF); texture->ref(); //image->ref(); geom->ref(); geode->addDrawable(geom); }
void MyRendererTFEditor_TFE::paintEvent( QPaintEvent * ) { QPainter painter( this ); painter.setRenderHint( QPainter::Antialiasing, false ); int s_w = this->size().width(); int s_h = this->size().height(); std::vector < TFEMarker > mrks; // remove isomarker for convienence TFEMarkers tfe_markers = m_tfe_markers; for( int i = 0 ; i < tfe_markers.markers.size() ; ) if( tfe_markers.markers.at( i ).b_iso ) tfe_markers.delMarker( i ); else i++; mrks = tfe_markers.markers; // paint tranfer function indirectly via tf markers for( int i = 0 ; i < mrks.size() - 1 ; i++ ) { QPoint bottom_left( rescale( m_display_min, m_display_max, mrks.at( i ).x, 0.0, 1.0 ) * s_w, s_h ); QPoint top_left( rescale( m_display_min, m_display_max, mrks.at( i ).x, 0.0, 1.0 ) * s_w, ( 1 - mrks.at( i ).color_right.alphaF() ) * s_h ); QPoint bottom_right( rescale( m_display_min, m_display_max, mrks.at( i+1 ).x, 0.0, 1.0 ) * s_w, s_h ); QPoint top_right( rescale( m_display_min, m_display_max, mrks.at( i+1 ).x, 0.0, 1.0 ) * s_w, ( 1 - mrks.at( i+1 ).color_left.alphaF() ) * s_h ); QPoint points[] = { top_right, bottom_right, bottom_left, top_left }; QLinearGradient gradient( bottom_left, bottom_right ); gradient.setColorAt( 0, mrks.at( i ).color_right ); gradient.setColorAt( 1, mrks.at( i+1 ).color_left ); painter.setPen( Qt::transparent ); painter.setBrush( gradient ); painter.drawPolygon( points, 4 ); } // paint histogram //for( int i = 0 ; i < TF_SIZE ; i++ ) //{ // int x_rescaled = int(rescale( 0, s_w - 1, i, m_display_min * ( TF_SIZE - 1 ), m_display_max * ( TF_SIZE - 1 ) )); // // // paint histogram // painter.setPen( QColor( 185, 185, 185, 75 ) ); // painter.drawLine( QLineF( i, // s_h, // i, // s_h - m_histogram[x_rescaled] * s_h ) ); //} painter.setRenderHint( QPainter::Antialiasing, true ); mrks = m_tfe_markers.markers; // paint markers for( int i = 1 ; i < mrks.size() - 1 ; i++ ) { float rect_center_x = ( rescale( m_display_min, m_display_max, mrks.at(i).x, 0.0, 1.0 ) * s_w ); float rect_center_y; QColor color_marker; int size_mark = 3; // paint vertical lines for iso marker if( mrks.at( i ).b_iso ) { painter.setRenderHint( QPainter::Antialiasing, false ); painter.setPen( QColor( 0, 0, 0, 50 ) ); painter.drawLine( QLineF( rect_center_x - 1, s_h, rect_center_x - 1, 0 ) ); painter.drawLine( QLineF( rect_center_x + 1, s_h, rect_center_x + 1, 0 ) ); painter.setPen( mrks.at( i ).color_left ); painter.drawLine( QLineF( rect_center_x, s_h, rect_center_x, 0 ) ); painter.setRenderHint( QPainter::Antialiasing, true ); } // draw markers rect_center_y = ( s_h - mrks.at(i).color_left.alpha() * s_h / 255.0 ); color_marker = mrks.at(i).color_left; color_marker.setAlpha( 255 ); if( mrks.at(i).color_left == mrks.at(i).color_right ) { painter.setPen( Qt::black ); painter.setBrush( Qt::NoBrush ); painter.drawEllipse( QRectF( rect_center_x - size_mark - 1, rect_center_y - size_mark - 1, 2*size_mark + 3 , 2*size_mark + 3 ) ); painter.setPen( color_marker ); painter.setBrush( QBrush( color_marker ) ); painter.drawEllipse( QRectF( rect_center_x - size_mark, rect_center_y - size_mark, 2*size_mark + 1 , 2*size_mark + 1 ) ); } else { painter.setPen( Qt::black ); painter.setBrush( Qt::NoBrush ); painter.drawEllipse( QRectF( rect_center_x - size_mark - 1, rect_center_y - size_mark - 1, 2*size_mark + 3 , 2*size_mark + 3 ) ); painter.setPen( color_marker ); painter.setBrush( QBrush( color_marker ) ); painter.drawEllipse( QRectF( rect_center_x - size_mark, rect_center_y - size_mark, 2*size_mark + 1 , 2*size_mark + 1 ) ); rect_center_y = ( s_h - mrks.at(i).color_right.alpha() * s_h / 255.0 ); color_marker = mrks.at(i).color_right; color_marker.setAlpha( 255 ); painter.setPen( Qt::black ); painter.setBrush( Qt::NoBrush ); painter.drawEllipse( QRectF( rect_center_x - size_mark - 1, rect_center_y - size_mark - 1, 2*size_mark + 3 , 2*size_mark + 3 ) ); painter.setPen( color_marker ); painter.setBrush( QBrush( color_marker ) ); painter.drawEllipse( QRectF( rect_center_x - size_mark, rect_center_y - size_mark, 2*size_mark + 1 , 2*size_mark + 1 ) ); } } // draw white circle around selected marker if( m_tfe_marker_selected != 0 ) { float rect_center_x = rescale( m_display_min, m_display_max, mrks.at(m_tfe_marker_selected).x, 0.0, 1.0 ) * s_w; float rect_center_y; int size_mark = 5; painter.setPen( QColor( 0, 0, 0, 50 ) ); painter.setBrush( Qt::NoBrush ); rect_center_y = s_h - mrks.at(m_tfe_marker_selected).color_left.alpha() * s_h / 255.0; if( mrks.at( m_tfe_marker_selected ).color_left == mrks.at( m_tfe_marker_selected ).color_right ) painter.drawEllipse( QRectF( rect_center_x - size_mark, rect_center_y - size_mark, 2*size_mark + 1 , 2*size_mark + 1 ) ); else { painter.drawEllipse( QRectF( rect_center_x - size_mark, rect_center_y - size_mark, 2*size_mark + 1 , 2*size_mark + 1 ) ); rect_center_y = s_h - mrks.at(m_tfe_marker_selected).color_right.alpha() * s_h / 255.0; painter.drawEllipse( QRectF( rect_center_x - size_mark, rect_center_y - size_mark, 2*size_mark + 1 , 2*size_mark + 1 ) ); } } // draw translucent white divisions int count_divisions; count_divisions = 20; for( int i = 1; i < count_divisions; i++ ) { float tenth = s_w / float( count_divisions ); painter.setPen( QColor( 255, 255, 255, 65 ) ); painter.drawLine( QLineF( tenth * i, 0, tenth * i, s_h ) ); painter.drawText( QPoint( tenth* i + 4, s_h - 3 ), tr( "%1" ).arg( m_display_min + ( m_display_max - m_display_min ) * i / count_divisions, 0, 'f', 2 ) ); } count_divisions = 5; for( int i = 1; i < count_divisions; i++ ) { float fourth = s_h / float( count_divisions ); painter.setPen( QColor( 255, 255, 255, 65 ) ); painter.drawLine( QLineF( 0, fourth * i, s_w, fourth * i ) ); } // paint black rectangular border painter.setRenderHint( QPainter::Antialiasing, false ); painter.setPen( QColor( 0, 0, 0, 50 ) ); painter.setBrush( Qt::NoBrush ); painter.drawRect( 0, 0, s_w - 1, s_h - 1 ); }
virtual ng::vertex_list3 map() const { auto r = bounding_box(); return ng::vertex_list3{ r.top_left().to_vector3(), r.top_right().to_vector3(), r.bottom_right().to_vector3(), r.bottom_left().to_vector3() }; }
/** * Bounds are valid, ie. defined and inside usual bounds * (-180<=lon<=180, -90<=lat<=90). */ constexpr bool valid() const noexcept { return bottom_left().valid() && top_right().valid(); }
osg::Node* createRectangle(osg::BoundingBox& bb, const std::string& filename) { osg::Vec3 top_left(bb.xMin(),bb.yMax(),bb.zMax()); osg::Vec3 bottom_left(bb.xMin(),bb.yMax(),bb.zMin()); osg::Vec3 bottom_right(bb.xMax(),bb.yMax(),bb.zMin()); osg::Vec3 top_right(bb.xMax(),bb.yMax(),bb.zMax()); // create geometry osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* vertices = new osg::Vec3Array(4); (*vertices)[0] = top_left; (*vertices)[1] = bottom_left; (*vertices)[2] = bottom_right; (*vertices)[3] = top_right; geom->setVertexArray(vertices); osg::Vec2Array* texcoords = new osg::Vec2Array(4); (*texcoords)[0].set(0.0f, 0.0f); (*texcoords)[1].set(1.0f, 0.0f); (*texcoords)[2].set(1.0f, 1.0f); (*texcoords)[3].set(0.0f, 1.0f); geom->setTexCoordArray(0,texcoords); osg::Vec3Array* normals = new osg::Vec3Array(1); (*normals)[0].set(0.0f,-1.0f,0.0f); geom->setNormalArray(normals, osg::Array::BIND_OVERALL); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0].set(1.0f,1.0f,1.0f,1.0f); geom->setColorArray(colors, osg::Array::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4)); // disable display list so our modified tex coordinates show up geom->setUseDisplayList(false); // load image osg::ref_ptr<osg::Image> img = osgDB::readRefImageFile(filename); // setup texture osg::TextureRectangle* texture = new osg::TextureRectangle(img); osg::TexMat* texmat = new osg::TexMat; texmat->setScaleByTextureRectangleSize(true); // setup state osg::StateSet* state = geom->getOrCreateStateSet(); state->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); state->setTextureAttributeAndModes(0, texmat, osg::StateAttribute::ON); // turn off lighting state->setMode(GL_LIGHTING, osg::StateAttribute::OFF); // install 'update' callback osg::Geode* geode = new osg::Geode; geode->addDrawable(geom); geode->setUpdateCallback(new TexturePanCallback(texmat)); return geode; }
//------------------------------------------------------------------------------ void Background2D::AddTile( const int x, const int y, const int width, const int height, const float depth, const float u1, const float v1, const float u2, const float v2, const Blending blending ) { Ogre::RenderOperation render_op; Ogre::HardwareVertexBufferSharedPtr vertex_buffer; unsigned int max_vertex_count; if( blending == QGears::B_ALPHA ) { render_op = m_AlphaRenderOp; vertex_buffer = m_AlphaVertexBuffer; max_vertex_count = m_AlphaMaxVertexCount; } else if( blending == QGears::B_ADD ) { render_op = m_AddRenderOp; vertex_buffer = m_AddVertexBuffer; max_vertex_count = m_AddMaxVertexCount; } else { LOG_ERROR( "Unknown blending type." ); return; } if( render_op.vertexData->vertexCount + TILE_VERTEX_COUNT > max_vertex_count ) { LOG_ERROR( "Max number of tiles reached. Can't create more than " + Ogre::StringConverter::toString( max_vertex_count / TILE_VERTEX_COUNT ) + " tiles." ); return; } Tile tile; tile.x = x; tile.y = y; tile.width = width; tile.height = height; tile.start_vertex_index = render_op.vertexData->vertexCount; tile.blending = blending; size_t index( m_Tiles.size() ); m_Tiles.push_back( tile ); Ogre::Vector2 top_left ( x, -y ); Ogre::Vector2 top_right( x + width, top_left.y ); Ogre::Vector2 bottom_right( top_right.x, -( y + height ) ); Ogre::Vector2 bottom_left( top_left.x, bottom_right.y ); virtualScreenToWorldSpace( top_left ); virtualScreenToWorldSpace( top_right ); virtualScreenToWorldSpace( bottom_right ); virtualScreenToWorldSpace( bottom_left ); float new_x1 = top_left.x; float new_y1 = top_left.y; float new_x2 = top_right.x; float new_y2 = top_right.y; float new_x3 = bottom_right.x; float new_y3 = bottom_right.y; float new_x4 = bottom_left.x; float new_y4 = bottom_left.y; float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL ); writeIterator += render_op.vertexData->vertexCount * TILE_VERTEX_INDEX_SIZE; *writeIterator++ = new_x1; *writeIterator++ = new_y1; *writeIterator++ = depth; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = u1; *writeIterator++ = v1; *writeIterator++ = new_x2; *writeIterator++ = new_y2; *writeIterator++ = depth; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = u2; *writeIterator++ = v1; *writeIterator++ = new_x3; *writeIterator++ = new_y3; *writeIterator++ = depth; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = u2; *writeIterator++ = v2; *writeIterator++ = new_x1; *writeIterator++ = new_y1; *writeIterator++ = depth; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = u1; *writeIterator++ = v1; *writeIterator++ = new_x3; *writeIterator++ = new_y3; *writeIterator++ = depth; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = u2; *writeIterator++ = v2; *writeIterator++ = new_x4; *writeIterator++ = new_y4; *writeIterator++ = depth; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = 1; *writeIterator++ = u1; *writeIterator++ = v2; render_op.vertexData->vertexCount += TILE_VERTEX_COUNT; vertex_buffer->unlock(); }
//------------------------------------------------------------------------------ void Background2D::OnResize() { calculateScreenScale(); for( unsigned int i = 0; i < m_Tiles.size(); ++i ) { Tile &tile( m_Tiles[ i ] ); Ogre::Vector2 top_left ( tile.x, -tile.y ); Ogre::Vector2 top_right( tile.x + tile.width, top_left.y ); Ogre::Vector2 bottom_right( top_right.x, -( tile.y + tile.height ) ); Ogre::Vector2 bottom_left( top_left.x, bottom_right.y ); virtualScreenToWorldSpace( top_left ); virtualScreenToWorldSpace( top_right ); virtualScreenToWorldSpace( bottom_right ); virtualScreenToWorldSpace( bottom_left ); float new_x1 = top_left.x; float new_y1 = top_left.y; float new_x2 = top_right.x; float new_y2 = top_right.y; float new_x3 = bottom_right.x; float new_y3 = bottom_right.y; float new_x4 = bottom_left.x; float new_y4 = bottom_left.y; Ogre::HardwareVertexBufferSharedPtr vertex_buffer; if( m_Tiles[ i ].blending == QGears::B_ALPHA ) { vertex_buffer = m_AlphaVertexBuffer; } else if( m_Tiles[ i ].blending == QGears::B_ADD ) { vertex_buffer = m_AddVertexBuffer; } float* writeIterator = ( float* )vertex_buffer->lock( Ogre::HardwareBuffer::HBL_NORMAL ); writeIterator += m_Tiles[ i ].start_vertex_index * TILE_VERTEX_INDEX_SIZE; *writeIterator++ = new_x1; *writeIterator++ = new_y1; writeIterator += 7; *writeIterator++ = new_x2; *writeIterator++ = new_y2; writeIterator += 7; *writeIterator++ = new_x3; *writeIterator++ = new_y3; writeIterator += 7; ///* *writeIterator++ = new_x1; *writeIterator++ = new_y1; writeIterator += 7; *writeIterator++ = new_x3; *writeIterator++ = new_y3; writeIterator += 7; //*/ *writeIterator++ = new_x4; *writeIterator++ = new_y4; vertex_buffer->unlock(); } applyScroll(); }
double Camera::bbToDetection(const Vector<double>& bbox, Vector<double>& pos3D, double ConvertScale, double& dist) { // pos3D.clearContent(); pos3D.setSize(3); double x = bbox(0); double y = bbox(1); double w = bbox(2); double h = bbox(3); // bottom_left and bottom_right are the point of the BBOX Vector<double> bottom_left(3, 1.0); bottom_left(0) = x + w/2.0; bottom_left(1) = y + h; Vector<double> bottom_right(3, 1.0); bottom_right(0) = x + w; bottom_right(1) = y + h; Vector<double> ray_bot_left_1; Vector<double> ray_bot_left_2; Vector<double> ray_bot_right_1; Vector<double> ray_bot_right_2; // Backproject through base point getRay(bottom_left, ray_bot_left_1, ray_bot_left_2); getRay(bottom_right, ray_bot_right_1, ray_bot_right_2); Vector<double> gpPointLeft; Vector<double> gpPointRight; // Intersect with ground plane intersectPlane(GPN_, GPD_, ray_bot_left_1, ray_bot_left_2, gpPointLeft); intersectPlane(GPN_, GPD_, ray_bot_right_1, ray_bot_right_2, gpPointRight); // Find top point Vector<double> ray_top_1; Vector<double> ray_top_2; Vector<double> aux(3, 1.0); aux(0) = x; aux(1) = y; getRay(aux, ray_top_1, ray_top_2); // Vertical plane through base points + normal Vector<double> point3; point3 = gpPointLeft; point3 -= (GPN_); Vector<double> vpn(3,0.0); Vector<double> diffGpo1Point3; Vector<double> diffGpo2Point3; diffGpo1Point3 = gpPointLeft; diffGpo1Point3 -=(point3); diffGpo2Point3 = gpPointRight; diffGpo2Point3 -= point3; vpn = cross(diffGpo1Point3,diffGpo2Point3); double vpd = (-1.0)*DotProduct(vpn, point3); Vector<double> gpPointTop; intersectPlane(vpn, vpd, ray_top_1, ray_top_2, gpPointTop); // Results gpPointTop -= gpPointLeft; // Compute Size double dSize = gpPointTop.norm(); // Compute Distance aux = t_; aux -= gpPointLeft; dist = aux.norm(); dist = dist * ConvertScale; if(gpPointLeft(2) < t_(2)) dist = dist * (-1.0); // Compute 3D Position of BBOx double posX = gpPointLeft(0) * ConvertScale; double posY = gpPointLeft(1) * ConvertScale; double posZ = gpPointLeft(2) * ConvertScale; pos3D(0) = (posX); pos3D(1) = (posY); pos3D(2) = (posZ); return dSize * ConvertScale; }
vertex_list3 sprite::map() const { auto r = bounding_box(); return vertex_list3{{ r.top_left().to_vector3(), r.top_right().to_vector3(), r.bottom_right().to_vector3(), r.bottom_left().to_vector3() }}; }
std::vector< std::vector<c_tikz_obj*> > c_polygon::split(const c_polygon& against) const { std::vector< std::vector<c_tikz_obj*> > ret(3); // Check each point individually char loc_a, loc_b, loc_c; loc_a = utils::is_located(a, against); loc_b = utils::is_located(b, against); loc_c = utils::is_located(c, against); // Check if we're above or below or inside if (loc_a == loc_b && loc_b == loc_c) { ret[loc_a].push_back(clone()); return ret; } // Check if point a is barely touching if (loc_a == 1 && loc_b == loc_c) { ret[loc_b].push_back(clone()); return ret; } // Check if point b is barely touching if (loc_b == 1 && loc_a == loc_c) { ret[loc_c].push_back(clone()); return ret; } // Check if point c is barely touching if (loc_c == 1 && loc_b == loc_a) { ret[loc_a].push_back(clone()); return ret; } // Check if a and b are barely touching if (loc_a == 1 && loc_b == 1) { ret[loc_c].push_back(clone()); return ret; } // Check if a and c are barely touching if (loc_a == 1 && loc_c == 1) { ret[loc_b].push_back(clone()); return ret; } // Check if b and c are barely touching if (loc_b == 1 && loc_c == 1) { ret[loc_a].push_back(clone()); return ret; } // Check if 1 point touching, one above, one below if (loc_a == 1 || loc_b == 1 || loc_c == 1) { c_line line; c_point split1, split2; if (loc_a == 1) { split1 = b; split2 = c; } if (loc_b == 1) { split1 = a; split2 = c; } if (loc_c == 1) { split1 = a; split2 = b; } line.set_points(split1, split2); // Split the line real split_pos = utils::get_split_point(line, against); c_point split_point = split1*split_pos + split2*(1-split_pos); c_polygon * polygon1 = (c_polygon*) this->clone(); c_polygon * polygon2 = (c_polygon*) this->clone(); if (loc_a == 1) { polygon1->a = a; polygon1->b = b; polygon1->c = split_point; polygon2->a = a; polygon2->b = c; polygon2->c = split_point; } if (loc_b == 1) { polygon1->a = b; polygon1->b = c; polygon1->c = split_point; polygon2->a = b; polygon2->b = a; polygon2->c = split_point; } if (loc_c == 1) { polygon1->a = c; polygon1->b = b; polygon1->c = split_point; polygon2->a = c; polygon2->b = a; polygon2->c = split_point; } ret[0].push_back(polygon1); ret[2].push_back(polygon2); return ret; } // Remaining cases: Two points above, one point below c_line line1, line2; bool two_above; if (loc_a == 0 && loc_b == 2 && loc_c == 2) { // Split ba and ca against the polygon line1.set_points(b, a); line2.set_points(c, a); two_above = true; } if (loc_a == 2 && loc_b == 0 && loc_c == 2) { // Split ab and cb against the polygon line1.set_points(a, b); line2.set_points(c, b); two_above = true; } if (loc_a == 2 && loc_b == 2 && loc_c == 0) { // Split ac and bc against the polygon line1.set_points(a, c); line2.set_points(b, c); two_above = true; } if (loc_a == 2 && loc_b == 0 && loc_c == 0) { // Split ba and ca against the polygon line1.set_points(b, a); line2.set_points(c, a); two_above = false; } if (loc_a == 0 && loc_b == 2 && loc_c == 0) { // Split ab and cb against the polygon line1.set_points(a, b); line2.set_points(c, b); two_above = false; } if (loc_a == 0 && loc_b == 0 && loc_c == 2) { // Split ac and bc against the polygon line1.set_points(a, c); line2.set_points(b, c); two_above = false; } std::vector< std::vector<c_tikz_obj*> > line1_split(3); std::vector< std::vector<c_tikz_obj*> > line2_split(3); line1_split = line1.split(against); line2_split = line2.split(against); int loc; if (two_above) { loc = 2; } else { loc = 0; } c_point point_top(((c_line*)line1_split[loc][0])->ex, ((c_line*)line1_split[loc][0])->ey, ((c_line*)line1_split[loc][0])->ez); c_point point_left(((c_line*)line1_split[loc][0])->sx, ((c_line*)line1_split[loc][0])->sy, ((c_line*)line1_split[loc][0])->sz); c_point point_right(((c_line*)line2_split[loc][0])->sx, ((c_line*)line2_split[loc][0])->sy, ((c_line*)line2_split[loc][0])->sz); c_point bottom_left(((c_line*)line1_split[2-loc][0])->sx, ((c_line*)line1_split[2-loc][0])->sy, ((c_line*)line1_split[2-loc][0])->sz); c_point bottom_right(((c_line*)line2_split[2-loc][0])->sx, ((c_line*)line2_split[2-loc][0])->sy, ((c_line*)line2_split[2-loc][0])->sz); c_polygon * polygon1 = (c_polygon*) this->clone(); c_polygon * polygon2 = (c_polygon*) this->clone(); c_polygon * polygon3 = (c_polygon*) this->clone(); polygon1->a = point_top; polygon1->b = point_left; polygon1->c = point_right; polygon2->a = bottom_left; polygon2->b = point_left; polygon2->c = point_right; polygon3->a = bottom_right; polygon3->b = bottom_left; polygon3->c = point_right; ret[2-loc].push_back(polygon1); ret[loc].push_back(polygon2); ret[loc].push_back(polygon3); return ret; }
void TrajectoryCosts::CalculateLateralAndLongitudinalCosts(vector<TrajectoryCost>& trajectoryCosts, const vector<vector<vector<WayPoint> > >& rollOuts, const vector<vector<WayPoint> >& totalPaths, const WayPoint& currState, const vector<WayPoint>& contourPoints, const PlanningParams& params, const CAR_BASIC_INFO& carInfo, const VehicleState& vehicleState) { double critical_lateral_distance = carInfo.width/2.0 + params.horizontalSafetyDistancel; double critical_long_front_distance = carInfo.wheel_base/2.0 + carInfo.length/2.0 + params.verticalSafetyDistance; double critical_long_back_distance = carInfo.length/2.0 + params.verticalSafetyDistance - carInfo.wheel_base/2.0; int iCostIndex = 0; PlannerHNS::Mat3 rotationMat(-currState.pos.a); PlannerHNS::Mat3 translationMat(-currState.pos.x, -currState.pos.y); PlannerHNS::Mat3 invRotationMat(currState.pos.a-M_PI_2); PlannerHNS::Mat3 invTranslationMat(currState.pos.x, currState.pos.y); double corner_slide_distance = critical_lateral_distance/2.0; double ratio_to_angle = corner_slide_distance/carInfo.max_steer_angle; double slide_distance = vehicleState.steer * ratio_to_angle; GPSPoint bottom_left(-critical_lateral_distance ,-critical_long_back_distance, currState.pos.z, 0); GPSPoint bottom_right(critical_lateral_distance, -critical_long_back_distance, currState.pos.z, 0); GPSPoint top_right_car(critical_lateral_distance, carInfo.wheel_base/3.0 + carInfo.length/3.0, currState.pos.z, 0); GPSPoint top_left_car(-critical_lateral_distance, carInfo.wheel_base/3.0 + carInfo.length/3.0, currState.pos.z, 0); GPSPoint top_right(critical_lateral_distance - slide_distance, critical_long_front_distance, currState.pos.z, 0); GPSPoint top_left(-critical_lateral_distance - slide_distance , critical_long_front_distance, currState.pos.z, 0); bottom_left = invRotationMat*bottom_left; bottom_left = invTranslationMat*bottom_left; top_right = invRotationMat*top_right; top_right = invTranslationMat*top_right; bottom_right = invRotationMat*bottom_right; bottom_right = invTranslationMat*bottom_right; top_left = invRotationMat*top_left; top_left = invTranslationMat*top_left; top_right_car = invRotationMat*top_right_car; top_right_car = invTranslationMat*top_right_car; top_left_car = invRotationMat*top_left_car; top_left_car = invTranslationMat*top_left_car; // m_SafetyBox.clear(); // m_SafetyBox.push_back(bottom_left); // m_SafetyBox.push_back(bottom_right); // m_SafetyBox.push_back(top_right); // m_SafetyBox.push_back(top_left); m_SafetyBorder.points.clear(); m_SafetyBorder.points.push_back(bottom_left) ; m_SafetyBorder.points.push_back(bottom_right) ; m_SafetyBorder.points.push_back(top_right_car) ; m_SafetyBorder.points.push_back(top_right) ; m_SafetyBorder.points.push_back(top_left) ; m_SafetyBorder.points.push_back(top_left_car) ; for(unsigned int il=0; il < rollOuts.size(); il++) { if(rollOuts.at(il).size() > 0 && rollOuts.at(il).at(0).size()>0) { RelativeInfo car_info; PlanningHelpers::GetRelativeInfo(totalPaths.at(il), currState, car_info); for(unsigned int it=0; it< rollOuts.at(il).size(); it++) { for(unsigned int icon = 0; icon < contourPoints.size(); icon++) { RelativeInfo obj_info; PlanningHelpers::GetRelativeInfo(totalPaths.at(il), contourPoints.at(icon), obj_info); double longitudinalDist = PlanningHelpers::GetExactDistanceOnTrajectory(totalPaths.at(il), car_info, obj_info); if(obj_info.iFront == 0 && longitudinalDist > 0) longitudinalDist = -longitudinalDist; double close_in_percentage = 1; // close_in_percentage = ((longitudinalDist- critical_long_front_distance)/params.rollInMargin)*4.0; // // if(close_in_percentage <= 0 || close_in_percentage > 1) close_in_percentage = 1; double distance_from_center = trajectoryCosts.at(iCostIndex).distance_from_center; if(close_in_percentage < 1) distance_from_center = distance_from_center - distance_from_center * (1.0-close_in_percentage); double lateralDist = fabs(obj_info.perp_distance - distance_from_center); if(longitudinalDist < -carInfo.length || lateralDist > 6) { continue; } longitudinalDist = longitudinalDist - critical_long_front_distance; if(m_SafetyBorder.PointInsidePolygon(m_SafetyBorder, contourPoints.at(icon).pos) == true) trajectoryCosts.at(iCostIndex).bBlocked = true; if(lateralDist <= critical_lateral_distance && longitudinalDist >= -carInfo.length/1.5 && longitudinalDist < params.minFollowingDistance) trajectoryCosts.at(iCostIndex).bBlocked = true; trajectoryCosts.at(iCostIndex).lateral_cost += 1.0/lateralDist; trajectoryCosts.at(iCostIndex).longitudinal_cost += 1.0/fabs(longitudinalDist); if(longitudinalDist >= -critical_long_front_distance && longitudinalDist < trajectoryCosts.at(iCostIndex).closest_obj_distance) { trajectoryCosts.at(iCostIndex).closest_obj_distance = longitudinalDist; trajectoryCosts.at(iCostIndex).closest_obj_velocity = contourPoints.at(icon).v; } } iCostIndex++; } } } }
osg::Node* createSubloadWall(osg::BoundingBox& bb) { osg::Group* group = new osg::Group; // left hand side of bounding box. osg::Vec3 top_left(bb.xMin(),bb.yMax(),bb.zMax()); osg::Vec3 bottom_left(bb.xMin(),bb.yMax(),bb.zMin()); osg::Vec3 bottom_right(bb.xMax(),bb.yMax(),bb.zMin()); osg::Vec3 top_right(bb.xMax(),bb.yMax(),bb.zMax()); osg::Vec3 center((bb.xMax()+bb.xMin())*0.5f,bb.yMax(),(bb.zMin()+bb.zMax())*0.5f); float height = bb.zMax()-bb.zMin(); // create the geometry for the wall. osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* vertices = new osg::Vec3Array(4); (*vertices)[0] = top_left; (*vertices)[1] = bottom_left; (*vertices)[2] = bottom_right; (*vertices)[3] = top_right; geom->setVertexArray(vertices); osg::Vec2Array* texcoords = new osg::Vec2Array(4); (*texcoords)[0].set(0.0f,1.0f); (*texcoords)[1].set(0.0f,0.0f); (*texcoords)[2].set(1.0f,0.0f); (*texcoords)[3].set(1.0f,1.0f); geom->setTexCoordArray(0,texcoords); osg::Vec3Array* normals = new osg::Vec3Array(1); (*normals)[0].set(0.0f,-1.0f,0.0f); geom->setNormalArray(normals); geom->setNormalBinding(osg::Geometry::BIND_OVERALL); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0].set(1.0f,1.0f,1.0f,1.0f); geom->setColorArray(colors); geom->setColorBinding(osg::Geometry::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); osg::Geode* geom_geode = new osg::Geode; geom_geode->addDrawable(geom); group->addChild(geom_geode); // set up the texture state. osg::Texture2D* texture = new osg::Texture2D; texture->setDataVariance(osg::Object::DYNAMIC); // protect from being optimized away as static state. texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR); texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR); osg::StateSet* stateset = geom->getOrCreateStateSet(); stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); // create the text label. osgText::Text* text = new osgText::Text; text->setDataVariance(osg::Object::DYNAMIC); text->setFont("fonts/arial.ttf"); text->setPosition(center); text->setCharacterSize(height*0.03f); text->setAlignment(osgText::Text::CENTER_CENTER); text->setAxisAlignment(osgText::Text::XZ_PLANE); osg::Geode* text_geode = new osg::Geode; text_geode->addDrawable(text); osg::StateSet* text_stateset = text_geode->getOrCreateStateSet(); text_stateset->setAttributeAndModes(new osg::PolygonOffset(-1.0f,-1.0f),osg::StateAttribute::ON); group->addChild(text_geode); // set the update callback to cycle through the various min and mag filter modes. group->setUpdateCallback(new ImageUpdateCallback(texture,text)); return group; }
osg::Node* createTestTexture2D(osg::Node* node, const std::string& filename) { osg::BoundingBox bb; osg::ref_ptr<osg::ComputeBoundsVisitor> boundsVistor = new osg::ComputeBoundsVisitor(); boundsVistor->reset(); node->accept(*boundsVistor.get()); bb = boundsVistor->getBoundingBox(); osg::Group* group = new osg::Group; // left hand side of bounding box. osg::Vec3 top_left(bb.xMin(), bb.yMin(), bb.zMax()); osg::Vec3 bottom_left(bb.xMin(), bb.yMin(), bb.zMin()); osg::Vec3 bottom_right(bb.xMin(), bb.yMax(), bb.zMin()); osg::Vec3 top_right(bb.xMin(), bb.yMax(), bb.zMax()); osg::Vec3 center(bb.xMin(), (bb.yMin() + bb.yMax())*0.5f, (bb.zMin() + bb.zMax())*0.5f); float height = bb.zMax() - bb.zMin(); // create the geometry for the wall. osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* vertices = new osg::Vec3Array(4); (*vertices)[0] = top_left; (*vertices)[1] = bottom_left; (*vertices)[2] = bottom_right; (*vertices)[3] = top_right; geom->setVertexArray(vertices); osg::Vec2Array* texcoords = new osg::Vec2Array(4); (*texcoords)[0].set(0.0f, 1.0f); (*texcoords)[1].set(0.0f, 0.0f); (*texcoords)[2].set(1.0f, 0.0f); (*texcoords)[3].set(1.0f, 1.0f); geom->setTexCoordArray(0, texcoords); osg::Vec3Array* normals = new osg::Vec3Array(1); (*normals)[0].set(1.0f, 0.0f, 0.0f); geom->setNormalArray(normals, osg::Array::BIND_OVERALL); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0].set(1.0f, 1.0f, 1.0f, 1.0f); geom->setColorArray(colors, osg::Array::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4)); osg::Geode* geom_geode = new osg::Geode; geom_geode->addDrawable(geom); group->addChild(geom_geode); // set up the texture state. osg::Texture2D* texture = new osg::Texture2D; texture->setDataVariance(osg::Object::DYNAMIC); // protect from being optimized away as static state. osg::notify(osg::FATAL) << filename << std::endl; osg::Image* image = g_SystemContext._resourceLoader->getImageByFileName(filename); if (image == NULL) { osg::notify(osg::FATAL) << filename << "--load faile!!!" << std::endl; } else texture->setImage(0, image); osg::StateSet* stateset = geom->getOrCreateStateSet(); stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); osg::notify(osg::FATAL) << "33333" << std::endl; // create the text label. osgText::Text* text = new osgText::Text; text->setDataVariance(osg::Object::DYNAMIC); text->setFont("fonts/arial.ttf"); text->setPosition(center); text->setCharacterSize(height*0.03f); text->setAlignment(osgText::Text::CENTER_CENTER); text->setAxisAlignment(osgText::Text::YZ_PLANE); osg::Geode* text_geode = new osg::Geode; text_geode->addDrawable(text); osg::StateSet* text_stateset = text_geode->getOrCreateStateSet(); text_stateset->setAttributeAndModes(new osg::PolygonOffset(-1.0f, -1.0f), osg::StateAttribute::ON); group->addChild(text_geode); // set the update callback to cycle through the various min and mag filter modes. //group->setUpdateCallback(new FilterCallback(texture,text)); return group; }