{"action":"created","issue":{"url":"https://api.github.com/repos/OpenMW/openmw/issues/844","labels_url":"https://api.github.com/repos/OpenMW/openmw/issues/844/labels{/name}","comments_url":"https://api.github.com/repos/OpenMW/openmw/issues/844/comments","events_url":"https://api.github.com/repos/OpenMW/openmw/issues/844/events","html_url":"https://github.com/OpenMW/openmw/pull/844","id":120603363,"number":844,"title":"First draft of serialization routines.","user":{"login":"cfcohen","id":2515512,"avatar_url":"https://avatars.githubusercontent.com/u/2515512?v=3","gravatar_id":"","url":"https://api.github.com/users/cfcohen","html_url":"https://github.com/cfcohen","followers_url":"https://api.github.com/users/cfcohen/followers","following_url":"https://api.github.com/users/cfcohen/following{/other_user}","gists_url":"https://api.github.com/users/cfcohen/gists{/gist_id}","starred_url":"https://api.github.com/users/cfcohen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfcohen/subscriptions","organizations_url":"https://api.github.com/users/cfcohen/orgs","repos_url":"https://api.github.com/users/cfcohen/repos","events_url":"https://api.github.com/users/cfcohen/events{/privacy}","received_events_url":"https://api.github.com/users/cfcohen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/OpenMW/openmw/labels/Discussion","name":"Discussion","color":"fbca04"},{"url":"https://api.github.com/repos/OpenMW/openmw/labels/Do%20not%20merge","name":"Do not merge","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":50,"created_at":"2015-12-06T02:44:20Z","updated_at":"2015-12-18T05:29:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/OpenMW/openmw/pulls/844","html_url":"https://github.com/OpenMW/openmw/pull/844","diff_url":"https://github.com/OpenMW/openmw/pull/844.diff","patch_url":"https://github.com/OpenMW/openmw/pull/844.patch"},"body":"This isn't really a pull request, but rather a request for review and commentary (if you're willing).   My real goal here was to learn some more about OpenSceneGraph, the OSGB/OSGT file format, OpenMW, NIF, etc.  That has certainly happened. :-) As usual, I've reached the point where I'm in over my head, and could use your guidance regardless of whether you ever intend to accept this pull request.\r\n\r\nThe general idea is that there's a new command \"nifconv\" that initializes the engine just far enough to load meshes, and then invokes the OutputStream writer to serialize the object.   There are two new shared libraries that are loaded dynamically by OSG to both read and write the extended object types.   Long term, I'd like to be able to run completely off OSGB assets as a proof of concept.  I've successfully written most of the NIFs in standard distribution, but I don't claim that they're all working properly (just the writing completes without crashing).\r\n\r\nThere are known problems with this commit, including a memory corruption problem when serializing to OSGT format that doesn't appear to happen when serializing to OSGB format.   I continue to find the OSG serialization code fragile, and confusing. :-(  I'll comment in more detail on individual parts of the code where I have questions or specific requests for changes (some changes are just minor bug fixes in the current code)."},"comment":{"url":"https://api.github.com/repos/OpenMW/openmw/issues/comments/165677319","html_url":"https://github.com/OpenMW/openmw/pull/844#issuecomment-165677319","issue_url":"https://api.github.com/repos/OpenMW/openmw/issues/844","id":165677319,"user":{"login":"cfcohen","id":2515512,"avatar_url":"https://avatars.githubusercontent.com/u/2515512?v=3","gravatar_id":"","url":"https://api.github.com/users/cfcohen","html_url":"https://github.com/cfcohen","followers_url":"https://api.github.com/users/cfcohen/followers","following_url":"https://api.github.com/users/cfcohen/following{/other_user}","gists_url":"https://api.github.com/users/cfcohen/gists{/gist_id}","starred_url":"https://api.github.com/users/cfcohen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfcohen/subscriptions","organizations_url":"https://api.github.com/users/cfcohen/orgs","repos_url":"https://api.github.com/users/cfcohen/repos","events_url":"https://api.github.com/users/cfcohen/events{/privacy}","received_events_url":"https://api.github.com/users/cfcohen/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T05:29:59Z","updated_at":"2015-12-18T05:29:59Z","body":"> Sounds complicated. I think you would have to override the default osg::Group serializer, and I'm pretty sure that osgconv would stop working.\r\n\r\nMaybe I misunderstand.  For export in OSG 3.2, I propose roughly:\r\n\r\nwriter->writeObject(geode->getDrawable(0));    \r\n\r\nFor import in OSG 3.2:\r\n\r\ndrawable = reader->readNode(file);\r\ngeode = new Geode();\r\ngeode->addChild(drawable);\r\nreturn geode;\r\n\r\nIs the problem that with out an enclosing Geode that that the 3.2 osgconv would consider the serialization invalid?  If so, I can test that.  The API allows the serialization of individual osg::Objects, so it's not clear to me that this wouldn't work.  \r\n\r\n> How about we add a new option to the NifLoader: bool mBackwardsCompatible. \r\n\r\nThis could work as well, although I'd prefer not to have the extra Geode obviously.  Not so much because of performance, but for clarity and simplicity.  Neither of these approaches address the bug in RigGeometry however.\r\n\r\nIn my most recent local commits, I'm able to do several new things, including creating a \"default\" actor bounding box.  I set it to a btBoxShape, and even without xbase_anim.nif, the player is able to move, which is an improvement over being immobile.  I'm also able to load OSGB geometry (in the code labeled \"TODO support .bullet shape files\") and use NodeToShapeVisitor to construct a BulletShape, although I'm not sure to what effect, since animated creatures still fall through the ground when moving.  The default translation appears to have correct some problems with positioning however.\r\n\r\nFinally, I've modified nifconv to process all NIFs with BulletShapeManager::createInstance() and I've serialized them using btDefaultSerializer.  With Tamriel Rebuilt and Better Bodies, there are 9285 non-compound shapes and 493 compound shapes.  There are 453 with mAnimatedShapes.size() > 0 and 842 with no mCollisionShape.  I figured the next step was to read them back in again as .bullet files instead of NIF files and see if it fixes creatures.\r\n\r\nI think I'm beginning to understand what you meant when you said:\r\n\r\n> NIF's only support triangle shapes, which are not the most optimal shape for a physics engine (slow to process, and can cause glitches if the triangles are too big).\r\n\r\nIt appears that the bullet collision shapes are currently just copies of the geometry.  I was under the impression that the NIFs had separate reduced polygon count geometry for the collision boxes.  And also you wrote:\r\n\r\n> ... but we'll also need to add some sort of meta-data specfying which shape(s) to use and whether or not they should be animated. This metadata could be in the .osg file or in another file.\r\n\r\nWhich I'm still confused by.  If you're able to decide how this should work over the holiday, I'd be very interested in hearing your conclusions.  I'll push one more time before the Christmas holiday tomorrow, and then there won't be any progress for more than a week. :-(  Hopefully answering my questions is less work than just writing it."}}