Collision with avatars and scene not working
Hi!
I import a scene from OSG (.ive file) into Vizard 3.0 and want to have avatars walking around in it. I have it working, but it takes to much calculation time, so I'm trying to make it better. It works fine with viz.intersect (calculating an intersection between the avatar and x meter in front of it), but I would like to use physics (hoping it would bet easier on the CPU). I tried this method: I assigned a collidemesh to the objects of the imported scene, which I want the avatars to collide with. The avatars have an avatar.collidebox around them, with the collision notify on. I assigned an event which is triggered by a collision (like in the tutorial). But the avatar does not collide with the scene.... What am I doing wrong?? Any ideas?? |
I know that collidemesh doesn't work with the physics dynamics, so I have to ddisable viz.DYNAMICS. I don't know if that helps you or not. Check out these recent threads, which may be of some help they discuss speeding up line intersection and doing collision in version 3.
http://www.worldviz.com/forum/showthread.php?t=729 http://www.worldviz.com/forum/showthread.php?t=725 |
Here is how I got some collision events with an avatar. Perhaps you are missing one of the steps. (Forgot male.enable( viz.COLLIDE_NOTIFY ) perhaps?)
Code:
import viz |
This seems to work, I'll try backing up a few steps and recreate this code in my model.
I added male.disable(viz.DYNAMICS), because else the avatar looks very blurry (drawing error or so?) AlsoI added gravity and a mousedriven walkto to see how it works. I'll try to incorporate it into my model tomorrow. But if anyone has anymore bright ideas how to detect collision with low cpu usage, please share! Here's the changed code: Code:
import viz |
I'm going mad....
I added a collidemesh to the scene objects, but I'm not sure that that went correctly, because I have a lot of objects with the same name and Vizard does not have a wildcard option to search all the children within a scene, based upon their name... But with one object I'm sure about that there's only one (the edge of the scene, named 'Layer:Bak'), the &^%& avatars just walk through, without generating a collision event.... And sometimes they generate a collision event, where there are no objects... I'm at a loss... Any bright ideas about what I am doing wrong? I'm using Vizard R3 Beta 2 (maybe that helps) LINK TO IVE FILE Code:
import viz |
Quick question: Can I make the collisionMeshes visible in some way? To see where the avatars should collide? F3 Shows only the geometry I believe.
|
Of course, the visual geometry should be the collide mesh. You can visualize the bounding boxes around the avatars with this code:
Code:
import viz |
I have experimented with your script and model. There seems to be invisible physics shapes in your model.
Instead of calling collideMesh on the child objects I just called it on the root "mall" node. This seems to work well. Would this be a solution for you? Code:
import viz |
OK, importing the scene this way works, but importing it as a stage doesn't. Now I know... I'll play with it some more tomorrow at 'work'. Thanks a lot for your help!!!
BTW:Is this a bug, or a feature? Yesterday I also tried adding a collidemesh to the scene, but then it was a stage object and not a viz.add object (node3d?). That didn't work, this does. |
The key difference between the code is that I do mall.collideMesh() instead of calling collideMesh() on children of the mall.
I had your problem with applying collideMesh() to children even when I added the mall via script. |
OK, so the problem is calling a collidemesh on a child. Knowing this I tried to detach the children I need to collide with from the mall object with Object.parent(viz.WORLD), but they just disappear. Apparently viz.World is not the current scene. How do I detach children from this node and attach them to the main scene? I tried viz.SCENE and viz.HEAD and viz.MAIN_SCENE, but none work)
I don't want to collide with the whole mall object, because it's rather large and I just need to collide with 14 objects to have the avatars walking in the right places. The sky for example is a child of the main scene (it's added with viz.add), but when I request the parent of the sky with sky.getParents() it's empty... So how to attach a child to the main? |
Update:
I encountered something strange: I cannot extract a list of children from my .ive file, although I can acces the children by name. So: ObjectsinMall = mall.getChildren() is an empty list, but tub = mall.getChild('Layer:Bak") is a valid object And when I open the Properties of the stage, or .ive object, I see all the children.... Strange.... Does an .ive file not support this? Or is there something else I am overlooking? |
|
All times are GMT -7. The time now is 05:48 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC