hello,
I’ve got a question about rendering.
I’ve created my own camera and attached it to my scene graph like this :
PT(PerspectiveLens) pLens = new PerspectiveLens();
pLens->set_fov(67.0f);
float w = GameWindow()->get_display_region_3d()->get_pixel_width();
float h = GameWindow()->get_display_region_3d()->get_pixel_height();
float aspect_ratio = w / h;
pLens->set_aspect_ratio(aspect_ratio);
PT(Camera) pCamera = new Camera("BaseCamera", pLens);
mFocusNode = Render3D().attach_new_node("FocusNode");
mFocusNode.set_pos(0,0,0);
mCameraNode = Render3D().attach_new_node(pCamera);
mCameraNode.reparent_to(mFocusNode);
GameWindow()->get_display_region_3d()->set_camera(mCameraNode);
pCamera->set_active(true);
mCameraNode.set_pos(100.0f,0.0f,100.0f);
mCameraNode.look_at(mFocusNode);
mCameraNode.show();
everything looks as it should so far.
Now I’ve attached a 3d model to the hud (render2D) like this :
LVector3f Pos3D = LVector3f(0.0f, 0.0f, 0.0f);
myNode = //load the 3D model
NodePath render2D = GameWindow()->get_render_2d();
PT(Camera) pCamera = //my camera
LPoint2f hudPos2D;
pCamera->get_lens()->project(pos3D, hudPos2D);
myNode.reparent_to(render2D);
myNode.set_pos(hudPos2D.get_x(), hudPos2D.get_y(), 0.0f);
myNode.show();
the problem is my 3d model is displayed very streched along the x axis.
Anyone knows why that is ?
Chrys