本文整理汇总了C++中OptimisedUtil::calculateFaceNormals方法的典型用法代码示例。如果您正苦于以下问题:C++ OptimisedUtil::calculateFaceNormals方法的具体用法?C++ OptimisedUtil::calculateFaceNormals怎么用?C++ OptimisedUtil::calculateFaceNormals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OptimisedUtil
的用法示例。
在下文中一共展示了OptimisedUtil::calculateFaceNormals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateFaceNormals
/// @copydoc OptimisedUtil::calculateFaceNormals
virtual void calculateFaceNormals(
const float *positions,
const EdgeData::Triangle *triangles,
Vector4 *faceNormals,
size_t numTriangles)
{
static ProfileItems results;
static size_t index;
index = Root::getSingleton().getNextFrameNumber() % mOptimisedUtils.size();
OptimisedUtil* impl = mOptimisedUtils[index];
ProfileItem& profile = results[index];
profile.begin();
impl->calculateFaceNormals(
positions,
triangles,
faceNormals,
numTriangles);
profile.end();
//
// Dagon SkeletonAnimation sample test results (CPU timestamp per-function call):
//
// Pentium 4 3.0G HT Athlon XP 2500+
//
// General 657080 486494
// SSE 223559 399495
//
// You can put break point here while running test application, to
// watch profile results.
++index; // So we can put break point here even if in release build
}
示例2: importObject
//.........这里部分代码省略.........
//do not pad the bounding box
ogreMesh->_setBounds(AxisAlignedBox(min, max), false);
ogreMesh->_setBoundingSphereRadius(Math::Sqrt(maxSquaredRadius));
}
else
{
AxisAlignedBox newBox(min, max);
newBox.merge(currBox);
//do not pad the bounding box
ogreMesh->_setBounds(newBox, false);
ogreMesh->_setBoundingSphereRadius(qMax(Math::Sqrt(maxSquaredRadius), currRadius));
}
/*
Create faces
*/
// All children should be submeshes
SubMesh* sm = ogreMesh->createSubMesh();
sm->setMaterialName("clippingMaterial");
sm->operationType = RenderOperation::OT_TRIANGLE_LIST;
sm->useSharedVertices = true;
// tri list
sm->indexData->indexCount = indexCount;
// Allocate space
HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton().
createIndexBuffer(
HardwareIndexBuffer::IT_16BIT,
sm->indexData->indexCount,
HardwareBuffer::HBU_DYNAMIC,
false);
sm->indexData->indexBuffer = ibuf;
unsigned short *pShort = static_cast<unsigned short*>(ibuf->lock(HardwareBuffer::HBL_DISCARD));
QVector<EdgeData::Triangle> triangles(indexCount / 3);
for (int i = 0; i < indexCount / 3; ++i) {
quint16 i1, i2, i3;
stream >> i1 >> i2 >> i3;
*pShort++ = i1;
*pShort++ = i2;
*pShort++ = i3;
triangles[i].vertIndex[0] = i1;
triangles[i].vertIndex[1] = i2;
triangles[i].vertIndex[2] = i3;
}
/* Recalculate the vertex normals */
Vector4 *faceNormals = (Vector4*)_aligned_malloc(sizeof(Vector4) * triangles.size(), 16);
OptimisedUtil *util = OptimisedUtil::getImplementation();
util->calculateFaceNormals(positions.constData(),
triangles.data(),
faceNormals,
indexCount / 3);
// Iterate over all children (vertexbuffer entries)
pVert = pVertStart;
for (int i = 0; i < vertexCount; ++i) {
float *pFloat;
Vector3 normal = Vector3::ZERO;
int count = 0;
/* Search for all faces that use this vertex */
for (int j = 0; j < triangles.size(); ++j) {
if (triangles[j].vertIndex[0] == i
|| triangles[j].vertIndex[1] == i
|| triangles[j].vertIndex[2] == i) {
normal.x += faceNormals[j].x / faceNormals[j].w;
normal.y += faceNormals[j].y / faceNormals[j].w;
normal.z += faceNormals[j].z / faceNormals[j].w;
count++;
}
}
normal.normalise();
/* Copy over the position */
normalElement.baseVertexPointerToElement(pVert, &pFloat);
*(pFloat++) = normal.x;
*(pFloat++) = normal.y;
*(pFloat++) = normal.z;
pVert += vbuf->getVertexSize();
}
_aligned_free(faceNormals);
vbuf->unlock();
ibuf->unlock();
return ogreMesh;
}