コード例 #1
0
        void JustStartedEscort()
        {
            m_uiEventTimer = 5000;
            m_uiEventCount = 0;

            m_lResearchersList.clear();

            float x, y, z;
            me->GetPosition(x, y, z);

            CellPair pair(Trinity::ComputeCellPair(x, y));
            Cell cell(pair);
            cell.data.Part.reserved = ALL_DISTRICT;
            cell.SetNoCreate();

            Trinity::AllCreaturesOfEntryInRange check(me, NPC_RESEARCHER, 25);
            Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(me,m_lResearchersList, check);
            TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher);
            cell.Visit(pair, cSearcher, *(me->GetMap()));

            if (!m_lResearchersList.empty())
                SetFormation();
        }
コード例 #2
0
        void Reset()
        {
            m_uiFreezeSlashTimer = 15*IN_MILLISECONDS;
            m_uiPenetratingColdTimer = 20*IN_MILLISECONDS;
            m_uiNerubianShadowStrikeTimer = 30*IN_MILLISECONDS;
            m_uiSummonNerubianTimer = 10*IN_MILLISECONDS;
            m_uiSubmergeTimer = 80*IN_MILLISECONDS;

            m_uiPursuingSpikeTimer = 2*IN_MILLISECONDS;
            m_uiSummonScarabTimer = 2*IN_MILLISECONDS;

            m_uiSummonFrostSphereTimer = 20*IN_MILLISECONDS;

            m_uiBerserkTimer = 15*MINUTE*IN_MILLISECONDS;
            m_uiStage = 0;
            m_uiScarabSummoned = 0;
            m_bIntro = true;
            m_bReachedPhase3 = false;
            m_uiTargetGUID = 0;
            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE);
            Summons.DespawnAll();
            m_vBurrowGUID.clear();
        }
コード例 #3
0
    void Reset()
    {
        Intro = true;
        Next = true;
        Wave = 0;
        IntroTimer = 45000;
        NextTimer = 51000;
        SandBreath_Timer = urand(6400, 10300);
        ImpendingDeath_Timer = urand(25000, 30000);
        WingBuffet_Timer = urand(12400, 20300);
        Mda_Timer = urand(1100, 8800);
        attackers.clear();
        me->SetReactState(REACT_PASSIVE);
        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

        Map* tmpMap = me->GetMap();

        if (!tmpMap)
            return;

        if (Creature* Thrall = tmpMap->GetCreature(tmpMap->GetCreatureGUID(NPC_THRALL)))
            ThrallGUID = Thrall->GetGUID();
    }
コード例 #4
0
ファイル: spell_dk.cpp プロジェクト: 814077430/ArkCORE
        void FilterTargets (std::list<Unit*>& unitList)
        {
            Unit* unit_to_add = NULL;
            for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end(); ++itr)
            {
                if ((*itr)->GetTypeId() == TYPEID_UNIT && (*itr)->GetOwnerGUID() == GetCaster()->GetGUID() && (*itr)->ToCreature()->GetCreatureInfo()->type == CREATURE_TYPE_UNDEAD)
                {
                    unit_to_add = (*itr);
                    break;
                }
            }

            unitList.clear();
            if (unit_to_add)
                unitList.push_back(unit_to_add);
            else
            {
                // Pet not found - remove cooldown
                if (Player* modOwner = GetCaster()->GetSpellModOwner())
                    modOwner->RemoveSpellCooldown(GetSpellInfo()->Id, true);
                FinishCast(SPELL_FAILED_NO_PET);
            }
        }
コード例 #5
0
ファイル: qst.cpp プロジェクト: openzelda/ozc2other
	bool mapDetails( std::list<object> & objects, uint32_t &x, uint32_t & y, uint32_t &w, uint32_t &h )
	{
		if ( oz::maps_iter == oz::maps.end())
			return false;
		objects.clear();


		rectangle group = *oz::maps_iter;
		//std::cout << "oz::mapDetails: " << group.x << "x" << group.x << " " << group.w<< "x" << group.h << std::endl;
		for( uint8_t _x = 0; _x < group.w; _x++)
		{
			for( uint8_t _y = 0; _y < group.h; _y++)
			{
				ParseLND(objects, group.x+_x, group.y+_y, _x, _y);
			}
		}
		x = group.x;
		y = group.y;
		w = group.w;
		h = group.h;
		oz::maps_iter++;
		return true;
	}
コード例 #6
0
ファイル: fs.cpp プロジェクト: asionius/fibjs
result_t fs_base::clearZipFS(exlib::string fname)
{
    if (fname.empty()) {
        s_cachelock.lock();
        s_cache.clear();
        s_cachelock.unlock();
    } else {
        std::list<obj_ptr<cache_node>>::iterator it;

        exlib::string safe_name;
        path_base::normalize(fname, safe_name);

        s_cachelock.lock();
        for (it = s_cache.begin(); it != s_cache.end(); ++it)
            if ((*it)->m_name == safe_name) {
                s_cache.erase(it);
                break;
            }
        s_cachelock.unlock();
    }

    return 0;
}
コード例 #7
0
        void Reset()
        {
            uiStampedeTimer = 10*IN_MILLISECONDS;
            uiWhirlingSlashTimer = 21*IN_MILLISECONDS;
            uiPunctureTimer = 10*IN_MILLISECONDS;
            uiEnrageTimer = 15*IN_MILLISECONDS;
            uiImpalingChargeTimer = 21*IN_MILLISECONDS;
            uiStompTimer = 25*IN_MILLISECONDS;
            uiTransformationTimer = 9*IN_MILLISECONDS;
            uiPhaseCounter = 0;

            impaledList.clear();
            shareTheLove = 0;

            bStartOfTransformation = true;

            Phase = TROLL;

            me->SetDisplayId(DISPLAY_TROLL);

            if (instance)
                instance->SetData(DATA_GAL_DARAH_EVENT, NOT_STARTED);
        }
コード例 #8
0
ファイル: AreaClipper.cpp プロジェクト: AllenBootung/FreeCAD
static void MakePolyPoly( const CArea& area, TPolyPolygon &pp, bool reverse = true ){
	pp.clear();

	for(std::list<CCurve>::const_iterator It = area.m_curves.begin(); It != area.m_curves.end(); It++)
	{
		pts_for_AddVertex.clear();
		const CCurve& curve = *It;
		const CVertex* prev_vertex = NULL;
		for(std::list<CVertex>::const_iterator It2 = curve.m_vertices.begin(); It2 != curve.m_vertices.end(); It2++)
		{
			const CVertex& vertex = *It2;
			if(prev_vertex)AddVertex(vertex, prev_vertex);
			prev_vertex = &vertex;
		}

		TPolygon p;
		p.resize(pts_for_AddVertex.size());
		if(reverse)
		{
			std::size_t i = pts_for_AddVertex.size() - 1;// clipper wants them the opposite way to CArea
			for(std::list<DoubleAreaPoint>::iterator It = pts_for_AddVertex.begin(); It != pts_for_AddVertex.end(); It++, i--)
			{
				p[i] = It->int_point();
			}
		}
		else
		{
			unsigned int i = 0;
			for(std::list<DoubleAreaPoint>::iterator It = pts_for_AddVertex.begin(); It != pts_for_AddVertex.end(); It++, i++)
			{
				p[i] = It->int_point();
			}
		}

		pp.push_back(p);
	}
}
コード例 #9
0
//*****************************************************************************
//*****************************************************************************
//
//*****************************************************************************
// [RC]
static void network_InitPWADList( void )
{
	g_PWADs.clear( );

	// Find the IWAD index.
	ULONG ulNumPWADs = 0, ulRealIWADIdx;
	for ( ULONG ulIdx = 0; Wads.GetWadName( ulIdx ) != NULL; ulIdx++ )
	{
		if ( strchr( Wads.GetWadName( ulIdx ), ':' ) == NULL ) // Since WADs can now be loaded within pk3 files, we have to skip over all the ones automatically loaded. To my knowledge, the only way to do this is to skip wads that have a colon in them.
		{
			if ( ulNumPWADs == FWadCollection::IWAD_FILENUM )
			{
				ulRealIWADIdx = ulIdx;
				break;
			}

			ulNumPWADs++;
		}
	}

	g_IWAD = Wads.GetWadName( ulRealIWADIdx );

	// Collect all the PWADs into a list.
	for ( ULONG ulIdx = 0; Wads.GetWadName( ulIdx ) != NULL; ulIdx++ )
	{
		// Skip the IWAD, zandronum.pk3, files that were automatically loaded from subdirectories (such as skin files), and WADs loaded automatically within pk3 files.
		if (( ulIdx == ulRealIWADIdx ) ||
			( stricmp( Wads.GetWadName( ulIdx ), GAMENAMELOWERCASE ".pk3" ) == 0 ) ||
			( Wads.GetLoadedAutomatically( ulIdx )) ||
			( strchr( Wads.GetWadName( ulIdx ), ':' ) != NULL ))
		{
			continue;
		}

		g_PWADs.push_back( Wads.GetWadName( ulIdx ));
	}
}
コード例 #10
0
ファイル: nuiObject.cpp プロジェクト: jpastuszek/nui3
void nuiObject::GetSortedAttributes(std::list<nuiAttribBase>& rListToFill) const
{
  CheckValid();
  rListToFill.clear();

  // Add classes attributes
  int32 c = mClassNameIndex;
  while (c >= 0)
  {
    std::map<nglString,nuiAttributeBase*>::const_iterator it = mClassAttributes[c].begin();
    std::map<nglString,nuiAttributeBase*>::const_iterator end = mClassAttributes[c].end();
    while (it != end)
    {
      nuiAttributeBase* pBase = it->second;
      rListToFill.push_back(nuiAttribBase(const_cast<nuiObject*>(this), pBase));
      
      ++it;
    }
    
    c = mInheritanceMap[c];
  }

  // Add instance attributes
  {
    std::map<nglString,nuiAttributeBase*>::const_iterator it = mInstanceAttributes.begin();
    std::map<nglString,nuiAttributeBase*>::const_iterator end = mInstanceAttributes.end();
    while (it != end)
    {
      nuiAttributeBase* pBase = it->second;
      rListToFill.push_back(nuiAttribBase(const_cast<nuiObject*>(this), pBase));
      
      ++it;
    }
  }
  
  rListToFill.sort(NUIATTRIBUTES_COMPARE);
}
コード例 #11
0
ファイル: waypoints.cpp プロジェクト: Leere/Server
void NPC::GetClosestWaypoint(std::list<wplist> &wp_list, int count, float m_x, float m_y, float m_z)
{
	wp_list.clear();
	if(Waypoints.size() <= count)
	{
		for(int i = 0; i < Waypoints.size(); ++i)
		{
			wp_list.push_back(Waypoints[i]);
		}
		return;
	}

	std::list<wp_distance> distances;
	for(int i = 0; i < Waypoints.size(); ++i)
	{
		float cur_x = (Waypoints[i].x - m_x);
		cur_x *= cur_x;
		float cur_y = (Waypoints[i].y - m_y);
		cur_y *= cur_y;
		float cur_z = (Waypoints[i].z - m_z);
		cur_z *= cur_z;
		float cur_dist = cur_x + cur_y + cur_z;
		wp_distance w_dist;
		w_dist.dist = cur_dist;
		w_dist.index = i;
		distances.push_back(w_dist);
	}
	distances.sort(wp_distance_pred);

	std::list<wp_distance>::iterator iter = distances.begin();
	for(int i = 0; i < count; ++i)
	{
		wp_list.push_back(Waypoints[(*iter).index]);
		++iter;
	}
}
コード例 #12
0
    void FilterTargets(std::list<WorldObject*>& targets)
    {
        // Shards of torment seems to target tanks if no other targets are available as of Warlords of Draenor
        if (targets.size() <= 1)
        {
            _hasTarget = !targets.empty();
            return;
        }

        Creature* caster = GetCaster()->ToCreature();
        if (!caster || !caster->IsAIEnabled)
            return;

        if (WorldObject* tank = caster->AI()->SelectTarget(SELECT_TARGET_TOPAGGRO))
            targets.remove(tank);

        std::list<WorldObject*> melee, ranged;
        for (WorldObject* target : targets)
        {
            if (caster->IsWithinMeleeRange(target->ToUnit()))
                melee.push_back(target);
            else
                ranged.push_back(target);
        }

        targets.clear();

        if (caster->GetMap()->Is25ManRaid())
            if (WorldObject* target = GetRandomContainerElement(ranged, melee))
                targets.push_back(target);

        if (WorldObject* target = GetRandomContainerElement(melee, ranged))
            targets.push_back(target);

        _hasTarget = !targets.empty();
    }
コード例 #13
0
    void DamageTaken(Unit* /*pDoneBy*/, uint32& uiDamage)
    {
        if (uiDamage > me->GetHealth() || me->HealthBelowPctDamaged(20, uiDamage))
        {
            uiDamage = 0;

            EnterEvadeMode();

            m_uiPhase = PHASE_COMPLETE;
            m_uiEventTimer = 2000;

            if (!lCreatureList.empty())
            {
                uint16 N = -1;

                for (std::list<Creature*>::iterator itr = lCreatureList.begin(); itr != lCreatureList.end(); ++itr)
                {
                    if ((*itr)->IsAlive())
                    {
                        N = N + 1;
                        (*itr)->RestoreFaction();
                        EnterEvadeMode();
                        (*itr)->SetWalk(false);
                        (*itr)->GetMotionMaster()->MovePoint(0, m_afEventMoveTo[N].m_fX,  m_afEventMoveTo[N].m_fY,  m_afEventMoveTo[N].m_fZ);
                        (*itr)->ForcedDespawn(5000);
                    }
                }
            }
            lCreatureList.clear();

            me->ForcedDespawn(60000);
            me->SummonCreature(NPC_TERVOSH, -2876.66f, -3346.96f, 35.6029f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000);
            me->SummonCreature(NPC_JAINA, -2876.95f, -3342.78f, 35.6244f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000);
            me->SummonCreature(NPC_PAINED, -2877.67f, -3338.63f, 35.2548f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 60000);
        }
    }
コード例 #14
0
  /**
   * Return all tile necessary for covering the given boundingbox using the given magnification.
   */
  void DataTileCache::GetTilesForBoundingBox(const Magnification& magnification,
                                              const GeoBox& boundingBox,
                                              std::list<TileRef>& tiles) const
  {
    tiles.clear();

    //log.Debug() << "Creating tile data for level " << level << " and bounding box " << boundingBox.GetDisplayText();

    uint32_t level=magnification.GetLevel();

    uint32_t cx1=(uint32_t)floor((boundingBox.GetMinLon()+180.0)/cellDimension[level].width);
    uint32_t cy1=(uint32_t)floor((boundingBox.GetMinLat()+90.0)/cellDimension[level].height);

    uint32_t cx2=(uint32_t)floor((boundingBox.GetMaxLon()+180.0)/cellDimension[level].width);
    uint32_t cy2=(uint32_t)floor((boundingBox.GetMaxLat()+90.0)/cellDimension[level].height);

    //std::cout << "Tile bounding box: " << cx1 << "," << cy1 << " - "  << cx2 << "," << cy2 << std::endl;

    for (size_t y=cy1; y<=cy2; y++) {
      for (size_t x=cx1; x<=cx2; x++) {
        tiles.push_back(GetTile(TileId(magnification,x,y)));
      }
    }
  }
コード例 #15
0
ファイル: ShareManager.cpp プロジェクト: bmdc-team/bmdc
void ShareManager::updateFilterCache(const std::string& strSetting, const std::string& strExtraPattern, bool escapeDot, std::list<StringMatch>& lst)
{
	lst.clear();

	auto tokens = StringTokenizer<string>(strSetting, ';').getTokens();
	for(auto& pattern: tokens)
	{
		if(pattern.empty())
		{
			continue;
		}

		if(escapeDot)
		{
			Util::replace(".", "\\.", pattern);
		}

		StringMatch matcher;
		matcher.pattern = pattern + strExtraPattern;
		matcher.setMethod(StringMatch::REGEX);
		matcher.prepare();
		lst.push_back(matcher);
	}
}
コード例 #16
0
ファイル: shellcode.cpp プロジェクト: JaonLin/pin-tools
/**
* Callback function that is executed every time an instruction identified as
* potential shellcode is executed.
**/
void dump_shellcode(std::string* instructionString)
{
	if (dumped.find(instructionString) != dumped.end())
	{
		// This check makes sure that an instruction is not dumped twice.
		// For a complete run trace it would make sense to dump an instruction
		// every time it is executed. However, imagine the shellcode has a
		// tight loop that is executed a million times. The resulting log file
		// is much easier to read if every instruction is only dumped once.

		return;
	}

	if (!legitInstructions.empty())
	{
		// If legit instructions have been logged before the shellcode is
		// executed, it is now a good time to dump them to the file. This
		// information then shows when control flow was transferred from
		// legit code to shellcode.

		traceFile << "Executed before" << endl;

		for (std::list<std::string>::iterator Iter = legitInstructions.begin(); Iter != legitInstructions.end(); ++Iter)
		{
			traceFile << *Iter << endl;
		}

		traceFile << endl << "Shellcode:" << endl;

		legitInstructions.clear();
	}

	traceFile << *instructionString << std::endl;

	dumped.insert(instructionString);
}
コード例 #17
0
            void Reset()
            {
                m_pInstance->SendEncounterUnit(ENCOUNTER_FRAME_DISENGAGE, me); // Remove
                DoCast(me, SPELL_NO_REGEN);
                summons.clear();
                me->SetPower(POWER_ENERGY, 0);
                me->SetMaxPower(POWER_ENERGY, 100);
                m_uiWitherTimer = 5000;
                m_uiSeedlingTimer = 10000;
                m_uiRampantTimer = 15000;
                m_uiLife_Drain_Timer = 6000;
                m_uiLife_Drain2_Timer = 10000;
                m_uiLife_Drain3_Timer = 14000;
                m_uiLife_Drain4_Timer = 19000;
                m_uiLife_Drain5_Timer = 25000;
                m_uiSporeTimer   = 7500;

                i = 0;
                for(uint8 p=0; p<10; p++)
                {
                    seedling[p] = NULL;
                    blossom[p] = NULL;
                }
            }
コード例 #18
0
    void JustDied(Unit *victim)
    {
        DoScriptText(SAY_DEATH, me);

        if (pInstance->GetData(TYPE_THRALL_EVENT) == IN_PROGRESS)
        {
            if (Creature* Thrall = me->GetMap()->GetCreature(ThrallGUID))
                Thrall->AI()->DoAction();
            else if (Creature* Thrall = me->FindNearestCreature(17876, 300.0f, true)) 
                Thrall->AI()->DoAction();

            pInstance->SetData(TYPE_THRALL_PART4, DONE);
        }

        if (pInstance->GetData(DATA_EPOCH_DEATH) == DONE)
            me->SetLootRecipient(NULL);
        else
        {
            pInstance->SetData(DATA_EPOCH_DEATH, DONE);
            pInstance->SetData(TYPE_THRALL_PART4, DONE);
        }

        attackers.clear();
    }
コード例 #19
0
ファイル: Schema.cpp プロジェクト: foogywoo/drone
/**
 * perform a topological sort of a cyclic graph
 * return vector of ordered gears
 * 
 * @param orderedGears
 */
void Schema::GearGraphManip::getOrderedGears(std::list<Gear*>& orderedGears)
{
  //reset
  _depthFirstCounter=0;
  for (unsigned int i=0;i<_nodes.size();++i)
  {
    _nodes[i].order=0;
    _nodes[i].visited=false;
  }

  for (unsigned int i=0;i<_nodes.size();++i)
  {
    if (!_nodes[i].visited)
      labelling(_nodes[i]);  
  }
  
  //sort according to order
  std::sort(_nodes.begin(), _nodes.end(), compareNodes);
  
  //fill the ordered gears vector now
  orderedGears.clear();
  for (unsigned int i=0;i<_nodes.size();++i)
    orderedGears.push_back(_nodes[i].gear);
}
コード例 #20
0
/*
 * The list compiled here may be sorted by
 * any criteria to form player ranking tables
 */
void indCrkDB::compilePlayerRecords(const titleRecord              &teamName,
                                    const titleRecord              &oppTeamName,
                                    const dateBeginEnd             &period,
                                    std::list<playerRecordsStruct> &playerRecordsList) const
{
    // clear player records list
    playerRecordsList.clear();

    // compile player names list
    std::vector<nameRecord> uNames;
    compilePlayersList(period, teamName, uNames);

    playerRecordsStruct tempRecordsStruct;
    std::vector<nameRecord>::const_iterator namePtr;
    for (namePtr = uNames.begin(); namePtr != uNames.end(); ++namePtr)
    {
        // initialise tempRecordsStruct
        tempRecordsStruct = playerRecordsStruct();

        compilePlayerRecords(*namePtr, teamName, oppTeamName, period, tempRecordsStruct);

        playerRecordsList.push_back(tempRecordsStruct);
    }
}
コード例 #21
0
ファイル: HGear.cpp プロジェクト: play113/swer
void HGear::SetSegmentsVariables(void(*callbackfunc)(const double *p))const
{
	callbackfunc_for_point = callbackfunc;
	gear_for_point = this;
	gp_Trsf rotation;
	rotation.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), m_angle * M_PI/180);
	mat_for_point = make_matrix(m_pos.Location(), m_pos.XDirection(), m_pos.YDirection());
	mat_for_point = rotation.Multiplied(mat_for_point);
	cone_sin_for_point = sin(m_cone_half_angle);
	cone_cos_for_point = cos(m_cone_half_angle);

	pitch_radius = (double)(m_module * m_num_teeth)/2;
	inside_radius = pitch_radius - m_dedendum_multiplier*m_module;
	outside_radius = pitch_radius + (m_addendum_multiplier*m_module + m_addendum_offset);
	base_radius = pitch_radius * cos(gear_for_point->m_pressure_angle) / cos(gear_for_point->m_cone_half_angle);

	if(inside_radius < base_radius)inside_radius = base_radius;

	inside_phi_and_angle = involute_intersect(inside_radius);
	outside_phi_and_angle = involute_intersect(outside_radius);
	tip_relief_phi_and_angle = involute_intersect(outside_radius - m_tip_relief);
	middle_phi_and_angle = involute_intersect(pitch_radius);
	spline_points_for_gear.clear();
}
コード例 #22
0
ファイル: boss_emalon.cpp プロジェクト: Firearm/TrinityCore
 void FilterTargetsSubsequent(std::list<Unit*>& unitList)
 {
     unitList.clear();
     if (_target)
         unitList.push_back(_target);
 }
コード例 #23
0
ファイル: CatSprite.hpp プロジェクト: bennyk/CatMaze
 void clear() {
     _conns.clear();
     _stop = false;
 }
コード例 #24
0
ファイル: new_combat.hpp プロジェクト: lindianyin/sgbj
 void reset()
 {
     m_actList.clear();
 }
コード例 #25
0
ファイル: clientmap.cpp プロジェクト: 0gb-us/minetest
	void clear()
	{
		lists.clear();
	}
コード例 #26
0
ファイル: main.cpp プロジェクト: KTHHCID/KinectTouch-1
int main(void)
{
  sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL");
  sf::Clock Clock;
  SDL_Surface *w = NULL;
  SDL_Surface *p = NULL;
  SDL_Rect pos;
  std::list<Button*> buttonList;
  int matrixBin[480][640];

  buttonList.push_back(new Button(new coords(320, 350, 100), 30));
  buttonList.push_back(new Button(new coords(350, 380, 100), 30));
  buttonList.push_back(new Button(new coords(380, 410, 100), 30));
  buttonList.push_back(new Button(new coords(410, 440, 100), 30));
  buttonList.push_back(new Button(new coords(440, 470, 100), 30));
  p = SDL_CreateRGBSurface(SDL_HWSURFACE, 1, 1, 32, 0, 0, 0, 0);
  SDL_Init(SDL_INIT_VIDEO);
  w = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);

  device = &freenect.createDevice<MyFreenectDevice>(0);
  device->startDepth();
  device->startVideo();
  // Set color and depth clear value
  glClearDepth(1.f);
  glClearColor(0.f, 0.f, 0.f, 0.f);
  // Enable Z-buffer read and write
  glEnable(GL_DEPTH_TEST);
  glDepthMask(GL_TRUE);
  
  GLuint gl_rgb_tex, gl_rgb_tex2;
  // glGenTextures(1, &gl_rgb_tex);
  glGenTextures(1, &gl_rgb_tex2);
  glBindTexture(GL_TEXTURE_2D, gl_rgb_tex2);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

  // glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  // Setup a perspective projection
  // glBindTexture(GL_TEXTURE_2D, gl_rgb_tex);
  // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  // glMatrixMode(GL_MODELVIEW);
  gluPerspective(90.f, 1.f, 1.f, 2500.f);  App.SetActive();
  device->setVideoFormat((freenect_video_format)0);
  int x, y, z;
  x = -250;
  y = 100;
  z = -270;
  int r = 45;
  bool b = false;
  float rotateY = 0;
  while (App.IsOpened())
    {
      int tmpx = 0, tmpy = 0;
      while (tmpy < 480)
	{
	  tmpx = 0;
	  while (tmpx < 640)
	    {
	      matrixBin[tmpy][tmpx] = 0;
	      matrixDetectOrder[tmpy][tmpx] = 0;
	      ++tmpx;
	    }
	  ++tmpy;
	}
      sf::Event Event;
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      
      glTranslatef(x, y, z);
      // glRotated(180, 1, 0, 0);
      // glBegin(GL_POINTS);
      // glPointSize(1.0);
      kk = 0;
      std::list<Button*>::iterator itBut = buttonList.begin();
      while (App.GetEvent(Event))
	{
	  if (Event.Type == sf::Event::Closed)
	    {
	      device->stopDepth();
	      device->stopVideo();
	      exit(0);
	    }
	  if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
	    {
	      device->stopDepth();
	      device->stopVideo();
	      exit(0);
	    }
	  if ((Event.Type == sf::Event::KeyPressed))
	    {
	      if (Event.Key.Code == sf::Key::Z)
		{
		  --rotateY;
		}
	      if (Event.Key.Code == sf::Key::X)
		{
		  ++rotateY;
		}
	      if ((Event.Key.Code == sf::Key::Up))
		{
		  r += 10;
		  device->setTiltDegrees(r);
		}
	      if ((Event.Key.Code == sf::Key::Down))
		{
		  r -= 10;
		  device->setTiltDegrees(r);
		}
	      if ((Event.Key.Code == sf::Key::W))
		{z+=10;
		}
	      if ((Event.Key.Code == sf::Key::S))
		{z-=10;
		}
	      if ((Event.Key.Code == sf::Key::A))
		{x+=10;
		}
	      if ((Event.Key.Code == sf::Key::D))
		{x-=10;}
	      if ((Event.Key.Code == sf::Key::E))
		{y+=10;}
	      if ((Event.Key.Code == sf::Key::Q))
		{y-=10;}
	    }
	}
      if (b == false && device->m_new_depth_frame && device->m_new_rgb_frame)
      	{
      	  resetView(b);
      	}
      else if (device->m_new_depth_frame || device->m_new_rgb_frame)
	{
	  SDL_FillRect(w, NULL, SDL_MapRGB(w->format, 0, 0, 0));
	  glRotatef(rotateY, 0, 1,0);
	  glRotated(180, 1, 0, 0);
	  int i = 0, j = 0;
	  // LoadRGBMatrix();
	  // LoadVertexMatrix();
	  // LoadVertexMatrix();
	  glBegin(GL_POINTS);
	  int x = 0;
	  int y = 0;
	  glPointSize(1);
	  while (y < (480))
	    {
	      x = 0;
	      while (x < 640)
		{
		  if (rgb != 0)
		    {
		      if (y > 200)
			{
			  if (device->xyzCoords[y][x][2] < 2047
			      && xyzCoords[y][x][2] < 2047)
			    {
			      if(device->xyzCoords[y][x][2] < xyzCoords[y][x][2] - 2
				 && device->xyzCoords[y][x][2] > xyzCoords[y][x][2] - 20
				 && compareRgb(device, x, y))
				{
				  // glColor3f(device->rgb[(y * 640 + x) * 3] / 255.0, 
				  // 	    device->rgb[(y * 640 + x) * 3 + 1] / 255.0,
				  // 	    device->rgb[(y * 640 + x) * 3 + 2] / 255.0);
				  glColor3f(1, 1, 1);
				  SDL_FillRect(p, NULL, SDL_MapRGB(w->format, 255, 255,255));                          
				  pos.x = x;
				  pos.y = y;
				  SDL_BlitSurface(p, NULL, w, &pos);
				  glVertex3f(x, y, device->xyzCoords[y][x][2]);
				}
			      glColor3f(device->rgb[(y * 640 + x) * 3] / 255.0, 
					device->rgb[(y * 640 + x) * 3 + 1] / 255.0,
					device->rgb[(y * 640 + x) * 3 + 2] / 255.0);
			      glVertex3f(x, y, device->xyzCoords[y][x][2]);
			    }
			}
		    }
		  ++x;
		}
	      ++y;
	    }
	  glEnd();
	}
      fingList.clear();
      SDL_Flip(w);
      glFlush();
      App.Display();
    }
  return 0;
}
コード例 #27
0
void fdevent_reset() {
    g_poll_node_map.clear();
    g_pending_list.clear();
}
コード例 #28
0
ファイル: rta_star.cpp プロジェクト: dseredyn/velma_planners
    void RTAStar::plan(const Eigen::VectorXd &q_start, const KDL::Frame &x_goal, std::list<Eigen::VectorXd > &path_q, MarkerPublisher &markers_pub) {
        path_q.clear();
        V_.clear();
        E_.clear();
        setGoal(x_goal);

        std::vector<double > tmp_vec;
        tmp_vec.resize(transform_delta_vec_.size(), 0.0);
        int q_new_idx_ = 0;

        {
            RTAStarState state_start( transform_delta_vec_.size() );
            state_start.h_value_ = 0.0;
            state_start.q_ = q_start;
            state_start.dq_.resize(ndof_);
            state_start.dq_.setZero();
            state_start.parent_idx_ = -1;
//            state_start.T_B_E_ = KDL::Frame(KDL::Vector(q_start(0), q_start(1), q_start(2)));
            kin_model_->calculateFk(state_start.T_B_E_, effector_name_, q_start);
            V_.insert(std::make_pair(0, state_start));
        }

        int current_node_idx = 0;
        while (true) {
            std::map<int, RTAStarState >::iterator v_it = V_.find(current_node_idx);
            if (v_it == V_.end()) {
                std::cout << "ERROR: RTAStar::plan v_it == V_.end() " << current_node_idx << std::endl;
                return;
            }

            if ((v_it->second.T_B_E_.p - x_goal.p).Norm() < 0.08 && v_it->second.q_.innerSize() == ndof_) {
                std::cout << "goal reached" << std::endl;
                while (true) {
                    path_q.push_front(v_it->second.q_);
                    current_node_idx = v_it->second.parent_idx_;
                    if (current_node_idx < 0) {
                        break;
                    }
                    v_it = V_.find(current_node_idx);
                    if (v_it == V_.end()) {
                        std::cout << "ERROR: v_it == V_.end() " << current_node_idx << std::endl;
                    }
                }
                return;
            }

            // From a given current state, the neighbouring states are generated
            for (int tr_idx = 0; tr_idx < transform_delta_vec_.size(); tr_idx++) {
                // the neighbour state was not yet visited from the current node
                if (v_it->second.neighbour_nodes_[tr_idx] == -1) {
                    // create a new state and add it to the graph
                    RTAStarState new_state( transform_delta_vec_.size() );
                    new_state.T_B_E_ = transform_delta_vec_[tr_idx] * v_it->second.T_B_E_;

                    // check if this neighbour state already exists
                    int state_idx = -1;//checkIfStateExists(new_state.T_B_E_);
                    if (state_idx == -1) {
                        // create a new state
                        q_new_idx_++;
                        new_state.h_value_ = getCostH(new_state.T_B_E_);
                        new_state.parent_idx_ = v_it->first;
                        new_state.parent_tr_idx_ = tr_idx;
                        v_it->second.neighbour_nodes_[tr_idx] = q_new_idx_;
                        V_.insert(std::make_pair(q_new_idx_, new_state));

                        markers_pub.addSinglePointMarker(q_new_idx_, new_state.T_B_E_.p, 0, 1, 0, 1, 0.05, "world");
                    }
                    else {
                        // add existing state to neighbour list
                        v_it->second.neighbour_nodes_[tr_idx] = state_idx;
                    }
                }
            }

            // The heuristic function, augmented by lookahead search, is applied to each,
            // and then the cost of the edge to each neighbouring state is added to this value,
            // resulting in an f value for each neighbour of the current state.
            bool validTransitionExists = false;
            for (int tr_idx = 0; tr_idx < transform_delta_vec_.size(); tr_idx++) {
                int neighbour_idx = v_it->second.neighbour_nodes_[tr_idx];
                if (neighbour_idx >= 0) {
                    std::map<int, RTAStarState >::const_iterator n_it = V_.find(neighbour_idx);
                    if (n_it == V_.end()) {
                        std::cout << "ERROR: RTAStar::plan n_it == V_.end() " << neighbour_idx << std::endl;
                        return;
                    }

                    // calculate the lookahead heuristics for each neighbour and add the cost from current state to neighbour
                    double cost_h = lookahead(n_it->second.T_B_E_, 5);
                    tmp_vec[tr_idx] = cost_h + getCostLine(v_it->second.T_B_E_, n_it->second.T_B_E_);
                    std::cout << "    cost_h " << tr_idx << " " << cost_h << std::endl;
                    validTransitionExists = true;
                }
                else {
                    tmp_vec[tr_idx] = 10000.0;
                }
            }

            if (!validTransitionExists) {
                // remove the current node
                std::cout << "   no possible transition " << v_it->first << std::endl;
                std::map<int, RTAStarState >::iterator parent_it = V_.find(v_it->second.parent_idx_);
                if (parent_it == V_.end()) {
                    std::cout << "no parent node" << std::endl;
                    return;
                }

                parent_it->second.neighbour_nodes_[v_it->second.parent_tr_idx_] = -2;

                markers_pub.addSinglePointMarker(v_it->first, v_it->second.T_B_E_.p, 0, 0, 0, 1, 0.05, "world");
                V_.erase(current_node_idx);
                current_node_idx = parent_it->first;
                markers_pub.publish();
                ros::spinOnce();
                continue;
            }

            // The node with the minimum f value is chosen for the new current state and a move to that state
            // is executed. At the same time, the next best f value is stored at the previous current state.

            // get the two smallest values
            double min1 = -1.0, min2 = -1.0;
            int min1_idx = -1;
            for (int tr_idx = 0; tr_idx < transform_delta_vec_.size(); tr_idx++) {
                if (min1 < 0 || min1 > tmp_vec[tr_idx]) {
                    min1 = tmp_vec[tr_idx];
                    min1_idx = tr_idx;
                }
            }

            for (int tr_idx = 0; tr_idx < transform_delta_vec_.size(); tr_idx++) {
                if (tr_idx == min1_idx) {
                    continue;
                }
                if (min2 < 0 || min2 > tmp_vec[tr_idx]) {
                    min2 = tmp_vec[tr_idx];
                }
            }

            std::cout << "current_node_idx " << current_node_idx << "  min: " << min1 << " " << min2 << std::endl;

            // execute the move
            int next_node_idx = v_it->second.neighbour_nodes_[min1_idx];
            if (next_node_idx < 0) {
                std::cout << "ERROR: next_node_idx < 0: " << next_node_idx << std::endl;
                return;
            }
            std::map<int, RTAStarState >::iterator n_it = V_.find(next_node_idx);
//            std::cout << n_it->second.T_B_E_.p[0] << " " << n_it->second.T_B_E_.p[1] << " " << n_it->second.T_B_E_.p[2] << std::endl;
            // check if the next state is possible

            if (!v_it->second.simulated_nodes_[min1_idx]) {
                // simulate
                n_it->second.q_.resize(ndof_);
                n_it->second.dq_.resize(ndof_);
                KDL::Frame nT_B_E;
                std::list<KDL::Frame > path_x;
                std::list<Eigen::VectorXd > path_q;
                KDL::Frame T_B_E(n_it->second.T_B_E_);
                bool col_free = collisionFree(v_it->second.q_, v_it->second.dq_, v_it->second.T_B_E_, n_it->second.T_B_E_, 0, n_it->second.q_, n_it->second.dq_, nT_B_E, &path_x, &path_q);

                int similar_state = checkIfStateExists(n_it->first, n_it->second);
                if (!col_free || similar_state >=0) {
                    n_it->second.h_value_ = 100.0;
                    if (!col_free) {
                        std::cout << "   invalid state change, removing node " << next_node_idx << std::endl;
                    }
                    else {
                        std::cout << "   joining states " << next_node_idx << " to " << similar_state << std::endl;
                    }
                    V_.erase(next_node_idx);
                    v_it->second.neighbour_nodes_[min1_idx] = -2;
                    markers_pub.addSinglePointMarker(n_it->first, n_it->second.T_B_E_.p, 0, 0, 0, 1, 0.05, "world");
                    markers_pub.publish();
                    ros::spinOnce();
                    continue;
                }

                v_it->second.simulated_nodes_[min1_idx] = true;
            }

/*            int similar_state = checkIfStateExists(n_it->first, n_it->second);
            if (similar_state >= 0) {
                // TODO: possible infinite loop!
                // join states
                v_it->second.neighbour_nodes_[min1_idx] = similar_state;
                V_.erase(next_node_idx);
                std::cout << "joining states: " << next_node_idx << " to " << similar_state << std::endl;
                next_node_idx = similar_state;
            }
*/
/*
                if (!col_free) {isPoseValid(n_it->second.T_B_E_)) {
                    n_it->second.h_value_ = 10.0;
                    markers_pub.addSinglePointMarker(n_it->first, n_it->second.T_B_E_.p, 0, 0, 0, 1, 0.05, "world");
                    markers_pub.publish();
                    ros::spinOnce();
                    std::cout << "   invalid pose" << std::endl;
                    continue;
                }
*/
            double min_h = 10000.0;
            int min_idx = -1;
            for (std::map<int, RTAStarState >::const_iterator v2_it = V_.begin(); v2_it != V_.end(); v2_it++) {
                if (v2_it->second.h_value_ < min_h && v2_it->second.q_.innerSize() == ndof_) {
                    min_h = v2_it->second.h_value_;
                    min_idx = v2_it->first;
                }
//                markers_pub.addVectorMarker(v2_it->first+6000, v2_it->second.T_B_E_.p + KDL::Vector(0,0,0.05), v2_it->second.T_B_E_.p + KDL::Vector(0,0,0.05 + v2_it->second.h_value_*0.1), 0, 0.7, 0, 0.5, 0.01, "world");
            }

            next_node_idx = min_idx;

            markers_pub.addSinglePointMarker(v_it->first, v_it->second.T_B_E_.p, 1, 0, 0, 1, 0.05, "world");
            markers_pub.addSinglePointMarker(n_it->first, n_it->second.T_B_E_.p, 0, 0, 1, 1, 0.05, "world");
            markers_pub.publish();
            ros::spinOnce();
//            getchar();

            markers_pub.addSinglePointMarker(v_it->first, v_it->second.T_B_E_.p, 0, 1, 0, 1, 0.05, "world");
            markers_pub.addSinglePointMarker(n_it->first, n_it->second.T_B_E_.p, 0, 1, 0, 1, 0.05, "world");

            // save the second minimum value
            v_it->second.h_value_ = min2;

            std::cout << "changing state to " << next_node_idx << std::endl;
            // go to the next state
            current_node_idx = next_node_idx;
//            getchar();
        }
    }
コード例 #29
0
            void UpdateAI(const uint32 diff)
            {
                if (!UpdateVictim())
                    return;

                if (TreeForm_Timer <= diff)
                {
                    DoScriptText(RAND(SAY_TREE_1,SAY_TREE_2), me);

                    if (me->IsNonMeleeSpellCasted(false))
                        me->InterruptNonMeleeSpells(true);

                    me->RemoveAllAuras();

                    DoCast(me, SPELL_SUMMON_FRAYER, true);
                    DoCast(me, SPELL_TRANQUILITY, true);
                    DoCast(me, SPELL_TREE_FORM, true);

                    me->GetMotionMaster()->MoveIdle();
                    MoveFree = false;

                    TreeForm_Timer = 75000;
                }
                else
                    TreeForm_Timer -= diff;

                if (!MoveFree)
                {
                    if (MoveCheck_Timer <= diff)
                    {
                        if (!Adds_List.empty())
                        {
                            for (std::list<uint64>::iterator itr = Adds_List.begin(); itr != Adds_List.end(); ++itr)
                            {
                                if (Unit *temp = Unit::GetUnit(*me,*itr))
                                {
                                    if (!temp->isAlive())
                                    {
                                        Adds_List.erase(itr);
                                        ++DeadAddsCount;
                                        break;
                                    }
                                }
                            }
                        }

                        if (DeadAddsCount < 3 && TreeForm_Timer-30000 <= diff)
                            DeadAddsCount = 3;

                        if (DeadAddsCount >= 3)
                        {
                            Adds_List.clear();
                            DeadAddsCount = 0;

                            me->InterruptNonMeleeSpells(true);
                            me->RemoveAllAuras();
                            me->GetMotionMaster()->MoveChase(me->getVictim());
                            MoveFree = true;
                        }
                        MoveCheck_Timer = 500;
                    }
                    else
                        MoveCheck_Timer -= diff;

                    return;
                }

                /*if (me->HasAura(SPELL_TREE_FORM,0) || me->HasAura(SPELL_TRANQUILITY,0))
                    return;*/

                //one random seedling every 5 secs, but not in tree form
                if (SummonSeedling_Timer <= diff)
                {
                    DoSummonSeedling();
                    SummonSeedling_Timer = 6000;
                }
                else
                    SummonSeedling_Timer -= diff;

                DoMeleeAttackIfReady();
            }
コード例 #30
0
ファイル: Config.cpp プロジェクト: TurboK234/dolphin
void Shutdown()
{
  s_layers.clear();
  s_callbacks.clear();
}