ozRocker

[SOLVED] polygroups?

Recommended Posts

Is it possible to define polygroups or vertex groups?  I know Blender allows you to define vertex groups.  Is there a way to include that info in the .babylon export?

Basically I want to be able to manipulate bodyparts vertices (not armature)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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.
https://doc.babylonjs.com/how_to/how_to_merge_meshes#use-your-own-merge-function

Share this post


Link to post
Share on other sites

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.

mesh.py

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.