sqlljlssb 发表于 2023-1-6 13:55:18

(内附代码)新人疑问,自行new Camera还需要设置什么才可以和MainCamera表现一致

下面的代码中,放开1,注释2
然后注释1,放开2
编译后的表现不一致.后者渲染有点问题,比如glider会透视,然后cow.osg也会有黑色的面

目前我只懂得要设置 setProjectionMatrixAsPerspective 和 setClearColor


int main(int argc, char **argv) {

    double wnd_width = 960, wnd_height = 540;
    osgViewer::Viewer vi;

    osg::Camera *test_cam = vi.getCamera();    // 1
    // osg::Camera *test_cam = new osg::Camera;   // 2

    test_cam->setProjectionMatrixAsPerspective(
      30.0, wnd_width / wnd_height, 1, 10000
    );
    test_cam->setClearColor(osg::Vec4(0.2, 0.2, 0.4, 1.0f));

    vi.setCamera(test_cam);

    vi.setUpViewInWindow(0, 0, wnd_width, wnd_height);
    vi.setSceneData(osgDB::readNodeFile("glider.osg"));

    vi.realize();
    return vi.run();
}
页: [1]
查看完整版本: (内附代码)新人疑问,自行new Camera还需要设置什么才可以和MainCamera表现一致