Re: [osg-users] Selective ClipNode
Thank you Sebastian, I also found another way that is useful in my case. I simply call the following code for each node I want to exclude from clipping: node->getOrCreateStateSet()->setMode(GL_CLIP_PLANE0, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED); Ale -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70786#70786 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Selective ClipNode
Am 4/18/2017 um 2:17 PM schrieb Ale Maro: Hi Sebastian, I would like to avoid that becouse each node may have complex (dynamic) transformations so I should traverse the scene, calculate the global transformation for each node and update each transformation for the children of the sibling-group Sorry I don't understand what you mean. If you simply put (at the top level) parts like this: SCENE |-CLIP |-Childs |-NON_CLIP |-Childs the childs in this example can have arbitary transformations... If you cannot place your nodes like this, you can take a look at the ClipNode-implementation and maybe inherit and change the parts that control the clipping state to set it effectively per child somehow. The other option is to simply use a shader that implements the clipping and to switch it on/off via uniform. Cheers Sebastian Ale -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70780#70780 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Related to osg lines
Hi, Iam using the following code and drawing the lines in osg and clamping the lines to the terrain for the purpose of road drawing LineSymbol* line = style.getOrCreate(); line->stroke()->color() = Color(Color::Black, 0.5f); line->stroke()->width() = 8.0f; line->tessellationSize() = 5; line->stroke()->widthUnits() = Units::METERS; AltitudeSymbol* alt = style.getOrCreate(); alt->clamping() = alt->CLAMP_TO_TERRAIN; But for me i want road with texture so what iam adding the quad and applying texture in the below code osg::ref_ptr vertices = new osg::Vec3Array; vertices->push_back(osg::Vec3(-1.0f,0.0f,-2.0f)); vertices->push_back(osg::Vec3(1.0f,0.0f,-2.0f)); vertices->push_back(osg::Vec3(1.0f,0.0f,2.0f)); vertices->push_back(osg::Vec3(-1.0f,0.0f,2.0f)); osg::ref_ptr normals = new osg::Vec3Array; normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f)); osg::ref_ptr colors = new osg::Vec4Array; colors->push_back(osg::Vec4(0.0f, 0.0f, 0.0f,0.0f)); osg::ref_ptr texcoords = new osg::Vec2Array; texcoords->push_back(osg::Vec2(0.0f, 0.0f)); texcoords->push_back(osg::Vec2(0.0f, 1.0f)); texcoords->push_back(osg::Vec2(1.0f, 1.0f)); texcoords->push_back(osg::Vec2(1.0f, 0.0f)); osg::ref_ptr geom = new osg::Geometry; geom->setVertexArray(vertices.get()); geom->setNormalArray(normals.get()); geom->setColorArray(colors.get()); geom->setNormalBinding(osg::Geometry::BIND_OVERALL); geom->setTexCoordArray(0,texcoords.get()); geom->setColorBinding(osg::Geometry::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); osg::ref_ptr texture = new osg::Texture2D; texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::CLAMP); texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::CLAMP); osg::ref_ptr image = osgDB::readImageFile("D:/Images/roadPic.jpg"); texture->setImage(image); osg::ref_ptr root = new osg::Geode; root->addDrawable(geom.get()); root->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture.get()); how to clamp the quad to the terrain for drawing the road in osgearth or any other way to add the texture to those lines? ... Thank you! Cheers, Rambabu -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70781#70781 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Selective ClipNode
Hi Ale, in my scene graph I have a root node of type osg::ClipNode. In this way I can add easily clipping planes to my scene. This works fine. Now I would like to exclude some nodes from clipping. I wonder if ClipNode supports something like a visitor mask to selectively apply clipping to children. You can always put the nodes to be excluded from clipping into a sibling-group of the ClipNode. Cheers Sebastian Thank you in advance. Best regards Ale -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70778#70778 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Selective ClipNode
Hi, in my scene graph I have a root node of type osg::ClipNode. In this way I can add easily clipping planes to my scene. This works fine. Now I would like to exclude some nodes from clipping. I wonder if ClipNode supports something like a visitor mask to selectively apply clipping to children. Thank you in advance. Best regards Ale -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70778#70778 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Related to osg lines
Hi, I think LineSymbol class has no this kind of function. Maybe you could use osg to do it. Glen 8802...@qq.com From: Rambabu Repaka Date: 2017-04-18 17:53 To: osg-users Subject: Re: [osg-users] Related to osg lines Hi,In osgearth project linesymbol is using and drawing the road but i want to add the texture to those lines,Normally how to add texture to the line in osg ? ... Thank you! Cheers, Rambabu -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70776#70776 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Related to osg lines
Hi,In osgearth project linesymbol is using and drawing the road but i want to add the texture to those lines,Normally how to add texture to the line in osg ? ... Thank you! Cheers, Rambabu -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70776#70776 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Related to osg lines
Hello, I saw these codes in OSGEarth project. Glen 8802...@qq.com From: Robert Osfield Date: 2017-04-18 17:26 To: OpenSceneGraph Users Subject: Re: [osg-users] Related to osg lines On 18 April 2017 at 10:22, Rambabu Repakawrote: > Hi,Iam drawing lines using the following code in osg > LineSymbol* line = style.getOrCreate(); > line->stroke()->color() = Color(Color::Black, 0.5f); > line->stroke()->width() = 4.5f; > line->tessellationSize() = 5; > line->stroke()->widthUnits() = Units::METERS; > How to add texture image to these Lines ? The OSG does not have any class called LineSymbol, so I can't see how it's related ot the OSG. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Related to osg lines
On 18 April 2017 at 10:22, Rambabu Repakawrote: > Hi,Iam drawing lines using the following code in osg > LineSymbol* line = style.getOrCreate(); > line->stroke()->color() = Color(Color::Black, 0.5f); > line->stroke()->width() = 4.5f; > line->tessellationSize() = 5; > line->stroke()->widthUnits() = Units::METERS; > How to add texture image to these Lines ? The OSG does not have any class called LineSymbol, so I can't see how it's related ot the OSG. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Related to osg lines
Hi,Iam drawing lines using the following code in osg LineSymbol* line = style.getOrCreate(); line->stroke()->color() = Color(Color::Black, 0.5f); line->stroke()->width() = 4.5f; line->tessellationSize() = 5; line->stroke()->widthUnits() = Units::METERS; How to add texture image to these Lines ? ... Thank you! Cheers, Rambabu -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70773#70773 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Fast move a lot of nodes to another group
Am 4/15/2017 um 6:24 PM schrieb Yura Ivanov: Hi, I created stateset with bool uniform to indicate that node is selected and mat uniform with current mouse transform. To select nodes, I set this uniforms to nodes and all transformation preforms in shader. On mouse release, all transform applies to nodes by calling setMatrix and mat uniform sets to identity. Everything works fast and after all I don’t have extra nodes and statesets. Maybe my approach in this task is wrong, but many editors, for example 3dsMax, can work with big number of objects. And bad structure of scene in this case is user problem. Thank you very much, especially for optimize. This will disable "native" picking of the nodes however. Also I wonder why this should be more efficient than putting every node under a transform in the first place. What you're doing is effectively a poor implementation of instancing. A better approach (if you want to use the uniform approach) is to setup a uniform buffer object (see [0]) containing the matrices and to use the draw-instanced version of your geometry to fetch it based on its gl_InstanceId. A version that scales better is to use a texture object to hold the matrices (see [1]) [0] http://3dcgtutorials.blogspot.de/2013/09/instancing-with-openscenegraph-part-ii.html [1] http://3dcgtutorials.blogspot.de/2013/08/instancing-with-openscenegraph.html Cheers Sebastian Cheers, Yura -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70767#70767 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Scale problem while transforming object in vertex shader
Hi Yura Hi, I have a transform matrix and I want to apply it in shader. I pass it into uniform and set gl_Position = gl_ModelViewProjectionMatrix*my_transfrom_matrix*gl_Vertex. If I set translate only, everything is ok. If I set translate and scale - translate multiplies by scale and transform is wrong (object is too far if scale>1.0). If I apply this transform not using shader (by SetMatrix) everything is ok. What I am doing wrong? Matrix multiplication is not cummutative in every case. Try gl_Position = gl_ModelViewMatrix * matrix * gl_ProjectionMatrix * gl_Vertex. Cheers Sebastian Thank you! Cheers, Yura -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=70768#70768 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org