Jump to content

Mesh, polygons and textures


Adrian
 Share

Recommended Posts

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

Link to comment
Share on other sites

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, 

Link to comment
Share on other sites

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;
Link to comment
Share on other sites

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);
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...