[osg-users] [osgPlugins] Implementing ReaderWriter in a class within application binary
Hey everyone, Is it possible for osgDB to load classes implementing ReaderWriter functionality out of my application binary, or must they be stored in a separate .so in the plugin directory? If so, are there any special directions I need to follow to get this working? Secondly, what is "proper" behavior for a plugin implementing only readNode functionality? Do I leave writeNode unimplemented? Or should I implement writeNode, but only return a WriteResult with a particular error status? Many thanks, Thomas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31786#31786 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Implementing ReaderWriter in a class within application binary
Hi Robert, Thank you for the time you take to make your response, and the level of information you included in it. Unfortunately I think you may have misunderstood my original question. I was not inquiring about the possibility of serializing my own classes into the native binary format, but rather I was wishing to know whether a class that implements the ReaderWriter functionality (i.e. the readNode and writeNode methods present in all osgDB plugins) for a new format must be compiled into an external plugin (.so), or whether it can be incorporated directly into my application code, and compiled as part of my application binary. The instructions I was able to find on the wiki regarding plugin implementation is a bit sketchy, and only covered the possibility of helping the osgDB locate ReaderWriter plugins that are actually stored as external plugins and not compiled into my application. Additionally I was wondering what "proper plugin etiquette" is for plugins that read a format, but do not also write to it. I noticed some plugins conditionally return a Code: WriteResult(WriteResult::FILE_NOT_HANDLED); My question on this second issue is whether it is "better manners" for my ReaderWriter class to implement a writeNode function that ALWAYS returns FILE_NOT_HANDLED, or whether it is best to just leave the function unimplemented. Thanks, Thomas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31803#31803 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Implementing ReaderWriter in a class within application binary
Tim Moore wrote: > You don't need to do anything special for a ReaderWriter that you wish to > link into your application. You write the class in exactly the same way, > including the REGISTER_OSGPLUGIN macro. Your plugin will be registered early > and OSG will use your code to load that file extension without searching for > an external plugin. > > > Depending on your platform, you might need to perform some additional magic > to ensure that your code is actually linked into the application. On Unix, > for example, if your plugin code is in a statically-linked library, the .o > file containing the REGISTER_OSGPLUGIN "call" won't be linked in unless you > create some external reference to code in that file. > > ... > > Not FILE_NOT_HANDLED, but NOT_IMPLEMENTED. Since the default virtual methods > return NOT_IMPLEMENTED, it's cleaner not to implement them yourself; you > might get the return result wrong :) > > > Tim > Ah, that is just exactly what I wanted to know. Many thanks. Are either of these clearly documented on the wiki somewhere that I should know about? Or would it perhaps be worth starting an entry on developing a new plugin? Thomas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31824#31824 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Implementing ReaderWriter in a class within application binary
That's good to know, I've registered for a wiki account and will do my best to post useful tips that I figure out. Most of the information I've seen on there up to this point seems to be related to developing around OSG rather than developing to extend it, which seems a little silly given how extensible and modular it has been designed to be. ~Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=31853#31853 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] pushing bytes back to ifstream?
I'm sorry if this is something that I should know, but osg::ifstream doesn't seem to have any way of peeking at the next byte or reading/pushing back a byte. I am attempting to implement a platform agnostic readLine() method that can handle \r\n, \r, or \n. Is there a wrapper class I should be using here with the ifstream, or is there another strategy I should use? Also, I should note that this is a binary stream, since the file type has a mix of binary and textual data. Thanks, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32317#32317 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] pushing bytes back to ifstream?
Alberto Luaces wrote: > > Hi Thomas, > > since osgDB::ifstream inherits from std, you can try putback(char c) > > http://www.cplusplus.com/reference/iostream/istream/putback/ That sounds great, thanks. I was simply unsure if this was allowed, as the documentation makes no mention of inheritance. Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32365#32365 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
I'm working on extending the bsp plugin to support the .dif (Dynamix Interior Format) used by Torque Game Engine and its successors. I am attempting to read the png lightmaps from the file stream, using the following code: Code: osg::ref_ptr reader = osgDB::Registry::instance()->getReaderWriterForExtension("png"); osgDB::ReaderWriter::ReadResult rr; mapFile->read((S8*)&j, sizeof(U32)); convertLEndianToHost(&j); curLevel.lightmaps.reserve(j); curLevel.lightDirMaps.reserve(j); curLevel.lightmapKeep.reserve(j); std::cout << "reading " << j << " lightmaps and lightDirMaps and lightmapkeeps" << std::endl; for(i = 0; i < curLevel.lightmaps.capacity(); i++){ rr = reader->readImage(*mapFile); std::cout << "read lm " << i << std::endl; if(rr.success()){ curLevel.lightmaps.push_back(rr.takeImage()); std::cout << "took lm " << i << std::endl; } else{ std::cout << "\t- Sorry, we screwed this one up" << std::endl; return false; } if(curLevel.iFV == 1 || curLevel.iFV >= 12){ rr = reader->readImage(*mapFile); std::cout << "read lmd " << i << std::endl; if(rr.success()){ osg::ref_ptr tmp = rr.takeImage(); // Should be autocleaned up by ref_ptr std::cout << "took lmd " << i << std::endl; curLevel.lightDirMaps.push_back(NULL); // Keep our place in the stream, but don't save the result of this std::cout << "pushed back empty" << std::endl; } else{ std::cout << "\t- Sorry, we screwed this one up" << std::endl; return false; } } mapFile->read((S8*)&flag,sizeof(U8)); curLevel.lightmapKeep.push_back(flag); std::cout << "took flag " << i << " : " << U32(flag) << std::endl; } Immediately after seeing "reading 20 lightmaps and lightDirmaps and lightmapkeeps" in the console, the plugin throws a bus error. I know the the png data in the stream is good, since the reference implementation from TGE manages to read it fine, and my debugging has shown that up until this point my plugin modifications have read the exact same information that that the reference implementation has. By process of elimination the hiccup is happening during the reading of the png itself, but since the reference implementation (whose readPNG method makes use of libpng) does okay, there must be some difference in the way the two are reading it. Am I doing something obviously wrong here? Are there subtleties in the behavior of the png reader/writers when reading from stream that I should be aware of? Any other comments? Thanks, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32601#32601 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
I'm recompiling a debug build now and setting XCode up to debug a shared library, but I'm not sure what information would be helpful to you? Debugging is usually an interactive process, so without more specificity than "use a debugger" I can't do much more than take a screenshot, or upload a zip with my plugin source and the test file I'm using for input for someone to run the debugger themselves. thanks, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32626#32626 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
Stepping through the code in XCode, I am crashing somewhere inside of ReaderWriterQT (specifically at GetGraphicsImporterForDataRef(dataRef, 'ptr ', &gicomp); inside of QuicktimeImportExport::doImport), which would seem to confirm what you are saying. Is it possible that the QT code isn't getting along with the overhauled Quicktime in Snow Leopard? Your suggestion of using the ReaderWriterPNG (based on libpng) seems like it would ensure the most consistent behavior across multiple platforms. How would I go about adding it to my XCode project and forcing the Registry to load that plugin in favor of imageio or Quicktime? As an interesting side-note, when running the code in the debugger, it actually seems to read the first image successfully, and crashes on the second, whereas when run in the Terminal without a debugging environment, it seems to crash when reading the first. Thanks, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32632#32632 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
Sorry for the double post, but since I'm not sure how Mail2Forum handles edits to posts on the forum, I figured it would be better to avoid any confusion between the two communication channels. I've gotten osgdb_png.so to compile, how might I go about forcing its use (in place of osgdb_qt.so) for PNG files specifically? Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32634#32634 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
Ulrich Hertlein wrote: > > A stack trace is usually helpful, as it would tell you where (in what > function) the crash > occurred. To that effect, it does not need to be interactive. > > As Stephan already said, any additional information is helpful (your original > mail didn't > have a lot of that). This is good to know for the next time I run into a problem, thanks. > Maybe the QT reader is buggy in the stream-reading path. This seems to have been the case. I set up the ReaderWriterPNG class to directly include libpng and libz in its own source (not a clean solution, but for relatively small libraries like that it seemed easier than mucking about with include/link directory settings in 3 different IDEs), and added support for the "istreampng" file extension, so that I had an easy way to make sure it superceded any of the default plugins that (claim to) support reading a png from stream. It seems to be working at the moment, but if anyone has suggestions for a less hacky solution, that would be appreciated. ~Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32637#32637 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
sth wrote: > > The quicktime plugin can handle input from streams but needs some > assistance, as it can read a LOT of image-formats. It needs a mime-type > / file-extension and a size of bytes to read from the stream. This makes sense, but is also semi-problematic, since I don't know how big the png in the stream is going to bedoes the quicktime plugin have a way of calculating this on it's own if knows what kind of file it should be reading? Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32640#32640 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
Skylark wrote: > Hi Stephan, Thomas, > > > > To preload the png-plugin: > > > > osgDB::Registry::instance()->loadLibrary("png"); // or "osgdb_png", not > > sure right now. > > > > Or I find it easier to do: > > osgDB::Registry::instance()->loadPluginForExtension("png"); > > J-S > Unfortunately as far as I can tell, this seems to load the first png-capable library it runs across, rather than the specific one I'm looking for. Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32647#32647 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] bus error when reading PNG data from stream for new plugin
Skylark wrote: > Ah yes, I should have thought before replying - on MacOS the Quicktime > or ImageIO plugins will be preferred... Then Stephan's way should work > for you. > > Sorry for wasting your time. > Not at all, it's always pleasant when someone takes the time to respond, even if the response isn't immediately helpful. I seem to have things working okay at the moment, so I'm grateful for that. Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32700#32700 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Translucent primitives grouped by Drawable or by Geode?
Hi, When rendering translucent objects in OpenSceneGraph, do I need a Drawable per set of translucent primitives, or a Geode per set? I'm asking because some of my models have a mixture of translucent and opaque materials, in terms of graph structure it seems like per-Geode would make more sense. I just want to be on the safe side. Thank you! Cheers, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33100#33100 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] upgrades to osgdb_bsp
Hey everyone, Over the last few weeks I've been working on upgrades to the ReaderWriterBSP class to allow it to load drawable geometry from files in the Dynamix Interior Format, a bsp format used by the Torque Game Engine, and it's derivatives. I have a few more bugs to track down with some missing polygons, and distortion of certain textures, but I think it is approaching readiness. Is this something that people feel would make a worthwhile addition to the default set of plugins? If so, how would I go about submitting it? Cheers, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33101#33101 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] upgrades to osgdb_bsp
robertosfield wrote: > If there are lots of changes then consider placing the changes into a > separate plugin, but this does also assume that their is a different > file extension for this file format, I don't know anything about the > "Dynamix Interior Format" so can't comment on this. Whether you do go > for separate plugin or not just package up all the required > files/modified files in full and post them to osg-submissions mailing > list and I can pick them up from there. The Dynamix Interior Format (DIF) is a binary-space partition format used by the Torque Game Engine, and derivative products (from GarageGames, founded by former members of Dynamix). It does use its own extension (.dif); however I felt that it made sense to work on it as an extension to the existing bsp plugin since it could then easily be extended at some point in the future into a nodekit providing BSP collision information to programs which (for example) make use of osgBullet or have similar physics needs. It is particularly likely that I will make these improvements myself at some point in the future, so having the plugin structured in that manner made sense as far as long-term planning is concerned. If you still want a separate plugin, I'm happy to separate it out, but the changes I made to the organizational structure and inheritance-tree of the classes in the osg_bsp plugin may still be desirable. Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33153#33153 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Translucent primitives grouped by Drawable or by Geode?
Robert, That is the response I was anticipating, but it's good to have my suspicions confirmed. Thanks, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33154#33154 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Several questions regarding Terrain
Hi, I would like to be able to load the terrain format used by the Torque Game Engine. A couple questions about how to use the Terrain mechanisms built in to OpenSceneGraph: If I have a heightfield which tiles cleanly, is there a mechanism to make a terrain repeat indefinitely? Is there any sort of mechanism to draw a hole in a patch of terrain? If not, how would such a thing be implemented? Can you have multiple layers of texture over the same heightfield? (i.e. a background texture and another "detail" texture painted over it? In the documentation I see names like "TerrainTechnique" "Layer" "Terrain" and "TerrainTile" being thrown around without much description of the roll of any individual class. Is this documented in any reasonable form somewhere, or would someone care to explain them? Thank you! Cheers, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35012#35012 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] upgrades to osgdb_bsp
I was sidetracked for a while with exams and such, but I got back to work and I think I have all but one (or two) of the bugs worked out. Looking at the image below (and ignoring the wooden gates), the bottom half represents what the top half should look like, minus the lighting. The faces that are strangely darker in the top half would lead me to believe that perhaps I have some faces which are flipped and showing their back face. But as far as the distortion of the stone texture on the ramp is concerned I'm stumped. The texturing is applied based on two "texgen equations" which are applied statically (not with a TexGen node) to generate a UV coordinate as follows: Given a point pt, and an "x" and "y" plane defining the texgen equation, Code: u = pt.x*xP.x + pt.y*xP.y + pt.z*xP.z + xP.w; v = pt.x*yP.x + pt.y*yP.y + pt.z*yP.z+yP.w; [Image: http://img814.imageshack.us/img814/9619/funkytex.jpg ] gDEBugger shows that the relevant textures in both osgViewer and the reference program are loaded and undistorted in memory. If anyone here has a hunch as to the cause, or has seen similar problems before, I'd love to hear about it. Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35098#35098 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Several questions regarding Terrain
Hi, I have loaded a 256x256 HeightField, created a HeightFieldLayer, and added it as the ElevationLayer to a TerrainTile. Now, if I would like to go about texturing patches of terrain, do I essentially need a separate TerrainTile for each individual area to be textured? And if this is the case, can multiple TerrainTiles use the same ImageLayer for their own ColorLayers? And I still have not decoded the use of the Terrain class itself, which doesn't seem to be used in the osgterrain_example demo application! Any help or tips that can be provided would be delightful. Thank you! Cheers, Thomas Vermont Sustainable Heating Initiative (http://www.sustainableheatingvt.org) || Village2Village Project (http://www.village2villageproject.org) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35110#35110 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org