WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
  #1  
Old 12-03-2008, 10:40 AM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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)
works just fine, but

Code:
square = makeOTFSquare()
square2 = makeOTFSquare()
square2.setPosition(someOffset)
square2.parent(square)
square.color(viz.RED)
only changes the color of square, not square2. I tried changing the OpMode of the square node, either when setting the color, or globally via square.setOpMode, but none of the OpMode options changes this behavior.

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?
Reply With Quote
  #2  
Old 12-08-2008, 04:39 PM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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?
Reply With Quote
  #3  
Old 12-09-2008, 09:18 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Does it work if you put all the OTF nodes underneath a group node, and then apply the color to the group node?
Reply With Quote
  #4  
Old 12-09-2008, 10:15 AM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
No, actually, that was how I first tried it. It doesn't work either way.
Reply With Quote
  #5  
Old 12-09-2008, 10:48 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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)
Reply With Quote
  #6  
Old 12-09-2008, 11:53 AM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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)
Here you will notice the probe shows up with wide lines, but in white, not red.
Reply With Quote
  #7  
Old 12-30-2008, 08:40 AM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
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.
Reply With Quote
  #8  
Old 01-14-2009, 08:38 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
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
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -7. The time now is 01:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC