Obtaining Positional Data
How can I obtain the user's positional data in the virtual environment?
Specifically, I am designing an experiment in which the user will move down a main hallway and then turn right down one of two hallways that lead off it. Proceeding down the second hall, they will see a symbol on the wall and will then return to the starting position. Once at the starting position, they will orient themselves so that they are pointing to the now occluded symbol. (Hopefully this makes sense). Ideally, the user will use a crosshair to point to the symbol. I have two questions: First, is it possible to have a crosshair on the screen at all times (think Quake, or similar). Second, how do I obtain the user's positional information once they are in position? All I need is rotational information about the Z-Axis (yaw, I think) to see how close the user is to actually pointing to the symbol. Thanks! |
Hi,
To get information about the viewer use the viz.get() command. Take a look in the command reference of the documentation for a more detailed description. Here's an example: Code:
#Get the head position Code:
import viz |
This seems to be working. Can I get it to give me the information when the joystick trigger is pressed?
Right now I have it printing the data inside a loop so it's giving me a continuous update, but this isn't really what I want. Also, is it possible to have the user "snap back" to a set position? Thanks! |
I just realized I didn't mention that I'd like to be able to trigger the "snap back" with either one of the joystick buttons (except the trigger) or, more ideally, a button on the keyboard. Thanks!
|
I just realized I didn't mention that I'd like to be able to trigger the "snap back" with either one of the joystick buttons (except the trigger) or, more ideally, a button on the keyboard. Thanks!
|
Hi,
If you want to snap the viewpoint to a certain location when a key is pressed then you will use a KEYBOARD_EVENT. This is an event that is triggered whenever a key is pressed. Here is an example that will place the viewpoint at the position [1,2,3] and reset the orientation whenever the 's' key is pressed: Code:
import viz |
Works beautifully. Thanks!
|
bullets
I'm using a variation of this duckcourt example, except I increased the speed and shrunk the ball so it looks like a bullet. Unfortunately the crosshair is not too accurate. I don't need pinpoint accuracy, but I would like the "bullet" to "shoot" from the middle of the crosshair. Sometimes when I shoot to the left or right, the bullet comes out from the left or right of the crosshair. I can't think of anyway to adjust this so the bullet comes out from the crosshair no matter what direction I'm shooting. Here is the code for your reference:
Code:
def MoveBullet(bullet,elapsed): |
Hi,
Can you provide the code for you shootBullet function, since that is where the relevant code should be. Are you using the viz.screentoworld function similar to the duckcourt example? |
Here you go. Thanks
Code:
def shootBullet(): |
Hi,
It looks like you pretty much copied the code from the duckcourt example. Do you get this same problem with the duckcourt script? |
Yes I did. It's not as noticeable because of the size of the balls, but I still do get the same effect.
|
Hi,
Would you mind posting a screenshot of this problem. I don't get this problem when I run the scripts here. Also, which version of Vizard are you using? |
Sure, I have a couple now. How can I go about posting them on this forum? I did notice that when I declared viz.go(viz.HMD |viz.STEREO | viz.TRACKER) it had the problem I had previously described. Once I take off the viz.STEREO, it works fine on my screen, but when I put the HMD on, the image does not display right. I'm not sure if that will help, but I thought I'd mention it.
|
Hi,
Ok, that makes sense now. When using the screentoworld command you need to account for the stereo mode. So if you are using the mouse with the left eye, then simply multiply the x component of the mouse position by 2. Code:
pos = viz.mousepos() |
What do you mean if i'm using the mouse with the left eye? I'm using both eyes. The effect occurs as follows. When I'm looking straight ahead, if I shoot to the left, the bullet goes too far left. If I'm shooting to the right, the bullet goes too far right. I tried implementing that code and i still got the same effect. Is there anyway to do this w/o stereo mode?
|
Hi,
Are you only getting this problem when using STEREO, or do you experience it in non-STEREO mode also? Keep in mind that STEREO mode will offset the position of each eye based on the IPD value. However, the screentoworld command returns coordinates based on the point between both eyes. This is probably why the bullets don't seem to be going straight through the crosshair. There is nothing you can really do about this. |
Yes, it only happens in stereo mode. I think I can take off STEREO mode but the only problem is when I try to do that, the eyes are switched in the HMD. They work fine when I'm looking at the screen (e.g. the Vizard VR toolkit code), but when I actually run the program there is a kind of false projection of an avatar on each eye. I'll close one eye and see one thing, then close the other and see another avatar. I don't know if this is making sense. Please feel free to ask me questions so I can clear this up
|
Hi,
If you are viewing the world through an HMD then you MUST enable stereo. Otherwise, your left eye will only see the left half of the world and your right eye will see the right half. |
I see, so basically there is no solution to the problem? Thank you for all your help. I know I have asked a lot but I appreciate all that you have helped me with.
|
Hi,
Well, I wouldn't really call this a problem. What you are asking is kind of impossible to do. You want the object to appear directly at the center of the crosshair for BOTH the left and right eye. Also, keep in mind that the duckcourt example was not intended to be used in STEREO mode. Having GUI objects, such as the crosshair, won't work correctly in STEREO. |
I think I'm not doing a very good job of communicating what we are trying to do. I spoke to another person that works here in the lab and he said that he remembered hearing that this software was used for military shooting simulations. Our application is similar. I'm thinking that if the military does it, the "gun" should be relatively accurate. For some reason ours isn't. I've attached the entire prototyped code for your reference. Any suggestions? If after looking at this code you still think it's impossible to get proper accuracy, then I'll move on and try something else. As I mentioned before, it works w/o stereo mode, but not with.
Thanks :) Code:
import viz |
1 Attachment(s)
Hi,
I've attached a modified version of the script which I hope will point out why you are experiencing this problem. First of all, I removed the crosshair because you shouldn't be using objects attached to the screen when using stereo. Second, I set the ipd value to 0. The ipd is the eye distance value. So both eyes will be at the same location. Third, I multiplied the x value of the mouse position by 2.0 when using the screentoworld command. This should cause the the bullet to come directly from the mouse position, for the left half of the screen. If you set the IPD value back to normal, you will experience your problem again. This is because in stereo mode the eyes are offset from the actual viewpoint position. I've attached an image which shows why the bullet appears to go to the left (excuse my crappy drawing skills :) ). Do you plan on the user using the mouse to aim while wearing the HMD? Code:
import viz |
For now we plan to use the mouse, however, when I tried this code, it didn't work for me. When I "shot" the avatars, nothing happened to them. So, now, after looking at this code, are you still sure that there is no way to adjust for the accuracy of the bullet when shooting to the sides? Thanks,
|
Hi,
The code I posted was made with the latest internal version of Vizard. I realized that it won't work with the version you have. You just need to change the screentoworld command to the following: Code:
bulletvector = viz.screentoworld(pos[0]+0.25,pos[1]) |
What do you mean by useless? I tried using the code w/the HMD and the bullet came exactly from the mouse position. Is there a way to make them perform an action when they are hit by a bullet? I wouldn't mind keeping the IPD at zero as long as the avatars would fall when they got hit.
|
The whole point of wearing an HMD is that each eye gets a different view of the scene. This is what make the image look 3D. Setting IPD to zero will effectively disable stereo since both eyes will be receiving the same view of the scene.
Here is some sample code that will play the hit animation when the avatar is hit by a bullet. Replace the code with whatever action you need: Code:
import viz |
Thank you very much!
|
Ok, I tried adding the wait then freeze, instead of just having the avatar fall and get back up, but for some reason, it's not working. What does the underscore in speed_node(0) mean?
Code:
info = viz.intersect(pos,futurePos) |
Hi,
You are not actually executing any animations on the avatar. You should add the following line before adding the WaitThenFreeze action: Code:
info.object.execute(7) |
All times are GMT -7. The time now is 01:57 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC