ビューポートの中央にメインシーンがあり、
それに加えて、ビューポートの隅に別の小さなオブジェクトを表示したいと思っています。問題は、小さなオブジェクトを描画すると、メインの投影変換によって変換され、傾斜して表示されることです。小さなオブジェクトの中心に独自の消失点を持たせたいです。
これは可能ですか?
1081 次
1 に答える
1
メインシーンをある方法で投影し、コーナーオブジェクトを別の方法で投影する必要があります。これは直接解決策につながります:
void render() {
glMatrixMode(GL_PROJECTION);
setUpMainProjection();
glMatrixMode(GL_MODELVIEW);
drawMainObject();
glMatrixMode(GL_PROJECTION);
setUpCornerProjection();
glMatrixMode(GL_MODELVIEW);
drawCornerObject();
}
おそらく、setUpCornerProjectionを実装する方法を疑問に思っているでしょう。次のようになります。
// let's say r is a rect, which, in eye space, contains the corner object and is
// centered on it
glFrustum(r.left, r.right, r.bottom, r.top, nearVal, farVal);
// let's say p is the rect in screen-space where you want to
// place the corner object
glViewport(p.x, p.y, p.width, p.height);
次に、setUpMainProjection()で、glFrustumとglViewportも呼び出す必要があります。
于 2011-02-21T22:13:18.263 に答える