我正在使用rajawali框架渲染360图像,而我正在使用特定的x,y和z坐标添加对象。
因此,当我移动相机时,我想获得x,y和z,以便我可以获得相机的坐标。
下面是我渲染360图片的代码。
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;
}
}
所以任何人都可以帮助我解决这个问题。