Lary Posted October 15, 2017 Share Posted October 15, 2017 Hi all, Thanks for your attention. Is there a way to cut one mesh into two (with two different mesh names), no matter where the cutting section will be, and fit another irrelevant mesh between the fore-mentioned two meshes?and at last add these 3 meshes to form a new object? I tried CSG, it seems the mesh can be cut into two on the surface, but in fact it still remains one mesh. You can check attached sketch to get an general idea of what I want, pls. forgive my poor drawing skill. I will greatly appreciate if you could offer me a solution! Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 15, 2017 Share Posted October 15, 2017 Hi Lary. I give my opinion. Generally, there are 2 methods: 1. Modify vertex data (somewhat difficult, but easier with simple mesh) 2. Fake it, using mesh-adding, re-scaling, re-positioning, etc. Make it LOOK-LIKE mesh is split, but actually create two narrower mesh. One of the two could be re-scaled original. The other... a new mesh. (Quite easy, but MUST be simple mesh) Simple mesh = box, rectangle, sideways tube, sideways cylinder, sideways triangle-stock (prism), stick-like things with consistent shape-profile along entire length of "run". Can you tell us more details? If your mesh is simple... perhaps possible. If mesh is complex, like inserting more tube into section of torus knot, then perhaps VERY difficult. Others are sure to comment soon. It is a lazy weekend for many. For others... they are raking. Quote Link to comment Share on other sites More sharing options...
JohnK Posted October 15, 2017 Share Posted October 15, 2017 Let A be the mesh to be split and let B be the mesh that goes in the middle when A is split. With CSG overlap B on the right hand side of A and cut away to form C. With CSG overlap B on left hand side and cut away to form D. Position and join C, B and D in that order, C to left of B and D to right of B. Because of how parts cut out CBD will fit snuggly and merged to form a new mesh. At least we can hope. Arte and Lary 2 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 15, 2017 Share Posted October 15, 2017 I did my whole game in CSG before switching most to blender/obj. One way to accomplish that is to have 2 copies of Mesh2 and position beforehand. So, position everything how you want it and then mesh2a.subtractInPlace(mesh1) and mesh2b.subtractInPlace(mesh1). Then all the CSGs do a unionInPlace(). Don't forget to .dispose() the meshes you aren't using as they will still be in the scene. I would add though that you could do this without CSG meshes by just parenting 2 copies of mesh 2 to mesh 1. Then you could have different textures as well. Quote Link to comment Share on other sites More sharing options...
Lary Posted October 16, 2017 Author Share Posted October 16, 2017 7 hours ago, Wingnut said: Hi Lary. I give my opinion. Generally, there are 2 methods: 1. Modify vertex data (somewhat difficult, but easier with simple mesh) 2. Fake it, using mesh-adding, re-scaling, re-positioning, etc. Make it LOOK-LIKE mesh is split, but actually create two narrower mesh. One of the two could be re-scaled original. The other... a new mesh. (Quite easy, but MUST be simple mesh) Simple mesh = box, rectangle, sideways tube, sideways cylinder, sideways triangle-stock (prism), stick-like things with consistent shape-profile along entire length of "run". Can you tell us more details? If your mesh is simple... perhaps possible. If mesh is complex, like inserting more tube into section of torus knot, then perhaps VERY difficult. Others are sure to comment soon. It is a lazy weekend for many. For others... they are raking. Thanks WingNut, you're always the first to give answer! My mesh is quite complex, it's a list of .babylon models. I choose a model from html selection list, than the according model will show and fit into a rect model, a bit like menu style. I hope I have made it clear enough. Anyway, I'm still in testing period for my project, I will ask for help here again in time when I get the detailed project requirement and any problem should occur. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Lary Posted October 16, 2017 Author Share Posted October 16, 2017 6 hours ago, brianzinn said: I did my whole game in CSG before switching most to blender/obj. One way to accomplish that is to have 2 copies of Mesh2 and position beforehand. So, position everything how you want it and then mesh2a.subtractInPlace(mesh1) and mesh2b.subtractInPlace(mesh1). Then all the CSGs do a unionInPlace(). Don't forget to .dispose() the meshes you aren't using as they will still be in the scene. I would add though that you could do this without CSG meshes by just parenting 2 copies of mesh 2 to mesh 1. Then you could have different textures as well. That can be a good way, thanks Brianzinn Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 16, 2017 Share Posted October 16, 2017 Hi again, guys. I still don't perfectly understand the goals, here. Just for fun, I want to remind that all mesh have bounding boxes, once created or imported-into a scene. The bounding boxes can be measured, and these measurements can be used to create/re-size other "container mesh". It is faked containment, but it still looks/works properly... to the end-user. Using these bounding box measurements, precise-sized gaps can be opened and closed between each mesh (in an array/line-up of many mesh). You can easily add/remove a mesh to/from a line-of-mesh... once you query/know the bounding box dimensions of the added/removed mesh. Let's pretend that the user has chosen some nice mesh models... to position side-by-side on a shelf. That shelf CAN be (seemingly automatically) re-scaled longer or shorter, and can determine proper shelf-width by summing all the widths of the bounding boxes of all shelf mesh. To users, it would APPEAR that the shelf is a smart, auto-scaling container/holder. But actually, it is all done with your "container scaling calculator" which gets applied to the shelf/holder after every mesh addition or removal. No CSG or other mesh-splitting is needed at all, in this case. Just up-scale or down-scale the container/shelf... based upon the measurements of the bounding boxes of the contained/held mesh models. Anyway, I just wanted to yap some more. I did a little time hiking/skiing in Alaska back-country. Although I have never cut-open a backpack and sewn-in more storage space, I have indeed done precise measuring of contained objects, and stretched some backpack materials... to make things fit. I say all this... just in case the goal is to build a shelf or box that is precisely-sized to fit chosen mesh, and allow re-scaling (re-sizing) as mesh are added/removed. If this is the goal, I'd say... make a "smart container". An "observer" watches for changes in the container.containedMesh array, and if it sees a change, it measures the added/removed mesh, and re-scales itself properly... to compensate for the change. https://www.babylonjs-playground.com/#1KH9RY#12 Somebody once wanted a topless box. I used an "indices chainsaw" to de-index the top side. heh. This would be a good container to use as a starter for "Lary's Auto-Sizing Container v1.0", right? Or not. PG#13 is active, too, with some .showBoundingBox = true... on the contained things. Ok, I'll shut up now. I'm probably off-topic, anyway. Be well. Quote Link to comment Share on other sites More sharing options...
Lary Posted October 16, 2017 Author Share Posted October 16, 2017 4 hours ago, Wingnut said: Hi again, guys. I still don't perfectly understand the goals, here. Just for fun, I want to remind that all mesh have bounding boxes, once created or imported-into a scene. The bounding boxes can be measured, and these measurements can be used to create/re-size other "container mesh". It is faked containment, but it still looks/works properly... to the end-user. Using these bounding box measurements, precise-sized gaps can be opened and closed between each mesh (in an array/line-up of many mesh). You can easily add/remove a mesh to/from a line-of-mesh... once you query/know the bounding box dimensions of the added/removed mesh. Let's pretend that the user has chosen some nice mesh models... to position side-by-side on a shelf. That shelf CAN be (seemingly automatically) re-scaled longer or shorter, and can determine proper shelf-width by summing all the widths of the bounding boxes of all shelf mesh. To users, it would APPEAR that the shelf is a smart, auto-scaling container/holder. But actually, it is all done with your "container scaling calculator" which gets applied to the shelf/holder after every mesh addition or removal. No CSG or other mesh-splitting is needed at all, in this case. Just up-scale or down-scale the container/shelf... based upon the measurements of the bounding boxes of the contained/held mesh models. Anyway, I just wanted to yap some more. I did a little time hiking/skiing in Alaska back-country. Although I have never cut-open a backpack and sewn-in more storage space, I have indeed done precise measuring of contained objects, and stretched some backpack materials... to make things fit. I say all this... just in case the goal is to build a shelf or box that is precisely-sized to fit chosen mesh, and allow re-scaling (re-sizing) as mesh are added/removed. If this is the goal, I'd say... make a "smart container". An "observer" watches for changes in the container.containedMesh array, and if it sees a change, it measures the added/removed mesh, and re-scales itself properly... to compensate for the change. https://www.babylonjs-playground.com/#1KH9RY#12 Somebody once wanted a topless box. I used an "indices chainsaw" to de-index the top side. heh. This would be a good container to use as a starter for "Lary's Auto-Sizing Container v1.0", right? Or not. PG#13 is active, too, with some .showBoundingBox = true... on the contained things. Ok, I'll shut up now. I'm probably off-topic, anyway. Be well. Hi Wingnut, I must say you're kind hearted, and words full of wisdom and humor. Your above elaboration enlighted me and gives a new way of thinking! Many thanks! I will try you guys' methods and see if I can manage my project. Wingnut 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.