Re: [osg-users] Different textures on each face of a geometry?
Hi Nick, If you mean using osg::Geometry::setTexCoordArray, that's what I was doing until now, but I can't anymore since I want to put 2 textures on a single Geometry AND show different parts of them... But if this is not possible without modifying the geometry, I could get by with a simple method to put half of an image into a texture, which I'd display completely. This seemed easier to me, but I don't know if it is doable and how to do it? Thanks for any advice! Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30472#30472 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Different textures on each face of a geometry?
Hi Robert, Thanks for your reply. :) Your solution looks great, I think it'll do the trick! I have another question : Is there a way to create an osg::Texture2D containing only one part of an image, instead of loading the whole image? Typically I want to create textures with only one half of an image. Is this doable? Or is there an easier way to display only one half of an image on my geometry, by configuring the StateSet maybe?... Thanks! Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30431#30431 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Different textures on each face of a geometry?
Hi all, I'm trying to create a simple, planar figure, covered by two rectangular textures, one on each face. For now I couldn't find a better way than creating two geometries very close to each other and fill each one with a different texture. It looks fine while the geometry doesn't change too much, but if I displace the vertices the two geometries start to overlap which result in an ugly mix of the two textures. And I can't do anything about it because of the complex deformation of my object... So I had this idea : is there a way to display different textures on each side of a single geometry? With osg::Geometry::setTexCoordArray maybe?? If not, I could get by with the normals of my geometries... Is there a way to get the normals of a vertex array, as vectors? An if not, how to achieve this simple effect, of a two-sided geometry with different images on each side?... :? Thank you! Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=30428#30428 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgGA::GUIEventHandler problem
Hi, Thanks for the reply! I actually managed to solve the problem, although I'm not sure of what caused it! :) Here's the code for my handler, may it help someone in the same case : Code: bool CRightPanelEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv) { if (nv->getFrameStamp() != NULL && nv->getFrameStamp()->getFrameNumber() != _lastFrame) { _lastFrame = nv->getFrameStamp()->getFrameNumber(); if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH) { // Stuff } } } Checking and recording the framestamp at each loop avoids processing a same frame two times. But I have no idea why my handler processed each frame two times... Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29360#29360 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgGA::GUIEventHandler problem
Hi, I keep having this strange behavior with my custom osgGA::GUIEventHandler class : the handle() method is executed twice each time I click on the handled object... I'm catching PUSH events only, and every single click on my object results in two runs in the corresponding block of the handle() method. The first idea would be that my EventHandler is added twice on my object but it is NOT the case. I'm setting it inside the constructor of another object, which is instanciated only once in the whole app. My handled object is inside an osg::Camera, could it be because of this? Picking objects inside a camera is tricky, but I managed to do it. The only problem is that they are picked twice... does a camera generate two PUSH events when clicked? So here I am... Does anyone have a clue on what's wrong with my handler? Or how I could debug it? Thanks! :) Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=29301#29301 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to delete osg graphs properly?
dglenn wrote: > > Memory handling has always been my worse subject in CS! > Not my best one either... :( @ Paul : I've read your QSG, and found lots of useful information, thanks again! In particular I've learnt by heart the part on memory management. :P But the problem is, I'm doing everything right... All my objects are now in ref_ptr and I still have memory leaks. I had an idea : might inheritance interfere with the osg::Referenced system? I mean, if I create my own class derived from PAT, then put it in a ref_ptr, will it be handled correctly? 'cause I've found out the following behaviour : class CustomPAT : public osg::PositionAttitudeTransform {...} int main() { PositionAttitudeTransform* myPAT1 = new PositionAttitudeTransform(); delete myPAT1; // Compilation error -> normal CustomPAT* myPAT2 = new CustomPAT(); delete myPAT2; // Compilation OK !!! -> shouldn't be } I don't know what to think about it... Could it cause a custom class not to be handled as it should be?... And another point : what if an update callback is still running when the object is dereferenced? Will it be dereferenced too?... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27977#27977 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to delete osg graphs properly?
Hi again, thanks for your responses! @ Paul : A good piece of advice for sure... I didn't even know there was a quick start guide :-* Thank you. @ Skylark : Wow thanks a lot for this very clear explanation!! It seems I was doing exactly the wrong thing... plus, I had simple pointers everywhere. So I fixed this, all of my osg objects are now in osg::ref_ptr, and I've removed every useless operation on my pointers, no release, no delete, just calling "new" when needed. But I still have the memory leak! (which is proven to be caused by my object) Any idea?... I have a subsidiary question : let be a node defined dynamically, existing only as a child of a group. Does the removeChild method delete this node? 'cause I'm doing this everywhere... Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27948#27948 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How to delete osg graphs properly?
Hi all, It's me again, with another practical problem : how to delete properly my osg objects when they contain lots of stuff? Basically I have a PAT with lots of groups and nodes inside it. At some point I need to delete it, then reinstanciate it right away. But I found out that doing this produces one big memory leak... My object is in an osg::ref_ptr, so I tried to .release() it first, it didn't quite change anything... I also tried to mess with the destructor, deleting manually some of the groups and nodes, with no more success... I have to mention that I use several NodeCallbacks inside my PAT, which may be active when I delete it. I don't know how to deal with them, or if I have to... So my question is : what is the proper method to delete an osg scene or part of scene (in order to avoid memory leaks)? Do I have to access and delete every leaf of my graph? Thanks for any advice! :) Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27926#27926 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shrink/Enlarge whole osg::Groups ?
That does the trick, thanks a lot! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27880#27880 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Shrink/Enlarge whole osg::Groups ?
Hi, Thanks for your response, and you're right, I'm not as clear as I thought... Let me explain what I want : I have a scene with an osg::Cylinder that represents a tray, and complex objects placed upon it (typically some Groups containing Text, Geometry and Shapes...). Everything is in a PAT and I just want it to be displayed bigger or smaller, with the same proportions, without changing its content and with the rest of the scene keeping a fixed size. So from what you say, I understand I should use the setScale method? If so, how do I set the Vec3d parameter? Thank you! Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27782#27782 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Shrink/Enlarge whole osg::Groups ?
Hi all, Everything is in the title : how would you change the size of the whole content of an osg::Group (or a PAT) as if it was a single object? Is this possible? Thank you! Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=27748#27748 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Newbie questions...
(the link of the tutorial) http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/KeyboardHandler -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26526#26526 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Newbie questions...
Hi Ulrich , Thanks for your reply! My problems with callbacks are solved. As for the keyboard handling, well, I think you're right, the addFunction method doesn't seem to belong to any osg class... but it's not part of my framework either! Actually I just followed the "official" Keyboard Handler tutorial... (Talking about this, I don't know if it's me but I find these tutorials quite poor and confusing... :?) Anyway, if you have any idea... :) Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26525#26525 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Newbie questions...
Hi everyone, As I'm new to OSG and the community i'm not sure if this is an appropriate place for a newbie's questions, but i'm having much difficulty to learn some specifics... :-* In particular, I'm stucked with callback functions and keyboard handling. Callbacks My problem is : I can get back the nodes of a geode if it's a loaded model (like the tank), but I can't do the same for my own objects, such as simple osg::Sphere loaded in an osg::Geode. What I do is I set the Geode's name to "earth" and I call : Code: _earthNode = dynamic_cast \< osgSim::DOFTransform* \> (findEarth.getFirst()); ... which results in a NULL value in _earthNode. I've found out that the dynamic_cast fails when the returned named object is a geode, but I don't know what object should be named in my hierarchy to be handled sucessfully by a DOFTransform? Or should I use something else than a DOFTransform?? Keyboard Events Handling Here's the kind of code I'm writing : Code: _KEH->addFunction(' ', buildGraph); buildGraph() beeing declared in the .h and beeing defined just below in the .cpp Code: void buildGraph(); Im doing exactly what is in the tutorial, except that everything is in a class, but it fails to build with the following error : > 1>.\CGraph.cpp(49) : error C3867: 'graphs::CGraph::buildGraph': function call > missing argument list; use '&graphs::CGraph::buildGraph' to create a pointer > to member Is anyone familiar with this compilation error?... I don't see what "argument list" is missing, since my function doesn't take any... Any help on any of these topics would be greatly appreciated! Thanks in advance! :) Cheers, Ku -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26347#26347 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org