本文整理汇总了C++中ea::vector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::push_back方法的具体用法?C++ vector::push_back怎么用?C++ vector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ea::vector
的用法示例。
在下文中一共展示了vector::push_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessRayQuery
void StaticModel::ProcessRayQuery(const RayOctreeQuery& query, ea::vector<RayQueryResult>& results)
{
RayQueryLevel level = query.level_;
switch (level)
{
case RAY_AABB:
Drawable::ProcessRayQuery(query, results);
break;
case RAY_OBB:
case RAY_TRIANGLE:
case RAY_TRIANGLE_UV:
Matrix3x4 inverse(node_->GetWorldTransform().Inverse());
Ray localRay = query.ray_.Transformed(inverse);
float distance = localRay.HitDistance(boundingBox_);
Vector3 normal = -query.ray_.direction_;
Vector2 geometryUV;
unsigned hitBatch = M_MAX_UNSIGNED;
if (level >= RAY_TRIANGLE && distance < query.maxDistance_)
{
distance = M_INFINITY;
for (unsigned i = 0; i < batches_.size(); ++i)
{
Geometry* geometry = batches_[i].geometry_;
if (geometry)
{
Vector3 geometryNormal;
float geometryDistance = level == RAY_TRIANGLE ? geometry->GetHitDistance(localRay, &geometryNormal) :
geometry->GetHitDistance(localRay, &geometryNormal, &geometryUV);
if (geometryDistance < query.maxDistance_ && geometryDistance < distance)
{
distance = geometryDistance;
normal = (node_->GetWorldTransform() * Vector4(geometryNormal, 0.0f)).Normalized();
hitBatch = i;
}
}
}
}
if (distance < query.maxDistance_)
{
RayQueryResult result;
result.position_ = query.ray_.origin_ + distance * query.ray_.direction_;
result.normal_ = normal;
result.textureUV_ = geometryUV;
result.distance_ = distance;
result.drawable_ = this;
result.node_ = node_;
result.subObject_ = hitBatch;
results.push_back(result);
}
break;
}
}
示例2: ProcessRayQuery
void Light::ProcessRayQuery(const RayOctreeQuery& query, ea::vector<RayQueryResult>& results)
{
// Do not record a raycast result for a directional light, as it would block all other results
if (lightType_ == LIGHT_DIRECTIONAL)
return;
float distance = query.maxDistance_;
switch (query.level_)
{
case RAY_AABB:
Drawable::ProcessRayQuery(query, results);
return;
case RAY_OBB:
{
Matrix3x4 inverse(node_->GetWorldTransform().Inverse());
Ray localRay = query.ray_.Transformed(inverse);
distance = localRay.HitDistance(GetWorldBoundingBox().Transformed(inverse));
if (distance >= query.maxDistance_)
return;
}
break;
case RAY_TRIANGLE:
if (lightType_ == LIGHT_SPOT)
{
distance = query.ray_.HitDistance(GetFrustum());
if (distance >= query.maxDistance_)
return;
}
else
{
distance = query.ray_.HitDistance(Sphere(node_->GetWorldPosition(), range_));
if (distance >= query.maxDistance_)
return;
}
break;
case RAY_TRIANGLE_UV:
URHO3D_LOGWARNING("RAY_TRIANGLE_UV query level is not supported for Light component");
return;
}
// If the code reaches here then we have a hit
RayQueryResult result;
result.position_ = query.ray_.origin_ + distance * query.ray_.direction_;
result.normal_ = -query.ray_.direction_;
result.distance_ = distance;
result.drawable_ = this;
result.node_ = node_;
result.subObject_ = M_MAX_UNSIGNED;
results.push_back(result);
}
示例3: LoadMesh
void LoadMesh(const ea::string& inputFileName, bool generateTangents, bool splitSubMeshes, bool exportMorphs)
{
File meshFileSource(context_);
meshFileSource.Open(inputFileName);
if (!meshFile_->Load(meshFileSource))
ErrorExit("Could not load input file " + inputFileName);
XMLElement root = meshFile_->GetRoot("mesh");
XMLElement subMeshes = root.GetChild("submeshes");
XMLElement skeletonLink = root.GetChild("skeletonlink");
if (root.IsNull())
ErrorExit("Could not load input file " + inputFileName);
ea::string skeletonName = skeletonLink.GetAttribute("name");
if (!skeletonName.empty())
LoadSkeleton(GetPath(inputFileName) + GetFileName(skeletonName) + ".skeleton.xml");
// Check whether there's benefit of avoiding 32bit indices by splitting each submesh into own buffer
XMLElement subMesh = subMeshes.GetChild("submesh");
unsigned totalVertices = 0;
unsigned maxSubMeshVertices = 0;
while (subMesh)
{
materialNames_.push_back(subMesh.GetAttribute("material"));
XMLElement geometry = subMesh.GetChild("geometry");
if (geometry)
{
unsigned vertices = geometry.GetInt("vertexcount");
totalVertices += vertices;
if (maxSubMeshVertices < vertices)
maxSubMeshVertices = vertices;
}
++numSubMeshes_;
subMesh = subMesh.GetNext("submesh");
}
XMLElement sharedGeometry = root.GetChild("sharedgeometry");
if (sharedGeometry)
{
unsigned vertices = sharedGeometry.GetInt("vertexcount");
totalVertices += vertices;
if (maxSubMeshVertices < vertices)
maxSubMeshVertices = vertices;
}
if (!sharedGeometry && (splitSubMeshes || (totalVertices > 65535 && maxSubMeshVertices <= 65535)))
{
useOneBuffer_ = false;
vertexBuffers_.resize(numSubMeshes_);
indexBuffers_.resize(numSubMeshes_);
}
else
{
vertexBuffers_.resize(1);
indexBuffers_.resize(1);
}
subMesh = subMeshes.GetChild("submesh");
unsigned indexStart = 0;
unsigned vertexStart = 0;
unsigned subMeshIndex = 0;
ea::vector<unsigned> vertexStarts;
vertexStarts.resize(numSubMeshes_);
while (subMesh)
{
XMLElement geometry = subMesh.GetChild("geometry");
XMLElement faces = subMesh.GetChild("faces");
// If no submesh vertexbuffer, process the shared geometry, but do it only once
unsigned vertices = 0;
if (!geometry)
{
vertexStart = 0;
if (!subMeshIndex)
geometry = root.GetChild("sharedgeometry");
}
if (geometry)
vertices = geometry.GetInt("vertexcount");
ModelSubGeometryLodLevel subGeometryLodLevel;
ModelVertexBuffer* vBuf;
ModelIndexBuffer* iBuf;
if (useOneBuffer_)
{
vBuf = &vertexBuffers_[0];
if (vertices)
vBuf->vertices_.resize(vertexStart + vertices);
iBuf = &indexBuffers_[0];
subGeometryLodLevel.vertexBuffer_ = 0;
subGeometryLodLevel.indexBuffer_ = 0;
}
else
{
vertexStart = 0;
//.........这里部分代码省略.........