Skip to content
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 from

Conversation

@jahow
Copy link
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!

olivier.g added 2 commits Jun 23, 2015
@jahow jahow changed the title Mesh bake patch Changes to meshes transform baking and added flipFaces Jun 23, 2015
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?

This comment has been minimized.

@jahow

jahow Jun 23, 2015 Author Contributor

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

olivier.g added 2 commits Jun 23, 2015
olivier.g
olivier.g
@jahow
Copy link
Contributor Author

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 ;)

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

olivier.g
@deltakosh
Copy link
Contributor

deltakosh commented Jun 24, 2015

Hey can you rebase it?

@deltakosh
Copy link
Contributor

deltakosh commented Jun 24, 2015

Nevermind..I'll merge it :D

@deltakosh deltakosh closed this Jun 24, 2015
@jahow
Copy link
Contributor Author

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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.