Dynamically adding collision flags and groups

edited January 2015 in Help request
As the topic states, is it possible?

I am trying to create a code to load a editor saved scene, but i am wondering if it would be possible to reload the collision flags and camera groups, since two scenes can have completely different groups and flags.

Thanks in advance.

Comments

  • edited January 2015
    Mmh, I think I need more details than that. :)

    For the collision flags, you can reset them or modify them at will. You don't need to add them manually, if a flag isn't found, it'll be added on the fly.

    If you want to clear all the current flags, you can simply do:
    orxConfig_PushSection(orxPHYSICS_KZ_CONFIG_SECTION);
    orxConfig_SetString(orxPHYSICS_KZ_CONFIG_COLLISION_FLAG_LIST, orxSTRING_EMPTY);
    orxConfig_PopSection();
    

    However if you still have bodies alive somewhere, their collision values will remain as they were, and if you re-add former flags, they might not have the same value as before (it depends on the order they're added).

    As for the groups, you can call orxCamera_AddGroupID()/orxCamera_RemoveGroupID() if you need to make any change at runtime. Does it answer your question or did you think of something different?
  • edited January 2015
    Well, I think I need to give more details, this is a part of a scene exported in the editor.
    [General]
    CollisionFlagList = hero#scenario
    GroupList = background#scenario#default
    ObjectListsNumber = 1
    ObjectList_0 = temple_fountaing_0#grounds_1#grounds_2#grounds_3#grounds_4#grounds_5#grounds_6#grounds_7
    

    My intent is to provide a code that will load scenes, which would mean I would need to reload the collision flags and the camera groups. I believe I can assume the caller will clear his/her former objects and load the new ones after the load scene.

    From the API:
    orxCamera_AddGroupID (orxCAMERA *_pstCamera, orxU32 _u32GroupID, orxBOOL _bAddFirst)

    What would this group ID be? I would assume it is a hash created by the name, but how is this value generated?

    I couldn't find how to add the collision flags.

    Could I just call:
    orxConfig_SetString(orxPHYSICS_KZ_CONFIG_COLLISION_FLAG_LIST, "hero#scenario");

    And reset the physics module? Would that have any side effects?

    Thanks in advance.
  • edited January 2015
    Yes, you're right, it's a hash that you can obtain by calling orxString_GetID().

    Basically, when switching to a new scene, you need to clear all camera group IDs and add the new ones, or, if that's easier, simply delete the old camera and create the new one with the flags already set in config.

    For the collision flags, all you need to do is clean the current list. There's no need to provide a list: every time a query will be made with a collision name that's not known, it'll get added automatically to the list and a value assigned to it.
  • edited January 2015
    Ok, thanks for the reply.

    Just wondering, is there any reason the CollisionFlagList parameter even exists then, if it is automatically created?

    PS: by the way, it is not listed on the wiki.
  • edited January 2015
    Ah, good catch for the wiki.

    The list is optional: one could use it if one needs to get fixed values for the flags themselves (ie. to work with another system that would have fixed values not coming from orx, for example).
    I assume that in most cases it's not going to be used though and can safely be ignored.
  • edited January 2015
    Knolan wrote:
    PS: by the way, it is not listed on the wiki.

    If you get a moment, are you able to wack it in the wiki? Assume it's a setting that exists in a stable release, otherwise it's best to redirect them to the development instructions on bitbucket.
  • edited January 2015
    My user can't log on the wiki, if you give me access I can add it.

    It is on the CreationTemplane.ini of the version 1.5, so I believe it on the stable:
    CollisionFlagList = [String] # ...; NB: Optional: defines all the literals that can be used to define the SelfFlags and CheckMask properties of Body. This list will grow with every new flag encountered at runtime;
    
  • edited January 2015
    Knolan wrote:
    My user can't log on the wiki, if you give me access I can add it.

    Ah yep. The wiki isn't linked to your forum account so you'll need to make an account there. Then you should be right to go. Iarwain might have to approve the account though?
  • edited January 2015
    Yes, as soon as you are registered I'll give you write access.
Sign In or Register to comment.