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


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

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


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

示例1: addContext

bool JsonLd::addContext(
   DynamicObject& context, DynamicObject& in, DynamicObject& out)
{
   bool rval = true;

   // "a" is automatically shorthand for rdf type
   DynamicObject ctx = (context.isNull() ? DynamicObject() : context.clone());
   ctx["a"] = RDF_TYPE;

   // TODO: should context simplification be an option? (ie: remove context
   // entries that are not used in the output)

   // setup output context
   DynamicObject& contextOut = out["#"];
   contextOut->setType(Map);

   // apply context
   _applyContext(ctx, contextOut, NULL, in, out);

   // clean up
   if(contextOut->length() == 0)
   {
      out->removeMember("#");
   }

   return rval;
}
开发者ID:zengyuxing007,项目名称:monarch,代码行数:27,代码来源:JsonLd.cpp

示例2: _getExceptionGraph

static DynamicObject _getExceptionGraph(
   DynamicObject& context, DynamicObject& autoContext, RdfaReader::Graph* g)
{
   DynamicObject rval(NULL);

   // clone auto context
   DynamicObject ctx = autoContext.clone();

   // use user-set context
   if(!context.isNull())
   {
      ctx = context.clone();
   }

   // save the old processor target and frame
   DynamicObject target = g->target;
   DynamicObject frame = g->frame;

   // use frame to embed error context in exception
   g->frame = DynamicObject();
   //g->frame["@context"] = JsonLd::createDefaultContext();
   g->frame["@type"] =
      "http://www.w3.org/ns/rdfa_processing_graph#Error";
   g->frame["http://www.w3.org/ns/rdfa_processing_graph#context"]->setType(Map);

   // finish processor graph
   g->target = DynamicObject();
   _finishGraph(ctx, g);
   rval = g->target;

   // reset old target and frame
   g->target = target;
   g->frame = frame;

   return rval;
}
开发者ID:bsletten,项目名称:monarch,代码行数:36,代码来源:RdfaReader.cpp

示例3: is

/*
	Retrieves a DynamicObject from the game library.
	Returns null if no object was found that matches name.
*/
DynamicObject * GameLibrary::getDynamicObject(string name) {
	// see if an instance of the object exists in dynamicObjects map.
	// if not load it in from memory, create it, and put it in the map.

	unordered_map<string, DynamicObject*> ::iterator it = dynamicObjects.find(name);

	DynamicObject *dynObj;
 	if(it != dynamicObjects.end())
	{
		//element found;
		dynObj = it->second;

		// create a clone of it.
		return dynObj->clone(this->mSceneManager);

	} else {
		// element was not found.
		// load it in and create instance 

		std::string fileName = "../TeamProject/GameData/DynamicObjects/" + 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

			list<Ogre::String> meshNames;
			if (document.HasMember("meshNames")) {
				for (int i = 0; i < document["meshNames"].Size(); i++) {
					meshNames.push_back(document["meshNames"][i].GetString());
				}
			} else {
				meshNames.push_back("ERROR.MESH.mesh");
			}


			// Parse data for the construction of the rigid body

			double restitution;
			if (document.HasMember("restitution")) {
				restitution = document["restitution"].GetDouble();
			} else {
				restitution = 0.0;
			}

			int massTemp;
			if (document.HasMember("mass")) {
				massTemp = document["mass"].GetInt();
			} else {
				massTemp = 1;
			}


			// Parse scale info
			Ogre::Vector3 scale = Ogre::Vector3(1, 1, 1);
			if (document.HasMember("scale")) {
				scale = parseVector3(document["scale"]);
			} else 
			{
				scale = Ogre::Vector3(1, 1, 1);
			}

			// Needed for collisions 
			// interaction legend by diana 
			// -1 = no interaction 
			// 1 = teapots meaning they disappear (for now) 
			// 2 = tuna can (ending... for now) 
			int interaction;
			if (document.HasMember("interaction")) {
				interaction = document["interaction"].GetInt();
			} else {
				interaction = -1; // this means there's no interaction 
			}


			string collisionShape;
			if (document.HasMember("collisionShape")) {
				collisionShape = document["collisionShape"].GetString();
			} else {
				collisionShape = "btBoxShape";
			}


			
			// temp vars used for parsing collision shape size data
			btVector3 colDim3 = btVector3(1,1,1);
			btScalar colScala = 1;
			btScalar colScalb = 1;

			/* Parse the CollisionShape and its size size */
			
//.........这里部分代码省略.........
开发者ID:simonkwong,项目名称:Shamoov,代码行数:101,代码来源:GameLibrary.cpp


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