01_user_documentation:05_object:06_references:02_object
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| 01_user_documentation:05_object:06_references:02_object [2025/08/15 14:35] – removed - external edit (Unknown date) 127.0.0.1 | 01_user_documentation:05_object:06_references:02_object [2025/08/15 14:35] (current) – ↷ Page moved from 01_user_documentation:05_object:03_modeling:03_references:02_object to 01_user_documentation:05_object:06_references:02_object gaetan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Object references ====== | ||
| + | |||
| + | Object references enable to load an object from a file, and store it in a resource directory. Such objects can then be used from the xl code as either: | ||
| + | - An instance of that object: i.e. a node with the 3d geometry of the object. | ||
| + | - A resolved graph: i.e. the loaded graph from the object. | ||
| + | |||
| + | ===== ===== | ||
| + | |||
| + | A single object reference can be used several times in the graph. Both as instances and as sub-graph. The reference object is '' | ||
| + | |||
| + | {{: | ||
| + | |||
| + | By default when a file is added to the [[: | ||
| + | Another solution to prevent conflicts would be to rename references. The name does not have to follow the file name. | ||
| + | |||
| + | To access a Reference in rgg you can either create a Node from the Reference (in XL blocks) or create a new object (in java block). E.g. | ||
| + | <code java> | ||
| + | [ Axiom ==> Reference(" | ||
| + | { Reference r = new Reference(" | ||
| + | </ | ||
| + | |||
| + | ==== Instance ==== | ||
| + | |||
| + | When added in the graph, the object '' | ||
| + | |||
| + | {{: | ||
| + | |||
| + | The Reference is actually turned into a graph Node whose instantiation rule is the sub-graph produced by the object. | ||
| + | |||
| + | ==== Resolved graph ==== | ||
| + | |||
| + | It is also possible to resolve the reference and access the sub-graph directly with the '' | ||
| + | |||
| + | <code java> | ||
| + | { Node rootRef = Reference(" | ||
| + | </ | ||
| + | |||
| + | The resolved graph can be inserted in the graph with: | ||
| + | <code java> | ||
| + | protected void init () | ||
| + | [ | ||
| + | {Node r = new Reference(" | ||
| + | Axiom ==> | ||
| + | ] | ||
| + | </ | ||
| + | |||
| + | which produce: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | **Note:** if you modify the graph given by the resolveNode() method, it modify the object behind the Reference. Thus, all new Reference to that object will have the modifications. | ||
