0

To anybody who has some experience with the Havok Physics Engine:

Is there a way to change the color of meshes/objects during runtime? I am working with the demo framework and I want to change the color of all the meshes/objects (in a demo) that are in-motion (velocity > 0). Its my first time using Havok. Can't find anything about it in the documentation I have.

Thanks!

On a sidenote: I have noticed that there are very little questions about Havok on stackoverflow and when I search questions about Havok online I can't seem to find anything. Where do all the Havok devs go to chat? They have a forum or something?

Schytheron
  • 715
  • 8
  • 28
  • They migrated to the [gamedev](https://gamedev.stackexchange.com/). – Smit Ycyken Mar 19 '18 at 17:06
  • @SmitYcyken There are even fewer questions regarding Havok on there. How is it possible that there are so few discussions about Havok on the internet? Its a pretty well known Physics engine. Plenty of peoplpe use it... – Schytheron Mar 19 '18 at 17:10
  • 1
    What about `HK_SET_OBJECT_COLOR`? it was the first link after googling your question [Phantom Triggers](http://brandondgameengines.blogspot.ru/2013/11/phantom-triggersevents-with-havok.html) – Smit Ycyken Mar 19 '18 at 17:16
  • Havok is mostly popular with larger teams that are capable of paying for support. It hasn't been popular among indie and small-time developers that often frequent SO and SE sites. You will find that these sites best cater to open-source software with large communities, and Havok simply isn't that, unfortunately. –  Mar 19 '18 at 17:19

1 Answers1

3

The solution using 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 );
}

For more information about HVD: HVD and camera ,Setting mesh color

Smit Ycyken
  • 1,189
  • 1
  • 11
  • 25
  • I have seen that blog post but that seems to work only for Havok's Visual Debugger and not during actual running demos. I want to be able to set the color while running the actual demo and not the visual debugger of the demo. – Schytheron Mar 19 '18 at 17:55