babbleon Posted March 8, 2018 Share Posted March 8, 2018 Hello, If I know the index / indeces a one or more vertices, how can I just delete them? Thank you Quote Link to comment Share on other sites More sharing options...
PsichiX Posted March 8, 2018 Share Posted March 8, 2018 why would you want to do that? please, tell us what end goal you want to achieve - probably there is a better way to get this thing done. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 8, 2018 Author Share Posted March 8, 2018 Thank you @PsichiX, I have a mesh which is exported from Blender. Separate faces have different vertex colours. I would like to be able to click on any particular part and it will delete the vertices that have that particular vertex colour and then create a new mesh from the previously deleted vertices. At the moment, when you click on it the selected vertices just get set to 0,0,0 and so are invisible. Here's a PG: https://playground.babylonjs.com/#44X0M9#10 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 8, 2018 Share Posted March 8, 2018 It’s not that simple vertices share faces that are on separate colors. You would need to do a flood fill algo basically and iterate over the points gather out the points that you need, mark the ones that are sharing faces, pull the buffer out and the repair the other one. I’ve tried to examine that it’s not simple and is very limited on scope. Especially when it will be hard to establish the vertices that are a different because they are a border to anouther color region and won’t be the same color as initially looking for. The better way is to have the mesh seperated already on inport. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 8, 2018 Author Share Posted March 8, 2018 Thank you @Pryme8 Quote Link to comment Share on other sites More sharing options...
Guest Posted March 8, 2018 Share Posted March 8, 2018 If you still want to go down the mesh edition path, here is a doc which uses our vertex data API: http://doc.babylonjs.com/how_to/how_to_merge_meshes This could give you some ideas Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 8, 2018 Author Share Posted March 8, 2018 Thank you. I am sick of vertices. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted March 8, 2018 Share Posted March 8, 2018 lol Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 9, 2018 Author Share Posted March 9, 2018 I have altered the approach on this. In short & in the absence of a better idea, I load a mesh and create x number of new meshes where x = number of unique vertex colours and set all vertex positions on each new mesh to 0 where they do not match the current vertex colour. PG here: https://playground.babylonjs.com/#44X0M9#28 The problem I'm having is that the vertex positions taken from the original loaded mesh do not correctly update on each distinctVertexColours loop. If you uncomment lines 72,73,74 and comment out 79,80,81 you will see the problem a bit more clearly. Does anyone have any bright ideas as how to fix this? Thank you. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 9, 2018 Share Posted March 9, 2018 some remarks: - line #91 is a duplicate of the applyToMesh API - Not sure to understand what would be the expected result if I uncomment the lines your mentioned. Can you elaborate on that? Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 9, 2018 Author Share Posted March 9, 2018 Thank you @Deltakosh - problem is still there if I comment out #91, but good to know. below is extract with comment about the bits of the loop for (l = 0; l < colors.length; l += 4) { if (colors[l + 0] == distinctVertexColours[k][0] && colors[l + 1] == distinctVertexColours[k][1] && colors[l + 2] == distinctVertexColours[k][2]) { ///sets vertices to 0 position if they have vertex colour in loop //positions[((l / 4) * 3) + 0] = 0; //positions[((l / 4) * 3) + 1] = 0; //positions[((l / 4) * 3) + 2] = 0; } else { ///sets vertices to 0 position if they do not have vertex colour in loop positions[((l / 4) * 3) + 0] = 0; positions[((l / 4) * 3) + 1] = 0; positions[((l / 4) * 3) + 2] = 0; } } Quote Link to comment Share on other sites More sharing options...
Guest Posted March 9, 2018 Share Posted March 9, 2018 I meant: what should be the expected visual result? Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 9, 2018 Author Share Posted March 9, 2018 ah, I see! As it stands now - I would expect to see x number of meshes (5 or 6) from left to right: 1st being the original mesh 2nd is correct 3rd with only faces of another vertex colour and so on Each of the new meshes would only have one single vertex colour and only be parts of the original mesh. If you uncomment lines 72,73,74 and comment out 79,80,81 all it would do if instead of hiding all but the chosen vertex colour, it would hide all other. Hope I am explaining properly. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 9, 2018 Share Posted March 9, 2018 Is it better: https://playground.babylonjs.com/#44X0M9#29 I added a slice to the original positions to avoid modifying them babbleon 1 Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 9, 2018 Author Share Posted March 9, 2018 Amazing! Thank you so much! Just adjusted the commented lines: https://playground.babylonjs.com/#44X0M9#31 and is now perfect. @Pryme8: Will this now work for you? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 9, 2018 Share Posted March 9, 2018 Yes and no... I do not understand the necessity to do things outside of normal scope. When you construct the mesh with vertex colors you are still having to go through and edit the mesh and set vertex colors, which takes just as much time as splitting the mesh up in your program. This just adds a bunch more steps... you are basically making bjs do what you should have just done in your 3d program. You could use this process though with this: http://www.babylonjs-playground.com/#36TFT6#15 ... like I said at that point you are just adding extra steps and making more work for yourself. but ill go ahead and enable the stuff to this new process, cause its easier to say yes and just do it then bother with conversation especially when its specifically what you want. I'm on it. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 9, 2018 Share Posted March 9, 2018 https://playground.babylonjs.com/#44X0M9#32 Now to implement HSV controls, and then the standard material properties. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 9, 2018 Author Share Posted March 9, 2018 Hi @Pryme8, Simply put, it's something I then wont have to do in Blender.. a real pain if I have modifiers which I invariably do. Not an issue if I am doing one model, but if i am doing say 6 models per day then it all stacks up. Much better BJS does the work on import than me. Thank you for agreeing to implement this. Cheers, GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted March 9, 2018 Share Posted March 9, 2018 no problem, as long as you are happy. GameMonetize 1 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.