本文整理汇总了C++中SubEntity::getSubMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ SubEntity::getSubMesh方法的具体用法?C++ SubEntity::getSubMesh怎么用?C++ SubEntity::getSubMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SubEntity
的用法示例。
在下文中一共展示了SubEntity::getSubMesh方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
//-----------------------------------------------------------------------
void
MeshInformer::getEntityStatistics(const Entity* entity, size_t& numVertices, size_t& numIndices)
{
size_t numSubEntities = entity->getNumSubEntities();
bool added_shared_vertex = false;
for (size_t i = 0; i < numSubEntities; ++i)
{
SubEntity* subEntity = entity->getSubEntity(i);
if (!subEntity->isVisible())
{
// Skip non-visible sub-entity
continue;
}
SubMesh* subMesh = subEntity->getSubMesh();
if (subMesh->operationType == RenderOperation::OT_TRIANGLE_LIST ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_STRIP ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_FAN)
{
if (subMesh->useSharedVertices)
{
if (!added_shared_vertex)
{
added_shared_vertex = true;
numVertices += subMesh->parent->sharedVertexData->vertexCount;
}
}
else
{
numVertices += subMesh->vertexData->vertexCount;
}
assert(subMesh->indexData->indexCount >= 3);
switch (subMesh->operationType)
{
case RenderOperation::OT_TRIANGLE_LIST:
assert(subMesh->indexData->indexCount % 3 == 0);
numIndices += subMesh->indexData->indexCount;
break;
case RenderOperation::OT_TRIANGLE_STRIP:
case RenderOperation::OT_TRIANGLE_FAN:
numIndices += (subMesh->indexData->indexCount - 2) * 3;
break;
}
}
}
}
示例2: apply
//---------------------------------------------------------------------
void Animation::apply(Entity* entity, Real timePos, Real weight,
bool software, bool hardware)
{
// Calculate time index for fast keyframe search
TimeIndex timeIndex = _getTimeIndex(timePos);
VertexTrackList::iterator i;
for (i = mVertexTrackList.begin(); i != mVertexTrackList.end(); ++i)
{
unsigned short handle = i->first;
VertexAnimationTrack* track = i->second;
VertexData* swVertexData;
VertexData* hwVertexData;
VertexData* origVertexData;
bool firstAnim = false;
if (handle == 0)
{
// shared vertex data
firstAnim = !entity->_getBuffersMarkedForAnimation();
swVertexData = entity->_getSoftwareVertexAnimVertexData();
hwVertexData = entity->_getHardwareVertexAnimVertexData();
origVertexData = entity->getMesh()->sharedVertexData;
entity->_markBuffersUsedForAnimation();
}
else
{
// sub entity vertex data (-1)
SubEntity* s = entity->getSubEntity(handle - 1);
// Skip this track if subentity is not visible
if (!s->isVisible())
continue;
firstAnim = !s->_getBuffersMarkedForAnimation();
swVertexData = s->_getSoftwareVertexAnimVertexData();
hwVertexData = s->_getHardwareVertexAnimVertexData();
origVertexData = s->getSubMesh()->vertexData;
s->_markBuffersUsedForAnimation();
}
// Apply to both hardware and software, if requested
if (software)
{
if (firstAnim && track->getAnimationType() == VAT_POSE)
{
// First time through for a piece of pose animated vertex data
// We need to copy the original position values to the temp accumulator
const VertexElement* origelem =
origVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
const VertexElement* destelem =
swVertexData->vertexDeclaration->findElementBySemantic(VES_POSITION);
HardwareVertexBufferSharedPtr origBuffer =
origVertexData->vertexBufferBinding->getBuffer(origelem->getSource());
HardwareVertexBufferSharedPtr destBuffer =
swVertexData->vertexBufferBinding->getBuffer(destelem->getSource());
destBuffer->copyData(*origBuffer.get(), 0, 0, destBuffer->getSizeInBytes(), true);
}
track->setTargetMode(VertexAnimationTrack::TM_SOFTWARE);
track->applyToVertexData(swVertexData, timeIndex, weight,
&(entity->getMesh()->getPoseList()));
}
if (hardware)
{
track->setTargetMode(VertexAnimationTrack::TM_HARDWARE);
track->applyToVertexData(hwVertexData, timeIndex, weight,
&(entity->getMesh()->getPoseList()));
}
}
}
示例3: getEntityStatistics
//-----------------------------------------------------------------------
void
MeshInformer::getEntityTriangles(const Entity* entity,
std::vector<Vector3>& vertices,
std::vector<size_t>& indices,
std::vector<size_t>* indexOffsets)
{
size_t numVertices = 0, numIndices = 0;
getEntityStatistics(entity, numVertices, numIndices);
size_t vertex_offset = vertices.size();
size_t index_offset = indices.size();
vertices.resize(vertex_offset + numVertices);
indices.resize(index_offset + numIndices);
// Software blended vertex data available only if animation enabled, and software animation are
// used by internally engine, or user requested software animation.
bool useBlended = entity->_isAnimated() &&
(!entity->isHardwareAnimationEnabled() || entity->getSoftwareAnimationRequests() > 0);
// Use skinned vertex data only if blended data available and skeleton animation enabled.
bool useSkinned = useBlended && entity->_isSkeletonAnimated();
Vector3* pVertices = &vertices[0];
size_t* pIndices = &indices[0];
size_t shared_vertex_offset = vertex_offset;
bool added_shared_vertex = false;
size_t numSubEntities = entity->getNumSubEntities();
for (size_t i = 0; i < numSubEntities; ++i)
{
SubEntity* subEntity = entity->getSubEntity(i);
if (!subEntity->isVisible())
{
// Skip non-visible sub-entity
continue;
}
SubMesh* subMesh = subEntity->getSubMesh();
if (indexOffsets)
{
indexOffsets->push_back(index_offset);
}
if (subMesh->operationType == RenderOperation::OT_TRIANGLE_LIST ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_STRIP ||
subMesh->operationType == RenderOperation::OT_TRIANGLE_FAN)
{
size_t current_vertex_offset;
if (subMesh->useSharedVertices)
{
if (!added_shared_vertex)
{
size_t vertexCount = getVertices(pVertices + vertex_offset,
useSkinned ? entity->_getSkelAnimVertexData()
:
useBlended && subMesh->parent->getSharedVertexDataAnimationType() != VAT_NONE ? entity->_getSoftwareVertexAnimVertexData()
:
subMesh->parent->sharedVertexData);
shared_vertex_offset = vertex_offset;
vertex_offset += vertexCount;
added_shared_vertex = true;
}
current_vertex_offset = shared_vertex_offset;
}
else
{
size_t vertexCount = getVertices(pVertices + vertex_offset,
useSkinned ? subEntity->_getSkelAnimVertexData()
:
useBlended && subMesh->getVertexAnimationType() != VAT_NONE ? subEntity->_getSoftwareVertexAnimVertexData()
:
subMesh->vertexData);
current_vertex_offset = vertex_offset;
vertex_offset += vertexCount;
}
size_t index_count = getTriangles(pIndices + index_offset, subMesh->indexData, current_vertex_offset, subMesh->operationType);
index_offset += index_count;
}
}
}