anyKode Marilou
ContentsIndexHome
Example
//From [samples/simple/7.0_TraceDisplay] directory

#include "stdafx.h"
#include "Modacpp.h"
#include "conio.h"

#define MODASERVER "localhost"

using namespace ModaCPP;

//--------------------------------------------------
TraceDisplay * ConfigureTraceDisplay(Geom *pGeom)
    {
    TraceDisplay *pRet=NULL;
    if(pGeom)
        {
        pRet=pGeom->CreateTraceDisplay();
        }
    return(pRet);
    }

//--------------------------------------------------
int main(int argc, char* argv[])
{
Connection *pConnection=new Connection(true);

//Try connect to MODA server
if(pConnection->Connect(MODASERVER))
    {
    _cprintf("Connection ok to moda server\r\n");
    //Find the robot
    RobotPHX *pWorld=pConnection->QueryWorld();
    if(pWorld)
        {
        _cprintf("world found\r\n");

        Geom *pSphere=pWorld->QueryGeom("/sphere0");
        ConfigureTraceDisplay(pSphere);

        pSphere=pWorld->QueryGeom("/sphere1");
        ConfigureTraceDisplay(pSphere);

        pSphere=pWorld->QueryGeom("/sphere2");
        TraceDisplay *pTrace=ConfigureTraceDisplay(pSphere);

        Moda::Commons::TraceDisplayOptions opts;
        if(pTrace->GetOptions(&opts))
            {
            opts.SetColorRGBA(255,0,0,255);
            opts.UpdateDelay=100;
            pTrace->SetOptions(&opts);
            }

        while(!_kbhit())
            {
            pWorld->Sleep(500);
            }

        //destroy the path in the simulator
        pTrace->Destroy();
        //delete the C++ object
        delete pTrace;
        }
    else
        {
        _cprintf("robot not found\r\n");
        }
    }
else
    {
    _cprintf("Unable to connect to moda server\r\n");
    }
//Disconnect & delete
pConnection->Disconnect();
delete pConnection;
return 0;
}
Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.