Reputation: 41
How would I go about getting each individual axis from each vertex in OpenSG? For example I want to get the x axis value "1.5" from "1.5, 3, 2".
Upvotes: 0
Views: 44
Reputation: 747
I assume that you already know how to get the vertices and are only struggeling to read the individual components. Also I assume that you are using OpenSG 2, although I think that the same functions are alvailable in OpenSG 1.8 as well.
OpenSG's Point and Vector classes offer the x()
, y()
, z()
and w()
function to access the first, second, third and fourth vector component respectively.
You can also access the underlying array which stores the vector data with getValues()
. Using an index into the array you get the nth vector component of your vertex' position.
OSG::Pnt3f p(1.5, 3, 2);
// prints
// The x-component is: 1.5
std::cout << "The x-component is: " << p.x() << "\n";
// prints
// Component 0 is: 1.5
// Component 1 is: 3
// Component 2 is: 2
for (unsigned int i = 0; i < 3; i++)
{
std::cout << "Component " << i << " is: " << p.getValues()[i] << "\n";
}
Note There are not many OpenSG users on StackOverflow. You will probably get better help if you write to the OpenSG Users Mailing List.
Upvotes: 1