Jump to content

  • Log In with Google      Sign In   
  • Create Account

lucky6969b

Member Since 06 Apr 2007
Offline Last Active Yesterday, 11:10 PM
-----

Topics I've Started

Please help "error C2504: 'Activity' : base class undefined"

14 June 2013 - 01:51 AM

Object and Goods are abstract.

When I derive a class called TruckArrive from it, the titled error occurs.

Please help

#pragma once

#include <string>
#include "..\NavMeshLoader.h"
#include "..\Pathfinding\Detour\Include\DetourCommon.h"
#include "..\Pathfinding\Recast\Include\Recast.h"
#include "DetourNavMeshQuery.h"
#include "..\Objects\Objects.h"

class Idle;
class Objects;
class Goods;

#ifdef WIN32
#    define snprintf _snprintf
#endif

// Uncomment this to dump all the requests in stdout.
#define DUMP_REQS

// Returns a random number [0..1)
static float frand()
{
//    return ((float)(rand() & 0xffff)/(float)0xffff);
    return (float)rand()/(float)RAND_MAX;
}

inline bool inRange(const float* v1, const float* v2, const float r, const float h)
{
    const float dx = v2[0] - v1[0];
    const float dy = v2[1] - v1[1];
    const float dz = v2[2] - v1[2];
    return (dx*dx + dz*dz) < r*r && fabsf(dy) < h;
}


static int fixupCorridor(dtPolyRef* path, const int npath, const int maxPath,
                         const dtPolyRef* visited, const int nvisited)
{
    int furthestPath = -1;
    int furthestVisited = -1;
    
    // Find furthest common polygon.
    for (int i = npath-1; i >= 0; --i)
    {
        bool found = false;
        for (int j = nvisited-1; j >= 0; --j)
        {
            if (path[i] == visited[j])
            {
                furthestPath = i;
                furthestVisited = j;
                found = true;
            }
        }
        if (found)
            break;
    }

    // If no intersection found just return current path.
    if (furthestPath == -1 || furthestVisited == -1)
        return npath;
    
    // Concatenate paths.    

    // Adjust beginning of the buffer to include the visited.
    const int req = nvisited - furthestVisited;
    const int orig = rcMin(furthestPath+1, npath);
    int size = rcMax(0, npath-orig);
    if (req+size > maxPath)
        size = maxPath-req;
    if (size)
        memmove(path+req, path+orig, size*sizeof(dtPolyRef));
    
    // Store visited
    for (int i = 0; i < req; ++i)
        path[i] = visited[(nvisited-1)-i];                
    
    return req+size;
}


static bool getSteerTarget(dtNavMeshQuery* navQuery, const float* startPos, const float* endPos,
                           const float minTargetDist,
                           const dtPolyRef* path, const int pathSize,
                           float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef,
                           float* outPoints = 0, int* outPointCount = 0)                            
{
    // Find steer target.
    static const int MAX_STEER_POINTS = 3;
    float steerPath[MAX_STEER_POINTS*3];
    unsigned char steerPathFlags[MAX_STEER_POINTS];
    dtPolyRef steerPathPolys[MAX_STEER_POINTS];
    int nsteerPath = 0;
    navQuery->findStraightPath(startPos, endPos, path, pathSize,
                               steerPath, steerPathFlags, steerPathPolys, &nsteerPath, MAX_STEER_POINTS);
    if (!nsteerPath)
        return false;
        
    if (outPoints && outPointCount)
    {
        *outPointCount = nsteerPath;
        for (int i = 0; i < nsteerPath; ++i)
            dtVcopy(&outPoints[i*3], &steerPath[i*3]);
    }

    
    // Find vertex far enough to steer to.
    int ns = 0;
    while (ns < nsteerPath)
    {
        // Stop at Off-Mesh link or when point is further than slop away.
        if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ||
            !inRange(&steerPath[ns*3], startPos, minTargetDist, 1000.0f))
            break;
        ns++;
    }
    // Failed to find good point to steer to.
    if (ns >= nsteerPath)
        return false;
    
    dtVcopy(steerPos, &steerPath[ns*3]);
    steerPos[1] = startPos[1];
    steerPosFlag = steerPathFlags[ns];
    steerPosRef = steerPathPolys[ns];
    
    return true;
}


class Activity
{
public:
    Objects *Actor;
    Goods *Target;
    Activity() : Actor(0), Target(0) { }
    Activity( Objects* actor, Goods* target ) : Actor(actor), Target(target)
    {
        NavMesh::GetNavMeshLoader().loadAll("Data\\all_tiles_navmesh.bin");
        mStep = 0;
    }

    ~Activity()
    {
        dtFreeNavMeshQuery(m_navQuery);
        m_navQuery = NULL;
    }

    void InitNavMesh(const dtNavMesh *navMesh);
    
private:
    void SetNavMesh(const dtNavMesh* navMesh) { m_navMesh = navMesh; }

protected:
    void findPath();


    void ReCalc();
    

public:
    virtual bool OnUpdate(float seconds) = 0;

    void Update(float seconds);
    

    Activity *FindBestActivity(Objects *actor);
    
    std::string ToString();

private:
    // *todo separate these into a module
    dtNavMeshQuery* m_navQuery;

    const dtNavMesh *m_navMesh;

    dtQueryFilter m_filter;

    dtStatus m_pathFindStatus;
    
    

    enum ToolMode
    {
        TOOLMODE_PATHFIND_FOLLOW,
        TOOLMODE_PATHFIND_STRAIGHT,
        TOOLMODE_PATHFIND_SLICED,
        TOOLMODE_RAYCAST,
        TOOLMODE_DISTANCE_TO_WALL,
        TOOLMODE_FIND_POLYS_IN_CIRCLE,
        TOOLMODE_FIND_POLYS_IN_SHAPE,
        TOOLMODE_FIND_LOCAL_NEIGHBOURHOOD,
    };
    
    ToolMode m_toolMode;

    int m_straightPathOptions;
    
    static const int MAX_POLYS = 256;
    static const int MAX_SMOOTH = 2048;
    
    dtPolyRef m_startRef;
    dtPolyRef m_endRef;
    dtPolyRef m_polys[MAX_POLYS];
    dtPolyRef m_parent[MAX_POLYS];
    int m_npolys;
    float m_straightPath[MAX_POLYS*3];
    unsigned char m_straightPathFlags[MAX_POLYS];
    dtPolyRef m_straightPathPolys[MAX_POLYS];
    int m_nstraightPath;
    float m_polyPickExt[3];
    float m_smoothPath[MAX_SMOOTH*3];
    int m_nsmoothPath;
    float m_queryPoly[4*3];

    static const int MAX_RAND_POINTS = 64;
    float m_randPoints[MAX_RAND_POINTS*3];
    int m_nrandPoints;
    bool m_randPointsInCircle;
    
    float m_spos[3];
    float m_epos[3];
    float m_hitPos[3];
    float m_hitNormal[3];
    bool m_hitResult;
    float m_distanceToWall;
    float m_neighbourhoodRadius;
    float m_randomRadius;
    bool m_sposSet;
    bool m_eposSet;

    int m_pathIterNum;
    dtPolyRef m_pathIterPolys[MAX_POLYS];
    int m_pathIterPolyCount;
    float m_prevIterPos[3], m_iterPos[3], m_steerPos[3], m_targetPos[3];
    
    static const int MAX_STEER_POINTS = 10;
    float m_steerPoints[MAX_STEER_POINTS*3];
    int m_steerPointCount;

private:
    class NavMesh
    {
    public:
        static NavMeshLoader& GetNavMeshLoader()
        {
            static NavMeshLoader m_NavMeshLoader;
            return m_NavMeshLoader;
        }



    };
public:
    void SetSrcPos(const D3DXVECTOR3& src);
    
    void SetDestPos(const D3DXVECTOR3& dest);
    
    float* GetPath(int index);
    
private:
    float m_SrcPos[3];
    float m_DestPos[3];

protected:
    // iterating the path
    int mStep;

};

 

Thanks

Jack

 


Letting a probability of an object to appear in the scene...

13 June 2013 - 05:38 AM

If on each frame update, I pick a randomized number, if this number is greater than 100000, then I let the object appear, is it an efficient or good way?

Thanks

Jack


After reinstalling windows 7, the scene becomes black

11 June 2013 - 10:41 PM

Nothing can be seen. The scene turns black after reinstalling windows 7 with re-arranging the drive partitions.

I have Lucid Virtu MVP though if that matters.

Thanks

Jack


How to retrieve a second value of std::map based on indexed key of std::string?

10 June 2013 - 02:17 AM

std::map<std::string, Bone*> key

 

pElbowBone = m_pObject->GetMesh()->GetBone(key["Shoulder"]);

 

Error    1    error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const std::map<_Kty,_Ty>' (or there is no acceptable conversion)    E:\Jacky\Documents\Visual Studio 2010\Projects\PerfectSim\PerfectSim\PerfectSim\Activities\InverseKinematics.cpp    97    1    PerfectSim

 

Thanks

Jack
 


Cohesion problem

10 June 2013 - 01:47 AM

#ifndef _IK_

#define _IK_



#include <d3dx9.h>

#include "..\Objects\Objects.h"



typedef struct D3DXFRAME_DERIVED Bone;

class SkinnedMesh;



class InverseKinematics

{

    

public:

    InverseKinematics (Objects *pSkinnedMesh, const D3DXVECTOR3& targetPos, const D3DXMATRIX& world);



private:

    void SetWorldTarget(const D3DXVECTOR3& targetPos) { m_vWorldTarget = targetPos; }

    void CalculateWorldObjectTransform(const D3DXMATRIX& world) { D3DXMatrixInverse(&m_matWorldObjectTransform, NULL, &world); }



public:



    //void UpdateHeadIK();

    //void UpdateArmIK();



    void ApplyLookAtIK(D3DXVECTOR3 &lookAtTarget, float maxAngle);

    void ApplyArmIK(Bone *pBone, D3DXVECTOR3 &hingeAxis, D3DXVECTOR3 &target);



 

     

private:

    void CalculateObjectSpaceTarget() { D3DXVec3TransformCoord(&m_vObjectTarget, &m_vWorldTarget, &m_matWorldObjectTransform); }



    // world transform of the target

    D3DXVECTOR3 m_vWorldTarget;

    D3DXMATRIX m_matWorldObjectTransform;

    D3DXVECTOR3 m_vObjectTarget;

    Objects *m_pObjects;

    D3DXVECTOR3 m_headForward;



    Bone *m_pHeadBone;

    Bone *m_pLShoulderBone;

    Bone *m_pLElbowBone;

    Bone *m_pLHandBone;



    Bone *m_pRShoulderBone;

    Bone *m_pRElbowBone;

    Bone *m_pRHandBone;



};



#endif

 

There is 1 Arm IK method, while has to apply to both arms, I don't want to repeat the ArmIK method,

However, I also don't want to pass a parameter to ArmIK as a local member attribute.

How would I change that?

Thanks

Jack


PARTNERS