示例#1
0
void MainWindow::listEntity()
{

	static std::vector<const char*> namesEntities;

	ImGui::Begin("List entities", &_windowListEntity);

	if (_timerListEntityUpdate > 1)
	{
		namesEntities = getAllEntities();
		_timerListEntityUpdate = 0;
	}
	else
	{
		_timerListEntityUpdate += fm::Time::dt;
	}
	static int number = -1;

	for (size_t i = 0; i < namesEntities.size(); i++)
	{
		fm::GameObject *o = fm::SceneManager::get().getCurrentScene()->GetGameObject(i);
		fmc::CTransform *transform = o->get<fmc::CTransform>();
		// Disable the default open on single-click behavior and pass in Selected flag according to our selection state.
		ImGuiTreeNodeFlags node_flags = ((number == i) ? ImGuiTreeNodeFlags_Selected : 0);

		// Node
		//ImGui::PushStyleColor(ImGuiCol_HeaderSelected, (ImVec4)ImColor::HSV(0.9f, 0.8f, 0.8f));

		bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, namesEntities[i], i);

		if (ImGui::IsItemClicked())
			number = i;
		if (node_open)
		{
			//ImGui::Text("Blah blah\nBlah Blah");
			ImGui::TreePop();

		}

		//ImGui::PopStyleColor(1);
		


	}
	if (number != -1)
		_currentEntity = fm::SceneManager::get().getCurrentScene()->getAllGameObjects()[number];


	if (ImGui::Button("Add Entity"))
	{
		_currentEntity = fm::GameObjectHelper::create();
		_currentEntity->addComponent<fmc::CTransform>(fm::math::Vector3f(0, 0, 0),
			fm::math::Vector3f(1, 1, 1),
			fm::math::vec3(0, 0, 0));
	}

	ImGui::End();

}
示例#2
0
void MyController::onInit(InitEvent &evt)
{
	avatars_number = "2";
	m_state = 20;
	ind =20;
	getAllEntities(names);


	int sstrPos1 = 0;
	int sstrPos2 = 0;
	int sstrPos3 = 0;
	std::string sheadss = "";
	std::string scmd = "";
	std::string stmpss = "";

	for (int j = 0; j< names.size();j++) {
		std::cout<<"the name is :"<< names[j] <<std::endl;
		sstrPos1 = 0;
		sstrPos2 = 0;
		sstrPos3 = 0;
		sheadss = "";
		scmd = "";
		stmpss = "";

		sstrPos2 = names[j].find("_", sstrPos1);
		sheadss.assign(names[j], sstrPos1, sstrPos2-sstrPos1);
		avatar avatar1;
		
		if (sheadss == "man") {
			avatar1.name = names[j];
			avatar1.ID = "";
			list.push_back(avatar1);
		}
	}

	for (int j = 0; j< list.size();j++) {
		std::cout<<"the list content:"<< list[j].name <<std::endl;
	}
	/*
	  avatar avatar4;
	  avatar4.name ="man_000";
	  avatar4.ID = "";
	  list.push_back(avatar4);

	  avatar avatar1;
	  avatar1.name = "man_001";
	  avatar1.ID = "";
	  list.push_back(avatar1);
	*/
	m_ref = NULL;
}
示例#3
0
int main() {
	//preallocate the instance
	auto entityManager = EntityManager::getInstance();

	//lets create an entity to place in entity manager
	auto entity = std::shared_ptr<AbstractEntity> (new MainEntity("Drone", 0));
	entity->addComponent(std::shared_ptr<AbstractComponent> (new HealthComponent("Drone Health")));
	entity->addComponent(std::shared_ptr<AbstractComponent> (new HealthComponent("Drone Armor")));
	entityManager->addEntity(entity);

	entity = std::shared_ptr<AbstractEntity> (new MainEntity("Drone", 1));
	entity->addComponent(std::shared_ptr<AbstractComponent> (new HealthComponent("Drone Health")));
	entity->addComponent(std::shared_ptr<AbstractComponent> (new HealthComponent("Drone Armor")));
	entityManager->addEntity(entity);

	entity = std::shared_ptr<AbstractEntity> (new MainEntity("Base", 2));
	entity->addComponent(std::shared_ptr<AbstractComponent> (new HealthComponent("Drone Health")));
	entity->addComponent(std::shared_ptr<AbstractComponent> (new HealthComponent("Drone Armor")));
	entityManager->addEntity(entity);

	//getting entity by ID
	auto entity_0 = entityManager->getEntityById(0);
	std::cout << "Entity ID 0: " << entity_0->getName() << std::endl;

	//getting entity by Name
	auto entityList = entityManager->getEntitiesByName("Drone");
	std::cout << "list: entities by name 'Drone'" << std::endl;
	for (auto entity : entityList) {
		std::cout << "Name: " << entity->getName();
		std::cout << "( " << entity->getID() << " )" << std::endl;
	}

	//getting entity by Family
	entityList = entityManager->getEntitiesByFamily("Main");
	std::cout << "list: entities by family 'Main'" << std::endl;
	for (auto entity : entityList) {
		std::cout << "Name: " << entity->getName();
		std::cout << "( " << entity->getID() << " )" << std::endl;
	}

	//get all entities in an STL vector
	auto entityVec = entityManager->getAllEntities();
	std::cout << "list: all entities" << std::endl;
	for (auto entity : entityList) {
		std::cout << "Name: " << entity->getName();
		std::cout << "( " << entity->getID() << " )" << std::endl;
	}

	return 0;
}
void MyController::onInit(InitEvent &evt) {
	m_my = getObj(myname());
	getAllEntities(m_entities);
	m_ref = NULL;
	retValue = 0.5;
	roboName = "robot_000";

	colState = false;

	// ワゴン
	tboxSize_x = 60.6;
	tboxSize_z = 64.6; 
	tboxMin_y  = 50.8;
	tboxMax_y  = 1000.0;
}
void MyController::onInit(InitEvent &evt) {  
  m_my = getObj(myname());
  getAllEntities(m_entities);
  m_ref = NULL;
  retValue = 0.1;
  roboName = "robot_000";

  colState = false;

  // ゴミ箱
  tboxSize_x  = 120.0;
  tboxSize_z  = 90.5; 
  tboxMin_y    = 30.0;
  tboxMax_y    = 1000.0;
}