mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
Cleanup and
This commit is contained in:
113
Decorations.cpp
113
Decorations.cpp
@@ -13,30 +13,45 @@
|
||||
|
||||
Frame::Frame(Type type) : Node(), type_(type), side_(nullptr), top_(nullptr), shadow_(nullptr), square_(nullptr)
|
||||
{
|
||||
static Mesh *shadows[3] = {nullptr};
|
||||
if (shadows[0] == nullptr) {
|
||||
shadows[0] = new Mesh("mesh/glow.ply", "images/glow.dds");
|
||||
shadows[1] = new Mesh("mesh/shadow.ply", "images/shadow.dds");
|
||||
shadows[2] = new Mesh("mesh/shadow_perspective.ply", "images/shadow_perspective.dds");
|
||||
}
|
||||
static Mesh *frames[4] = {nullptr};
|
||||
if (frames[0] == nullptr) {
|
||||
frames[0] = new Mesh("mesh/border_round.ply");
|
||||
frames[1] = new Mesh("mesh/border_top.ply");
|
||||
frames[2] = new Mesh("mesh/border_large_round.ply");
|
||||
frames[3] = new Mesh("mesh/border_large_top.ply");
|
||||
}
|
||||
static LineSquare *sharpframe = new LineSquare( 3 );
|
||||
|
||||
color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
||||
switch (type) {
|
||||
case SHARP_LARGE:
|
||||
square_ = new LineSquare( 3 );
|
||||
shadow_ = new Mesh("mesh/glow.ply", "images/glow.dds");
|
||||
square_ = sharpframe;
|
||||
shadow_ = shadows[0];
|
||||
break;
|
||||
case SHARP_THIN:
|
||||
square_ = new LineSquare( 3 );
|
||||
square_ = sharpframe;
|
||||
break;
|
||||
case ROUND_LARGE:
|
||||
side_ = new Mesh("mesh/border_large_round.ply");
|
||||
top_ = new Mesh("mesh/border_large_top.ply");
|
||||
shadow_ = new Mesh("mesh/shadow.ply", "images/shadow.dds");
|
||||
side_ = frames[2];
|
||||
top_ = frames[3];
|
||||
shadow_ = shadows[1];
|
||||
break;
|
||||
default:
|
||||
case ROUND_THIN:
|
||||
side_ = new Mesh("mesh/border_round.ply");
|
||||
top_ = new Mesh("mesh/border_top.ply");
|
||||
shadow_ = new Mesh("mesh/shadow.ply", "images/shadow.dds");
|
||||
side_ = frames[0];
|
||||
top_ = frames[1];
|
||||
shadow_ = shadows[1];
|
||||
break;
|
||||
case ROUND_SHADOW:
|
||||
side_ = new Mesh("mesh/border_round.ply");
|
||||
top_ = new Mesh("mesh/border_top.ply");
|
||||
shadow_ = new Mesh("mesh/shadow_perspective.ply", "images/shadow_perspective.dds");
|
||||
side_ = frames[0];
|
||||
top_ = frames[1];
|
||||
shadow_ = shadows[2];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -44,9 +59,7 @@ Frame::Frame(Type type) : Node(), type_(type), side_(nullptr), top_(nullptr), sh
|
||||
|
||||
Frame::~Frame()
|
||||
{
|
||||
if(side_) delete side_;
|
||||
if(top_) delete top_;
|
||||
if(shadow_) delete shadow_;
|
||||
|
||||
}
|
||||
|
||||
void Frame::update( float dt )
|
||||
@@ -58,14 +71,21 @@ void Frame::update( float dt )
|
||||
side_->update(dt);
|
||||
if(shadow_)
|
||||
shadow_->update(dt);
|
||||
if(square_)
|
||||
square_->update(dt);
|
||||
}
|
||||
|
||||
void Frame::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
{
|
||||
if ( !initialized() ) {
|
||||
if(side_) side_->init();
|
||||
if(top_) top_->init();
|
||||
if(shadow_) shadow_->init();
|
||||
if(side_ && !side_->initialized())
|
||||
side_->init();
|
||||
if(top_ && !top_->initialized())
|
||||
top_->init();
|
||||
if(shadow_ && !shadow_->initialized())
|
||||
shadow_->init();
|
||||
if(square_ && !square_->initialized())
|
||||
square_->init();
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -127,21 +147,21 @@ void Frame::accept(Visitor& v)
|
||||
|
||||
Handles::Handles(Type type) : Node(), type_(type)
|
||||
{
|
||||
color = glm::vec4( 1.f, 1.f, 0.f, 1.f);
|
||||
static Mesh *handle_rotation_ = new Mesh("mesh/border_handles_rotation.ply");
|
||||
static Mesh *handle_corner = new Mesh("mesh/border_handles_overlay.ply");
|
||||
|
||||
color = glm::vec4( 1.f, 1.f, 0.f, 1.f);
|
||||
if ( type_ == ROTATE ) {
|
||||
handle_ = new Mesh("mesh/border_handles_rotation.ply");
|
||||
handle_ = handle_rotation_;
|
||||
}
|
||||
else {
|
||||
// handle_ = new LineSquare(color, int ( 2.1f * Rendering::manager().DPIScale()) );
|
||||
handle_ = new Mesh("mesh/border_handles_overlay.ply");
|
||||
handle_ = handle_corner;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Handles::~Handles()
|
||||
{
|
||||
if(handle_) delete handle_;
|
||||
}
|
||||
|
||||
void Handles::update( float dt )
|
||||
@@ -153,7 +173,8 @@ void Handles::update( float dt )
|
||||
void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
{
|
||||
if ( !initialized() ) {
|
||||
if(handle_) handle_->init();
|
||||
if(handle_ && !handle_->initialized())
|
||||
handle_->init();
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -248,45 +269,33 @@ void Handles::accept(Visitor& v)
|
||||
|
||||
Icon::Icon(Type style, glm::vec3 pos) : Node()
|
||||
{
|
||||
color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
||||
translation_ = pos;
|
||||
|
||||
switch (style) {
|
||||
case IMAGE:
|
||||
icon_ = new Mesh("mesh/icon_image.ply");
|
||||
break;
|
||||
case VIDEO:
|
||||
icon_ = new Mesh("mesh/icon_video.ply");
|
||||
break;
|
||||
case SESSION:
|
||||
icon_ = new Mesh("mesh/icon_vimix.ply");
|
||||
break;
|
||||
case CLONE:
|
||||
icon_ = new Mesh("mesh/icon_clone.ply");
|
||||
break;
|
||||
case RENDER:
|
||||
icon_ = new Mesh("mesh/icon_render.ply");
|
||||
break;
|
||||
case EMPTY:
|
||||
icon_ = new Mesh("mesh/icon_empty.ply");
|
||||
break;
|
||||
default:
|
||||
case GENERIC:
|
||||
icon_ = new Mesh("mesh/point.ply");
|
||||
break;
|
||||
static Mesh *icons[7] = {nullptr};
|
||||
if (icons[0] == nullptr) {
|
||||
icons[IMAGE] = new Mesh("mesh/icon_image.ply");
|
||||
icons[VIDEO] = new Mesh("mesh/icon_video.ply");
|
||||
icons[SESSION] = new Mesh("mesh/icon_vimix.ply");
|
||||
icons[CLONE] = new Mesh("mesh/icon_clone.ply");
|
||||
icons[RENDER] = new Mesh("mesh/icon_render.ply");
|
||||
icons[EMPTY] = new Mesh("mesh/icon_empty.ply");
|
||||
icons[GENERIC] = new Mesh("mesh/point.ply");
|
||||
}
|
||||
|
||||
icon_ = icons[style];
|
||||
translation_ = pos;
|
||||
color = glm::vec4( 1.f, 1.f, 1.f, 1.f);
|
||||
|
||||
}
|
||||
|
||||
Icon::~Icon()
|
||||
{
|
||||
if(icon_) delete icon_;
|
||||
|
||||
}
|
||||
|
||||
void Icon::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
{
|
||||
if ( !initialized() ) {
|
||||
if(icon_) icon_->init();
|
||||
if(icon_ && !icon_->initialized())
|
||||
icon_->init();
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,4 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
// TODO Shadow mesh with unique vao
|
||||
|
||||
|
||||
#endif // DECORATIONS_H
|
||||
|
||||
@@ -38,7 +38,7 @@ void ImageShader::use()
|
||||
program_->setUniform("stipple", stipple);
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
if ( mask < 9 ) {
|
||||
if ( mask < 10 ) {
|
||||
glBindTexture(GL_TEXTURE_2D, mask_presets[mask]);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
2
Mesh.h
2
Mesh.h
@@ -26,7 +26,7 @@ public:
|
||||
inline std::string meshPath() const { return mesh_resource_; }
|
||||
inline std::string texturePath() const { return texture_resource_; }
|
||||
|
||||
protected:
|
||||
//protected:
|
||||
std::string mesh_resource_;
|
||||
std::string texture_resource_;
|
||||
uint textureindex_;
|
||||
|
||||
@@ -209,7 +209,7 @@ Points::Points(std::vector<glm::vec3> points, glm::vec4 color, uint pointsize) :
|
||||
indices_.push_back ( i );
|
||||
}
|
||||
|
||||
drawMode_ = GL_POINTS;
|
||||
drawMode_ = GL_POINTS; // TODO implement drawing of points as Mesh
|
||||
pointsize_ = pointsize;
|
||||
}
|
||||
|
||||
|
||||
44
Scene.cpp
44
Scene.cpp
@@ -64,7 +64,9 @@ void Node::accept(Visitor& v)
|
||||
v.visit(*this);
|
||||
}
|
||||
|
||||
//
|
||||
// Primitive
|
||||
//
|
||||
|
||||
Primitive::~Primitive()
|
||||
{
|
||||
@@ -181,8 +183,10 @@ void Primitive::replaceShader( Shader *newshader )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Group
|
||||
//
|
||||
|
||||
Group::~Group()
|
||||
{
|
||||
clear();
|
||||
@@ -292,11 +296,34 @@ Node *Group::back()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint Group::numChildren() const
|
||||
//
|
||||
// Switch node
|
||||
//
|
||||
|
||||
Switch::~Switch()
|
||||
{
|
||||
return children_.size();
|
||||
clear();
|
||||
}
|
||||
|
||||
void Switch::clear()
|
||||
{
|
||||
for(std::vector<Node *>::iterator it = children_.begin(); it != children_.end(); ) {
|
||||
// one less ref to this node
|
||||
(*it)->refcount_--;
|
||||
// if this group was the only remaining parent
|
||||
if ( (*it)->refcount_ < 1 ) {
|
||||
// delete
|
||||
delete (*it);
|
||||
}
|
||||
// erase this iterator from the list
|
||||
it = children_.erase(it);
|
||||
}
|
||||
|
||||
// reset active
|
||||
active_ = 0;
|
||||
}
|
||||
|
||||
|
||||
void Switch::update( float dt )
|
||||
{
|
||||
Node::update(dt);
|
||||
@@ -341,14 +368,20 @@ Node *Switch::child(uint index) const
|
||||
uint Switch::attach(Node *child)
|
||||
{
|
||||
children_.push_back(child);
|
||||
child->refcount_++;
|
||||
|
||||
// make new child active
|
||||
active_ = children_.size() - 1;
|
||||
return active_;
|
||||
}
|
||||
|
||||
void Switch::detatch(Node *child)
|
||||
{
|
||||
// if removing the active child, it cannot be active anymore
|
||||
if ( children_.at(active_) == child )
|
||||
active_ = 0;
|
||||
|
||||
// find the node with this id, and erase it out of the list of children
|
||||
// NB: do NOT delete with remove : this takes all nodes with same depth (i.e. equal depth in set)
|
||||
std::vector<Node *>::iterator it = std::find_if(children_.begin(), children_.end(), hasId(child->id()));
|
||||
if ( it != children_.end()) {
|
||||
// detatch child from group parent
|
||||
@@ -357,6 +390,9 @@ void Switch::detatch(Node *child)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Scene
|
||||
//
|
||||
|
||||
Scene::Scene()
|
||||
{
|
||||
|
||||
22
Scene.h
22
Scene.h
@@ -165,20 +165,23 @@ public:
|
||||
Group() : Node() {}
|
||||
virtual ~Group();
|
||||
|
||||
// Node interface
|
||||
virtual void update (float dt) override;
|
||||
virtual void accept (Visitor& v) override;
|
||||
virtual void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
||||
|
||||
// container
|
||||
void clear();
|
||||
void attach (Node *child);
|
||||
void attach (Node *child);
|
||||
void detatch (Node *child);
|
||||
void sort();
|
||||
inline uint numChildren () const { return children_.size(); }
|
||||
|
||||
// Group specific access to its Nodes
|
||||
void sort();
|
||||
NodeSet::iterator begin();
|
||||
NodeSet::iterator end();
|
||||
Node *front();
|
||||
Node *back();
|
||||
uint numChildren() const;
|
||||
|
||||
protected:
|
||||
NodeSet children_;
|
||||
@@ -186,7 +189,7 @@ protected:
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The Switch class is a Group to selectively update & draw ONE selected child
|
||||
* @brief The Switch class selectively updates & draws ONE selected child
|
||||
*
|
||||
* update() will update only the active child
|
||||
* draw() will draw only the active child
|
||||
@@ -196,18 +199,23 @@ class Switch : public Node {
|
||||
|
||||
public:
|
||||
Switch() : Node(), active_(0) {}
|
||||
virtual ~Switch();
|
||||
|
||||
// Node interface
|
||||
virtual void update (float dt) override;
|
||||
virtual void accept (Visitor& v) override;
|
||||
virtual void draw (glm::mat4 modelview, glm::mat4 projection) override;
|
||||
|
||||
// container
|
||||
void clear();
|
||||
uint attach (Node *child);
|
||||
void detatch (Node *child);
|
||||
void setActive (uint index);
|
||||
inline uint numChildren () const { return children_.size(); }
|
||||
|
||||
uint active () const { return active_; }
|
||||
// Switch specific access to its Nodes
|
||||
void setActive (uint index);
|
||||
uint active () const { return active_; }
|
||||
Node *activeChild () const { return child(active_); }
|
||||
uint numChildren () const { return children_.size(); }
|
||||
Node *child (uint index) const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -130,6 +130,7 @@ Source::~Source()
|
||||
delete groups_[View::LAYER];
|
||||
|
||||
groups_.clear();
|
||||
frames_.clear();
|
||||
overlays_.clear();
|
||||
|
||||
for (auto it = clones_.begin(); it != clones_.end(); it++)
|
||||
|
||||
16
View.cpp
16
View.cpp
@@ -111,12 +111,12 @@ std::pair<Node *, glm::vec2> View::pick(glm::vec3 point)
|
||||
|
||||
void GeometryView::select(glm::vec2 A, glm::vec2 B)
|
||||
{
|
||||
for(auto it = scene.ws()->begin(); it != scene.ws()->end(); it++) {
|
||||
if ( *it != selection_box_)
|
||||
selection_box_->attach(*it);
|
||||
}
|
||||
// for(auto it = scene.ws()->begin(); it != scene.ws()->end(); it++) {
|
||||
// if ( *it != selection_box_)
|
||||
// selection_box_->attach(*it);
|
||||
// }
|
||||
|
||||
selection_box_->visible_ = true;
|
||||
// selection_box_->visible_ = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -319,9 +319,9 @@ GeometryView::GeometryView() : View(GEOMETRY)
|
||||
scene.fg()->attach(border);
|
||||
|
||||
// selection box
|
||||
selection_box_ = new Box;
|
||||
selection_box_->visible_ = false;
|
||||
scene.ws()->attach(selection_box_);
|
||||
// selection_box_ = new Box;
|
||||
// selection_box_->visible_ = false;
|
||||
// scene.ws()->attach(selection_box_);
|
||||
}
|
||||
|
||||
void GeometryView::update(float dt)
|
||||
|
||||
Reference in New Issue
Block a user