Changeset 1278
 Timestamp:
 Apr 23, 2012, 2:20:16 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/mesh.h
r1277 r1278 501 501 502 502 mat3 rotmat = mat3::rotate(360.0f / nsides, 0.f, 1.f, 0.f); 503 vec3 p1(r1, h, 0.f); 504 vec3 p2(r2, h, 0.f); 505 503 vec3 p1(r1, h, 0.f), p2(r2, h, 0.f), n; 504 505 /* Construct normal */ 506 n = p2; 507 n.y = r1 * (r1  r2) / (2.f * h); 508 if (!smooth) 509 n = mat3::rotate(180.0f / nsides, 0.f, 1.f, 0.f) * n; 510 n = normalize(n); 511 512 /* FIXME: normals should be flipped in twosided mode, but that 513 * means duplicating the vertices again... */ 506 514 for (int i = 0; i < nsides; i++) 507 515 { 508 516 AppendQuadVert(p1); 517 SetCurVertNormal(n); 509 518 AppendQuadVert(p2); 519 SetCurVertNormal(n); 510 520 SetCurVertColor(m_color2); 511 521 … … 516 526 if (dualside) 517 527 AppendQuad(i * 2, i * 2 + 1, j * 2 + 1, j * 2, vbase); 518 519 /* TODO: compute normals */520 528 } 521 529 … … 526 534 { 527 535 AppendQuadVert(p1); 536 SetCurVertNormal(n); 528 537 AppendQuadVert(p2); 538 SetCurVertNormal(n); 529 539 SetCurVertColor(m_color2); 530 540 … … 533 543 AppendQuad(i * 4, i * 4 + 1, i * 4 + 3, i * 4 + 2, vbase); 534 544 } 535 } 536 537 if (!smooth) 538 ComputeQuadNormals(ibase, m_quadidx.Count()  ibase); 545 546 n = rotmat * n; 547 } 539 548 } 540 549
Note: See TracChangeset
for help on using the changeset viewer.