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


C++ SBScene::getScale方法代码示例

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


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

示例1: initSteeringSpaceObject

void SbmPawn::initSteeringSpaceObject()
{
	SmartBody::SBScene* scene = SmartBody::SBScene::getScene();
	
	if (!scene->getSteerManager()->getEngineDriver()->isInitialized())	return;
	if (!scene->getSteerManager()->getEngineDriver()->_engine)	return;

	float steerScale = 1.0f / scene->getScale();

	// get the size of the steering object
	float x, y, z, h, p, r;
	this->get_world_offset(x, y, z, h, p, r);	
	gwiz::quat_t q = gwiz::euler_t(p,h,r);	
	SrQuat pawnQ = SrQuat((float)q.w(), (float)q.x(), (float)q.y(), (float)q.z());
	SrVec size = this->getVec3Attribute("collisionShapeScale");
	size = size*pawnQ;
	steeringSpaceObjSize.x = fabs(size.x);
	steeringSpaceObjSize.y = fabs(size.y);
	steeringSpaceObjSize.z = fabs(size.z);	
	
	float xmin = (x - steeringSpaceObjSize.x) / steerScale;
	float xmax = (x + steeringSpaceObjSize.x) / steerScale;
	float ymin = (y - steeringSpaceObjSize.y) / steerScale;
	float ymax = (y + steeringSpaceObjSize.y) / steerScale;
	float zmin = (z - steeringSpaceObjSize.z) / steerScale;
	float zmax = (z + steeringSpaceObjSize.z) / steerScale;
	
	

	//LOG("steeringSpaceObjSize = %f %f %f, scale = %f", steeringSpaceObjSize.x, steeringSpaceObjSize.y, steeringSpaceObjSize.z, steerScale);

	if (steeringSpaceObj_p)
	{
		const Util::AxisAlignedBox& box = steeringSpaceObj_p->getBounds();
		if (fabs(box.xmax - xmax) > .0001 ||
			fabs(box.xmin - xmin) > .0001 ||
			fabs(box.ymax - ymax) > .0001 ||
			fabs(box.ymin - ymin) > .0001 ||
			fabs(box.zmax - zmax) > .0001 ||
			fabs(box.zmin - zmin) > .0001)
		{
			SmartBody::SBScene::getScene()->getSteerManager()->getEngineDriver()->_engine->getSpatialDatabase()->removeObject(steeringSpaceObj_p, steeringSpaceObj_p->getBounds());
			Util::AxisAlignedBox& mutableBox = const_cast<Util::AxisAlignedBox&>(box);
			mutableBox.xmax = xmax;
			mutableBox.xmin = xmin;
			mutableBox.ymax = ymax;
			mutableBox.ymin = ymin;
			mutableBox.zmax = zmax;
			mutableBox.zmin = zmin;
			SmartBody::SBScene::getScene()->getSteerManager()->getEngineDriver()->_engine->getSpatialDatabase()->addObject(steeringSpaceObj_p, steeringSpaceObj_p->getBounds());
		}
	}
	else
	{
		steeringSpaceObj_p = new SteerLib::BoxObstacle(xmin, xmax, ymin, ymax, zmin, zmax);
		SmartBody::SBScene::getScene()->getSteerManager()->getEngineDriver()->_engine->addObstacle(steeringSpaceObj_p);
		SmartBody::SBScene::getScene()->getSteerManager()->getEngineDriver()->_engine->getSpatialDatabase()->addObject(steeringSpaceObj_p, steeringSpaceObj_p->getBounds());	
	}
}
开发者ID:gsi-upm,项目名称:SmartSim,代码行数:59,代码来源:sbm_pawn.cpp


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