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


C++ DynamicObject::setPosition方法代码示例

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


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

示例1: is

Stage * GameLibrary::getStage(string name) {
	// element was not found.
	// load it in and create instance 
	
	std::string fileName = "../TeamProject/GameData/Stages/" + name +".json";
	FILE* pFile = fopen(fileName.c_str(), "rb");
		
	if(pFile != NULL) {
		char buffer[65536];
		rapidjson::FileReadStream is(pFile, buffer, sizeof(buffer));
		rapidjson::Document document;
		document.ParseStream<0, rapidjson::UTF8<>, rapidjson::FileReadStream>(is);
		
		// File was opened successfully and parsed into JSON,
		// now we create the instance, for anything not specified in the json file

		std::list<DynamicObject*> tempDynObjs;
		std::list<StaticScenery*> tempStaticScenery;
		std::list<Ogre::Light*> tempLights;
				
		// load dynamic objects
		if (document.HasMember("DynamicObjects")) {
			for (int i = 0; i < document["DynamicObjects"].Size(); i++) {
				
				string name = document["DynamicObjects"][i]["name"].GetString();
				
				Ogre::Vector3 position = Ogre::Vector3(0, 0, 0);
				Ogre::Quaternion rotation = Ogre::Quaternion(1, 0, 0, 0);

				if (document["DynamicObjects"][i].HasMember("position")) {
					double x = document["DynamicObjects"][i]["position"][0].GetDouble();
					double y = document["DynamicObjects"][i]["position"][1].GetDouble();
					double z = document["DynamicObjects"][i]["position"][2].GetDouble();
					position = Ogre::Vector3(x, y, z);
				} else {
					position = Ogre::Vector3(0, 0, 0);
				}

				if (document["DynamicObjects"][i].HasMember("Orientation")) {
					double w = document["DynamicObjects"][i]["Orientation"][0].GetDouble();
					double x = document["DynamicObjects"][i]["Orientation"][1].GetDouble();
					double y = document["DynamicObjects"][i]["Orientation"][2].GetDouble();
					double z = document["DynamicObjects"][i]["Orientation"][3].GetDouble();
					rotation = Ogre::Quaternion(w, x, y, z);
				} else {
					rotation = Ogre::Quaternion(1, 0, 0, 0);
				}


				DynamicObject* tempDynObj =  this->getDynamicObject(name);
				tempDynObj->setPosition(position);
				tempDynObj->setOrientation(rotation);
				tempDynObjs.push_back(tempDynObj);

				// psuedocode for collision filtering once this is set up
				// checks if it's an interactive object and if it is, add to phys manager 
				// list to handle specific collision checking 
				// if (tempDynObj->fallRigidBody->getUserIndex() != -1) 
				//    physmanager->collisionlist.push(tempDynObj)
			}
		}		

		// load StaticScenery
		if (document.HasMember("StaticScenery")) {
			for (int i = 0; i < document["StaticScenery"].Size(); i++) {
				
				
				string name = document["StaticScenery"][i]["name"].GetString();
				
				
				Ogre::Vector3 position = Ogre::Vector3(0, 0, 0);
				Ogre::Quaternion rotation = Ogre::Quaternion(1, 0, 0, 0);
//				int interaction = -1; 

				// interaction legend 
				// -1 = no interaction 
				// 0 = player respawns  
				//if (document.HasMember("interaction")) {
				//	OutputDebugString("interaction is set to 0 \n"); 
				//	interaction = document["interaction"].GetInt();
				//}

				if (document["StaticScenery"][i].HasMember("position")) {
					double x = document["StaticScenery"][i]["position"][0].GetDouble();
					double y = document["StaticScenery"][i]["position"][1].GetDouble();
					double z = document["StaticScenery"][i]["position"][2].GetDouble();
					position = Ogre::Vector3(x, y, z);
				} else {
					position = Ogre::Vector3(0, 0, 0);
				}

				
				if (document["StaticScenery"][i].HasMember("orientation")) {
					double w = document["StaticScenery"][i]["rotation"][0].GetDouble();
					double x = document["StaticScenery"][i]["rotation"][1].GetDouble();
					double y = document["StaticScenery"][i]["rotation"][2].GetDouble();
					double z = document["StaticScenery"][i]["rotation"][3].GetDouble();
					rotation = Ogre::Quaternion(w, x, y, z);
				} else {
					rotation = Ogre::Quaternion(1, 0, 0, 0);
//.........这里部分代码省略.........
开发者ID:simonkwong,项目名称:Shamoov,代码行数:101,代码来源:GameLibrary.cpp


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