New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to meshes transform baking and added flipFaces #579

Closed
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@jahow
Contributor

jahow commented Jun 23, 2015

Added the following functions to the Mesh class:

  • bakeCurrentTransformIntoVertices(): computes the world matrix of the mesh, bake it in its vertices and then clears all transform
  • flipFaces(flipNormals: boolean): inverse all the faces of the mesh, and optionally scales all the normals by -1

Modified the following function:

  • bakeTransformIntoVertices(...): this function now makes sure that transformed normals are kept normalized, and flip the faces of the mesh if necessary

Should make mirroring meshes much easier!

@jahow jahow changed the title from Mesh bake patch to Changes to meshes transform baking and added flipFaces Jun 23, 2015

Show outdated Hide outdated Babylon/Mesh/babylon.mesh.ts
data = this.getVerticesData(VertexBuffer.NormalKind);
temp = [];
var temp_normal = new Vector3(0, 0, 0); // this vector is used to normalize the newly transformed normal
for (index = 0; index < data.length; index += 3) {
Vector3.TransformNormal(Vector3.FromArray(data, index), transform).toArray(temp, index);

This comment has been minimized.

@RaananW

RaananW Jun 23, 2015

Member

Normalizing does make sense! :-)
Doesn't this function already deliver a normal? You can simply add the normalize function between the TransformNormal and the toArray. Or did I miss something?

@RaananW

RaananW Jun 23, 2015

Member

Normalizing does make sense! :-)
Doesn't this function already deliver a normal? You can simply add the normalize function between the TransformNormal and the toArray. Or did I miss something?

This comment has been minimized.

@jahow

jahow Jun 23, 2015

Contributor

You're absolutely right. I'll update the PR!

@jahow

jahow Jun 23, 2015

Contributor

You're absolutely right. I'll update the PR!

@jahow

This comment has been minimized.

Show comment
Hide comment
@jahow

jahow Jun 23, 2015

Contributor

Changed the way the normal is normalized (thanks Raanan), although I'm realizing that whether the normal vector is normalized or not doesn't change much the final render. But I guess we'll all sleep better if normals are normals ;)

Contributor

jahow commented Jun 23, 2015

Changed the way the normal is normalized (thanks Raanan), although I'm realizing that whether the normal vector is normalized or not doesn't change much the final render. But I guess we'll all sleep better if normals are normals ;)

Show outdated Hide outdated Babylon/Mesh/babylon.mesh.ts
public flipFaces(flipNormals: boolean = false): void {
var vertex_data = VertexData.ExtractFromMesh(this);
if (flipNormals) {

This comment has been minimized.

@deltakosh

deltakosh Jun 23, 2015

Contributor

You should test for normal presence here

@deltakosh

deltakosh Jun 23, 2015

Contributor

You should test for normal presence here

@deltakosh

This comment has been minimized.

Show comment
Hide comment
@deltakosh

deltakosh Jun 24, 2015

Contributor

Hey can you rebase it?

Contributor

deltakosh commented Jun 24, 2015

Hey can you rebase it?

@deltakosh

This comment has been minimized.

Show comment
Hide comment
@deltakosh

deltakosh Jun 24, 2015

Contributor

Nevermind..I'll merge it :D

Contributor

deltakosh commented Jun 24, 2015

Nevermind..I'll merge it :D

@deltakosh deltakosh closed this Jun 24, 2015

@jahow

This comment has been minimized.

Show comment
Hide comment
@jahow

jahow Jun 25, 2015

Contributor

Oh ok, thanks! sorry I didn't do it in time!

Contributor

jahow commented Jun 25, 2015

Oh ok, thanks! sorry I didn't do it in time!

@jahow jahow deleted the jahow:mesh_bake_patch branch Jul 10, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment