当前位置: 首页>>代码示例>>C++>>正文


C++ Bounds::getName方法代码示例

本文整理汇总了C++中Bounds::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Bounds::getName方法的具体用法?C++ Bounds::getName怎么用?C++ Bounds::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bounds的用法示例。


在下文中一共展示了Bounds::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addCollisionBounds


//.........这里部分代码省略.........
			Bounds::Ptr pBounds;

			switch (bounds.getType()) {
			case Bounds::TYPE_PLANE:
				pBounds = expand(dynamic_cast<const BoundingPlane&>(bounds));
				break;
			case Bounds::TYPE_SPHERE:
				pBounds = expand(dynamic_cast<const BoundingSphere&>(bounds));
				break;
			case Bounds::TYPE_CYLINDER:
				pBounds = expand(dynamic_cast<const BoundingCylinder&>(bounds));
				break;
			case Bounds::TYPE_BOX:
				pBounds = expand(dynamic_cast<const BoundingBox&>(bounds));
				break;
			case Bounds::TYPE_CONVEX_MESH:
				pBounds = expand(dynamic_cast<const BoundingConvexMesh&>(bounds));
				break;
			default:
				break;
			}

			return pBounds;
		}

		Bounds::Ptr expand(const BoundingPlane &bounds) const {
			BoundingPlane::Desc desc;
			desc.normal = bounds.getNormal();
			desc.distance = bounds.getDistance();// + skinThickness;
			return desc.create();
		}

		Bounds::Ptr expand(const BoundingSphere &bounds) const {
			BoundingSphere::Desc desc;
			desc.pose = bounds.getPose();
			desc.radius = bounds.getRadius() + skinThickness;
			return desc.create();
		}

		Bounds::Ptr expand(const BoundingCylinder &bounds) const {
			BoundingCylinder::Desc desc;
			desc.pose = bounds.getPose();
			desc.length = bounds.getLength() + REAL_TWO*skinThickness;
			desc.radius = bounds.getRadius() + skinThickness;
			return desc.create();
		}

		Bounds::Ptr expand(const BoundingBox &bounds) const {
			BoundingBox::Desc desc;
			desc.pose = bounds.getPose();
			desc.dimensions.set(
				bounds.getDimensions().v1 + skinThickness,
				bounds.getDimensions().v2 + skinThickness,
				bounds.getDimensions().v3 + skinThickness
			);
			return desc.create();
		}

		Bounds::Ptr expand(const BoundingConvexMesh &bounds) const {
			BoundingConvexMesh::Desc desc;

			const U32 numOfVertices = (U32)bounds.getVertices().size();
			desc.vertices.resize(numOfVertices);

			Vec3 centroid(REAL_ZERO);
			for (U32 i = 0; i < numOfVertices; ++i)
				centroid.add(centroid, bounds.getVertices()[i]);
			centroid.multiply(REAL_ONE/numOfVertices, centroid);
			
			// expand along lines drawn from centroid to vertices
			for (U32 i = 0; i < numOfVertices; ++i) {
				Vec3 axis;
				axis.subtract(bounds.getVertices()[i], centroid);
				axis.normalise();
				desc.vertices[i].multiplyAdd(skinThickness, axis, bounds.getVertices()[i]);
			}
			
			const U32 numOfTriangles = (U32)bounds.getTriangles().size();

			if (numOfTriangles > 0) {
				desc.bCook = false;
				desc.triangles = bounds.getTriangles();
			}
			else
				desc.bCook = true;
			
			return desc.create();
		}
	};

	// Expand bounds
	Bounds::Ptr pBounds = Expander(desc.collisionDesc.skinThickness).expand(collisionBounds);
	if (pBounds == NULL)
		throw MsgHeuristicBoundsExpand(Message::LEVEL_ERROR, "Heuristic::addCollisionBounds(): unable to create %s", collisionBounds.getName());
	
	//context.debug("Heuristic::setCollisionBounds(): group #%08x, name: %s\n", pBounds->getGroup(), pBounds->getName());

	// add to the collection
	this->collisionBounds.push_back(pBounds);
}
开发者ID:marekkopicki,项目名称:Golem,代码行数:101,代码来源:Heuristic.cpp


注:本文中的Bounds::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。