• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TransportPath类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TransportPath的典型用法代码示例。如果您正苦于以下问题:C++ TransportPath类的具体用法?C++ TransportPath怎么用?C++ TransportPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TransportPath类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FillTransporterPathVector

bool FillTransporterPathVector(uint32 PathID, TransportPath & Path)
{
    // Store dbc values into current Path array
    Path.Resize(sTaxiPathNodeStore.GetNumRows());

    uint32 i = 0;
    for (uint32 j = 0; j < sTaxiPathNodeStore.GetNumRows(); ++j)
    {
        auto pathnode = sTaxiPathNodeStore.LookupEntry(j);
        if (pathnode == nullptr)
            continue;

        if (pathnode->path == PathID)
        {
            Path[i].mapid = pathnode->mapid;
            Path[i].x = pathnode->x;
            Path[i].y = pathnode->y;
            Path[i].z = pathnode->z;
            Path[i].actionFlag = pathnode->flags;
            Path[i].delay = pathnode->waittime;
            ++i;
        }
    }

    Path.Resize(i);
    return (i > 0 ? true : false);
}
开发者ID:armm77,项目名称:AscEmu,代码行数:27,代码来源:TransporterHandler.cpp


示例2: FillPathVector

bool FillPathVector(uint32 PathID, TransportPath & Path)
{
    Path.Resize(dbcTaxiPathNode.GetNumRows());
    uint32 i = 0;

    for(uint32 j = 0; j < dbcTaxiPathNode.GetNumRows(); j++)
    {
        DBCTaxiPathNode *pathnode = dbcTaxiPathNode.LookupRow(j);
        if(pathnode->PathId == PathID)
        {
            Path[i].mapid       = pathnode->ContinentID;
            Path[i].x           = pathnode->LocX;
            Path[i].y           = pathnode->LocY;
            Path[i].z           = pathnode->LocZ;
            Path[i].actionFlag  = pathnode->flags;
            Path[i].delay       = pathnode->delay;
            ++i;
        }
    }

    Path.Resize(i);
    return (i > 0 ? true : false);
}
开发者ID:WowDevs,项目名称:Sandshroud,代码行数:23,代码来源:TransporterHandler.cpp


示例3: FillPathVector

bool FillPathVector(uint32 PathID, TransportPath & Path)
{
	Path.Resize(dbcTaxiPathNode.GetNumRows());
	uint32 i = 0;

	for(uint32 j = 0; j < dbcTaxiPathNode.GetNumRows(); j++)
	{
		DBCTaxiPathNode *pathnode = dbcTaxiPathNode.LookupRow(j);
		if(pathnode->path == PathID)
		{
			Path[i].mapid		= pathnode->mapid;
			Path[i].x			= pathnode->x;
			Path[i].y			= pathnode->y;
			Path[i].z			= pathnode->z;
			Path[i].actionFlag	= pathnode->flag;
			Path[i].delay		= pathnode->waittime;
			++i;
		}
	}

	Path.Resize(i);
	return (i > 0 ? true : false);
}
开发者ID:WowDevs,项目名称:sandshroud-1,代码行数:23,代码来源:TransporterHandler.cpp


示例4: GenerateWaypoints

bool Transporter::GenerateWaypoints()
{
    TransportPath path;
    FillPathVector(GetInfo()->MoTransport.TaxiPathId, path);

    if(path.Size() == 0) return false;

    vector<keyFrame> keyFrames;
    int mapChange = 0;
    for (int i = 1; i < (int)path.Size() - 1; i++)
    {
        if (mapChange == 0)
        {
            if ((path[i].mapid == path[i+1].mapid))
            {
                keyFrame k(path[i].x, path[i].y, path[i].z, path[i].mapid, path[i].actionFlag, path[i].delay);
                keyFrames.push_back(k);
            }
            else
            {
                mapChange = 1;
            }
        }
        else
        {
            mapChange--;
        }
    }

    int lastStop = -1;
    int firstStop = -1;

    // first cell is arrived at by teleportation :S
    keyFrames[0].distFromPrev = 0;
    if (keyFrames[0].actionflag == 2)
    {
        lastStop = 0;
    }

    // find the rest of the distances between key points
    for (size_t i = 1; i < keyFrames.size(); i++)
    {
        if ((keyFrames[i-1].actionflag == 1) || (keyFrames[i].mapid != keyFrames[i-1].mapid))
        {
            keyFrames[i].distFromPrev = 0;
        }
        else
        {
            keyFrames[i].distFromPrev =
                sqrt(pow(keyFrames[i].x - keyFrames[i - 1].x, 2) +
                pow(keyFrames[i].y - keyFrames[i - 1].y, 2) +
                pow(keyFrames[i].z - keyFrames[i - 1].z, 2));
        }
        if (keyFrames[i].actionflag == 2)
        {
            if(firstStop<0)
                firstStop=(int)i;

            lastStop = (int)i;
        }
    }

    float tmpDist = 0;
    for (int i = 0; i < (int)keyFrames.size(); i++)
    {
        if( lastStop < 0 || firstStop < 0 ) // IT NEVER STOPS :O
            continue;

        int j = (i + lastStop) % (int)keyFrames.size();

        if (keyFrames[j].actionflag == 2)
            tmpDist = 0;
        else
            tmpDist += keyFrames[j].distFromPrev;
        keyFrames[j].distSinceStop = tmpDist;
    }

    for (int i = int(keyFrames.size()) - 1; i >= 0; i--)
    {
        int j = (i + (firstStop+1)) % (int)keyFrames.size();
        tmpDist += keyFrames[(j + 1) % keyFrames.size()].distFromPrev;
        keyFrames[j].distUntilStop = tmpDist;
        if (keyFrames[j].actionflag == 2)
            tmpDist = 0;
    }

    for (size_t i = 0; i < keyFrames.size(); i++)
    {
        if (keyFrames[i].distSinceStop < (30 * 30 * 0.5))
            keyFrames[i].tFrom = sqrt(2 * keyFrames[i].distSinceStop);
        else
            keyFrames[i].tFrom = ((keyFrames[i].distSinceStop - (30 * 30 * 0.5f)) / 30) + 30;

        if (keyFrames[i].distUntilStop < (30 * 30 * 0.5))
            keyFrames[i].tTo = sqrt(2 * keyFrames[i].distUntilStop);
        else
            keyFrames[i].tTo = ((keyFrames[i].distUntilStop - (30 * 30 * 0.5f)) / 30) + 30;

        keyFrames[i].tFrom *= 1000;
        keyFrames[i].tTo *= 1000;
//.........这里部分代码省略.........
开发者ID:WowDevs,项目名称:Sandshroud,代码行数:101,代码来源:TransporterHandler.cpp


示例5: GenerateWaypoints

bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
{
    TransportPath path;
    sObjectMgr->GetTransportPathNodes(pathid, path);

    if (path.Empty())
        return false;

    std::vector<keyFrame> keyFrames;
    int mapChange = 0;
    mapids.clear();
    for (size_t i = 1; i < path.Size() - 1; ++i)
    {
        if (mapChange == 0)
        {
            if ((path[i].mapid == path[i+1].mapid))
            {
                keyFrame k(path[i].x, path[i].y, path[i].z, path[i].mapid, path[i].actionFlag, path[i].delay);
                keyFrames.push_back(k);
                mapids.insert(k.mapid);
            }
            else
            {
                mapChange = 1;
            }
        }
        else
        {
            --mapChange;
        }
    }

    int lastStop = -1;
    int firstStop = -1;

    // first cell is arrived at by teleportation :S
    keyFrames[0].distFromPrev = 0;
    if (keyFrames[0].actionflag == 2)
    {
        lastStop = 0;
    }

    // find the rest of the distances between key points
    for (size_t i = 1; i < keyFrames.size(); ++i)
    {
        if ((keyFrames[i].actionflag == 1) || (keyFrames[i].mapid != keyFrames[i-1].mapid))
        {
            keyFrames[i].distFromPrev = 0;
        }
        else
        {
            keyFrames[i].distFromPrev =
                sqrt(pow(keyFrames[i].x - keyFrames[i - 1].x, 2) +
                pow(keyFrames[i].y - keyFrames[i - 1].y, 2) +
                pow(keyFrames[i].z - keyFrames[i - 1].z, 2));
        }
        if (keyFrames[i].actionflag == 2)
        {
            // remember first stop frame
            if (firstStop == -1)
                firstStop = i;
            lastStop = i;
        }
    }

    float tmpDist = 0;
    for (size_t i = 0; i < keyFrames.size(); ++i)
    {
        int j = (i + lastStop) % keyFrames.size();
        if (keyFrames[j].actionflag == 2)
            tmpDist = 0;
        else
            tmpDist += keyFrames[j].distFromPrev;
        keyFrames[j].distSinceStop = tmpDist;
    }

    for (int i = int(keyFrames.size()) - 1; i >= 0; i--)
    {
        int j = (i + (firstStop+1)) % keyFrames.size();
        tmpDist += keyFrames[(j + 1) % keyFrames.size()].distFromPrev;
        keyFrames[j].distUntilStop = tmpDist;
        if (keyFrames[j].actionflag == 2)
            tmpDist = 0;
    }

    for (size_t i = 0; i < keyFrames.size(); ++i)
    {
        if (keyFrames[i].distSinceStop < (30 * 30 * 0.5f))
            keyFrames[i].tFrom = sqrt(2 * keyFrames[i].distSinceStop);
        else
            keyFrames[i].tFrom = ((keyFrames[i].distSinceStop - (30 * 30 * 0.5f)) / 30) + 30;

        if (keyFrames[i].distUntilStop < (30 * 30 * 0.5f))
            keyFrames[i].tTo = sqrt(2 * keyFrames[i].distUntilStop);
        else
            keyFrames[i].tTo = ((keyFrames[i].distUntilStop - (30 * 30 * 0.5f)) / 30) + 30;

        keyFrames[i].tFrom *= 1000;
        keyFrames[i].tTo *= 1000;
    }
//.........这里部分代码省略.........
开发者ID:Bootz,项目名称:SF1,代码行数:101,代码来源:Transport.cpp



注:本文中的TransportPath类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Transporter类代码示例发布时间:2022-05-31
下一篇:
C++ TransportMaterialStatus类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap