Skip to content

Instantly share code, notes, and snippets.

@lukpazera
Created September 17, 2014 15:48
Show Gist options
  • Save lukpazera/3a2af335e1a966598189 to your computer and use it in GitHub Desktop.
Save lukpazera/3a2af335e1a966598189 to your computer and use it in GitHub Desktop.
How to get current scene interface and read number of mesh items in scene from it.
/*
This snippet demonstrates how to get currently selected scene interface and
obtain number of mesh items in the scene from it.
Generally, selections are managed via selection service and are stored
as packets. So what we are doing is we are getting recent selection
of the cinema type from the selection service which comes as a pointer
to the selection packet. We then use scene packet translation object
to extract scene interface out of the packet we received pointer to from
selection service.
Finally, we use scene service to look up mesh type integer code
and use ItemCount() method on scene interface to get a number of items
of required type - meshes in our case.
*/
CLxUser_SelectionService sel_svc;
CLxUser_SceneService scn_service;
CLxUser_ScenePacketTranslation scene_trans_pkt;
CLxUser_Scene scene;
LXtItemType mesh_type_code;
unsigned int mesh_count = 0;
scene_trans_pkt.autoInit();
if(!scene_trans_pkt.test())
{
// abort here although that shouldn't really happen
}
void *scn_pkt = sel_svc.Recent(LXiSEL_CINEMA);
scene_trans_pkt.Scene(scn_pkt, scene);
scn_service.ItemTypeLookup(LXsITYPE_MESH, &mesh_type_code);
scene.ItemCount(mesh_type_code, &mesh_count);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment