Adrian Posted September 15, 2014 Share Posted September 15, 2014 Hi, I would like to create a mesh, if i understand well, a mesh is group of polygon - triangle - which result in a 3D object. So, i want to make a plane composed of two independent triangle BUT with a common texture, i want to be able to apply my texture to the mesh and keep the possibility to change the position of each triangle independently. I am a bit confused about that, i looked inside the documentation but to be honest it's not clear for a profane ! Thanks for your time Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 15, 2014 Share Posted September 15, 2014 Hello Adrian, You understand well: a mesh is a group of triangles. Each triangle is composed of vertices, and each vertex has several important information, like color or normal. With your problem, I would try to create a simple plane, with 1 subdivision, and add it a wireframe material (you can find all this in the babylon wiki here).Then, i would read this *awesome* tutorial ;) : http://pixelcodr.com/tutos/trees/trees.html With this, you will be able to move each vertex of your plane, with a whole texture. Cheers, Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 15, 2014 Author Share Posted September 15, 2014 Thanks Temechon. It works, i can see two triangle but there is no texture, if i set wireframe to false i can see the texture. I read the tutorial on pixelcodr, but for now it's far from my skills... I keep looking on how move each vertex i suppose i have to loop through the mesh's vertex.var cell = BABYLON.Mesh.CreateGround("cell", 10, 10, 1, scene);var material = new BABYLON.StandardMaterial("material", scene);material.diffuseTexture = new BABYLON.Texture("/grass.png", scene);material.diffuseTexture.uScale = 1;material.diffuseTexture.vScale = 1;material.wireframe = true;cell.material = material; Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 15, 2014 Share Posted September 15, 2014 I keep looking on how move each vertex i suppose i have to loop through the mesh's vertex. Exactly ! And I told you about the wireframe only to show you that you already had two triangles Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 15, 2014 Author Share Posted September 15, 2014 Ha ! ok i understand, natively a ground is composed of 2 triangles ! I know i can get the total number of vertex using : cell.getTotalVertices()It return 4 vertices. Quote Link to comment Share on other sites More sharing options...
Temechon Posted September 15, 2014 Share Posted September 15, 2014 Try this : var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind);var numberOfPoints = positions.length/3;Try to update positions[0] and positions[1], and check what it does Quote Link to comment Share on other sites More sharing options...
Adrian Posted September 15, 2014 Author Share Posted September 15, 2014 With a lot of your help, Temechon, i have been able to achieve my needs ! Merci !var cell = BABYLON.Mesh.CreateGround("cell", 10, 10, 1, scene);var material = new BABYLON.StandardMaterial("material", scene);material.diffuseTexture = new BABYLON.Texture("/grass.png", scene);material.diffuseTexture.uScale = 1;material.diffuseTexture.vScale = 1;//material.wireframe = true;cell.material = material; var positions = cell.getVerticesData(BABYLON.VertexBuffer.PositionKind);var numberOfPoints = positions.length/3;positions[1] = 5;cell.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions, false); Temechon 1 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.