git-svn-id: svn://db.shs.com.ru/libs@644 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -44,6 +44,7 @@ Renderer::Renderer(QGLView * view_): RendererBase(view_),
|
|||||||
|
|
||||||
shader_files[srServiceFill ] = "service_fill.glsl";
|
shader_files[srServiceFill ] = "service_fill.glsl";
|
||||||
shader_files[srServiceFrame] = "service_frame.glsl";
|
shader_files[srServiceFrame] = "service_frame.glsl";
|
||||||
|
shader_files[srServiceLine ] = "service_line.glsl";
|
||||||
|
|
||||||
shader_files[srGeometryPass ] = "ds_geom.glsl";
|
shader_files[srGeometryPass ] = "ds_geom.glsl";
|
||||||
shader_files[srLightOmniPass] = "ds_light.glsl";
|
shader_files[srLightOmniPass] = "ds_light.glsl";
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class Renderer: public RendererBase {
|
|||||||
// Service
|
// Service
|
||||||
srServiceFill,
|
srServiceFill,
|
||||||
srServiceFrame,
|
srServiceFrame,
|
||||||
|
srServiceLine,
|
||||||
|
|
||||||
// Deferred shading
|
// Deferred shading
|
||||||
srGeometryPass,
|
srGeometryPass,
|
||||||
|
|||||||
@@ -193,26 +193,31 @@ void RendererService::fillSpotObjects() {
|
|||||||
Object o;
|
Object o;
|
||||||
cur_objects.clear();
|
cur_objects.clear();
|
||||||
cur_aims.clear();
|
cur_aims.clear();
|
||||||
cur_lines.clear();
|
QVector<QVector3D> & lv (line_mesh_f->vertices ());
|
||||||
double scl = 1.;
|
QVector<QVector3D> & ln (line_mesh_f->normals ());
|
||||||
|
QVector<QVector2D> & lt (line_mesh_f->texcoords ());
|
||||||
|
QVector< Vector2i> & lind(line_mesh_f->indicesLines());
|
||||||
|
lv.clear();
|
||||||
foreach (Light * l, ll) {
|
foreach (Light * l, ll) {
|
||||||
QMatrix4x4 m;
|
QMatrix4x4 m;
|
||||||
m = invariantSizeMatrix(l->worldPos(), &scl) * parentRotationMatrix(l);
|
m = invariantSizeMatrix(l->worldPos()) * parentRotationMatrix(l);
|
||||||
m.transposed().copyDataTo(o.modelmatrix);
|
m.transposed().copyDataTo(o.modelmatrix);
|
||||||
o.object_id = l->id_;
|
o.object_id = l->id_;
|
||||||
cur_objects << o;
|
cur_objects << o;
|
||||||
|
|
||||||
QMatrix4x4 sm;
|
lv << l->worldPos() << l->worldAim();
|
||||||
sm.scale(1, 1, l->distance() / scl);
|
|
||||||
m = m * sm;
|
|
||||||
m.transposed().copyDataTo(o.modelmatrix);
|
|
||||||
//cur_lines << o;
|
|
||||||
|
|
||||||
m = invariantSizeMatrix(l->worldAim());
|
m = invariantSizeMatrix(l->worldAim());
|
||||||
m.transposed().copyDataTo(o.modelmatrix);
|
m.transposed().copyDataTo(o.modelmatrix);
|
||||||
o.object_id = l->id_ + 1;
|
o.object_id = l->id_ + 1;
|
||||||
cur_aims << o;
|
cur_aims << o;
|
||||||
}
|
}
|
||||||
|
ln.resize(lv.size());
|
||||||
|
lt.resize(lv.size());
|
||||||
|
lind.resize(lv.size() / 2);
|
||||||
|
for (int i = 0; i < lind.size(); ++i) {
|
||||||
|
lind[i] = Vector2i(i*2, i*2 + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -348,12 +353,6 @@ void RendererService::drawLightsFrame(QColor color) {
|
|||||||
box_mesh_f->loadSelections(v, rs.cur_selections_);
|
box_mesh_f->loadSelections(v, rs.cur_selections_);
|
||||||
box_mesh_f->draw(v, cur_aims.size());
|
box_mesh_f->draw(v, cur_aims.size());
|
||||||
|
|
||||||
setObjectsColor(cur_lines, color);
|
|
||||||
line_mesh_f->loadObjects(v, cur_lines);
|
|
||||||
r->fillSelectionsBuffer(rs.cur_selections_, light2objectList(v->scene_->lights_used.value(Light::Cone)));
|
|
||||||
line_mesh_f->loadSelections(v, rs.cur_selections_);
|
|
||||||
line_mesh_f->draw(v, cur_lines.size());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -372,12 +371,11 @@ void RendererService::renderService() {
|
|||||||
f->glEnable(GL_MULTISAMPLE);
|
f->glEnable(GL_MULTISAMPLE);
|
||||||
glEnableDepth();
|
glEnableDepth();
|
||||||
f->glClear(GL_DEPTH_BUFFER_BIT);
|
f->glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
if (r->bindShader(Renderer::srServiceFrame, &prog)) {
|
if (r->bindShader(Renderer::srServiceFrame, &prog)) {
|
||||||
prog->setUniformValue("qgl_ProjMatrix", r->view->camera()->projectionMatrix(r->view->aspect));
|
prog->setUniformValue("qgl_ProjMatrix", r->view->camera()->projectionMatrix(r->view->aspect));
|
||||||
|
|
||||||
/// lights
|
/// lights
|
||||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
r->setUniformCamera(prog, r->view->camera());
|
r->setUniformCamera(prog, r->view->camera());
|
||||||
|
|
||||||
prog->setUniformValue("line_width", 2.f);
|
prog->setUniformValue("line_width", 2.f);
|
||||||
@@ -387,10 +385,16 @@ void RendererService::renderService() {
|
|||||||
prog->setUniformValue("z_offset", -1.E-2f);
|
prog->setUniformValue("z_offset", -1.E-2f);
|
||||||
drawLightsFrame(Qt::black);
|
drawLightsFrame(Qt::black);
|
||||||
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (r->bindShader(Renderer::srServiceLine, &prog)) {
|
||||||
|
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
r->setUniformCamera(prog, r->view->camera());
|
||||||
|
line_object.color = QColor2QVector(Qt::white);
|
||||||
|
line_mesh_f->loadObject(f, line_object);
|
||||||
|
line_mesh_f->draw(f, 1);
|
||||||
|
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
}
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
if (r->bindShader(Renderer::srServiceFill, &prog)) {
|
if (r->bindShader(Renderer::srServiceFill, &prog)) {
|
||||||
r->setUniformCamera(prog, r->view->camera());
|
r->setUniformCamera(prog, r->view->camera());
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ private:
|
|||||||
QVector3D selection_center;
|
QVector3D selection_center;
|
||||||
QVector<QMatrix4x4> mat_xyz, mat_ms2;
|
QVector<QMatrix4x4> mat_xyz, mat_ms2;
|
||||||
QVector<QVector4D> color_xyz, color_ms2;
|
QVector<QVector4D> color_xyz, color_ms2;
|
||||||
QVector<QGLEngineShaders::Object> cur_objects, cur_aims, cur_lines;
|
QVector<QGLEngineShaders::Object> cur_objects, cur_aims;
|
||||||
|
QGLEngineShaders::Object line_object;
|
||||||
Camera * axis_camera;
|
Camera * axis_camera;
|
||||||
QSize axis_viewport;
|
QSize axis_viewport;
|
||||||
HandleAction current_action;
|
HandleAction current_action;
|
||||||
|
|||||||
17
qglengine/shaders/service_line.glsl
Normal file
17
qglengine/shaders/service_line.glsl
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// vert //
|
||||||
|
|
||||||
|
out vec4 object_color;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
gl_Position = qgl_ftransform();
|
||||||
|
object_color = qgl_ObjectColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// frag //
|
||||||
|
|
||||||
|
in vec4 object_color;
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
qgl_FragColor = object_color;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user