From 4ec7130da08861dc4aff0232dbce38f3471696a4 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 05 Aug 2019 20:41:17 -0400 Subject: [PATCH] Materials working. --- BoundaryRep.java | 56 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 47 insertions(+), 9 deletions(-) diff --git a/BoundaryRep.java b/BoundaryRep.java index 3583aa0..79ff6fe 100644 --- a/BoundaryRep.java +++ b/BoundaryRep.java @@ -1997,7 +1997,10 @@ if (v.vertexlinks == null) continue; - if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0) + // Warning: faster but dangerous + if (v.weights != null && v.weights[j] + // == 0) + < 0.001 * v.totalweight) { //testweight += v.weights[j-1]; continue; @@ -3857,6 +3860,28 @@ Trim(true/*wastrim*/,true,crease,wasstrip,false); } + void GenerateNormalsMesh() + { + if (stripified) + { + Unstripify(); + } + + if (trimmed) + { + normals = null; + } + else + { + for (int i=VertexCount(); --i>=0;) + { + Vertex v = GetVertex(i); + + v.norm = null; + } + } + } + void GenNormalsJME() { assert(false); @@ -3979,7 +4004,7 @@ NormalGenerator ng; if (crease) - ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4); + ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4); else ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4); @@ -4013,8 +4038,9 @@ triangles[i] = i; } - Untrim(); - MergeNormals(); +// Untrim(); + if (!trimmed) + MergeNormals(); } } @@ -4076,8 +4102,9 @@ triangles[0] = 3; } - Untrim(); - MergeNormals(); + //Untrim(); + if (!trimmed) + MergeNormals(); } /* @@ -4131,6 +4158,8 @@ void MergeNormals() { + assert(!trimmed); + boolean smooth = Grafreed.smoothmode; boolean link = Grafreed.linkUV; Grafreed.smoothmode = true; @@ -4942,9 +4971,18 @@ v./*pos.*/y = positions[i3 + 1]; v./*pos.*/z = positions[i3 + 2]; - v.norm.x = normals[i3]; - v.norm.y = normals[i3 + 1]; - v.norm.z = normals[i3 + 2]; + if (normals == null) + { + v.norm.x = 0; + v.norm.y = 0; + v.norm.z = 0; + } + else + { + v.norm.x = normals[i3]; + v.norm.y = normals[i3 + 1]; + v.norm.z = normals[i3 + 2]; + } v.s = uvmap[i2]; v.t = uvmap[i2 + 1]; -- Gitblit v1.6.2