本文整理汇总了C++中geom::Vec3f::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3f::normalize方法的具体用法?C++ Vec3f::normalize怎么用?C++ Vec3f::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geom::Vec3f
的用法示例。
在下文中一共展示了Vec3f::normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setClipPlaneParamsNormal
void ClippingShader::setClipPlaneParamsNormal(unsigned int id, Geom::Vec3f normal)
{
// Check if the given id is valid
if (errorRaiseWrongId(!isClipPlaneIdValid(id), "ClippingShader::setClipPlaneParamsFirstVec"))
return;
// Get the corresponding plane index
int planeIndex = m_clipPlanesIds[id].index;
// Normalize
Geom::Vec3f normalNormalized = normal;
normalNormalized.normalize();
// Check if it is worth updating values !
if (normalNormalized == m_clipPlanes[planeIndex].normal)
return;
// Copy the given clipping plane parameter
m_clipPlanes[planeIndex].normal = normalNormalized;
// Update the plane arrays
updateClipPlaneUniformsArray(id);
// Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform();
}
示例2: dir
ClippingPresetAnimatedSpheresCubeCollision::ClippingPresetAnimatedSpheresCubeCollision(Geom::Vec3f center, float size, int spheresCount, float radius)
{
// Store animation settings
m_cubeCenter = center;
m_cubeSize = size;
int usedSpheresCount = spheresCount;
if (usedSpheresCount < 1)
usedSpheresCount = 1;
// Add spheres to preset
for (int i = 0; i < usedSpheresCount; i++)
addClipSphere(m_cubeCenter, radius);
// Store spheres random directions
m_spheresDirections.resize(usedSpheresCount);
srand(time(NULL));
for (size_t i = 0; i < m_spheresDirections.size(); i++)
{
Geom::Vec3f dir ((rand() % 1000) - 500, (rand() % 1000) - 500, (rand() % 1000) - 500);
dir.normalize();
m_spheresDirections[i] = dir;
}
// Set clipping mode
setClippingMode(ClippingShader::CLIPPING_MODE_AND);
}