Buran Motion Planning Framework
|
3 #include <QOpenGLWidget>
5 #include <QOpenGLFunctions>
6 #include <QOpenGLVertexArrayObject>
7 #include <QOpenGLBuffer>
9 #include <QtWidgets/QSlider>
10 #include <QOpenGLShaderProgram>
24 class QTGLWidget :
public QOpenGLWidget,
protected QOpenGLFunctions {
31 explicit QTGLWidget(QWidget *parent =
nullptr);
48 QSize
sizeHint()
const Q_DECL_OVERRIDE;
73 virtual void init() = 0;
78 virtual void paint() = 0;
170 static const char *vertexShaderSourceCore =
175 "out vec3 vertNormal;\n"
176 "uniform mat4 projMatrix;\n"
177 "uniform mat4 mvMatrix;\n"
178 "uniform mat3 normalMatrix;\n"
180 " vert = vertex.xyz;\n"
181 " vertNormal = normalMatrix * normal;\n"
182 " gl_Position = projMatrix * mvMatrix * vertex;\n"
188 static const char *fragmentShaderSourceCore =
190 "in highp vec3 vert;\n"
191 "in highp vec3 vertNormal;\n"
192 "out highp vec4 fragColor;\n"
193 "uniform highp vec3 lightPos;\n"
195 " highp vec3 L = normalize(lightPos - vert);\n"
196 " highp float NL = max(dot(normalize(vertNormal), L), 0.0);\n"
197 " highp vec3 color = vec3(0.39, 1.0, 0.0);\n"
198 " highp vec3 col = clamp(color * 0.2 + color * 0.8 * NL, 0.0, 1.0);\n"
199 " fragColor = vec4(col, 1.0);\n"
205 static const char *vertexShaderSource =
206 "attribute vec4 vertex;\n"
207 "attribute vec3 normal;\n"
208 "varying vec3 vert;\n"
209 "varying vec3 vertNormal;\n"
210 "uniform mat4 projMatrix;\n"
211 "uniform mat4 mvMatrix;\n"
212 "uniform mat3 normalMatrix;\n"
214 " vert = vertex.xyz;\n"
215 " vertNormal = normalMatrix * normal;\n"
216 " gl_Position = projMatrix * mvMatrix * vertex;\n"
222 static const char *fragmentShaderSource =
223 "varying highp vec3 vert;\n"
224 "varying highp vec3 vertNormal;\n"
225 "uniform highp vec3 lightPos;\n"
227 " highp vec3 L = normalize(lightPos - vert);\n"
228 " highp float NL = max(dot(normalize(vertNormal), L), 0.0);\n"
229 " highp vec3 color = vec3(0.39, 1.0, 0.0);\n"
230 " highp vec3 col = clamp(color * 0.2 + color * 0.8 * NL, 0.0, 1.0);\n"
231 " gl_FragColor = vec4(col, 1.0);\n"
239 static void qNormalizeAngle(
int &angle) {
242 while (angle > 360 * 16)