Container componentA container to control several OpenGLComponents. Example UsageIn the following example, three components are put into a container and get moved by a SimpleMover and rotated around the Y axis by a SimpleRotator: o1 = SimpleButton(size=(1,1,1)).activate() o2 = SimpleCube(size=(1,1,1)).activate() o3 = ArrowButton(size=(1,1,1)).activate() containercontents = { o1: {"position":(0,1,0)}, o2: {"position":(1,-1,0)}, o3: {"position":(-1,-1,0)}, } Graphline( OBJ1=o1, OBJ2=o2, OBJ3=o3, CONTAINER=Container(contents=containercontents, position=(0,0,-10)), MOVER=SimpleMover(amount=(0.01,0.02,0.03)), ROTATOR=SimpleRotator(amount=(0,0.1,0)), linkages = { ("MOVER", "outbox") : ("CONTAINER","position"), ("ROTATOR", "outbox") : ("CONTAINER","rel_rotation") } ).run() How does it work?The Container component provides the same inboxes for absolute and relative movement as a OpenGLComponent. These are "position", "rotation", "scaling", "rel_position", "rel_rotation", "rel_scaling", their names are self explanatory. When the container receives a tuple in one of those inboxes, it does update its own transform and uses it to translate the movement to its content components. This is done in the method rearangeContents(). Currently only translation and scaling is supported. This means though components change their position with respect to the rotation of the container and their relative position, the components rotation does not change. The contents have to be provided as constructor keyword in form of a nested dictionary of the following form: { component1 : { "position":(x,y,z), "rotation":(x,y,z), "scaling":(x,y,z) }, component2 : { "position":(x,y,z), "rotation":(x,y,z), "scaling":(x,y,z) }, ... } Each of the "position", "rotation" and "scaling" arguments specify the amount relative to the container. They are all optional. As stated earlier, rotation is not supported yet so setting the rotation has no effect. Container components terminate if a producerFinished or shutdownMicroprocess message is received on their "control" inbox. The received message is also forwarded to the "signal" outbox. Upon termination, this component does not unbind itself from the OpenGLDisplay service and does not free any requested resources. Kamaelia.UI.OpenGL.Container.Containerclass Container(Axon.AdaptiveCommsComponent.AdaptiveCommsComponent)Container(...) -> A new Container component. A container to control several OpenGLComponents. Keyword arguments:
Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. __init__(self, **argd)x.__init__(...) initializes x; see x.__class__.__doc__ for signature applyTransforms(self)Use the objects translation/rotation/scaling values to generate a new transformation Matrix if changes have happened. handleMovement(self)Handle movement commands received by corresponding inboxes. FeedbackGot a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording! Please leave you feedback here in reply to the documentation thread in the Kamaelia blog. -- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT |
Kamaelia
is an open source project originated from and guided by BBC
Research. For more information browse the site or get in
contact.
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved.