# HG changeset patch # User John Tsiombikas # Date 1434939339 -10800 # Node ID 893192aea0990bb8677b3cd637451db960e76acf # Parent 3fcd7b4d631f14d17a439b0e46d8b3efc1ac7733 board keeps objects instead of raw meshes diff -r 3fcd7b4d631f -r 893192aea099 src/board.cc --- a/src/board.cc Mon Jun 22 05:05:37 2015 +0300 +++ b/src/board.cc Mon Jun 22 05:15:39 2015 +0300 @@ -5,7 +5,7 @@ Board::Board() { - puck_mesh = 0; + puck_obj = 0; clear(); } @@ -25,13 +25,13 @@ void Board::destroy() { - for(size_t i=0; idraw(); + for(size_t i=0; idraw(); } } @@ -59,12 +59,19 @@ { Matrix4x4 xform; + obj.clear(); + // generate bottom Mesh *bottom = new Mesh; gen_box(bottom, HSIZE, BOT_THICKNESS, HSIZE * 2.0); xform.set_translation(Vector3(0, -BOT_THICKNESS / 2.0, 0)); bottom->apply_xform(xform); + Object *obottom = new Object; + obottom->set_mesh(bottom); + obj.push_back(obottom); + + // generate the 4 sides Mesh *sides = new Mesh; gen_box(sides, WALL_THICKNESS, WALL_HEIGHT, VSIZE + WALL_THICKNESS * 2); @@ -94,6 +101,11 @@ sides->append(tmp); tmp.clear(); + Object *osides = new Object; + osides->set_mesh(sides); + obj.push_back(osides); + + // generate the hinges Mesh *hinges = new Mesh; gen_cylinder(hinges, HINGE_RAD, HINGE_HEIGHT, 10, 1, 1); @@ -108,10 +120,10 @@ hinges->append(tmp); + Object *ohinges = new Object; + ohinges->set_mesh(hinges); + obj.push_back(ohinges); - board_meshes.clear(); - board_meshes.push_back(bottom); - board_meshes.push_back(sides); - board_meshes.push_back(hinges); + return true; } diff -r 3fcd7b4d631f -r 893192aea099 src/board.h --- a/src/board.h Mon Jun 22 05:05:37 2015 +0300 +++ b/src/board.h Mon Jun 22 05:15:39 2015 +0300 @@ -2,7 +2,7 @@ #define BOARD_H_ #include -#include "mesh.h" +#include "object.h" #define NUM_SLOTS 24 #define MAX_PUCKS 30 @@ -12,8 +12,8 @@ class Board { private: int slots[NUM_SLOTS][MAX_PUCKS]; - std::vector board_meshes; - Mesh *puck_mesh; + std::vector obj; + Object *puck_obj; bool generate(); diff -r 3fcd7b4d631f -r 893192aea099 src/object.cc --- a/src/object.cc Mon Jun 22 05:05:37 2015 +0300 +++ b/src/object.cc Mon Jun 22 05:15:39 2015 +0300 @@ -37,7 +37,7 @@ glMatrixMode(GL_MODELVIEW); glPushMatrix(); - glLoadTransposeMatrixf(matrix[0]); + glMultTransposeMatrixf(matrix[0]); mesh->draw();