37 unsigned int numYSamples,
float xExtent,
float yExtent)
67 rectangle.
center = { 0.0f, 0.0f, 0.0f };
68 rectangle.axis[0] = { 1.0f, 0.0f, 0.0f };
69 rectangle.axis[1] = { 0.0f, 1.0f, 0.0f };
70 rectangle.extent = { xExtent, yExtent };
73 auto visual = std::make_shared<Visual>(vbuffer, ibuffer);
76 visual->UpdateModelBound();
82 float xExtent,
float yExtent)
85 float inv = 1.0f / (
static_cast<float>(numSamples)-1.0
f);
86 unsigned int numVertices = numSamples*(numSamples + 1)/2;
87 unsigned int numTriangles = (numSamples - 1)*(numSamples - 1);
90 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
102 for (
unsigned int i1 = 0, i = 0; i1 < numSamples; ++i1)
105 pos[1] = tcd[1] * yExtent;
106 for (
unsigned int i0 = 0; i0 + i1 < numSamples; ++i0, ++i)
109 pos[0] = tcd[0] * xExtent;
120 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
126 int y0 = 0,
y1 = numSamples;
128 for (
unsigned int i1 = 0; i1 < numSamples - 2; ++i1)
130 int bot0 =
y0, bot1 = bot0 + 1, top0 =
y1, top1 =
y1 + 1;
131 for (
unsigned int i0 = 0; i0 + i1 < numSamples - 2; ++i0)
133 ibuffer->SetTriangle(t++, bot0, bot1, top0);
134 ibuffer->SetTriangle(t++, bot1, top1, top0);
138 ibuffer->SetTriangle(t++, bot0, bot1, top0);
142 ibuffer->SetTriangle(t++, y0, y0 + 1,
y1);
145 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
148 visual->UpdateModelBound();
154 unsigned int numRadialSamples,
float radius)
157 unsigned int ssm1 = numShellSamples - 1;
158 unsigned int rsm1 = numRadialSamples - 1;
159 float invSSm1 = 1.0f/
static_cast<float>(ssm1);
160 float invRS = 1.0f/
static_cast<float>(numRadialSamples);
161 unsigned int numVertices = 1 + numRadialSamples*ssm1;
162 unsigned int numTriangles = numRadialSamples*(2 * ssm1 - 1);
165 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
178 pos = { 0.0f, 0.0f, 0.0f };
179 tcd = { 0.5f, 0.5f };
186 for (
unsigned int r = 0;
r < numRadialSamples; ++
r)
189 float cs = cos(angle);
190 float sn = sin(angle);
193 for (
unsigned int s = 1;
s < numShellSamples; ++
s)
195 float fraction = invSSm1*
s;
197 unsigned int i = s + ssm1*
r;
198 pos = radius*fracRadial;
199 tcd[0] = 0.5f + 0.5f*fracRadial[0];
200 tcd[1] = 0.5f + 0.5f*fracRadial[1];
211 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
216 for (
unsigned int r0 = rsm1, r1 = 0,
t = 0; r1 < numRadialSamples;
219 ibuffer->SetTriangle(
t++, 0, 1 + ssm1*r0, 1 + ssm1*r1);
221 for (
unsigned int s = 1;
s < ssm1; ++
s)
223 unsigned int i00 =
s + ssm1*r0;
224 unsigned int i01 =
s + ssm1*r1;
225 unsigned int i10 = i00 + 1;
226 unsigned int i11 = i01 + 1;
228 ibuffer->SetTriangle(
t++, i00, i10, i11);
229 ibuffer->SetTriangle(
t++, i00, i11, i01);
234 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
237 visual->UpdateModelBound();
247 int numTriangles = 12;
250 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
267 for (
unsigned int z = 0,
v = 0;
z < 2; ++
z)
269 float fz =
static_cast<float>(
z), omfz = 1.0
f - fz;
270 float zSign = 2.0f*fz - 1.0f;
271 pos[2] = zSign*zExtent;
272 nor[2] = zSign*diag[2];
273 for (
unsigned int y = 0;
y < 2; ++
y)
275 float fy =
static_cast<float>(
y);
276 float ySign = 2.0f*fy - 1.0f;
277 pos[1] = ySign*yExtent;
278 nor[1] = ySign*diag[1];
279 tcd[1] = (1.0f - fy)*omfz + (0.75
f - 0.5
f*fy)*fz;
280 for (
unsigned int x = 0;
x < 2; ++
x, ++
v)
282 float fx =
static_cast<float>(
x);
283 float xSign = 2.0f*fx - 1.0f;
284 pos[0] = xSign*xExtent;
285 nor[0] = xSign*diag[0];
286 tcd[0] = fx*omfz + (0.25f + 0.5f*fx)*fz;
301 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
306 ibuffer->SetTriangle(0, 0, 2, 3);
307 ibuffer->SetTriangle( 1, 0, 3, 1);
308 ibuffer->SetTriangle( 2, 0, 1, 5);
309 ibuffer->SetTriangle( 3, 0, 5, 4);
310 ibuffer->SetTriangle( 4, 0, 4, 6);
311 ibuffer->SetTriangle( 5, 0, 6, 2);
312 ibuffer->SetTriangle( 6, 7, 6, 4);
313 ibuffer->SetTriangle( 7, 7, 4, 5);
314 ibuffer->SetTriangle( 8, 7, 5, 1);
315 ibuffer->SetTriangle( 9, 7, 1, 3);
316 ibuffer->SetTriangle(10, 7, 3, 2);
317 ibuffer->SetTriangle(11, 7, 2, 6);
324 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
327 visual->UpdateModelBound();
333 unsigned int numAxisSamples,
unsigned int numRadialSamples,
float radius,
337 unsigned int numVertices = numAxisSamples*(numRadialSamples + 1);
338 unsigned int numTriangles = 2 * (numAxisSamples - 1)*numRadialSamples;
339 float invRS = 1.0f/
static_cast<float>(numRadialSamples);
340 float invASm1 = 1.0f/
static_cast<float>(numAxisSamples - 1);
341 float halfHeight = 0.5f*
height;
344 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
355 std::vector<float> cs(numRadialSamples + 1);
356 std::vector<float> sn(numRadialSamples + 1);
357 for (
unsigned int r = 0;
r < numRadialSamples; ++
r)
363 cs[numRadialSamples] = cs[0];
364 sn[numRadialSamples] = sn[0];
367 for (
unsigned int a = 0, i = 0;
a < numAxisSamples; ++
a)
369 float axisFraction =
a*invASm1;
370 float z = -halfHeight + height*axisFraction;
376 for (
unsigned int r = 0;
r <= numRadialSamples; ++
r, ++i)
378 float radialFraction =
r*invRS;
379 nor = { cs[
r], sn[
r], 0.0f };
380 pos = sliceCenter + radius*nor;
388 tcd = { radialFraction, axisFraction };
399 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
404 for (
unsigned int a = 0, aStart = 0,
t = 0;
a < numAxisSamples - 1; ++
a)
406 unsigned int i0 = aStart;
407 unsigned int i1 = i0 + 1;
408 aStart += numRadialSamples + 1;
409 unsigned int i2 = aStart;
410 unsigned int i3 = i2 + 1;
411 for (
unsigned int i = 0; i < numRadialSamples;
412 ++i, ++i0, ++i1, ++i2, ++i3)
414 ibuffer->SetTriangle(
t++, i0, i1, i2);
415 ibuffer->SetTriangle(
t++, i1, i3, i2);
424 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
427 visual->UpdateModelBound();
432 float maxDist = sqrt(radius*radius + height*height);
433 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
434 visual->modelBound.SetRadius(maxDist);
441 unsigned int numAxisSamples,
unsigned int numRadialSamples,
float radius,
445 std::shared_ptr<Visual> visual =
CreateSphere(numAxisSamples,
446 numRadialSamples, radius);
452 VertexBuffer* vbuffer = visual->GetVertexBuffer().get();
458 float hDiv2 = 0.5f*
height;
469 float zFactor = 2.0f/
static_cast<float>(numAxisSamples - 1);
470 float tmp0 = radius*(-1.0f + zFactor);
471 float tmp1 = 1.0f/(radius*(+1.0f - zFactor));
472 for (i = 0; i < numVertices-2; ++i)
475 pos[2] = hDiv2*(-1.0f + tmp1*(pos[2] - tmp0));
476 float adjust = radius/sqrt(pos[0]*pos[0] + pos[1]*pos[1]);
483 if (visual->UpdateModelNormals())
486 for (i = 0; i < numVertices; ++i)
498 float maxDist = sqrt(radius*radius + height*height);
499 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
500 visual->modelBound.SetRadius(maxDist);
505 unsigned int numRadialSamples,
float radius)
508 unsigned int zsm1 = numZSamples - 1;
509 unsigned int zsm2 = numZSamples - 2;
510 unsigned int zsm3 = numZSamples - 3;
511 unsigned int rsp1 = numRadialSamples + 1;
512 float invRS = 1.0f/
static_cast<float>(numRadialSamples);
513 float zFactor = 2.0f/
static_cast<float>(zsm1);
514 unsigned int numVertices = zsm2*rsp1 + 2;
515 unsigned int numTriangles = 2 * zsm2*numRadialSamples;
518 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
529 std::vector<float> cs(rsp1), sn(rsp1);
530 for (
unsigned int r = 0;
r < numRadialSamples; ++
r)
536 cs[numRadialSamples] = cs[0];
537 sn[numRadialSamples] = sn[0];
541 for (
unsigned int z = 1;
z < zsm1; ++
z)
543 float zFraction = -1.0f + zFactor*
static_cast<float>(
z);
544 float zValue = radius*zFraction;
550 float sliceRadius = sqrt(
std::abs(radius*radius - zValue*zValue));
553 for (
unsigned int r = 0;
r <= numRadialSamples; ++
r, ++i)
555 float radialFraction =
r*invRS;
557 pos = sliceCenter + sliceRadius*radial;
567 tcd = { radialFraction, 0.5f*(zFraction + 1.0f) };
578 pos = { 0.0f, 0.0f, -radius };
581 nor = { 0.0f, 0.0f, -1.0f };
585 nor = { 0.0f, 0.0f, 1.0f };
589 tcd = { 0.5f, 0.5f };
598 pos = { 0.0f, 0.0f, radius };
601 nor = { 0.0f, 0.0f, 1.0f };
605 nor = { 0.0f, 0.0f, -1.0f };
609 tcd = { 0.5f, 1.0f };
617 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
623 for (
unsigned int z = 0, zStart = 0;
z < zsm3; ++
z)
625 unsigned int i0 = zStart;
626 unsigned int i1 = i0 + 1;
628 unsigned int i2 = zStart;
629 unsigned int i3 = i2 + 1;
630 for (i = 0; i < numRadialSamples; ++i, ++i0, ++i1, ++i2, ++i3)
632 ibuffer->SetTriangle(t++, i0, i1, i2);
633 ibuffer->SetTriangle(t++, i1, i3, i2);
638 unsigned int numVerticesM2 = numVertices - 2;
639 for (i = 0; i < numRadialSamples; ++i, ++
t)
641 ibuffer->SetTriangle(t, i, numVerticesM2, i+1);
645 unsigned int numVerticesM1 = numVertices - 1,
offset = zsm3*rsp1;
646 for (i = 0; i < numRadialSamples; ++i, ++
t)
648 ibuffer->SetTriangle(t, i+offset, i+1+offset, numVerticesM1);
657 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
660 visual->UpdateModelBound();
665 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
666 visual->modelBound.SetRadius(radius);
672 unsigned int numCircleSamples,
unsigned int numRadialSamples,
673 float outerRadius,
float innerRadius)
676 float invCS = 1.0f/
static_cast<float>(numCircleSamples);
677 float invRS = 1.0f/
static_cast<float>(numRadialSamples);
678 unsigned int numVertices = (numCircleSamples + 1)*(numRadialSamples + 1);
679 unsigned int numTriangles = 2 * numCircleSamples*numRadialSamples;
682 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
693 for (
unsigned int c = 0;
c < numCircleSamples; ++
c)
696 float circleFraction =
static_cast<float>(
c)*invCS;
698 float cosTheta = cos(theta);
699 float sinTheta = sin(theta);
704 for (
unsigned int r = 0;
r <= numRadialSamples; ++
r, ++i)
706 float radialFraction =
static_cast<float>(
r)*invRS;
708 float cosPhi = cos(phi);
709 float sinPhi = sin(phi);
711 pos = torusMiddle + innerRadius*nor;
719 tcd = { radialFraction, circleFraction };
730 for (
unsigned int r = 0;
r <= numRadialSamples; ++
r, ++i)
755 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
761 for (
unsigned int c = 0, cStart = 0;
c < numCircleSamples; ++
c)
763 unsigned int i0 = cStart;
764 unsigned int i1 = i0 + 1;
765 cStart += numRadialSamples + 1;
766 unsigned int i2 = cStart;
767 unsigned int i3 = i2 + 1;
768 for (i = 0; i < numRadialSamples; ++i, ++i0, ++i1, ++i2, ++i3)
770 ibuffer->SetTriangle(t++, i0, i2, i1);
771 ibuffer->SetTriangle(t++, i1, i2, i3);
781 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
784 visual->UpdateModelBound();
789 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
790 visual->modelBound.SetRadius(outerRadius);
797 float const sqrt2Div3 = sqrt(2.0
f)/3.0f;
798 float const sqrt6Div3 = sqrt(6.0
f)/3.0f;
799 float const oneThird = 1.0f/3.0f;
800 unsigned int const numVertices = 4;
801 unsigned int const numTriangles = 4;
804 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
813 Position(1) = { 2.0f*sqrt2Div3, 0.0f, -oneThird };
814 Position(2) = { -sqrt2Div3, sqrt6Div3, -oneThird };
815 Position(3) = { -sqrt2Div3, -sqrt6Div3, -oneThird };
816 for (
unsigned int i = 0; i < numVertices; ++i)
829 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
834 ibuffer->SetTriangle(0, 0, 1, 2);
835 ibuffer->SetTriangle(1, 0, 2, 3);
836 ibuffer->SetTriangle(2, 0, 3, 1);
837 ibuffer->SetTriangle(3, 1, 3, 2);
845 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
849 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
850 visual->modelBound.SetRadius(1.0
f);
857 float const sqrtThird = sqrt(1.0
f/3.0
f);
858 unsigned int const numVertices = 8;
859 unsigned int const numTriangles = 12;
862 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
870 Position(0) = { -sqrtThird, -sqrtThird, -sqrtThird };
871 Position(1) = { sqrtThird, -sqrtThird, -sqrtThird };
872 Position(2) = { sqrtThird, sqrtThird, -sqrtThird };
873 Position(3) = { -sqrtThird, sqrtThird, -sqrtThird };
874 Position(4) = { -sqrtThird, -sqrtThird, sqrtThird };
875 Position(5) = { sqrtThird, -sqrtThird, sqrtThird };
876 Position(6) = { sqrtThird, sqrtThird, sqrtThird };
877 Position(7) = { -sqrtThird, sqrtThird, sqrtThird };
878 for (
unsigned int i = 0; i < numVertices; ++i)
891 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
896 ibuffer->SetTriangle(0, 0, 3, 2);
897 ibuffer->SetTriangle( 1, 0, 2, 1);
898 ibuffer->SetTriangle( 2, 0, 1, 5);
899 ibuffer->SetTriangle( 3, 0, 5, 4);
900 ibuffer->SetTriangle( 4, 0, 4, 7);
901 ibuffer->SetTriangle( 5, 0, 7, 3);
902 ibuffer->SetTriangle( 6, 6, 5, 1);
903 ibuffer->SetTriangle( 7, 6, 1, 2);
904 ibuffer->SetTriangle( 8, 6, 2, 3);
905 ibuffer->SetTriangle( 9, 6, 3, 7);
906 ibuffer->SetTriangle(10, 6, 7, 4);
907 ibuffer->SetTriangle(11, 6, 4, 5);
915 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
919 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
920 visual->modelBound.SetRadius(1.0
f);
927 unsigned int const numVertices = 6;
928 unsigned int const numTriangles = 8;
931 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
940 Position(1) = { -1.0f, 0.0f, 0.0f };
942 Position(3) = { 0.0f, -1.0f, 0.0f };
944 Position(5) = { 0.0f, 0.0f, -1.0f };
945 for (
unsigned int i = 0; i < numVertices; ++i)
958 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
963 ibuffer->SetTriangle(0, 4, 0, 2);
964 ibuffer->SetTriangle(1, 4, 2, 1);
965 ibuffer->SetTriangle(2, 4, 1, 3);
966 ibuffer->SetTriangle(3, 4, 3, 0);
967 ibuffer->SetTriangle(4, 5, 2, 0);
968 ibuffer->SetTriangle(5, 5, 1, 2);
969 ibuffer->SetTriangle(6, 5, 3, 1);
970 ibuffer->SetTriangle(7, 5, 0, 3);
978 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
982 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
983 visual->modelBound.SetRadius(1.0
f);
990 float const a = 1.0f/sqrt(3.0
f);
991 float const b = sqrt((3.0
f - sqrt(5.0
f))/6.0
f);
992 float const c = sqrt((3.0
f + sqrt(5.0
f))/6.0
f);
993 unsigned int const numVertices = 20;
994 unsigned int const numTriangles = 36;
997 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
1025 for (
unsigned int i = 0; i < numVertices; ++i)
1038 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
1043 ibuffer->SetTriangle(0, 0, 8, 9);
1044 ibuffer->SetTriangle( 1, 0, 9, 4);
1045 ibuffer->SetTriangle( 2, 0, 4, 16);
1046 ibuffer->SetTriangle( 3, 0, 12, 13);
1047 ibuffer->SetTriangle( 4, 0, 13, 1);
1048 ibuffer->SetTriangle( 5, 0, 1, 8);
1049 ibuffer->SetTriangle( 6, 0, 16, 17);
1050 ibuffer->SetTriangle( 7, 0, 17, 2);
1051 ibuffer->SetTriangle( 8, 0, 2, 12);
1052 ibuffer->SetTriangle( 9, 8, 1, 18);
1053 ibuffer->SetTriangle(10, 8, 18, 5);
1054 ibuffer->SetTriangle(11, 8, 5, 9);
1055 ibuffer->SetTriangle(12, 12, 2, 10);
1056 ibuffer->SetTriangle(13, 12, 10, 3);
1057 ibuffer->SetTriangle(14, 12, 3, 13);
1058 ibuffer->SetTriangle(15, 16, 4, 14);
1059 ibuffer->SetTriangle(16, 16, 14, 6);
1060 ibuffer->SetTriangle(17, 16, 6, 17);
1061 ibuffer->SetTriangle(18, 9, 5, 15);
1062 ibuffer->SetTriangle(19, 9, 15, 14);
1063 ibuffer->SetTriangle(20, 9, 14, 4);
1064 ibuffer->SetTriangle(21, 6, 11, 10);
1065 ibuffer->SetTriangle(22, 6, 10, 2);
1066 ibuffer->SetTriangle(23, 6, 2, 17);
1067 ibuffer->SetTriangle(24, 3, 19, 18);
1068 ibuffer->SetTriangle(25, 3, 18, 1);
1069 ibuffer->SetTriangle(26, 3, 1, 13);
1070 ibuffer->SetTriangle(27, 7, 15, 5);
1071 ibuffer->SetTriangle(28, 7, 5, 18);
1072 ibuffer->SetTriangle(29, 7, 18, 19);
1073 ibuffer->SetTriangle(30, 7, 11, 6);
1074 ibuffer->SetTriangle(31, 7, 6, 14);
1075 ibuffer->SetTriangle(32, 7, 14, 15);
1076 ibuffer->SetTriangle(33, 7, 19, 3);
1077 ibuffer->SetTriangle(34, 7, 3, 10);
1078 ibuffer->SetTriangle(35, 7, 10, 11);
1086 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
1090 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
1091 visual->modelBound.SetRadius(1.0
f);
1098 float const goldenRatio = 0.5f*(1.0f + sqrt(5.0
f));
1099 float const invRoot = 1.0f/sqrt(1.0
f + goldenRatio*goldenRatio);
1100 float const u = goldenRatio*invRoot;
1101 float const v = invRoot;
1102 unsigned int const numVertices = 12;
1103 unsigned int const numTriangles = 20;
1106 std::shared_ptr<VertexBuffer> vbuffer =
CreateVBuffer(numVertices);
1126 for (
unsigned int i = 0; i < numVertices; ++i)
1139 std::shared_ptr<IndexBuffer> ibuffer =
CreateIBuffer(numTriangles);
1144 ibuffer->SetTriangle(0, 0, 8, 4);
1145 ibuffer->SetTriangle( 1, 0, 5, 10);
1146 ibuffer->SetTriangle( 2, 2, 4, 9);
1147 ibuffer->SetTriangle( 3, 2, 11, 5);
1148 ibuffer->SetTriangle( 4, 1, 6, 8);
1149 ibuffer->SetTriangle( 5, 1, 10, 7);
1150 ibuffer->SetTriangle( 6, 3, 9, 6);
1151 ibuffer->SetTriangle( 7, 3, 7, 11);
1152 ibuffer->SetTriangle( 8, 0, 10, 8);
1153 ibuffer->SetTriangle( 9, 1, 8, 10);
1154 ibuffer->SetTriangle(10, 2, 9, 11);
1155 ibuffer->SetTriangle(11, 3, 11, 9);
1156 ibuffer->SetTriangle(12, 4, 2, 0);
1157 ibuffer->SetTriangle(13, 5, 0, 2);
1158 ibuffer->SetTriangle(14, 6, 1, 3);
1159 ibuffer->SetTriangle(15, 7, 3, 1);
1160 ibuffer->SetTriangle(16, 8, 6, 4);
1161 ibuffer->SetTriangle(17, 9, 4, 6);
1162 ibuffer->SetTriangle(18, 10, 5, 7);
1163 ibuffer->SetTriangle(19, 11, 7, 5);
1171 std::shared_ptr<Visual> visual = std::make_shared<Visual>(vbuffer, ibuffer);
1175 visual->modelBound.SetCenter({ 0.0f, 0.0f, 0.0f, 1.0f });
1176 visual->modelBound.SetRadius(1.0
f);
1183 auto vbuffer = std::make_shared<VertexBuffer>(
mVFormat, numVertices);
1190 LogError(
"Positions are required.");
1202 std::set<DFType> required;
1233 std::shared_ptr<VertexBuffer>
const& vbuffer, VASemantic semantic,
1236 char* channel =
nullptr;
1240 channel = vbuffer->GetChannel(semantic, 0, std::set<DFType>());
1241 LogAssert(channel != 0,
"Unexpected condition.");
1245 int const numVertices = vbuffer->GetNumElements();
1246 for (
int i = 0; i < numVertices; ++i)
1248 float* tuple4 =
reinterpret_cast<float*
>(
1302 tcd[0] = 0.5f*(1.0f +
1324 for (
unsigned int t = 0;
t < numTriangles; ++
t)
void ReverseTriangleOrder(IndexBuffer *ibuffer)
std::shared_ptr< Visual > CreateHexahedron()
Vector3< float > & Normal(unsigned int i)
void SetPosition(unsigned int i, Vector3< float > const &pos)
unsigned int GetNumElements() const
std::shared_ptr< Visual > CreateCylinderClosed(unsigned int numAxisSamples, unsigned int numRadialSamples, float radius, float height)
Vector3< float > & Bitangent(unsigned int i)
std::shared_ptr< IndexBuffer > CreateIBuffer(unsigned int numTriangles)
void SetTangent(unsigned int i, Vector3< float > const &tan)
std::shared_ptr< Visual > CreateRectangle(unsigned int numXSamples, unsigned int numYSamples, float xExtent, float yExtent)
bool SetTriangle(uint32_t i, uint32_t v0, uint32_t v1, uint32_t v2)
gte::BSNumber< UIntegerType > abs(gte::BSNumber< UIntegerType > const &number)
#define LogAssert(condition, message)
std::shared_ptr< Visual > CreateTorus(unsigned int numCircleSamples, unsigned int numRadialSamples, float outerRadius, float innerRadius)
std::shared_ptr< VertexBuffer > CreateVBuffer(unsigned int numVertices)
uint32_t GetNumPrimitives() const
void SetBinormal(unsigned int i, Vector3< float > const &bin)
std::shared_ptr< Visual > CreateSphere(unsigned int numZSamples, unsigned int numRadialSamples, float radius)
Vector3< float > & Position(unsigned int i)
std::shared_ptr< Visual > CreateCylinderOpen(unsigned int numAxisSamples, unsigned int numRadialSamples, float radius, float height)
void SetPlatonicTCoord(unsigned int i, Vector3< float > const &pos)
std::shared_ptr< Visual > CreateTetrahedron()
Vector2< float > & TCoord(unsigned int unit, unsigned int i)
IndexAttribute indexAttribute
bool mAssignTCoords[VA_MAX_TCOORD_UNITS]
GLubyte GLubyte GLubyte GLubyte w
void SetTCoord(unsigned int i, Vector2< float > const &tcd)
GLboolean GLboolean GLboolean GLboolean a
std::shared_ptr< Visual > CreateOctahedron()
std::shared_ptr< Visual > CreateTriangle(unsigned int numSamples, float xExtent, float yExtent)
std::vector< VertexAttribute > vertexAttributes
static Real ACos(Real const &x)
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
#define LogError(message)
std::shared_ptr< Visual > CreateBox(float xExtent, float yExtent, float zExtent)
Vector3< float > & Tangent(unsigned int i)
std::shared_ptr< Visual > CreateDodecahedron()
Real Normalize(GVector< Real > &v, bool robust=false)
GLint GLsizei GLsizei height
GLboolean GLboolean GLboolean b
std::shared_ptr< Visual > CreateIcosahedron()
GLdouble GLdouble GLdouble z
static Real ATan2(Real const &y, Real const &x)
std::shared_ptr< Visual > CreateDisk(unsigned int numShellSamples, unsigned int numRadialSamples, float radius)
GLfloat GLfloat GLfloat v2
GLuint GLfloat GLfloat y0
Real ComputeOrthogonalComplement(int numInputs, Vector2< Real > *v, bool robust=false)
GLint GLenum GLboolean GLsizei stride
char * GetGeometricChannel(std::shared_ptr< VertexBuffer > const &vbuffer, VASemantic semantic, float w)
bool GetTriangle(uint32_t i, uint32_t &v0, uint32_t &v1, uint32_t &v2) const
void SetNormal(unsigned int i, Vector3< float > const &nor)
char * mTCoords[VA_MAX_TCOORD_UNITS]
static Vector Unit(int d)