void ETHScene::AssignControllerToEntity(ETHEntity* entity, const int callbackId, const int constructorCallbackId, const int destructorCallbackId) { entity->SetDestructorCallbackId(destructorCallbackId); if (callbackId >= 0 || constructorCallbackId >= 0) { ETHEntityControllerPtr currentController(entity->GetController()); ETHEntityControllerPtr newController(new ETHRawEntityController(currentController, m_pContext, callbackId, constructorCallbackId)); entity->SetController(newController); } if (entity->IsBody()) { ETHEntityControllerPtr controller = m_physicsSimulator.CreatePhysicsController(entity, m_pModule, m_pContext); #if defined(_DEBUG) || defined(DEBUG) str_type::stringstream ss; Platform::Logger::TYPE logType; if (controller) { logType = Platform::Logger::INFO; ss << GS_L("Physics controller successfuly created: "); } else { logType = Platform::Logger::ERROR; ss << GS_L("Couldn't create physics controller: "); } ss << entity->GetEntityName() << GS_L(" (#") << entity->GetID() << GS_L(")"); m_provider->Log(ss.str(), logType); #endif entity->SetController(controller); } }
bool ThreadControl::addThread(Thread *newThread){ int cont = 1; struct ThreadList *auxiliary; if(controller == NULL){ controller = newController(newThread); } else{ auxiliary = controller; while(true){ if(newThread == auxiliary->pointer || cont >= MAX_THREAD_IN_CONTROLLER) return false; if(auxiliary->next == NULL) break; auxiliary = auxiliary->next; cont++; } auxiliary->next = newController(newThread); } return true; }
TGen::Engine::Component * TGen::Engine::Controller::Subsystem::createComponent(const std::string & name, const std::string & entityName, const TGen::PropertyTree & properties) { TGen::Engine::PlayerController * ret = NULL; std::string type = properties.getProperty("type", "none"); if (type == "firstperson") { // TODO: spräng ut alla ctor-params till metoder std::auto_ptr<TGen::Engine::Controller::FirstPerson> newController(new TGen::Engine::Controller::FirstPerson(name, TGen::lexical_cast<scalar>(properties.getProperty("deltaPlane", "1.0")), TGen::lexical_cast<scalar>(properties.getProperty("jumpForce", "15000")), TGen::lexical_cast<scalar>(properties.getProperty("jumpTime", "0.3")) )); newController->setUsePhysics(TGen::lexical_cast<bool>(properties.getProperty("usePhysics", "false"))); newController->setAirControl(TGen::lexical_cast<scalar>(properties.getProperty("airControl", "0.7"))); newController->setView(properties.getProperty("view", "sceneNode")); newController->setControl(properties.getProperty("control", "sceneNode")); //newController->addCamera("headcam", properties.getProperty("camera", "sceneCamera")); newController->setWeaponLink(properties.getProperty("weapon", "")); newController->setEquipment(properties.getProperty("equipment", "")); ret = newController.release(); } else if (type == "arcball") { TGen::Engine::Controller::Arcball * newArcball = new TGen::Engine::Controller::Arcball(name); newArcball->setControl(properties.getProperty("control", "sceneNode")); //newArcball->addCamera("headcam", properties.getProperty("camera", "sceneCamera")); ret = newArcball; } else { throw TGen::RuntimeException("Controller::Subsystem::createComponent", "invalid controller type: '" + type + "'"); } ret->setCamera(properties.getProperty("camera", "")); controllers.insert(std::make_pair(entityName, ret)); return ret; }