-
Notifications
You must be signed in to change notification settings - Fork 1
VerseLayer
Instances of VerseLayer
are used for creating new layers at Verse server. Layers can be used for sharing arrays, sparse matrixes, vectores, etc. When other client creates layer in subscribed node, then instance of VerseLayer is automatically created and stored in dictionary node.layers
(key is id of layer).
New VerseLayer can be created using following code:
import vrsent
import verse as vas
session = vrsent.VerseSession(hostname='localhost', service='12345', \
callback_thread=True, username='joe', password='pass')
# Create node that will contain layer
node = vrsent.VerseNode(session, custom_type=100)
# Create layer
layer = vrsent.VerseLayer(node=node, \
parent_layer=None, \
data_type=vrs.VALUE_TYPE_UINT8, \
count=1,
custom_type=128)
while(session.state != 'DISCONNECTED'):
session.callback_update()
time.sleep(1.0/session.fps)
When layer is created, then you can add items to the layer. Item of layer can be only tuple and tuple can contain max 4 values of int/float. You can add item to layer using following code:
layer.items[0] = (1.0, -1.0, 0.0)
Keep in mind that item of layer has to be tuple. When we want to have item only with one scalar value, then we has to use one item tuple:
other_layer.items[0] = (1.0,)
The layer.items
is subclass of dictionary. Assigning value to the item automatically sends value to the Verse server.
When we want to change some existing item layer.items[0] = (0,)
, then we use same code: layer.items[0] = (0,)
.
When we want to "delete" (better term is unset) some item of layer, then we simply remove item from layer using pop()
:
# Add two items to layer
layer.items[0] = (1, 0, 0)
layer.items[1] = (0, 1, 0)
# Remove second item from layer
layer.pop(1)
- https://gist.github.com/jirihnidek/fb3bbb23fbeae3ffbdb5#file-verse_layer_create-py
- This script creates node with layer and add values to this layer
- https://gist.github.com/jirihnidek/fb3bbb23fbeae3ffbdb5#file-verse_layer_inc_01-py
- This script tries to increment values of specific layer
- https://gist.github.com/jirihnidek/fb3bbb23fbeae3ffbdb5#file-verse_layer_inc_02-py
- This script tries to increment values of all layers in nodes with specified combination of custom types