void WaypointMovementGenerator<Creature>::InitializeWaypointPath(Creature& u, int32 id, WaypointPathOrigin wpSource, uint32 initialDelay, uint32 overwriteEntry) { LoadPath(u, id, wpSource, overwriteEntry); i_nextMoveTime.Reset(initialDelay); // Start moving if possible StartMove(u); }
void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* /*invoker*/) { if (me->isInCombat())// no wp movement in combat { sLog->outError("SmartAI::StartPath: Creature entry %u wanted to start waypoint movement while in combat, ignoring.", me->GetEntry()); return; } if (HasEscortState(SMART_ESCORT_ESCORTING)) StopPath(); if (path) if (!LoadPath(path)) return; if (!mWayPoints || mWayPoints->empty()) return; AddEscortState(SMART_ESCORT_ESCORTING); mCanRepeatPath = repeat; SetRun(run); WayPoint* wp = GetNextWayPoint(); if (wp) { me->GetPosition(&mLastOOCPos); me->GetMotionMaster()->MovePoint(wp->id, wp->x, wp->y, wp->z); GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, NULL, wp->id, GetScript()->GetPathId()); } }
void WaypointMovementGenerator<Creature>::Initialize( Creature &u ) { i_nextMoveTime.Reset(0); // TODO: check the lower bound (0 is probably too small) u.StopMoving(); LoadPath(u); u.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); }
void WaypointMovementGenerator<Creature>::Reset(Creature &creature) { i_path = NULL; LoadPath(creature); SetStoppedByPlayer(false); i_nextMoveTime.Reset(0); creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); }
/*=================== Tunnel Initialization ================================*/ struct tunnel_state * atunnel_InitTunnel(void) { struct tunnel_state *st = (struct tunnel_state *) calloc (1, sizeof(*st)); LoadPath(st); st->current_texture = NRAND(MAX_TEXTURE); return st; }
void WaypointMovementGenerator<Creature>::Initialize(Creature& creature) { creature.addUnitState(UNIT_STAT_ROAMING); creature.clearUnitState(UNIT_STAT_WAYPOINT_PAUSED); LoadPath(creature); StartMoveNow(creature); }
void WaypointMovementGenerator<Creature>::Initialize(Creature& creature) { creature.addUnitState(UNIT_STAT_ROAMING); LoadPath(creature); if (!creature.isAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE)) return; creature.addUnitState(UNIT_STAT_ROAMING_MOVE); StartMoveNow(creature); }
void FlightPathMovementGenerator::Initialize(Player &player) { player.getHostilRefManager().setOnlineOfflineState(false); player.addUnitState(UNIT_STAT_IN_FLIGHT); LoadPath(player); i_currentNode = 0; Traveller<Player> traveller(player); // do not send movement, it was sent already i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); }
void WaypointMovementGenerator<Creature>::DoInitialize(Creature* owner) { if (!owner) return; if (!owner->isAlive()) return; LoadPath(owner); owner->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE); }
void FlightPathMovementGenerator::Initialize(Player &player) { player.getHostilRefManager().setOnlineOfflineState(false); player.addUnitState(UNIT_STAT_IN_FLIGHT); player.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); LoadPath(player); Traveller<Player> traveller(player); // do not send movement, it was sent already i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); player.SendMonsterMoveByPath(GetPath(),GetCurrentNode(),GetPathAtMapEnd(),MOVEMENTFLAG_WALK_MODE|MOVEMENTFLAG_ONTRANSPORT); }
void FlightPathMovementGenerator::Initialize(Player &player) { // Random handlers used for quests etc. - best would be to add FlightPathMovementGenerator::Initialize to sub-script class (Feanor) if( player.m_taxi.GetTaxiDestination() == 158 || player.m_taxi.GetTaxiDestination() == 243 ) player.SetDisplayId(16587); player.getHostileRefManager().setOnlineOfflineState(false); player.addUnitState(UNIT_STAT_IN_FLIGHT); player.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); LoadPath(player); Traveller<Player> traveller(player); // do not send movement, it was sent already i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); player.SendMonsterMoveByPath(GetPath(),GetCurrentNode(),GetPathAtMapEnd(), SplineFlags(SPLINEFLAG_WALKMODE|SPLINEFLAG_FLYING)); }
void PathBehavior::DoStepPostEvents(RuntimeScene & scene) { if(!isPathLoaded) { LoadPath(scene); Reset(); } if(futureSegment != -1) { EnterSegment(futureSegment); futureSegment = -1; } if(futurePosition != -1) { timeOnSegment = futurePosition * totalSegmentTime; futurePosition = -1; } }
/** * Called at each frame before events : * Position the object on the path */ void PathBehavior::DoStepPreEvents(RuntimeScene & scene) { if(!isPathLoaded) { LoadPath(scene); Reset(); } // add to the current time along the path timeOnSegment += static_cast<double>(scene.GetTimeManager().GetElapsedTime()) / 1000000.0 * speed; // if I reached the end of this segment, move to a new segment if (timeOnSegment >= totalSegmentTime && currentSegment < path.size()) EnterSegment(currentSegment + 1); //Position object on the segment sf::Vector2f newPos; if ( !path.empty() && currentSegment < path.size()-1 ) newPos = offset + path[currentSegment] + (path[currentSegment + 1] - path[currentSegment]) * (timeOnSegment / totalSegmentTime); else { if ( stopAtEnd && !path.empty()) newPos = path.back() + offset; else if (reverseAtEnd) { std::reverse(path.begin(), path.end()); EnterSegment(0); if (!path.empty()) newPos = path.front() + offset; } else { EnterSegment(0); if (!path.empty()) newPos = path.front() + offset; } } object->SetX(newPos.x); object->SetY(newPos.y); return; }
void SmartAI::StartPath(bool run/* = false*/, uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 1*/) { if (me->IsInCombat()) // no wp movement in combat { TC_LOG_ERROR("misc", "SmartAI::StartPath: Creature entry %u wanted to start waypoint movement (%u) while in combat, ignoring.", me->GetEntry(), pathId); return; } if (HasEscortState(SMART_ESCORT_ESCORTING)) StopPath(); SetRun(run); if (pathId) { if (!LoadPath(pathId)) return; } if (_path.nodes.empty()) return; _currentWaypointNode = nodeId; _waypointPathEnded = false; _repeatWaypointPath = repeat; // Do not use AddEscortState, removing everything from previous _escortState = SMART_ESCORT_ESCORTING; if (invoker && invoker->GetTypeId() == TYPEID_PLAYER) { _escortNPCFlags = me->GetUInt32Value(UNIT_NPC_FLAGS); me->SetFlag(UNIT_NPC_FLAGS, 0); } GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, nullptr, _currentWaypointNode, GetScript()->GetPathId()); me->GetMotionMaster()->MovePath(_path, _repeatWaypointPath); }
void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* invoker) { if (me->IsInCombat())// no wp movement in combat { sLog->outError("SmartAI::StartPath: Creature entry %u wanted to start waypoint movement while in combat, ignoring.", me->GetEntry()); return; } if (HasEscortState(SMART_ESCORT_ESCORTING)) StopPath(); if (path) { if (!LoadPath(path)) return; } if (!mWayPoints || mWayPoints->empty()) return; if (WayPoint* wp = GetNextWayPoint()) { AddEscortState(SMART_ESCORT_ESCORTING); mCanRepeatPath = repeat; SetRun(run); if (invoker && invoker->GetTypeId() == TYPEID_PLAYER) { mEscortNPCFlags = me->GetUInt32Value(UNIT_NPC_FLAGS); me->SetUInt32Value(UNIT_NPC_FLAGS, 0); } Movement::PointsArray pathPoints; GenerateWayPointArray(&pathPoints); me->GetMotionMaster()->MoveSplinePath(&pathPoints); GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, NULL, wp->id, GetScript()->GetPathId()); } }
void FlightPathMovementGenerator::Initialize(Player &player) { player.getHostileRefManager().setOnlineOfflineState(false); player.addUnitState(UNIT_STAT_IN_FLIGHT); player.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); LoadPath(player); Traveller<Player> traveller(player); // do not send movement, it was sent already i_destinationHolder.SetDestination(traveller, i_path[i_currentNode].x, i_path[i_currentNode].y, i_path[i_currentNode].z, false); player.SendMonsterMoveByPath(GetPath(), GetCurrentNode(), GetPathAtMapEnd()); // Storage to preload flightmaster grid at end of flight. For multi-stop flights, this will // be reinitialized for each flightmaster at the end of each spline (or stop) in the flight. uint32 nodeCount = i_mapIds.size(); // Get the number of nodes in the path. i_path and i_mapIds are the // same size when loaded in ObjectMgr::GetTaxiPathNodes, called from LoadPath() m_endMapId = i_mapIds[nodeCount -1]; // Get the map ID from the last node m_preloadTargetNode = nodeCount - 3; // 2 nodes before the final node, we pre-load the grid m_endGridX = i_path[nodeCount -1].x; // Get the X position from the last node m_endGridY = i_path[nodeCount -1].y; // Get tye Y position from the last node }
void SmartAI::StartPath(bool run, uint32 path, bool repeat, Unit* invoker) { if (me->IsInCombat())// no wp movement in combat { TC_LOG_ERROR("misc", "SmartAI::StartPath: Creature entry %u wanted to start waypoint movement while in combat, ignoring.", me->GetEntry()); return; } if (HasEscortState(SMART_ESCORT_ESCORTING)) StopPath(); SetRun(run); if (path) if (!LoadPath(path)) return; if (_path.nodes.empty()) return; mCurrentWPID = 1; m_Ended = false; // Do not use AddEscortState, removing everything from previous cycle mEscortState = SMART_ESCORT_ESCORTING; mCanRepeatPath = repeat; if (invoker && invoker->GetTypeId() == TYPEID_PLAYER) { mEscortNPCFlags = me->GetUInt32Value(UNIT_NPC_FLAGS); me->SetFlag(UNIT_NPC_FLAGS, 0); } GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_START, nullptr, mCurrentWPID, GetScript()->GetPathId()); me->GetMotionMaster()->MovePath(_path, mCanRepeatPath); }
bool CConfigIni::LoadSystem(const CString& systemName, CConfigIni::structSystem& system) { //路径 LoadPath(systemName, l_szIniItem_PathData, system.m_szPathData); LoadPath(systemName, l_szIniItem_PathTask, system.m_szPathTask); LoadPath(systemName, l_szIniItem_PathSample, system.m_szPathSample); LoadPath(systemName, l_szIniItem_PathCompound, system.m_szPathCompound); LoadPath(systemName, l_szIniItem_PathMethod, system.m_szPathMethod); LoadPath(systemName, l_szIniItem_PathCrystalReport, system.m_szPathCrystalReport); LoadPath(systemName, l_szIniItem_PathLog, system.m_szPathLog); //参数 LoadString(systemName, l_szIniItem_DefaultMethod, system.m_szDefaultMethod); LoadString(systemName, l_szIniItem_Inject, system.m_szInject); // LoadString(systemName, _T("SCParam"), system.m_szSCParam); // LoadString(systemName, _T("SysSettings"), system.m_szSysSettings); LoadString(systemName, l_szIniItem_Instrument, system.m_szInstrument); //硬件 LoadInt(systemName, l_szIniItem_RGACOM, system.m_iRGACOM); LoadInt(systemName, l_szIniItem_ValveCOM, system.m_iValveCOM); LoadInt(systemName, l_szIniItem_PumpCOM, system.m_iPumpCOM); LoadInt(systemName, l_szIniItem_NextSampleID, system.m_iNextSampleID); LoadString(systemName, l_szIniItem_WindowName, system.m_szWindowName); LoadString(systemName, l_szIniItem_ProgramName, system.m_szProgramName); LoadString(systemName, l_szIniItem_MessageName, system.m_szMessageName); LoadString(systemName, l_szIniItem_SignalName, system.m_szSignalName); LoadString(systemName, l_szIniItem_XSLFolder, system.m_szXSLFolder); if(system.m_szXSLFolder.GetLength()) { TCHAR c = system.m_szXSLFolder.GetAt(system.m_szXSLFolder.GetLength() - 1); if(c == '/' || c == '\\') system.m_szXSLFolder.Delete(system.m_szXSLFolder.GetLength() - 1); } LoadString(systemName, l_szIniItem_LastTask, system.m_szLastTask); LoadInt(systemName, l_szIniItem_ShowAutoSampler, system.m_bShowAutoSampler); return true; }
void main(int argc, char **argv) { // init glut glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE); // create the window glutCreateWindow("PQP Demo - Falling"); // set OpenGL graphics state -- material props, perspective, etc. init_viewer_window(); // set the callbacks glutDisplayFunc(cb_display); glutMouseFunc(cb_mouse); glutMotionFunc(cb_motion); glutKeyboardFunc(cb_keyboard); glutIdleFunc(cb_idle); // create models FILE *fp; int ntris, i; double a,b,c; PQP_REAL p1[3],p2[3],p3[3]; // model 1 torus1_drawn = new Model("torus1.tris"); torus1_tested = new PQP_Model(); fp = fopen("torus1.tris","r"); fscanf(fp,"%d",&ntris); torus1_tested->BeginModel(); for (i = 0; i < ntris; i++) { fscanf(fp,"%lf %lf %lf",&a,&b,&c); p1[0] = (PQP_REAL)a; p1[1] = (PQP_REAL)b; p1[2] = (PQP_REAL)c; fscanf(fp,"%lf %lf %lf",&a,&b,&c); p2[0] = (PQP_REAL)a; p2[1] = (PQP_REAL)b; p2[2] = (PQP_REAL)c; fscanf(fp,"%lf %lf %lf",&a,&b,&c); p3[0] = (PQP_REAL)a; p3[1] = (PQP_REAL)b; p3[2] = (PQP_REAL)c; torus1_tested->AddTri(p1,p2,p3,i); } torus1_tested->EndModel(); fclose(fp); // model 2 torus2_drawn = new Model("torus2.tris"); torus2_tested = new PQP_Model(); fp = fopen("torus2.tris","r"); fscanf(fp,"%d",&ntris); torus2_tested->BeginModel(); for (i = 0; i < ntris; i++) { fscanf(fp,"%lf %lf %lf",&a,&b,&c); p1[0] = (PQP_REAL)a; p1[1] = (PQP_REAL)b; p1[2] = (PQP_REAL)c; fscanf(fp,"%lf %lf %lf",&a,&b,&c); p2[0] = (PQP_REAL)a; p2[1] = (PQP_REAL)b; p2[2] = (PQP_REAL)c; fscanf(fp,"%lf %lf %lf",&a,&b,&c); p3[0] = (PQP_REAL)a; p3[1] = (PQP_REAL)b; p3[2] = (PQP_REAL)c; torus2_tested->AddTri(p1,p2,p3,i); } torus2_tested->EndModel(); fclose(fp); // load paths LoadPath(R1,T1,"torus1.path"); LoadPath(R2,T2,"torus2.path"); // print instructions LOG4CXX_INFO(KrisLibrary::logger(),"PQP Demo - Falling:\n" "Press:\n" "0 - no proximity query, just animation\n" "1 - collision query\n" " overlapping triangles shown in red.\n" "2 - distance query\n" " closest points connected by a line.\n" "3 - tolerance query\n" " reduce/increase tolerance with -/= keys.\n" " models turn blue when closer than the tolerance.\n" "any other key to toggle animation on/off\n"); // Enter the main loop. glutMainLoop(); }
void Profile::GetDeviceConfig(unsigned n, DeviceConfig &config) { TCHAR buffer[64]; config.port_type = ReadPortType(n); MakeDeviceSettingName(buffer, _T("Port"), n, _T("BluetoothMAC")); Get(buffer, config.bluetooth_mac); MakeDeviceSettingName(buffer, _T("Port"), n, _T("IOIOUartID")); Get(buffer, config.ioio_uart_id); MakeDeviceSettingName(buffer, _T("Port"), n, _T("TCPPort")); if (!Get(buffer, config.tcp_port)) config.tcp_port = 4353; config.path.clear(); if (config.port_type == DeviceConfig::PortType::SERIAL && !LoadPath(config, n) && !LoadPortIndex(config, n)) { if (IsAltair() && n == 0) config.path = _T("COM3:"); else if (IsAltair() && n == 2) config.path = _T("COM2:"); } MakeDeviceSettingName(buffer, _T("Port"), n, _T("BaudRate")); if (!Get(buffer, config.baud_rate)) { /* XCSoar before 6.2 used to store a "speed index", not the real baud rate - try to import the old settings */ static gcc_constexpr_data unsigned speed_index_table[] = { 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 }; MakeDeviceSettingName(buffer, _T("Speed"), n, _T("Index")); unsigned speed_index; if (Get(buffer, speed_index) && speed_index < ARRAY_SIZE(speed_index_table)) config.baud_rate = speed_index_table[speed_index]; else if (IsAltair()) config.baud_rate = 38400; else config.baud_rate = 4800; } MakeDeviceSettingName(buffer, _T("Port"), n, _T("BulkBaudRate")); if (!Get(buffer, config.bulk_baud_rate)) config.bulk_baud_rate = 0; _tcscpy(buffer, _T("DeviceA")); buffer[_tcslen(buffer) - 1] += n; if (!Get(buffer, config.driver_name)) { if (IsAltair() && n == 0) config.driver_name = _T("Altair RU"); else if (IsAltair() && n == 1) config.driver_name = _T("Vega"); else if (IsAltair() && n == 2) config.driver_name = _T("NmeaOut"); else config.driver_name.clear(); } }
void WaypointMovementGenerator<Creature>::DoInitialize(Creature* creature) { LoadPath(creature); creature->AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE); }
void WaypointMovementGenerator<Creature>::DoInitialize(Creature* creature) { LoadPath(creature); }
void Profile::GetDeviceConfig(const ProfileMap &map, unsigned n, DeviceConfig &config) { char buffer[64]; bool have_port_type = ReadPortType(map, n, config.port_type); MakeDeviceSettingName(buffer, "Port", n, "BluetoothMAC"); map.Get(buffer, config.bluetooth_mac); MakeDeviceSettingName(buffer, "Port", n, "IOIOUartID"); map.Get(buffer, config.ioio_uart_id); MakeDeviceSettingName(buffer, "Port", n, "IPAddress"); if (!map.Get(buffer, config.ip_address)) config.ip_address.clear(); MakeDeviceSettingName(buffer, "Port", n, "TCPPort"); if (!map.Get(buffer, config.tcp_port)) config.tcp_port = 4353; config.path.clear(); if ((!have_port_type || config.port_type == DeviceConfig::PortType::SERIAL) && !LoadPath(map, config, n) && LoadPortIndex(map, config, n)) config.port_type = DeviceConfig::PortType::SERIAL; MakeDeviceSettingName(buffer, "Port", n, "BaudRate"); if (!map.Get(buffer, config.baud_rate)) { /* XCSoar before 6.2 used to store a "speed index", not the real baud rate - try to import the old settings */ static constexpr unsigned speed_index_table[] = { 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 }; MakeDeviceSettingName(buffer, "Speed", n, "Index"); unsigned speed_index; if (map.Get(buffer, speed_index) && speed_index < ARRAY_SIZE(speed_index_table)) config.baud_rate = speed_index_table[speed_index]; } MakeDeviceSettingName(buffer, "Port", n, "BulkBaudRate"); if (!map.Get(buffer, config.bulk_baud_rate)) config.bulk_baud_rate = 0; strcpy(buffer, "DeviceA"); buffer[strlen(buffer) - 1] += n; map.Get(buffer, config.driver_name); MakeDeviceSettingName(buffer, "Port", n, "Enabled"); map.Get(buffer, config.enabled); MakeDeviceSettingName(buffer, "Port", n, "SyncFromDevice"); map.Get(buffer, config.sync_from_device); MakeDeviceSettingName(buffer, "Port", n, "SyncToDevice"); map.Get(buffer, config.sync_to_device); MakeDeviceSettingName(buffer, "Port", n, "K6Bt"); map.Get(buffer, config.k6bt); MakeDeviceSettingName(buffer, "Port", n, "I2C_Bus"); map.Get(buffer, config.i2c_bus); MakeDeviceSettingName(buffer, "Port", n, "I2C_Addr"); map.Get(buffer, config.i2c_addr); MakeDeviceSettingName(buffer, "Port", n, "PressureUse"); map.GetEnum(buffer, config.press_use); MakeDeviceSettingName(buffer, "Port", n, "SensorOffset"); map.Get(buffer, config.sensor_offset); MakeDeviceSettingName(buffer, "Port", n, "SensorFactor"); map.Get(buffer, config.sensor_factor); MakeDeviceSettingName(buffer, "Port", n, "UseSecondDevice"); map.Get(buffer, config.use_second_device); MakeDeviceSettingName(buffer, "Port", n, "SecondDevice"); map.Get(buffer, config.driver2_name); }
void WaypointMovementGenerator<Creature>::Initialize(Creature& creature) { LoadPath(creature); creature.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); }
void FlightPathMovementGenerator::Initialize(Player &player) { LoadPath(player); Reset(player); }