本文整理汇总了C++中Model::GetNumGeometries方法的典型用法代码示例。如果您正苦于以下问题:C++ Model::GetNumGeometries方法的具体用法?C++ Model::GetNumGeometries怎么用?C++ Model::GetNumGeometries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model::GetNumGeometries方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTileGeometry
void NavigationMesh::GetTileGeometry(NavBuildData* build, Vector<NavigationGeometryInfo>& geometryList, BoundingBox& box)
{
Matrix3x4 inverse = node_->GetWorldTransform().Inverse();
for (unsigned i = 0; i < geometryList.Size(); ++i)
{
if (box.IsInsideFast(geometryList[i].boundingBox_) != OUTSIDE)
{
const Matrix3x4& transform = geometryList[i].transform_;
if (geometryList[i].component_->GetType() == OffMeshConnection::GetTypeStatic())
{
OffMeshConnection* connection = static_cast<OffMeshConnection*>(geometryList[i].component_);
Vector3 start = inverse * connection->GetNode()->GetWorldPosition();
Vector3 end = inverse * connection->GetEndPoint()->GetWorldPosition();
build->offMeshVertices_.Push(start);
build->offMeshVertices_.Push(end);
build->offMeshRadii_.Push(connection->GetRadius());
build->offMeshFlags_.Push((unsigned short)connection->GetMask());
build->offMeshAreas_.Push((unsigned char)connection->GetAreaID());
build->offMeshDir_.Push((unsigned char)(connection->IsBidirectional() ? DT_OFFMESH_CON_BIDIR : 0));
continue;
}
else if (geometryList[i].component_->GetType() == NavArea::GetTypeStatic())
{
NavArea* area = static_cast<NavArea*>(geometryList[i].component_);
NavAreaStub stub;
stub.areaID_ = (unsigned char)area->GetAreaID();
stub.bounds_ = area->GetWorldBoundingBox();
build->navAreas_.Push(stub);
continue;
}
#ifdef ATOMIC_PHYSICS
CollisionShape* shape = dynamic_cast<CollisionShape*>(geometryList[i].component_);
if (shape)
{
switch (shape->GetShapeType())
{
case SHAPE_TRIANGLEMESH:
{
Model* model = shape->GetModel();
if (!model)
continue;
unsigned lodLevel = shape->GetLodLevel();
for (unsigned j = 0; j < model->GetNumGeometries(); ++j)
AddTriMeshGeometry(build, model->GetGeometry(j, lodLevel), transform);
}
break;
case SHAPE_CONVEXHULL:
{
ConvexData* data = static_cast<ConvexData*>(shape->GetGeometryData());
if (!data)
continue;
unsigned numVertices = data->vertexCount_;
unsigned numIndices = data->indexCount_;
unsigned destVertexStart = build->vertices_.Size();
for (unsigned j = 0; j < numVertices; ++j)
build->vertices_.Push(transform * data->vertexData_[j]);
for (unsigned j = 0; j < numIndices; ++j)
build->indices_.Push(data->indexData_[j] + destVertexStart);
}
break;
case SHAPE_BOX:
{
unsigned destVertexStart = build->vertices_.Size();
build->vertices_.Push(transform * Vector3(-0.5f, 0.5f, -0.5f));
build->vertices_.Push(transform * Vector3(0.5f, 0.5f, -0.5f));
build->vertices_.Push(transform * Vector3(0.5f, -0.5f, -0.5f));
build->vertices_.Push(transform * Vector3(-0.5f, -0.5f, -0.5f));
build->vertices_.Push(transform * Vector3(-0.5f, 0.5f, 0.5f));
build->vertices_.Push(transform * Vector3(0.5f, 0.5f, 0.5f));
build->vertices_.Push(transform * Vector3(0.5f, -0.5f, 0.5f));
build->vertices_.Push(transform * Vector3(-0.5f, -0.5f, 0.5f));
const unsigned indices[] = {
0, 1, 2, 0, 2, 3, 1, 5, 6, 1, 6, 2, 4, 5, 1, 4, 1, 0, 5, 4, 7, 5, 7, 6,
4, 0, 3, 4, 3, 7, 1, 0, 4, 1, 4, 5
};
for (unsigned j = 0; j < 36; ++j)
build->indices_.Push(indices[j] + destVertexStart);
}
break;
default:
break;
}
continue;
}
#endif
//.........这里部分代码省略.........
示例2: AddStaticModelData
//=============================================================================
//=============================================================================
void StaticModelPoolMgr::AddStaticModelData(Node *pNode, StaticModel *pStaticModel)
{
NvMeshData nvMeshData;
StaticModelData staticModelData;
Model *pModel = pStaticModel->GetModel();
// only one geom currently supprted
assert( pModel && pModel->GetNumGeometries() == 1 && "multiple gemoetries currently NOT supported" );
Matrix3x4 objMatrix = pNode->GetTransform();
Quaternion objRotation = pNode->GetRotation();
Geometry *pGeometry = pModel->GetGeometry(0, 0);
VertexBuffer *pVbuffer = pGeometry->GetVertexBuffer(0);
unsigned uElementMask = pVbuffer->GetElementMask();
unsigned vertexSize = pVbuffer->GetVertexSize();
const unsigned char *pVertexData = (const unsigned char*)pVbuffer->Lock(0, pVbuffer->GetVertexCount());
// get verts, normals, uv, etc.
if ( pVertexData )
{
unsigned numVertices = pVbuffer->GetVertexCount();
for ( unsigned i = 0; i < numVertices; ++i )
{
unsigned char *pDataAlign = (unsigned char *)(pVertexData + i * vertexSize);
if ( uElementMask & MASK_POSITION )
{
const Vector3 vPos = *reinterpret_cast<Vector3*>( pDataAlign );
pDataAlign += sizeof( Vector3 );
Vector3 vxformPos = objMatrix * vPos; // xform
// verts list
staticModelData.listVerts.Push( vxformPos );
nvMeshData.listVerts.push_back( Vec3f( vxformPos.x_, vxformPos.y_, vxformPos.z_ ) );
}
if ( uElementMask & MASK_NORMAL )
{
const Vector3 vNorm = *reinterpret_cast<Vector3*>( pDataAlign );
pDataAlign += sizeof( Vector3 );
// normal list
Vector3 vxformNorm = objRotation * vNorm; // xform
staticModelData.listNormals.Push( vxformNorm );
nvMeshData.listNormals.push_back( Vec3f( vxformNorm.x_, vxformNorm.y_, vxformNorm.z_ ) );
}
if ( uElementMask & MASK_COLOR )
{
const unsigned uColor = *reinterpret_cast<unsigned*>( pDataAlign );
pDataAlign += sizeof( unsigned );
}
if ( uElementMask & MASK_TEXCOORD1 )
{
const Vector2 vUV = *reinterpret_cast<Vector2*>( pDataAlign );
pDataAlign += sizeof( Vector2 );
// uv list
staticModelData.listUVs.Push( vUV );
}
// skip other mask elements - we got what we wanted
}
//unlock
pVbuffer->Unlock();
}
else
{
// error
assert( false && "failed to unlock vertex buffer" );
}
// get indeces
IndexBuffer *pIbuffer = pGeometry->GetIndexBuffer();
const unsigned *pIndexData = (const unsigned *)pIbuffer->Lock( 0, pIbuffer->GetIndexCount() );
const unsigned short *pUShortData = (const unsigned short *)pIndexData;
if ( pUShortData )
{
unsigned numIndeces = pIbuffer->GetIndexCount();
unsigned indexSize = pIbuffer->GetIndexSize();
assert( indexSize == sizeof(unsigned short) );
for( unsigned i = 0; i < numIndeces; i += 3 )
{
int idx0 = (int)pUShortData[i ];
int idx1 = (int)pUShortData[i+1];
int idx2 = (int)pUShortData[i+2];
staticModelData.listTris.Push( IntVector3( idx0, idx1, idx2 ) );
nvMeshData.listTris.push_back( Vec3i( idx0, idx1, idx2 ) );
}
//unlock
pIbuffer->Unlock();
//.........这里部分代码省略.........