PDA

View Full Version : Ordered Operator Stack


Ces
03-26-2008, 12:11 PM
Been trying to come up with a clean implementation of a live mirror symmetry operator in XSI, and I've come to the conclusion that without a ordered operator stack it's near impossible.
Basically if we had a ordered operator stack based on a priority, it would make implementing things like these a lot easier. Where operators get sorted according to this member from lowest to highest, 0 being the default in which the operator stack functions as a normal FILO stack.

So, guess there's two sides of this post.
Any ideas for implementation with SDK in it's current state?
And any thoughts on my suggestion? :)

Cheers, Ces.

Julian Johnson
03-27-2008, 09:29 AM
This is simple RunTime SCOP that gives you one way of implementing a 'live' symmetry operator. Run the script and it will create a half cube split along X. Tweak any of the points in positive X and they'll be updated in negative X. Very rudimentary. It tries to overcome the FILO nature of the Operator Stack by ignoring it completely and putting the operator in the Animation Stack which keeps it above all the Modeling ops no matter what!

oMesh = Application.CreatePrim("Cube", "MeshSurface", "", "")
Application.SetValue("cube.polymsh.geom.subdivu", 2, "")
Application.ActivatePolygonSelTool("")
Application.SelectGeometryComponents("cube.poly[0-2,6,8]")
Application.ApplyTopoOp("DeleteComponent", "cube.poly[0-2,6,8]", "siUnspecified", "siPersistentOperation", "")

oScop = XSIFactory.CreateScriptedOp ("Op", "", "Python")

oScop.AddOutputPort(oMesh.ActivePrimitive)
oScop.AddInputPort(oMesh.ActivePrimitive,'In')

oScop.AlwaysEvaluate = 1

codeStr = """
def Op_Update(ctx, Out, In):
geom = In.Value.Geometry.Get2()
l = []
for x in geom[0][0]:
l.append(x * -1)
pax = list(geom[0][0])
pax.extend(l)
pay = list(geom[0][1])
pay.extend(list(geom[0][1]))
paz = list(geom[0][2])
paz.extend(list(geom[0][2]))
nupa = (pax,pay,paz)

polys = list(geom[1])
l = []
maxx = max(polys)+1
actidx = 0
while actidx < len(polys):
l2 = [polys[actidx]]
inc = polys[actidx]
slice = polys[actidx + 1:actidx + 1 + inc]
slice.reverse()
for x in slice:
l2.append(x + maxx)
l.extend(l2)
actidx = actidx + polys[actidx] + 1

polys.extend(l)
Out.Value.Geometry.Set(nupa,polys)

"""

oScop.Code = codeStr
oScop.Connect(oMesh,1)

thiago
03-27-2008, 06:23 PM
I came with this idea on the XSI list but nobody really liked it I think... ha!
But here I go again...:

a Custom Stack.

Where you can place this stack anywhere between the normal XSI construction modes. So you could add any operator to this stack and it would force it evaluation before send anything up into the graph.

Another solution:
be able to "stick" operators in a place and it wouldn't move no matter what.