Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating complex global variables #35

Open
zflo opened this issue Mar 11, 2014 · 1 comment
Open

Creating complex global variables #35

zflo opened this issue Mar 11, 2014 · 1 comment
Labels

Comments

@zflo
Copy link

zflo commented Mar 11, 2014

I would like to create a complex global variable in my environment and read it out in the fitness script. It is supposed to represent 4 3D positions, so it must be some sort of 4 by 3 matrix. Is there some nerd.createGlobalProperty thing to do that (and some way to "decode" the data back to usable position vectors, in the fitness script)? So far, I didn't even manage to convert a new Array([...],[...],...) into a string, such that it would pass as a globalDoubleProperty. Shouldn't be a problem, eventually, but isn't there a simpler way?

@zflo zflo added the question label Mar 11, 2014
@cybott
Copy link
Member

cybott commented Mar 11, 2014

No, there is no direct way to do that. You can:

  1. Create 12 new double values in the VariableRepository using
    nerd.createGlobalDoubleValue() and access these values in the script via
    a declaration of nerd.defineVariable(). With this approach, all
    variables would be automatically present in the script during each
    execution step, which is comparably efficient. See
    http://www.ultopia.de/drupal/nerddoc/node/76#defVar

  2. Create four string values to represent the position vectors as
    string. You may use the helper function nerd.toVector3DString() to set
    the values and nerd.getVectorElement(string vectorString, int index). Or
    you could write your own helper scripts to read and write the string
    representation of your own vector or matrix string. See
    http://www.ultopia.de/drupal/nerddoc/node/76#HelperFunctions.

  3. Implement a new function to class ScriptingContext, e.g. bool
    createGlobalVector3DProperty(const QString &propertyName, double x,
    double y, double z); That function should be implemented similar to bool
    createGlobalDoubleProperty(const QString &propertyName, double content =
    0.0);

Hope this helps.

On 03/11/2014 06:12 PM, zflo wrote:

I would like to create a complex global variable in my environment and
read it out in the fitness script. It is supposed to represent 4 3D
positions, so it must be some sort of 4 by 3 matrix. Is there some
|nerd.createGlobalProperty| thing to do that (and some way to "decode"
the data back to usable position vectors, in the fitness script)? So
far, I didn't even manage to convert a |new Array([...],[...],...)|
into a string, such that it would pass as a globalDoubleProperty.
Shouldn't be a problem, eventually, but isn't there a simpler way?


Reply to this email directly or view it on GitHub
#35.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants