<div dir="ltr"><div><div><div>Hi Vitaliy,<br><br></div><div>From your description it's not possible to know what the exact problem is and therefore it's not possible to suggest ways to resolve the issue.<br><br>Is the border part of the 8x8.png image?<br></div><br></div>Does the current behaviour have the icon displayed at the correct size?<br><br></div>Robert.<br><div><div><div><br><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 28 July 2015 at 16:43, Vitaliy Polyakov <span dir="ltr"><<a href="mailto:poljak181@yandex.ru" target="_blank">poljak181@yandex.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I want to draw an icon using texture. My texture image is an image of 8x8 pixel size. It looks like quadrate without center (center is transparent). Border width of this quadrate is one pixel.<br>
When I moving camera with the mouse - border size of icon changed. It can also disappear.<br>
How can I provide permanent width of quadrate border (1 pixel, as in a texture)<br>
My code to add icon on the scene.<br>
<br>
<br>
Code:<br>
osg::ref_ptr<osg::Node> createTexture()<br>
{<br>
osg::ref_ptr<osg::Image> image = osgDB::readImageFile("8x8.png");<br>
float width = image->s();<br>
float height = image->t();<br>
<br>
osg::Geometry* geometry = new osg::Geometry;<br>
<br>
osg::Vec3Array* verts = new osg::Vec3Array(4);<br>
(*verts)[0] = osg::Vec3(-width/2.0f, -height/2.0, 0.0f);<br>
(*verts)[1] = osg::Vec3(width/2.0f, -height/2.0, 0.0f);<br>
(*verts)[2] = osg::Vec3(width/2.0f, height/2.0, 0.0f);<br>
(*verts)[3] = osg::Vec3(-width/2.0f,height/2.0, 0.0f);<br>
geometry->setVertexArray( verts );<br>
<br>
osg::Vec2Array* texcoords = new osg::Vec2Array(4);<br>
<br>
(*texcoords)[0].set(0.0f, 0.0f);<br>
(*texcoords)[1].set(width, 0.0f);<br>
(*texcoords)[2].set(width, height);<br>
(*texcoords)[3].set(0.0f, height);<br>
<br>
geometry->setTexCoordArray(0, texcoords);<br>
<br>
osg::Vec4Array* colors = new osg::Vec4Array(1);<br>
(*colors)[0].set(1,1,1,1);<br>
geometry->setColorArray( colors );<br>
geometry->setColorBinding( osg::Geometry::BIND_OVERALL );<br>
<br>
geometry->addPrimitiveSet( new osg::DrawArrays(GL_QUADS, 0, 4));<br>
<br>
osg::StateSet* stateSet = geometry->getOrCreateStateSet();<br>
<br>
osg::TextureRectangle* texture = new osg::TextureRectangle( image );<br>
texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST);<br>
texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST);<br>
stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);<br>
<br>
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);<br>
stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS,false), 1 );<br>
<br>
osg::Geode* geode = new osg::Geode;<br>
geode->addDrawable( geometry );<br>
<br>
osg::AutoTransform* at = new osg::AutoTransform;<br>
at->setAutoScaleToScreen( true );<br>
at->setAutoRotateMode( osg::AutoTransform::ROTATE_TO_SCREEN );<br>
at->addChild( geode );<br>
return at;<br>
}<br>
<br>
<br>
<br>
Thank you![/code]<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=64511#64511" rel="noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=64511#64511</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div><br></div>