#1
|
|||
|
|||
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. Giancarlo |
#2
|
|||
|
|||
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 <VizNode>.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()
__________________
Paul Elliott WorldViz LLC |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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.
__________________
Paul Elliott WorldViz LLC |
Thread Tools | |
Display Modes | Rate This Thread |
|
|