Jump to content

Babylon file format and mesh name


Tyrahell
 Share

Recommended Posts

Hi everyone,

 

Thanks to you i managed to load my geometry created a third app :

 

http://www.strains.fr/import_bridge.html

 

At the moment, im dealing with the picking (left shift + left click in the sample above) and get some trouble because my bridge is only composed of a unique mesh named 'Cube' :

{"autoClear":true,"clearColor":[0.41,0.41,0.41],"ambientColor":[0.0,0.0,0.0],"gravity":[0.0000,-9.8100,0.0000],"cameras":[{"name":"Camera","id":"Camera","position":[7.4811,5.3437,-6.5076],"rotation":[0.4615,-0.8149,0.0108],"fov":0.8576,"minZ":0.1000,"maxZ":100.0000,"speed":1.0000,"inertia":0.9000,"checkCollisions":false,"applyGravity":false,"ellipsoid":[0.2000,0.9000,0.2000]}],"activeCamera":"Camera","lights":[{"name":"Lamp","id":"Lamp","type":0.0000,"position":[4.0762,5.9039,1.0055],"intensity":1.0000,"diffuse":[1.0000,1.0000,1.0000],"specular":[1.0000,1.0000,1.0000]}],"materials":[{"name":"1cube.Material","id":"1cube.Material","ambient":[0.8000,0.8000,0.8000],"diffuse":[0.6400,0.6400,0.6400],"specular":[0.5000,0.5000,0.5000],"specularPower":50.0000,"emissive":[0.0000,0.0000,0.0000],"alpha":1.0000,"backFaceCulling":false}],"meshes":[{"name":"Cube","id":"Cube","materialId":"1cube.Material","position":[0.0000,0.0000,0.0000],"rotation":[-0.0000,-0.0000,0.0000],"scaling":[1.0000,1.0000,1.0000],"isVisible":true,"isEnabled":true,"useFlatShading":false,"checkCollisions":false,"billboardMode":0,"receiveShadows":false,"positions":[0.000000,-1.050034,-0.525000,1.000000,-1.050034,-0.525000,1.000000,-1.050034,-0.505189,0.000000,-1.050034,-0.505189,

You can check the totally of my bridge.babylon hand made file there : www.strains.fr/bridge.babylon

 

If you got any idea on how to add multiple "name" to each mesh of my scene, let me know ^_^

 

Regards,

 

Tyrahell

Link to comment
Share on other sites

The only way is by number I guess :(

 

Hi DK, my picking look like this :

                // Picking		window.addEventListener("click", function (evt) 		{				if (evt.shiftKey)			{				// We try to pick an object, type of BABYLON.Mesh				var pickResult = myScene.pick(evt.clientX, evt.clientY);				if( pickResult.hit )				{					var result = pickResult.pickedMesh.id;					alert(result);				}			}		});

My result when i shift+click on a polygon is to get a Babylon.Mesh structure, but im not interessed by the whole structure, only by the clicked polygon.

If i cant get a name or id by polygon, how can i interact with a polygon to transform it ?

 

Regards,

 

Tyrahell

Link to comment
Share on other sites

You can do something like this (This is what I did to get uv of the picked point):

var indices = this.pickedMesh.getIndices();            var uvs = this.pickedMesh.getVerticesData(BABYLON.VertexBuffer.UVKind);            var uv0 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);            var uv1 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);            var uv2 = BABYLON.Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);            uv0 = uv0.scale(this.bu);            uv1 = uv1.scale(this.bv);            uv2 = uv2.scale(1.0 - this.bu - this.bv);            return new BABYLON.Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
Link to comment
Share on other sites

Thanks a lot, now i have directly access to my scene properties through picking and using a .babylon file.

Here is the code sample to flip my scene in real time :

// Picking		window.addEventListener("click", function (evt) 		{				if (evt.shiftKey)			{				// We try to pick an object, type of BABYLON.Mesh				var pickResult = myScene.pick(evt.clientX, evt.clientY);				if( pickResult.hit )				{						var indices = pickResult.pickedMesh.getIndices();						var VerticesPosition = pickResult.pickedMesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);					var nbPosition = VerticesPosition.length / 3;										var arrayPosition = [];										for ( i = 0; i < nbPosition; i++ ) 					{						var myX = VerticesPosition[ i*3 + 0 ];						var myY = VerticesPosition[ i*3 + 1 ] * -1;						var myZ = VerticesPosition[ i*3 + 2 ];												arrayPosition.push( myX );						arrayPosition.push( myY );						arrayPosition.push( myZ );					}										pickResult.pickedMesh.setVerticesData( BABYLON.VertexBuffer.PositionKind, arrayPosition, false);				}			}		});

Problem solved once more thanks to you DK, see you all in september !

 

++Tyra :)

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...