screen resize problem

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

Post by kaos »

in gui application

Code: Select all

        driver->OnResize( core::dimension2d<irr::u32>(panel3d->GetSize().x,panel3d->GetSize().y) );
        camera->setAspectRatio( (float)(panel3d->GetSize().x) / (float)(panel3d->GetSize().y) );
getSceneNodeFromScreenCoordinatesBB dont't work fine.

the first time work good but if we resize and change camera ratio of the window them not work.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

@kaos: Is this a new bug in svn? In that case please tell us if it got added in trunk or in a branch. Otherwise please use an own thread for the bug-report, as in here it will probably get lost. And it would be great if you could for such bugs code a real example to show it. Otherwise one of us will have to do that and that usually takes longer (you already can reproduce it somehow while we have to start coding such an example from scratch only guessing what the problem could be).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

Post by kaos »

sorry it's 1.7.1 but the problem exits, if irrlicht start with 640x480(for example) them if we scale de window to 1024x768 the function getSceneNodeFromScreenCoordinatesBB dont't work fine. I think it is proportions dont't change.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

You are probably right and there is a bug. Still we're just happy when people who can already reproduce a bug write a short example which we can just compile to also reproduce it. This is so much easier for you to do than for us (and well, we also like that because occasionally it happens that when people reduce it to a simple example they find out that the problem isn't in the engine).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kaos
Posts: 155
Joined: Tue Aug 12, 2008 8:25 pm
Location: Spain

Post by kaos »

CuteAlien wrote:@kaos - You are probably right and there is a bug. Still we're just happy when people who can already reproduce a bug write a short example which we can just compile to also reproduce it. This is so much easier for you to do than for us (and well, we also like that because occasionally it happens that when people reduce it to a simple example they find out that the problem isn't in the engine).
wxwidget application

Code: Select all

#include <windows.h>
#include "irrlicht.h"
#include "wx/wx.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

ICameraSceneNode* camera    = {0};
IrrlichtDevice* device      = {0};
ISceneManager* smgr         = {0};
IVideoDriver* driver        = {0};
SExposedVideoData videodata;
HWND hwnd;

class MyApp: public wxApp
{
    virtual bool OnInit();
};

IMPLEMENT_APP(MyApp)

class MyFrame: public wxFrame
{

public:

    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
    void OnQuit(wxCommandEvent& event);
    void OnPaint(wxPaintEvent &event);
    void OnSize(wxSizeEvent &event);
    void OnMotion( wxMouseEvent& event );

    wxPanel* m_panel6;
    wxPanel* getPanel() { return m_panel6; }

    DECLARE_EVENT_TABLE()

};

enum
{
    ID_Quit = 1
};

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
    EVT_MENU(ID_Quit,MyFrame::OnQuit)
    EVT_PAINT(MyFrame::OnPaint)
    EVT_SIZE(MyFrame::OnSize)
END_EVENT_TABLE()

bool MyApp::OnInit()
{

    MyFrame *frame = new MyFrame( _("Hello World"), wxPoint(50, 50), wxSize(800,600) );
    frame->Show(true);
    SetTopWindow(frame);

    hwnd = (HWND)frame->getPanel()->GetHandle();

    irr::SIrrlichtCreationParameters param;
    param.DriverType        = video::EDT_DIRECT3D9;
    param.WindowId          = reinterpret_cast<void*>(hwnd);
    param.Vsync             = false;
    param.Bits              = 32;
    param.HighPrecisionFPU  = true; // para directx
    SExposedVideoData videodata_temp(hwnd);
    videodata = videodata_temp;

    device = irr::createDeviceEx(param);
	smgr   = device->getSceneManager();
	driver = device->getVideoDriver();

    camera = smgr->addCameraSceneNode();
	camera->setFarValue(5000);
	camera->setNearValue(0.1f);
	camera->setFOV(1.256636f);
	camera->setID(0);
	camera->setPosition(core::vector3df(0,0,0));
	camera->setTarget(core::vector3df(0,0,1));
    camera->setAspectRatio( (float)(frame->getPanel()->GetSize().x) / (float)(frame->getPanel()->GetSize().y) );
	device->getSceneManager()->setActiveCamera(camera);
    IMeshSceneNode* cube = smgr->addCubeSceneNode(10.0f);
    cube->setName("BOX");
    cube->setPosition(core::vector3df(0,0,50));

    return true;

}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
       : wxFrame(NULL, -1, title, pos, size)
{

  wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

  m_panel6 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );

  // create text ctrl with minimal size 100x60
  topsizer->Add(
    m_panel6,
    1,            // make vertically stretchable
    wxEXPAND |    // make horizontally stretchable
    wxALL,        //   and make border all around
    0 );         // set border width to 10

  wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
  button_sizer->Add(
     new wxButton( this, wxID_OK, "OK" ),
     0,           // make horizontally unstretchable
     wxALL,       // make border all around (implicit top alignment)
     10 );        // set border width to 10
  button_sizer->Add(
     new wxButton( this, wxID_CANCEL, "Cancel" ),
     0,           // make horizontally unstretchable
     wxALL,       // make border all around (implicit top alignment)
     10 );        // set border width to 10

  topsizer->Add(
     button_sizer,
     0,                // make vertically unstretchable
     wxALIGN_CENTER ); // no border and centre horizontally

  SetSizer( topsizer );      // use the sizer for layout
  
  m_panel6->Connect( wxEVT_MOTION, wxMouseEventHandler( MyFrame::OnMotion ), NULL, this );

  topsizer->SetSizeHints( this );   // set size hints to honour minimum size

}

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(true);
}

void MyFrame::OnPaint(wxPaintEvent &event)
{
    if( driver )
    {
        camera->setAspectRatio( (float)(m_panel6->GetSize().x) / (float)(m_panel6->GetSize().y) );
        driver->beginScene(true,true,video::SColor(0,160,160,160),videodata);
        smgr->drawAll();
        driver->endScene();
    }
   event.Skip();
}

void MyFrame::OnSize(wxSizeEvent &event)
{
    if( driver )
    {
        driver->OnResize( core::dimension2d<irr::u32>(m_panel6->GetSize().x,m_panel6->GetSize().y) );
        camera->setAspectRatio( (float)(m_panel6->GetSize().x) / (float)(m_panel6->GetSize().y) );
    }
    event.Skip();
}

void MyFrame::OnMotion( wxMouseEvent& event )
{
    wxPoint currentPos = event.GetPosition();
    core::vector3df intersection;
    core::triangle3df hitTriangle;
    core::line3d<f32> line;
    line = smgr->getSceneCollisionManager()->getRayFromScreenCoordinates( core::position2d<s32>(currentPos.x,currentPos.y) );
    ISceneNode* node = smgr->getSceneCollisionManager()->getSceneNodeAndCollisionPointFromRay( line, intersection, hitTriangle );
    char buf[1024] = {0};
    if( node )
    {
        strcpy(buf,node->getName());
    }
    else
    {
        strcpy(buf,"XXX");
    }
    sprintf( &buf[strlen(buf)], " -> %d,%d", currentPos.x, currentPos.y );
    this->SetTitle(buf);
}
Post Reply