Forum

#1 2016-10-10 14:56:42

RedSolos
New member

Constraint

Bonjour, Voila je cherche a faire un script pour créer une contrainte entre deux objets, mais sans succès.
Voici où j'en suis et je bloque a  l'ajout de la dependence :

Hello, Here is I try to make a script to create a constraint between two objects, but unsuccessfully.
Here is where I am there and I block in the addition of the dependence

from guerilla import Modifier, Document, Node

mod = Modifier.get
doc = Document()

#Createobject
sn = doc.loadfile('$(LIBRARY)/primitives/sphere.glocator')
spherenode = sn[0]

#Create SpotLight
Light = doc.loadfile('$(LIBRARY)/lights/pointlight.glight')[0]

# Create constraint
cNode = Node.create('Constraint', 'TransformConstraint', parent=Light)

# Create euler
eNode = Node.create('Euler', 'TransformEuler', parent=Light)

# Create transform stack
Light.Transform.connect(cNode.Out)
cNode.In.connect(eNode.Out)

# Create connections
cPlug = cNode.createplug('WeightSphere',plugType ='ConstraintTransformWeightPlug',dataType = 'float',flags = '4',value = '1' )

with Modifier() as mod:
    cPlug.adddependency(spherenode.Transform.)

Toute aide est la bienvenue

Red

Last edited by RedSolos (2016-10-10 14:57:15)

Offline

 

#2 2016-10-11 10:47:33

hulud
Guerilla dev, the guy to hug

Re: Constraint

Hi RedSolo !

Here is a Python script that constraints a node over multiple objects. With a single constraint, the object keeps its original position.


Code:

import guerilla

def CreateConstraint (node, targets):
    ''' Constraint a node on multiple objects transform'''
    # Quick binding of the transform plugin in Python
    def TransformConstraintCreate(node):
        return fromLua(fromLua(lua.globals().TransformConstraint.create)(toLua(node)))
    def TransformEulerCreate(node):
        return fromLua(fromLua(lua.globals().TransformEuler.create)(toLua(node)))


    TransformEulerCreate(node)
    TransformConstraintCreate(node)
    constraint = node.getchild ("Constraint")

    with Modifier() as mod:
        for target in targets:
            mod.createplug (constraint, "Weight"+target.getname(), "ConstraintTransformWeightPlug", types('float', desc={'min':0,'max':1}), Plug.Dynamic, 1)
            mod.adddependency (constraint.Objects, target.Transform)

# Get the light
pointLight = _("PointLight")
sphere = _("Sphere")
CreateConstraint (pointLight, [sphere])

Cyril 'Hulud' Corvazier
Guerilla developer
http://www.mercs-eng.com

Offline

 

#3 2016-10-13 11:29:32

RedSolos
New member

Re: Constraint

Thanks Cyrill smile

I have a other question smile

Do you have an example for create some windows in python with the python API smile

Thanks in advance

Red

Offline

 

#4 2016-11-06 07:21:12

colin
Member

Re: Constraint

pyside pyside
http://guerillarender.com/doc/1.4/Pytho … yside.html

par contre,   toujours pas de moyen de parenter notre qdialog/qwidget   la main window de Guérilla?  pour pas qu'elle passe  en arrière plan quand on click ds l'interface.

Et  il est vraiment nécessaire ce binding du lua ? ça me paraît tarabiscoté pour créer un plug in ?
mercii


Technical Director Rendering/Compositing
At Illumination MacGuff.

Offline

 

#5 2016-11-06 11:16:12

Ben
Guerilla dev, the guy to hug

Re: Constraint

Hi Colin,

We'll check what we can do for you with your widgets smile

Regarding the Lua binding, most of Guerilla UI and document handling is actually written in Lua, making Lua the first and natural scripting language. The Python SDK was added later, and sometimes lags a bit behind the Lua SDK, but we're working on it. It just happens in this case that the Python SDK was not complete, hence the Lua workaround smile

Cheers,
Ben


Benjamin 'Ben' Legros
Guerilla developer
http://www.guerillarender.com

Offline

 

#6 2016-11-06 16:48:57

colin
Member

Re: Constraint

yes je m'en doutais.   merci !
je crois que je vais me mettre au lua histoire de comprendre ce qui se passe derrière l'api python. 

et trop cool pour le pyside merci.  et je me demandais si votre UI est initialement du qt, et si on pouvais faire du pyside avec le look Guérilla.  Comme dans nuke ou maya. 
merci !


Technical Director Rendering/Compositing
At Illumination MacGuff.

Offline

 

#7 2016-11-06 17:31:14

Ben
Guerilla dev, the guy to hug

Re: Constraint

You can have a look at python/guerilla.py, which is the auto-generated Python binding.
The UI is our own OpenGL-based toolkit, it's not based on Qt. I guess you can skin PySide/PyQt to look like Guerilla smile


Benjamin 'Ben' Legros
Guerilla developer
http://www.guerillarender.com

Offline

 

#8 2016-11-06 23:57:49

colin
Member

Re: Constraint

oh! c'est de l'opengl ! cool.  on peut être espérer une api :p. 
Si déj  on peut avoir de quoi rattacher   la main Window c'est super.  Et je me motiverai peut être   faire un stylesheet qt Guérilla   partager. 

mercii


Technical Director Rendering/Compositing
At Illumination MacGuff.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB