Clarisse 4.0 SP5b SDK  4.0.0.0.5.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
ModuleShadingLayer Class Reference

defines behavior for ShadingLayer objects, which define rules (based on objects names) to override materials for a batch of objects. More...

Inheritance diagram for ModuleShadingLayer:
ModuleProjectItem ModuleObject OfModule ResourceUser EventObject CoreCustomData CoreBaseObject CoreBaseType

Classes

struct  SlEventInfo
 

Public Types

enum  DataSourcePriority {
  PRIORITY_RULES_FIRST,
  PRIORITY_OBJECTS_FIRST
}
 

Public Member Functions

const CoreStringget_override_info_label (const ShadingLayerOverrideInfo &value)
 
ShadingLayerOverrideInfo get_override_info (const CoreString &label)
 
 ModuleShadingLayer (OfObject &object)
 
void update_rules_type ()
 
void init (const OfObject &object)
 fill module with its OfObject data. Called just after deserialization.
 
void create_scene_object_rules (const ModuleSceneObject &module_scene_object, CoreVector< ShadingLayerRule * > &new_rules, const ShadingLayerRuleCreationMode &creation_mode, const int &insertion_index, CoreSet< CoreString > &uniques_filters)
 Create rules for incoming scene object. will create the rules for all its underlying objects and their respectives shading groups.
 
void create_rules_from_items (const CoreVector< CoreString > &items_pathes, const ShadingLayerRuleCreationMode &creation_mode, const int &insert_row_index=-1)
 fill module with rules created from all incoming objects and their shading rules
 
void fill_object (OfObject &object)
 fill input ShadingLayer OfObject with module data. Called just before serialization.
 
void set_is_dirty ()
 
void build_rules_indexes (CoreHashTable< ShadingLayerRule *, unsigned int > &rules_hash, unsigned int &padding) const
 Build the rules indexes depending on where they appear in the shading layer hierarchy.
 
void get_objects_shading (const CoreBasicArray< ModuleSceneObject * > &objects, SceneShadingTable &shading_table) const
 Build a mapping correspondence between incoming scene objects and their shading links, depending on Shading Layer rules. If a scene object does not have any rule that applies to it, it will be associated to its regular material. If a rule is found for an object without any shading group specification (ex: tree, and not tree:leaf), then the rule related material will be applied for all the object shading groups unless specific rules are found PRIOR to this rule in the Shading Layer tree.
 
bool resolve_objects_shading (const CoreBasicArray< OfObject * > &objects, SceneShadingTable &shading_table)
 Helper function that accepts OfObjects in input. Will not work if any of the input object has not a ModuleSceneObject typed module. Unlike get_objects_shading, will return regular objects materials instead of (-1) if shading layer has no rule that applies. If is_visible is deactivated for some objects, returned materials will be 0.
 
void resolve_objects_shading (const CoreBasicArray< ModuleSceneObject * > &, SceneShadingTable &shading_table)
 Helper function. Unlike get_objects_shading, will return regular objects materials instead of (-1) if shading layer has no rule that applies. If is_visible is deactivated for some objects, returned materials will be 0.
 
int get_first_matching_rule_index (const CoreString &filter) const
 
const CoreVector
< ShadingLayerRule * > & 
get_rules () const
 
void get_rules_recursively (CoreVector< ShadingLayerRule * > &rules)
 
void get_objects_only_rules_recursively (CoreVector< ShadingLayerRule * > &rules, const bool &include_path_rules=true, const bool &include_world_rules=true) const
 
void get_generic_rules_recursively (CoreVector< ShadingLayerRule * > &rules, const bool &include_path_rules=true, const bool &include_world_rules=true) const
 
ShadingLayerRulecheck_static_rule_recursively (const CoreString &key) const
 
void set_rules_object_relative (const CoreVector< ShadingLayerRule * > &rules)
 
ShadingLayerRuleadd_shading_layer_rule (const bool &is_active=true, const CoreString &filter="")
 
void add_shading_layer_rules (const CoreVector< ShadingLayerRule * > &rules)
 
void remove_shading_layer_rule (const unsigned int &index)
 
void remove_shading_layer_rules (const CoreVector< unsigned int > &indexes)
 
void move_shading_layer_rule (const unsigned int &index, const unsigned int &move_to_index)
 
ShadingLayerRuleinsert_shading_layer_rule (const unsigned int &index, const bool &is_active=true, const CoreString &filter="")
 
void clear_shading_layer_rules ()
 
void clear_selected_columns ()
 
bool set_sl_is_active (const unsigned int &index, const bool &value)
 
bool set_sl_filter (const unsigned int &index, const CoreString &filter)
 
void set_rules_value (const CoreVector< unsigned int > &rules_indexes, const CoreString &column_name, const CoreString &value)
 Set rules column value. Script helper for easier access, otherwise template accessors are available for direct API access.
 
void set_rule_value (const unsigned int &rule_index, const CoreString &column_name, const CoreString &value)
 Set rule column value. Script helper for easier access, otherwise template accessors are available for direct API access.
 
void set_rule_state (const unsigned int &rule_index, const CoreString &column_name, const bool &state)
 Set rule column state. Script helper for easier access, otherwise template accessors are available for direct API access. State specifies if the column value is set or not, whatever value is contained in it.
 
CoreString get_rule_value (const unsigned int &rule_index, const CoreString column_name)
 Get rule column state. Script helper for easier access, otherwise template accessors are available for direct API access. this function State specifies if the column value is set or not, whatever value is contained in it.
 
void add_child (const OfObject &child)
 add a new child to shading layer.
 
void remove_child (const OfObject &child)
 
void remove_child (const unsigned int &child_index)
 
unsigned int get_children_count ()
 
const OfObjectget_child (const unsigned int &index) const
 
const CoreVector
< ModuleShadingLayer * > & 
get_children () const
 
const CoreVector
< ModuleShadingLayer * > & 
get_parents () const
 
bool has_world_rules () const
 
bool has_path_rules () const
 
bool is_column_selected (const CoreString &column_name) const
 
const CoreVector< const
ShadingLayerColumnItem * > & 
get_selected_column_items () const
 
const unsigned int get_selected_column_index (const CoreString &column_name) const
 
unsigned int get_selected_column_index (const char *column_name) const
 
bool has_values_for_column (const CoreString &column_name) const
 
void select_column (const CoreString &column)
 Selects a column from the listed columns. If this column was previously selected then removed, its previous values get restored.
 
void unselect_column (const CoreString &column)
 Removes a column from the listed columns. Do not remove the values to restore them automaticaly if the value is set back.
 
const CoreSet< OfContext * > & get_root_contexts () const
 
const CoreVector< CoreString > & get_root_kinematic_paths () const
 

Static Public Member Functions

static const int & rule_invalid_index ()
 
static const int & rule_invisible_index ()
 
static void get_static_column_names (CoreVector< CoreString > &columns)
 
static void init_available_columns (OfApp &app)
 
static CoreVector
< ShadingLayerColumnItem * > & 
get_available_column_items ()
 
static const
ShadingLayerColumnItem
get_available_column_item (const CoreString &name)
 
static unsigned int get_column_value_index (const CoreString &name)
 Returns the index of the column with incoming name. This index can be used to retrieve the column value for a given rule and associated column.
 
static CoreString color_to_string (const GMathVec3d &color)
 
static GMathVec3d string_to_color (const CoreString &str)
 
static void get_matching_objects (const OfApp &app, const CoreString &filter, CoreVector< OfObject * > &output_objects)
 get all objects matching a specific filter. Only scene objects will be returned.
 

Protected Member Functions

void get_group_shading_layer_modules (ModuleGroup *group, CoreVector< ModuleShadingLayer * > &sl_modules)
 
void update_children ()
 
virtual void on_attribute_change (const OfAttr &attr, int &dirtiness, const int &dirtiness_flags)
 
void on_vars_change (OfVars &vars, const CoreString &event, void *data)
 
- Protected Member Functions inherited from ModuleProjectItem
virtual void module_constructor (OfObject &object)
 
- Protected Member Functions inherited from ModuleObject
bool get_builtin_variable_value (const CoreString &var_name, CoreVector< CoreVariant > &value) const
 
bool get_builtin_variable_value_at (const CoreString &var_name, CoreVector< CoreVariant > &value, const double &time) const
 
virtual void module_destructor ()
 
virtual void on_send_event (const CoreString &event)
 
virtual ResourceDatacreate_resource (const int &id, void *data) const
 
virtual void on_resource_update (const int &id, ResourceData *resource)
 
virtual bool on_new_time (const double &time)
 
virtual void * create_eval_data (const CtxEval &eval_ctx) const
 
virtual void destroy_eval_data (const CtxEval &eval_ctx, void *eval_data) const
 
virtual void * create_thread_data (const CtxEval &eval_ctx) const
 
virtual void destroy_thread_data (const CtxEval &eval_ctx, void *thread_data) const
 
virtual bool has_thread_data () const
 
virtual ModuleCmacreate_cma (const CtxEval *eval_ctx) const
 
virtual void destroy_cma (ModuleCma *cma) const
 
const bool pre_evaluate_begin (const CtxEval &eval_ctx) const
 
void pre_evaluate_end (const CtxEval &eval_ctx) const
 
virtual ResourceDataset_resource_data (const int &resource_id, ResourceData *data, const CoreString &key)
 
virtual ResourceDataset_resource_data (const int &resource_id, void *data_serial, const size_t &data_serial_size, const CoreString &key)
 
virtual unsigned int get_project_resource_count () const
 
virtual int get_project_resource_id (const unsigned int &index) const
 
virtual ResourceObject * get_project_resource (const unsigned int &index) const
 
virtual void get_attr_preset_hints (CoreArray< bool > &hints, const OfAttr &attr)
 
template<class T_Callbacks >
T_Callbacks * get_callbacks () const
 
- Protected Member Functions inherited from OfModule
void protect_object (const bool &enable) const
 
virtual void on_deserialize (const CoreVersion &serial_version, const ParserGroup &parser_group, const OfSerialOptions &serial_options)
 

Friends

class ShadingLayerRule
 
class ShadingLayerEvalTask
 
struct ProgressInfo
 

Detailed Description

defines behavior for ShadingLayer objects, which define rules (based on objects names) to override materials for a batch of objects.


Class Documentation

struct ModuleShadingLayer::SlEventInfo
Class Members
CoreString m_column Column affected by the last column modification event.
int m_move_to_index if last event was EVT_ID_SHADING_LAYER_RULE_MOVED, this is where it moved.
int m_rule_index rule affected by last EVT_ID_SHADING_LAYER_NEW_RULE/EVT_ID_SHADING_LAYER_RULE_REMOVED/EVT_ID_SHADING_LAYER_RULE_MODIFIED
CoreVector< unsigned int > m_rules_indexes rules affected by last EVT_ID_SHADING_LAYER_RULES_REMOVED event [ids are ordered from greatest to smallest)

Member Function Documentation

void ModuleShadingLayer::add_child ( const OfObject child)

add a new child to shading layer.

Parameters
[in]childshading layer object
void ModuleShadingLayer::create_rules_from_items ( const CoreVector< CoreString > &  items_pathes,
const ShadingLayerRuleCreationMode &  creation_mode,
const int &  insert_row_index = -1 
)

fill module with rules created from all incoming objects and their shading rules

Parameters
[in]items_pathesitems full names to create rules for
[in]creation_modespecifies if we want to use items full names (with path) for rules or create rules relatives to their name.
[in]insert_row_indexwhere to insert the newly created rules in the shading layer. -1 value for adding rules to the end (default).
void ModuleShadingLayer::create_scene_object_rules ( const ModuleSceneObject module_scene_object,
CoreVector< ShadingLayerRule * > &  new_rules,
const ShadingLayerRuleCreationMode &  creation_mode,
const int &  insertion_index,
CoreSet< CoreString > &  uniques_filters 
)

Create rules for incoming scene object. will create the rules for all its underlying objects and their respectives shading groups.

Parameters
[in]module_scene_objectobject to create rules for
[out]new_rulesrules created by the function
[in]creation_modespecifies what kind of filter we want to create for the new rules: 1- Use Full Names 2- Use Relative Names 3- Use Kinematics 4- Use Shading Groups names
[in]insertion_indexwhere to insert the new rules in shading layer (-1 by default)
[out]uniques_filtersstore unique filters in order to prevent the creation of multiple rules with same filter
void ModuleShadingLayer::get_matching_objects ( const OfApp app,
const CoreString filter,
CoreVector< OfObject * > &  output_objects 
)
static

get all objects matching a specific filter. Only scene objects will be returned.

Parameters
[in]appapplication
[in]filter.Can describe object name and shading group name with the use of wildcards. ex "*box*>Default" will retrieve all objects whose full name contains box and has a shading group named Default.
[out]output_objectsvector filled with objects matching the input filter.
void ModuleShadingLayer::get_objects_shading ( const CoreBasicArray< ModuleSceneObject * > &  objects,
SceneShadingTable shading_table 
) const

Build a mapping correspondence between incoming scene objects and their shading links, depending on Shading Layer rules. If a scene object does not have any rule that applies to it, it will be associated to its regular material. If a rule is found for an object without any shading group specification (ex: tree, and not tree:leaf), then the rule related material will be applied for all the object shading groups unless specific rules are found PRIOR to this rule in the Shading Layer tree.

Parameters
[in]objectsitems we want to know shading links for
[out]shading_tableoutput shading links for each item in the same order, in the following format: [scene_object_index][shading_group_index]
CoreString ModuleShadingLayer::get_rule_value ( const unsigned int &  rule_index,
const CoreString  column_name 
)

Get rule column state. Script helper for easier access, otherwise template accessors are available for direct API access. this function State specifies if the column value is set or not, whatever value is contained in it.

Parameters
[in]rule_indexwhich rule to set state for
[in]column_namewhich column to set state for
[in]state
bool ModuleShadingLayer::resolve_objects_shading ( const CoreBasicArray< OfObject * > &  objects,
SceneShadingTable shading_table 
)

Helper function that accepts OfObjects in input. Will not work if any of the input object has not a ModuleSceneObject typed module. Unlike get_objects_shading, will return regular objects materials instead of (-1) if shading layer has no rule that applies. If is_visible is deactivated for some objects, returned materials will be 0.

Returns
false if at least one object module is not typed ModuleSceneObject.
void ModuleShadingLayer::select_column ( const CoreString column)

Selects a column from the listed columns. If this column was previously selected then removed, its previous values get restored.

Parameters
[in]columncolumn name
void ModuleShadingLayer::set_rule_state ( const unsigned int &  rule_index,
const CoreString column_name,
const bool &  state 
)

Set rule column state. Script helper for easier access, otherwise template accessors are available for direct API access. State specifies if the column value is set or not, whatever value is contained in it.

Parameters
[in]rule_indexwhich rule to set state for
[in]column_namewhich column to set state for
[in]state
void ModuleShadingLayer::set_rule_value ( const unsigned int &  rule_index,
const CoreString column_name,
const CoreString value 
)

Set rule column value. Script helper for easier access, otherwise template accessors are available for direct API access.

Parameters
[in]rule_indexwhich rule to set value for
[in]column_namewhich column to set value for
[in]valueas string. May contain any type supported by ShadingLayer, provided its the right type for the given column.
void ModuleShadingLayer::set_rules_value ( const CoreVector< unsigned int > &  rules_indexes,
const CoreString column_name,
const CoreString value 
)

Set rules column value. Script helper for easier access, otherwise template accessors are available for direct API access.

Parameters
[in]rules_indexrules indexes to set value for
[in]column_namewhich column to set value for
[in]valueas string. May contain any type supported by ShadingLayer, provided its the right type for the given column.
void ModuleShadingLayer::unselect_column ( const CoreString column)

Removes a column from the listed columns. Do not remove the values to restore them automaticaly if the value is set back.

Parameters
[in]columncolumn name