0
モデルのインスタンスから3D座標(Vector3として)を取得したいと思います。 次のコードで私は元の座標しか得ることができませんが、レンダリングメソッドでは、私のモデルはY軸を中心に回転していて(同時に動いています)、各フレームの座標を取得したいと思います。LibGDXでモデルインスタンスの3D座標を取得する方法は?
私は@Xoppaによって作成された小さなクラスを使用しています:
public static class GameObject extends ModelInstance {
public Vector3 center = new Vector3();
public Vector3 dimensions = new Vector3();
public float radius;
public BoundingBox bounds = new BoundingBox();
public GameObject (Model model, String rootNode, boolean mergeTransform) {
super(model, rootNode, mergeTransform);
calculateBoundingBox(bounds);
bounds.getCenter(center);
bounds.getDimensions(dimensions);
radius = dimensions.len()/2f;
}
}
、ここでは私のコードです:機能なし「getPosition」またはそのようなことはありません
public void render(float delta) {
super.render(delta);
if (loading && manager.update()) {
doneLoading();
}
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
batch.begin();
backgroundSprite.draw(batch);
batch.end();
for(GameObject instance : instances){
instance.transform.rotate(new Vector3(0, 1, 0), 0.5f);
float x = instance.bounds.getCenterX();
float y = instance.bounds.getCenterY();
float z = instance.bounds.getCenterZ();
System.out.println(x+" "+y+" "+z);
if(isVisible(cam, instance)){
modelBatch.begin(cam);
modelBatch.render(instance, environment);
modelBatch.end();
}
}
}
、それはすべてのMatrix4についてです私はそれについて数学のコースを持っていません。私は立ち往生している。
ここに行く:http://badlogicgames.com/forum/viewtopic.php?f=11&t=17878&p=75338#p75338 – Xoppa
@Xoppaあなたのチュートリアルは動作していないようです: – Vellyxenya
私のレンダリングメソッドは次のとおりです: 'for(GameObjectインスタンス:instances){ instance.transform.rotate(new Vector3(0,1,0)、0.5f); instance.updateTransform();System.out.println(instance.position); if(isVisible(cam、instance)){ modelBatch.begin(cam); modelBatch.render(instance、environment); modelBatch.end(); } }とGameObjectクラス: – Vellyxenya