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


C++ ManualObject::getParentNode方法代码示例

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


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

示例1: raycastFromPoint

/***************************************************************************//*!
 * @brief Raycast from a point in to the scene.
 * @param[in] point		Point to analyse
 * @param[in] normal		Direction
 * @param[out] result	Result ( ONLY if return TRUE )
 * @return TRUE if somethings found => {result} NOT EMPTY
 */
bool OgreMeshRay::raycastFromPoint(const Ogre::Vector3& point,
		const Ogre::Vector3& normal, Ogre::Vector3& result,
		std::string entityName) {
	// create the ray to test
	Ogre::Ray ray(point, normal);

	if (!m_raySceneQuery)
		return false;

	// create a query object
	m_raySceneQuery->setRay(ray);

	// execute the query, returns a vector of hits
	if (m_raySceneQuery->execute().size() <= 0) {
		// raycast did not hit an objects bounding box
		return false;
	}

	// at this point we have raycast to a series of different objects bounding boxes.
	// we need to test these different objects to see which is the first polygon hit.
	// there are some minor optimizations (distance based) that mean we wont have to
	// check all of the objects most of the time, but the worst case scenario is that
	// we need to test every triangle of every object.
	Ogre::Real closest_distance = -1.0f;
	Ogre::Vector3 closest_result;
	Ogre::RaySceneQueryResult& query_result = m_raySceneQuery->getLastResults();
	for (size_t qr_idx = 0, size = query_result.size(); qr_idx < size;
			++qr_idx) {
		// stop checking if we have found a raycast hit that is closer
		// than all remaining entities
		if (closest_distance >= 0.0f
				&& closest_distance < query_result[qr_idx].distance)
			break;

		// only check this result if its a hit against an entity
		if (query_result[qr_idx].movable) {
			if (entityName != ""
					&& query_result[qr_idx].movable->getName() != entityName) {
				std::cout << query_result[qr_idx].movable->getName()
						<< "is not " << entityName << std::endl;
				continue;
			}
			std::cout << query_result[qr_idx].movable->getName() << "is truly "
					<< entityName << std::endl;
			const std::string& movableType =
					query_result[qr_idx].movable->getMovableType();
			// mesh data to retrieve
			size_t vertex_count;
			size_t index_count;
			Ogre::Vector3* vertices;
			unsigned long* indices;

			if (movableType == "ManualObject") {
				// get the entity to check
				Ogre::ManualObject* pentity =
						static_cast<Ogre::ManualObject*>(query_result[qr_idx].movable);
				// get the mesh information
				GetMeshInformation(pentity, vertex_count, vertices, index_count,
						indices,
						pentity->getParentNode()->_getDerivedPosition(),
						pentity->getParentNode()->_getDerivedOrientation(),
						pentity->getParentNode()->_getDerivedScale());
			} else if (movableType == "Entity") {
				// get the entity to check
				Ogre::Entity *pentity =
						static_cast<Ogre::Entity*>(query_result[qr_idx].movable);
				// get the mesh information
				GetMeshInformation(pentity, vertex_count, vertices, index_count,
						indices,
						pentity->getParentNode()->_getDerivedPosition(),
						pentity->getParentNode()->_getDerivedOrientation(),
						pentity->getParentNode()->_getDerivedScale());
			} else {
				continue;
			}

			// test for hitting individual triangles on the mesh
			bool new_closest_found = false;
			for (int i = 0; i < static_cast<int>(index_count); i += 3) {
				// check for a hit against this triangle
				std::pair<bool, Ogre::Real> hit = Ogre::Math::intersects(ray,
						vertices[indices[i]], vertices[indices[i + 1]],
						vertices[indices[i + 2]], true, false);

				// if it was a hit check if its the closest
				if (hit.first
						&& (closest_distance < 0.0f
								|| hit.second < closest_distance)) {
					// this is the closest so far, save it off
					closest_distance = hit.second;
					new_closest_found = true;
				}
			}
//.........这里部分代码省略.........
开发者ID:netzz,项目名称:minemonics,代码行数:101,代码来源:OgreMeshRay.cpp


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