#1
|
|||
|
|||
trouble changing subnode (child node) color, alpha, etc.
I'm having trouble setting various properties (e.g., color, alpha, ambient) for on-the-fly objects when they are the children (or subnodes) of other objects. For example
Code:
square = makeOTFSquare() square.color(viz.RED) Code:
square = makeOTFSquare() square2 = makeOTFSquare() square2.setPosition(someOffset) square2.parent(square) square.color(viz.RED) Is there any easy way to do this, or will I have to loop over all the child (and grand-child, great-grand-child, etc.) nodes, changing each one individually? |
#2
|
|||
|
|||
Still having the same trouble, though I have found that some node properties do get passed onto children. For example, setting <node3d>.lineWidth or <node3d>.pointSize works as I would like. Any thoughts?
|
#3
|
|||
|
|||
Does it work if you put all the OTF nodes underneath a group node, and then apply the color to the group node?
|
#4
|
|||
|
|||
No, actually, that was how I first tried it. It doesn't work either way.
|
#5
|
|||
|
|||
Can you post a working script that reproduces this specific problem? I tried the following script and it works for me. It loads 2 OTF nodes underneath a group node. When the spacebar is pressed, it will set the color of the group node to red, which gets applied to the OTF nodes.
Code:
import vizshape viz.go() group = viz.addGroup(pos=(0,1,10)) box = vizshape.addBox(parent=group,color=viz.BLUE,pos=(-1,0,0)) sphere = vizshape.addSphere(parent=group,color=viz.GREEN,pos=(1,0,0)) vizact.onkeydown(' ',group.color,viz.RED) |
#6
|
|||
|
|||
Interesting ... I wish I'd known about vizshape, because I've basically recreated much of its functionality, and in an apparently inferior way. I can't seem to find any documentation on vizshape, and its code comments are rather sparse as well. What you sent me does work.
Here's an example of what I did (a bit stripped down but reproduces the error): Code:
import viz import math class Circle(viz.VizPrimitive): def __init__(self): #draw circle viz.startlayer(viz.LINE_LOOP) for i in range(32): radians = 2*math.pi*i/32 viz.vertex([math.sin(radians),math.cos(radians),0]) self.node = viz.endlayer() #initialize base class viz.VizPrimitive.__init__(self,self.node.id) class Probe(viz.VizPrimitive): def __init__(self): #draw probe self.node = viz.addGroup() #draw circle circle = Circle() circle.parent(self.node) #draw lines viz.startlayer(viz.LINES) viz.vertex(0,0,0) viz.vertex(0,0,-1) line = viz.endlayer(self.node) #initialize base class viz.VizPrimitive.__init__(self,self.node.id) viz.go() viz.eyeheight(0) probe = Probe() probe.setPosition(0,0,5) probe.setEuler(20,10,0) probe.color(viz.RED) probe.lineWidth(10) |
#7
|
|||
|
|||
Can anyone explain why my classes don't work correctly for setting color? I'm a bit boggled, and looking over the vizshape module didn't really clarify anything for me.
|
#8
|
|||
|
|||
I run into a similar problem when creating GUIs. Some child nodes don't take the alpha of their parent. In the following example the texture quad does inherit the parent's alpha, the text and on-the-fly objects do not.
By the by, I only got the texture quad to take the parent's alpha when I set the alpha call's op mode to viz.OP_OVERRIDE. Code:
import viz viz.go() viz.clearcolor(viz.SKYBLUE) forceIDRoot = viz.addGroup(parent=viz.SCREEN, pos=[.40, .92, 0]) forceIDRoot.alpha(.5, op=viz.OP_OVERRIDE) # viz.OP_OVERRIDE gets the quad alphaed forceIDQuad = viz.addTexQuad(parent=forceIDRoot, scale=[4.5,1,0]) #yes alpha #no text alpha t = viz.addText('afdasdf asdfasdf', parent=forceIDRoot, pos=[-.165, .01, 0], scale=[.3]*3) t.color(viz.BLACK) viz.startlayer(viz.QUADS) viz.vertex([0,0,0]) viz.vertex([.5,0,0]) viz.vertex([.5,.5,0]) viz.vertex([0,.5,0]) viz.endlayer(parent=forceIDRoot) #no alpha?
__________________
Paul Elliott WorldViz LLC |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Pivot points for child objects in Vizard with 3ds Max | Gladsomebeast | Vizard | 0 | 09-19-2006 11:21 AM |