WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-18-2011, 01:37 PM
miles miles is offline
Member
 
Join Date: Jan 2011
Posts: 21
Unfortunately, the project is many large files, so I can't post the whole thing. I can try posting relevant sections, but it would be difficult to get it working isolated.

#loads all environmental objects
class Environment:
def __init__(self, config, link):
self.link = link

#clear the scene
### THIS IS NOT WORKING
#for child in viz.MainScene.getChildren():
# child.remove()

backgroundcolor = config.GetVector('vDisplayBackgroundColor')
viz.clearcolor(backgroundcolor)

self.court = viz.addTexQuad(viz.WORLD, viz.MainScene, 100)
self.court.setEuler(0,90,0)

#grass field
if config.GetBool('bEnvGroundTexture'):
grass = viz.addTexture('res/grass.jpg')
grass.wrap(viz.WRAP_T, viz.REPEAT)
grass.wrap(viz.WRAP_S, viz.REPEAT)
scale = viz.Transform()
scale.setScale(10,10,1)
self.court.texmat(scale)
self.court.texture(grass)
#green plane
else:
self.court.color(0,.3,0)
self.court.disable(viz.LIGHTING)
Reply With Quote
  #2  
Old 01-18-2011, 02:51 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
That's the problem with wanting to clear the entire scene, other modules might add their own hidden nodes to the scene which can cause problems when you delete them.

You can keep track of all the nodes you create and delete them individually, as Jeff already suggested.

The approach I would recommend is to create a root group node and add all your objects as children of it. Then you just need to delete the root node and all your objects will be cleared. Here is an example:
Code:
# Root node for all objects
root = viz.addGroup()

# Add object underneath root
court = viz.addTexQuad(parent=root)

.
.
.
# This will delete all the objects added to root
root.remove()
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


All times are GMT -7. The time now is 02:33 AM.


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