Havok - 您可以在运行时更改对象的颜色吗?

时间:2018-03-19 17:05:11

标签: c++ game-engine game-physics mesh havok

任何对Havok物理引擎有一定经验的人:

有没有办法在运行时更改网格/对象的颜色?我正在使用演示框架,我想要更改动态(velocity > 0)中所有网格/对象(在演示中)的颜色。这是我第一次使用Havok。在我的文档中找不到任何相关内容。

谢谢!

旁注:我注意到关于堆栈溢出的Havok问题很少,当我在线搜索有关Havok的问题时,我似乎找不到任何东西。所有Havok开发者都去哪儿聊天?他们有论坛或什么?

1 个答案:

答案 0 :(得分:3)

使用HVD的解决方案 - Havok Visual Debugger:

// Needed for calling color change macro
#include <common\visualize\hkdebugdisplay.h>

// You'll of course need any other headers for any other physics stuff 
// you're doing in your file

void SetColorForPhysicsDebugger( unsigned int Red, unsigned int Green,
                                 unsigned int Blue, unsigned int Alpha, 
                                 const hkpCollidable* pCollidable )
{
    // Havok takes an unsigned int (32-bit), allowing 8-bits for 
    // each channel (alpha, red, green, and blue, in that
    // order).

    // Because we only need 8-bits from each of the 32-bit ints 
    // passed into this function, we'll mask the first 24-bits.
    Red &= 0x000000FF;
    Green &= 0x000000FF;
    Blue &= 0x000000FF;
    Alpha &= 0x000000FF;

    // Now we pack the four channels into a single int
    const uint32_t color = (Alpha << 24) | (Red << 16) | (Green << 8) | Blue;

    // We use the macro provided by Havok
    HK_SET_OBJECT_COLOR( reinterpret_cast<hkulong>( pCollidable ), color );
}

有关HVD的更多信息:HVD and cameraSetting mesh color