Changeset 1262
 Timestamp:
 Apr 21, 2012, 8:23:52 PM (9 years ago)
 Location:
 trunk/orbital
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/orbital/mesh.h
r1260 r1262 36 36 "varying vec4 pass_Color;" 37 37 "" 38 "vec4 Light = vec4( 10.0, 1.0, 1.0, 1.0);"38 "vec4 Light = vec4(3.0, 3.0, 1.0, 1.0);" 39 39 "vec3 Kd = vec3(1.0, 0.8, 0.8);" 40 40 "vec3 Ld = vec3(1.0, 0.8, 0.8);" … … 345 345 void AppendCylinder() {} /* TODO */ 346 346 347 void AppendSphere(vec3 const &size, int divisions) 348 { 349 int ibase = m_quadidx.Count(); 350 int vbase = m_vert.Count(); 351 352 vec3 d = size * 0.5f; 353 float const pi = acos(1.0f); 354 355 Array<vec2> table; 356 for (int i = 0; i <= divisions; i++) 357 table.Append(vec2(sin(pi * 2 / divisions * i) + 1e5f, 358 cos(pi * 2 / divisions * i) + 1e5f)); 359 360 for (int j = 0; j <= divisions / 2; j++) 361 for (int i = 0; i < divisions; i++) 362 { 363 int j2 = j + 1; 364 int i2 = (i + 1) % divisions; 365 366 AppendQuadVert(d * vec3(table[i], 1.0f) * table[j].xxy); 367 AppendQuadVert(d * vec3(table[i2], 1.0f) * table[j].xxy); 368 AppendQuadVert(d * vec3(table[i2], 1.0f) * table[j2].xxy); 369 AppendQuadVert(d * vec3(table[i], 1.0f) * table[j2].xxy); 370 } 371 372 for (int i = vbase; i < m_vert.Count(); i += 4) 373 AppendQuad(0, 1, 2, 3, i); 374 375 ComputeQuadNormals(ibase, m_quadidx.Count()  ibase); 376 } 377 347 378 void AppendBox(vec3 const &size) 348 379 { 
trunk/orbital/orbital.cpp
r1260 r1262 29 29 { 30 30 m.SetCurColor(vec4(1.0, 1.0, 0.0, 1.0)); 31 m.AppendBox(vec3(1.0, 1.0, 1.0)); 32 m.Duplicate(); 33 m.RotateX(45); 34 m.Translate(vec3(0.5, 0.0, 0.0)); 31 m.AppendSphere(vec3(1.0, 0.5, 1.0), 32); 32 m.Translate(vec3(0.0, 0.4, 0.0)); 33 m.Flush(); 34 35 m.SetCurColor(vec4(1.0, 0.0, 1.0, 1.0)); 36 m.AppendBox(vec3(0.5, 0.5, 0.5)); 37 m.RotateX(45.0); 38 m.RotateZ(45.0); 39 m.Translate(vec3(0.0, 0.4, 0.0)); 35 40 m.Flush(); 36 41
Note: See TracChangeset
for help on using the changeset viewer.