{"id":702,"date":"2012-02-25T15:40:05","date_gmt":"2012-02-25T12:40:05","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=702"},"modified":"2013-08-15T22:20:37","modified_gmt":"2013-08-15T19:20:37","slug":"mesh-box-reference-vertices-triangles-uv-normals","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/02\/25\/mesh-box-reference-vertices-triangles-uv-normals\/","title":{"rendered":"Mesh Box Reference : Vertices \/ Triangles \/ UV \/ Normals"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"703\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/25\/mesh-box-reference-vertices-triangles-uv-normals\/mboxchunkvertexmeshcube1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mBoxChunkVertexMeshCube1.jpg?fit=680%2C383&amp;ssl=1\" data-orig-size=\"680,383\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"mBoxChunkVertexMeshCube1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mBoxChunkVertexMeshCube1.jpg?fit=680%2C383&amp;ssl=1\" class=\"alignnone size-full wp-image-703\" title=\"mBoxChunkVertexMeshCube1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mBoxChunkVertexMeshCube1.jpg?resize=680%2C383\" width=\"680\" height=\"383\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mBoxChunkVertexMeshCube1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mBoxChunkVertexMeshCube1.jpg?resize=300%2C168&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p><strong>Mesh Box Reference Image<\/strong><\/p>\n<p>If you want to build a simple mesh box with scripts in Unity, this kind of image helped me to understand how it works..<\/p>\n<p>Also have a look of the ChunkRender example,<br \/>\nhow it builds the mesh by adding 4 vertices on each box face: <a title=\"http:\/\/unitycoder.com\/blog\/2012\/02\/15\/dummy-craft-chunk-renderer-js\/\" href=\"http:\/\/unitycoder.com\/blog\/2012\/02\/15\/dummy-craft-chunk-renderer-js\/\" target=\"_blank\">ChunkRenderer<\/a><\/p>\n<p><strong>Main image ^<\/strong><br \/>\n&#8211; Vertice locations \/ coordinates are shown: Vector3(<strong><span style=\"color: #ff0000;\">x<\/span><\/strong>,<strong><span style=\"color: #00ff00;\">y<\/span><\/strong>,<strong><span style=\"color: #0000ff;\">z<\/span><\/strong>)<\/p>\n<p>&#8212;<\/p>\n<h3>Part#2 :\u00a0Lets build a simple mesh<\/h3>\n<p>What are we doing:<br \/>\n&#8211; Initialize vertex points array (it is a list of points in 3D space)<br \/>\n&#8211; Initialize triangle index array (this list tells Unity how to connect the points, to build a polygon face = triangle)<br \/>\n&#8211; Add 1st point to the vertex array (0,0,0)<br \/>\n&#8211; Add 2nd point to the vertex array (0,1,0)<br \/>\n&#8211; Add 3rd point to the vertex array (1,1,0)<br \/>\n&#8211; Now we have 3 points in 3D space..(but we cannot see anything, since we just have points..)<br \/>\n&#8211; Assign triangle list [0,1,2] (&#8220;connect the points&#8221;, we start from (0,0,0), then go to (0,1,0), then (1,1,0))<br \/>\n&#8211; Last step: Assign the points and triangle list to our Unity mesh (and then we have a visible mesh)<\/p>\n<p><strong>Download Source #1<\/strong>: (creating single triangle mesh with javascript)<br \/>\n<a title=\"Download\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=202&amp;uid=un1t3c0d5r\" target=\"_blank\">MeshTutorial1.unityPackage<\/a><\/p>\n<p><strong>Image#2:<\/strong><br \/>\n&#8211; In the image we have 3 points (vertices), marked with white &#8220;x&#8221;<br \/>\n&#8211; Dotted lines are showing how we connect the points (clockwise), to build a polygon <strong><span style=\"color: #ff00ff;\">face<\/span> <\/strong>(<strong><span style=\"color: #ff00ff;\">triangle<\/span>)<\/strong><br \/>\n&#8211; See also: <a title=\"http:\/\/en.wikipedia.org\/wiki\/Polygon_mesh#Elements_of_mesh_modeling\" href=\"http:\/\/en.wikipedia.org\/wiki\/Polygon_mesh#Elements_of_mesh_modeling\" target=\"_blank\">http:\/\/en.wikipedia.org\/wiki\/Polygon_mesh#Elements_of_mesh_modeling<\/a><\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"715\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/25\/mesh-box-reference-vertices-triangles-uv-normals\/mesh_triangle_face1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_triangle_face1.jpg?fit=680%2C488&amp;ssl=1\" data-orig-size=\"680,488\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"mesh_triangle_face1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_triangle_face1.jpg?fit=680%2C488&amp;ssl=1\" class=\"alignnone size-full wp-image-715\" title=\"mesh_triangle_face1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_triangle_face1.jpg?resize=680%2C488\" width=\"680\" height=\"488\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_triangle_face1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_triangle_face1.jpg?resize=300%2C215&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p><strong>Image#3<\/strong><\/p>\n<p>Our mesh box is actually build from bunch of triangles:<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"716\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/02\/25\/mesh-box-reference-vertices-triangles-uv-normals\/mesh_faces1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_faces1.jpg?fit=680%2C383&amp;ssl=1\" data-orig-size=\"680,383\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"mesh_faces1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_faces1.jpg?fit=680%2C383&amp;ssl=1\" class=\"alignnone size-full wp-image-716\" title=\"mesh_faces1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_faces1.jpg?resize=680%2C383\" width=\"680\" height=\"383\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_faces1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mesh_faces1.jpg?resize=300%2C168&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mesh Box Reference Image If you want to build a simple mesh box with scripts in Unity, this kind of image helped me to understand how it works.. Also have a look of the ChunkRender example, how it builds the mesh by adding 4 vertices [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":703,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[62,187,188,115,194,100,5,189,101,145,33,102],"class_list":["post-702","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-3d","tag-box","tag-build","tag-cube","tag-edges","tag-indices","tag-mesh","tag-script","tag-triangles","tag-uv","tag-vertex","tag-vertices"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/02\/mBoxChunkVertexMeshCube1.jpg?fit=680%2C383&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-bk","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=702"}],"version-history":[{"count":13,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/702\/revisions"}],"predecessor-version":[{"id":2318,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/702\/revisions\/2318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/703"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}