timetocode

Negative scale, flipping, and general understanding

Recommended Posts

On some objs that I import, I'm having to do foo.scaling = new BABYLON.Vector3(-1, 1, 1).  For example this zombie needed the torso scaling set (-1, 1, 1) before the left and right hands appeared on the correct sides of the body among other details. The arms are parented to the torso, so I think that is how the scale is factoring into which side they appear on. The head is actually flipped incorrectly at the moment as well, but that doesn't really matter. I'm fine with scaling(-1,1,1) as a solution, but for some reason the gun now has its mesh inside out or something.

So my question is two parts:

1) why is the gun inside out? 

The parent order (child to parent) is weapon -> leftHand -> lowerLeftArm -> upperLeftArm -> torso. In theory everything is inheriting its scale from torso.  Each body part is a separate mesh made the same way, yet only the weapon is inside out, not the torso or any of the arm parts (maybe I just have an error in my code, unless there is some reason that this would naturally by the case).

2) is there a babylon function to fix only an individual mesh?

I searched the forum and found many pgs dating back up to 3 years, and some mention of including righthand vs lefthand modes in bjs... but I wasn't sure what the current day method would be to fix just the weapon mesh below.

image.png.84bb352f04cf47ace31655a61e46ea86.png

It may be a little hard to see that it is in fact inside-out, so here's another picture of what the weapon is supposed to look like:

image.thumb.png.74e2c31b57bb3b76b8234bb91160dece.png

 

I cannot use blender+babylon-exporter to make the full model at this point (some complex issues with networking bone animations exported from blender to babylon, a topic for another time).

I am still using blender to pose my character as a visual reference before converting the rotations of each body part over to a custom animation system -- so this is perhaps where the conflicting notion of left/right arms is coming from originally.

 

Thanks :D

Share this post


Link to post
Share on other sites

Found mesh.flipFaces(false) which seems to fix all of the meshes I've had problems with so far.

I also tried the full scene-wide flip (scene.useRightHandSystem = true) which worked as well and allowed me to not have any negative scales.  I'm going back to left hand though, not sure if it is more intuitive or if I just have too much code that relies on it, but flipping a voxel collision system and maps was not so easy.

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.