Wednesday, 11th October, 2006

VT SDK: little trick for BuildingBlock development

Filed under: Virtools, Virtools SDK — dominique @ 05:10

There is a little trick one can find in a sample of the SDK in regards to parameter indices inside BBs. Ever had the case where you were writing a BB and suddenly you wanted to insert i.e a InputParameter? If your code is more complex you maybe just add it at the end to prevent changing all the Input-Parameter queries.

If you use ENUMs instead, you can easily reorder and insert new paramters. For example 

// Input Params
enum
{
    PARAM_CHARACTER = 0,
    PARAM_SKIN,
    PARAM_ANIM,
    PARAM_AMBIENT,
    PARAM_FACE,
    PARAM_CLOTHES,
    PARAM_HAIR,
    PARAM_BRAIN,
    PARAM_STATE
};

// Settings/Local Params
enum
{
    PARAM_CONSIDER_AMBIENT = 0,
    PARAM_CONSIDER_PLAYER
};

[....]

// example usage
CKCharacter* charc = (CKCharacter*) beh->GetInputParameterObject(PARAM_CHARACTER);
(etc  …)

Any reordering is now not braking the code anymore. Inserting now only needs changes in two places: enums and proto-definition.
Very nice idea! Thanks to whoever it had.

Bookmark and Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Technorati
  • Digg
  • Reddit
  • Google Bookmarks
  • YahooMyWeb
  • Live-MSN
  • Facebook

1 Comment »

No comments yet.

RSS feed for comments on this post. | TrackBack URI

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

Bookmark and Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Technorati
  • Digg
  • Reddit
  • Google Bookmarks
  • YahooMyWeb
  • Live-MSN
  • Facebook