Work in progress - implementation of cropping in Geometry view instead

of AppearanceView. Display of scaled mixing surface in Mixing and Layers
view. Changed stippling shading.
This commit is contained in:
brunoherbelin
2020-12-07 00:17:10 +01:00
parent 78f9216d32
commit 44b888fd04
20 changed files with 711 additions and 93 deletions

View File

@@ -334,6 +334,7 @@ set(VMIX_RSC_FILES
./rsc/mesh/border_handles_overlay_filled.ply
./rsc/mesh/border_handles_sharp.ply
./rsc/mesh/border_handles_menu.ply
./rsc/mesh/border_handles_crop.ply
./rsc/mesh/border_handles_shadow.ply
./rsc/mesh/border_large_sharp.ply
./rsc/mesh/border_vertical_overlay.ply

View File

@@ -159,7 +159,8 @@ Handles::Handles(Type type) : Node(), type_(type)
static Mesh *handle_rotation = new Mesh("mesh/border_handles_rotation.ply");
static Mesh *handle_corner = new Mesh("mesh/border_handles_overlay.ply");
static Mesh *handle_scale = new Mesh("mesh/border_handles_scale.ply");
static Mesh *handle_restore = new Mesh("mesh/border_handles_menu.ply");
static Mesh *handle_crop = new Mesh("mesh/border_handles_crop.ply");
static Mesh *handle_menu = new Mesh("mesh/border_handles_menu.ply");
static Mesh *handle_shadow = new Mesh("mesh/border_handles_shadow.ply", "images/soft_shadow.dds");
if ( type_ == Handles::ROTATE ) {
@@ -169,7 +170,10 @@ Handles::Handles(Type type) : Node(), type_(type)
handle_ = handle_scale;
}
else if ( type_ == Handles::MENU ) {
handle_ = handle_restore;
handle_ = handle_menu;
}
else if ( type_ == Handles::CROP ) {
handle_ = handle_crop;
}
else {
handle_ = handle_corner;
@@ -300,6 +304,18 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
shadow_->draw( ctm, projection );
handle_->draw( ctm, projection );
}
else if ( type_ == Handles::CROP ){
// one icon in bottom right corner
// 1. Fixed displacement by (0.12,0.12) along the rotation..
ctm = GlmToolkit::transform(glm::vec4(0.f), rot, mirror);
glm::vec4 pos = ctm * glm::vec4(mirror.x * 0.12f, mirror.x * 0.12f, 0.f, 1.f);
// 2. ..from the bottom right corner (1,1)
vec = ( modelview * glm::vec4(-1.f, -1.f, 0.f, 1.f) ) + pos;
ctm = GlmToolkit::transform(vec, rot, glm::vec3(mirror.x, mirror.y, 1.f));
// 3. draw
shadow_->draw( ctm, projection );
handle_->draw( ctm, projection );
}
else if ( type_ == Handles::MENU ){
// one icon in top left corner
// 1. Fixed displacement by (-0.12,0.12) along the rotation..
@@ -341,7 +357,7 @@ Symbol::Symbol(Type t, glm::vec3 pos) : Node(), type_(t)
icons[BUSY] = new Mesh("mesh/icon_circles.ply");
icons[LOCK] = new Mesh("mesh/icon_lock.ply");
icons[UNLOCK] = new Mesh("mesh/icon_unlock.ply");
icons[CROP] = new Mesh("mesh/icon_rightarrow.ply");
icons[ARROWS] = new Mesh("mesh/icon_rightarrow.ply");
icons[CIRCLE] = new Mesh("mesh/icon_circle.ply");
icons[CLOCK] = new Mesh("mesh/icon_clock.ply");
icons[CLOCK_H] = new Mesh("mesh/icon_clock_hand.ply");

View File

@@ -36,7 +36,7 @@ protected:
class Handles : public Node
{
public:
typedef enum { RESIZE = 0, RESIZE_H, RESIZE_V, ROTATE, SCALE, MENU } Type;
typedef enum { RESIZE = 0, RESIZE_H, RESIZE_V, ROTATE, SCALE, CROP, MENU } Type;
Handles(Type type);
~Handles();
@@ -61,7 +61,7 @@ class Symbol : public Node
{
public:
typedef enum { CIRCLE_POINT = 0, SQUARE_POINT, IMAGE, VIDEO, SESSION, CLONE, RENDER, PATTERN, CAMERA, SHARE,
DOTS, BUSY, LOCK, UNLOCK, CROP, CIRCLE, SQUARE, CLOCK, CLOCK_H, GRID, CROSS, EMPTY } Type;
DOTS, BUSY, LOCK, UNLOCK, ARROWS, CROP, CIRCLE, SQUARE, CLOCK, CLOCK_H, GRID, CROSS, EMPTY } Type;
Symbol(Type t = CIRCLE_POINT, glm::vec3 pos = glm::vec3(0.f));
~Symbol();

View File

@@ -252,16 +252,15 @@ glm::mat4 FrameBuffer::projection() const
return projection_;
}
glm::vec2 FrameBuffer::projectionArea() const
{
return projection_crop_;
return projection_area_;
}
void FrameBuffer::setProjectionArea(glm::vec2 c)
{
projection_crop_.x = CLAMP(c.x, 0.1f, 1.f);
projection_crop_.y = CLAMP(c.y, 0.1f, 1.f);
projection_ = glm::ortho(-projection_crop_.x, projection_crop_.x, projection_crop_.y, -projection_crop_.y, -1.f, 1.f);
projection_area_.x = CLAMP(c.x, 0.1f, 1.f);
projection_area_.y = CLAMP(c.y, 0.1f, 1.f);
projection_ = glm::ortho(-projection_area_.x, projection_area_.x, projection_area_.y, -projection_area_.y, -1.f, 1.f);
}

View File

@@ -24,7 +24,6 @@ public:
void begin();
// pop attrib and unbind to end draw
void end();
// blit copy to another, returns true on success
bool blit(FrameBuffer *other);
// bind the FrameBuffer in READ and perform glReadPixels
@@ -42,7 +41,7 @@ public:
float aspectRatio() const;
std::string info() const;
// projection and crop
// projection area (crop)
glm::mat4 projection() const;
glm::vec2 projectionArea() const;
void setProjectionArea(glm::vec2 c);
@@ -60,7 +59,7 @@ private:
RenderingAttrib attrib_;
glm::mat4 projection_;
glm::vec2 projection_crop_;
glm::vec2 projection_area_;
uint textureid_, intermediate_textureid_;
uint framebufferid_, intermediate_framebufferid_;
bool use_alpha_, use_multi_sampling_;

View File

@@ -396,10 +396,10 @@ void ImGuiVisitor::visit (Source& s)
// preview
float preview_width = ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN;
float width = preview_width;
float height = width / s.frame()->aspectRatio();
float height = s.frame()->projectionArea().y * width / ( s.frame()->projectionArea().x * s.frame()->aspectRatio());
if (height > 230) {
height = 230;
width = height * s.frame()->aspectRatio();
width = height * s.frame()->aspectRatio() * ( s.frame()->projectionArea().x / s.frame()->projectionArea().y);
}
ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height));

View File

@@ -156,6 +156,12 @@ void PickingVisitor::visit(Handles &n)
float l = glm::length( glm::vec2(vec) );
picked = glm::length( glm::vec2( 1.f + l, -1.f - l) - glm::vec2(P) ) < 1.5f * scale;
}
else if ( n.type() == Handles::CROP ){
// the icon for scaling is on the right bottom corner at (0.12, -0.12) in scene coordinates
glm::vec4 vec = glm::inverse(modelview_) * glm::vec4( 0.1f, 0.1f, 0.f, 0.f );
float l = glm::length( glm::vec2(vec) );
picked = glm::length( glm::vec2( -1.f + l, -1.f + l) - glm::vec2(P) ) < 1.5f * scale;
}
else if ( n.type() == Handles::MENU ){
// the icon for restore is on the left top corner at (-0.12, 0.12) in scene coordinates
glm::vec4 vec = glm::inverse(modelview_) * glm::vec4( 0.1f, 0.1f, 0.f, 0.f );

View File

@@ -27,6 +27,7 @@ Node::Node() : initialized_(false), visible_(true), refcount_(0)
scale_ = glm::vec3(1.f);
rotation_ = glm::vec3(0.f);
translation_ = glm::vec3(0.f);
crop_ = glm::vec3(1.f);
}
Node::~Node ()
@@ -53,6 +54,7 @@ void Node::copyTransform(Node *other)
scale_ = other->scale_;
rotation_ = other->rotation_;
translation_ = other->translation_;
crop_ = other->crop_;
}
void Node::update( float dt)

View File

@@ -70,7 +70,7 @@ public:
bool visible_;
uint refcount_;
glm::mat4 transform_;
glm::vec3 scale_, rotation_, translation_;
glm::vec3 scale_, rotation_, translation_, crop_;
// animation update callbacks
// list of callbacks to call at each update

View File

@@ -347,6 +347,9 @@ void SessionLoader::XMLToNode(tinyxml2::XMLElement *xml, Node &n)
XMLElement *rotationNode = node->FirstChildElement("rotation");
if (rotationNode)
tinyxml2::XMLElementToGLM( rotationNode->FirstChildElement("vec3"), n.rotation_);
XMLElement *cropNode = node->FirstChildElement("crop");
if (cropNode)
tinyxml2::XMLElementToGLM( cropNode->FirstChildElement("vec3"), n.crop_);
}
}
@@ -482,9 +485,6 @@ void SessionLoader::visit (Source& s)
xmlCurrent_ = sourceNode->FirstChildElement("Appearance");
s.groupNode(View::APPEARANCE)->accept(*this);
xmlCurrent_ = sourceNode->FirstChildElement("Crop");
s.renderingSurface()->accept(*this);
xmlCurrent_ = sourceNode->FirstChildElement("Blending");
s.blendingShader()->accept(*this);

View File

@@ -47,6 +47,10 @@ tinyxml2::XMLElement *SessionVisitor::NodeToXML(Node &n, tinyxml2::XMLDocument *
rotation->InsertEndChild( XMLElementFromGLM(doc, n.rotation_) );
newelement->InsertEndChild(rotation);
XMLElement *crop = doc->NewElement("crop");
crop->InsertEndChild( XMLElementFromGLM(doc, n.crop_) );
newelement->InsertEndChild(crop);
return newelement;
}
@@ -343,10 +347,6 @@ void SessionVisitor::visit (Source& s)
sourceNode->InsertEndChild(xmlCurrent_);
s.groupNode(View::APPEARANCE)->accept(*this);
xmlCurrent_ = xmlDoc_->NewElement("Crop");
sourceNode->InsertEndChild(xmlCurrent_);
s.renderingSurface()->accept(*this);
xmlCurrent_ = xmlDoc_->NewElement( "Blending" );
sourceNode->InsertEndChild(xmlCurrent_);
s.blendingShader()->accept(*this);

View File

@@ -97,6 +97,10 @@ Source::Source() : initialized_(false), active_(true), need_update_(true), symbo
handles_[View::GEOMETRY][Handles::MENU]->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
handles_[View::GEOMETRY][Handles::MENU]->translation_.z = 0.1;
overlays_[View::GEOMETRY]->attach(handles_[View::GEOMETRY][Handles::MENU]);
handles_[View::GEOMETRY][Handles::CROP] = new Handles(Handles::CROP);
handles_[View::GEOMETRY][Handles::CROP]->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 1.f);
handles_[View::GEOMETRY][Handles::CROP]->translation_.z = 0.1;
overlays_[View::GEOMETRY]->attach(handles_[View::GEOMETRY][Handles::CROP]);
frame = new Frame(Frame::SHARP, Frame::THIN, Frame::NONE);
frame->translation_.z = 0.1;
@@ -181,6 +185,9 @@ Source::Source() : initialized_(false), active_(true), need_update_(true), symbo
// default to image processing enabled
renderingshader_ = (Shader *) processingshader_;
mixingshader_ = new ImageShader;
mixingshader_->stipple = 1.0;
// create media surface:
// - textured with original texture from media player
// - crop & repeat UV can be managed here
@@ -190,6 +197,7 @@ Source::Source() : initialized_(false), active_(true), need_update_(true), symbo
// will be created at init
renderbuffer_ = nullptr;
rendersurface_ = nullptr;
mixingsurface_ = nullptr;
}
@@ -333,27 +341,23 @@ void Source::attach(FrameBuffer *renderbuffer)
rendersurface_ = new FrameBufferSurface(renderbuffer_, blendingshader_);
groups_[View::RENDERING]->attach(rendersurface_);
groups_[View::GEOMETRY]->attach(rendersurface_);
groups_[View::MIXING]->attach(rendersurface_);
// groups_[View::LAYER]->attach(rendersurface_);
// for mixing and layer views, add another surface to overlay
// (stippled view on top with transparency)
Surface *surfacemix = new FrameBufferSurface(renderbuffer_);
ImageShader *is = static_cast<ImageShader *>(surfacemix->shader());
if (is) is->stipple = 1.0;
groups_[View::MIXING]->attach(surfacemix);
groups_[View::LAYER]->attach(surfacemix);
mixingsurface_ = new FrameBufferSurface(renderbuffer_, mixingshader_);
groups_[View::MIXING]->attach(mixingsurface_);
groups_[View::LAYER]->attach(mixingsurface_);
// for appearance view, a dedicated surface without blending
// for views showing a scaled mixing surface, a dedicated transparent surface allows grabbing
Surface *surfacetmp = new Surface();
surfacetmp->setTextureIndex(Resource::getTextureTransparent());
groups_[View::APPEARANCE]->attach(surfacetmp);
groups_[View::MIXING]->attach(surfacetmp);
groups_[View::LAYER]->attach(surfacetmp);
// Transition group node is optionnal
if ( groups_[View::TRANSITION]->numChildren() > 0 ) {
groups_[View::TRANSITION]->attach(rendersurface_);
groups_[View::TRANSITION]->attach(surfacemix);
}
if (groups_[View::TRANSITION]->numChildren() > 0)
groups_[View::TRANSITION]->attach(mixingsurface_);
// scale all icon nodes to match aspect ratio
for (int v = View::MIXING; v < View::INVALID; v++) {
@@ -367,8 +371,9 @@ void Source::attach(FrameBuffer *renderbuffer)
// make the source visible
if ( mode_ == UNINITIALIZED ) {
setMode(VISIBLE);
need_update_ = true;
}
need_update_ = true;
}
@@ -405,13 +410,16 @@ void Source::update(float dt)
dt_ = dt;
// update nodes if needed
if (need_update_)
if (renderbuffer_ && mixingsurface_ && need_update_)
{
// Log::Info("UPDATE %s %f", initials_, dt);
// ADJUST alpha based on MIXING node
// read position of the mixing node and interpret this as transparency of render output
glm::vec2 dist = glm::vec2(groups_[View::MIXING]->translation_);
// use the prefered transfer function
blendingshader_->color.a = sin_quad( dist.x, dist.y );
mixingshader_->color.a = blendingshader_->color.a;
// CHANGE update status based on limbo
bool a = glm::length(dist) < 1.3f;
@@ -421,14 +429,21 @@ void Source::update(float dt)
// MODIFY geometry based on GEOMETRY node
groups_[View::RENDERING]->translation_ = groups_[View::GEOMETRY]->translation_;
groups_[View::RENDERING]->rotation_ = groups_[View::GEOMETRY]->rotation_;
// avoid any null scale
glm::vec3 s = groups_[View::GEOMETRY]->scale_;
// avoid any null scale
s.x = CLAMP_SCALE(s.x);
s.y = CLAMP_SCALE(s.y);
s.z = 1.f;
groups_[View::GEOMETRY]->scale_ = s;
groups_[View::RENDERING]->scale_ = s;
// MODIFY CROP projection based on GEOMETRY crop
renderbuffer_->setProjectionArea( glm::vec2(groups_[View::GEOMETRY]->crop_) );
// Mixing and layer icons scaled based on GEOMETRY crop
mixingsurface_->scale_ = groups_[View::GEOMETRY]->crop_;
mixingsurface_->scale_.x *= renderbuffer_->aspectRatio();
// mixingsurface_->update(0.f);
// MODIFY depth based on LAYER node
groups_[View::MIXING]->translation_.z = groups_[View::LAYER]->translation_.z;
groups_[View::GEOMETRY]->translation_.z = groups_[View::LAYER]->translation_.z;
@@ -439,17 +454,12 @@ void Source::update(float dt)
static glm::mat4 UVtoScene = GlmToolkit::transform(glm::vec3(1.f, -1.f, 0.f),
glm::vec3(0.f, 0.f, 0.f),
glm::vec3(-2.f, 2.f, 1.f));
// make sure to update rendering texture surface node
texturesurface_->update(dt);
// Aspect Ratio correction transform : coordinates of Appearance Frame are scaled by render buffer width
glm::mat4 Ar = glm::identity<glm::mat4>();
if (renderbuffer_)
Ar = glm::scale(glm::identity<glm::mat4>(), glm::vec3(renderbuffer_->aspectRatio() * texturesurface_->scale_.x, texturesurface_->scale_.y, 1.f) );
glm::mat4 Ar = glm::scale(glm::identity<glm::mat4>(), glm::vec3(renderbuffer_->aspectRatio(), 1.f, 1.f) );
// Translation : same as Appearance Frame (modified by Ar)
glm::mat4 Tra = glm::translate(glm::identity<glm::mat4>(), groups_[View::APPEARANCE]->translation_);
// Scaling : inverse scaling (larger UV when smaller Appearance Frame)
glm::mat4 Sca = glm::scale(glm::identity<glm::mat4>(), glm::vec3( texturesurface_->scale_.x / groups_[View::APPEARANCE]->scale_.x,
texturesurface_->scale_.y / groups_[View::APPEARANCE]->scale_.y, 1.f));
glm::mat4 Sca = glm::scale(glm::identity<glm::mat4>(), glm::vec3(groups_[View::APPEARANCE]->scale_.x,groups_[View::APPEARANCE]->scale_.y, 1.f));
// Rotation : same angle than Appearance Frame, inverted axis
glm::mat4 Rot = glm::rotate(glm::identity<glm::mat4>(), groups_[View::APPEARANCE]->rotation_.z, glm::vec3(0.f, 0.f, -1.f) );
// Combine transformations (non transitive) in this order:
@@ -460,7 +470,7 @@ void Source::update(float dt)
// 5. Revert aspect ration correction
// 6. Apply the Scaling (independent of aspect ratio)
// 7. switch back to UV coordinate system
texturesurface_->shader()->iTransform = glm::inverse(UVtoScene) * Sca * glm::inverse(Ar) * Rot * Tra * Ar * UVtoScene;
texturesurface_->shader()->iTransform = glm::inverse(UVtoScene) * glm::inverse(Sca) * glm::inverse(Ar) * Rot * Tra * Ar * UVtoScene;
// do not update next frame
need_update_ = false;

View File

@@ -162,6 +162,7 @@ protected:
// the rendersurface draws the renderbuffer in the scene
// It is associated to the rendershader for mixing effects
FrameBufferSurface *rendersurface_;
FrameBufferSurface *mixingsurface_;
// image processing shaders
ImageProcessingShader *processingshader_;
@@ -171,6 +172,7 @@ protected:
// blendingshader provides mixing controls
ImageShader *blendingshader_;
ImageShader *mixingshader_;
// surface to draw on
Surface *texturesurface_;
@@ -181,7 +183,7 @@ protected:
// overlays and frames to be displayed on top of source
std::map<View::Mode, Group*> overlays_;
std::map<View::Mode, Switch*> frames_;
std::map<View::Mode, Handles*[6]> handles_;
std::map<View::Mode, Handles*[7]> handles_;
Symbol *symbol_;
// update

View File

@@ -2103,8 +2103,8 @@ void Navigator::RenderSourcePannel(Source *s)
// Source pannel
static ImGuiVisitor v;
s->accept(v);
// ensure change is applied
s->touch();
// ensure change is applied // TODO : touch() in visitor ? [avoid here as it forces useless update]
// s->touch();
// delete button
ImGui::Text(" ");
// Action on source

138
View.cpp
View File

@@ -764,6 +764,12 @@ GeometryView::GeometryView() : View(GEOMETRY)
scene.fg()->attach(overlay_scaling_);
overlay_scaling_->visible_ = false;
border = new Frame(Frame::SHARP, Frame::THIN, Frame::NONE);
border->color = glm::vec4( COLOR_HIGHLIGHT_SOURCE, 0.2f );
overlay_crop_ = border;
scene.fg()->attach(overlay_crop_);
overlay_crop_->visible_ = false;
show_context_menu_ = false;
}
@@ -824,6 +830,7 @@ void showContextMenu(View::Mode m, const char* label)
else if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset" )){
s->group(m)->scale_ = glm::vec3(1.f);
s->group(m)->rotation_.z = 0;
s->group(m)->crop_ = glm::vec3(1.f);
s->touch();
}
else if (ImGui::Selectable( ICON_FA_EXPAND " Fit" )){
@@ -842,6 +849,7 @@ void showContextMenu(View::Mode m, const char* label)
}
else if (ImGui::Selectable( ICON_FA_PERCENTAGE " Original aspect ratio" )){ //ICON_FA_ARROWS_ALT_H
s->group(m)->scale_.x = s->group(m)->scale_.y;
s->group(m)->scale_ *= s->group(m)->crop_;
s->touch();
}
}
@@ -992,6 +1000,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
s->handles_[mode_][Handles::RESIZE_H]->visible_ = false;
s->handles_[mode_][Handles::RESIZE_V]->visible_ = false;
s->handles_[mode_][Handles::ROTATE]->visible_ = false;
s->handles_[mode_][Handles::CROP]->visible_ = false;
s->handles_[mode_][Handles::MENU]->visible_ = false;
// inform on which corner should be overlayed (opposite)
s->handles_[mode_][Handles::RESIZE]->overlayActiveCorner(-corner);
@@ -1045,6 +1054,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
s->handles_[mode_][Handles::SCALE]->visible_ = false;
s->handles_[mode_][Handles::RESIZE_V]->visible_ = false;
s->handles_[mode_][Handles::ROTATE]->visible_ = false;
s->handles_[mode_][Handles::CROP]->visible_ = false;
s->handles_[mode_][Handles::MENU]->visible_ = false;
// inform on which corner should be overlayed (opposite)
s->handles_[mode_][Handles::RESIZE_H]->overlayActiveCorner(-corner);
@@ -1085,6 +1095,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
s->handles_[mode_][Handles::SCALE]->visible_ = false;
s->handles_[mode_][Handles::RESIZE_H]->visible_ = false;
s->handles_[mode_][Handles::ROTATE]->visible_ = false;
s->handles_[mode_][Handles::CROP]->visible_ = false;
s->handles_[mode_][Handles::MENU]->visible_ = false;
// inform on which corner should be overlayed (opposite)
s->handles_[mode_][Handles::RESIZE_V]->overlayActiveCorner(-corner);
@@ -1125,6 +1136,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
s->handles_[mode_][Handles::RESIZE_H]->visible_ = false;
s->handles_[mode_][Handles::RESIZE_V]->visible_ = false;
s->handles_[mode_][Handles::ROTATE]->visible_ = false;
s->handles_[mode_][Handles::CROP]->visible_ = false;
s->handles_[mode_][Handles::MENU]->visible_ = false;
// prepare overlay
overlay_scaling_cross_->visible_ = false;
@@ -1156,6 +1168,50 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
info << " x " << sourceNode->scale_.y;
}
// picking on the CROP
else if ( pick.first == s->handles_[mode_][Handles::CROP] ) {
// hide all other grips
s->handles_[mode_][Handles::RESIZE]->visible_ = false;
s->handles_[mode_][Handles::RESIZE_H]->visible_ = false;
s->handles_[mode_][Handles::RESIZE_V]->visible_ = false;
s->handles_[mode_][Handles::ROTATE]->visible_ = false;
s->handles_[mode_][Handles::SCALE]->visible_ = false;
s->handles_[mode_][Handles::MENU]->visible_ = false;
// prepare overlay
overlay_crop_->scale_ = s->stored_status_->scale_ / s->stored_status_->crop_;
overlay_crop_->scale_.x *= s->frame()->aspectRatio();
overlay_crop_->translation_.x = s->stored_status_->translation_.x;
overlay_crop_->translation_.y = s->stored_status_->translation_.y;
overlay_crop_->rotation_.z = s->stored_status_->rotation_.z;
overlay_crop_->update(0);
overlay_crop_->visible_ = true;
// PROPORTIONAL ONLY
if (UserInterface::manager().shiftModifier()) {
float factor = glm::length( glm::vec2( source_to ) ) / glm::length( glm::vec2( source_from ) );
source_scaling = glm::vec3(factor, factor, 1.f);
}
// calculate crop of framebuffer
sourceNode->crop_ = s->stored_status_->crop_ * source_scaling;
// POST-CORRECTION ; discretized crop with ALT
if (UserInterface::manager().altModifier()) {
sourceNode->crop_.x = ROUND(sourceNode->crop_.x, 10.f);
sourceNode->crop_.y = ROUND(sourceNode->crop_.y, 10.f);
}
// CLAMP crop values
sourceNode->crop_.x = CLAMP(sourceNode->crop_.x, 0.1f, 1.f);
sourceNode->crop_.y = CLAMP(sourceNode->crop_.y, 0.1f, 1.f);
// apply center scaling
s->frame()->setProjectionArea( glm::vec2(sourceNode->crop_) );
sourceNode->scale_ = s->stored_status_->scale_ * (sourceNode->crop_ / s->stored_status_->crop_);
// show cursor depending on diagonal
corner = glm::sign(sourceNode->scale_);
ret.type = (corner.x * corner.y) < 0.f ? Cursor_ResizeNWSE : Cursor_ResizeNESW;
info << "Crop " << std::fixed << std::setprecision(3) << sourceNode->crop_.x;
info << " x " << sourceNode->crop_.y;
}
// picking on the rotating handle
else if ( pick.first == s->handles_[mode_][Handles::ROTATE] ) {
@@ -1164,6 +1220,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
s->handles_[mode_][Handles::RESIZE_H]->visible_ = false;
s->handles_[mode_][Handles::RESIZE_V]->visible_ = false;
s->handles_[mode_][Handles::SCALE]->visible_ = false;
s->handles_[mode_][Handles::CROP]->visible_ = false;
s->handles_[mode_][Handles::MENU]->visible_ = false;
// ROTATION on CENTER
@@ -1281,6 +1338,7 @@ void GeometryView::terminate()
overlay_scaling_grid_->visible_ = false;
overlay_scaling_cross_->visible_ = false;
overlay_scaling_->visible_ = false;
overlay_crop_->visible_ = false;
// restore of all handles overlays
glm::vec2 c(0.f, 0.f);
@@ -1295,6 +1353,7 @@ void GeometryView::terminate()
(*sit)->handles_[mode_][Handles::RESIZE_V]->visible_ = true;
(*sit)->handles_[mode_][Handles::SCALE]->visible_ = true;
(*sit)->handles_[mode_][Handles::ROTATE]->visible_ = true;
(*sit)->handles_[mode_][Handles::CROP]->visible_ = true;
(*sit)->handles_[mode_][Handles::MENU]->visible_ = true;
}
@@ -1845,10 +1904,10 @@ AppearanceView::AppearanceView() : View(APPEARANCE), edit_source_(nullptr), need
// Scene foreground
//
// crop icons
crop_horizontal_ = new Symbol(Symbol::CROP);
crop_horizontal_ = new Symbol(Symbol::ARROWS);
crop_horizontal_->translation_ = glm::vec3(1.0f, 1.12f, 0.f);
scene.fg()->attach(crop_horizontal_);
crop_vertical_ = new Symbol(Symbol::CROP);
crop_vertical_ = new Symbol(Symbol::ARROWS);
crop_vertical_->rotation_.z = M_PI_2;
crop_vertical_->translation_ = glm::vec3(-1.12f, -1.0f, 0.f);
scene.fg()->attach(crop_vertical_);
@@ -2050,7 +2109,7 @@ void AppearanceView::adjustBackground()
{
// by default consider edit source is null
float image_original_width = 1.f;
glm::vec2 image_crop_area = glm::vec2(1.f, 1.f);
// glm::vec2 image_crop_area = glm::vec2(1.f, 1.f);
surfacepreview->setTextureIndex( Resource::getTextureTransparent() );
// if its a valid index
@@ -2058,11 +2117,10 @@ void AppearanceView::adjustBackground()
// update rendering frame to match edit source AR
image_original_width = edit_source_->frame()->aspectRatio();
surfacepreview->setTextureIndex( edit_source_->frame()->texture() );
surfacepreview->scale_ = edit_source_->mixingsurface_->scale_;
image_crop_area = glm::vec2(edit_source_->texturesurface_->scale_);
surfacepreview->scale_.x = image_original_width;
image_crop_area.x *= image_original_width;
// surfacepreview->scale_.x = image_original_width;
// image_crop_area.x *= image_original_width;
}
// update objects in the scene to represent the image and crop area
@@ -2077,9 +2135,9 @@ void AppearanceView::adjustBackground()
backgroundchecker_->shader()->iTransform = Ar * Tra;
// foreground
crop_horizontal_->translation_.x = image_crop_area.x;
crop_vertical_->translation_.y = -image_crop_area.y;
crop_vertical_->translation_.x = -image_original_width - 0.12f;
// crop_horizontal_->translation_.x = image_crop_area.x;
// crop_vertical_->translation_.y = -image_crop_area.y;
// crop_vertical_->translation_.x = -image_original_width - 0.12f;
}
@@ -2126,22 +2184,22 @@ void AppearanceView::draw()
adjustBackground();
}
// draw marks in axis
if (edit_source_ != nullptr){
if (show_horizontal_scale_) {
int n = static_cast<int>( edit_source_->frame()->aspectRatio() / 0.2f );
static glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), glm::vec3( 0.2f, 0.f, 0.f));
DrawVisitor dv(horizontal_mark_, Rendering::manager().Projection());
dv.loop(n + 1, T);
scene.accept(dv);
}
if (show_vertical_scale_) {
static glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), glm::vec3( 0.f, -0.2f, 0.f));
DrawVisitor dv(vertical_mark_, Rendering::manager().Projection());
dv.loop(6, T);
scene.accept(dv);
}
}
// // draw marks in axis
// if (edit_source_ != nullptr){
// if (show_horizontal_scale_) {
// int n = static_cast<int>( edit_source_->frame()->aspectRatio() / 0.2f );
// static glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), glm::vec3( 0.2f, 0.f, 0.f));
// DrawVisitor dv(horizontal_mark_, Rendering::manager().Projection());
// dv.loop(n + 1, T);
// scene.accept(dv);
// }
// if (show_vertical_scale_) {
// static glm::mat4 T = glm::translate(glm::identity<glm::mat4>(), glm::vec3( 0.f, -0.2f, 0.f));
// DrawVisitor dv(vertical_mark_, Rendering::manager().Projection());
// dv.loop(6, T);
// scene.accept(dv);
// }
// }
// draw general view
Shader::force_blending_opacity = true;
@@ -2191,13 +2249,13 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
show_horizontal_scale_ = true;
}
// crop horizontally
edit_source_->texturesurface_->scale_.x = CLAMP(val, 0.2f, max_width) / max_width;
edit_source_->touch();
// update background and frame
adjustBackground();
// cursor indication
info << "Crop " << std::fixed << std::setprecision(3) << max_width * edit_source_->texturesurface_->scale_.x;
info << " x " << edit_source_->texturesurface_->scale_.y;
// edit_source_->texturesurface_->scale_.x = CLAMP(val, 0.2f, max_width) / max_width;
// edit_source_->touch();
// // update background and frame
// adjustBackground();
// // cursor indication
// info << "Crop " << std::fixed << std::setprecision(3) << max_width * edit_source_->texturesurface_->scale_.x;
// info << " x " << edit_source_->texturesurface_->scale_.y;
ret.type = Cursor_ResizeEW;
}
if ( pick.first == crop_vertical_ ) {
@@ -2209,13 +2267,13 @@ View::Cursor AppearanceView::grab (Source *s, glm::vec2 from, glm::vec2 to, std:
show_vertical_scale_ = true;
}
// crop vertically
edit_source_->texturesurface_->scale_.y = CLAMP(val, 0.2f, 1.0f);
edit_source_->touch();
// update background and frame
adjustBackground();
// cursor indication
info << "Crop " << std::fixed << std::setprecision(3) << max_width * edit_source_->texturesurface_->scale_.x ;
info << " x " << edit_source_->texturesurface_->scale_.y;
// edit_source_->texturesurface_->scale_.y = CLAMP(val, 0.2f, 1.0f);
// edit_source_->touch();
// // update background and frame
// adjustBackground();
// // cursor indication
// info << "Crop " << std::fixed << std::setprecision(3) << max_width * edit_source_->texturesurface_->scale_.x ;
// info << " x " << edit_source_->texturesurface_->scale_.y;
ret.type = Cursor_ResizeNS;
}

1
View.h
View File

@@ -173,6 +173,7 @@ private:
Node *overlay_scaling_;
Node *overlay_scaling_cross_;
Node *overlay_scaling_grid_;
Node *overlay_crop_;
bool show_context_menu_;
};

View File

@@ -0,0 +1,506 @@
ply
format ascii 1.0
comment Created by Blender 2.91.0 - www.blender.org
element vertex 250
property float x
property float y
property float z
element face 246
property list uchar uint vertex_indices
end_header
-0.042157 0.063218 0.000000
-0.041120 0.063272 0.000000
-0.041354 0.063272 0.000000
-0.040476 0.063272 0.000000
-0.039503 0.063272 0.000000
-0.038283 0.063272 0.000000
-0.036898 0.063272 0.000000
-0.035432 0.063272 0.000000
-0.033965 0.063272 0.000000
-0.032581 0.063272 0.000000
-0.031361 0.063272 0.000000
-0.030387 0.063272 0.000000
-0.029743 0.063272 0.000000
-0.029510 0.063272 0.000000
-0.028707 0.063218 0.000000
-0.042927 0.063061 0.000000
-0.027936 0.063061 0.000000
-0.043658 0.062807 0.000000
-0.027206 0.062807 0.000000
-0.044342 0.062464 0.000000
-0.026522 0.062464 0.000000
-0.044972 0.062039 0.000000
-0.025892 0.062039 0.000000
-0.045540 0.061539 0.000000
-0.025323 0.061539 0.000000
-0.046041 0.060970 0.000000
-0.024823 0.060970 0.000000
-0.046467 0.060341 0.000000
-0.024397 0.060341 0.000000
-0.046810 0.059657 0.000000
-0.024054 0.059657 0.000000
-0.047064 0.058926 0.000000
-0.023800 0.058926 0.000000
-0.047221 0.058155 0.000000
-0.023642 0.058155 0.000000
-0.047275 0.057352 0.000000
-0.023588 0.057352 0.000000
-0.047275 0.057158 0.000000
-0.023588 0.055760 0.000000
-0.047275 0.056621 0.000000
-0.047275 0.055810 0.000000
-0.047275 0.054794 0.000000
-0.023588 0.051358 0.000000
-0.047275 0.053640 0.000000
-0.047275 0.052418 0.000000
-0.047275 0.051196 0.000000
-0.023588 0.044709 0.000000
-0.047275 0.050043 0.000000
-0.047275 0.049026 0.000000
-0.047275 0.048215 0.000000
-0.047275 0.047678 0.000000
-0.047275 0.047484 0.000000
-0.057948 0.047430 0.000000
-0.057145 0.047484 0.000000
-0.015693 0.023802 0.000000
-0.014605 0.047484 0.000000
-0.015693 0.047484 0.000000
-0.011599 0.047484 0.000000
-0.007057 0.047484 0.000000
-0.001363 0.047484 0.000000
0.005097 0.047484 0.000000
0.011942 0.047484 0.000000
0.018787 0.047484 0.000000
0.025248 0.047484 0.000000
0.030941 0.047484 0.000000
0.035483 0.047484 0.000000
0.038490 0.047484 0.000000
0.039577 0.047484 0.000000
0.040648 0.047412 0.000000
-0.058719 0.047273 0.000000
0.041676 0.047202 0.000000
-0.059449 0.047019 0.000000
0.042650 0.046864 0.000000
-0.060133 0.046676 0.000000
0.043562 0.046406 0.000000
-0.060763 0.046251 0.000000
0.044402 0.045839 0.000000
-0.061332 0.045751 0.000000
0.045160 0.045172 0.000000
-0.061832 0.045182 0.000000
-0.062258 0.044553 0.000000
0.045827 0.044414 0.000000
-0.023588 0.036374 0.000000
-0.062601 0.043869 0.000000
0.046395 0.043574 0.000000
-0.062855 0.043138 0.000000
0.046852 0.042663 0.000000
-0.063013 0.042367 0.000000
0.047191 0.041689 0.000000
-0.063067 0.041564 0.000000
0.047401 0.040661 0.000000
-0.063067 0.041331 0.000000
-0.063067 0.040687 0.000000
-0.063067 0.039714 0.000000
0.047473 0.039590 0.000000
-0.063067 0.038494 0.000000
0.023786 0.023802 0.000000
0.047473 -0.023562 0.000000
-0.063067 0.037110 0.000000
-0.063067 0.035643 0.000000
-0.023588 0.026916 0.000000
-0.063067 0.034177 0.000000
-0.063067 0.032793 0.000000
-0.063067 0.031573 0.000000
-0.063067 0.030600 0.000000
-0.063067 0.029956 0.000000
-0.063067 0.029723 0.000000
-0.063013 0.028920 0.000000
-0.062855 0.028149 0.000000
-0.062601 0.027419 0.000000
-0.062258 0.026735 0.000000
-0.047275 0.023802 0.000000
-0.023588 0.016895 0.000000
-0.061832 0.026105 0.000000
-0.061332 0.025537 0.000000
-0.060763 0.025036 0.000000
-0.060133 0.024611 0.000000
-0.059449 0.024268 0.000000
-0.058719 0.024014 0.000000
-0.057948 0.023856 0.000000
-0.057145 0.023802 0.000000
-0.056951 0.023802 0.000000
-0.056414 0.023802 0.000000
-0.055603 0.023802 0.000000
-0.054586 0.023802 0.000000
-0.053432 0.023802 0.000000
-0.052210 0.023802 0.000000
-0.050988 0.023802 0.000000
-0.049834 0.023802 0.000000
-0.048817 0.023802 0.000000
-0.048006 0.023802 0.000000
-0.047469 0.023802 0.000000
-0.047275 -0.039350 0.000000
0.023786 -0.057111 0.000000
-0.023588 0.006875 0.000000
-0.023588 -0.002584 0.000000
-0.023588 -0.010919 0.000000
-0.023588 -0.017568 0.000000
-0.023588 -0.021970 0.000000
-0.023588 -0.023562 0.000000
0.015890 -0.023562 0.000000
0.015890 -0.047244 0.000000
0.057342 -0.023562 0.000000
0.058146 -0.023616 0.000000
0.058916 -0.023773 0.000000
0.059647 -0.024027 0.000000
0.060331 -0.024370 0.000000
0.060960 -0.024795 0.000000
0.061529 -0.025295 0.000000
0.062030 -0.025864 0.000000
0.062455 -0.026493 0.000000
0.062798 -0.027177 0.000000
0.063052 -0.027908 0.000000
0.063210 -0.028679 0.000000
0.063264 -0.029482 0.000000
0.063264 -0.029715 0.000000
0.063264 -0.030359 0.000000
0.063264 -0.031332 0.000000
0.063264 -0.032552 0.000000
0.063264 -0.033936 0.000000
0.063264 -0.035403 0.000000
0.063264 -0.036869 0.000000
0.063264 -0.038253 0.000000
0.063264 -0.039473 0.000000
-0.047203 -0.040421 0.000000
0.063264 -0.040446 0.000000
-0.046993 -0.041448 0.000000
0.047473 -0.047244 0.000000
0.063264 -0.041090 0.000000
0.063264 -0.041323 0.000000
0.063210 -0.042126 0.000000
-0.046655 -0.042422 0.000000
0.063052 -0.042897 0.000000
-0.046197 -0.043334 0.000000
0.062798 -0.043627 0.000000
-0.045630 -0.044173 0.000000
0.062455 -0.044311 0.000000
-0.044962 -0.044931 0.000000
0.062030 -0.044940 0.000000
-0.044204 -0.045599 0.000000
0.061529 -0.045509 0.000000
0.060960 -0.046010 0.000000
-0.043364 -0.046166 0.000000
0.060331 -0.046435 0.000000
-0.042453 -0.046623 0.000000
0.059647 -0.046778 0.000000
-0.041478 -0.046962 0.000000
0.058916 -0.047032 0.000000
-0.040451 -0.047172 0.000000
0.058146 -0.047190 0.000000
-0.039380 -0.047244 0.000000
0.057342 -0.047244 0.000000
-0.038292 -0.047244 0.000000
-0.035286 -0.047244 0.000000
-0.030744 -0.047244 0.000000
-0.025050 -0.047244 0.000000
-0.018590 -0.047244 0.000000
-0.011745 -0.047244 0.000000
-0.004900 -0.047244 0.000000
0.001561 -0.047244 0.000000
0.007254 -0.047244 0.000000
0.011796 -0.047244 0.000000
0.014803 -0.047244 0.000000
0.047473 -0.047438 0.000000
0.047473 -0.047975 0.000000
0.047473 -0.048785 0.000000
0.047473 -0.049802 0.000000
0.047473 -0.050955 0.000000
0.047473 -0.052177 0.000000
0.047473 -0.053399 0.000000
0.047473 -0.054553 0.000000
0.047473 -0.055569 0.000000
0.047473 -0.056380 0.000000
0.047473 -0.056917 0.000000
0.047473 -0.057111 0.000000
0.023840 -0.057914 0.000000
0.047419 -0.057914 0.000000
0.023997 -0.058685 0.000000
0.047261 -0.058685 0.000000
0.024251 -0.059415 0.000000
0.047007 -0.059415 0.000000
0.024594 -0.060099 0.000000
0.046664 -0.060099 0.000000
0.025020 -0.060728 0.000000
0.046238 -0.060728 0.000000
0.025521 -0.061297 0.000000
0.045738 -0.061297 0.000000
0.026089 -0.061798 0.000000
0.045169 -0.061798 0.000000
0.026719 -0.062223 0.000000
0.044539 -0.062223 0.000000
0.027403 -0.062566 0.000000
0.043855 -0.062566 0.000000
0.028134 -0.062820 0.000000
0.043125 -0.062820 0.000000
0.028904 -0.062978 0.000000
0.042354 -0.062978 0.000000
0.029707 -0.063032 0.000000
0.041551 -0.063032 0.000000
0.029940 -0.063032 0.000000
0.030585 -0.063032 0.000000
0.031558 -0.063032 0.000000
0.032778 -0.063032 0.000000
0.034162 -0.063032 0.000000
0.035629 -0.063032 0.000000
0.037096 -0.063032 0.000000
0.038480 -0.063032 0.000000
0.039700 -0.063032 0.000000
0.040674 -0.063032 0.000000
0.041318 -0.063032 0.000000
3 0 1 2
3 0 3 1
3 0 4 3
3 0 5 4
3 0 6 5
3 0 7 6
3 0 8 7
3 0 9 8
3 0 10 9
3 0 11 10
3 0 12 11
3 0 13 12
3 0 14 13
3 15 14 0
3 15 16 14
3 17 16 15
3 17 18 16
3 19 18 17
3 19 20 18
3 21 20 19
3 21 22 20
3 23 22 21
3 23 24 22
3 25 24 23
3 25 26 24
3 27 26 25
3 27 28 26
3 29 28 27
3 29 30 28
3 31 30 29
3 31 32 30
3 33 32 31
3 33 34 32
3 35 34 33
3 35 36 34
3 37 36 35
3 37 38 36
3 39 38 37
3 40 38 39
3 41 38 40
3 41 42 38
3 43 42 41
3 44 42 43
3 45 42 44
3 45 46 42
3 47 46 45
3 48 46 47
3 49 46 48
3 50 46 49
3 51 46 50
3 52 51 53
3 52 46 51
3 54 55 56
3 54 57 55
3 54 58 57
3 54 59 58
3 54 60 59
3 54 61 60
3 54 62 61
3 54 63 62
3 54 64 63
3 54 65 64
3 54 66 65
3 54 67 66
3 54 68 67
3 69 46 52
3 54 70 68
3 71 46 69
3 54 72 70
3 73 46 71
3 54 74 72
3 75 46 73
3 54 76 74
3 77 46 75
3 54 78 76
3 79 46 77
3 80 46 79
3 54 81 78
3 80 82 46
3 83 82 80
3 54 84 81
3 85 82 83
3 54 86 84
3 87 82 85
3 54 88 86
3 89 82 87
3 54 90 88
3 91 82 89
3 92 82 91
3 93 82 92
3 54 94 90
3 95 82 93
3 54 96 94
3 96 97 94
3 98 82 95
3 99 82 98
3 99 100 82
3 101 100 99
3 102 100 101
3 103 100 102
3 104 100 103
3 105 100 104
3 106 100 105
3 107 100 106
3 108 100 107
3 109 100 108
3 110 100 109
3 110 111 100
3 111 112 100
3 113 111 110
3 114 111 113
3 115 111 114
3 116 111 115
3 117 111 116
3 118 111 117
3 119 111 118
3 120 111 119
3 121 111 120
3 122 111 121
3 123 111 122
3 124 111 123
3 125 111 124
3 126 111 125
3 127 111 126
3 128 111 127
3 129 111 128
3 130 111 129
3 131 111 130
3 132 112 111
3 133 97 96
3 132 134 112
3 132 135 134
3 132 136 135
3 132 137 136
3 132 138 137
3 132 139 138
3 132 140 139
3 132 141 140
3 133 142 97
3 133 143 142
3 133 144 143
3 133 145 144
3 133 146 145
3 133 147 146
3 133 148 147
3 133 149 148
3 133 150 149
3 133 151 150
3 133 152 151
3 133 153 152
3 133 154 153
3 133 155 154
3 133 156 155
3 133 157 156
3 133 158 157
3 133 159 158
3 133 160 159
3 133 161 160
3 133 162 161
3 133 163 162
3 164 141 132
3 133 165 163
3 166 141 164
3 133 167 165
3 167 168 165
3 167 169 168
3 167 170 169
3 171 141 166
3 167 172 170
3 173 141 171
3 167 174 172
3 175 141 173
3 167 176 174
3 177 141 175
3 167 178 176
3 179 141 177
3 167 180 178
3 167 181 180
3 182 141 179
3 167 183 181
3 184 141 182
3 167 185 183
3 186 141 184
3 167 187 185
3 188 141 186
3 167 189 187
3 190 141 188
3 167 191 189
3 192 141 190
3 193 141 192
3 194 141 193
3 195 141 194
3 196 141 195
3 197 141 196
3 198 141 197
3 199 141 198
3 200 141 199
3 201 141 200
3 202 141 201
3 133 203 167
3 133 204 203
3 133 205 204
3 133 206 205
3 133 207 206
3 133 208 207
3 133 209 208
3 133 210 209
3 133 211 210
3 133 212 211
3 133 213 212
3 133 214 213
3 215 214 133
3 215 216 214
3 217 216 215
3 217 218 216
3 219 218 217
3 219 220 218
3 221 220 219
3 221 222 220
3 223 222 221
3 223 224 222
3 225 224 223
3 225 226 224
3 227 226 225
3 227 228 226
3 229 228 227
3 229 230 228
3 231 230 229
3 231 232 230
3 233 232 231
3 233 234 232
3 235 234 233
3 235 236 234
3 237 236 235
3 237 238 236
3 239 238 237
3 240 238 239
3 241 238 240
3 242 238 241
3 243 238 242
3 244 238 243
3 245 238 244
3 246 238 245
3 247 238 246
3 248 238 247
3 249 238 248

View File

@@ -30,7 +30,7 @@ void main()
float maskIntensity = (maskColor.r + maskColor.g + maskColor.b) / 3.0;
float A = textureColor.a * vertexColor.a * color.a * maskIntensity;
A -= stipple * ( int(gl_FragCoord.x + gl_FragCoord.y) % 2 > 0 ? 0.05 : 0.95 );
A += stipple * ( int(gl_FragCoord.x + gl_FragCoord.y) % 2 );
// output RGBA
FragColor = vec4(RGB, clamp(A, 0.0, 1.0) );

View File

@@ -22,6 +22,14 @@ XMLElement *tinyxml2::XMLElementFromGLM(XMLDocument *doc, glm::ivec2 vector)
return newelement;
}
XMLElement *tinyxml2::XMLElementFromGLM(XMLDocument *doc, glm::vec2 vector)
{
XMLElement *newelement = doc->NewElement( "vec2" );
newelement->SetAttribute("x", vector.x);
newelement->SetAttribute("y", vector.y);
return newelement;
}
XMLElement *tinyxml2::XMLElementFromGLM(XMLDocument *doc, glm::vec3 vector)
{
XMLElement *newelement = doc->NewElement( "vec3" );
@@ -62,6 +70,14 @@ void tinyxml2::XMLElementToGLM(XMLElement *elem, glm::ivec2 &vector)
elem->QueryIntAttribute("y", &vector.y);
}
void tinyxml2::XMLElementToGLM(XMLElement *elem, glm::vec2 &vector)
{
if ( !elem || std::string(elem->Name()).find("vec2") == std::string::npos )
return;
elem->QueryFloatAttribute("x", &vector.x); // If this fails, original value is left as-is
elem->QueryFloatAttribute("y", &vector.y);
}
void tinyxml2::XMLElementToGLM(XMLElement *elem, glm::vec3 &vector)
{
if ( !elem || std::string(elem->Name()).find("vec3") == std::string::npos )

View File

@@ -10,11 +10,13 @@ class XMLDocument;
class XMLElement;
XMLElement *XMLElementFromGLM(XMLDocument *doc, glm::ivec2 vector);
XMLElement *XMLElementFromGLM(XMLDocument *doc, glm::vec2 vector);
XMLElement *XMLElementFromGLM(XMLDocument *doc, glm::vec3 vector);
XMLElement *XMLElementFromGLM(XMLDocument *doc, glm::vec4 vector);
XMLElement *XMLElementFromGLM(XMLDocument *doc, glm::mat4 matrix);
void XMLElementToGLM(XMLElement *elem, glm::ivec2 &vector);
void XMLElementToGLM(XMLElement *elem, glm::vec2 &vector);
void XMLElementToGLM(XMLElement *elem, glm::vec3 &vector);
void XMLElementToGLM(XMLElement *elem, glm::vec4 &vector);
void XMLElementToGLM(XMLElement *elem, glm::mat4 &matrix);