我更改了Google示例中的代码' AugmentedRealitySample喜欢这样:
Boolean useBasicObjectInsteadOf3DModel = false;
if (useBasicObjectInsteadOf3DModel) {
// This is the original code provided by the Google sample.
// The mObject is an Object3D.
// Build a Cube and place it initially in the origin.
mObject = new Cube(CUBE_SIDE_LENGTH);
} else {
// This is the new code
LoaderOBJ objParser = new LoaderOBJ(mContext.getResources(), mTextureManager, R.raw.object_obj);
try {
objParser.parse();
mObject = objParser.getParsedObject();
} catch (ParsingException e) {
e.printStackTrace();
}
}
mObject.setMaterial(material);
mObject.setPosition(0, 0, -3);
mObject.setRotation(Vector3.Axis.Z, 180);
getCurrentScene().addChild(mObject);
当将useBasicObjectsInsteadOf3dModel设置为true时,该对象会粘贴到现实世界中的某个点(例如墙)。设置为false时,似乎设置了对象位置,以便Tango设备位于对象的中间,并且对象随平板电脑一起移动。然而,物体的旋转似乎是有效的,因为它像指南针中的针一样移动。
问题是:如何通过LoaderOBJ加载对象到现实世界中的某个点?