WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   importing a single WRL with many objects. (https://forum.worldviz.com/showthread.php?t=927)

giancamati 12-15-2006 09:08 AM

importing a single WRL with many objects.
 
Hello everybody,

I have this problem: I have a single wrl scene with many objects. When I use viz.add(...) function I can visualize the scene correctly. Now, the problem is the Vizards see the entire scene as a unique object instead of a set of objects.
This could be a problem when I would grab a single object in the scene. How can I solve this problem? That is importing a complete scene in wrl file and grabbing each element of the scene as a single object.
For example I have a wrl scene with 300 elements. Should I write viz.add(...) for 300 times if I want to load all these object separately?

Thank you very much.:D

Giancarlo

Gladsomebeast 12-15-2006 09:20 AM

OK. At some point before collidemesh is called the objects will have to be seperated from eachother and made children of viz.WORLD. When you call viz.add () models are automaticly children of viz.WORLD. If you want to add all of the models at once you will need to get each object by the name it is assgined in the modeling program with the .getChild() method. This would be easier if they were given a nice namming convention in the modeling program so you could do this in a loop instead of hundrds of lines of code.

You could also export each object from the modeling program, hopefuly with some nice namming convention, and call viz.add() 300 times.

Code:

for i in range(NUMBER_OF_OBJECTS):
        object = viz.add('object' + str(i) + '.wrl')
        object.collideMesh()


giancamati 12-18-2006 10:49 AM

I tyred
 
Hello,

I tryed to use viz.get(viz.WORLD) to get the list but it returns a list with length 2.
Why?

Thank you.
Giancarlo Amati

Gladsomebeast 12-18-2006 01:13 PM

I think I did no make myself clear.

For collideMesh() to work, the model must be a child of viz.WORLD. If you import all your objects in one file, the objects will be children of the larger model/file object. So you would have to break the objects out of the model and set their parents to viz.WORLD. Here is some code showing what I am talking about.

bigModel = viz.add('allmyobjects.wrl')
smallThing = bigModel.getChild('mySubObjectName')
smallThing.parent(viz.WORLD)
smallThing.collideMesh()

You would have to do this for each model you want to be grabable. Allternativly, you could use the code in my last message and have each object be a seperate file.


All times are GMT -7. The time now is 06:54 PM.

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