...
 
Commits (2)
#ifndef MenuItem_h
#define MenuItem_h
#pragma once
#include "ofMain.h"
class MenuItem
{
public:
MenuItem(std::string path, float _x, float _y, std::string _name)
{
name = _name;
if (ofLoadImage(tex, path))
{
if (tex.isAllocated())
{
draw_pos.x = _x;
draw_pos.y = _y;
float rect_x = draw_pos.x - (tex.getWidth() / 2);
float rect_y = draw_pos.y - (tex.getHeight() / 2);
hit_zone = ofRectangle(rect_x, rect_y, tex.getWidth(), tex.getHeight());
tex.setAnchorPercent(0.5, 0.5);
}
}
b_hovered = false;
b_selected = false;
}
~MenuItem()
{
if (tex.isAllocated())
{
tex.clear();
}
}
void draw()
{
if (!tex.isAllocated())
return;
ofPushStyle();
if (b_hovered) ofSetColor(ofColor::lightGrey);
else if (b_selected) ofSetColor(ofColor::orange);
else ofSetColor(ofColor::white);
tex.draw(draw_pos);
ofPopStyle();
}
bool inside(ofVec2f hit)
{
bool _hit = hit_zone.inside(hit);
if (_hit)
{
if (b_selected) return _hit;
else
{
b_hovered = true;
return _hit;
}
}
else
{
b_hovered = false;
return false;
}
}
void select()
{
b_selected = !b_selected;
b_hovered = !b_selected;
}
void unselect()
{
b_selected = false;
b_hovered = false;
}
std::string& getName()
{
return name;
}
private:
ofVec2f draw_pos;
ofTexture tex;
ofRectangle hit_zone;
std::string name;
bool b_hovered;
bool b_selected;
};
#endif /* MenuItem_h */
#ifndef ParamSliderItem_h
#define ParamSliderItem_h
#pragma once
#include "ofMain.h"
class ParamSliderItem
{
public:
ParamSliderItem(float _x, float _y, float _width, float _height, float _min, float _max, std::string _name)
{
name = _name;
draw_pos.x = _x;
draw_pos.y = _y;
float rect_x = draw_pos.x - (_width / 2);
float rect_y = draw_pos.y - (_height / 2);
hit_zone = ofRectangle(rect_x, rect_y, _width, _height);
min_val = _min;
max_val = _max;
b_selected = false;
b_hovered = false;
reset();
}
ParamSliderItem()
{
}
void draw()
{
ofPushStyle();
if (b_hovered) ofSetColor(ofColor::lightGrey);
else ofSetColor(ofColor::white);
float line_x = hit_zone.x;
float line_y = hit_zone.y + (hit_zone.height / 2);
/* Main transport line */
ofDrawLine(line_x, line_y, line_x+hit_zone.width, line_y);
/* Cursor */
ofSetLineWidth(3.0f);
ofDrawLine(line_x+(cur_pos*hit_zone.width), line_y-10, line_x+(cur_pos*hit_zone.width), line_y+10);
ofPopStyle();
}
bool inside(const ofVec2f& hit)
{
if (hit_zone.inside(hit))
{
if (b_selected) return true;
else
{
b_hovered = true;
return true;
}
}
else
{
b_hovered = false;
return false;
}
}
void select()
{
}
void unselect()
{
}
std::string& getName()
{
}
void mouseDown(const ofVec2f& _mouse)
{
cur_pos = (_mouse.x - hit_zone.x) / hit_zone.width;
cur_val = ofMap(cur_pos, 0.0f, 1.0f, min_val, max_val);
}
/*** ADDING THIS TO GET VALUES FROM ARDUINO */
void setValue(float val)
{
cur_val = val;
}
/*******/
float getValue()
{
return cur_val;
}
ofRectangle& getRect()
{
return hit_zone;
}
void reset()
{
cur_val = 1.0f;
cur_pos = ofMap(cur_val, min_val, max_val, 0.0f, 1.0f);
}
private:
ofVec2f draw_pos;
ofRectangle hit_zone;
float cur_pos;
float cur_val;
float min_val;
float max_val;
std::string name;
bool b_hovered;
bool b_selected;
};
#endif /* ParamSlider_h */
Console for VJing made with [openFrameworks](https://openframeworks.cc/)
It is using Arduino to connect to the interface,
and [HPV](https://github.com/vjacob/ofxHPVPlayer) file format for video (should allow high res video and high fps).
Useful link: [binaries for HPV_Creator](https://github.com/HasseltVR/Holo_Toolset/releases/tag/v1.1)
\ No newline at end of file
#ifndef RangeSliderItem_h
#define RangeSliderItem_h
#pragma once
#include "ofMain.h"
class RangeSliderItem
{
public:
RangeSliderItem(float _x, float _y, float _width, float _height, std::string _name)
{
name = _name;
draw_pos.x = _x;
draw_pos.y = _y;
float rect_x = draw_pos.x - (_width / 2);
float rect_y = draw_pos.y - (_height / 2);
hit_zone = ofRectangle(rect_x, rect_y, _width, _height);
b_selected = false;
b_hovered = false;
range_in = 0.f;
range_out = 1.f;
}
RangeSliderItem()
{
}
void draw()
{
ofPushStyle();
if (b_hovered) ofSetColor(ofColor::lightGrey);
else ofSetColor(ofColor::white);
float line_x = hit_zone.x;
float line_y = hit_zone.y + (hit_zone.height / 2);
/* Main transport line */
ofDrawLine(line_x, line_y, line_x+hit_zone.width, line_y);
/* Cursor */
ofSetLineWidth(3.0f);
ofDrawLine(line_x+cur_pos, line_y-10, line_x+cur_pos, line_y+10);
if (range_in > 0.0f || range_out < 1.0f)
{
/* Loop range */
ofSetColor(255,174,0,100);
float range_start = line_x + (hit_zone.width * range_in);
float range_end = hit_zone.width * (range_out-range_in);
ofDrawRectangle(range_start, line_y-10, range_end, 20);
}
ofPopStyle();
}
bool inside(const ofVec2f& hit)
{
if (hit_zone.inside(hit))
{
if (b_selected) return true;
else
{
b_hovered = true;
return true;
}
}
else
{
b_hovered = false;
return false;
}
}
void select()
{
}
void unselect()
{
}
std::string& getName()
{
}
void setPlayhead(float _cur_pos)
{
cur_pos = _cur_pos*hit_zone.width;
}
void mouseDown(const ofVec2f& _cursor)
{
cur_pos = (_cursor.x - (hit_zone.x + hit_zone.width * range_in)) / ((range_out - range_in) * hit_zone.width);
}
void setRangeIn(float _in)
{
range_in = (_in - hit_zone.x) / hit_zone.width;
if (range_in > range_out)
{
range_in = MAX(0.0f,range_out-0.1f);
}
}
void setRangeOut(float _out)
{
range_out = (_out - hit_zone.x) / hit_zone.width;
if (range_out < range_in)
{
range_out = MIN(1.0f,range_in+0.1f);
}
}
void clearRange()
{
range_in = 0.f;
range_out = 1.f;
}
float getValue()
{
return cur_pos;
}
ofVec2f getSelectedRange()
{
return ofVec2f(range_in, range_out);
}
ofRectangle& getRect()
{
return hit_zone;
}
private:
ofVec2f draw_pos;
ofRectangle hit_zone;
float cur_pos;
float range_in;
float range_out;
std::string name;
bool b_hovered;
bool b_selected;
};
#endif /* RangeSliderItem_h */
This diff is collapsed.
#pragma once
#include "ofMain.h"
#include "ofxHPVPlayer.h"
#include "ofxHapPlayer.h"
#include "ofxTextureRecorder.h"
#include "ofxDatGui.h"
#include "MenuItem.h"
#include "RangeSliderItem.h"
#include "ParamSliderItem.h"
#include "ofTrueTypeFontExt.h"
class ofApp : public ofBaseApp
{
......@@ -19,11 +14,7 @@ public:
void update();
void draw();
void exit();
void onHPVEvent(const HPVEvent& event);
void setupUI();
void keyPressed(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
......@@ -35,24 +26,16 @@ public:
int flickering(int length_in, int length_out, int max_opacity=100, int min_opacity=0,int delay=0);
ofxHPVPlayer hpvPlayer;
ofxHPVPlayer hpv_ch1;
ofxHPVPlayer hpv_ch2;
ofxHPVPlayer hpv_ch3;
ofxHapPlayer hpvPlayer, hpv_ch1, hpv_ch2, hpv_ch3;
ofImage mask_prep;
ofImage mask_ch1, mask_ch2, mask_ch3;
std::map<std::string, MenuItem *> ui_items;
RangeSliderItem * range_slider;
ParamSliderItem * speed_slider;
bool b_draw_stats;
bool b_draw_gui;
int framerate;
int actual_frame;
ofTrueTypeFontExt gui_font;
vector<string> video_names;
float potar_1, potar_2, potar_4, potar_0, potar_10, potar_11;
int opacity_1, opacity_2, opacity_3;
......@@ -98,6 +81,10 @@ public:
ofxDatGuiTextInput* input_text;
void onTextInputEvent(ofxDatGuiTextInputEvent e);
ofTrueTypeFont font;
// 3-Panels Masks
int panelWidth, panelHeight;
float speed_ch1, speed_ch2, speed_ch3;
private:
......
#pragma once
#include "ofMain.h"
class ofTrueTypeFontExt : public ofTrueTypeFont
{
public:
// -----------------------------------------------------------------
void drawStringShadowed( string _s, ofVec2f _pos,
ofColor _frontColor = ofColor(255,255,255), ofColor _backColor = ofColor(0,0,0) )
{
drawStringShadowed( _s, _pos.x, _pos.y, _frontColor, _backColor );
}
// -----------------------------------------------------------------
void drawStringShadowed( string _s, float _x, float _y,
ofColor _frontColor = ofColor(255,255,255), ofColor _backColor = ofColor(0,0,0) )
{
ofSetColor( _backColor );
drawString( _s, _x + 1, _y + 1 );
ofSetColor( _frontColor );
drawString( _s, _x, _y );
}
// -----------------------------------------------------------------
void drawTextureAtlas( float _x, float _y, float _w, float _h )
{
if( _w == 0.0f || _h == 0.0f )
{
_w = texAtlas.getWidth();
_h = texAtlas.getHeight();
}
texAtlas.draw( _x, _y, _w, _h );
}
};