GithubHelp home page GithubHelp logo

Comments (6)

cuinjune avatar cuinjune commented on May 22, 2024 2

You can access all the methods through ofVec3f() variable before converting it to glm::vec3().

So I'd suggest always define variables in ofVec3f() type and only covert them to glm::vec3() when needed.

Like the following example:

ofelia f;
local v = ofVec3f(3, 4, 1);
print(v:length());
local mesh = ofMesh();
mesh:addVertex(v:vec3());
local v2 = ofVec3f(mesh:getVertex(0));
print(v2:length());

I don't think it is currently possible to directly initialize glm::vec3() by doing something like local v = glm.vec3(0, 0, 0) in Ofelia. This could be a bug or recently supported feature of ofxLua. I will try to update ofxLua used in Ofelia soon and see if glm can be used directly.

from ofelia.

cuinjune avatar cuinjune commented on May 22, 2024 1

mesh:addColor() accepts ofFloatColor() instead of ofColor() which uses float r,g,b values between 0 and 1.

You can check the ofelia/examples/3d/coloredCube example to see how it can be used.

from ofelia.

cuinjune avatar cuinjune commented on May 22, 2024

Hi, you should convert ofVec3f() to glm::vec3() by appending :vec3() to ofVec3f() as it says here: https://github.com/danomatika/ofxLua#glm

So your code should be

mesh:addVertex(ofVec3f(0,0,0):vec3());

from ofelia.

grabanton avatar grabanton commented on May 22, 2024

@cuinjune, thank you! It works for addVertex, but what about color? How to convert ofColor_< unsigned char > to *|ofColor_< float >? And is there an approach to get a list of all methods of an object?

from ofelia.

grabanton avatar grabanton commented on May 22, 2024

Where I can find information about mathematical operations with glm objects? When I try call any methods of glm::vec3() I got errors:

- ofelia: [string "package.preload['__.x25eb0c0.c'] = nil packag..."]:4: attempt to index a userdata value (local 'v')

I mean acces to vector components or length(), distance(), dot(), cross() etc...

UPD:
Found approch to doing it. I need wrap glm::vec3 back to ofVec3f type. And there available all needed methods.
like in this example:

local v1 = ofVec3f(mesh:getVertex(0));
local v2 = ofVec3f(mesh:getVertex(1));
print(v1:distance(v2));

But still actual question about getting list of object methods )

from ofelia.

grabanton avatar grabanton commented on May 22, 2024

@cuinjune, thank you very much! I have a number of questions and suggestions on how to improve the ofelia. Can we chat in person on Facebook or Telegram so as not to clog up the thread?
telegram
facebook

from ofelia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.