gpt4 book ai didi

c++ - Havok - 你能在运行时改变对象的颜色吗?

转载 作者:行者123 更新时间:2023-11-27 23:47:35 30 4
gpt4 key购买 nike

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

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

谢谢!

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

最佳答案

使用 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 camera , Setting mesh color

关于c++ - Havok - 你能在运行时改变对象的颜色吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49368588/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com