void VertexArray::Add( const unsigned char newcol[], int newcolcount, const float newnorm[], int newnormcount, const float newvert[], int newvertcount, const int newfaces[], int newfacecount, const float newtc[], int newtccount) { assert(texcoords.size() == 1); SetFaces(newfaces, newfacecount, faces.size(), vertices.size() / 3); SetVertices(newvert, newvertcount, vertices.size()); SetNormals(newnorm, newnormcount, normals.size()); SetColors(newcol, newcolcount, colors.size()); SetTexCoords(0, newtc, newtccount, texcoords[0].size()); }
void plInterMeshSmooth::SmoothNormals(hsTArray<plSpanHandle>& sets) { hsTArray<uint16_t>* shareVtx = new hsTArray<uint16_t>[sets.GetCount()]; hsTArray<uint16_t>* edgeVerts = new hsTArray<uint16_t>[sets.GetCount()]; FindEdges(sets, edgeVerts); int i; for( i = 0; i < sets.GetCount()-1; i++ ) { int j; for( j = edgeVerts[i].GetCount()-1; j >= 0; --j ) { hsPoint3 pos = GetPosition(sets[i], edgeVerts[i][j]); hsVector3 normAccum = GetNormal(sets[i], edgeVerts[i][j]);; shareVtx[i].Append(edgeVerts[i][j]); int k; for( k = i+1; k < sets.GetCount(); k++ ) { FindSharedVerts(pos, sets[k], edgeVerts[k], shareVtx[k], normAccum); } normAccum.Normalize(); GetNormal(sets[i], edgeVerts[i][j]) = normAccum; for( k = i+1; k < sets.GetCount(); k++ ) { SetNormals(sets[k], shareVtx[k], normAccum); } // Now remove all the shared verts (which we just processed) // from edgeVerts so we don't process them again. for( k = i; k < sets.GetCount(); k++ ) { int m; for( m = 0; m < shareVtx[k].GetCount(); m++ ) { int idx = edgeVerts[k].Find(shareVtx[k][m]); hsAssert(idx != edgeVerts[k].kMissingIndex, "Lost vertex between find and remove"); edgeVerts[k].Remove(idx); } shareVtx[k].SetCount(0); } } } delete [] shareVtx; delete [] edgeVerts; }
void VertexArray::SetToBillboard(float x1, float y1, float x2, float y2) { int bfaces[6]; bfaces[0] = 0; bfaces[1] = 1; bfaces[2] = 2; bfaces[3] = 0; bfaces[4] = 2; bfaces[5] = 3; SetFaces(bfaces, 6); float normals[12]; for (int i = 0; i < 12; i+=3) { normals[i] = 0; normals[i+1] = 0; normals[i+2] = 1; } SetNormals(normals, 12); //build this: //x1, y1, 0 //x2, y1, 0 //x2, y2, 0 //x1, y2, 0 float verts[12]; verts[2] = verts[5] = verts[8] = verts[11] = 0.0; verts[0] = verts[9] = x1; verts[3] = verts[6] = x2; verts[1] = verts[4] = y1; verts[7] = verts[10] = y2; SetVertices(verts, 12); float tc[8]; tc[0] = tc[1] = tc[3] = tc[6] = 0.0; tc[2] = tc[4] = tc[5] = tc[7] = 1.0; SetTexCoordSets(1); SetTexCoords(0, tc, 8); }