Jump to content

[SOLVED] polygroups?


Recommended Posts

i try mix 2 morph vertex (first frame and last frame ) in one vertex buffer and send to shader 

that lose some Unrecognizable detail now i wanna attach motion 

so after that i have one mesh but have some small morph too :) but  i don't  have result yet but  in this task you wanna change raw data to grouped data

that is possible but if you ask to linked animation to them (like rig) it is different it is like write 3d geometry manager app in web

Link to comment
Share on other sites

I checked and it looks like groups are parsed in the OBJ importer

public obj = /^o/;
public group = /^g/;

but "group" and "obj" will both create a new mesh

//Define a mesh or an object
//Each time this keyword is analysed, create a new Object with all data for creating a babylonMesh
} else if (this.group.test(line) || this.obj.test(line)) {
//Create a new mesh corresponding to the name of the group.
//Definition of the mesh

Maybe I can hack the OBJ importer to create array pointers to the groups.

There's no animation here, but I want to avoid morph targets 'cos I want to manipulate the vertices mathematically

Link to comment
Share on other sites

3 hours ago, ozRocker said:

Maybe I can hack the OBJ importer to create array pointers to the groups.

Not quite sure what you are after, but you could write your own custom mesh merge as well, if you want the meshes together and your own grouping.

Link to comment
Share on other sites

  • 4 months later...

I finally got off my lazy ass and implemented a solution.

You can see the result here: preview.punkoffice.com/bodyparts

I altered the mesh.py file of the Blender exporter to parse the vertex groups.  If anyone wants to see the code changes I've attached my version of mesh.py.  The bits I added have # _NEW_ before the code.  I'm not great at Python so maybe it can be improved.  @JCPalmer this might be of use to you if you want to incorporate vertex groups.

So the extra JSON in the .babylon file looks like this: 

"vertexGroups":[{"name":"waist","id":"waist","indices":[4053,4054,4055,405, etc....]}]

In the Babylon.js code in the Mesh.parse function I added this ( @Deltakosh if you want to incorporate vertex groups you can use this)

            // Vertex groups
            if (parsedMesh.vertexGroups) {
                mesh.vertexGroups = parsedMesh.vertexGroups;

I also had to add a new function to find the vertex group:

BABYLON.Mesh.prototype.getVertexGroupByName = function(vgName) {
    for (var i=0; i<this.vertexGroups.length; i++) {
        if (this.vertexGroups[i].name == vgName) return this.vertexGroups[i];
    return null;


I'm not sure if this is the best way so feel free to ignore if its not efficient, but it works for my needs.


Link to comment
Share on other sites

  • ozRocker changed the title to [SOLVED] polygroups?

Up to my ears in 2.80 changes & TOB improvements right now.  Will look at your file, but not right now.  The tricky part about geometry exporting is multiple materials.  Border vertices get duplicated across sub-meshes.  Anything like this would have to be optional, since it would add to the file size in a significant way.

There are going to be many changes to the next version of mesh.py.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...