Quantcast
Channel: beginners - openFrameworks
Viewing all 4929 articles
Browse latest View live

I can't call a function in a class from within a mouse event in another class

$
0
0

@lumooo wrote:

Is this supposed to not work, or am I missing something really trivial?
This is my code:

In main.cpp:

void ofApp::mouseDragged(int x, int y, int button){
    kinematics.mouseDragged(x, y, button);
}

in kinematics.cpp:

 void kinematics::mouseDragged(int x, int y, int button){
     targetx = x;
     targety = y;
     communication.sendData(draai1, draai2, draai3);
 }

in communication.cpp:

void communication::sendData(int a, int b, int c){

    ofDrawBitmapString(a, 20, 150);
    ofDrawBitmapString(b, 20, 200);
    ofDrawBitmapString(c, 20, 250);
    device.writeByte(a);

}

I don't get any errors, it just doesn't execute the function in communication.cpp

communication.hpp:

 #ifndef communication_hpp
 #define communication_hpp

#include <stdio.h>
#include <ofMain.h>
#include "ofxIO.h"
#include "ofxSerial.h"

class communication{
public:
    void setup();
    void update();
    void draw();
    void sendData(int a, int b, int c);

   ofx::IO::SerialDevice device;
};

#endif /* communication_hpp */

Posts: 5

Participants: 2

Read full topic


Reading and saving ofVec2f / ofVec4f from ofxXmlSettings

$
0
0

@SebastianSobotka wrote:

Hi,
Is there an easy way to get a vector value from XML file?

I would like to have:

declaration in ofApp.h
ofVec4f vec;

setup in ofApp.cpp
settings.loadFile("settings.xml");

settings.xml

<settings>
<something>116, 32, 767, 511</something>
</settings>

It works for int and float but not for vectors..
vec = settings.getValue("settings:something", ofVec4f(0,0,0,0));

Posts: 1

Participants: 1

Read full topic

Specify c++ flags on travis

$
0
0

@edapx wrote:

Hi, I'm trying to get my addons tested on travis and appveyor.

The problem is, that one of the addon that I've made, require the use of std::regex_iterator. On Mac, this is not a problem, clang does not complains.
On linux, it needs g++ >= 4.9, and the flag -std=gnu++14.

The flag that get actually passed on my build, it is g++ -c -g3 -DDEBUG -Wall -std=c++11.

https://travis-ci.org/edap/ofxLSystemGrammar/jobs/208960422

Someone has an idea about how to change it?

Also, I do not know how much sense it has to make a configuration on the CI that includes this flag. Are the addons under linux supposed to work with the flag std=c++11?

Posts: 1

Participants: 1

Read full topic

Load and save mp4 locally

$
0
0

@Pedro Garlaschi wrote:

Hey guys,

I've been working on this installation where i have a cms to pull a couple of images and mp4. I manage to save the images but i'm struggling to save the video files.

I've been trying to get one ofFIle object to load the video but nothing good yet. Any light in the end of the tunnel ?

Cheers

Posts: 2

Participants: 1

Read full topic

How to specify ofBackground( ) with a hex value instead of RGB?

$
0
0

@chadilaksono wrote:

I'm trying to specify my background color:
ofBackground(65,70,245);

Is there's anyway I can use a hex value instead of the RGB values? I tried doing this:
ofBackground(0x4146f5);

But that doesn't seem to be working. I know there's a way to set hex color using:
ofSetHexColor(0x4146f5);

But how do I do that for the background?

Posts: 3

Participants: 2

Read full topic

Videos Playing out of Sync

$
0
0

@ashutosh wrote:

Hi,

I am trying to play two locally stored, overlaid 4K videos in synchronization. However, I am experiencing a slight lag (2-3 frames) in one of them. Can someone kindly suggest me how I can achieve perfect sync.

My code is as follows:

void ofApp::setup(){
  ofBackground(255,255,255);
  ofSetVerticalSync(true);

  // HQ video
  movieHQ.load("horses.mp4");
  movieHQ.setLoopState(OF_LOOP_NORMAL);

  // LQ video
  movieLQ.load("horseslq.mp4");
  movieLQ.setLoopState(OF_LOOP_NORMAL);

  // Setting speeds equal
  movieHQ.setSpeed(1.0);
  movieLQ.setSpeed(1.0);
  movieLQ.play();
  movieHQ.play();

  // videoSection is of type ofPixels
  videoSection.allocate(600, 300, OF_PIXELS_RGB);

  // these are defined as global var
  x_pos = 0;
  y_pos = 0;

}

//--------------------------------------------------------------
void ofApp::update(){
  ofPixels & pixels = movieHQ.getPixels();

  // Croping a fixed sized rectangle from HQ video with starting point as current mouse pointer position
  pixels.cropTo(videoSection, x_pos, y_pos, 600, 300);

  // Taking entire 4K pixels of LQ video
  ofPixels & morepixels = movieLQ.getPixels();

  // Putting HQ pixel rectangle into LQ pixel 4K frame
  videoSection.pasteInto(morepixels, x_pos, y_pos);

  // videoTexture is of type ofTexture
  videoTexture.loadData(morepixels);
  movieLQ.update();
  movieHQ.update();
}

//--------------------------------------------------------------
void ofApp::draw(){
	videoTexture.draw(0, 0, 3840, 2160);
}
//--------------------------------------------------------------
// updates global variables x_pos and y_pos with current mouse positions
void ofApp::mouseMoved(int x, int y ){
	if ((x_pos < 3840) && (x_pos >= 0))
		x_pos = x;
	else
		x_pos = 3840;
	if ((y_pos < 2160) && (y_pos >= 0))
		y_pos = y;
	else
		y_pos = 2160;
}

Posts: 3

Participants: 3

Read full topic

ofParameter addListener doesn't match overloads

$
0
0

@Kaito_Kid wrote:

Hello,

I am starting to use OpenFrameworks with ofxGui.

I have the following lines:

    primType2D.setName("2D");
    primType2D.set(true);
    primType2D.addListener(this, &ofApp::primDim2DChanged);

here are the declarations of primType2D and primDim2DChanged:

    ofParameter<bool> primType2D;
    bool primDim2DChanged();

On build, I fail with this:
'ofAddListener': none of the 5 overloads could convert all the argument types (compiling source file ofApp.cpp)

it originates from:

openFrameworks\types\ofParameter.h line 435

I have no idea what I'm doing wrong. I tried explicitly giving the priority and switching the bool function to a void function, but it doesn't make any difference.

Posts: 5

Participants: 3

Read full topic

ofSystem() windows

$
0
0

@fresla wrote:

I guess this is really basic, but I have a few questions about ofSystem().

I need to record and play files from the kinect2 in my application, I found there is a command line utility to do this called KSUtil. It works perfectly with the ofxKinectForWindows2 addon, but I want to control this all from within my OF app.

I have added a path to KSUtil to my PATH variable and from the normal command line I can call this

KSUtil -play d:\Kinect\20170111_073508_00.xef

and it works perfectly, I thought I could call this from ofSystem(), but it does not work, I get an error that the specified file cannot be found. Is there some difference between what happens via ofSystem() and just using the command line?

Also how can I deal with white spaces in file paths when using ofSystem(), I get errors in other instances from having spaces in file paths and names, but I would like to be able to handle these as well.

Cheers

fred

Posts: 1

Participants: 1

Read full topic


Color and dimensions of ofSpherePrimitive

$
0
0

@Kaito_Kid wrote:

I am creating primitives using user input for the atributes (location, size, color, etc).

I could easily make a prism, using the following code

ofBoxPrimitive* box = new ofBoxPrimitive();
box->set(w, h, d);
box->setPosition(x, y, z);
//box->rotate(rand() % 360, 1.0, 0.0, 0.0);
//box->rotate(rand() % 360, 0, 1.0, 0.0);
//box->rotate(rand() % 360, 0, 0.0, 1.0);
for (int i = 0; i < 6; i++)
{
    box->setSideColor(i, fillCol);
}

But as for the ofSpherePrimitive, I can't find how to set the color to something else than white, and the size to something irregular (like a 3D ellipse? I don't know what's the word).

I figured out I should use textures to give the sphere a color, but I can't get it to work.

What is the recommended method to color and stretch an ofSpherePrimitive, or should I use another tye of object entirely? If yes, which one?

Posts: 1

Participants: 1

Read full topic

OSC over ethernet cable

$
0
0

@Sergio_Marchesini wrote:

Hi,
I am trying to send OSC from one raspberry to another to synchronize two ofxImageSequence playbacks.
Everything works fine if the sender and receiver are on two ofApps on the same machine, but I can not get the message across the eth0 connection.

I assigned static ips to both machines, and I can ping the receiver machine from the sender machine, still I can not get the message across.

I am wondering if I need to enable listening to the port somewhere in the receiver machine at networking level, or if there is some way of debugging this beyond trying to ping one machine from the other :slight_smile:

Thanks for any hint.

Posts: 1

Participants: 1

Read full topic

Correct way to select drawing order

$
0
0

@Kaito_Kid wrote:

I have a scene containing primitives created by the user (mostly cubes and spheres with custom colors and sizes).

Now, if I draw them all in the order they appeared, obviously I get problems, like a cube added later behind another one showing up on top of it even though it should not be visible without moving the camera.

If I check for their location on the z axis, that would make everything better, but it would still look bad if two cubes with different rotations were on top of each other. Instead of seeing part of both.

The "expected" result would be something like that

But it wouldn't work with this technique.

So what is the recommended way to select the order of drawing in order to get a scene as realistic as possible? There's probably more to it than just the order, so I'd like to know how should those primitive be drawn to obtain a realistic result?

Posts: 3

Participants: 2

Read full topic

Help moving triangles vertexes in 3d space with ofxTriangleMesh

$
0
0

@rojele wrote:

Hi, everyone,

I’m trying to access to z position of different vertexs of the multiple triangles in a mesh in order to move them in 3d space, but I don’t get to give them a new value.
I’m using the zach liebermann lib ofxTriangleMesh.
I’m trying to find the positions in the struct “meshTriangle”, as I guess I that’s the proper way, but I don’t know exactly how.
In fact, when I try to cout the values of meshTriangle.pts
for(int it=0; it<mesh.triangles[i].pts.size();it++){
cout << mesh.triangles[i].pts[2];cout << "\n";
}
I get the following error:
`member reference base ‘ofPoint[3]’ is not a structure or union`
, so I don't even know how to handle the values.

Any help would be very welcome, a lot of thanks in advance!

Posts: 2

Participants: 1

Read full topic

Check ofRay intersection with a ofMeshFace

$
0
0

@Kaito_Kid wrote:

Pretty self explanatory. I've tried many examples of code here, but I couldn't get one to work.

I have an ofRay (from ofxRay), and a list of of3dPrimitive. I am trying to figure out if the ray intersects a primitive, and if so, to know which primitive the ray intersected with "first" (as in, which one is the closest to the screen).

ofVec3f screenToWorld = camera.screenToWorld(ofVec3f(x, y, 0.0));

std::list<primitive>::iterator iterator;

ofRay ray(camera.getPosition(), screenToWorld - camera.getPosition(), true);

for (iterator = primitives.begin(); iterator != primitives.end(); ++iterator)
{
    if (!shiftHeld)
    {
       iterator->setSelected(false);
    }

    float* distance = 0;

    bool found = iterator->FindIntersection(ray, distance);
}

And my findIntersection looks like this:

bool primitive::calcTriangleIntersection(ofRay ray, float *result) const {

    ofMesh mesh = prim->getMesh();
    std::vector<ofMeshFace> indices = mesh.getUniqueFaces();

    for (std::vector<ofMeshFace>::iterator i = indices.begin(); i != indices.end(); ++i)
    {
        ofMeshFace face = *i;

        // Detection here

        if (detected intersection)
        {
            *result = distance;
            return true;
        }
    }
    return false;
}

I've tried so many things, but none of them works. I'm also drawing my rays to the screen, so I know for a fact that they are indeed created correctly and go in the right direction for an infinite distance

Posts: 1

Participants: 1

Read full topic

Msys2 dependencies for a standalone app (v0.9.8)

$
0
0

@bnc wrote:

Hi mingw friends,

My basic question is: What is the right way to distribute my app on windows?

I decided to give msys2 a try (since it has less dependencies than VS2015 ... I thought).
Everything went fine, until I copied my app to a clean WIN7 computer. It needed some dlls, like libwinpthread, etc. I copied all from the mingw32/bin to the data... and finally... the app wont start just crash (without any usable info)
I've also noticed that there is a "make copy_dlls" command, which should do the same thing, but it does not start, giving me this error:

HOST_OS=MINGW32_NT-6.1
checking pkg-config libraries: cairo zlib openssl glew
copying dlls to bin
cp: cannot stat '/mingw32/bin/libjasper-1.dll': No such file or directory
make: *** [/c/of_v0.9.8_msys2_release/libs/openFrameworksCompiled/project/msys2/config.msys2.default.mk:315: copy_dlls] Error 1

by changing the MSYS2_ROOT = /mingw32 to MSYS2_ROOT = /msys64/mingw32
it says:

HOST_OS=MINGW32_NT-6.1
checking pkg-config libraries: cairo zlib openssl glew
/bin/sh: /msys64/mingw32/bin/pkg-config: No such file or directory
/bin/sh: /msys64/mingw32/bin/pkg-config: No such file or directory
/bin/sh: /msys64/mingw32/bin/pkg-config: No such file or directory
/bin/sh: /msys64/mingw32/bin/pkg-config: No such file or directory
/bin/sh: /msys64/mingw32/bin/pkg-config: No such file or directory
/c/of_v0.9.8_msys2_release/libs/openFrameworksCompiled/project/makefileCommon/config.shared.mk:294: *** cairo not installed. Did you run the latest install_dependencies.sh? zlib not installed. Did you run the latest install_dependencies.sh? openssl not installed. Did you run the latest install_dependencies.sh? glew not installed. Did you run the latest install_dependencies.sh?. Stop.

And yes, I've run the latest install_dependencies.sh...

any help would be very appreciated!

Posts: 1

Participants: 1

Read full topic

ofTexture buffer from vidGrabber

$
0
0

@d_p wrote:

Hi folks! New here, this is my first project in oF.
What I'm trying to do is to build a video scratcher by filling in a buffer from my webcam and playing it back.
I'm using a vector of ofTexture for memory optimization. At each update cycle I store the current frame in an ofImage (named colorImg) and then pass it to the vector. Everything works fine, except that when I try to store for example one minute of video (3600 frames) I still have 2gb ram usage. Does the ofImage allocate a new one at each cycle? How could i solve this?

Thanks!
daniele

vector<ofTexture> buffer;

void ofScratcher::write(ofImage *frame){
    buffer[wPos].allocate(*frame);
}

void ofApp::update(){
    ofBackground(100,100,100);
    bool bNewFrame = false;
    vidGrabber.update();
    bNewFrame = vidGrabber.isFrameNew();

    if (bNewFrame){
        colorImg.setFromPixels(vidGrabber.getPixels());
        scratcher.write(&colorImg);
    }

    scratcher.setwPos();
    scratcher.setrPos();
}

Posts: 3

Participants: 2

Read full topic


Undefined symbols for architecture i386

$
0
0

@kotutku wrote:

Hi,

I'm trying to build this project: https://github.com/cyrilcode/cyril against openFrameworks 0.8.4 for i386 architecture, on latest XCode and macOS Sierra.

I've fixed some compilation errors, included all required libraries, etc., and now it's failing on the last linking step. This is the error I'm getting:

"ofAppGLFWWindow::error_cb(int, char const*)", referenced from:
      ofAppGLFWWindow::ofAppGLFWWindow() in openFrameworks.a(ofAppGLFWWindow.o)
  "ofAppGLFWWindow::windowShouldClose()", referenced from:
      vtable for ofAppGLFWWindow in openFrameworks.a(ofAppGLFWWindow.o)

I've tried multiple things: building with other SDKs (10.12, 10.11, 10.10) using system libfreetype, libfreeimage, other openFrameworks version (0.8.0, 0.8,4, 0.9.2, 0.9.8) and nothing helps - I'm getting the exact same linking errors.

Wham am I missing here?

Posts: 2

Participants: 1

Read full topic

Filling in DrawLine?

$
0
0

@mondaysfeelblue wrote:

Hi, new to of...
I drew a shape with ofDrawLine and trying to fill it with solid color.

I tried ofFill(); but it doesn't seem to work.

Is there another command for it?

Thanks in advance

Posts: 2

Participants: 2

Read full topic

ofxOscReceiver returning 0 for getNextMessage( ofxOscMessage & message )

$
0
0

@jaymollica wrote:

I've got a remote IP with an open port:

nc -vu MY_REMOTE_IP MY_PORT

returns:

Connection to MY_REMOTE_IP port MY_PORT [udp/sdfunc] succeeded!

But when I try to stream the UDP connection via my ofx app it says the connection is not returning any messages.

bool ofxOscReceiver::getNextMessage( ofxOscMessage & message )
{
	return messagesChannel.tryReceive(message);
}

the messagesChannel.tryReceive(message) is printing out as 0

the github repo of my example project is here:

Right now I'm just trying to print the UDP stream to the console, but I'm not sure how to verify that the UDP connection is actually streaming data to my remote?

I am not able to regularly access the server where the stream is hosted. But I can confirm that it is streaming the data when I access it locally.

If I get a positive nc result could there be anything preventing me from accessing the stream remotely?

Posts: 1

Participants: 1

Read full topic

Problem compiling with ofxAssimpModelLoader

$
0
0

@Kaito_Kid wrote:

I tried to add ofxAssimpModelLoader to my project.

I added all of the files in the addons directory of my project, and added all the include directories.

But I end up with those errors:

Does anyone have any idea what I'm doing wrong?

It looks like I'm missing some of the .cpp files that are supposed to be linked with the .h files, but I can't figure out what exactly is mising.

Posts: 1

Participants: 1

Read full topic

From Polyline to texture

$
0
0

@edapx wrote:

Hello, I want to make a terrain in 3D with a closed path on which the camera will move.
My idea is the following:
1) draw a closed path using ofPolyline.
2)Save this path in a texture
3)Pass the texture to a shader. Each pixel will have different color and heights based on how far is it from the the pixels that compose the path.

My question is, how can I pass the position of the vertices that compose the ofPolyline to a texture?

Posts: 1

Participants: 1

Read full topic

Viewing all 4929 articles
Browse latest View live