Closed sam16222 closed 7 years ago
Hi @sam16222 I think you are asking about getting the geometry/object at the center of the screen?
If so that's a ray casting problem. You may want to check out https://github.com/gearvrf/GearVRf-Demos/blob/master/gvr-eyepicking/
You can call GVRScene.getMainCameraRig().getHeadTransform() to get the camera view matrix. It is updated every frame when your head moves.
@sam16222 Do you need more help?
@liaxim I tried using what you suggested, but couldn't quite achieve what I wanted to. Here's what I want to do. Take a spherical mesh. It is blank all around. I want to point at a position and tap. At that location I should be able to spawn an image or a text box. Can you think of a way to do this? I tried using getHitLocation() but it didn't quite work.
@sam16222 It didn't quite work in what way? Thanks.
It's just not giving me the exact position. As explained in the situation above, can you tell me a way to do it? I just want to look at a location, tap and then spawn a text box at the location, with the appropriate rotation values.
@sam16222
Let me know if the following is of use:
If you follow the example https://github.com/gearvrf/GearVRf-Demos/blob/master/gvr-eyepicking/
You can modify the PickHandler's onInside() function and query the collision position:
public class PickHandler implements IPickEvents
{
public void onEnter(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo)
{
}
public void onExit(GVRSceneObject sceneObj)
{
}
public void onNoPick(GVRPicker picker) { }
public void onPick(GVRPicker picker) { }
public void onInside(GVRSceneObject sceneObj, GVRPicker.GVRPickedObject pickInfo) {
//This function is called whenever your looking direction intersects with an object.
//This is supposed to be the exact position you look for
float[] hitLocation = pickInfo.hitLocation;
//Do something about this position, such as spawning an image or text box
...
}
}
We close issues if no more activity after awhile. Feel free to ask anew
Hello, Is there a way to obtain the transform position of the point being looked at via the head tracker? I was looking into getLookAt but it only gives the vector.