mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 21:27:54 +00:00
Refactor graphics client to run in a single thread; remove extraneous files
This commit is contained in:
parent
ad5be89c4a
commit
ff18faf6dc
2
trick_sims/.gitignore
vendored
2
trick_sims/.gitignore
vendored
@ -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
|
||||
|
@ -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):
|
@ -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)
|
||||
|
||||
#==========================================
|
2
trick_sims/SIM_billiards/S_overrides.mk
Normal file
2
trick_sims/SIM_billiards/S_overrides.mk
Normal file
@ -0,0 +1,2 @@
|
||||
TRICK_CFLAGS += -Imodels
|
||||
TRICK_CXXFLAGS += -Imodels
|
@ -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 ..
|
@ -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) {
|
@ -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;
|
||||
|
||||
};
|
@ -1,5 +1,5 @@
|
||||
#include <igl/opengl/glfw/Viewer.h>
|
||||
#include <igl/readOFF.h>
|
||||
// #include <igl/readOFF.h>
|
||||
#include <igl/opengl/glfw/imgui/ImGuiPlugin.h>
|
||||
#include <igl/opengl/glfw/imgui/ImGuiMenu.h>
|
||||
#include <igl/opengl/glfw/imgui/ImGuiHelpers.h>
|
||||
@ -10,29 +10,21 @@
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <queue>
|
||||
|
||||
#include "Socket.hh"
|
||||
|
||||
// #include <sys/types.h>
|
||||
// #include <sys/socket.h>
|
||||
// #include <netinet/in.h>
|
||||
// #include <unistd.h>
|
||||
// #include <arpa/inet.h>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
std::vector<Eigen::Vector3d> ball_colors = {Eigen::Vector3d(1.0,1.0,0.0), //yellow
|
||||
std::vector<Eigen::Vector3d> 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<Eigen::Vector3i> getFacesWithBaseIndex(int newBase) {
|
||||
std::vector<Eigen::Vector3i> 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<Eigen::Vector3d> getVerticesWithOffset(int newBase) {
|
||||
// std::vector<Eigen::Vector3i> 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<Eigen::Vector3d> vertices;
|
||||
std::vector<Eigen::Vector3i> faces;
|
||||
std::vector<Eigen::Vector3d> 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<double> parseTrickResponse(std::vector<std::string> list) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void launchViewer (igl::opengl::glfw::Viewer *viewer) {
|
||||
viewer->launch();
|
||||
}
|
||||
|
||||
bool mousePressed = false;
|
||||
double mouseX = 0;
|
||||
double mouseY = 0;
|
||||
|
||||
std::queue<std::string> 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<int> parseTrickResponseInt(std::vector<std::string> list) {
|
||||
std::vector<int> 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<std::string> 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<double> 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<double> 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<double> 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<double> 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<double> 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<double> 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<double> 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<double> bumperData = parseTrickResponse(split(reply, '\t'));
|
||||
std::vector<int> 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<double> 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<double> 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();
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
TRICK_CFLAGS += -Imodels -I/usr/local/include/eigen3/
|
||||
TRICK_CXXFLAGS += -Imodels -I/usr/local/include/eigen3/
|
@ -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.
|
||||
|
@ -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 "-------------------------------------------------------------------------------"
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
Main-Class: PoolTableDisplay
|
@ -1 +0,0 @@
|
||||
Subproject commit a9b087f9d8e9cce32ab68705128164cd5d4ad81a
|
Loading…
Reference in New Issue
Block a user