示例#1
0
void IconManager::render(Icon& icon, Eris::TypeInfo& erisType) {
	//we need to get the model mapping definition for this type
	//once we have that, we will check for the first action of the first case of the first match (since that's guaranteed to be a show-model action
	Eris::Connection* conn = EmberServices::getSingleton().getServerService().getConnection();
	if (conn) {
		Eris::TypeService* typeService = conn->getTypeService();
		if (typeService) {
			DummyEntity dummyEntity("-1", &erisType, typeService);
			std::string modelName;
			Mapping::ModelActionCreator actionCreator(dummyEntity, [&](std::string newModelName){
				modelName = newModelName;
			}, [&](std::string partName){
				//Ignore parts
			});
			std::unique_ptr<EntityMapping::EntityMapping> modelMapping(Mapping::EmberEntityMappingManager::getSingleton().getManager().createMapping(dummyEntity, actionCreator, &EmberOgre::getSingleton().getWorld()->getView()));
			if (modelMapping) {
				modelMapping->initialize();
			}
			//if there's no model defined for this use the placeholder model
			if (modelName.empty()) {
				modelName = "common/primitives/placeholder.modeldef";
			}
			//update the model preview window
			// 					Model::Model* model = Model::Model::createModel(mIconRenderer.getRenderContext()->getSceneManager(), modelName);
			render(icon, modelName);
			// 					mIconRenderer.getRenderContext()->getSceneManager()->destroyMovableObject(model);

			dummyEntity.shutdown();
		}
	}
}
示例#2
0
void EntityEditor::getGoalInfo(const std::string& id)
{

	Eris::Account* account = EmberServices::getSingleton().getServerService().getAccount();

	Atlas::Objects::Operation::Generic get;
	std::list<std::string> parents;
	parents.emplace_back("commune");
	get->setParents(parents);
	get->setTo(mEntity.getId());

	//By setting it TO an entity and FROM our avatar we'll make the server deliver it as
	//if it came from the entity itself (the server rewrites the FROM to be of the entity).
	get->setFrom(mWorld.getAvatar()->getEmberEntity().getId());
	//By setting a serial number we tell the server to "relay" the operation. This means that any
	//response operation from the target entity will be sent back to us.
	get->setSerialno(Eris::getNewSerialno());

	Atlas::Message::MapType goalMap;
	goalMap["id"] = id;
	Atlas::Objects::Entity::Anonymous getArg;
	getArg->setAttr("goal_info", goalMap);
	get->setArgs1(getArg);

	Eris::Connection* connection = account->getConnection();

	connection->getResponder()->await(get->getSerialno(), this, &EntityEditor::operationGetGoalInfoResult);
	connection->send(get);
}
示例#3
0
void EntityEditor::removeGoal(const std::string& id)
{
	Eris::Account* account = EmberServices::getSingleton().getServerService().getAccount();

	Atlas::Message::MapType goalElement;
	goalElement["id"] = id;
	//By not defining anything else than the id we're telling the server to remove it.

	Atlas::Objects::Entity::Anonymous thought;
	thought->setAttr("goal", goalElement);

	Atlas::Objects::Operation::RootOperation thinkOp;
	thinkOp->setArgs1(thought);
	std::list<std::string> parents;
	parents.emplace_back("think");
	thinkOp->setParents(parents);
	thinkOp->setTo(mEntity.getId());
	//By setting it TO an entity and FROM our avatar we'll make the server deliver it as
	//if it came from the entity itself (the server rewrites the FROM to be of the entity).
	thinkOp->setFrom(mWorld.getAvatar()->getEmberEntity().getId());

	Eris::Connection* connection = account->getConnection();

	connection->send(thinkOp);
}
示例#4
0
void IconManager::render(Icon& icon, Eris::TypeInfo& erisType)
{
  //we need to get the model mapping definition for this type
  //once we have that, we will check for the first action of the first case of the first match (since that's guaranteed to be a show-model action
  Eris::Connection* conn = EmberServices::getSingleton().getServerService().getConnection();
  if (conn) {
    Eris::TypeService* typeService = conn->getTypeService();
    if (typeService) {
      DummyEntity dummyEntity("-1", &erisType, typeService);
      IconActionCreator actionCreator(dummyEntity);
      std::auto_ptr<EntityMapping::EntityMapping> modelMapping(Mapping::EmberEntityMappingManager::getSingleton().getManager().createMapping(dummyEntity, &actionCreator, Application::getSingleton().getMainView()));
      std::string modelName;
      if (modelMapping.get()) {
        modelMapping->initialize();
        modelName = actionCreator.getModelName();
      }
      //if there's no model defined for this use the placeholder model
      if (modelName == "") {
        modelName = "placeholder";
      }
      //update the model preview window
      // 					Model::Model* model = Model::Model::createModel(mIconRenderer.getRenderContext()->getSceneManager(), modelName);
      render(icon, modelName);
      // 					mIconRenderer.getRenderContext()->getSceneManager()->destroyMovableObject(model);

      dummyEntity.shutdown();
    }
  }
}
示例#5
0
void EntityEditor::addKnowledge(const std::string& predicate, const std::string& subject, const std::string& knowledge)
{
	Eris::Account* account = EmberServices::getSingleton().getServerService().getAccount();

	Atlas::Objects::Entity::Anonymous thought;
	thought->setAttr("predicate", predicate);
	thought->setAttr("subject", subject);
	thought->setAttr("object", knowledge);

	Atlas::Objects::Operation::RootOperation thinkOp;
	thinkOp->setArgs1(thought);
	std::list<std::string> parents;
	parents.emplace_back("think");
	thinkOp->setParents(parents);
	thinkOp->setTo(mEntity.getId());
	//By setting it TO an entity and FROM our avatar we'll make the server deliver it as
	//if it came from the entity itself (the server rewrites the FROM to be of the entity).
	thinkOp->setFrom(mWorld.getAvatar()->getEmberEntity().getId());

	Eris::Connection* connection = account->getConnection();

	connection->send(thinkOp);

}