# I'm a Render Engine developer, how can I support Skatter?

Scattered instances are stored in an hash/array structure which can be read by render engines (or anyone for that matter). This is very similar to parsing the model and reading the transformation of regular Component Instances. \
This allows users to render hundreds of thousands of instances without overloading Sketchup.

The hash is in a shared namespace called **`Common`**, and its name is **`render_instances`**.

It is structured like so:

```
{ 
	Sketchup.active_model.definitions.entityID => { 
		plugin_name => {
			comp_def => [
				{:transformation => trans1, :material => mat1},
				{:transformation => trans2, :material => mat2},
				...
			]
		}
	}
}
```

* ***Sketchup.active\_model.definitions.entityID***  is used to differentiate models on OSX, as we can have multiple models opened in one Sketchup instance
  * ***plugin\_name***  is the plugin's name, in this case "skatter". This level is necessary so we don't overwrite each other's data
  * ***comp\_def***  is the [Sketchup::ComponentDefinition](http://ruby.sketchup.com/Sketchup/ComponentDefinition.html) of the scattered object. Each item of this array is an individual instance generated by Skatter.
    * ***:transformation*** is a [Geom::Transformation](http://ruby.sketchup.com/Geom/Transformation.html) that represents the instance's transform
    * ***:material*** is a [Sketchup::Material](http://ruby.sketchup.com/Sketchup/Material.html) assigned to the instance. If this is not defined or nil, simply consider this instance as having the default material applied to it, just like a regular Component Instance.

Reading this in Ruby is pretty simple:

```
modelID = Sketchup.active_model.definitions.entityID

if defined?(Common.render_instances) && Common.render_instances[modelID]
	for plugin_name, definitions in Common.render_instances[modelID]
		for definition, instances in definitions 
			for instance in instances
				
				transform = instance [:transformation]
				material = instance [:material]
				
				# Then do your stuff using definition, transform and material...
			
			end#for
		end#for
	end#for
end#if
```

Additionally, you can add an observer to the Common module, and Skatter will call it every time it updates. It is useful if you are doing Real Time rendering.

```
class MyObserver
	def on_render_instances_updated(model_id, plugin_name, definition)
	
		puts model_id.to_s + " -> " + plugin_name + " -> " + definition.name
		
		data = Common.render_instances[model_id][plugin_name][definition]
	
	  # Then do your stuff...
	
	end
end

Common.add_observer(MyObserver.new)
```

If you have any question or need a NFR license to test your implementation with Skatter, contact us at  <skatter@lindale.io>.

{% hint style="info" %}
This is an open protocol, so if other plugins use it, you will automatically support them as well.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://skatter.help.lindale.io/faq/im-a-render-engine-developer-how-can-i-support-skatter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
