Xav Posted November 21, 2017 Share Posted November 21, 2017 Hi !, I'm looking at how vertices work so that I can work with and transform my mesh later. For that I started with a simple box to find the order and give a number on the vertices group. Can someone explain to me why numbers 3 and 7 are in the same place? https://playground.babylonjs.com/#3CZLNK Thank you ! Quote Link to comment Share on other sites More sharing options...
jerome Posted November 21, 2017 Share Posted November 21, 2017 a cube has 6 sides each side is composed with 2 triangular facets, so 4 vertices. Side vertices aren't shared with other sides so they can hold different UVs and normals per side. I total : 4 * 6 = 24 vertices... some are in the same location. Quote Link to comment Share on other sites More sharing options...
Xav Posted November 21, 2017 Author Share Posted November 21, 2017 thank you Jerome I'm ok with you all 24 vertices match with nbrVertices = cube.getTotalVertices (); I follow you well on the 6 face with 4 vertices per face. There are then 6 vertices of each face that have the same coordinates. What I would like to do is group them ... like this Quote Link to comment Share on other sites More sharing options...
jerome Posted November 21, 2017 Share Posted November 21, 2017 What do you mean by "to group them" ? To replace 3 vertices on the same location by only one ? Quote Link to comment Share on other sites More sharing options...
Xav Posted November 21, 2017 Author Share Posted November 21, 2017 Create an array with vertices that are the same coordinated in the same index for example myCubeVertices = [[all vertices with same coordinates xyz], [all vertices with same coordinates xyz], ...] ? Does this seem to me easier to visualize and manipulate? Quote Link to comment Share on other sites More sharing options...
Arte Posted November 21, 2017 Share Posted November 21, 2017 27 minutes ago, Xav said: Create an array with vertices that are the same coordinated in the same index for example myCubeVertices = [[all vertices with same coordinates xyz], [all vertices with same coordinates xyz], ...] ? Does this seem to me easier to visualize and manipulate? Hi @Xav Group Vertices https://playground.babylonjs.com/#3CZLNK#1 Quote Link to comment Share on other sites More sharing options...
Xav Posted November 21, 2017 Author Share Posted November 21, 2017 Hi Arte Cool I think I must not be good in my code because group returns only 7 differents positions while we should have 8 ? https://playground.babylonjs.com/#3CZLNK#2 Quote Link to comment Share on other sites More sharing options...
Xav Posted November 21, 2017 Author Share Posted November 21, 2017 Ok it's good https://playground.babylonjs.com/#3CZLNK#3 I changed my loop for (var i=0 ; i < nbrVertices ; i+=3){ with: for (var i=0 ; i < nbrVertices ; i++){ Arte 1 Quote Link to comment Share on other sites More sharing options...
Xav Posted November 21, 2017 Author Share Posted November 21, 2017 Thanks You ! It's cood: https://playground.babylonjs.com/#3CZLNK#5 Quote Link to comment Share on other sites More sharing options...
Arte Posted November 21, 2017 Share Posted November 21, 2017 Quote Link to comment Share on other sites More sharing options...
Xav Posted November 21, 2017 Author Share Posted November 21, 2017 I continued my research and I also found this post which helps to understand the function: On the other side I haven't found information to adapt the uv according to the new position of vertices? var uvs = mesh.getVerticesData(BABYLON.VertexBuffer.UVKind); mesh.setVerticesData(BABYLON.VertexBuffer.UVKind, uvs); What is the relationship between a vertex position vector3 and a UV position vector2 ? Thanks Quote Link to comment Share on other sites More sharing options...
jerome Posted November 21, 2017 Share Posted November 21, 2017 some readings : http://doc.babylonjs.com/resources/facets http://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors 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.