Clarisse 5.0 SP8 SDK  5.0.5.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Protected Attributes | List of all members
GeometrySceneInfo Class Reference

Adds pivot information and object instancing to GeometryBundles. More...

Inheritance diagram for GeometrySceneInfo:
GeometryObjectBundle ResourceData EventObject CoreCustomData CoreBaseObject CoreBaseType

Public Types

enum  ShadingGroupMode {
  SHADING_GROUP_USE_ITEM_NAME = 0,
  SHADING_GROUP_USE_KINEMATIC_PATH = 1
}
 

Public Member Functions

 GeometrySceneInfo (ResourceBundleManager *resource_bundle_manager)
 
 GeometrySceneInfo (const GeometrySceneInfo &src)
 
void clear ()
 
void copy_from (const GeometrySceneInfo &source)
 
bool is_merge_shading_groups () const
 Return true if the bundle generates a shading group name for each shading group of each geometry it contains.
Return false if the bundle generates a shading group name for each shading group of each instance it contains.
 
void set_merge_shading_groups (const bool &merge)
 Tells the bundle to merge the shading groups of duplicated geometries If set to true, the bundle will generate a shading group name for each shading group of each geometry it contains. If set to false, the bundle will generatee a shading group name for each shading group of each instance it contains.
 
virtual void init (const unsigned int &geo_count, const unsigned int &item_count, const int &animation_mode, const int &visibility_mode)
 Initialize the Bundle arrays and options.
 
void set_geometry (ResourceBundleItem *geo_resource, const CoreString &name, const int &animation_type, const bool &has_subdiv, const unsigned int &index)
 Sets a geometry in the bundle.
 
void set_item (const unsigned int &index, const unsigned int &geometry_index, const GMathMatrix4x4d &matrix, const CoreString &item_name, const CoreString &kinematic_path, const bool &visibility=true)
 Defines an instance in the bundle.
 
void update_matrix (const unsigned int &index, const GMathMatrix4x4d &matrix)
 Updates the matrix for an instance of the bundle.
 
virtual void build_shading_groups ()
 Generates all structures which will be used to build shading group names.
 
virtual void build_shading_group_names (CoreVector< CoreString > &shading_group_names, const ShadingGroupMode &shading_group_mode=SHADING_GROUP_USE_ITEM_NAME) const
 Generates the list of shading groups that will be available.
 
const CoreArray< bool > & get_visibilities () const
 Return the list of object visibilities.
 
virtual GMathBbox3d get_shading_group_bbox (const unsigned int &id) const
 Returns the bounding box of a shading group.
 
const CoreArray< unsigned int > & get_geometry_indices () const
 Return the indices of the geometies used by the instances.
 
const CoreArray< unsigned int > & get_instance_indices () const
 Return the indices of the first instance referencing the geometries.
 
const CoreArray
< GMathMatrix4x4d > & 
get_matrices () const
 Returns all matrices of all instances of the bundle.
 
const CoreArray
< GMathMatrix4x4d > & 
get_inv_matrices () const
 Returns all inverted matrices.
 
const CoreArray< double > & get_matrix_determinants () const
 Returns all matrix determinants.
 
const unsigned int & get_shading_group_offset (unsigned int index) const
 Returns the shading group offset for an instance.
 
const CoreVector< unsigned int > & get_shading_group_offsets () const
 Returns the shading group offsets array.
 
void build_bounding_boxes ()
 Builds the bounding boxes of all the shading groups.
 
const int & get_geometry_anim_type (const unsigned int &geo_index) const
 Returns the animation type of the specified geometry.
 
void set_visibility (const unsigned int &index, const bool &visibility)
 Set the visibility of a geometry at a given index.
 
const unsigned int & get_items_count () const
 Returns the number of instances in the bundle.
 
const int & get_animation_mode () const
 Returns how the bundle is animated. Returns 0 if the bundle is static. Returns 1 if at least one matrix is animated Returns 2 if at least one geometry is animated / deformed.
 
const bool & is_geometry_subdiv (unsigned int index) const
 Returns whether the specified geometry has subdivision enabled or not.
 
unsigned int get_item_count () const
 Get the number of items (aka instances) in this bundle.
 
const CoreStringget_item_name (const unsigned int &index) const
 Get an item's name.
 
const CoreStringget_kinematic_path (const unsigned int &index) const
 Get an item's full kinematic path.
 
const CoreStringget_geometry_name (unsigned int index) const
 Returns the name of the geometry at the given index.
 
const GMathMatrix4x4d & get_shading_group_matrix (const unsigned int &id) const
 
const GMathMatrix4x4d & get_shading_group_inverse_matrix (const unsigned int &id) const
 
const double & get_shading_group_matrix_determinant (const unsigned int &id) const
 
virtual void get_matrices_at (const double &time, GMathMatrix4x4d *matrices) const
 Evaluate matrices for all instances at the time specified.
 
size_t get_memory_size () const override
 Get the amount of memory occupied by the resource.
 
- Public Member Functions inherited from GeometryObjectBundle
 GeometryObjectBundle (ResourceBundleManager *resource_bundle_manager)
 
void clear ()
 Resets the bundle and release all geometries that it contains.
 
void copy_from (const GeometryObjectBundle &source)
 
void init_arrays (const unsigned int &geo_count)
 Creates the data arrays that will be needed to store all geometries.
 
void set_geometry (ResourceBundleItem *geo_resource, const unsigned int &index)
 Sets a geometry in a slot.
 
const CoreArray
< GeometryObject * > & 
get_geometries () const
 Accessor to geometries stored in the bundle.
 
const CoreStringget_geometry_hash_key (const unsigned int &index) const
 Return the hash_key of the i-th GeometryObject.
 
virtual unsigned int get_primitive_count () const
 Return the total number of primitives that are stored in the bundle.
 
virtual unsigned int get_geometry_count () const
 Return the number of geometries that are stored in the bundle.
 
virtual unsigned int get_uv_map_count () const
 Return the number of UV maps defined in the bundle.
 
- Public Member Functions inherited from ResourceData
 ResourceData (const ResourceData &other)
 
ResourceImportDataget_import_data () const
 
void set_import_data (ResourceImportData *data)
 
virtual Core128BitHashKey get_hash_key () const
 Get the hash key of the resource.
 
virtual bool is_serializable () const
 Tell if the resource can be serialized or not.
 
virtual void * serialize (size_t &serial_size) const
 Serialize the resource data.
 
virtual bool deserialize (void *serial, const size_t &serial_size)
 Deserialize the resource data.
 
void advert_memory_changed () const
 Adverts that the memory usage of the resource has changed.
 
bool is_protected () const
 
- Public Member Functions inherited from EventObject
 EventObject ()
 Constructor.
 
 EventObject (const EventObject &src)
 Copy Constructor.
 
virtual ~EventObject () override
 Destructor.
 
void connect (EventObject &sender, const CoreString &event_id, EventInfoMethod event_cb, void *data=0)
 Connects this to an object to listen to a specific event.
 
void connect (EventObject &sender, EventInfoMethod event_cb, void *data=0)
 Connects this to an object to listen any of its events.
 
bool disconnect (EventObject &sender, const CoreString &event_id, EventInfoMethod event_cb, void *data=0)
 
bool disconnect_all (EventObject &sender)
 Disconnects from all objects sender was listening on.
 
void disconnect_all ()
 Disconnects from all objects we were listening on.
 
void remove_all_connection ()
 Disconnects object from other objects it is listening to, and also disconnects all objects listening to it.
 
void raise_event (const CoreString &event_id) const
 sends an event
 
void raise_event (const EventInfo &event_info) const
 sends an event
 
bool is_connected (EventObject &sender, const CoreString &event_id, void *data)
 
void set_mute (const bool &mute)
 Asks for object muting. This will increase or decrease the muting counter. Unmuting may not be immediat since it will happen only when counter reaches 0.
 
bool is_mute () const
 Returns if object is muted.
 
CoreArray< EventObject * > get_senders () const
 
unsigned int get_sender_count () const
 
unsigned int get_receiver_count () const
 
void connect (EventObject &sender, const CoreString &event_id, EventMethod event_cb, void *data=0)
 Connects this to an object to listen to a specific event.
 
void connect (EventObject &sender, EventMethod event_cb, void *data=0)
 Connects this to an object to listen any of its events.
 
bool disconnect (EventObject &sender, const CoreString &event_id, EventMethod event_cb, void *data=0)
 Disconnects this from an object for a specific event.
 
- Public Member Functions inherited from CoreCustomData
 CoreCustomData (const CoreCustomData &src)
 
void add_custom_data (void *key, const bool &data)
 
void add_custom_data (void *key, const int &data)
 
void add_custom_data (void *key, const unsigned int &data)
 
void add_custom_data (void *key, const char *data)
 
void add_custom_data (void *key, const CoreString &data)
 
void add_custom_data (void *key, const double &data)
 
void add_custom_data (void *key, void *data)
 
void remove_custom_data (void *key)
 
void remove_all_custom_data ()
 
void set_custom_data (void *key, const bool &data)
 
void set_custom_data (void *key, const int &data)
 
void set_custom_data (void *key, const unsigned int &data)
 
void set_custom_data (void *key, const double &data)
 
void set_custom_data (void *key, const char *data)
 
void set_custom_data (void *key, const CoreString &data)
 
void set_custom_data (void *key, void *data)
 
void get_custom_data (void *key, bool &data) const
 
void get_custom_data (void *key, int &data) const
 
void get_custom_data (void *key, unsigned int &data) const
 
void get_custom_data (void *key, double &data) const
 
void get_custom_data (void *key, CoreString &data) const
 
void get_custom_data (void *key, void *&data) const
 
- Public Member Functions inherited from CoreBaseObject
bool is_kindof (const CoreBaseObject &object) const
 
CoreString get_class_info_name () const
 
const unsigned long & get_class_info_id () const
 
virtual bool is_kindof (const CoreClassInfo &cinfo) const
 
virtual const CoreClassInfoget_class_info () const
 
template<class T >
T * cast ()
 
template<class T >
const T * cast () const
 
- Public Member Functions inherited from CoreBaseType
bool is_kindof (const CoreClassInfo &cinfo) const
 

Protected Attributes

CoreVector< CoreStringm_geometry_names
 names to the geometries
 
CoreArray< int > m_animation_type
 list of animation flags
 
CoreArray< bool > m_has_subdivision
 list of subdivision flags
 
CoreArray< unsigned int > m_geometry_indices
 list of indices pointing to unique geometries. One pointer per instance.
 
CoreArray< unsigned int > m_instance_indices
 list of indices pointing to the first instances referencing geometries. One pointer per geometry. Can be CORE_INVALID_INDEX if a geometry is never used.
 
CoreArray< GMathMatrix4x4d > m_matrix_list
 list of matrices. One matrix per instance.
 
CoreArray< GMathMatrix4x4d > m_inv_matrix_list
 list of inverted matrices. One matrix per instance.
 
CoreArray< double > m_matrix_det_list
 list of matrix determinants. One determinant per instance.
 
CoreArray< CoreStringm_item_name
 names of the items. One value per instance.
 
CoreArray< CoreStringm_kinematic_path
 kinematic paths of the items. One value per instance.
 
CoreArray< bool > m_visibilities
 list of visibility flags, it must be set only if the SceneItem visibility mode is set to "Use Property"
 
CoreVector< unsigned int > m_shading_group_item_index
 geometry indices for each shading group
 
CoreVector< unsigned int > m_shading_group_offsets
 list of shading group offsets. One index per geometry.
 
CoreArray< GMathBbox3d > m_shading_group_bbox
 store the shading group bbox of each shading group
 
bool m_merge_shading_groups
 How shading group names are generated: per geometry or per instance.
 
int m_animation_mode
 how the file is animated: 0 = still, 1 = anim only, 2 = at least one deform
 
- Protected Attributes inherited from GeometryObjectBundle
ResourceBundleManagerm_resource_bundle_manager
 the lite resource manager
 
CoreArray< ResourceBundleItem * > m_resources_list
 list of resources, one per geometry
 
CoreArray< GeometryObject * > m_geometry_list
 list of unique (deduplicated) geometries
 
unsigned int m_primitive_count
 
unsigned int m_uv_map_count
 

Additional Inherited Members

- Static Public Member Functions inherited from EventObject
static void connect (EventObject &sender, const CoreString &event_id, EventObject &receiver, EventInfoMethod event_cb, void *data=0)
 Static version of the above function.
 
static void connect (EventObject &sender, EventObject &receiver, EventInfoMethod event_cb, void *data=0)
 Static version of the above function.
 
static void connect (EventObject &sender, const CoreString &event_id, EventInfoFunction event_cb, void *data=0)
 Connects to an object to listen to a specific event.
 
static void connect (EventObject &sender, EventInfoFunction event_cb, void *data=0)
 Connects to an object to listen any of its events.
 
static bool disconnect (EventObject &sender, const CoreString &event_id, EventInfoFunction event_cb, void *data=0)
 
static void raise_event (EventObject &sender, const CoreString &event_id)
 Sends an event.
 
static void raise_event (EventObject &sender, const EventInfo &event_info)
 Sends an event.
 
static void connect (EventObject &sender, const CoreString &event_id, EventFunction event_cb, void *data=0)
 Connects to an object to listen to a specific event.
 
static void connect (EventObject &sender, EventFunction event_cb, void *data=0)
 Connects to an object to listen any of its events.
 
static void connect (EventObject &sender, const CoreString &event_id, EventObject &receiver, EventMethod event_cb, void *data=0)
 Static version of the above function.
 
static void connect (EventObject &sender, EventObject &receiver, EventMethod event_cb, void *data=0)
 Static version of the above function.
 
static bool disconnect (EventObject &sender, const CoreString &event_id, EventFunction event_cb, void *data=0)
 Disconnects this from an object for a specific event.
 

Detailed Description

Adds pivot information and object instancing to GeometryBundles.

This class derives from the GeometryObjectBundle class. It is the class that must be used when creating the RESOURCE_ID_GEOMETRY or RESOURCE_ID_GEOMETRY resources of a GeometryBundle-deriving object.

This class contains, aside from geometry data, pivot information and instancing information. Instances must always be filled, as geometries are not directly accessibles. If a bundle defines one object, it must have one geometry and one instance, pointing on the geometry.

Note
Item and instance both designate the same thing in the documentation/code.
See Also
GeometryObjectBundle

Member Function Documentation

void GeometrySceneInfo::build_shading_group_names ( CoreVector< CoreString > &  shading_group_names,
const ShadingGroupMode &  shading_group_mode = SHADING_GROUP_USE_ITEM_NAME 
) const
virtual

Generates the list of shading groups that will be available.

Parameters
[out]shading_group_namesThe resulting shading groups names.
shading_group_modeSpecifies if shading groups paths are generated according to object names or kinematic paths.
See Also
set_merge_shading_groups
const CoreString& GeometrySceneInfo::get_geometry_name ( unsigned int  index) const
inline

Returns the name of the geometry at the given index.

Note
index must be valid, no check is done.
const CoreString& GeometrySceneInfo::get_item_name ( const unsigned int &  index) const
inline

Get an item's name.

Parameters
indexThe index of the item. Must be valid!
Returns
the name of the item.
const CoreString& GeometrySceneInfo::get_kinematic_path ( const unsigned int &  index) const
inline

Get an item's full kinematic path.

Parameters
indexThe index of the item. Must be valid!
Returns
the kinematic path of the item.
void GeometrySceneInfo::get_matrices_at ( const double &  time,
GMathMatrix4x4d *  matrices 
) const
virtual

Evaluate matrices for all instances at the time specified.

Parameters
timeTime at which matrices needs to be evaluated
matricesArray of matrices that needs to be filled. Must be allocated beforehand
size_t GeometrySceneInfo::get_memory_size ( void  ) const
overridevirtual

Get the amount of memory occupied by the resource.

Returns an estimate in bytes of the data allocated by the object.

Reimplemented from GeometryObjectBundle.

const unsigned int & GeometrySceneInfo::get_shading_group_offset ( unsigned int  index) const

Returns the shading group offset for an instance.

Returns
The shading group offset. This is the index of the first shading group of the specified instance in the shading group names array.
void GeometrySceneInfo::init ( const unsigned int &  geo_count,
const unsigned int &  item_count,
const int &  animation_mode,
const int &  visibility_mode 
)
virtual

Initialize the Bundle arrays and options.

Parameters
geo_countnumber of geometries that will be stored in this bundle
item_countnumber of instances that will be created in this bundle
animation_modeThe animation mode is an hint on how the objects may behave. Values are 0: static, 1: pivot/matrices may change, 2: geometries may change.
visibility_modeThe visibility mode specifies how the visibility of each object is determined. Values are 0: User must specify per object visibility, 1: Visibilities are set in Clarisse (With material linker, shading layer, etc...).
void GeometrySceneInfo::set_geometry ( ResourceBundleItem geo_resource,
const CoreString name,
const int &  animation_type,
const bool &  has_subdiv,
const unsigned int &  index 
)

Sets a geometry in the bundle.

Parameters
geo_resourceResourceItem that contains the geometry.
nameName of the geometry (used in shading group generation)
animation_typeInformation about the geometry animation. Constant/Homogenous/Heterogenous
has_subdivIs subdivision enabled for this geometry ?
indexIndex of the geometry in the bundle
void GeometrySceneInfo::set_item ( const unsigned int &  index,
const unsigned int &  geometry_index,
const GMathMatrix4x4d &  matrix,
const CoreString item_name,
const CoreString kinematic_path,
const bool &  visibility = true 
)

Defines an instance in the bundle.

Parameters
indexIndex of the instance
geometry_indexIndex of the geometry the instances uses.
matrixPivot matrix of the current instance.
item_nameName of the instance. (may be used in shading group generation)
kinematic_pathkinematic path of the instance. ( may be used in shading group generation)
visibilityIs the geometry visible ?
void GeometrySceneInfo::set_merge_shading_groups ( const bool &  merge)
inline

Tells the bundle to merge the shading groups of duplicated geometries If set to true, the bundle will generate a shading group name for each shading group of each geometry it contains. If set to false, the bundle will generatee a shading group name for each shading group of each instance it contains.

Note
Avoid setting this option to true if your bundle contains deformed objects:
material assignement may be broken as geometry deduplication will not preserve shading group names between frames.
void GeometrySceneInfo::update_matrix ( const unsigned int &  index,
const GMathMatrix4x4d &  matrix 
)

Updates the matrix for an instance of the bundle.

Parameters
indexIndex of the instance
matrixMatrix
Note
Use this function if you need to animate objects in bundle