통합 단계 1e: Visual Debugger로 데이터 전송

Navigation Lab의 연결을 허용하도록 게임을 설정한 경우 사용자 고유의 데이터, 모양 및 볼륨을 Navigation Lab으로 전송할 수 있습니다. Navigation Lab에는 Gameware Navigation의 기본 클래스에서 전송한 디버깅 데이터와 같은 데이터가 표시됩니다. 다른 모든 데이터와 마찬가지로 이러한 데이터를 기록하고, 클립에 저장하고, 재생할 수 있습니다.

다음을 사용하여 디버깅 데이터를 보낼 수 있습니다.

다음 코드 예제에서는 위 세 가지 방법을 모두 보여 줍니다.

참고:

이러한 권장 사항을 건너뛰어도 오류가 발생하지는 않지만 실제로 Navigation Lab으로 전송되지 않을 내부 오브젝트 만들기와 관련된 계산이 낭비됩니다.

[Tutorial_FirstIntegration.cpp의 코드]

#include "gwnavruntime/visualsystem/displaylist.h"
...

void MyGameWorld::TestVisualDebugger()
{
// Visual debugging is disabled in Shipping builds. Even though the symbols and functions are available, they do nothing.
// Guarding this code is not necessary, but is recommended in order to prevent useless computations.
#ifndef KY_BUILD_SHIPPING 
    Kaim::VisualDebugServer* visualDebugServer = m_world->GetVisualDebugServer();

    // always check the state of the VisualDebugServer
    // to avoid costly construction of messages for nothing
    if (visualDebugServer->IsConnected() == false)
        return;

    const char* myCategoryName = "MyGame";

    // Sends a message to the Log window of the Navigation Lab
    static KyUInt32 framecount = 0;
    KY_LOG_MESSAGE(("FrameCount: %d", framecount));
    framecount++;

    // Sends a single data value
    KyUInt32 someKindOfInformation = 1256;
    visualDebugServer->SendUInt32("SomeKindOfInformation", someKindOfInformation, myCategoryName);

    // Sends current, average, max, and min stats computed by the game
    const char* someKindOfStat = "SomeKindOfStat";
    KyFloat32   currentValue   = 2.56f;
    KyFloat32   averageValue   = 2.56f;
    KyFloat32   maxValue       = 3.026f;
    KyFloat32   minValue       = 0.21f;
    visualDebugServer->SendStats(someKindOfStat, currentValue, averageValue, maxValue, minValue, myCategoryName);

    // Visual information is sent using a display list
    Kaim::Vec3f boxLowerCornerPosition = Kaim::Vec3f(-5.0f, -5.0f, 0.0f);
    Kaim::Vec3f boxExtents             = Kaim::Vec3f(3.0f, 2.0f, 1.0f);
    Kaim::Vec3f positionA              = Kaim::Vec3f(0.0f, 2.0f, 0.0f);
    Kaim::Vec3f positionB              = Kaim::Vec3f(10.0f, 10.0f, 0.0f);
    KyFloat32   radius                 = 0.4f;
    KyFloat32   height                 = 2.0f;

    // The Gameware Navigation coordinate system is Z-up, right-handed,
    // in meters. Always convert positions, vectors and sizes from the coordinate
    // system you use in your game. You can set up a Kaim::CoordSystem object, and use
    // its methods to do the conversions for you, as shown below.
    boxLowerCornerPosition = m_coordSystem.ClientToNavigation_Pos( boxLowerCornerPosition );
    boxExtents             = m_coordSystem.ClientToNavigation_Pos( boxExtents );
    positionA              = m_coordSystem.ClientToNavigation_Pos( positionA );
    positionB              = m_coordSystem.ClientToNavigation_Pos( positionB );
    radius                 = m_coordSystem.ClientToNavigation_Dist( radius );
    height                 = m_coordSystem.ClientToNavigation_Dist( height );
    
    {
        // Create a display list and send a line
        Kaim::ScopedDisplayList displayList(m_world, Kaim::DisplayList_Enable);
        displayList.InitSingleFrameLifespan("Simple Display List", myCategoryName);
        displayList.PushLine(positionB, positionB + Kaim::Vec3f::UnitZ(), Kaim::VisualColor::White);
        // The ScopedDisplayList is automatically sent to the Navigation Lab
        // when it goes out of scope.
    }

    {
        // Create a second display list and send more shapes
        Kaim::ScopedDisplayList displayList(m_world, Kaim::DisplayList_Enable);
        displayList.InitSingleFrameLifespan("Complex Display List", myCategoryName);

        Kaim::VisualShapeColor shapeColor;
        shapeColor.m_triangleColor = Kaim::VisualColor(255, 255, 0);
        shapeColor.m_lineColor     = Kaim::VisualColor(175, 175, 0);

        displayList.PushVerticalCylinder( positionA, radius, height, 10, shapeColor);
        displayList.PushLine( positionA, positionB, Kaim::VisualColor::Red);

        shapeColor.m_triangleColor = Kaim::VisualColor(0, 255, 0, 128);
        shapeColor.m_lineColor     = Kaim::VisualColor(0, 128, 0, 255);

        Kaim::Box3f someBox(boxLowerCornerPosition, boxLowerCornerPosition + boxExtents);
        displayList.PushBox(someBox, shapeColor);

        displayList.PushText( positionB + Kaim::Vec3f::UnitZ(), Kaim::VisualColor(0, 255, 255), "Some text");
        // Again, the ScopedDisplayList is automatically sent to the Navigation Lab
        // when it goes out of scope.
    }
#endif
}

Navigation Lab을 게임에 연결하면 이제 다음이 표시됩니다.