From ff18faf6dc81d77f2ca80650c11b44e30baf30c9 Mon Sep 17 00:00:00 2001 From: Jacqueline Deans Date: Thu, 14 Jul 2022 16:07:14 -0500 Subject: [PATCH] Refactor graphics client to run in a single thread; remove extraneous files --- trick_sims/.gitignore | 2 + .../Modified_data/realtime.py | 0 .../RUN_break/input.py | 26 +- .../RUN_hexagon/input.py | 0 .../RUN_test/input.py | 14 +- .../{SIM_pool => SIM_billiards}/S_define | 0 trick_sims/SIM_billiards/S_overrides.mk | 2 + .../models/graphics/cpp/CMakeLists.txt | 0 .../models/graphics/cpp/README.md | 6 +- .../models/graphics/cpp/Socket.cpp | 29 +- .../models/graphics/cpp/Socket.hh | 10 +- .../models/graphics/cpp/cmake/libigl.cmake | 0 .../models/graphics/cpp/main.cpp | 516 +++++++++--------- .../graphics/java/src/PoolTableDisplay.java | 0 .../models/pool_table/include/ball.hh | 0 .../models/pool_table/include/bumper.hh | 0 .../pool_table/include/common_geometry.hh | 0 .../models/pool_table/include/pocket.hh | 0 .../models/pool_table/include/pool_table.hh | 0 .../models/pool_table/src/ball.cpp | 0 .../models/pool_table/src/bumper.cpp | 0 .../models/pool_table/src/pocket.cpp | 0 .../models/pool_table/src/pool_table.cpp | 0 trick_sims/SIM_pool/S_overrides.mk | 2 - .../SIM_pool/models/graphics/cpp/LICENSE | 363 ------------ .../SIM_pool/models/graphics/java/Makefile | 36 -- .../graphics/java/dist/PoolTableDisplay.jar | Bin 6493 -> 0 bytes .../SIM_pool/models/graphics/java/manifest | 1 - .../models/graphics/libigl-example-project | 1 - 29 files changed, 312 insertions(+), 696 deletions(-) rename trick_sims/{SIM_pool => SIM_billiards}/Modified_data/realtime.py (100%) rename trick_sims/{SIM_pool => SIM_billiards}/RUN_break/input.py (90%) rename trick_sims/{SIM_pool => SIM_billiards}/RUN_hexagon/input.py (100%) rename trick_sims/{SIM_pool => SIM_billiards}/RUN_test/input.py (96%) rename trick_sims/{SIM_pool => SIM_billiards}/S_define (100%) create mode 100644 trick_sims/SIM_billiards/S_overrides.mk rename trick_sims/{SIM_pool => SIM_billiards}/models/graphics/cpp/CMakeLists.txt (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/graphics/cpp/README.md (63%) rename trick_sims/{SIM_pool => SIM_billiards}/models/graphics/cpp/Socket.cpp (59%) rename trick_sims/{SIM_pool => SIM_billiards}/models/graphics/cpp/Socket.hh (70%) rename trick_sims/{SIM_pool => SIM_billiards}/models/graphics/cpp/cmake/libigl.cmake (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/graphics/cpp/main.cpp (72%) rename trick_sims/{SIM_pool => SIM_billiards}/models/graphics/java/src/PoolTableDisplay.java (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/include/ball.hh (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/include/bumper.hh (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/include/common_geometry.hh (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/include/pocket.hh (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/include/pool_table.hh (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/src/ball.cpp (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/src/bumper.cpp (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/src/pocket.cpp (100%) rename trick_sims/{SIM_pool => SIM_billiards}/models/pool_table/src/pool_table.cpp (100%) delete mode 100644 trick_sims/SIM_pool/S_overrides.mk delete mode 100644 trick_sims/SIM_pool/models/graphics/cpp/LICENSE delete mode 100644 trick_sims/SIM_pool/models/graphics/java/Makefile delete mode 100644 trick_sims/SIM_pool/models/graphics/java/dist/PoolTableDisplay.jar delete mode 100644 trick_sims/SIM_pool/models/graphics/java/manifest delete mode 160000 trick_sims/SIM_pool/models/graphics/libigl-example-project diff --git a/trick_sims/.gitignore b/trick_sims/.gitignore index 60d1a30c..4a06bade 100644 --- a/trick_sims/.gitignore +++ b/trick_sims/.gitignore @@ -25,7 +25,9 @@ T_main_* **/SIM_*/.trick **/SIM_*/trick.zip **/graphics/dist +**/graphics/java/dist **/graphics/manifest **/graphics/build +**/graphics/cpp/build jitlib build diff --git a/trick_sims/SIM_pool/Modified_data/realtime.py b/trick_sims/SIM_billiards/Modified_data/realtime.py similarity index 100% rename from trick_sims/SIM_pool/Modified_data/realtime.py rename to trick_sims/SIM_billiards/Modified_data/realtime.py diff --git a/trick_sims/SIM_pool/RUN_break/input.py b/trick_sims/SIM_billiards/RUN_break/input.py similarity index 90% rename from trick_sims/SIM_pool/RUN_break/input.py rename to trick_sims/SIM_billiards/RUN_break/input.py index 42ebca76..e6e05b7c 100644 --- a/trick_sims/SIM_pool/RUN_break/input.py +++ b/trick_sims/SIM_billiards/RUN_break/input.py @@ -2,7 +2,7 @@ import math exec(open("./Modified_data/realtime.py").read()) -dyn.table.numBalls = 11 +dyn.table.numBalls = 16 dyn.table.balls = trick.TMM_declare_var_1d("Ball*", dyn.table.numBalls) ballRadius = 0.02 @@ -30,11 +30,11 @@ dyn.table.addBall(center_x+unit_pos[0]*6*(ballRadius+tol), center_y+unit_pos[1]* dyn.table.addBall(center_x+unit_neg[0]*6*(ballRadius+tol), center_y+unit_neg[1]*2*(ballRadius+tol), ballMass, ballRadius, False) dyn.table.addBall(center_x+unit_pos[0]*6*(ballRadius+tol), center_y+unit_pos[1]*2*(ballRadius+tol), ballMass, ballRadius, False) -# dyn.table.addBall(center_x+unit_neg[0]*8*(ballRadius+tol), center_y+unit_neg[1]*8*(ballRadius+tol), ballMass, ballRadius, False) -# dyn.table.addBall(center_x+unit_pos[0]*8*(ballRadius+tol), center_y+unit_pos[1]*8*(ballRadius+tol), ballMass, ballRadius, False) -# dyn.table.addBall(center_x+unit_neg[0]*8*(ballRadius+tol), center_y+unit_neg[1]*4*(ballRadius+tol), ballMass, ballRadius, False) -# dyn.table.addBall(center_x+unit_pos[0]*8*(ballRadius+tol), center_y+unit_pos[1]*4*(ballRadius+tol), ballMass, ballRadius, False) -# dyn.table.addBall(center_x+unit_pos[0]*8*(ballRadius+tol), center_y, ballMass, ballRadius, False) +dyn.table.addBall(center_x+unit_neg[0]*8*(ballRadius+tol), center_y+unit_neg[1]*8*(ballRadius+tol), ballMass, ballRadius, False) +dyn.table.addBall(center_x+unit_pos[0]*8*(ballRadius+tol), center_y+unit_pos[1]*8*(ballRadius+tol), ballMass, ballRadius, False) +dyn.table.addBall(center_x+unit_neg[0]*8*(ballRadius+tol), center_y+unit_neg[1]*4*(ballRadius+tol), ballMass, ballRadius, False) +dyn.table.addBall(center_x+unit_pos[0]*8*(ballRadius+tol), center_y+unit_pos[1]*4*(ballRadius+tol), ballMass, ballRadius, False) +dyn.table.addBall(center_x+unit_pos[0]*8*(ballRadius+tol), center_y, ballMass, ballRadius, False) corners = [-.5, -.25, .5, .25] @@ -110,13 +110,17 @@ bumperShapes = [ [bumperBorders[0][0], bumperBorders[0][1]-bumperWidth, bumpe bumperShapeTypes = [3, 3, 3, 3, 3, 3, 2, 2,2,2,2, 2, 2, 2,2,2, 2, 2] -dyn.table.numBumpers = len(bumperBorders) + +bumperNum = len(bumperBorders) +print("Num bumpers: ", len(bumperBorders)) +dyn.table.numBumpers = bumperNum dyn.table.bumpers = trick.TMM_declare_var_1d("Bumper*", dyn.table.numBumpers) -for i in range(len(bumperBorders)): - id = dyn.table.addBumper(len(bumperShapes[i])/2, bumperBorders[i][0], bumperBorders[i][1], bumperBorders[i][2],bumperBorders[i][3]) - dyn.table.bumpers[id][0].numPoints = len(bumperShapes[i])/2 - dyn.table.bumpers[id][0].renderedShape = trick.TMM_declare_var_1d("Vec*", dyn.table.bumpers[id].numPoints) +for i in range(bumperNum): + numPoints = len(bumperShapes[i])/2 + id = dyn.table.addBumper(numPoints, bumperBorders[i][0], bumperBorders[i][1], bumperBorders[i][2],bumperBorders[i][3]) + dyn.table.bumpers[id][0].numPoints = numPoints + dyn.table.bumpers[id][0].renderedShape = trick.TMM_declare_var_1d("Vec*", numPoints) dyn.table.bumpers[id][0].shapeType = bumperShapeTypes[i] for j in range(0, len(bumperShapes[i]), 2): diff --git a/trick_sims/SIM_pool/RUN_hexagon/input.py b/trick_sims/SIM_billiards/RUN_hexagon/input.py similarity index 100% rename from trick_sims/SIM_pool/RUN_hexagon/input.py rename to trick_sims/SIM_billiards/RUN_hexagon/input.py diff --git a/trick_sims/SIM_pool/RUN_test/input.py b/trick_sims/SIM_billiards/RUN_test/input.py similarity index 96% rename from trick_sims/SIM_pool/RUN_test/input.py rename to trick_sims/SIM_billiards/RUN_test/input.py index c016a353..f8b990cc 100644 --- a/trick_sims/SIM_pool/RUN_test/input.py +++ b/trick_sims/SIM_billiards/RUN_test/input.py @@ -106,19 +106,21 @@ bumperShapes = [ [bumperBorders[0][0], bumperBorders[0][1]-bumperWidth, bumpe bumperShapeTypes = [3, 3, 3, 3, 3, 3, 2, 2,2,2,2, 2, 2, 2,2,2, 2, 2] -dyn.table.numBumpers = len(bumperBorders) +bumperNum = len(bumperBorders) +print("Num bumpers: ", len(bumperBorders)) +dyn.table.numBumpers = bumperNum dyn.table.bumpers = trick.TMM_declare_var_1d("Bumper*", dyn.table.numBumpers) -for i in range(len(bumperBorders)): - id = dyn.table.addBumper(len(bumperShapes[i])/2, bumperBorders[i][0], bumperBorders[i][1], bumperBorders[i][2],bumperBorders[i][3]) - dyn.table.bumpers[id][0].numPoints = len(bumperShapes[i])/2 - dyn.table.bumpers[id][0].renderedShape = trick.TMM_declare_var_1d("Vec*", dyn.table.bumpers[id].numPoints) +for i in range(bumperNum): + numPoints = len(bumperShapes[i])/2 + id = dyn.table.addBumper(numPoints, bumperBorders[i][0], bumperBorders[i][1], bumperBorders[i][2],bumperBorders[i][3]) + dyn.table.bumpers[id][0].numPoints = numPoints + dyn.table.bumpers[id][0].renderedShape = trick.TMM_declare_var_1d("Vec*", numPoints) dyn.table.bumpers[id][0].shapeType = bumperShapeTypes[i] for j in range(0, len(bumperShapes[i]), 2): dyn.table.addPointToBumper(id, bumperShapes[i][j],bumperShapes[i][j+1]) - dyn_integloop.getIntegrator(trick.Euler, 6*dyn.table.numBalls) #========================================== diff --git a/trick_sims/SIM_pool/S_define b/trick_sims/SIM_billiards/S_define similarity index 100% rename from trick_sims/SIM_pool/S_define rename to trick_sims/SIM_billiards/S_define diff --git a/trick_sims/SIM_billiards/S_overrides.mk b/trick_sims/SIM_billiards/S_overrides.mk new file mode 100644 index 00000000..1b84a37b --- /dev/null +++ b/trick_sims/SIM_billiards/S_overrides.mk @@ -0,0 +1,2 @@ +TRICK_CFLAGS += -Imodels +TRICK_CXXFLAGS += -Imodels \ No newline at end of file diff --git a/trick_sims/SIM_pool/models/graphics/cpp/CMakeLists.txt b/trick_sims/SIM_billiards/models/graphics/cpp/CMakeLists.txt similarity index 100% rename from trick_sims/SIM_pool/models/graphics/cpp/CMakeLists.txt rename to trick_sims/SIM_billiards/models/graphics/cpp/CMakeLists.txt diff --git a/trick_sims/SIM_pool/models/graphics/cpp/README.md b/trick_sims/SIM_billiards/models/graphics/cpp/README.md similarity index 63% rename from trick_sims/SIM_pool/models/graphics/cpp/README.md rename to trick_sims/SIM_billiards/models/graphics/cpp/README.md index 8338bf67..2479c965 100644 --- a/trick_sims/SIM_pool/models/graphics/cpp/README.md +++ b/trick_sims/SIM_billiards/models/graphics/cpp/README.md @@ -1,18 +1,18 @@ # Pool Table Display -Uses the Libigl library for visualization. Connects to SIM_Billiards +Uses the Libigl library for visualization. Connects to SIM_billiards ## Compile libigl must be downloaded from Github : https://github.com/libigl/libigl + Clone it somewhere accessible, like your home directory. It does not need to be compiled. -libigl depends on Eigen3, which also need to be downloaded and installed : https://eigen.tuxfamily.org/index.php?title=Main_Page +libigl depends on Eigen3, which may need to be downloaded and installed : https://eigen.tuxfamily.org/index.php?title=Main_Page To compile: - mkdir build cd build cmake .. diff --git a/trick_sims/SIM_pool/models/graphics/cpp/Socket.cpp b/trick_sims/SIM_billiards/models/graphics/cpp/Socket.cpp similarity index 59% rename from trick_sims/SIM_pool/models/graphics/cpp/Socket.cpp rename to trick_sims/SIM_billiards/models/graphics/cpp/Socket.cpp index 7afe4ec7..d4587478 100644 --- a/trick_sims/SIM_pool/models/graphics/cpp/Socket.cpp +++ b/trick_sims/SIM_billiards/models/graphics/cpp/Socket.cpp @@ -1,11 +1,16 @@ #include "Socket.hh" -#define SOCKET_BUF_SIZE 2048 +#define SOCKET_BUF_SIZE 20480 -Socket::Socket (std::string hostname, int port) : hostname(hostname), port(port) { - socket_fd = socket(AF_INET, SOCK_STREAM, 0); - if (socket_fd < 0) { - std::cout << "Socket connection failed" << std::endl; +Socket::Socket() : _initialized(false) {} + +int Socket::init (std::string hostname, int port) { + _hostname = hostname; + _port = port; + _socket_fd = socket(AF_INET, SOCK_STREAM, 0); + if (_socket_fd < 0) { + std::cout << "Socket connection failed" << std::endl; + return -1; } struct sockaddr_in serv_addr; @@ -13,18 +18,22 @@ Socket::Socket (std::string hostname, int port) : hostname(hostname), port(port) serv_addr.sin_port = htons(port); // convert to weird network byte format if(inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr)<=0) { - std::cout << "Invalid address/ Address not supported" << std::endl; + std::cout << "Invalid address/ Address not supported" << std::endl; + return -1; } - if (connect(socket_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { - std::cout << "Connection failed" << std::endl; + if (connect(_socket_fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0) { + std::cout << "Connection failed" << std::endl; + return -1; } + + _initialized = true; } int Socket::send (std::string message) { // weird syntax I've never used before - since the send syscall that i'm trying to use is overloaded in this class, // I have to append :: to the front of it so that the compiler knows to look in the global namespace - int success = ::send(socket_fd, message.c_str(), message.size(), 0); + int success = ::send(_socket_fd, message.c_str(), message.size(), 0); if (success < message.size()) { std::cout << "Failed to send message" << std::endl; } @@ -37,7 +46,7 @@ int Socket::operator<< (std::string message) { std::string Socket::receive () { char buffer[SOCKET_BUF_SIZE]; - int numBytes = read(socket_fd, buffer, SOCKET_BUF_SIZE); + int numBytes = read(_socket_fd, buffer, SOCKET_BUF_SIZE); if (numBytes < 0) { std::cout << "Failed to read from socket" << std::endl; } else if (numBytes < SOCKET_BUF_SIZE) { diff --git a/trick_sims/SIM_pool/models/graphics/cpp/Socket.hh b/trick_sims/SIM_billiards/models/graphics/cpp/Socket.hh similarity index 70% rename from trick_sims/SIM_pool/models/graphics/cpp/Socket.hh rename to trick_sims/SIM_billiards/models/graphics/cpp/Socket.hh index 6823ca29..dd9680d1 100644 --- a/trick_sims/SIM_pool/models/graphics/cpp/Socket.hh +++ b/trick_sims/SIM_billiards/models/graphics/cpp/Socket.hh @@ -9,7 +9,8 @@ class Socket { public: - Socket (std::string hostname, int port); + Socket (); + int init(std::string hostname, int port); int send (std::string message); int operator<< (std::string message); @@ -18,8 +19,9 @@ class Socket { void operator>> (std::string& ret); private: - int port; - std::string hostname; - int socket_fd; + int _port; + std::string _hostname; + int _socket_fd; + bool _initialized; }; diff --git a/trick_sims/SIM_pool/models/graphics/cpp/cmake/libigl.cmake b/trick_sims/SIM_billiards/models/graphics/cpp/cmake/libigl.cmake similarity index 100% rename from trick_sims/SIM_pool/models/graphics/cpp/cmake/libigl.cmake rename to trick_sims/SIM_billiards/models/graphics/cpp/cmake/libigl.cmake diff --git a/trick_sims/SIM_pool/models/graphics/cpp/main.cpp b/trick_sims/SIM_billiards/models/graphics/cpp/main.cpp similarity index 72% rename from trick_sims/SIM_pool/models/graphics/cpp/main.cpp rename to trick_sims/SIM_billiards/models/graphics/cpp/main.cpp index 2a913208..1ed067e0 100644 --- a/trick_sims/SIM_pool/models/graphics/cpp/main.cpp +++ b/trick_sims/SIM_billiards/models/graphics/cpp/main.cpp @@ -1,5 +1,5 @@ #include -#include +// #include #include #include #include @@ -10,29 +10,21 @@ #include #include #include -#include -#include #include "Socket.hh" -// #include -// #include -// #include -// #include -// #include -#include - -std::vector ball_colors = {Eigen::Vector3d(1.0,1.0,0.0), //yellow +std::vector ball_colors = {Eigen::Vector3d(0.0,0.4,0.0), //green + Eigen::Vector3d(1.0,1.0,0.0), //yellow Eigen::Vector3d(0.0,0.0,1.0), //blue Eigen::Vector3d(1.0,0.0,0.0), //red Eigen::Vector3d(0.5,0.0,0.3), //purple Eigen::Vector3d(0.7,0.5,0.0), //orange - Eigen::Vector3d(0.0,0.7,0.0), //green - Eigen::Vector3d(0.3,0.07,0.15), //maroon Eigen::Vector3d(0.0,0.0,0.0), //black + Eigen::Vector3d(0.3,0.07,0.15), //maroon }; + const double layer_BALL = 0.005; const double layer_TABLE = 0.001; const double layer_BUMPER = 0.002; @@ -56,7 +48,6 @@ class RenderedShape { return faces.size(); } - std::vector getFacesWithBaseIndex(int newBase) { std::vector newFaces; int offset = newBase - baseIndex; @@ -69,29 +60,9 @@ class RenderedShape { return newFaces; } - ~RenderedShape() { - if (destructorPrint) - std::cout << "Destroying rendered Shape" << std::endl; - } - - // std::vector getVerticesWithOffset(int newBase) { - // std::vector newFaces; - // int offset = newBase - baseIndex; - // Eigen::Vector3i baseOffset(offset, offset, offset); - // for (Eigen::Vector3i& face : faces) { - // newFaces.emplace_back(face + baseOffset); - // } - // baseIndex = newBase; - - // return newFaces; - // } - std::vector vertices; std::vector faces; std::vector colors; - - bool destructorPrint = false; - }; class Point { @@ -141,18 +112,13 @@ class Polygon { return color; } - ~Polygon() { - if (destructorPrint) - std::cout << "Destroying a polygon" << std::endl; - } - // Works with any simple convex polygon where the points are in order virtual RenderedShape* render() const { RenderedShape * shape = new RenderedShape(); if (!isValid()) { // Should maybe throw an error - std::cerr << "Generic has incorrect number of corners" << std::endl; + std::cout << "Generic has incorrect number of corners" << std::endl; return shape; } @@ -178,7 +144,6 @@ class Polygon { unsigned int vertexMax; double layer; int id; - bool destructorPrint = false; }; class Circle : public Polygon { @@ -207,7 +172,7 @@ class Circle : public Polygon { // Add center shape->vertices.emplace_back(points[0].toVec3()); - // std::cout << "Center: " << points[0].toVec3() << std::endl; + // Add outside vertices for (int i = 0; i <= numWedges; i++) { shape->vertices.emplace_back(points[0].x() + radius * cos(2 * M_PI * i / numWedges), @@ -230,34 +195,6 @@ class Circle : public Polygon { int numWedges = 20; }; -// class Generic : public Polygon { - -// public: -// Generic(int numPoints, double layer) : Polygon(numPoints, layer) {} - -// // Assumes a simple convex polygon -// virtual RenderedShape* render() const { -// RenderedShape * shape = new RenderedShape(); - -// if (!isValid()) { -// // Should maybe throw an error -// std::cerr << "Generic has incorrect number of corners" << std::endl; -// return shape; -// } - -// for (int i = 0; i < points.size(); i++) { -// shape->vertices.emplace_back(points[i].toVec3()); -// shape->colors.emplace_back(color); -// } - -// for (int i = 1; i < points.size()-1; i++) { -// shape->faces.emplace_back(0, i, i+1); -// } - -// return shape; -// } -// }; - class Rectangle : public Polygon { public: @@ -451,7 +388,6 @@ class Table { for (Polygon* shape : staticShapes) { std::cout << "Rendering shape " << i++ << std::endl; RenderedShape *renderedShape = shape->render(); - renderedShape->destructorPrint = true; numStaticVertices += renderedShape->getNumVertices(); numStaticFaces += renderedShape->getNumFaces(); staticRenderedShapes.emplace_back(renderedShape); @@ -577,83 +513,139 @@ std::vector parseTrickResponse(std::vector list) { return ret; } -void launchViewer (igl::opengl::glfw::Viewer *viewer) { - viewer->launch(); -} - -bool mousePressed = false; -double mouseX = 0; -double mouseY = 0; - -std::queue messageQueue; -std::mutex messageLock; - -bool sendCue = false; -std::mutex renderLock; - -Eigen::MatrixXd V; -Eigen::MatrixXi F; -Eigen::MatrixXd C; -igl::opengl::glfw::imgui::ImGuiMenu* menu; - -bool mouse_down (igl::opengl::glfw::Viewer& viewer, int button, int modifier) { - mousePressed = true; - return true; -} - -bool mouse_up (igl::opengl::glfw::Viewer& viewer, int button, int modifier) { - mousePressed = false; - std::string cueRequest = ""; - std::string templateString = "dyn.table.applyCueForce(%.3f, %.3f) \n"; - - char buf[128]; - sprintf(buf, templateString.c_str(), mouseX, mouseY); - cueRequest += std::string(buf); - - messageLock.lock(); - messageQueue.push(cueRequest); - messageLock.unlock(); - - return true; -} - -bool mouse_move (igl::opengl::glfw::Viewer& viewer, int mouse_x, int mouse_y) { - Eigen::Vector3f pos(mouse_x, mouse_y, 0); - Eigen::Matrix4f model = viewer.core().view; - Eigen::Vector3f unproj = igl::unproject(pos, model, viewer.core().proj, viewer.core().viewport); - mouseX = unproj[0]; - mouseY = -unproj[1]; - return true; -} - -bool pre_draw (igl::opengl::glfw::Viewer& viewer) { - renderLock.lock(); - - viewer.data().clear(); - viewer.core().orthographic = true; - viewer.data().show_lines = false; - viewer.data().set_face_based(false); - viewer.data().double_sided = true; - viewer.core().is_animating = true; - viewer.core().camera_zoom = 2; - viewer.data().set_mesh(V, F); - viewer.data().set_colors(C); - - renderLock.unlock(); -} - -void draw_viewer_menu () { - ImGui::Text("Menu"); - if (ImGui::Button("Reset Cue Ball", ImVec2(-1, 0))) - { - std::string message = "dyn.table.resetCueBall() \n"; - messageLock.lock(); - messageQueue.push(message); - messageLock.unlock(); +std::vector parseTrickResponseInt(std::vector list) { + std::vector ret; + for (int i = 1; i < list.size(); i++) { + ret.push_back(stoi(list[i])); } - + return ret; } +// void launchViewer (igl::opengl::glfw::Viewer *viewer) { +// std::cout << "About to launch the viewer" << std::endl; +// viewer->launch(); +// } + + + +// std::queue messageQueue; +// std::mutex messageLock; + +// std::mutex renderLock; + + +// igl::opengl::glfw::imgui::ImGuiMenu* menu; + +// bool mouse_down (igl::opengl::glfw::Viewer& viewer, int button, int modifier) { +// mousePressed = true; +// return true; +// } + +// bool mouse_up (igl::opengl::glfw::Viewer& viewer, int button, int modifier) { +// mousePressed = false; +// std::string cueRequest = ""; +// std::string templateString = "dyn.table.applyCueForce(%.3f, %.3f) \n"; + +// char buf[128]; +// sprintf(buf, templateString.c_str(), mouseX, mouseY); +// cueRequest += std::string(buf); + +// messageLock.lock(); +// messageQueue.push(cueRequest); +// messageLock.unlock(); + +// return true; +// } + +// bool mouse_move (igl::opengl::glfw::Viewer& viewer, int mouse_x, int mouse_y) { +// Eigen::Vector3f pos(mouse_x, mouse_y, 0); +// Eigen::Matrix4f model = viewer.core().view; +// Eigen::Vector3f unproj = igl::unproject(pos, model, viewer.core().proj, viewer.core().viewport); +// mouseX = unproj[0]; +// mouseY = -unproj[1]; +// return true; +// } + +// bool pre_draw (igl::opengl::glfw::Viewer& viewer) { + + // std::string reply; + // socket >> reply; + + // // std::cout << "Got data: " << reply << std::endl; + // std::vector replyData = parseTrickResponse(split(reply, '\t')); + // // numBalls = (int)replyData[0]; + + // if (replyData.size() <= 1) { + // // std::cout << "Received bad reply" << std::endl; + // return false; + // } + + // table.clearMovingShapes(); + + // Eigen::Vector2d cueBallPos(0,0); + // int cueBallIndex = 0; + + + // for (int i = 0; i < numBalls; i++) { + // double inPlay = replyData[1+(i*3 + 2)]; + // if (inPlay == 0) { + // continue; + // } + // std::vector circleData = {replyData[1+(i*3)], replyData[1+(i*3 + 1)], radii[i]}; + // Eigen::Vector3d circleColor; + // if (i == cueBallIndex) { + // circleColor = Eigen::Vector3d(1,1,1); + // cueBallPos = Eigen::Vector2d(replyData[1+(i*2)], replyData[1+(i*2 + 1)]); + // } else { + // circleColor = ball_colors[i % ball_colors.size()]; + + // } + // table.addShape(circleData, circleColor, false, CIRCLE, layer_BALL); + // } + + // if (mousePressed) { + // // Draw the cue + // double cue_width = 0.03; + // Eigen::Vector2d cue_end(mouseX, mouseY); + // Eigen::Vector2d vec = (cue_end - cueBallPos).normalized(); + // Eigen::Vector2d off1(-vec(1), vec(0)); + // Eigen::Vector2d off2(vec(1), -vec(0)); + // Eigen::Vector2d point1 = cue_end + (off1 * cue_width); + // Eigen::Vector2d point2 = cue_end + (off2 * cue_width); + // std::vector triangleData = {cueBallPos(0), cueBallPos(1), point1(0), point1(1), point2(0), point2(1)}; + // table.addShape(triangleData, Eigen::Vector3d(0, 0, 0), false, TRIANGLE, layer_CUE); + // } + + // renderLock.lock(); + // std::tie(V, F, C) = table.getMesh(); + + // renderLock.lock(); + + // viewer.data().clear(); + // viewer.core().orthographic = true; + // viewer.data().show_lines = false; + // viewer.data().set_face_based(false); + // viewer.data().double_sided = true; + // viewer.core().is_animating = true; + // viewer.core().camera_zoom = 2; + // viewer.data().set_mesh(V, F); + // viewer.data().set_colors(C); + + // renderLock.unlock(); +// } + +// void draw_viewer_menu () { +// ImGui::Text("Menu"); +// if (ImGui::Button("Reset Cue Ball", ImVec2(-1, 0))) +// { +// std::string message = "dyn.table.resetCueBall() \n"; +// messageLock.lock(); +// messageQueue.push(message); +// messageLock.unlock(); +// } + +// } + int main(int argc, char *argv[]) { @@ -663,25 +655,21 @@ int main(int argc, char *argv[]) return -1; } + bool socketOn = true; int port = 0; port = std::stoi(argv[1]); if (port == 0) { - printUsage(); - return -1; + socketOn = false; } std::cout << "Port received: " << port << std::endl; - - Socket socket("localhost", port); - - socket << "trick.var_set_client_tag(\"PoolTableDisplay\") \n"; - - // Should request all the static data first - table, bumper, and pocket shapes - // Hardcoded for now - - socket << "trick.var_add(\"dyn.table.numBalls\")\ntrick.var_send() \ntrick.var_clear() \n"; + Socket socket; + socket.init("localhost", port); std::string reply; + + socket << "trick.var_set_client_tag(\"PoolTableDisplay\") \n"; + socket << "trick.var_add(\"dyn.table.numBalls\")\ntrick.var_send() \ntrick.var_clear() \n"; socket >> reply; auto parsed = split(reply, '\t'); @@ -695,24 +683,18 @@ int main(int argc, char *argv[]) sprintf(buf, templateString, i); radiusRequest += std::string(buf); } + socket << radiusRequest; socket << "trick.var_send() \ntrick.var_clear() \n"; socket >> reply; - // std::cout << "Radius reply: " << reply << std::endl; - auto radii = parseTrickResponse(split(reply, '\t')); - // To be able to account for balls being added and subtracted, probably need to request numBalls every time, and just delete the moving objects each render cycle - // Probably a more optimized way to do this - // TODO: figure that out + auto radii = parseTrickResponse(split(reply, '\t')); Table table; - - - socket << "trick.var_add(\"dyn.table.numTablePoints\") \ntrick.var_add(\"dyn.table.tableShapeType\")\n \ntrick.var_send() \ntrick.var_clear() \n"; socket >> reply; - std::cout << "Table shape reply: " << reply << std::endl; + std::vector tableData = parseTrickResponse(split(reply, '\t')); int numTablePoints = tableData[0]; enum PolygonType tableShape = PolygonType((int)tableData[1]); @@ -724,22 +706,28 @@ int main(int argc, char *argv[]) sprintf(buf, templateString, i, i); pointRequest += std::string(buf); } + socket << pointRequest; socket << "trick.var_send() \ntrick.var_clear() \n"; socket >> reply; + std::vector tablePoints = parseTrickResponse(split(reply, '\t')); table.addShape(tablePoints, Eigen::Vector3d(0.2, 0.6, 0.2), true, tableShape, layer_TABLE); + // Make the rail - translate each point on the table out from center by railWidth std::vector railData; - - if (tableShape == RECTANGLE) { + + if (tableShape == RECTANGLE) { + // If it's a rectangle then the rail is a bigger rectangle double railWidth = 0.07; railData.push_back(tablePoints[0] - railWidth); railData.push_back(tablePoints[1] - railWidth); railData.push_back(tablePoints[2] + railWidth); railData.push_back(tablePoints[3] + railWidth); } else { + // If it's just a shape then rail is bigger shape + // Works with simple convex polygons double railWidth = 0.15; for (int i = 0; i < tablePoints.size(); i+=2) { Eigen::Vector2d point(tablePoints[i], tablePoints[i+1]); @@ -753,11 +741,10 @@ int main(int argc, char *argv[]) table.addShape(railData, Eigen::Vector3d(.3, .2, .15), true, tableShape, layer_RAIL); - // Pockets - socket << "trick.var_add(\"dyn.table.numPockets\")\n \ntrick.var_send() \ntrick.var_clear() \n"; - + socket << "trick.var_add(\"dyn.table.numPockets\")\n \ntrick.var_send() \ntrick.var_clear() \n"; socket >> reply; - double numPockets = stod(split(reply, '\t')[1]); + + int numPockets = stoi(split(reply, '\t')[1]); for (int i = 0; i < numPockets; i++) { templateString = "trick.var_add(\"dyn.table.pockets[%d][0].pos._x\")\ntrick.var_add(\"dyn.table.pockets[%d][0].pos._y\")\n\ntrick.var_add(\"dyn.table.pockets[%d][0].radius\")\n"; char buf[256]; @@ -771,21 +758,14 @@ int main(int argc, char *argv[]) table.addShape(pocketData, Eigen::Vector3d(0.0, 0.0, 0.0), true, CIRCLE, layer_POCKET); } - - // std::vector table_corners = {-.5, -.25, .5, .25}; - // Eigen::Vector3d table_color(0.2, 0.6, 0.2); - // table.addShape(table_corners, table_color, true, RECTANGLE); - // Bumpers - socket << "trick.var_add(\"dyn.table.numBumpers\")\n \ntrick.var_send() \ntrick.var_clear() \n"; - socket >> reply; - double numBumpers = stod(split(reply, '\t')[1]); + + int numBumpers = stoi(split(reply, '\t')[1]); std::cout << "Num bumpers: " << numBumpers << std::endl; - //templateString = "trick.var_add(\"dyn.table.bumpers[%d][0].border.p1.x\") \ntrick.var_add(\"dyn.table.bumpers[%d][0].border.p1.y\")\ntrick.var_add(\"dyn.table.bumpers[%d][0].border.p2.x\") \ntrick.var_add(\"dyn.table.bumpers[%d][0].border.p2.y\")\n"; for (int i = 0; i < numBumpers; i++) { std::string bumperRequests = ""; @@ -796,7 +776,7 @@ int main(int argc, char *argv[]) socket << bumperRequests; socket << "trick.var_send() \ntrick.var_clear() \n"; socket >> reply; - std::vector bumperData = parseTrickResponse(split(reply, '\t')); + std::vector bumperData = parseTrickResponseInt(split(reply, '\t')); int bumperPoints = bumperData[0]; enum PolygonType bumperShape = PolygonType((int)bumperData[1]); @@ -812,7 +792,6 @@ int main(int argc, char *argv[]) socket >> reply; std::vector bumperBorder = parseTrickResponse(split(reply, '\t')); - table.addShape(bumperBorder, Eigen::Vector3d(0.2,0.4,0.2), true, bumperShape, layer_BUMPER); } @@ -830,6 +809,7 @@ int main(int argc, char *argv[]) socket << positionRequest; socket << "trick.var_send() \ntrick.var_clear() \n"; socket >> reply; + auto positions = parseTrickResponse(split(reply, '\t')); @@ -839,97 +819,65 @@ int main(int argc, char *argv[]) table.addShape(circleData, circleColor, false, CIRCLE, layer_BALL); } - renderLock.lock(); - std::tie(V, F, C) = table.getMesh(); - renderLock.unlock(); + bool mousePressed = false; + double mouseX = 0; + double mouseY = 0; - igl::opengl::glfw::Viewer * viewer = new igl::opengl::glfw::Viewer(); + Eigen::MatrixXd V; + Eigen::MatrixXi F; + Eigen::MatrixXd C; + + std::tie(V, F, C) = table.getMesh(); + + igl::opengl::glfw::Viewer * view = new igl::opengl::glfw::Viewer(); igl::opengl::glfw::imgui::ImGuiPlugin *plugin = new igl::opengl::glfw::imgui::ImGuiPlugin(); - viewer->plugins.push_back(plugin); - menu = new igl::opengl::glfw::imgui::ImGuiMenu(); + igl::opengl::glfw::imgui::ImGuiMenu *menu = new igl::opengl::glfw::imgui::ImGuiMenu(); + + view->plugins.push_back(plugin); plugin->widgets.push_back(menu); + view->callback_mouse_down = [&](igl::opengl::glfw::Viewer& viewer, int button, int modifier) -> bool { + std::cout << "Mouse down" << std::endl; + mousePressed = true; + return false; + }; - viewer->callback_mouse_down = mouse_down; - viewer->callback_mouse_up = mouse_up; - viewer->callback_mouse_move = mouse_move; - viewer->callback_pre_draw = pre_draw; - menu->callback_draw_viewer_menu = draw_viewer_menu; + view->callback_mouse_up = [&] (igl::opengl::glfw::Viewer& viewer, int button, int modifier) -> bool { + mousePressed = false; + std::string cueRequest = ""; + std::string templateString = "dyn.table.applyCueForce(%.3f, %.3f) \n"; - viewer->core().orthographic = true; - viewer->core().camera_zoom = 2; - viewer->data().show_lines = false; - viewer->data().set_face_based(false); - viewer->data().double_sided = true; - - viewer->core().is_animating = true; - - // Plot the mesh - viewer->data().set_mesh(V, F); - viewer->data().set_colors(C); - - // Viewer is blocking, have to launch it in a separate thread - std::thread viewerThread (launchViewer, viewer); - - // std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - - - std::cout << "After launch " << std::endl; - // Need to get nBalls and posititions every time - // Maybe should add some coordinating by ID logic too - socket << "trick.var_pause() \n"; - socket << "trick.var_add(\"dyn.table.numBalls\")\n"; - positionRequest = ""; - templateString = "trick.var_add(\"dyn.table.balls[%d][0].pos._x\")\ntrick.var_add(\"dyn.table.balls[%d][0].pos._y\")\ntrick.var_add(\"dyn.table.balls[%d][0].inPlay\")\n"; - for (int i = 0; i < numBalls; i++) { char buf[128]; - sprintf(buf, templateString, i, i, i); - positionRequest += std::string(buf); - } + sprintf(buf, templateString.c_str(), mouseX, mouseY); + cueRequest += std::string(buf); + socket << cueRequest; + return false; + }; + view->callback_mouse_move = [&] (igl::opengl::glfw::Viewer& viewer, int mouse_x, int mouse_y) { + Eigen::Vector3f pos(mouse_x, mouse_y, 0); + Eigen::Matrix4f model = viewer.core().view; + // Viewer is made for 3d, so we have to do math to figure out what the 2d mouse coordinates are + Eigen::Vector3f unproj = igl::unproject(pos, model, viewer.core().proj, viewer.core().viewport); + mouseX = unproj[0]; + mouseY = -unproj[1]; + return true; + }; - socket << positionRequest; - socket << "trick.var_ascii() \n"; - socket << "trick.var_cycle(0.010) \n"; - socket << "trick.var_unpause() \n"; - - int badReplies = 10; - - // Start the actual draw loop - int drawIteration = 0; - while (true) { - // std::cout << "Draw loop iteration" << drawIteration++ << std::endl; - - messageLock.lock(); - while (!messageQueue.empty()) { - std::string message = messageQueue.front(); - messageQueue.pop(); - socket.send(message); - } - messageLock.unlock(); - - std::string reply; + view->callback_pre_draw = [&](igl::opengl::glfw::Viewer& viewer) -> bool { + // Look for new data and redraw socket >> reply; - - // std::cout << "Got data: " << reply << std::endl; std::vector replyData = parseTrickResponse(split(reply, '\t')); - // numBalls = (int)replyData[0]; if (replyData.size() <= 1) { - // std::cout << "Received bad reply" << std::endl; - badReplies--; - if (badReplies > 0) - continue; - else - break; + return false; } table.clearMovingShapes(); - Eigen::Vector2d cueBallPos(0,0); + Eigen::Vector2d cueBallPos; int cueBallIndex = 0; - for (int i = 0; i < numBalls; i++) { double inPlay = replyData[1+(i*3 + 2)]; if (inPlay == 0) { @@ -942,7 +890,6 @@ int main(int argc, char *argv[]) cueBallPos = Eigen::Vector2d(replyData[1+(i*2)], replyData[1+(i*2 + 1)]); } else { circleColor = ball_colors[i % ball_colors.size()]; - } table.addShape(circleData, circleColor, false, CIRCLE, layer_BALL); } @@ -960,10 +907,61 @@ int main(int argc, char *argv[]) table.addShape(triangleData, Eigen::Vector3d(0, 0, 0), false, TRIANGLE, layer_CUE); } - renderLock.lock(); std::tie(V, F, C) = table.getMesh(); - renderLock.unlock(); - } + + viewer.data().clear(); + viewer.core().orthographic = true; + viewer.data().show_lines = false; + viewer.data().set_face_based(false); + viewer.data().double_sided = true; + viewer.core().is_animating = true; + viewer.core().camera_zoom = 2; - viewerThread.join(); + // Set mesh and colors to new positions + viewer.data().set_mesh(V, F); + viewer.data().set_colors(C); + + return false; + }; + + menu->callback_draw_viewer_menu = [&] () { + ImGui::Text("Menu"); + if (ImGui::Button("Reset Cue Ball", ImVec2(-1, 0))) + { + std::string message = "dyn.table.resetCueBall() \n"; + socket << message; + } + }; + + + // Initial viewer setup + view->core().orthographic = true; + view->core().camera_zoom = 2; + view->data().show_lines = false; + view->data().set_face_based(false); + view->data().double_sided = true; + view->core().is_animating = true; + + // Plot the mesh + view->data().set_mesh(V, F); + view->data().set_colors(C); + + // Viewer is blocking, have to launch it in a separate thread + + // Need to get nBalls and positions every time + socket << "trick.var_pause() \n"; + socket << "trick.var_add(\"dyn.table.numBalls\")\n"; + positionRequest = ""; + templateString = "trick.var_add(\"dyn.table.balls[%d][0].pos._x\")\ntrick.var_add(\"dyn.table.balls[%d][0].pos._y\")\ntrick.var_add(\"dyn.table.balls[%d][0].inPlay\")\n"; + for (int i = 0; i < numBalls; i++) { + char buf[128]; + sprintf(buf, templateString, i, i, i); + positionRequest += std::string(buf); + } + socket << positionRequest; + socket << "trick.var_ascii() \n"; + socket << "trick.var_cycle(0.010) \n"; + socket << "trick.var_unpause() \n"; + + view->launch(); } diff --git a/trick_sims/SIM_pool/models/graphics/java/src/PoolTableDisplay.java b/trick_sims/SIM_billiards/models/graphics/java/src/PoolTableDisplay.java similarity index 100% rename from trick_sims/SIM_pool/models/graphics/java/src/PoolTableDisplay.java rename to trick_sims/SIM_billiards/models/graphics/java/src/PoolTableDisplay.java diff --git a/trick_sims/SIM_pool/models/pool_table/include/ball.hh b/trick_sims/SIM_billiards/models/pool_table/include/ball.hh similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/include/ball.hh rename to trick_sims/SIM_billiards/models/pool_table/include/ball.hh diff --git a/trick_sims/SIM_pool/models/pool_table/include/bumper.hh b/trick_sims/SIM_billiards/models/pool_table/include/bumper.hh similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/include/bumper.hh rename to trick_sims/SIM_billiards/models/pool_table/include/bumper.hh diff --git a/trick_sims/SIM_pool/models/pool_table/include/common_geometry.hh b/trick_sims/SIM_billiards/models/pool_table/include/common_geometry.hh similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/include/common_geometry.hh rename to trick_sims/SIM_billiards/models/pool_table/include/common_geometry.hh diff --git a/trick_sims/SIM_pool/models/pool_table/include/pocket.hh b/trick_sims/SIM_billiards/models/pool_table/include/pocket.hh similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/include/pocket.hh rename to trick_sims/SIM_billiards/models/pool_table/include/pocket.hh diff --git a/trick_sims/SIM_pool/models/pool_table/include/pool_table.hh b/trick_sims/SIM_billiards/models/pool_table/include/pool_table.hh similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/include/pool_table.hh rename to trick_sims/SIM_billiards/models/pool_table/include/pool_table.hh diff --git a/trick_sims/SIM_pool/models/pool_table/src/ball.cpp b/trick_sims/SIM_billiards/models/pool_table/src/ball.cpp similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/src/ball.cpp rename to trick_sims/SIM_billiards/models/pool_table/src/ball.cpp diff --git a/trick_sims/SIM_pool/models/pool_table/src/bumper.cpp b/trick_sims/SIM_billiards/models/pool_table/src/bumper.cpp similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/src/bumper.cpp rename to trick_sims/SIM_billiards/models/pool_table/src/bumper.cpp diff --git a/trick_sims/SIM_pool/models/pool_table/src/pocket.cpp b/trick_sims/SIM_billiards/models/pool_table/src/pocket.cpp similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/src/pocket.cpp rename to trick_sims/SIM_billiards/models/pool_table/src/pocket.cpp diff --git a/trick_sims/SIM_pool/models/pool_table/src/pool_table.cpp b/trick_sims/SIM_billiards/models/pool_table/src/pool_table.cpp similarity index 100% rename from trick_sims/SIM_pool/models/pool_table/src/pool_table.cpp rename to trick_sims/SIM_billiards/models/pool_table/src/pool_table.cpp diff --git a/trick_sims/SIM_pool/S_overrides.mk b/trick_sims/SIM_pool/S_overrides.mk deleted file mode 100644 index 4fea3c64..00000000 --- a/trick_sims/SIM_pool/S_overrides.mk +++ /dev/null @@ -1,2 +0,0 @@ -TRICK_CFLAGS += -Imodels -I/usr/local/include/eigen3/ -TRICK_CXXFLAGS += -Imodels -I/usr/local/include/eigen3/ \ No newline at end of file diff --git a/trick_sims/SIM_pool/models/graphics/cpp/LICENSE b/trick_sims/SIM_pool/models/graphics/cpp/LICENSE deleted file mode 100644 index e87a115e..00000000 --- a/trick_sims/SIM_pool/models/graphics/cpp/LICENSE +++ /dev/null @@ -1,363 +0,0 @@ -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. "Contributor" - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. "Contributor Version" - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the terms of - a Secondary License. - -1.6. "Executable Form" - - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - - means a work that combines Covered Software with other material, in a - separate file or files, that is not Covered Software. - -1.8. "License" - - means this document. - -1.9. "Licensable" - - means having the right to grant, to the maximum extent possible, whether - at the time of the initial grant or subsequently, any and all of the - rights conveyed by this License. - -1.10. "Modifications" - - means any of the following: - - a. any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. "Patent Claims" of a Contributor - - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the License, - by the making, using, selling, offering for sale, having made, import, - or transfer of either its Contributions or its Contributor Version. - -1.12. "Secondary License" - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. "Source Code Form" - - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, "control" means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution - become effective for each Contribution on the date the Contributor first - distributes such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under - this License. No additional rights or licenses will be implied from the - distribution or licensing of Covered Software under this License. - Notwithstanding Section 2.1(b) above, no patent license is granted by a - Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of - its Contributions. - - This License does not grant any rights in the trademarks, service marks, - or logos of any Contributor (except as may be necessary to comply with - the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this - License (see Section 10.2) or under the terms of a Secondary License (if - permitted under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its - Contributions are its original creation(s) or it has sufficient rights to - grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under - applicable copyright doctrines of fair use, fair dealing, or other - equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under - the terms of this License. You must inform recipients that the Source - Code Form of the Covered Software is governed by the terms of this - License, and how they can obtain a copy of this License. You may not - attempt to alter or restrict the recipients' rights in the Source Code - Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter the - recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for - the Covered Software. If the Larger Work is a combination of Covered - Software with a work governed by one or more Secondary Licenses, and the - Covered Software is not Incompatible With Secondary Licenses, this - License permits You to additionally distribute such Covered Software - under the terms of such Secondary License(s), so that the recipient of - the Larger Work may, at their option, further distribute the Covered - Software under the terms of either this License or such Secondary - License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices - (including copyright notices, patent notices, disclaimers of warranty, or - limitations of liability) contained within the Source Code Form of the - Covered Software, except that You may alter any license notices to the - extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on - behalf of any Contributor. You must make it absolutely clear that any - such warranty, support, indemnity, or liability obligation is offered by - You alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, - judicial order, or regulation then You must: (a) comply with the terms of - this License to the maximum extent possible; and (b) describe the - limitations and the code they affect. Such description must be placed in a - text file included with all distributions of the Covered Software under - this License. Except to the extent prohibited by statute or regulation, - such description must be sufficiently detailed for a recipient of ordinary - skill to be able to understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing - basis, if such Contributor fails to notify You of the non-compliance by - some reasonable means prior to 60 days after You have come back into - compliance. Moreover, Your grants from a particular Contributor are - reinstated on an ongoing basis if such Contributor notifies You of the - non-compliance by some reasonable means, this is the first time You have - received notice of non-compliance with this License from such - Contributor, and You become compliant prior to 30 days after Your receipt - of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, - counter-claims, and cross-claims) alleging that a Contributor Version - directly or indirectly infringes any patent, then the rights granted to - You by any and all Contributors for the Covered Software under Section - 2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an "as is" basis, - without warranty of any kind, either expressed, implied, or statutory, - including, without limitation, warranties that the Covered Software is free - of defects, merchantable, fit for a particular purpose or non-infringing. - The entire risk as to the quality and performance of the Covered Software - is with You. Should any Covered Software prove defective in any respect, - You (not any Contributor) assume the cost of any necessary servicing, - repair, or correction. This disclaimer of warranty constitutes an essential - part of this License. No use of any Covered Software is authorized under - this License except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from - such party's negligence to the extent applicable law prohibits such - limitation. Some jurisdictions do not allow the exclusion or limitation of - incidental or consequential damages, so this exclusion and limitation may - not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts - of a jurisdiction where the defendant maintains its principal place of - business and such litigation shall be governed by laws of that - jurisdiction, without reference to its conflict-of-law provisions. Nothing - in this Section shall prevent a party's ability to bring cross-claims or - counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. Any law or regulation which provides that - the language of a contract shall be construed against the drafter shall not - be used to construe this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version - of the License under which You originally received the Covered Software, - or under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a - modified version of this License if you rename the license and remove - any references to the name of the license steward (except to note that - such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary - Licenses If You choose to distribute Source Code Form that is - Incompatible With Secondary Licenses under the terms of this version of - the License, the notice described in Exhibit B of this License must be - attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, -then You may include the notice in a location (such as a LICENSE file in a -relevant directory) where a recipient would be likely to look for such a -notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice - - This Source Code Form is "Incompatible - With Secondary Licenses", as defined by - the Mozilla Public License, v. 2.0. - diff --git a/trick_sims/SIM_pool/models/graphics/java/Makefile b/trick_sims/SIM_pool/models/graphics/java/Makefile deleted file mode 100644 index 55e5e663..00000000 --- a/trick_sims/SIM_pool/models/graphics/java/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -SHELL = /bin/sh - -PROJECT_NAME = PoolTableDisplay -SRC_DIR = src -BUILD_DIR = build -CLASSES_DIR = $(BUILD_DIR)/classes -JAR_DIR = dist -MAIN_CLASS = PoolTableDisplay - -all: jar - -clean: - rm -rf $(BUILD_DIR) - rm -f manifest - -spotless: clean - rm -rf dist - -$(CLASSES_DIR): - @ mkdir -p $(CLASSES_DIR) - -compile: | $(CLASSES_DIR) - javac -sourcepath $(SRC_DIR) -d $(CLASSES_DIR) $(SRC_DIR)/PoolTableDisplay.java - -manifest: - @ echo "Main-Class: $(MAIN_CLASS)" > $@ - -$(JAR_DIR): - @ mkdir -p $(JAR_DIR) - -jar: compile manifest | $(JAR_DIR) - jar cvfm $(JAR_DIR)/$(PROJECT_NAME).jar manifest -C $(CLASSES_DIR) . - @ echo "-------------------------------------------------------------------------------" - @ echo " BUILD COMPLETE" - @ echo "The Java jar file (the Java Executable) is located at: $(JAR_DIR)/$(PROJECT_NAME).jar" - @ echo "-------------------------------------------------------------------------------" diff --git a/trick_sims/SIM_pool/models/graphics/java/dist/PoolTableDisplay.jar b/trick_sims/SIM_pool/models/graphics/java/dist/PoolTableDisplay.jar deleted file mode 100644 index 9de0aeaa35fddc5f4ed8ba97f4cca20db4ffc6e3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6493 zcmaKw1yCGao3?QcKDbNJVQ>vj7<6!l;2zvP!EG4aJr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y*ja0BMWM?;KAkyG zwsO}o*{ba5yhOG<-fWMZ9ua3DQ1P8#vJ&=tk!A(a{6jfymOPcX_xqm7pOhv_ z_$o|R6>#SLKC!+UJI!mB>5R-Sd3_8x_7~MzmE#nSVr-%=GRKY9>$gG0^hP|hO4CjX;TsXX-N^000{pb>HmLT{|D*+cm0de{{j5} zwEi8X{{i}cN&NTlU)I0j{eM2;?^yK@a{o&kzlVPT_<#ET4p06-*S|!B{J$aCfBOI4 yqyIrHf5{sCe*l+%n*aVa|FrRcNdo8JHTCMssJ}T60s`9a!}~W!o+JHp_5T29KzCdK diff --git a/trick_sims/SIM_pool/models/graphics/java/manifest b/trick_sims/SIM_pool/models/graphics/java/manifest deleted file mode 100644 index 5c286ff4..00000000 --- a/trick_sims/SIM_pool/models/graphics/java/manifest +++ /dev/null @@ -1 +0,0 @@ -Main-Class: PoolTableDisplay diff --git a/trick_sims/SIM_pool/models/graphics/libigl-example-project b/trick_sims/SIM_pool/models/graphics/libigl-example-project deleted file mode 160000 index a9b087f9..00000000 --- a/trick_sims/SIM_pool/models/graphics/libigl-example-project +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a9b087f9d8e9cce32ab68705128164cd5d4ad81a