mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
some changes and bugfixes
This commit is contained in:
+13
-11
@@ -35,15 +35,17 @@ namespace vb01{
|
|||||||
mat4 proj = perspective(radians(fov), width / height, nearPlane, farPlane);
|
mat4 proj = perspective(radians(fov), width / height, nearPlane, farPlane);
|
||||||
|
|
||||||
for(Line &l : lines){
|
for(Line &l : lines){
|
||||||
shader->use();
|
if(l.visible){
|
||||||
shader->setVec3(l.color, "color");
|
shader->use();
|
||||||
shader->setMat4(proj, "proj");
|
shader->setVec3(l.color, "color");
|
||||||
shader->setMat4(view, "view");
|
shader->setMat4(proj, "proj");
|
||||||
|
shader->setMat4(view, "view");
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glVertex3f(l.start.x, l.start.y, l.start.z);
|
glVertex3f(l.start.x, l.start.y, l.start.z);
|
||||||
glVertex3f(l.end.x, l.end.y, l.end.z);
|
glVertex3f(l.end.x, l.end.y, l.end.z);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,9 +83,9 @@ namespace vb01{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LineRenderer::removeLine(int id){
|
void LineRenderer::removeLine(int id){
|
||||||
for(Line &l : lines)
|
for(int i = 0; i < lines.size(); ++i)
|
||||||
if(l.id == id){
|
if(lines[i].id == id){
|
||||||
lines.erase(lines.begin() + id);
|
lines.erase(lines.begin() + i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -11,15 +11,17 @@ namespace vb01{
|
|||||||
|
|
||||||
class LineRenderer{
|
class LineRenderer{
|
||||||
public:
|
public:
|
||||||
struct Line{int id; Vector3 start; Vector3 end; Vector3 color;};
|
struct Line{int id; Vector3 start; Vector3 end; Vector3 color; bool visible = true;};
|
||||||
enum VectorFieldType{START, END, COLOR};
|
enum VectorFieldType{START, END, COLOR};
|
||||||
|
|
||||||
static LineRenderer* getSingleton();
|
static LineRenderer* getSingleton();
|
||||||
void drawLines();
|
void drawLines();
|
||||||
void addLine(Vector3 start, Vector3 end, Vector3 color);
|
void addLine(Vector3 start, Vector3 end, Vector3 color);
|
||||||
void changeLineField(int, Vector3, VectorFieldType);
|
void changeLineField(int, Vector3, VectorFieldType);
|
||||||
|
void toggleVisibility(int i, bool v){getLine(i).visible = v;}
|
||||||
void removeLine(int);
|
void removeLine(int);
|
||||||
Line& getLine(int);
|
Line& getLine(int);
|
||||||
|
inline std::vector<Line>& getLines(){return lines;}
|
||||||
private:
|
private:
|
||||||
LineRenderer();
|
LineRenderer();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user