Jump to content

Negative scale, flipping, and general understanding


timetocode
 Share

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

Link to comment
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.

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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