void Awake() { InitialiserReference(); AppliquerTexture(); GenererSommets(); GenererTriangles(); GenererUV(); Maillage.RecalculateNormals(); }
void Start() { InitRef(); AppliquerTexture(); GenererSommets(); GenererTriangles(); GenererUVs(); Maillage.RecalculateNormals(); }
protected override void GénérerListeTriangles() { int[] Triangles = new int[nbTriangles * NB_SOMMETS_PAR_TRIANGLE]; // Triangles du corps int cpt = 0; for (int t = 0; t < nbTranches; ++t) { for (int f = 0; f < 4; ++f) { if (f == 0) { Triangles[cpt] = f * (nbTranches + 1) + t; Triangles[cpt + 1] = Triangles[cpt] + nbTranches + 1; Triangles[cpt + 3] = Triangles[cpt] + nbTranches + 1; Triangles[cpt + 4] = Triangles[cpt + 1] + 1; Triangles[cpt + 6] = Triangles[cpt + 1] + 1; Triangles[cpt + 7] = Triangles[cpt] + 1; Triangles[cpt + 9] = Triangles[cpt] + 1; Triangles[cpt + 10] = f * (nbTranches + 1) + t; Triangles[cpt + 2] = Triangles[cpt + 5] = Triangles[cpt + 8] = Triangles[cpt + 11] = nbSommets - NB_SOMMETS_BOUTS + (t - nbTranches); cpt += NB_SOMMETS_PAR_TRIANGLE * 4; } else { Triangles[cpt] = f * (nbTranches + 1) + t; Triangles[cpt + 1] = Triangles[cpt + 4] = Triangles[cpt] + nbTranches + 1; Triangles[cpt + 2] = Triangles[cpt + 3] = Triangles[cpt] + 1; Triangles[cpt + 5] = Triangles[cpt + 1] + 1; cpt += NB_SOMMETS_PAR_TRIANGLE * NB_TRIANGLES_PAR_TUILE; } } } // Triangles des deux bouts int p = Triangles.Length - NB_SOMMETS_PAR_TRIANGLE * 4; Triangles[p] = nbSommets - 8; Triangles[p + 2] = Triangles[p + 3] = nbSommets - 7; Triangles[p + 1] = Triangles[p + 4] = nbSommets - 6; Triangles[p + 5] = nbSommets - 5; Triangles[p + 6] = nbSommets - 4; Triangles[p + 7] = Triangles[p + 9] = nbSommets - 3; Triangles[p + 8] = Triangles[p + 11] = nbSommets - 2; Triangles[p + 10] = nbSommets - 1; Maillage.triangles = Triangles; Maillage.RecalculateNormals(); }