本文整理汇总了C++中ofVec2f::set方法的典型用法代码示例。如果您正苦于以下问题:C++ ofVec2f::set方法的具体用法?C++ ofVec2f::set怎么用?C++ ofVec2f::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofVec2f
的用法示例。
在下文中一共展示了ofVec2f::set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trackpad_mouse_scroll
void trackpad_mouse_scroll(float delta_x, float delta_y) {
checkGesture(TRACKPAD_SCROLL);
scrollVelocity.set(delta_x, delta_y);
scrollPosition += scrollVelocity;
cam = camStart;
cam.truck(scrollScale * scrollPosition.x);
cam.boom(scrollScale * -scrollPosition.y);
}
示例2: getTriangleFromSegmentSize
bool getTriangleFromSegmentSize(double _szA, double _szB, double _szC, double x0, double y0, double _angle, double _scale, ofVec2f & _ptA, ofVec2f & _ptB, ofVec2f & _ptC) {
double r0 = _szB * _scale;
double x1 = 0 + _szA * _scale;
double y1 = 0;
double r1 = _szC * _scale;
vector<ofVec2f> _points;
circlesIntersection(0, 0, r0, x1, y1, r1, _points);
if(_points.size() == 0) return false; // dont intersect --- sides dont make a triangle
_ptA.set(0, 0);
_ptB.set(x1, y1);
_ptC.set(_points[1].x, _points[1].y);
_ptC.x = _ptB.x + (_ptA.x - _ptC.x);
_ptC.y = _ptB.y + (_ptA.y - _ptC.y);
double _sin = sin(ofDegToRad(_angle));
double _cos = cos(ofDegToRad(_angle));
ofVec2f _pivot = (_ptA + _ptB + _ptC) / 3.0;
_ptA -= _pivot;
_ptB -= _pivot;
_ptC -= _pivot;
_ptA = rotatePoint(_ptA.x, _ptA.y, 0, 0, 0, 0, _sin, _cos);
_ptB = rotatePoint(_ptB.x, _ptB.y, 0, 0, 0, 0, _sin, _cos);
_ptC = rotatePoint(_ptC.x, _ptC.y, 0, 0, 0, 0, _sin, _cos);
_ptA += ofVec2f(x0,y0);
_ptB += ofVec2f(x0,y0);
_ptC += ofVec2f(x0,y0);
return true;
}
示例3: pivot
void handle::pivot(float f, ofVec2f p, ofVec2f t, string jType, string actor){
ofVec2f np(m_posC);
if(jType == "weld"){
np = m_posC.getRotated(f, p, ofVec3f(0,0,1));
t.set(np - m_posC);
m_posC.set(np);
m_rotC += f;
}else if(jType == "pivot"){
if(m_posC != p){
m_posC += t;
}
}
//recursive function call on children
vector <handleJoint>::iterator it = m_children.begin();
while(it != m_children.end()){
if(it->m_handle->getIndex() == actor){++it; continue;} //actor is to prevent double calls
if(it->m_type == "free"){++it; continue;}
if(jType == "weld" && it->m_type == "weld"){
it->m_handle->pivot(f, p, t, "weld", m_index);
}else if(jType == "pivot" || it->m_type == "pivot"){
if(m_posC != p)it->m_handle->pivot(f, p, t, "pivot", m_index);
}
++it;
}
//pivot the parent
if(m_parent){
if(actor != m_parent->getIndex()){
handleJoint hj = m_parent->getChildJoint(m_index);
if(jType == "weld" && hj.m_type == "weld"){
m_parent->pivot(f, p, t, "weld", m_index);
}else if(jType == "pivot" || hj.m_type == "pivot"){
if(m_posC != p)m_parent->pivot(f, p, t, "pivot", m_index);
}
}
}
}
示例4: fitLine
void fitLine(const ofPolyline& polyline, ofVec2f& point, ofVec2f& direction) {
Vec4f line;
fitLine(Mat(toCv(polyline)), line, CV_DIST_L2, 0, .01, .01);
direction.set(line[0], line[1]);
point.set(line[2], line[3]);
}
示例5: setForce
void setForce(float x, float y) {
force.set(x,y);
}
示例6: setPos
void setPos(float x, float y) {
pos.set(x,y);
}
示例7: setup
//--------------------------------------------------------------
void ofApp::setup(){
// Init
ofBackground(255, 255, 255);
ofSetFrameRate(59.94);
font.load("MuseoSans_500.otf", 45);
fontSmall.load("MuseoSans_500.otf", 22);
// Videos loading
videoSize.set(1280, 720);
ofFbo f;
f.allocate(videoSize.x, videoSize.y);
fbos.push_back(f);
thumbVideoSize.set(320, 180);
image.load(targetDate + "/kmeans.png");
for (int i = 0; i < 1; i++) {
ofVideoPlayer v;
videos.push_back(v);
videos[i].load(targetDate + "/movie.mov");
videos[i].play();
float speed = 1;
videoSpeeds.push_back(videoSpeed);
f.allocate(thumbVideoSize.x, thumbVideoSize.y);
fbos.push_back(f);
}
myGlitch.setup(&fbos[0]);
// GUI Set up
gui.setup();
gui.add(rateThreshold.setup("rate", ofVec2f(50, 120), ofVec2f(0, 0), ofVec2f(180, 180)));
gui.add(taionThreshold.setup("taion", 35, 30.0, 40.0));
gui.setPosition(videoSize.x + 20, 300);
setupJsons();
averageTaion = getAverage(taions);
minMaxTaion = getMinMax(taions);
minMaxRate = getMinMax(rates);
loading = false;
csv.load(targetDate + "/rt.csv");
for(int i = 0; i < csv.getNumRows(); i++) {
// Rt mode
int a = ofToInt(csv[i][3]);
// D mode
// int a = ofToInt(csv[i][2]) + 1;
cls.push_back(a);
}
afont.loadFont("fontawesome-webfont.ttf", 40);
setPieChart();
for (int i = 0; i < 4; i++) {
ofPath path;
switch (i) {
case 0:
path.setColor(ofColor(69,105,144));
break;
case 1:
path.setColor(ofColor(239,118,122));
break;
case 2:
path.setColor(ofColor(73,190,170));
break;
case 3:
path.setColor(ofColor(238,184,104));
break;
default:
break;
}
path.setCircleResolution(360);
path.moveTo(150, 150);
path.arc( 150, 150, 200, 200, lastAngle, lastAngle + angles[i]);
lastAngle += angles[i];
paths.push_back(path);
}
choosedCluster = 1;
//ウィンドウ初期位置
ofSetWindowPosition(1441,0);
for (int i = 0; i < cls.size(); i++) {
cout << cls[i] << endl;
}
}
示例8: trackpad_mouse_move
void trackpad_mouse_move(float x, float y) {
mousePosition.set(x, y);
}
示例9: trackpad_swipe
void trackpad_swipe(float delta_x, float delta_y) {
checkGesture(TRACKPAD_SWIPE);
swipeVelocity.set(delta_x, delta_y);
swipePosition += swipeVelocity;
}
示例10: setPosition
void setPosition(float x, float y) {
position.set(x, y);
midi.sendControlChange(1, 64 + index, getPresence());
}
示例11: setup
void Controller::setup(ofTexture * texture, ofVec2f originalSize, ofRectangle originalCoordinates, ofPoint originalPerspective[4], string name, float guiWidth, float guiHeight ){
// Arguments
this->texture = texture;
this->name = name;
this->guiWidth = guiWidth;
this->guiHeight = guiHeight;
if(originalSize.x==0.0
&& originalSize.y==0.0){
originalSize.set(texture->getWidth(), texture->getHeight());
}
this->originalSize = originalSize;
if(originalCoordinates.x==0.0
&& originalCoordinates.y==0.0
&& originalCoordinates.width==0.0
&& originalCoordinates.height==0.0){
if(ofGetUsingNormalizedTexCoords())originalCoordinates.set(0.0, 0.0, 1.0, 1.0);
else originalCoordinates.set(0.0, 0.0, texture->getWidth(), texture->getHeight());
}
this->originalCoordinates = originalCoordinates;
if(originalPerspective[0].x == 0 && originalPerspective[0].y == 0
&& originalPerspective[1].x == 0 && originalPerspective[1].y == 0
&& originalPerspective[2].x == 0 && originalPerspective[2].y == 0
&& originalPerspective[3].x == 0 && originalPerspective[3].y == 0){
originalPerspective[0].x = ofGetWidth()/2 - texture->getWidth()/2;
originalPerspective[0].y = ofGetHeight()/2 - texture->getHeight()/2;
originalPerspective[1].x = ofGetWidth()/2 + texture->getWidth()/2;
originalPerspective[1].y = ofGetHeight()/2 - texture->getHeight()/2;
originalPerspective[2].x = ofGetWidth()/2 + texture->getWidth()/2;
originalPerspective[2].y = ofGetHeight()/2 + texture->getHeight()/2;
originalPerspective[3].x = ofGetWidth()/2 - texture->getWidth()/2;
originalPerspective[3].y = ofGetHeight()/2 + texture->getHeight()/2;
}
memcpy(this->originalPerspective,originalPerspective,sizeof(ofPoint)*4);
// Register draw event for the enable/disable magic
ofAddListener(ofEvents().draw, this, &Controller::drawEvent);
drawing = false;
drawn = true;
// Some intial setup
guiHelperFbo.allocate(150, 60);
blendB = blendL = blendR = blendT = 0;
lastClickTime = ofGetElapsedTimeMillis();
historyIndex = -1;
guiHasChanged = false;
perspectiveHasChanged = false;
// Generate filenames
safename = safe_string(name);
stringstream ss_guiFile;
ss_guiFile << safename << "/gui.xml";
guiFile = ss_guiFile.str();
stringstream ss_perspectiveFile;
ss_perspectiveFile << safename << "/perspective.xml";
perspectiveFile = ss_perspectiveFile.str();
stringstream ss_meshFile;
ss_meshFile << safename << "/mesh";
meshFile = ss_meshFile.str();
// Perspective
perspective.setup(0, 0, getWindowWidth(), getWindowHeight());
perspective.setCornerSensibility(0.03);
perspective.activate();
ofAddListener(perspective.changeEvent, this, &Controller::onPerspectiveChange);
// Meshes
controlMesh.setMode(OF_PRIMITIVE_POINTS);
internalMesh.setMode(OF_PRIMITIVE_TRIANGLES);
// GUI
gui.setup(name, guiFile,guiWidth, guiHeight);
gui.setPosition(originalPerspective[0].x, originalPerspective[0].y);
ofxButton * load = new ofxButton();
load->setup("Load", guiWidth, guiHeight);
load->addListener(this, &Controller::onLoad);
gui.add(load);
ofxButton * save = new ofxButton();
save->setup("Save", guiWidth, guiHeight);
save->addListener(this, &Controller::onSave);
gui.add(save);
ofxToggle * enablePerspective = new ofxToggle();
enablePerspective->setup("Perspective Warp", true, guiWidth, guiHeight);
enablePerspective->addListener(this, &Controller::onEnablePerspective);
gui.add(enablePerspective);
ofxButton * resetPerspective = new ofxButton();
resetPerspective->setup("Reset Perspective", guiWidth, guiHeight);
resetPerspective->addListener(this, &Controller::onResetPerspective);
gui.add(resetPerspective);
ofxButton * resetMesh = new ofxButton();
resetMesh->setup("Reset Mesh", guiWidth, guiHeight);
resetMesh->addListener(this, &Controller::onResetMesh);
gui.add(resetMesh);
//.........这里部分代码省略.........