node3d.visible(viz.OFF) Problem
Hello
I have a small problems with the node3d.visible command. if I have 2 bodies like in the following code, when I swith off the visibility of the first body, then the second body also disapears. Is there a workaround? Thank you Sandro Code:
body1 = viz.add('body1.obj') |
You can link an empty group node to your original parent object and then set the group node to be the parent of your child object. Then when you change the visibility of the original parent it won't affect the child. Here's an example.
Code:
import viz |
Thank You Jeff
I just have one more problem with this code. In the line: Code:
ball = viz.add('ball.wrl',parent=group,pos=[0,1,0]) I would need to give this position in relation to the box. In my real code, there are a lot of bodies, all connected in something like a chain. So if I have to calculate all the initial positions in world coordinates it would be a lot of work. With the line Code:
body2 = body1.add('body2.obj') Do you have an idea how to do this? Sandro |
the position of the ball is set in its parent coordinate system, the default is viz.ABS_PARENT. So the ball is always [0,1,0] in the group node's coordinate system which is the same as the box. If you try
Code:
print ball.getPosition(viz.ABS_GLOBAL) |
1 Attachment(s)
Hi
Sorry, I am not able to work it ou by myself. I added a small sample, and it should work like this: there are 3 bars in a chain. The bar-body is attached bar1 should rotate araund the vertikal axis (keys "t" and "b") on the end of bar1, bar2 is connected and should rotate like a arm. and on the end of bar2, bar3 is connected and should also rotate like a arm. and then I want to switch the visibility of bar2 The first code is like I want it: Code:
import viz First problem, the bar3 is not at the end of bar2 (you have to navigate back to look for it) this has something to do with the ANCHOR_POS of the first bar. Second problem, bar3 follows bar2, but not the bar1. Code:
import viz |
Here are two options. For your code without the group node you could replace
Code:
vizact.onkeydown(' ',bar2.visible,viz.TOGGLE) Code:
vizact.onkeydown('1',bar2.disable,viz.RENDERING) in the code with group node and the link you could add Code:
link.setSrcFlag(viz.ABS_GLOBAL) |
Thank you Jeff
The version with "bar.disable,viz.RENDERING" works best for me, and I think this is the easiest way to do it. And with this version I can still use the "box.visible,viz.TOGGLE" command when I want all linked nodes to disappear. Sandro |
All times are GMT -7. The time now is 08:07 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC