HPW Posted September 9, 2016 Share Posted September 9, 2016 Hello, I am new to babylon.js and have a question about possible use of the obj loader in babylon: A obj file has groups which does sort the 3D faces into objects. Many obj viewer does show the resulting object-tree. Is this structure preserved after loading into babylon? Is it possible to build a web-viewer for such scene where I can pick a group/object and get back the groupname-string? Is it possible to highlight oder mark the selected object? I have not found a limit in the obj specs about the groupnames possible max string-length. Any limit in babylon? Regards Hans-Peter Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 9, 2016 Share Posted September 9, 2016 Hello @HPW, welcome to the forum! Let's look at this popular obj-loading playground demo. http://www.babylonjs-playground.com/#28YUR5#111 "Bane" is the big creature in the middle, I guess. (Wingnut not a Batman fan.) Here is link to obj file used... https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane_3.obj See any group names in there? I don't know if there are any in there. Maybe not. Using browser f12 tools, I viewed the Bane object in object inspector. It has a .loadedMeshes property with 8 objects. Each object has an .id that might be the subMesh (group) name. I printed them to JS console. Also, each of those have .isPickable set true (see console, also). They are ready for clicking, after scene pick-code is written. These 8 objects are groups, correct? If not, would you please create playground... loading .obj file that has group names? Thx. Perhaps this talk/test... answers your questions? I hope so. Yes, you can highlight or mark these objects... using showBoundingBox, or edgesRenderer, or outLineRenderer, or umm... @NasimiAsl created another "outliner" using shaders, I think. Many ways to mark/highlight. Study and experiment... perhaps you will be successful. If there is problems, come here and tell problem. We help. Thanks! Again, welcome! Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted September 10, 2016 Share Posted September 10, 2016 hi i just make that for how can select group of mesh use with one mesh hover on the GPU and no information for cpu side or javascript we just show that in render output http://www.babylonjs-playground.com/#1TYWYB#142 http://www.babylonjs-playground.com/#1TYWYB#143 you can keep your standard material and just need make helper material i recommend use this function function helper(mesh,groupKey, scene) { mesh.helperMaterial = new BABYLONX.ShaderBuilder() .Solid() // black material .SetUniform('Group','float') // define group uniform .InLine('if(Group=='+groupKey+'.0 ){') // condition of shader for change color .IdColor(13000200, 1.) // costom Color Id : 13000200 just some id to changed to unsigned integer and postprocess can detect that .InLine('}') // end of block .BuildMaterial(scene); mesh.actionManager = new BABYLON.ActionManager(scene); mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger, function(ev){ // when hover this mesh change selectiongroup selectedGroup = groupKey; })); mesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger, function(ev){ // unselect when changed material is not used selectedGroup = 0; })); mesh._savedMaterial = mesh.material; // keep current material in that for optimized rendertarget } Wingnut 1 Quote Link to comment Share on other sites More sharing options...
HPW Posted September 10, 2016 Author Share Posted September 10, 2016 Hello, Thanks for the quick replys and the welcome. Following your hint I first get the complete asset: https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane_3.obj https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane_3.mtl https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane3_Chest_D.tga https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane3_Stuff_D.tga https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane3_Eye_D.tga https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane3_Head_D.tga https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane3_Mouth_D.tga https://dl.dropboxusercontent.com/u/17799537/objFileLoader/Bane/Bane3_Pants_D.tga Looking into the obj and mtl files with an Editor, I find the 8 object definitions. o Bane3Mouth o Bane3Head o Bane3Coverlid o Bane3Pipes o Bane3Pants o Bane3Chest o Bane3Stuff o Bane3Eyes So the loader supports the o-Definition. Good to know. So now I have to find out if the g-Definition is also supported. Question: Do you think that there is a Limit in the length of the object-name-string. Can it become longer? So I have to start to get deeper into the babylonjs-stuff and ist Debugging technics. Question to the mouser_over Events: Has this Event the object-name and can update other Areas of the Html-page with some text-info about the object? Thanks again! Regards Hans-Peter 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.