Raggar Posted May 14, 2017 Share Posted May 14, 2017 The following functionality applies the current vertices' positions to the same vertices(No change to the mesh). var arr = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); for (var i = 0; i <mesh.getTotalVertices(); i = i++){ var fx = arr[i * 3 + 0]; var fy = arr[i * 3 + 1]; var fz = arr[i * 3 + 2]; arr[i * 3 + 0] = fx; arr[i * 3 + 1] = fy; arr[i * 3 + 2] = fz; } mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, arr); I'm unsure as to how to apply a random noise, that still takes into account the vertices that are on the same position? If I use something like fx/fy/fz + a random value, the faces split up, and creates holes in the mesh. Quote Link to comment Share on other sites More sharing options...
JohnK Posted May 14, 2017 Share Posted May 14, 2017 There are two basic construction methods for a mesh Corners on a mesh share vertices and normals Corners on a mesh do not share vertices and normals. ( A flat shaded mesh) (read more here ) In BJS a sphere is created using method 1 and a box using method 2. Should you apply random noise to a mesh constructed with method 2 then the faces will split apart. PGs Randomised Sphere (but still split along seam) Flat Shaded Randomised Sphere Randomised Box "Smoothed Randomised Box more on smoothing function here but not the added TRUE parameter for applyToMesh since we need to maintain update-ability of the mesh Dad72 and Raggar 2 Quote Link to comment Share on other sites More sharing options...
Raggar Posted May 14, 2017 Author Share Posted May 14, 2017 Hmm. I might be missing something here. Look at my imported model: http://www.babylonjs-playground.com/#JZS611#1 The model has smoothing groups (From 3Ds max). Flat-shaded or smooth doesn't seem to make a difference. Might this be due to the way the model is exported or created in 3Ds max? Quote Link to comment Share on other sites More sharing options...
JohnK Posted May 14, 2017 Share Posted May 14, 2017 Added in minimising function http://www.babylonjs-playground.com/#JZS611#2 Do not know anything about 3D max. Quote Link to comment Share on other sites More sharing options...
Raggar Posted May 31, 2017 Author Share Posted May 31, 2017 Hmm. For now, I've been using morph targets, but I'd like some more randomization without having multiple models. I'll try another model, as the one in this example was a quick one, where I applied the push modifier due to weird normal behavier. This was a bad fix, but the quickest one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.