Re: [osg-users] Store parent matrix inside of child
Hi Drake, You could have a matrix wrapped up in your custom GizmoDrawable but you'd have to be careful about when you passed on the matrix. One normally doesn't cache matrices this way, as it usually isn't required. There is chance that you are trying to tackle a problem that there is an established and better solution, but as don't say anything about the actual problem you trying to solve, just focus on possible solution to an unknown problem we can't provide any useful advice. Robert On 4 January 2015 at 14:11, Drake Aldwyn azrai...@gmail.com wrote: Hi, all Below is my code: is it possible somehow store matrix transform of PAT inside of children (gizmo) ? Code: osg::ref_ptrosg::Switch sw = new osg::Switch; sw-setName(Switch); sw-addChild(scene,true); sw-addChild(getLineCube(pos,11),false); osg::ref_ptrAgentShape myPos = new AgentShape; // This is PAT myPos-setPosition(pos); myPos-addChild(sw); myPos-setName(AgentShape); osg::ref_ptrosg::Geode geodeGizmo = new osg::Geode; osg::ref_ptrGizmoDrawable gizmo = new GizmoDrawable; gizmo-setName(gizmo); gizmo-setGizmoMode( GizmoDrawable:: NO_GIZMO); gizmo-setTransform(matrixTrasform of PAT); geodeGizmo-addDrawable( gizmo.get() ); geodeGizmo-setCullingActive( false ); myPos-addChild(geodeGizmo); return myPos; Thank you! Cheers, Drake -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62224#62224 ___ 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] Low frame rate ( Update Callback on 50 bones ).
Happy new years everyone! Hope everyone had a great holidays! I just wanted to update this thread and bump it as I am now doing some further tweaking on getting things running optimally. I narrowed down some things, and I now have ONLY the hands being rendered in release mode. I get around 45 fps.. which is ok, but I would like to see it higher. Unless I am vastly overestimating the capability of this it should be able to render the hands up close to 60 fps on release mode. I've tested running only the API without rendering the hands and the frame rate stays a solid 58-60 fps. The moment I add the hands to the scene and they move around the FR drops to around 45. So I know the sensor data is not the source of the delay. I tried a traversal class that runs through the hand model. (Hand model is an FBX class with baked in texture and rigging exported from 3DS max) hoping to do all the work on the GPU: Code: class VBO_Updater : public osg::NodeVisitor { public: VBO_Updater() : NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN) {} ~VBO_Updater(){} virtual void apply(osg::Node node) { traverse(node); } virtual void apply(osg::Geode geode) { unsigned int numGeoms = geode.getNumDrawables(); for (unsigned int i = 0; i numGeoms; i++) { osg::ref_ptrosg::Geometry curGeom = geode.getDrawable(i)-asGeometry(); if (curGeom) { curGeom-setUseDisplayList(false); curGeom-setUseVertexBufferObjects(true); osg::ref_ptrVertexBufferObject df = curGeom-getOrCreateVertexBufferObject(); df-setUsage(GL_STREAM_DRAW); osg::ref_ptrosg::StateSet stateset = curGeom-getOrCreateStateSet(); stateset-setAttributeAndModes(new osg::CullFace()); } } } private: }; But this didn't seem to do anything for the frame rate. I assume that the fbx model is still not being skinned on the GPU. How do I make sure that the GPU is doing the hard work and not the CPU? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62226#62226 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Low frame rate ( Update Callback on 50 bones ).
If I am not mistaken, you will have to run your own vertex shaders in order to do hardware animation skinning. The osganimationhardware example provides a very basic example of doing so. This may mean that your shader might have to be hardcoded to work with a specific 3D model (bone structure) only. Christian 2015-01-05 13:16 GMT+01:00 Chris Hidden ch...@erghis.com: Happy new years everyone! Hope everyone had a great holidays! I just wanted to update this thread and bump it as I am now doing some further tweaking on getting things running optimally. I narrowed down some things, and I now have ONLY the hands being rendered in release mode. I get around 45 fps.. which is ok, but I would like to see it higher. Unless I am vastly overestimating the capability of this it should be able to render the hands up close to 60 fps on release mode. I've tested running only the API without rendering the hands and the frame rate stays a solid 58-60 fps. The moment I add the hands to the scene and they move around the FR drops to around 45. So I know the sensor data is not the source of the delay. I tried a traversal class that runs through the hand model. (Hand model is an FBX class with baked in texture and rigging exported from 3DS max) hoping to do all the work on the GPU: Code: class VBO_Updater : public osg::NodeVisitor { public: VBO_Updater() : NodeVisitor(NodeVisitor::TRAVERSE_ALL_CHILDREN) {} ~VBO_Updater(){} virtual void apply(osg::Node node) { traverse(node); } virtual void apply(osg::Geode geode) { unsigned int numGeoms = geode.getNumDrawables(); for (unsigned int i = 0; i numGeoms; i++) { osg::ref_ptrosg::Geometry curGeom = geode.getDrawable(i)-asGeometry(); if (curGeom) { curGeom-setUseDisplayList(false); curGeom-setUseVertexBufferObjects(true); osg::ref_ptrVertexBufferObject df = curGeom-getOrCreateVertexBufferObject(); df-setUsage(GL_STREAM_DRAW); osg::ref_ptrosg::StateSet stateset = curGeom-getOrCreateStateSet(); stateset-setAttributeAndModes(new osg::CullFace()); } } } private: }; But this didn't seem to do anything for the frame rate. I assume that the fbx model is still not being skinned on the GPU. How do I make sure that the GPU is doing the hard work and not the CPU? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62226#62226 ___ 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] Store parent matrix inside of child
Well, Ill try describe what I'm trying to do. I have scene where I put object with this code: Code: std::string path=models\\; std::string path2=textures\\; osg::Node* scene = osgDB::readNodeFile(path+n); scene-setName(scene); osg::BlendFunc*blendFunc = new osg::BlendFunc(); osg::BlendColor*blendColor= new osg::BlendColor(osg::Vec4(1, 1, 1, 0.5 )); blendFunc-setSource(osg::BlendFunc::CONSTANT_ALPHA); blendFunc-setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA); scene-getOrCreateStateSet()-setAttributeAndModes( new osg::BlendFunc ); scene-getOrCreateStateSet()-setRenderingHint( osg::StateSet:: TRANSPARENT_BIN ); osg::StateSet* pStateSet = scene-getOrCreateStateSet(); pStateSet-setMode( GL_LIGHTING, osg::StateAttribute::OFF ); osg::Texture2D* pTex = new osg::Texture2D; osg::Image* pImage = osgDB::readImageFile(path2+t); pTex-setImage( pImage ); pStateSet-setTextureAttributeAndModes( 0, pTex, osg::StateAttribute::ON ); osg::Material* material = new osg::Material; material-setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); material-setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); material-setAlpha(osg::Material::FRONT_AND_BACK, 0.5); pStateSet-setAttribute(material,osg::StateAttribute::ON); pStateSet-setMode(GL_BLEND, true); osg::BlendFunc* blend = new osg::BlendFunc; blend-setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_DST_ALPHA); pStateSet-setAttributeAndModes(blend, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); osg::ref_ptrosg::Switch sw = new osg::Switch; sw-setName(Switch); sw-addChild(scene,true); sw-addChild(getLineCube(pos,11),false); osg::ref_ptrAgentShape myPos = new AgentShape; myPos-setPosition(pos); myPos-addChild(sw); myPos-setName(AgentShape); osg::ref_ptrosg::Geode geodeGizmo = new osg::Geode; osg::ref_ptrGizmoDrawable gizmo = new GizmoDrawable; gizmo-setName(gizmo); gizmo-setGizmoMode( GizmoDrawable:: NO_GIZMO); geodeGizmo-addDrawable( gizmo.get() ); geodeGizmo-setCullingActive( false ); myPos-addChild(geodeGizmo); return myPos; } I use my own class inherited from PAT, because I need my own values. This PAT contains gizmo from lib gizmo and osggizmo examples. When i put matrix transform of my osg::Node* scene, I can move object but it doesn't move PAT actually, so I trying understand how could I move whole PAT with this gizmo.[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62229#62229 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Store parent matrix inside of child
Hi Drake, I can't personally help you, I know nothing about gizmo. You don't really explain what you are trying to do either, you provide code, which is a specific attempt at a solution to a problem, not a definition of the problem which makes it doubly impossible to guess what you need to do. I'd suggest when explaining stuff you don't provide code, but a high level explanation of how you want to manage you scene and how gizmo affects this. Robert. On 5 January 2015 at 18:02, Drake Aldwyn azrai...@gmail.com wrote: Well, Ill try describe what I'm trying to do. I have scene where I put object with this code: Code: std::string path=models\\; std::string path2=textures\\; osg::Node* scene = osgDB::readNodeFile(path+n); scene-setName(scene); osg::BlendFunc*blendFunc = new osg::BlendFunc(); osg::BlendColor*blendColor= new osg::BlendColor(osg::Vec4(1, 1, 1, 0.5 )); blendFunc-setSource(osg::BlendFunc::CONSTANT_ALPHA); blendFunc-setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA); scene-getOrCreateStateSet()-setAttributeAndModes( new osg::BlendFunc ); scene-getOrCreateStateSet()-setRenderingHint( osg::StateSet:: TRANSPARENT_BIN ); osg::StateSet* pStateSet = scene-getOrCreateStateSet(); pStateSet-setMode( GL_LIGHTING, osg::StateAttribute::OFF ); osg::Texture2D* pTex = new osg::Texture2D; osg::Image* pImage = osgDB::readImageFile(path2+t); pTex-setImage( pImage ); pStateSet-setTextureAttributeAndModes( 0, pTex, osg::StateAttribute::ON ); osg::Material* material = new osg::Material; material-setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); material-setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); material-setAlpha(osg::Material::FRONT_AND_BACK, 0.5); pStateSet-setAttribute(material,osg::StateAttribute::ON); pStateSet-setMode(GL_BLEND, true); osg::BlendFunc* blend = new osg::BlendFunc; blend-setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_DST_ALPHA); pStateSet-setAttributeAndModes(blend, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); osg::ref_ptrosg::Switch sw = new osg::Switch; sw-setName(Switch); sw-addChild(scene,true); sw-addChild(getLineCube(pos,11),false); osg::ref_ptrAgentShape myPos = new AgentShape; myPos-setPosition(pos); myPos-addChild(sw); myPos-setName(AgentShape); osg::ref_ptrosg::Geode geodeGizmo = new osg::Geode; osg::ref_ptrGizmoDrawable gizmo = new GizmoDrawable; gizmo-setName(gizmo); gizmo-setGizmoMode( GizmoDrawable:: NO_GIZMO); geodeGizmo-addDrawable( gizmo.get() ); geodeGizmo-setCullingActive( false ); myPos-addChild(geodeGizmo); return myPos; } I use my own class inherited from PAT, because I need my own values. This PAT contains gizmo from lib gizmo and osggizmo examples. When i put matrix transform of my osg::Node* scene, I can move object but it doesn't move PAT actually, so I trying understand how could I move whole PAT with this gizmo.[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62229#62229 ___ 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] Store parent matrix inside of child
Hi Drake, just guessing by the subject of the email. If you want to store matrix to some node (your child node) you can use the userdata of the node and RefMatrix. Something like osg::Matrix parentMatrix; child-setUserData(new osg::RefMatrix(parentMatrix)); then dynamic_cast the userData to RefMatrix when you need it Again, the hint is just by guessing. Robert is right, it is not clear what you are after Cheers, Nick On Mon, Jan 5, 2015 at 8:50 PM, Robert Osfield robert.osfi...@gmail.com wrote: Hi Drake, I can't personally help you, I know nothing about gizmo. You don't really explain what you are trying to do either, you provide code, which is a specific attempt at a solution to a problem, not a definition of the problem which makes it doubly impossible to guess what you need to do. I'd suggest when explaining stuff you don't provide code, but a high level explanation of how you want to manage you scene and how gizmo affects this. Robert. On 5 January 2015 at 18:02, Drake Aldwyn azrai...@gmail.com wrote: Well, Ill try describe what I'm trying to do. I have scene where I put object with this code: Code: std::string path=models\\; std::string path2=textures\\; osg::Node* scene = osgDB::readNodeFile(path+n); scene-setName(scene); osg::BlendFunc*blendFunc = new osg::BlendFunc(); osg::BlendColor*blendColor= new osg::BlendColor(osg::Vec4(1, 1, 1, 0.5 )); blendFunc-setSource(osg::BlendFunc::CONSTANT_ALPHA); blendFunc-setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA); scene-getOrCreateStateSet()-setAttributeAndModes( new osg::BlendFunc ); scene-getOrCreateStateSet()-setRenderingHint( osg::StateSet:: TRANSPARENT_BIN ); osg::StateSet* pStateSet = scene-getOrCreateStateSet(); pStateSet-setMode( GL_LIGHTING, osg::StateAttribute::OFF ); osg::Texture2D* pTex = new osg::Texture2D; osg::Image* pImage = osgDB::readImageFile(path2+t); pTex-setImage( pImage ); pStateSet-setTextureAttributeAndModes( 0, pTex, osg::StateAttribute::ON ); osg::Material* material = new osg::Material; material-setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); material-setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0f,1.0f,1.0f,1.0f)); material-setAlpha(osg::Material::FRONT_AND_BACK, 0.5); pStateSet-setAttribute(material,osg::StateAttribute::ON); pStateSet-setMode(GL_BLEND, true); osg::BlendFunc* blend = new osg::BlendFunc; blend-setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_DST_ALPHA); pStateSet-setAttributeAndModes(blend, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); osg::ref_ptrosg::Switch sw = new osg::Switch; sw-setName(Switch); sw-addChild(scene,true); sw-addChild(getLineCube(pos,11),false); osg::ref_ptrAgentShape myPos = new AgentShape; myPos-setPosition(pos); myPos-addChild(sw); myPos-setName(AgentShape); osg::ref_ptrosg::Geode geodeGizmo = new osg::Geode; osg::ref_ptrGizmoDrawable gizmo = new GizmoDrawable; gizmo-setName(gizmo); gizmo-setGizmoMode( GizmoDrawable:: NO_GIZMO); geodeGizmo-addDrawable( gizmo.get() ); geodeGizmo-setCullingActive( false ); myPos-addChild(geodeGizmo); return myPos; } I use my own class inherited from PAT, because I need my own values. This PAT contains gizmo from lib gizmo and osggizmo examples. When i put matrix transform of my osg::Node* scene, I can move object but it doesn't move PAT actually, so I trying understand how could I move whole PAT with this gizmo.[/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62229#62229 ___ 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 -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org