首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Havok -你能在运行时改变对象的颜色吗?

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

Stack Overflow用户
提问于 2018-03-20 01:05:11
回答 1查看 83关注 0票数 0

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

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

谢谢!

附注:我注意到在stackoverflow上关于Havok的问题很少,当我在网上搜索关于Havok的问题时,我似乎找不到任何东西。所有的Havok开发者都去哪里聊天了?他们有论坛还是什么?

EN

回答 1

Stack Overflow用户

发布于 2018-03-20 01:31:14

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

代码语言:javascript
复制
// 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 );
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49368588

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档