feat(renderer): added cylinder for hinges
This commit is contained in:
parent
d100932a9e
commit
dcc1f64354
6 changed files with 210 additions and 7 deletions
|
@ -46,5 +46,5 @@ void main()
|
||||||
aNormal == vec3(0, 0, 1) ? FaceBack : -1;
|
aNormal == vec3(0, 0, 1) ? FaceBack : -1;
|
||||||
|
|
||||||
vSurfaceZ = surfaces[vFace];
|
vSurfaceZ = surfaces[vFace];
|
||||||
// if (surfaces[vFace] > SurfaceUniversal) vSurfaceZ = 0;
|
if (surfaces[vFace] > SurfaceUniversal) vSurfaceZ = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,8 @@ public:
|
||||||
[[ def_prop(name="BackSurface", category=SURFACE) ]]
|
[[ def_prop(name="BackSurface", category=SURFACE) ]]
|
||||||
SurfaceType backSurface = SurfaceType::SurfaceSmooth;
|
SurfaceType backSurface = SurfaceType::SurfaceSmooth;
|
||||||
|
|
||||||
|
inline SurfaceType GetSurfaceFromFace(NormalId face) { return surfaceFromFace(face); }
|
||||||
|
|
||||||
Part();
|
Part();
|
||||||
Part(PartConstructParams params);
|
Part(PartConstructParams params);
|
||||||
~Part() override;
|
~Part() override;
|
||||||
|
|
|
@ -1589,16 +1589,156 @@ static float OUTLINE_VERTICES[] = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static float CYLINDER_VERTICES[] = {
|
||||||
|
// positions // normals // texture coords
|
||||||
|
|
||||||
|
0.0, -0.5, -0.5, 0.2588, -0.9659, -0.0, 1.0, 1.0,
|
||||||
|
0.25, -0.4330125, 0.5, 0.2588, -0.9659, -0.0, 0.916667, 0.5,
|
||||||
|
0.0, -0.5, 0.5, 0.2588, -0.9659, -0.0, 1.0, 0.5,
|
||||||
|
0.25, -0.4330125, -0.5, 0.7071, -0.7071, -0.0, 0.916667, 1.0,
|
||||||
|
0.4330125, -0.25, 0.5, 0.7071, -0.7071, -0.0, 0.833333, 0.5,
|
||||||
|
0.25, -0.4330125, 0.5, 0.7071, -0.7071, -0.0, 0.916667, 0.5,
|
||||||
|
0.4330125, -0.25, -0.5, 0.9659, -0.2588, -0.0, 0.833333, 1.0,
|
||||||
|
0.5, 0.0, 0.5, 0.9659, -0.2588, -0.0, 0.75, 0.5,
|
||||||
|
0.4330125, -0.25, 0.5, 0.9659, -0.2588, -0.0, 0.833333, 0.5,
|
||||||
|
0.5, 0.0, -0.5, 0.9659, 0.2588, -0.0, 0.75, 1.0,
|
||||||
|
0.4330125, 0.25, 0.5, 0.9659, 0.2588, -0.0, 0.666667, 0.5,
|
||||||
|
0.5, 0.0, 0.5, 0.9659, 0.2588, -0.0, 0.75, 0.5,
|
||||||
|
0.4330125, 0.25, -0.5, 0.7071, 0.7071, -0.0, 0.666667, 1.0,
|
||||||
|
0.25, 0.4330125, 0.5, 0.7071, 0.7071, -0.0, 0.583333, 0.5,
|
||||||
|
0.4330125, 0.25, 0.5, 0.7071, 0.7071, -0.0, 0.666667, 0.5,
|
||||||
|
0.25, 0.4330125, -0.5, 0.2588, 0.9659, -0.0, 0.583333, 1.0,
|
||||||
|
0.0, 0.5, 0.5, 0.2588, 0.9659, -0.0, 0.5, 0.5,
|
||||||
|
0.25, 0.4330125, 0.5, 0.2588, 0.9659, -0.0, 0.583333, 0.5,
|
||||||
|
0.0, 0.5, -0.5, -0.2588, 0.9659, -0.0, 0.5, 1.0,
|
||||||
|
-0.25, 0.4330125, 0.5, -0.2588, 0.9659, -0.0, 0.416667, 0.5,
|
||||||
|
0.0, 0.5, 0.5, -0.2588, 0.9659, -0.0, 0.5, 0.5,
|
||||||
|
-0.25, 0.4330125, -0.5, -0.7071, 0.7071, -0.0, 0.416667, 1.0,
|
||||||
|
-0.4330125, 0.25, 0.5, -0.7071, 0.7071, -0.0, 0.333333, 0.5,
|
||||||
|
-0.25, 0.4330125, 0.5, -0.7071, 0.7071, -0.0, 0.416667, 0.5,
|
||||||
|
-0.4330125, 0.25, -0.5, -0.9659, 0.2588, -0.0, 0.333333, 1.0,
|
||||||
|
-0.5, 0.0, 0.5, -0.9659, 0.2588, -0.0, 0.25, 0.5,
|
||||||
|
-0.4330125, 0.25, 0.5, -0.9659, 0.2588, -0.0, 0.333333, 0.5,
|
||||||
|
-0.5, 0.0, -0.5, -0.9659, -0.2588, -0.0, 0.25, 1.0,
|
||||||
|
-0.4330125, -0.25, 0.5, -0.9659, -0.2588, -0.0, 0.166667, 0.5,
|
||||||
|
-0.5, 0.0, 0.5, -0.9659, -0.2588, -0.0, 0.25, 0.5,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.37,
|
||||||
|
0.0, 0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.01,
|
||||||
|
0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.457846, 0.37,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.7071, -0.7071, -0.0, 0.166667, 1.0,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.7071, -0.7071, -0.0, 0.083333, 0.5,
|
||||||
|
-0.4330125, -0.25, 0.5, -0.7071, -0.7071, -0.0, 0.166667, 0.5,
|
||||||
|
-0.25, -0.4330125, -0.5, -0.2588, -0.9659, -0.0, 0.083333, 1.0,
|
||||||
|
0.0, -0.5, 0.5, -0.2588, -0.9659, -0.0, 0.0, 0.5,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.2588, -0.9659, -0.0, 0.083333, 0.5,
|
||||||
|
0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.99, 0.25,
|
||||||
|
-0.25, 0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.042154,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.457846,
|
||||||
|
0.0, -0.5, -0.5, 0.2588, -0.9659, -0.0, 1.0, 1.0,
|
||||||
|
0.25, -0.4330125, -0.5, 0.2588, -0.9659, -0.0, 0.916667, 1.0,
|
||||||
|
0.25, -0.4330125, 0.5, 0.2588, -0.9659, -0.0, 0.916667, 0.5,
|
||||||
|
0.25, -0.4330125, -0.5, 0.7071, -0.7071, -0.0, 0.916667, 1.0,
|
||||||
|
0.4330125, -0.25, -0.5, 0.7071, -0.7071, -0.0, 0.833333, 1.0,
|
||||||
|
0.4330125, -0.25, 0.5, 0.7071, -0.7071, -0.0, 0.833333, 0.5,
|
||||||
|
0.4330125, -0.25, -0.5, 0.9659, -0.2588, -0.0, 0.833333, 1.0,
|
||||||
|
0.5, 0.0, -0.5, 0.9659, -0.2588, -0.0, 0.75, 1.0,
|
||||||
|
0.5, 0.0, 0.5, 0.9659, -0.2588, -0.0, 0.75, 0.5,
|
||||||
|
0.5, 0.0, -0.5, 0.9659, 0.2588, -0.0, 0.75, 1.0,
|
||||||
|
0.4330125, 0.25, -0.5, 0.9659, 0.2588, -0.0, 0.666667, 1.0,
|
||||||
|
0.4330125, 0.25, 0.5, 0.9659, 0.2588, -0.0, 0.666667, 0.5,
|
||||||
|
0.4330125, 0.25, -0.5, 0.7071, 0.7071, -0.0, 0.666667, 1.0,
|
||||||
|
0.25, 0.4330125, -0.5, 0.7071, 0.7071, -0.0, 0.583333, 1.0,
|
||||||
|
0.25, 0.4330125, 0.5, 0.7071, 0.7071, -0.0, 0.583333, 0.5,
|
||||||
|
0.25, 0.4330125, -0.5, 0.2588, 0.9659, -0.0, 0.583333, 1.0,
|
||||||
|
0.0, 0.5, -0.5, 0.2588, 0.9659, -0.0, 0.5, 1.0,
|
||||||
|
0.0, 0.5, 0.5, 0.2588, 0.9659, -0.0, 0.5, 0.5,
|
||||||
|
0.0, 0.5, -0.5, -0.2588, 0.9659, -0.0, 0.5, 1.0,
|
||||||
|
-0.25, 0.4330125, -0.5, -0.2588, 0.9659, -0.0, 0.416667, 1.0,
|
||||||
|
-0.25, 0.4330125, 0.5, -0.2588, 0.9659, -0.0, 0.416667, 0.5,
|
||||||
|
-0.25, 0.4330125, -0.5, -0.7071, 0.7071, -0.0, 0.416667, 1.0,
|
||||||
|
-0.4330125, 0.25, -0.5, -0.7071, 0.7071, -0.0, 0.333333, 1.0,
|
||||||
|
-0.4330125, 0.25, 0.5, -0.7071, 0.7071, -0.0, 0.333333, 0.5,
|
||||||
|
-0.4330125, 0.25, -0.5, -0.9659, 0.2588, -0.0, 0.333333, 1.0,
|
||||||
|
-0.5, 0.0, -0.5, -0.9659, 0.2588, -0.0, 0.25, 1.0,
|
||||||
|
-0.5, 0.0, 0.5, -0.9659, 0.2588, -0.0, 0.25, 0.5,
|
||||||
|
-0.5, 0.0, -0.5, -0.9659, -0.2588, -0.0, 0.25, 1.0,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.9659, -0.2588, -0.0, 0.166667, 1.0,
|
||||||
|
-0.4330125, -0.25, 0.5, -0.9659, -0.2588, -0.0, 0.166667, 0.5,
|
||||||
|
0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.457846, 0.37,
|
||||||
|
0.25, -0.4330125, -0.5, -0.0, -0.0, -1.0, 0.37, 0.457846,
|
||||||
|
0.0, -0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.49,
|
||||||
|
0.0, -0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.49,
|
||||||
|
-0.25, -0.4330125, -0.5, -0.0, -0.0, -1.0, 0.13, 0.457846,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.37,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.37,
|
||||||
|
-0.5, 0.0, -0.5, -0.0, -0.0, -1.0, 0.01, 0.25,
|
||||||
|
-0.4330125, 0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.13,
|
||||||
|
-0.4330125, 0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.13,
|
||||||
|
-0.25, 0.4330125, -0.5, -0.0, -0.0, -1.0, 0.13, 0.042154,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.37,
|
||||||
|
-0.25, 0.4330125, -0.5, -0.0, -0.0, -1.0, 0.13, 0.042154,
|
||||||
|
0.0, 0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.01,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.37,
|
||||||
|
0.0, 0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.01,
|
||||||
|
0.25, 0.4330125, -0.5, -0.0, -0.0, -1.0, 0.37, 0.042154,
|
||||||
|
0.4330125, 0.25, -0.5, -0.0, -0.0, -1.0, 0.457846, 0.13,
|
||||||
|
0.4330125, 0.25, -0.5, -0.0, -0.0, -1.0, 0.457846, 0.13,
|
||||||
|
0.5, 0.0, -0.5, -0.0, -0.0, -1.0, 0.49, 0.25,
|
||||||
|
0.0, 0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.01,
|
||||||
|
0.5, 0.0, -0.5, -0.0, -0.0, -1.0, 0.49, 0.25,
|
||||||
|
0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.457846, 0.37,
|
||||||
|
0.0, 0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.01,
|
||||||
|
0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.457846, 0.37,
|
||||||
|
0.0, -0.5, -0.5, -0.0, -0.0, -1.0, 0.25, 0.49,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.0, -0.0, -1.0, 0.042154, 0.37,
|
||||||
|
-0.4330125, -0.25, -0.5, -0.7071, -0.7071, -0.0, 0.166667, 1.0,
|
||||||
|
-0.25, -0.4330125, -0.5, -0.7071, -0.7071, -0.0, 0.083333, 1.0,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.7071, -0.7071, -0.0, 0.083333, 0.5,
|
||||||
|
-0.25, -0.4330125, -0.5, -0.2588, -0.9659, -0.0, 0.083333, 1.0,
|
||||||
|
0.0, -0.5, -0.5, -0.2588, -0.9659, -0.0, 0.0, 1.0,
|
||||||
|
0.0, -0.5, 0.5, -0.2588, -0.9659, -0.0, 0.0, 0.5,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.457846,
|
||||||
|
0.0, -0.5, 0.5, -0.0, -0.0, 1.0, 0.75, 0.49,
|
||||||
|
0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.87, 0.457846,
|
||||||
|
0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.87, 0.457846,
|
||||||
|
0.4330125, -0.25, 0.5, -0.0, -0.0, 1.0, 0.957846, 0.37,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.457846,
|
||||||
|
0.4330125, -0.25, 0.5, -0.0, -0.0, 1.0, 0.957846, 0.37,
|
||||||
|
0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.99, 0.25,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.457846,
|
||||||
|
0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.99, 0.25,
|
||||||
|
0.4330125, 0.25, 0.5, -0.0, -0.0, 1.0, 0.957846, 0.13,
|
||||||
|
0.25, 0.4330125, 0.5, -0.0, -0.0, 1.0, 0.87, 0.042154,
|
||||||
|
0.25, 0.4330125, 0.5, -0.0, -0.0, 1.0, 0.87, 0.042154,
|
||||||
|
0.0, 0.5, 0.5, -0.0, -0.0, 1.0, 0.75, 0.01,
|
||||||
|
0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.99, 0.25,
|
||||||
|
0.0, 0.5, 0.5, -0.0, -0.0, 1.0, 0.75, 0.01,
|
||||||
|
-0.25, 0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.042154,
|
||||||
|
0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.99, 0.25,
|
||||||
|
-0.25, 0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.042154,
|
||||||
|
-0.4330125, 0.25, 0.5, -0.0, -0.0, 1.0, 0.542154, 0.13,
|
||||||
|
-0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.51, 0.25,
|
||||||
|
-0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.51, 0.25,
|
||||||
|
-0.4330125, -0.25, 0.5, -0.0, -0.0, 1.0, 0.542154, 0.37,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.457846,
|
||||||
|
-0.25, 0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.042154,
|
||||||
|
-0.5, 0.0, 0.5, -0.0, -0.0, 1.0, 0.51, 0.25,
|
||||||
|
-0.25, -0.4330125, 0.5, -0.0, -0.0, 1.0, 0.63, 0.457846,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
Mesh* CUBE_MESH;
|
Mesh* CUBE_MESH;
|
||||||
Mesh* SPHERE_MESH;
|
Mesh* SPHERE_MESH;
|
||||||
Mesh* ARROW_MESH;
|
Mesh* ARROW_MESH;
|
||||||
Mesh* OUTLINE_MESH;
|
Mesh* OUTLINE_MESH;
|
||||||
|
Mesh* CYLINDER_MESH;
|
||||||
|
|
||||||
void initMeshes() {
|
void initMeshes() {
|
||||||
CUBE_MESH = new Mesh(sizeof(CUBE_VERTICES) / sizeof(float) / 8, CUBE_VERTICES);
|
CUBE_MESH = new Mesh(sizeof(CUBE_VERTICES) / sizeof(float) / 8, CUBE_VERTICES);
|
||||||
SPHERE_MESH = new Mesh(sizeof(SPHERE_VERTICES) / sizeof(float) / 8, SPHERE_VERTICES);
|
SPHERE_MESH = new Mesh(sizeof(SPHERE_VERTICES) / sizeof(float) / 8, SPHERE_VERTICES);
|
||||||
ARROW_MESH = new Mesh(sizeof(ARROW_VERTICES) / sizeof(float) / 8, ARROW_VERTICES);
|
ARROW_MESH = new Mesh(sizeof(ARROW_VERTICES) / sizeof(float) / 8, ARROW_VERTICES);
|
||||||
OUTLINE_MESH = new Mesh(sizeof(OUTLINE_VERTICES) / sizeof(float) / 8, OUTLINE_VERTICES);
|
OUTLINE_MESH = new Mesh(sizeof(OUTLINE_VERTICES) / sizeof(float) / 8, OUTLINE_VERTICES);
|
||||||
|
CYLINDER_MESH = new Mesh(sizeof(CYLINDER_VERTICES) / sizeof(float) / 8, CYLINDER_VERTICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Python generator:
|
/* Python generator:
|
||||||
|
|
|
@ -5,5 +5,6 @@ extern Mesh* CUBE_MESH;
|
||||||
extern Mesh* SPHERE_MESH;
|
extern Mesh* SPHERE_MESH;
|
||||||
extern Mesh* ARROW_MESH;
|
extern Mesh* ARROW_MESH;
|
||||||
extern Mesh* OUTLINE_MESH;
|
extern Mesh* OUTLINE_MESH;
|
||||||
|
extern Mesh* CYLINDER_MESH;
|
||||||
|
|
||||||
void initMeshes();
|
void initMeshes();
|
|
@ -11,9 +11,11 @@
|
||||||
#include <glm/gtc/quaternion.hpp>
|
#include <glm/gtc/quaternion.hpp>
|
||||||
#include <glm/trigonometric.hpp>
|
#include <glm/trigonometric.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "datatypes/cframe.h"
|
#include "datatypes/cframe.h"
|
||||||
|
#include "datatypes/color3.h"
|
||||||
#include "objects/handles.h"
|
#include "objects/handles.h"
|
||||||
#include "rendering/torus.h"
|
#include "rendering/torus.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
@ -191,6 +193,58 @@ void renderParts() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Vector3 FACES[6] = {
|
||||||
|
{1, 0, 0},
|
||||||
|
{0, 1, 0},
|
||||||
|
{0, 0, 1},
|
||||||
|
{-1, 0, 0},
|
||||||
|
{0, -1, 0},
|
||||||
|
{0, 0, -1},
|
||||||
|
};
|
||||||
|
|
||||||
|
void renderSurfaceExtras() {
|
||||||
|
glDepthMask(GL_TRUE);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
glCullFace(GL_BACK);
|
||||||
|
glFrontFace(GL_CCW);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
// Use shader
|
||||||
|
ghostShader->use();
|
||||||
|
|
||||||
|
// view/projection transformations
|
||||||
|
glm::mat4 projection = glm::perspective(glm::radians(45.f), (float)viewportWidth / (float)viewportHeight, 0.1f, 1000.0f);
|
||||||
|
glm::mat4 view = camera.getLookAt();
|
||||||
|
ghostShader->set("projection", projection);
|
||||||
|
ghostShader->set("view", view);
|
||||||
|
ghostShader->set("color", glm::vec3(0.87f, 0.87f, 0.0f));
|
||||||
|
|
||||||
|
// Pass in the camera position
|
||||||
|
ghostShader->set("viewPos", camera.cameraPos);
|
||||||
|
|
||||||
|
for (auto it = gWorkspace()->GetDescendantsStart(); it != gWorkspace()->GetDescendantsEnd(); it++) {
|
||||||
|
InstanceRef inst = *it;
|
||||||
|
if (!inst->IsA("Part")) continue;
|
||||||
|
std::shared_ptr<Part> part = std::dynamic_pointer_cast<Part>(inst);
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
NormalId face = (NormalId)i;
|
||||||
|
SurfaceType type = part->GetSurfaceFromFace(face);
|
||||||
|
if (type <= SurfaceType::SurfaceUniversal) continue;
|
||||||
|
|
||||||
|
Vector3 surfaceCenter = part->cframe * (normalFromFace(face) * part->size / 2.f);
|
||||||
|
|
||||||
|
glm::mat4 model = CFrame::pointToward(surfaceCenter, part->cframe.Rotation() * normalFromFace(face));
|
||||||
|
model = glm::scale(model, glm::vec3(0.4,0.4,0.4));
|
||||||
|
ghostShader->set("model", model);
|
||||||
|
glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model)));
|
||||||
|
|
||||||
|
CYLINDER_MESH->bind();
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, CYLINDER_MESH->vertexCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void renderSkyBox() {
|
void renderSkyBox() {
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glCullFace(GL_FRONT);
|
glCullFace(GL_FRONT);
|
||||||
|
@ -454,7 +508,7 @@ void renderRotationArcs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CFrame> DEBUG_CFRAMES;
|
std::vector<std::pair<CFrame, Color3>> DEBUG_CFRAMES;
|
||||||
|
|
||||||
void renderDebugCFrames() {
|
void renderDebugCFrames() {
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
@ -480,12 +534,12 @@ void renderDebugCFrames() {
|
||||||
// Pass in the camera position
|
// Pass in the camera position
|
||||||
handleShader->set("viewPos", camera.cameraPos);
|
handleShader->set("viewPos", camera.cameraPos);
|
||||||
|
|
||||||
for (CFrame frame : DEBUG_CFRAMES) {
|
for (auto& [frame, color] : DEBUG_CFRAMES) {
|
||||||
glm::mat4 model = frame;
|
glm::mat4 model = frame;
|
||||||
model = glm::scale(model, glm::vec3(0.5, 0.5, 1.5));
|
model = glm::scale(model, glm::vec3(0.5, 0.5, 1.5));
|
||||||
handleShader->set("model", model);
|
handleShader->set("model", model);
|
||||||
handleShader->set("material", Material {
|
handleShader->set("material", Material {
|
||||||
.diffuse = glm::vec3(0.0f, 0.0f, 1.0f),
|
.diffuse = color,
|
||||||
.specular = glm::vec3(0.5f, 0.5f, 0.5f),
|
.specular = glm::vec3(0.5f, 0.5f, 0.5f),
|
||||||
.shininess = 16.0f,
|
.shininess = 16.0f,
|
||||||
});
|
});
|
||||||
|
@ -498,7 +552,11 @@ void renderDebugCFrames() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addDebugRenderCFrame(CFrame frame) {
|
void addDebugRenderCFrame(CFrame frame) {
|
||||||
DEBUG_CFRAMES.push_back(frame);
|
addDebugRenderCFrame(frame, Color3(0, 0, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
void addDebugRenderCFrame(CFrame frame, Color3 color) {
|
||||||
|
DEBUG_CFRAMES.push_back(std::make_pair(frame, color));
|
||||||
}
|
}
|
||||||
|
|
||||||
void render(GLFWwindow* window) {
|
void render(GLFWwindow* window) {
|
||||||
|
@ -509,6 +567,7 @@ void render(GLFWwindow* window) {
|
||||||
renderHandles();
|
renderHandles();
|
||||||
renderDebugCFrames();
|
renderDebugCFrames();
|
||||||
renderParts();
|
renderParts();
|
||||||
|
renderSurfaceExtras();
|
||||||
renderOutlines();
|
renderOutlines();
|
||||||
renderRotationArcs();
|
renderRotationArcs();
|
||||||
if (wireframeRendering)
|
if (wireframeRendering)
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
extern bool wireframeRendering;
|
extern bool wireframeRendering;
|
||||||
|
|
||||||
namespace Data { class CFrame; };
|
namespace Data { class CFrame; class Color3; };
|
||||||
|
|
||||||
void renderInit(GLFWwindow* window, int width, int height);
|
void renderInit(GLFWwindow* window, int width, int height);
|
||||||
void render(GLFWwindow* window);
|
void render(GLFWwindow* window);
|
||||||
void setViewport(int width, int height);
|
void setViewport(int width, int height);
|
||||||
void addDebugRenderCFrame(Data::CFrame);
|
void addDebugRenderCFrame(Data::CFrame);
|
||||||
|
void addDebugRenderCFrame(Data::CFrame, Data::Color3);
|
Loading…
Add table
Reference in a new issue