Topper Posted March 23, 2018 Share Posted March 23, 2018 Hi Babylonians, I´m coming up with with a new question. What is (for the described purpose) the most elegant way of loading meshes into an existing scene? My application will use something like a ressource (product) configurator for forklifts, pallet trucks, etc. To display a vehicle i want to use a BJS scene. The user will be able to scroll through the vehicles (data grid) and the scene has to change, accordingly. Since the vehicle models are very complex I will buy them online at turbosquid and other places. I don´t need complex textures but I want to keep (and change) colors. There will be like 3 to 7 different colors per model. We use Blender, but we still don´t kno which way to go: 1) obj and mtl 2) loading meshes from .babylon 3) gltf 4) stl 5) AsstesManager When I merge the everything to one single mesh in Blender, I can´t work with different materials (colors), right? Should I create single meshes in Blender that will share the same material in BJS? Using multi materials and submeshes i need to know the vertices number ranges. How do i get this done with complex models like forklift? Here´s an example of what our models look like: What is the most elegant way to get this accomplished? BR, Topper Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 23, 2018 Share Posted March 23, 2018 I can only speak for .babylon, but merging meshes will result in a BABYLON.MultiMaterial for the mesh. This is really an aggregate of StandardMaterials. You can still get an individual using mat. subMaterials & make changes. Probably need to iterate through each sub material & match name to get the value for 'i' though. Since a .babylon is very closely integrated, this might not be available for all the formats, but I do not know. Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 23, 2018 Share Posted March 23, 2018 If you're in standard workflow, .babylon file is probably the best option. As JCPalmer said, you can easily point a material then. Example: on Blender, these materials are applied on your object myObject once append in your BJS scene, you can acceed to Material.001 like this: var myObject = scene.getMeshByName("myObject"); var myMaterial = myObject.material.subMaterial[1]; myMaterial.ambientColor = new BABYLON.Color3.Magenta(); If you're in PBR workflow the GLTF exporter will split one object into one mesh per subMaterial. Here a playground example (sources) with some material parsing (line 79 to 88). Dad72 and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Topper Posted March 23, 2018 Author Share Posted March 23, 2018 Thanks so far. i think i will go the .babylon way. So if i don't wanna use multi materials and this pbr thing, what are the prelimineries in Blender? 1) one mesh per different material (wheels, chassis, cabin, etc.) 2) parenting in Blender or in BJS? do you use the words object and mesh interchangeably? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 24, 2018 Share Posted March 24, 2018 In case of your model, I wil try to detach only potentially animatable parts if needed. If not, one object is fine (so with multimaterials on it obviously). But if you want, for example, yellow color at the bottom part of the model, but red color at the body, In Blender you need to assign each parts to its own material. In fact you can also split your model into multiple meshes if you think it's easier, it's not a big deal. It's on you, depending of which type of interactions you want to code. Quote Link to comment Share on other sites More sharing options...
Topper Posted March 28, 2018 Author Share Posted March 28, 2018 thanks V!nc3r, that did the trick. Works as expected and needed. This one can be closed. BR, Markus Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 28, 2018 Share Posted March 28, 2018 Just an observation: when using the .babylon exporter, don't forget to assign Edge split modifiers on your objects to preserve smooth and sharp shadings. Quote Link to comment Share on other sites More sharing options...
Topper Posted March 28, 2018 Author Share Posted March 28, 2018 I know. Thank´s for the tip. Already implemented. 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.