Recommended Posts

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]
	}]
}

 

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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 ! :)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :

test-blender.JPG

bab_testifc_blender.babylon

Share this post


Link to post
Share on other sites

@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 :

 

instances_bug_2.JPG

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.