babbleon Posted July 17, 2018 Share Posted July 17, 2018 (edited) Hello, For anyone that may be interested, I have been messing with mesh.py to get it to export Vertex Groups along with their associated indices and have attached it. I think @adam and @ozRocker have both asked about this and I'd definitely make good use of it. I'd be grateful if you could let me know if this works for you or not, please. It currently adds them under the 'meshes' as 'vertexGroups' Massive disclaimer: I am not good with Python! Thank you Problem: it duplicates indices. mesh.py Edited July 17, 2018 by babbleon Problem ozRocker and dbawel 1 1 Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 17, 2018 Author Share Posted July 17, 2018 The attached mesh.py has been corrected and does not have duplicated indices. mesh.py Quote Link to comment Share on other sites More sharing options...
Guest Posted July 17, 2018 Share Posted July 17, 2018 I guess @JCPalmer could find it useful Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 17, 2018 Author Share Posted July 17, 2018 Just now, Deltakosh said: I guess @JCPalmer could find it useful Silly me, yes of course! thank you DK. Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 17, 2018 Author Share Posted July 17, 2018 the attached now puts the vertexGroups under mesh metadata. mesh.py Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 17, 2018 Author Share Posted July 17, 2018 PG illustrating use of this: http://www.babylonjs-playground.com/#0MSI9S#1 V!nc3r and JCPalmer 2 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 17, 2018 Share Posted July 17, 2018 Saw the pg, and downloaded last file, but did not diff it to the repos. As it is the largest source file in the add-on, I would need to diff to find the lines added / changed. Not a big deal in Netbeans. I do not a use for right now in my own work, but now that I know it is an option uses might come up. If you are thinking about a PR, a checkbox in the custom properties (default false) would definitely be needed, since if you are not using, it could really increase the size of the export file. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted July 18, 2018 Share Posted July 18, 2018 @babbleon you are awesome!! This is exactly what I need! Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 18, 2018 Author Share Posted July 18, 2018 Thank you @ozRocker, do let me know if you have problems with it. @JCPalmer, I have now added checkbox as you suggested. I have a problem which is beyond my understanding of python and would be grateful if you could help please. You may recall we added the 'Track To' constraint which adds this to metadata. I cannot work out how not to overwrite metadata when we have both 'Vertex Groups' & 'Track To'. I attach the latest mesh.py though I can do a PR if you prefer. mesh.py Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 18, 2018 Share Posted July 18, 2018 In the middle of something today. Will look at this soon. Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 18, 2018 Author Share Posted July 18, 2018 Thank you, much appreciated. Quote Link to comment Share on other sites More sharing options...
ozRocker Posted July 19, 2018 Share Posted July 19, 2018 Just wondering, with the Blender export, is vertex order preserved? Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 19, 2018 Author Share Posted July 19, 2018 Hi @ozRocker, I don't think so but @JCPalmer will know. On another point, I'm looking at being able to support exporting individual vertex positions between specific frames into metadata.. so no need for OBJ sequences or parsing PC2 data. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 19, 2018 Share Posted July 19, 2018 7 hours ago, ozRocker said: Just wondering, with the Blender export, is vertex order preserved? Not at all. Even worse, if you desired that, the vertices are not even directly consulted. A feature in Blender that allows you to get a temp copy of geometry, with modifiers applied is used. So if you were using a modifier like mirror, then twice the vertices would be exported than were actually be in the mesh. Inside of using the mesh copy, vertices are indexed in the export for compactness & that is how BJS loads them to gl context. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 22, 2018 Share Posted July 22, 2018 I look at your mesh.py. I refactored it creating a small class called BJSVertexGroup, since you were doing an array of arrays, then indexing into it with loop, and also including a matching name. It is very small, and looks a lot like the SubMesh class: class BJSVertexGroup: def __init__(self, group): self.name = group.name self.groupIdx = group.index self.indices = [] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - def to_scene_file(self, file_handler): file_handler.write('\n{') write_string(file_handler, 'name', self.name, True) write_array(file_handler, 'indices', self.indices) file_handler.write('}') This adds functionality, so I bumped the version to 5.7. I ran it in against a blend with armature of 25 bones, but one of the meshes is only affected by 2 bones (vertex groups are used for bones too). It correctly only matched for 2 vertex groups. Data looked reasonable. I do not have code to playing with this once in BJS though. Please run this mesh.py against your .blends to verify, before I push up the new .zip file. Also, please add an announcement topic illustrating, since this is the only change for 5.7 Quote Link to comment Share on other sites More sharing options...
babbleon Posted July 25, 2018 Author Share Posted July 25, 2018 (edited) Hi @JCPalmer, this all seems to work fine thank you. Something's not quite right with the indices.. I will have a look when I have time & post back. I will post a further amended mesh.py soon which enabled you to export animated vertex positions so once that is sorted and you're happy to include - it can go to 5.7 too. Thank you. Edited July 25, 2018 by babbleon correction Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 25, 2018 Share Posted July 25, 2018 Might be you wrote it out this way: write_array(file_handler, 'indices', list(set(self.vertexGroups[indexgroups]))) I was not sure what that did. Looking at this entire topic, it was probably for duplicates. That could be put into the to_scene_file(). Duplicates can also just be avoided by moving up & indenting the code that appends them only when the vertex is added for the first time. Duplicates are created automatically for the vertices which border a material change, but those are not implemented through indices, but actual duplicate vertices. On your animation of vertices, this can get really expensive file size wise. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.