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

ofxDatGui moving scrollview — items clearing and invalid indices

$
0
0

@robotPatrol wrote:

hi,

i am trying to move items in my scrollview element, but instead all the items clear. i have added an integer array to create indexes for the items to move to in setup, update, draw and by the clear button within the scroll view example. each time, the scroll view clears.

.h

#pragma once

#include "ofMain.h"
#include "ofxDatGui.h"

class ofApp : public ofBaseApp{

public:
	void setup();
	void update();
	void draw();

    int width;
    ofxDatGuiTheme* theme;
    ofxDatGuiButton* addItem;
    ofxDatGuiButton* clearAll;
    ofxDatGuiScrollView* view;

    void onScrollViewEvent(ofxDatGuiScrollViewEvent e);
    void onAddNewItemButtonClick(ofxDatGuiButtonEvent e);
    void onClearAllButtonClick(ofxDatGuiButtonEvent e);

    int intVals[8] = {3, 5, 6, 2, 1, 4, 7, 0};
};

.cpp

#include "ofApp.h"

void ofApp::setup()
{
    ofSetWindowShape(1920, 1080);
    ofSetWindowPosition(ofGetScreenWidth()/2 - ofGetWidth()/2, 0);

    width = 540;
    theme = new ofxDatGuiThemeMidnight();

// create a button to attach items to the scroll view //
    addItem = new ofxDatGuiButton("click to add item");
    addItem->setStripeVisible(false);
    addItem->setWidth(width);
    addItem->setPosition(ofGetWidth()/2 - addItem->getWidth()/2, 240);
    addItem->setLabelAlignment(ofxDatGuiAlignment::CENTER);
    addItem->onButtonEvent(this, &ofApp::onAddNewItemButtonClick);

// create a scroll view that displays eight items at a time //
    view = new ofxDatGuiScrollView("ScrollView #1", 8);
    view->setWidth(width);
    view->setPosition(addItem->getX(), addItem->getY() + addItem->getHeight() + 1);
    view->onScrollViewEvent(this, &ofApp::onScrollViewEvent);

// add a button to allow us to clear the scroll view out //
    clearAll = new ofxDatGuiButton("click to clear all items");
    clearAll->setStripeVisible(false);
    clearAll->setWidth(width);
    clearAll->setPosition(ofGetWidth()/2 - clearAll->getWidth()/2, view->getY() + view->getHeight() + 1);
    clearAll->setLabelAlignment(ofxDatGuiAlignment::CENTER);
    clearAll->onButtonEvent(this, &ofApp::onClearAllButtonClick);

// add a few items for testing //
    for(int i=0; i<8; i++) view->add("item " + ofToString(view->getNumItems() + 1));
    addItem->setLabel("click to add item - " + ofToString(view->getNumItems()) + " items");

}

void ofApp::update()
{
    view->update();
    addItem->update();
    clearAll->update();

}

void ofApp::draw()
{
    view->draw();
    addItem->draw();
    clearAll->draw();
}

void ofApp::onScrollViewEvent(ofxDatGuiScrollViewEvent e)
{
    cout << e.target->getLabel() << " [index " << e.index << "] selected in [" << e.parent->getName() << "]" << endl;
}

void ofApp::onAddNewItemButtonClick(ofxDatGuiButtonEvent e)
{
    view->add("item " + ofToString(view->getNumItems() + 1));
    addItem->setLabel("click to add item - " + ofToString(view->getNumItems()) + " items");
}

void ofApp::onClearAllButtonClick(ofxDatGuiButtonEvent e)
{
    //view->clear();

for(int i=0; i<8; i++) {
    view -> move(view -> get(i), intVals[i]); // view -> move(i, intVals[i]); has the same result
}

addItem->setLabel("click to add item");
}

this is just a demo to recreate the problem.
in my project i am using a multimap. even though i am using indexes within the bounds of my map and my scrollview, i get
"invalid move operation, check your indices."

this is my code:

an example map:

[0] = (first = 1, second = 4)
[1] = (first = 2, second = 10)
[2] = (first = 3, second = 6)
[3] = (first = 3, second = 9)
[4] = (first = 4, second = 7)
[5] = (first = 7, second = 1)
[6] = (first = 7, second = 3)
[7] = (first = 8, second = 8)
[8] = (first = 9, second = 2)
[9] = (first = 10, second = 5)

for(int i = 0; i < 10; i ++) {
myscrollview -> move(myscrollview -> get((Map.begin() -> second) -1), i);
}

i've also tried:

for(int i = 0; i < 10; i ++) {
myscrollview -> move((Map.begin() -> second) -1, i);
}

thanks in advance,
01

Posts: 1

Participants: 1

Read full topic


How do I up and run with HaarFinder

$
0
0

@Sasan_Bahrami wrote:

I need to use Haarfinder but I am a bit new in this and I want to find the faces that are laughing or smiling
I am in XCode 8.2 on OSX

Posts: 7

Participants: 2

Read full topic

Get framebuffer

$
0
0

@haggi wrote:

Hi,
I'm starting a project that will send the framebuffer to another application via spout. In the spout sender examples an new framebuffer object is used, initialized and sent via spout. Is there a way to get the default framebuffer of openframeworks?

Posts: 1

Participants: 1

Read full topic

Can OF be built as DLL on Windows?

$
0
0

@cuinjune wrote:

I would like to know if it is possible to build OF as DLL on Windows so it can be used by other programs using dlopen.
Thanks in advance!

Posts: 1

Participants: 1

Read full topic

Using opencv with openframework

$
0
0

@veer wrote:

I just started to work with openframeworks with opencv. I have few queries.

Openframeworks provide many image processing functions. Opencv also provide many functions of image processing. Could anyone suggest me how openframeworks is different from Opencv? when do we need to use openframeworks with opencv? And how ofxcv work makes openframeworks to use opencv?

Posts: 2

Participants: 2

Read full topic

HELP: adding linker flags to qbs project?

$
0
0

@Christof wrote:

Hi,

what's the place for adding linker flags to a qbs project (e.g. for linking to a library)?
I tried to add them to the qbs project like this:
of.linkerFlags['-L./src/lib -lfoo']
but the library doesn't get linked - at least not at the right time because I get unresolved symbols.

I added the same linker flags to PROJECT_LDFLAGS in config.make and build with the make file from the command line - and it worked. Am I doing something wrong? What is the best way to add static/dynamic libraries to an OF qbs project?

I'm using OF 0.9.3 with MSYS2 + QtCreator

Thanks!

Posts: 1

Participants: 1

Read full topic

Generative mesh extrusion

$
0
0

@JotaroUT wrote:

Hi, I would like to make some generative art similar to this in oF, and hopefully make some ofx addon for this.
This might be possible with ofxVbo or something, but not sure of how everyone does vector calculation and so on, to make some extruding animation or generation.

I hope to hear from who has a good idea for this, thank you.

Best,
Joe

ref:

Posts: 6

Participants: 2

Read full topic

Get light power

$
0
0

@edapx wrote:

Is there a way to get a parameter that defines the "light power" out of an ofLight object?
I see that there are values like attenuation, but no power. I need it to calculate the radiance at a certain point on a surface.

Posts: 5

Participants: 2

Read full topic


How to detect OF's platform & version by shell script

$
0
0

@cuinjune wrote:

Hi, I'm trying to create a shell script that will be located inside my OF app and do something depending on the target platform & version.

For example, if the script file is in of_v0.9.8_osx_release/apps/myApps/exmptyExample, it will detect that the app is targeting OSX.

Is there any platform & version info in each OF release folder other than the folder's name?
Thanks in advance!

Posts: 4

Participants: 3

Read full topic

ofxAssimpModelLoader does not show colors

$
0
0

@edapx wrote:

I'm importing an .obj model with a .mtl file. Precisely, this model http://www.graphics.cornell.edu/online/box/data.html

As I need to reposition all the meshes that compose the models and for each mesh I've to be able to query the global transformation matrix, I've converted each mesh that is in the ofxAssimpModelLoader in a of3DPrimitive, as I've described here https://forum.openframeworks.cc/t/get-global-vertices-position-of-an-instance-of-ofxassimpmodelloader/27433/5?u=edapx

When I iterate through the faces of each mesh, face.hasColors() returns false, although the colors are in the .mtl file

I've changed the method:

of3dPrimitive MeshHelper::toPrimitive(const ofMesh& mesh) {
    of3dPrimitive primitive;
    primitive.getMesh().clear();
    primitive.getMesh().append(mesh);
    primitive.getMesh().enableNormals();
    return primitive;
}

to

of3dPrimitive MeshHelper::toPrimitive(const ofMesh& mesh) {
    of3dPrimitive primitive;
    primitive.getMesh().clear();
    primitive.getMesh().append(mesh);
    primitive.getMesh().enableColors();
    primitive.getMesh().enableNormals();
    return primitive;
}

But it is still returning false. I've also tried to put glDisable(GL_COLOR_MATERIAL);
like explained here https://forum.openframeworks.cc/t/displaying-material-colors-correctly-without-textures-using-assimp/8708/5 in the draw method but it does not work.

I know this is an old topic, but I did not found in the forum any solution to this problem.

Posts: 2

Participants: 2

Read full topic

ofxTextureRecorder - memory build up

$
0
0

@stephanschulz wrote:

@arturo

I got your addon working with OF 0.10 on OS X 10.10.5

I modified it to save an array of ofTextures. Eventually i will capture a bunch of camera frames in an array and if i like the captured content i want to save it to disk.

But it seems the memory usage goes up when reading from an array to your addon's recorder.
If i comment out this line there is no memory build up. (but obviously no saving)

recorder.save(frames[i]);

I saw similar behaviour when using the older ofxImageSequenceRecorder addon.

Do you have any advice on what i am doing wrong?

here is my modified example:

Posts: 3

Participants: 2

Read full topic

ofxCv compile issue

$
0
0

@Kesava_Prasad wrote:

@kylemcdonald,
I am using Qt creator 4.2.1 on ubuntu 16.04

While compiling I get error messages like /home/kesav/Downloads/of_v0.9.8_linux64_release/addons/ofxCv/libs/ofxCv/src/ObjectFinder.cpp:1: error: ofxCv/ObjectFinder.h: No such file or directory

I changed the .qbs file to include search paths and also added ofxCv into of.addons

My addons.config.mk file has:

ADDON_INCLUDES = libs/ofxCv/include
ADDON_INCLUDES += libs/CLD/include/CLD
ADDON_INCLUDES += libs/ofxCv/include/ofxCv
ADDON_INCLUDES += src

What else am I missing?

Posts: 1

Participants: 1

Read full topic

Use of undeclared identifier 'glm'

Draw image from thread

$
0
0

@veer wrote:

We generally load a image in ofApp::setup() function. do changes on image in ofApp::update() function and and display (draw) image in ofApp::draw() function.

I want to write a application using openframeworks. I want to create two threads. one should be read the image and another should display (draw) image. The draw thread is not displaying. Could anyone suggest me why it is happening?

Posts: 2

Participants: 2

Read full topic

ofxCv examples not working

$
0
0

@Kesava_Prasad wrote:

I have imported a project from ofxCv examples and opened it in project Generator. However it didn't compile. It says Calibration.h and some other files from the src of oxcv is not found. I tried editing the addon,config.mk file and qbs file as per instructions.

Can some on throw some light on how to go about? Is there a standard way of editing addon.config file?

Posts: 3

Participants: 2

Read full topic


Eclipse plugin for OS X

$
0
0

@quinn wrote:

Hi, I'm adding visibility to my issue here:

as far as i can tell there is nothing platform specific about the plugin, so this could be as easy as removing os="linux" from the plugin. Unfortunately I can't test this because I can't figure out how to install the stuff in the github repo as a plugin, I'm new to eclipse plugin development.

Posts: 1

Participants: 1

Read full topic

Visual Studio project from scratch

$
0
0

@Jordi wrote:

Usually, it is preferable to clone the empty example or use project generator, but sometimes I wanted to know what are the exact steps to turn a VS C++ project into an OF project.
So here we go:

Visual Studio OF project from scratch

From now on Visual Studio(VS), Openframeworks (OF).

  1. Create a folder to host a set of projects. (optional)
    go to your openframeworks/apps folder.
    mkdir newSetOfProjects

  2. Create Visual Studio project
    File -> new -> project
    Visual C++/Win32 Console Application
    Create Subdirectory must be unchecked
    Name: newProject
    Location: openFrameworks\apps\newSetOfProjects\newProject\
    OK
    next
    check empty project
    finish

  3. Copy "src" folder from empty example:
    In terminal:
    cd newProject
    cp -r ../../../examples/empty/emptyExample/src ./src

  4. Import sources to project.
    Go to VS:
    Delete automatically created filers in project (Headers, Resource files, Source)
    Add new filter "src": Right Click on project, add.../filter-> src
    Add files located at src: Right click on filter src, add, existing items... main, ofApp.h, ofApp.cpp
    At this point trying to compile will throw:

    Error C1083 Cannot open include file: 'ofMain.h': No such file or directory

    This is because this project has no openframeorks yet.
    Close VS.

  5. Import OF project to solution.
    Open newProject.sln in a text editor and add openframeworks project. To do so, add these lines right after "EndProject", and before "Global".

    Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openframeworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}"
    EndProject

    Save and Close.

  6. Link OF project to our project.
    Open newProject.vcxproj in a text editor, and right after:

    <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />

    Add these lines:

    <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksRelease.props" />
      </ImportGroup>
      <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksRelease.props" />
      </ImportGroup>
      <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksDebug.props" />
      </ImportGroup>
      <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
        <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
        <Import Project="..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksDebug.props" />
      </ImportGroup>

    Then, at the end of the file, after the last:

    </ItemGroup>

    add these:

      <ItemGroup>
        <ProjectReference Include="$(OF_ROOT)\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj">
          <Project>{5837595d-aca9-485c-8e76-729040ce4b0b}</Project>
        </ProjectReference>
      </ItemGroup>

    Save and Close.

  7. Finally, to build and run:
    Open VS
    Right click on NewProject -> Set as Startup Project.
    Press F5 to build and run.

Posts: 1

Participants: 1

Read full topic

Trying to create a way for smooth rotation, but still no success

$
0
0

@Pavelas wrote:

Hi all,

I am trying to make a smooth rotation of touchscreen recognized object - it has some rotation jitter, so I am using the same function as for the movement smoothing :
rotationease += (rotation - rotationease) * 0.05;

but I have an issue - then I am rotating the object putted on touchscreen(special foil, witch is capable to track position of special objects placed on screen and rotation of those objects), I am getting values from 0 to 359 - angle of object center rotation, so then I am rotating that object and I am passing the 359 to 0, or 0 to 359 degrees my function starts to move the object in opposite way, is there are any correct way of doing this?

Thanks in advanced!

Posts: 1

Participants: 1

Read full topic

Superscript and supscript

$
0
0

@csw wrote:

Hi all,

I'm looking for a way of displaying text with superscript and subscript elements. Are there any addons that support this (or does ofTrueTypeFont support it)?

Thanks!

Posts: 1

Participants: 1

Read full topic

ofXml setAttribute produces anonymous tag

$
0
0

@hamoid wrote:

Hi! This code:

void ofxPolySave(const ofPolyline & poly, string xmlPath) {
    ofXml xml;
    auto data = xml.appendChild("poly");
    //data.setAttribute("closed", ofToString(poly.isClosed()));
    for(auto & point : poly.getVertices()) {
        auto p = data.appendChild("point");
        p.setAttribute("x", ofToString(point.x));
        p.setAttribute("y", ofToString(point.y));
    }
    data.setAttribute("closed", ofToString(poly.isClosed()));
    xml.save(xmlPath);
}

produces this file:

<?xml version="1.0"?>
<poly>
        <point x="226" y="483" />
        <point x="378" y="420" />
        <point x="508" y="494" />
        <point x="442" y="565" />
</poly>
<:anonymous closed="0" />

?
Note the <:anonymous /> tag at the end.

If I move the .setAttribute line up before the for loop, all the point tags go inside the anonymous tag. Different error, but no better.

I can't find anything about anonymity in xml :stuck_out_tongue: nor the word anonymous in the whole source of openframeworks.

Any ideas?

Posts: 2

Participants: 1

Read full topic

Viewing all 4929 articles
Browse latest View live