1

I am using rajawali framework for rendering 360 image and over that i am adding on object at particular x,y and z coordinate.

So i want to get x,y and z when i move my camera so how i can get the coordinate of camera.

Below is my code to render 360 image.

public class MyRenderer extends RajawaliCardboardRenderer {

public MyRenderer(Context context) {
    super(context);
}

@Override
protected void initScene() {

    Sphere sphere = createPhotoSphereWithTexture(new Texture("photo", R.drawable.panorama));

    Sphere sphere2 = createArrowWithTexture();
    sphere2.setPosition(20, 5, 10);
    sphere.addChild(sphere2);

    getCurrentScene().addChild(sphere);

    Vector3 v = new Vector3(0, 0, 0);
    getCurrentCamera().setPosition(v);
    getCurrentCamera().setFieldOfView(100);


}

@Override
public void onNewFrame(HeadTransform headTransform) {
    super.onNewFrame(headTransform);
    Matrix4 v = getCurrentCamera().getViewMatrix();
    Log.e(TAG, v + "");
}


private static Sphere createPhotoSphereWithTexture(ATexture texture) {

    Material material = new Material();
    material.setColor(0);

    try {
        material.addTexture(texture);
    } catch (ATexture.TextureException e) {
        throw new RuntimeException(e);
    }

    Sphere sphere = new Sphere(50, 64, 32);
    sphere.setScaleX(-1);
    sphere.setMaterial(material);

    return sphere;
}

private static Sphere createArrowWithTexture() {

    Material material = new Material();
    float[] reticleColorArray = new float[]{0, 0, 0, 0.5f};
    material.setColor(reticleColorArray);

    Texture t = new Texture("photo", R.drawable.ret);
    try {
        material.addTexture(t);
    } catch (ATexture.TextureException e) {
        throw new RuntimeException(e);
    }

    Sphere sphere = new Sphere(10, 30, 30);
    sphere.rotate(Vector3.Axis.Z, 150);
    sphere.rotate(Vector3.Axis.Y, 20);

    sphere.setMaterial(material);


    return sphere;
}
 }

so any one can help me out in this how i can get coordinate.

Nikhil Sharma
  • 593
  • 7
  • 23

0 Answers0