Hi,
so I am trying to get a custom GUI button working similar to this compass by vitek http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=16887
problem is, I put this on a bar that scrolls across the bottom of the screen, if the button goes past the edge of the screen, it is clipped against the screen, so it gets squeezed against the side of the screen and then fills up the entire screen if it goes completely outside the screen.
I think it is driver->setViewPort(AbsoluteRect); that clips it.
So I'm trying to do this instead by setting the mesh vertices to the rectangle position but I'm not sure what to set the transforms (ETS_VIEW etc.) to, to just draw a simple rectangle mesh.
Any suggestions?
draw to viewport getting clipped
This may help:
http://irrlicht.sourceforge.net/phpBB2/ ... 077#183077
Although the aspect ratio is wrong, you may need to change the part "setTransform(ETS_PROJECTION, ... )" to accept a projection matrix with an aspect ratio of ScreenSize.height / ScreenSize.width.
http://irrlicht.sourceforge.net/phpBB2/ ... 077#183077
Although the aspect ratio is wrong, you may need to change the part "setTransform(ETS_PROJECTION, ... )" to accept a projection matrix with an aspect ratio of ScreenSize.height / ScreenSize.width.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
yessss finally got it working, Thanks Blindside
heres the alternative to changing the view port
recti vp = driver->getViewPort();
recti mRect = meshRect - vector2di(vp.getWidth(),vp.getHeight())/2;
mRect.LowerRightCorner.Y *= -1;
mRect.UpperLeftCorner.Y *= -1;
Mesh.Vertices[0].Pos.X = mRect.UpperLeftCorner.X;
Mesh.Vertices[0].Pos.Y = mRect.LowerRightCorner.Y;
Mesh.Vertices[3].Pos.X = mRect.LowerRightCorner.X;
Mesh.Vertices[3].Pos.Y = mRect.LowerRightCorner.Y;
Mesh.Vertices[2].Pos.X = mRect.LowerRightCorner.X;
Mesh.Vertices[2].Pos.Y = mRect.UpperLeftCorner.Y;
Mesh.Vertices[1].Pos.X = mRect.UpperLeftCorner.X;
Mesh.Vertices[1].Pos.Y = mRect.UpperLeftCorner.Y;
matrix4 ProjMatrix;
ProjMatrix.buildProjectionMatrixOrthoLH(vp.getWidth(),vp.getHeight(), -100.0f, 1000.0f);
driver->setTransform(ETS_PROJECTION, ProjMatrix);
driver->setTransform(ETS_VIEW, matrix4());
driver->setTransform(ETS_WORLD, matrix4());
driver->setMaterial(Mesh.Material);
driver->drawMeshBuffer(&Mesh);
heres the alternative to changing the view port
recti vp = driver->getViewPort();
recti mRect = meshRect - vector2di(vp.getWidth(),vp.getHeight())/2;
mRect.LowerRightCorner.Y *= -1;
mRect.UpperLeftCorner.Y *= -1;
Mesh.Vertices[0].Pos.X = mRect.UpperLeftCorner.X;
Mesh.Vertices[0].Pos.Y = mRect.LowerRightCorner.Y;
Mesh.Vertices[3].Pos.X = mRect.LowerRightCorner.X;
Mesh.Vertices[3].Pos.Y = mRect.LowerRightCorner.Y;
Mesh.Vertices[2].Pos.X = mRect.LowerRightCorner.X;
Mesh.Vertices[2].Pos.Y = mRect.UpperLeftCorner.Y;
Mesh.Vertices[1].Pos.X = mRect.UpperLeftCorner.X;
Mesh.Vertices[1].Pos.Y = mRect.UpperLeftCorner.Y;
matrix4 ProjMatrix;
ProjMatrix.buildProjectionMatrixOrthoLH(vp.getWidth(),vp.getHeight(), -100.0f, 1000.0f);
driver->setTransform(ETS_PROJECTION, ProjMatrix);
driver->setTransform(ETS_VIEW, matrix4());
driver->setTransform(ETS_WORLD, matrix4());
driver->setMaterial(Mesh.Material);
driver->drawMeshBuffer(&Mesh);