0

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

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

谢谢!

在旁注中:我注意到在 stackoverflow 上几乎没有关于 Havok 的问题,当我在线搜索有关 Havok 的问题时,我似乎找不到任何东西。所有 Havok 开发人员都去哪里聊天?他们有论坛什么的?

4

1 回答 1

3

使用 HVD - Havok 可视化调试器的解决方案:

// 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 和相机设置网格颜色

于 2018-03-19T17:31:13.887 回答