devNotes 3-16-16 hex map seam

png2

    private void Build_HexQuad_List()
    {
        H_Element HE;

        int nEl = 0;

        for (var ring = 0; ring < latitudeSegments; ring++)
        {
            //H1   Even Row - 0,2,4,6,
            for (int i = 0; i < longitudeSegments; i++)
            {
                HE = new H_Element();

                HE.myIndex = nEl;

                Vector3 v0, v1, v2, v3, vCent;

                int qIdx = ring * longitudeSegments + i;

                v0 = LLQuads[qIdx].mdQuad.vertices[0];
                v1 = LLQuads[qIdx].mdQuad.vertices[1];
                v2 = LLQuads[qIdx].mdQuad.vertices[2];
                v3 = LLQuads[qIdx].mdQuad.vertices[3];

                vCent = (v0 + v1 + v2 + v3) / 4f;

                Vector3 vRight = v2 - v0;
                Vector3 vUp = v0 - v1;

                HE.mdH.vertices.Add(v0 + (1f / 6f) * vRight + (1f / 2f) * vUp);
                HE.mdH.vertices.Add(v0 + (1f / 6f) * vRight - (1f / 2f) * vUp);
                HE.mdH.vertices.Add(v2 - (1f / 6f) * vRight + (1f / 2f) * vUp);
                HE.mdH.vertices.Add(v2 - (1f / 6f) * vRight - (1f / 2f) * vUp);

                HE.mdH.normals.Add(vCent.normalized);
                HE.mdH.normals.Add(vCent.normalized);
                HE.mdH.normals.Add(vCent.normalized);
                HE.mdH.normals.Add(vCent.normalized);

                HE.mdH.uv.Add(new Vector2(0f, 1f));
                HE.mdH.uv.Add(new Vector2(0f, 0f));
                HE.mdH.uv.Add(new Vector2(1f, 1f));
                HE.mdH.uv.Add(new Vector2(1f, 0f));

                //Evens
                if (ring > 1 && ring < latitudeSegments - 2 )
                {
                    HE.neighborLoc[0] = nEl - longitudeSegments * 2;
                    HE.neighborLoc[1] = nEl - longitudeSegments;
                    HE.neighborLoc[2] = nEl + longitudeSegments;
                    HE.neighborLoc[3] = nEl + longitudeSegments * 2;

                    if (i == 0)
                    {
                        HE.neighborLoc[4] = nEl + 2 * longitudeSegments - 1;
                        HE.neighborLoc[5] = nEl - 1;
                    }
                    else
                    {
                        HE.neighborLoc[4] = nEl + longitudeSegments - 1;
                        HE.neighborLoc[5] = nEl - (longitudeSegments + 1);
                    }
                }
                else
                {
                    HE.neighborLoc[0] = 0;
                    HE.neighborLoc[1] = 0;
                    HE.neighborLoc[2] = 0;
                    HE.neighborLoc[3] = 0;
                    HE.neighborLoc[4] = 0;
                    HE.neighborLoc[5] = 0;
                }

                HE.mdH.triangles.AddRange(new[] { 0, 1, 2, 2, 1, 3 });
                HexQuads.Add(HE);

                nEl++;
            }

            //H3 Odd Row - 1,3,5,7,
            for (int i = 0; i < longitudeSegments; i++)
            {
                HE = new H_Element();

                HE.myIndex = nEl;

                Vector3 v0, v1, v2, v3, vCent;

                int qIdx = ring * longitudeSegments + i;

                v0 = LLQuads[qIdx].mdQuad.vertices[0];
                v1 = LLQuads[qIdx].mdQuad.vertices[1];
                v2 = LLQuads[qIdx].mdQuad.vertices[2];
                v3 = LLQuads[qIdx].mdQuad.vertices[3];

                vCent = (v0 + v1 + v2 + v3) / 4f;

                Vector3 vRight = v2 - v0;
                Vector3 vUp = v0 - v1;

                HE.mdH.vertices.Add(v2 - (1f / 3f) * vRight);
                HE.mdH.vertices.Add(v3 - (1f / 3f) * vRight);
                HE.mdH.vertices.Add(v2 + (1f / 3f) * vRight);
                HE.mdH.vertices.Add(v3 + (1f / 3f) * vRight);

                HE.mdH.normals.Add(vCent.normalized);
                HE.mdH.normals.Add(vCent.normalized);
                HE.mdH.normals.Add(vCent.normalized);
                HE.mdH.normals.Add(vCent.normalized);

                HE.mdH.uv.Add(new Vector2(0f, 1f));
                HE.mdH.uv.Add(new Vector2(0f, 0f));
                HE.mdH.uv.Add(new Vector2(1f, 1f));
                HE.mdH.uv.Add(new Vector2(1f, 0f));

                //Odds
                if (ring > 1 && ring < latitudeSegments - 2)
                {
                    HE.neighborLoc[0] = nEl - longitudeSegments * 2;

                    if (i == longitudeSegments - 1)
                    {
                        HE.neighborLoc[1] = nEl - 2 * longitudeSegments + 1;
                        HE.neighborLoc[2] = nEl + 1;
                    }
                    else
                    {
                        HE.neighborLoc[1] = nEl - longitudeSegments + 1;
                        HE.neighborLoc[2] = nEl + longitudeSegments + 1;
                    } 
                    HE.neighborLoc[3] = nEl + longitudeSegments * 2;
                    HE.neighborLoc[4] = nEl + longitudeSegments;
                    HE.neighborLoc[5] = nEl - longitudeSegments;
                }
                else
                {
                    HE.neighborLoc[0] = 0;
                    HE.neighborLoc[1] = 0;
                    HE.neighborLoc[2] = 0;
                    HE.neighborLoc[3] = 0;
                    HE.neighborLoc[4] = 0;
                    HE.neighborLoc[5] = 0;
                }

                HE.mdH.triangles.AddRange(new[] { 0, 1, 2, 2, 1, 3 });
                HexQuads.Add(HE);

                nEl++;
            }
        }
    }

 

seamgjhggk

dings

jojo6

spawnseam

seam

(Seam at i == 0 && i == longitudeSegmentCount-1)

seam_34

pop

 

 

UV_Test

 

hihfih8