Re: [osg-users] osgAndroidExampleGLES1 and 2 error on Android 3.x device
Hi Jorge, Actually I did already change that, so to compile for platform-10 even. But no success either. If you think that it might help to try explicitly with platform 9 I will. But I seriously doubt that it can help... Luca -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42159#42159 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgAndroidExampleGLES1 and 2 error on Android 3.x device
10 doesn't matter for Ndk because the last change was in 9 (if you look there's no platform 10). If you already did this don't botter. But just to be sure you did it with the OSG library not the example, right? 2011/8/22 Luca Vezzadini > Hi Jorge, > Actually I did already change that, so to compile for platform-10 even. But > no success either. > If you think that it might help to try explicitly with platform 9 I will. > But I seriously doubt that it can help... > > Luca > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=42159#42159 > > > > > > ___ > 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] Transparency over a osgText::Text
Hi community, I'm trying to create a transparent text in the HUD. I'm adding the text via a widget over the canvas windowmanager, but my guess is the process for setting the text transparent is independent. How can I achieve what I'm trying to do? I can get the background BoundingBox transparent without difficulties, but not the text. Cheers, Daniel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42161#42161 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgAndroidExampleGLES1 and 2 error on Android 3.x device
I actually used 10 for both (OSG and the example). Luca -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42162#42162 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] An Open Scene Graph solicitation has been posted on FedBizOpps
Wow, so this is how a government dept submits a bug report :) Should be nice to hunt this one down, I was just wondering over the weekend what happened to it. References here: http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/62225 http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/63954 rgds jp On 19/08/2011 20:31, Judith E Terrill wrote: For your information, a solicitation to develop a fix for Open Scene Graph has been posted on FedBizOpps that may be of interest to you. You may view the solicitation and instructions for responding at: https://www.fbo.gov/index?s=opportunity&mode=form&id=5b646272c11b0c2fb01ce61f954a4555&tab=core&tabmode=list&= Please note that offerors must be registered in CCR (https://www.bpn.gov/ccr/default.aspx) in order to be considered for award. If you have any questions, please contact Divya Soni at divya.s...@nist.gov. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Multi GPU Rendering
I have tested osgViewer on the pc with two GPU card, windows 7 and osg 2.8.3. When I display the statistics, I can see the 2 GPUs. And, If I move the scene from one screen to the other, I can see the load of the GPUs that change. But, I have some problem with the mouse. Sometimes, using the mouse only move the scene on 1 screen and not on the other. And I can only move the scene using the mouse on screen 2 (whereas the main screen is screen 1). -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42164#42164 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgPPU swig wrapped and viewport issues
Hi, I recently started some experimenting with osgPPU. The first results are very nice and promising!! (osgppu rocks ;-)) I added osgswig wrappers to the osgswig project to do some testing, and i experienced a few glitches. 1. there were some manipulation glitches, these were caused by our camera setting COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES on. Turning this off resolved the issue. 2. i had some resize problems, after searching on the forum. I found a solution, by adding some additional explicit resize calls ( for example in an event handler ): osgPPU::Camera::resizeViewport(0,0, ea.getWindowWidth(), ea.getWindowHeight(), viewer->getCamera()); viewer->getProcessor()->onViewportChange(); this does work when the x and y of the viewport are 0, 0 but i see wrong results if x and y are increased ( purple bars appear ). 3. an additional frame() call was needed after the scene is loaded and before the postprocessor is attached, otherwise i would see only a black screen. Grtz, René ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgAndroidExampleGLES1 and 2 error on Android 3.x device
Searching on many forums it comes out that other people do have similar issues with that linker warning. Not sure if that is related to the execution errors that we have (see original post from Ricky) but there might be a relation. Somewhere it was mentioned that the _dso_handle thing is defined in libc.a; and if you look at the stack traces posted by Ricky the libc is always mentioned on the very top of the list... Could it be an issue with the new NDK release? Maybe something is messed up in the way it handles these things? I'm not such an expert in gcc compilation so I cannot help that much here, sorry about that... Luca PS I'd like to try using the NDK r5b which apparently did not show these warnings. Any idea where I could get it from? The official NDK page only offers the link to the latest version -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42166#42166 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgAndroidExampleGLES1 and 2 error on Android 3.x device
Well I have it for linux I can send it to you. If it really is a Bug they will solve in the next rc. 2011/8/22 Luca Vezzadini > Searching on many forums it comes out that other people do have similar > issues with that linker warning. Not sure if that is related to the > execution errors that we have (see original post from Ricky) but there might > be a relation. > Somewhere it was mentioned that the _dso_handle thing is defined in libc.a; > and if you look at the stack traces posted by Ricky the libc is always > mentioned on the very top of the list... > Could it be an issue with the new NDK release? Maybe something is messed up > in the way it handles these things? I'm not such an expert in gcc > compilation so I cannot help that much here, sorry about that... > > Luca > > PS > I'd like to try using the NDK r5b which apparently did not show these > warnings. Any idea where I could get it from? The official NDK page only > offers the link to the latest version > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=42166#42166 > > > > > > ___ > 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] How To: QTreeWidget with multiple nodes of same name in scenegraph
Hi, I am trying to create a QTreeWidget to represent the scene graph in a hierarchical tree view. I used the thread http://forum.openscenegraph.org/viewtopic.php?t=4486 as a starting point. The code used to create the tree nodes is: Code: void BuildTreeNodeVisitor::CreateSubTree(osg::NodePath list) { QTreeWidgetItem* subTree = _tree->topLevelItem(0); for(osg::NodePath::iterator pitr=list.begin(); pitr!=list.end(); ++pitr) //iterate over the entire nodePath from the node visitor iterator { std::string name = (*pitr)->getName(); bool find =false; if (!subTree) //if no item is present at the top of the tree //set the top most QTreeItem as the first element pointed to by pitr { QTreeWidgetItem *added = new QTreeWidgetItem(); //added->setText(0, QString(name.c_str()) ); added->setText(0, QString::fromLocal8Bit("SCENEGRAPH:")); _tree->addTopLevelItem (added); subTree = _tree->topLevelItem(0); } //loop through tree to check if name exists in tree for (int i = 0; i < subTree->childCount(); i++) { if (subTree->child(i)->text(0)==QString::fromStdString(name)) //name already exists i.e. node already exists, do not add duplicate { find = true; subTree = subTree->child(i); break; } } if (!find) //node not found in the node path, create new item and add to tree { QTreeWidgetItem *added = new QTreeWidgetItem(); added->setText(0, QString::fromLocal8Bit (name.c_str())); subTree->addChild (added); } } return; } This works fine until the scene graph has more than 1 node with the same name. If I load two cow.osg nodes, the tree (as expected) shows only one. To work around I tried to set userData by setting it to false for every newly loaded node and then setting it to true when the node got added to tree. However, this has its own problems as the nodes (Geodes) lying underneath the loaded osg::ref_ptr do not have the userData set. Which makes this rather clumsy: Code: void BuildTreeNodeVisitor::CreateSubTree(osg::NodePath list) { QTreeWidgetItem* subTree = _tree->topLevelItem(0); for(osg::NodePath::iterator pitr=list.begin(); pitr!=list.end(); ++pitr) //iterate over the entire nodePath from the node visitor iterator { std::string name = (*pitr)->getName(); bool find = false; bool addedToTree; if(dynamic_cast((*pitr)->getUserData()) == NULL) { (*pitr)->setUserData(new NodeAddedToTreeUserData(false)); addedToTree = false; } else { addedToTree = dynamic_cast ((*pitr)->getUserData())->addedToTree; } int currentChildIndex; for (currentChildIndex = 0; currentChildIndex < subTree->childCount(); currentChildIndex++) { if (subTree->child(currentChildIndex)->text(0)==QString::fromStdString(name)) //name already exists i.e. node already exists, do not add duplicate { if(addedToTree == true) { find = true; subTree = subTree->child(currentChildIndex); break; } } } if (!find) //node not found in the node path, create new item and add to tree { QTreeWidgetItem *added = new QTreeWidgetItem(); added->setText(0, QString::fromLocal8Bit (name.c_str())); subTree->addChild (added); (*pitr)->setUserData(new NodeAddedToTreeUserData(true)); } //check for geodes that do not have user data set and if not added to the tree if(find && dynamic_cast((*pitr)->getUserData()) == NULL) { QTreeWidgetItem *added = new QTreeWidgetItem(); added->setText(0, QString::fromLocal8Bit (name.c_str())); subTree->parent()->addChild(added); (*pitr)->setUserData(new NodeAddedToTreeUserData(true)); } } return; } I was having trouble figuring out the best way to solve this issue of creating a QTreeWidget that can represent any scene graph even having multiple nodes with same names. Any suggestions would be most welcome Thanks Sincerely, Sanat -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42169#42169 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] AlphaPixel Mac binaries Execute bit
Someone from the OSG BOF apparently raised an issue about the Execute bit (not being) set on the Mac binaries produced by the AlphaPixel build system. We haven't been able to pinpoint this, and wondered if anyone who had run into this might step forward so we can figure it out? -- Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com http://www.alphapixel.com/ Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting. "There is no Truth. There is only Perception. To Perceive is to Exist." - Xen ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] An Open Scene Graph solicitation has been posted on FedBizOpps
Hello, The Problem [or bug or required enhancement]: A problem in this system has been observed where parallel, multi-threaded applications do not scale properly to multiple graphics cards resulting in low frame rates. I believe that they may want an enhancement. They may also want a bug fix since they used "fix" and the above uses the word problem. The statement of work indicates that NIST tried to get a "free" fix out of the community but could not. I assume that one task in their list [creation of a test bed] was the reason for no free fix, since that test bed costs money. Example [the following is a task]: .The vendor shall discuss the results and proposed solution with the OSG community and come to a consensus as to the best solution implementation. This tells me that NIST wants some sort of warm fuzzy from the OSG community but see my comment above on the "free" fix. This task already has a failure mode. However, it does consider the issue of interoperability. Will the fix be a best practices type of fix as judged by the OSG community? Will the fix impact other OSG code? But also remember. Somebody is being paid and a task is to get free comments on optimizing and validating the fix. The real question is can the solicitation process be simplified. Is there a way for entities to quickly focus funds similar to the way blender does it [I remember a vague description of the process from Blender BOF's but the process seems to exist]. See the phrase " Wow, so this". The key word is "Wow". My comment on simplification is that NIST is very supportive of the OSG community and wants the vendor to add the "fix or enhancement" back into the OSG ecosystem. This is the perfect method to accelerate feature wish lists. However, it is targeted for a specific host OS / GPU combination and is NOT a general "enhancement". Of course, the problem may not exist on Red Hat or Fedora or Ubuntu [or ] or Windows or Macintosh. Can NIST prove that it does not exist on those platforms! Some interesting notes: NIST anticipates that the "fix" will require 6 months including the required reports. That means 2 boring progress reports in addition to the real documentation on the fix. Also, there is the preparation time for the quotation. Simplification may be impossible since NIST has to prove that it did not violate any laws [there are lots]. This is a main reason for this post. Can anyone figure out how to simplify and still satisfy rules and performance metrics? Lastly, I believe that this is a positive opportunity and lots can be learned. So, I suppose that NIST should be thanked. Also, apologies for the bandwidth usage. John F. Richardson -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of J.P. Delport Sent: Monday, August 22, 2011 4:57 AM To: OpenSceneGraph Users Subject: Re: [osg-users] An Open Scene Graph solicitation has been posted on FedBizOpps Wow, so this is how a government dept submits a bug report :) Should be nice to hunt this one down, I was just wondering over the weekend what happened to it. References here: http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/62225 http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/63954 rgds jp On 19/08/2011 20:31, Judith E Terrill wrote: > For your information, a solicitation to develop a fix for Open Scene > Graph has been posted on FedBizOpps that may be of interest to you. You > may view the solicitation and instructions for responding at: > > https://www.fbo.gov/index?s=opportunity&mode=form&id=5b646272c11b0c2fb01ce61 f954a4555&tab=core&tabmode=list&= > > > Please note that offerors must be registered in CCR > (https://www.bpn.gov/ccr/default.aspx) in order to be considered for award. > If you have any questions, please contact Divya Soni at > divya.s...@nist.gov. > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html. This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ___ 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] How To: QTreeWidget with multiple nodes of same name in scenegraph
Hi Sanat, Maybe you should use Qt's Model View Controller framework. It is a lot more complex than the Tree Widget, but also gives a lot more possibilities. You could write a QAbstractItemModel that directly accesses the live scene graph. You would have to inform the model of changes to your scene graph - added or removed items. You can set links to OSG nodes as InternalPointer in your QModelIndex objects. Mind you: Representing the scene graph as a tree will only work if there are no nodes with multiple parents! Cheers, Martin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42173#42173 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Effect of rotation transforms on Bounding Spheres
Hi, I am trying to use the excellent application from osgworks - osgwbvv to draw bounding spheres around any particular selected node in the scene graph. The function used to draw the bounding sphere is below: Code: void OsgViewerWindow::drawBoundingSphere(osg::ref_ptr &node) { osg::MatrixList matrixList = node->getWorldMatrices(); osg::ref_ptr boundingBoxMt = new osg::MatrixTransform(); osg::ref_ptr boundingBoxGeode = new osg::Geode(); osg::StateSet* ss = boundingBoxGeode->getOrCreateStateSet(); ss->setAttributeAndModes( new osg::PolygonMode( osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE ) ); ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); const osg::BoundingSphere bs( node->getBound() ); boundingBoxMt->postMult(osg::Matrix::rotate(matrixList[0].getRotate())* osg::Matrix::translate(bs._center + matrixList[0].getTrans()) ); //add drawable to the geode boundingBoxGeode->addDrawable( osgwTools::makeGeodesicSphere( bs._radius, 1 ) ); //add geode under Mt boundingBoxMt->addChild(boundingBoxGeode); //get the parent matrix transform of the node and add bounding sphere to it node->getParent(0)->addChild(boundingBoxGeode); return; } While this works fine when there are translations applied to the MatrixTransforms above the nodes, the bounding spheres do not enclose the geometry when rotations are added to the mix. Actually, rendering the bounding sphere clearly showed that something was wrong. I tried following some of the threads as there was some mention of rotations in transforms leading to incorrect results. I thought I was doing ok but haven't had much success. Hence I wanted to ask what is the correct approach to get the bounding sphere for a particular node which may have rotations in addition to translation and scale. Thanks Sincerely, Sanat. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42174#42174 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How To: QTreeWidget with multiple nodes of same name in scenegraph
Hi Martin, I'll take a look at the MVC in Qt. Expanding on the last point you made, the fact that most tree structures such as QTreeWidget, etc seem to have the option for only one parent node, is that an enforced limitation on a scene graph being built - for example, someone would have to load different tires for 2 cars even if they may end up using the same just to allow the tree view to be a faithful representation of the scene graph ? Thanks, Sanat. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42175#42175 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] SIGGRAPH 2011 OpenSceneGraph BOF
Hay John. Maybe next year I can get my Miku Miku Dance port to OSG done and I can entertain the crowd with a singing, dancing figure as a demo. Or would that be a bit over the top for a technical audience? D Glenn D Glenn (a.k.a David Glenn) - Moving Heaven and Earth! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42176#42176 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] An Open Scene Graph solicitation has been postedon FedBizOpps
>However, it is targeted for a specific host OS / GPU combination and is NOT a general >"enhancement". Of course, the problem may not exist on Red Hat or Fedora or Ubuntu [or Linux variant here>] or Windows or Macintosh. >Can NIST prove that it does not exist on those platforms! They provide links to get the test bed software which manifests the problem. It might be worthwhile (if one has the hardware) to see if this problem exists on other OS types. It should be fairly easy to do. My guess is that the problem will persist on those other platforms... -Shayne -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of John Richardson Sent: Monday, August 22, 2011 1:09 PM To: 'OpenSceneGraph Users' Subject: Re: [osg-users] An Open Scene Graph solicitation has been postedon FedBizOpps Snipped to reduce verbosity... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] The Vortex team is looking for a 3D Graphics Software Developer
3D graphics software developers with OpenSceneGraph / OpenGL experience wanted - if you know anyone who could be interested then please forward. Join a team of talented developers building computer graphics for immersive virtual environments for the world’s leading manufacturers and training organizations. The Vortex team is seeking a 3D Graphics Software Developer to join our visual‐simulation applications team. The individual will be responsible for software development of visualization and simulation modules within an interactive, virtual world building and planning application as well as for our simulator technology. For a complete job description see: http://www.vxsim.com/en/about_vortex/jobs Based in Old Montreal, CM Labs develops software and provides services for the 3D visual simulation industry. Vortex is the leading development platform for real‐time modeling of physics‐based vehicles, machines and robots. Vortex is used by applications developers to build physically accurate motion models and interactive behaviors for demanding industrial and defence applications such as training, virtual testing, mission planning and visualization. We provide competitive salaries and an employee group benefits package. Please send applications to h...@vxsim.com We are also offering referral compensation to anyone who connects us with a successful hire. Contact me for more information. Thanks, Arnold. - Arnold Free Vortex - Behaviour in Motion www.vxsim.com Office: 514-287-1166 x225 Mobile: 514-236-9800 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How To: QTreeWidget with multiple nodes of same name in scenegraph
Nerazurri: In a tree, nodes can by definition only have one parent. If you want to display a scene graph in a tree structure you could display a node multiple times for each parent? BTW Maybe one of the existing applications has something for you? http://www.openscenegraph.org/projects/osg/wiki/Community/Applications -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=42180#42180 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Custom Vertex Attributes & Binding
Hello everyone. I am using custom vertex attributes but running into a strange issue. I do not seem to be able to use: BIND_PER_PRIMITIVE ..when using custom vertex attributes. Is this a known limitation, or is it likely a bug/me doing something wrong? I have attached a simple example of this failure; if you uncomment "GridCoordinates", nothing is rendered at all (nor do I receive any information via OSG_NOTIFY). If you keep this commented out, the grid renders. Curious... #include #include #include #include #include class Grid: public osg::Geometry { public: enum { GRID_POSITION = 6, GRID_COORDINATE = 7 }; Grid(const osg::Vec2s& size, const osg::Vec2& gridSize = osg::Vec2(1.0f, 1.0f)): _size (size), _gridSize (gridSize) { setUseDisplayList(false); } bool allocate() { osg::Program* program = new osg::Program(); osg::Shader* vert= osg::Shader::readShaderFile(osg::Shader::VERTEX, "vert.glsl"); osg::Shader* frag= osg::Shader::readShaderFile(osg::Shader::FRAGMENT, "frag.glsl"); // osg::Uniform* texture = new osg::Uniform(osg::Uniform::SAMPLER_2D, "Texture"); program->addShader(vert); program->addShader(frag); program->addBindAttribLocation("GridPosition", GRID_POSITION); program->addBindAttribLocation("GridCoordinate", GRID_COORDINATE); osg::Vec4Array* gridPositions = new osg::Vec4Array(); osg::Vec2Array* gridCoordinates = new osg::Vec2Array(); for(short x = 0; x < _size.x(); x++) { for(short y = 0; y < _size.y(); y++) { osg::Vec4 bl(x, y, 0.0f, 0.0f); osg::Vec4 br(x + _gridSize.x(), y, 0.0f, 1.0f); osg::Vec4 ur(x + _gridSize.x(), y + _gridSize.y(), 0.0f, 2.0f); osg::Vec4 ul(x, y + _gridSize.y(), 0.0f, 3.0f); gridPositions->push_back(bl); gridPositions->push_back(br); gridPositions->push_back(ur); gridPositions->push_back(ul); gridCoordinates->push_back(osg::Vec2(x, y)); } } // GridPosition setVertexAttribArray(GRID_POSITION, gridPositions); setVertexAttribBinding(GRID_POSITION, osg::Geometry::BIND_PER_VERTEX); /* // GridCoordinates setVertexAttribArray(GRID_COORDINATE, gridCoordinates); setVertexAttribBinding(GRID_COORDINATE, osg::Geometry::BIND_PER_PRIMITIVE); u*/ // Finish seting up the Geometry... addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, _size.x() * _size.y() * 4)); // texture->set(0); osg::StateSet* state = getOrCreateStateSet(); state->setAttributeAndModes(program); // state->addUniform(texture); return true; } virtual osg::BoundingBox computeBound() const { return osg::BoundingBox( osg::Vec3(0.0f, 0.0f, 0.0f), osg::Vec3(_size.x() * _gridSize.x(), _size.y() * _gridSize.y(), 0.0f) ); } private: osg::Vec2s _size; osg::Vec2 _gridSize; }; int main(int argc, char** argv) { osgViewer::Viewer viewer; Grid* grid = new Grid(osg::Vec2s(10, 10)); grid->allocate(); osg::Geode* geode = new osg::Geode(); geode->addDrawable(grid); viewer.setSceneData(geode); viewer.addEventHandler(new osgViewer::StatsHandler()); return viewer.run(); } varying float color; void main() { gl_FragColor = vec4(color, color, color, 1.0); } in vec4 GridPosition; in vec2 GridCoordinate; varying float color; void main() { color = GridPosition.w / 3.0; gl_Position = gl_ModelViewProjectionMatrix * vec4(GridPosition.xyz, 1.0); } ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org