From 12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6 Mon Sep 17 00:00:00 2001 From: KT Date: Tue, 19 Oct 2021 14:03:28 -0500 Subject: Publish a4 --- dev/a4-dance/dance_floor.cc | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 dev/a4-dance/dance_floor.cc (limited to 'dev/a4-dance/dance_floor.cc') diff --git a/dev/a4-dance/dance_floor.cc b/dev/a4-dance/dance_floor.cc new file mode 100644 index 0000000..f8302e6 --- /dev/null +++ b/dev/a4-dance/dance_floor.cc @@ -0,0 +1,71 @@ +#include "dance_floor.h" +#include "config.h" + +DanceFloor::DanceFloor(float s, int c) { + tileSize_ = s; + tileCount_ = c; + /** + Array indices; + Array coords; + Array texcoords; + tex = Texture::fromFile(DANCEFLOOR_PATH); + + indices.append(0,1,2,3); + coords.append(Vector3(-tileSize/2, 0, -tileSize/2)); + texcoords.append(Vector2(0,0)); + coords.append(Vector3(-tileSize/2, 0, tileSize/2)); + texcoords.append(Vector2(0,1)); + coords.append(Vector3(tileSize/2, 0, tileSize/2)); + texcoords.append(Vector2(1,1)); + coords.append(Vector3(tileSize/2, 0, -tileSize/2)); + texcoords.append(Vector2(1,0)); + + vdatabuf = VertexBuffer::create(sizeof(Vector3) * coords.size() + + sizeof(Vector2) * texcoords.size() + sizeof(int)*indices.size(), + VertexBuffer::WRITE_ONCE); + + vcoords = AttributeArray(coords, vdatabuf); + vtexcoords = AttributeArray(texcoords, vdatabuf); + vindices = IndexStream(indices, vdatabuf); + + colors.resize(tileCount*2); + for (int i=0; ipushState(); + rd->setTexture(0, tex); + + rd->beginIndexedPrimitives(); + rd->setVertexArray(vcoords); + rd->setTexCoordArray(0, vtexcoords); + + + for (int x=0; xsetColor(colors[x][y]+Color3(0.1,0.1,0.1)); + rd->setObjectToWorldMatrix(CoordinateFrame(Vector3((x - tileCount) * tileSize, + 0, + (y - tileCount) * tileSize))); + rd->sendIndices(PrimitiveType::QUADS, vindices); + if (Random::common().uniform(0, 1) < 0.015) { + colors[x][y] = Color3(Random::common().uniform(0.3, 2.0), + Random::common().uniform(0.3, 2.0), + Random::common().uniform(0.3, 2.0)); + } + } + } + + rd->endIndexedPrimitives(); + rd->popState(); + */ +} + -- cgit v1.2.3