如何从OpenSG中的每个顶点获取每个单独的轴?例如,我想从"1.5,3,2“中得到x轴值"1.5”。
发布于 2017-01-07 14:30:45
我假设您已经知道如何获取顶点,并且只在费力地读取各个组件。此外,我假设您使用的是OpenSG 2,尽管我认为在OpenSG 1.8中也可以使用相同的函数。
OpenSG的Point和Vector分别提供了x()、y()、z()和w()函数来访问第一、第二、第三和第四矢量组件。您还可以访问基础数组,它用getValues()存储向量数据。使用数组中的索引,就可以得到顶点位置的第n个矢量分量。
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在StackOverflow上的OpenSG用户不多。如果您写信给OpenSG用户邮件列表,您可能会得到更好的帮助。
https://stackoverflow.com/questions/41507596
复制相似问题