Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

ofNode::getGlobalPosition problems and glm::tmat4x4 has no member named ‘xyz’

$
0
0

@action wrote:

I’m having a weird behavior working with the position of a camera.
Somehow getGlobalPosition returns a different vector than the assigned on setGlobalPosition in the same node.

camera.setGlobalPosition( glm::vec3(0, 10, 200) );
camera.getGlobalPosition();  // => returns <200, 0, 10>

*The values are correct but the axes are disordered.

Have been checking the source code of ofNode. ofNode::getGlobalPosition is calling ofNode::getGlobalTransformMatrix which return a glm::mat4, then ofNode::getGlobalPosition gets the 3rd row and return the xyz points of the vector in a glm::vec3.

ofNode.cpp

glm::mat4 ofNode::getGlobalTransformMatrix() const {
	if(parent) return parent->getGlobalTransformMatrix() * getLocalTransformMatrix();
	else return getLocalTransformMatrix();
}

glm::vec3 ofNode::getGlobalPosition() const {
	return getGlobalTransformMatrix()[3].xyz();
}

When I try to get the getGlobalTransformMatrix by myself and select the 3rd row of the matrix, then I got the correct and organized values which I can cats on a glm :: vec3 and work with it.
But when I directly use the ofNode :: getGlobalPosition method, the vector is wrong.

// This works
glm::vec3 globalPosition = camera.getGlobalTransformMatrix()[3];

Then I try to use the xyz() method and check if this is what makes it fail. But instead I get the followinf error:

glm::vec3 globalPosition = camera.getGlobalTransformMatrix()[3].xyz();

error: ‘glm::tmat4x4<float, (glm::precision)0>::col_type {aka struct glm::tvec4<float, (glm::precision)0>}’ has no member named ‘xyz’
glm::vec3 test = cam.getGlobalTransformMatrix()[3].xyz();

Should be this the propperly behavior of the ‘getGlobalPosition’ function?
Have anybody had any similar behavior before?

I’m woring on Arch Linux, with the github version of OF, compied a week ago.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles