Search Unity

[GoogleVR SDK] Help with a little script needed..

Discussion in 'VR' started by vanhauttebram, Jan 19, 2019.

  1. vanhauttebram

    vanhauttebram

    Joined:
    Nov 16, 2018
    Posts:
    10
    Hello,

    I am making a simple VR application where I can jump multiple 360° photo's (changes happen when concentrating my central point on a predefined area.

    Everything works well, but now I will let some people use my application. Here is the thing:

    I want to make a heatmap of the most looked at areas. So I would like to make a simple script (preferable in C# as I'm using C# for the little animations I have made), that logs the coordinates of the Main Camera (more in specific the center of the main camera, so the center of focus).

    I will shorty describe how the hierarchy of my application looks like:

    -gvrEditorSimulator (from Google VR)
    -gvrEventSystem (from Google VR)
    -Tripod, and on that tripod is my Main Camera. In that camera I have a gvrReticlePointer (so that the dot of the center is visible on screen).

    -Then I have different Spheres, and each sphere is made insideout, so that when I load a photo in it, and my Main Camera jumps inside this sphere, it looks like I'm in a Virtual Reality world.

    The Main Camera only jumps from sphere to sphere, so the combination of coördinates the camera can have is finite (1 set of coördinates per sphere), since the user can not walk in the spheres, only look around (so the pitch and yaw DOES change).

    What I would like now:

    A simple script attached to the Main Camera (for example LogScript.cs) that writes out the coordinates of the camera and in what Sphere it is at that moment. The spheres are have all different locations (Sphere1 has for example 0,0,0 [x,y,z] position, sphere2 100,0,0 , and so on. So what I could do is just read out the coördinates of the camera (and then hardcode equate it to know in what sphere it is. This means ofcourse new work on every added sphere). Also the question here is: how to ask the coördinates of the Main Camera?
    I would also need to know the looking angle (pitch and yaw) positions as those are actually what will make the eventual heatmap (since the coordinates are fixed, the main camera only jumps from sphere center to sphere center).

    The log file can then be for example a csv file:
    1,100,0,0,45,12,Sphere1
    2,0,100,0,37,14,Sphere2
    [log index,x,y,z,pitch,yaw,sphere]

    The actual mapping on to the picture will be done by myself then in Python.

    Second question:
    if I construct a for example csv file, where on the device (in my case a smartphone) would that get stored? Since I am making this in Unity on my Windows desktop, I can't choose the Android save path I think?

    Does anyone have any experience with such a simple script that can read out these coördinates and log them away?

    Thanks in advance!
     
  2. vanhauttebram

    vanhauttebram

    Joined:
    Nov 16, 2018
    Posts:
    10
  3. vanhauttebram

    vanhauttebram

    Joined:
    Nov 16, 2018
    Posts:
    10
    No one who can help me with this?
     
  4. vanhauttebram

    vanhauttebram

    Joined:
    Nov 16, 2018
    Posts:
    10
  5. nat42

    nat42

    Joined:
    Jun 10, 2017
    Posts:
    353
    I can't speak for others, but I'm put off by "questions" like this. This is phrased like a task someone wants done for them or a homework assignment.

    It's great to cover a little of what you are working to achieve but this is too much. Instead tell us why you are stuck doing this yourself, and what quick little things people might offer to give you a push in the right direction (ie. complete this yourself)

    Take getting the coordinates of the camera: I presume you checked Unity documentation, maybe Googled it, and looked at a tutorial or 7? What happened that prevented you applying those solutions over the last week? Did you try code and receive errors? Maybe post that code.
     
  6. vanhauttebram

    vanhauttebram

    Joined:
    Nov 16, 2018
    Posts:
    10
    I tried to access the coordinates of the main camera with: https://docs.unity3d.com/ScriptReference/Camera-main.html and 'Camera.mainCamera.gameObject.transform.position'.

    I have deleted all the code I had written and tested, since nothing gave any result that was wanted.

    This one I also had a look at: https://forum.unity.com/threads/camera-get-position-vector3-solved.59051/ but couldn't figure it out.

    I have to say I am pretty unexperienced so need a good push in the right direction. That was why this post was made.

    Thanks for replying!