8
私は自分の世界のメッシュの位置を追跡しているモデル行列を持っています。 glRotate()
とglTranslate()
を呼び出すたびに、私はmodelMatrix.rotate()
とmodelMatrix.translate()
に対応するコールが正しく機能しているようです。BoundingBoxにマトリックス変換を適用
ここで、私の各モデルに関連付けられているバウンディングボックスを更新する必要があります。私はlibGDXフレームワークで作業しており、BoundingBox
クラスfound hereにはメソッドmul()
があります。これは、境界ボックスに行列を適用できるはずですが、値が正しく更新されていないと思います。それを適用しようとしています。何か案は?
gl.glPushMatrix();
// Set the model matrix to the identity matrix
modelMatrix.idt();
// Update the orbit value of this model
orbit = (orbit + ORBIT_SPEED * delta) % 360;
gl.glRotatef(orbit, 1.0f, 1.0f, 0);
// Update the model matrix rotation
modelMatrix.rotate(1.0f, 1.0f, 0, orbit);
// Move the model to it's specified radius
gl.glTranslatef(0, 0, -ORBIT_DISTANCE);
// Update the model matrix translation
modelMatrix.translate(0, 0, -ORBIT_DISTANCE);
// Update the bounding box
boundingBox.mul(modelMatrix);
if (GameState.DEBUG)
{
renderBoundingBox(gl, delta);
}
// Bind the texture and draw
texture.bind();
mesh.render(GL10.GL_TRIANGLES);
gl.glPopMatrix();
バウンディングボックスを描画する前にアイデンティティをロードしていますか? –
いいえ、モデルとバウンディングボックスを描画するまで、 'glLoadIdentity()'を呼び出す必要はありません。 – DRiFTy
私はあなたがすべきだと思います。あなたはあなたのbbを2回変えているからです。 renderbbの中でプッシュ/ポップを行う。投影を保つ。あなたがtodoテストをしたいなら、変換はアイデンティティを読み込まず、mul()を呼び出さないでください。そうすることで、teモデルと同じ変換でte bbを描くことになります。うまくいくはずです。 –