hackSolo Posted June 27, 2016 Share Posted June 27, 2016 Hi, I have trouble using mesh instances while parsing a .babylon file. I'm using Newtonsoft to parse a .babylon file in c# and since i'm trying to improve the parsing and save memory space and time by using mesh instances instead of having vetex data copies inside meshes the model keeps loading fine in sandbox but doesn't show the instances geometries on the screen... (they all are enable and visible) I have the exact same problem when i try to use geometry ids which are the same for meshes with similar vertex data but different placement. (what should be an instance...) I can give samples files if you want to help me on that. I also made log files to compare matrices transformations in different cases which appears that it should be working But my parser is used in a very particular case so it wont any usefull to share it.. My best guess was that instances worked like parent | child so the child transformation depends on it's parent transformation. but i've seen files working where the child transformation was based on the world transformation and no link at all with the containing mesh. I was then wondering if there was a limit on the number of instances then i saw that there was not on the documentation. I'm stuck here and hope that somebody could help me on that ! preview : { "materials": [{ "name": "124848", "id": "124848", "ambient": [0.0, 0.0, 0.0], "diffuse": [0.423529416, 0.266666681, 0.0431372561], "specular": [0.0, 0.0, 0.0], "emissive": [0.0, 0.0, 0.0], "specularPower": 0.0, "alpha": 1.0, "backFaceCulling": false, "checkReadyOnlyOnce": true }], "meshes": [{ "name": "9d3d5698", "id": "d6880dd6-4a83-4891-8746-61ca867be8d7", "skeletonId": "-1", "materialId": "124848", "billboardMode": 0, "autoAnimateFrom": 0, "autoAnimateTo": 100, "isVisible": true, "isEnabled": true, "pickable": false, "freezeWorldMatrix": false, "checkCollisions": false, "receiveShadows": true, "autoAnimateLoop": true, "showBoundingBox": false, "showSubMeshesBoundingBox": false, "infiniteDistance": false, "autoAnimate": true, "visibility": 1.0, "subMeshes": [{ "materialIndex": 0, "verticesStart": 0, "verticesCount": 72, "indexStart": 0, "indexCount": 36 }], "instances": [{ "id": "cfe2ea30-9cda-4185-9bbf-5e3c5780f8e1", "materialId": "124848", "name": "fd255bd6", "position": [14.1874352, 23.2159557, -33.19057], "rotation": [0.0, 0.0, 0.0], "rotationQuaternion": [0.0, 1.0, 0.0, 0.0], "scaling": [0.01, 0.01, 0.01], "freezeWorldMatrix": true, "animations": [] }], "position": [15.387435, 23.2159557, -33.19057], "rotation": [0.0, 0.0, 0.0], "rotationQuaternion": [0.0, 1.0, 0.0, 0.0], "scaling": [0.01, 0.01, 0.01], "pivotMatrix": [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0], "positions": [... (72)], "normals": [... (72)], "indices": [... (36)], "animations": [empty] }] } Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 27, 2016 Share Posted June 27, 2016 Hello, not sure to understand: you use Babylon.js file format and render it in a different engine in C#? is it correct? Quote Link to comment Share on other sites More sharing options...
hackSolo Posted June 28, 2016 Author Share Posted June 28, 2016 Hello, Sorry for the misunderstanding :/ I'm parsing a Babylon.js file in c# from data coming from other types of 3d files. Then render the data with Babylon's engine. There comes the difficulties to understand how mesh.instances[] and geometries.vertexdata[] are handled by the Babylon engine. When I use duplicated meshes instead of geometry.id or mesh.instances[] I have absolutely no problem. But if I try to use them the duplicated meshes's geometries won't render. Thanks for reply Quote Link to comment Share on other sites More sharing options...
hackSolo Posted June 28, 2016 Author Share Posted June 28, 2016 I've seen this coming code in babylon.babylonFileLoader : SceneLoader.RegisterPlugin({ extensions: ".babylon", importMesh: (meshesValuesComparisons: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]): boolean => { //[...] // import instances only if no meshes names are provided var mesh = Mesh.Parse(parsedMesh, scene, rootUrl, parsedData.geometries, meshesValuesComparisonsProvided); meshes.push(mesh); //[...] } does that means that only meshes with no name attribute can load instances? If so that would be the answer of one of my question ! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 28, 2016 Share Posted June 28, 2016 Ok I understand. Do you use this assembly to generate the .babylon file? https://github.com/BabylonJS/Babylon.js/tree/master/Exporters/3ds%20Max/BabylonExport.Entities It will help you understand how it works Quote Link to comment Share on other sites More sharing options...
hackSolo Posted June 28, 2016 Author Share Posted June 28, 2016 I use one i've made myself i could share it tomorrow for now. It's very similar to that one except that meah and Instance are super class for me not childs of abstract mesh. I have to give it à try! Also can instances have different parents? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 28, 2016 Share Posted June 28, 2016 Yep:) Quote Link to comment Share on other sites More sharing options...
hackSolo Posted June 28, 2016 Author Share Posted June 28, 2016 OK so if you would like to I have to show you a file i've been using for testing which was made with blender crossing instances and parent/child dependency. The child instances's transformations don't base on the parent's transformation but on the scene when I load it on sandbox. But if I hard code it (no Babylon file at all) to the playground it works perfectly. I feel like the fileLoader don't read the parentId or something Quote Link to comment Share on other sites More sharing options...
hackSolo Posted June 29, 2016 Author Share Posted June 29, 2016 this is the file i was talking about very simple but the 3 cubes should be on the plane's diagonal.. bab_test.babylon Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 29, 2016 Share Posted June 29, 2016 This is where the instances are loaded: https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.ts#L1896 parentID is not loaded and need to be setup after loading time. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 29, 2016 Share Posted June 29, 2016 This is what I have so far. Quote Link to comment Share on other sites More sharing options...
Adem Posted June 29, 2016 Share Posted June 29, 2016 Please can someone help me with how to merge geometric meshes with the same texture Quote Link to comment Share on other sites More sharing options...
hackSolo Posted June 30, 2016 Author Share Posted June 30, 2016 Hi Deltakosh, That's what I have also and i was expecting the 3 cubes on the left to be on the plane's diagonal. So if I understood. SandBox is a simple loader and if I want the parent/child dependency I have to specify the paretnIds with AbstractMesh._waitingParentId in the SceneLoader.load(...)? same file exported with blender gives : bab_testifc_blender.babylon Quote Link to comment Share on other sites More sharing options...
hackSolo Posted June 30, 2016 Author Share Posted June 30, 2016 @Deltakosh I've tried inserting parentID during the loading since my childs's positioning are already calculated against the parent's position. It takes the right _waitingParentId but the _renderParentId equals -1 and the scene loads exactly the same way... see below : 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.