• Advertisement
Sign in to follow this  

Smoothing out a TimeAStar Path.

This topic is 817 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If the returned timeastar path consists of discrete times like 1,2,3,4

and I want to interpolate it with a catmull-rom spline.

I have to blend the waypoints between time say 1 and 2

while timeastar works best with discrete time and discrete locations.

Is it possible to make the timeastar path continuous by intepolating it

with catmull rom? If I do it like that, I have to make up some

real times like 1.25, 1.50, 1.75 to add between the time of 1 and 2

and the timeastar is no longer discrete in nature.

 

Should I double up the waypoints this way?

I find that there is one problem with this, if 2 waypoints are really close to each other, the effect of smoothing is not prominent?

D3DXVECTOR3& CMyApp::GotoWaypoint(const D3DXVECTOR3& vSrc, const D3DXVECTOR3& vDest, float fSpeed, bool bSmoothPath)
{
    D3DXVECTOR3 vOut;
    if (bSmoothPath) {
        D3DXVECTOR3 p[4];
        p[0] = vSrc;
        p[1] = vSrc;
        p[2] = vDest;
        p[3] = vDest;
        vOut = *D3DXVec3CatmullRom(&vOut, &p[0], &p[1], &p[2], &p[3], fSpeed);
    }
    else {
        vOut = *D3DXVec3Lerp(&vOut, &vSrc, &vDest, fSpeed);
    }
    return vOut;
}

These interpolated waypoints using catmull rom give abrupt turn to the agent

Wp is 4.84535 0 -0.498869
Wp is 4.8462 0 -0.501389
Wp is 4.84722 0 -0.504407
Wp is 4.84823 0 -0.507419
Wp is 4.84925 0 -0.510424
Wp is 4.85026 0 -0.513422
Wp is 4.8511 0 -0.515915
Wp is 4.8521 0 -0.518901
Wp is 4.85294 0 -0.521384
Wp is 4.85394 0 -0.524357
Wp is 4.85494 0 -0.527323
Wp is 4.85577 0 -0.52979
Wp is 4.85677 0 -0.532743
Wp is 4.85776 0 -0.53569
Wp is 4.85859 0 -0.53814
Wp is 4.85974 0 -0.541561
Wp is 4.86073 0 -0.544486
Wp is 4.86155 0 -0.546918
Wp is 4.86253 0 -0.54983
Wp is 4.86351 0 -0.552735
Wp is 4.86433 0 -0.55515
Wp is 4.86546 0 -0.558522
Wp is 4.86643 0 -0.561405
Wp is 4.8674 0 -0.56428
Wp is 4.86901 0 -0.569055
Wp is 4.8703 0 -0.57286
Wp is 4.87126 0 -0.575705
Wp is 4.87237 0 -0.579015
Wp is 4.8738 0 -0.583255
Wp is 4.87475 0 -0.586071
Wp is 4.8757 0 -0.588881
Wp is 4.87664 0 -0.591682
Wp is 4.87758 0 -0.594475
Wp is 4.87852 0 -0.59726
Wp is 4.8793 0 -0.599576
Wp is 4.88024 0 -0.602346
Wp is 4.88117 0 -0.605109
Wp is 4.88194 0 -0.607405
Wp is 4.88287 0 -0.610153
Wp is 4.88379 0 -0.612893
Wp is 4.88456 0 -0.61517
Wp is 4.88548 0 -0.617895
Wp is 4.8864 0 -0.620612
Wp is 4.88731 0 -0.62332
Wp is 4.88807 0 -0.625571
Wp is 4.88913 0 -0.628711
Wp is 4.88988 0 -0.630948
Wp is 4.89078 0 -0.633624
Wp is 4.89168 0 -0.636292
Wp is 4.89243 0 -0.638508
Wp is 4.89333 0 -0.64116
Wp is 4.89422 0 -0.643803
Wp is 4.89496 0 -0.645999
Wp is 4.89584 0 -0.648627
Wp is 4.89673 0 -0.651245
Wp is 4.89746 0 -0.653421
Wp is 4.89834 0 -0.656023
Wp is 4.89965 0 -0.659911
Wp is 4.90037 0 -0.662061
Wp is 4.90124 0 -0.664634
Wp is 4.9021 0 -0.667198

I am using

float x = m_CharInfo[name].vEndPos.x - m_CharInfo[name].vStartPos.x;
float z = m_CharInfo[name].vEndPos.z - m_CharInfo[name].vStartPos.z;
float fNewDir = atan2f(-x, -z);
m_CharObject[name]->SetRot(D3DXVECTOR3(fNewDir, 0.0f, 0.0f));

This is something I would want to try.

http://www.gamasutra.com/view/feature/131505/toward_more_realistic_pathfinding.php

But the thing is if I have to test 8 starting directions from the start, and 8 ending directions it will end up with.

there are on maximum 64 transitions per iteration, which will put the burden over the cooperative pathfinding thread a lot...

 

 

How can I avoid the abrupt turn of agent?

Thanks

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement