[ODE] how can i use dGeomSetCollideBits()?

David Walters hidden.asbestos at googlemail.com
Tue Nov 21 15:47:21 MST 2006


> i do not know how to set the
> CollideBits, should i write as this:
> dGeomSetCollideBits(geo1,00000...0000000)?

You're nearly right, however you can't express the bits of the mask in
binary - C/C++ does not support this format, instead I would recommend
you pack the bits into a hexadecimal value. I'm sure there a some very
good guides you could find using google to help with converting binary
to hexadecimal.

Alternatively, and probably simpler to read, would be to use the
left-shift operator '<<' to adjust a single bit and generate the right
value for your mask.

e.g. bit 5 is set by: dGeomSetCollideBits( geo1, ( 1 << 5 ) );
bit 7 is set by writing dGeomSetCollideBits( geo1, ( 1 << 7 ) );
bit 0 is set by writing ( 1 << 0 ), and so on up to ( 1 << 31 ).

In addition, use the bitwise 'or' operator to combine flags:
e.g. dGeomSetCollideBits( geo1, ( 1 << 5 ) | ( 1 << 7 ) |  ( 1 << 0 ) );

I hope this helps,
Regards,
David


More information about the ODE mailing list