目前,我正试图在libgdx中制作简单的3d模型查看器。我只是好奇,如果我可以改变相机,以正确地查看三维模型。
//--三维模型部分
Model smallCar= assets.get("data/small_car.obj", Model.class);//<--dynamic model
ModelInstance smallCarInstance = new ModelInstance(smallCar);我可以设定相机的静态位置,但我想根据汽车型号的大小来设置摄像机的位置,如下所示:
cam.position.set(1f, 1f, smallCar.getWidth()* 2f); //<--isn't available
cam.lookAt(0,0,0); 相机的位置应该是动态的,这样它的位置就不会影响三维模型的视图。谢谢,
发布于 2016-01-15 08:30:02
BoundingBox boundingBox = smallCarInstance.calculateBoundingBox(new BoundingBox());
float maxDistance = Float.max(Float.max(boundingBox.getWidth(), boundingBox.getHeight()), boundingBox.getDepth());
cam.position.set(0f, 0f, maxDistance * 2f);
cam.lookAt(0f, 0f, 0f);
cam.rotateAround(Vector3.Zero, Vector3.X, -30f);
cam.update();https://stackoverflow.com/questions/34805910
复制相似问题