簡體   English   中英

Havok-您可以在運行時更改對象的顏色嗎?

[英]Havok - Can you change color of objects during runtime?

對於任何對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和相機設置網格顏色

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM