Hi folks !
I work on a board game project. I use some GUI stuff and I use billboards (or quad) for any other animation. For sure, as you expect, everything (or nearly) is 2D. This is a board game. The idea is that the player (camera) is over the board (top view).
QUESTION: In all game, we need a CAMERA to see the scene. In my case, I put the board in a 3D world on Z = 0, so everything is easy to me to put all graphical object in the plan XY (z = 0). My camera is somewhere like Z = -100 in order to see the board and all elements.
Is it other way to do it ?
Other question: I design it in order to see all elements in 1440x900 pixels format and the camera is fixed. I am not sure what I am supposed to do if the player changes the resolution... like going in 800x600 mode. Do I need to move the camera ?
Thank you.
Board game (like card game or Monopoly), CAMERA ISSUE
-
- Posts: 54
- Joined: Thu Oct 25, 2007 1:38 pm
- Location: Montreal, Canada
do you want/need to do it differently? It seems like a fine solution to me so unless you've got problems i'd stick with it.
you could try changing the resolution and seeing if the camera needs moving, but it shouldn't as you're not changing how much is drawn, just at what resolution it's drawn. so at a higher resolution you see exactly the same amount just at a higher quality/onscreen size.
one thing you might have to consider is widescreen/multiple monitors.
you could try changing the resolution and seeing if the camera needs moving, but it shouldn't as you're not changing how much is drawn, just at what resolution it's drawn. so at a higher resolution you see exactly the same amount just at a higher quality/onscreen size.
one thing you might have to consider is widescreen/multiple monitors.
-
- Posts: 54
- Joined: Thu Oct 25, 2007 1:38 pm
- Location: Montreal, Canada
Thanks.
Thank you JP !
I just wanna be sure that I was not wrong. Every book I read talk about 3D, nothing more about 2D. So I was looking for the good technique. I will continue this way and see what happen with resolution change.
Thanks.
I just wanna be sure that I was not wrong. Every book I read talk about 3D, nothing more about 2D. So I was looking for the good technique. I will continue this way and see what happen with resolution change.
Thanks.
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
If you use an orthographic camera, your object sizes will be consistent fractions of whatever view size you specify. As you're doing a 2d visualisation, an orthographic projection is probably more suitable anyway.
This example uses 2 viewports just to show two different 'screen' resolutions at the same time. You generally don't have to mess around with viewports: the important part is setting an orthogonal camera projection matrix, and sizing and positioning your objects using an appropriate fraction of the widthOfViewVolume and heightOfViewVolume that you set in the orthogonal matrix.
This example uses 2 viewports just to show two different 'screen' resolutions at the same time. You generally don't have to mess around with viewports: the important part is setting an orthogonal camera projection matrix, and sizing and positioning your objects using an appropriate fraction of the widthOfViewVolume and heightOfViewVolume that you set in the orthogonal matrix.
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment(lib, "Irrlicht.lib")
#define IRRLICHT_SVN_OR_1_5 0
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_OPENGL, dimension2d<s32>(800, 800));
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
// Use 2 viewports, one 800 x 600 (4:3), one 355 x 200 (16:9)
rect<s32> viewPort1(0, 0, 800, 600);
rect<s32> viewPort2(0, 600, 355, 800);
// Build an orthogonal matrix that says the screen is 100 x 100. This means that an object
// that is 100 x 100 will exactly fill the screen (or in this case, viewport) regardless
// of how big (in pixels) the screen or viewport actually is.
matrix4 orthogonalMatrix;
orthogonalMatrix.buildProjectionMatrixOrthoLH(100.f, 100.f, 1.f, 50.f);
// Add a cameras
ICameraSceneNode * camera = smgr->addCameraSceneNode();
camera->setPosition(vector3df(0, 0, -20));
// Now make the camera orthographic. The method to do that has changed since 1.4.2
#if IRRLICHT_SVN_OR_1_5
camera->setProjectionMatrix(orthogonalMatrix, true); // SVN / Irrlicht 1.5
#else
camera->setProjectionMatrix(orthogonalMatrix); // <= 1.4.2
camera->setIsOrthogonal(true);
#endif
// Create one billboard that is 25% and 50% of the height and width of the orthogonal view
// size, and offset 25% to the left and above screen centre.
scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
bill->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setPosition(vector3df(-25.f, 25.f, 0.f));
bill->setSize(core::dimension2d<f32>(25.f, 50.f));
while(device->run())
{
driver->beginScene(true, true, SColor(255,100,101,140));
// Reset the viewport to the whole screen
driver->setViewPort(rect<s32>(0, 0, driver->getScreenSize().Width, driver->getScreenSize().Height));
// And draw a background in each viewport so that we can see their bounds.
driver->draw2DRectangle(SColor(255, 255, 0, 0), viewPort1);
driver->draw2DRectangle(SColor(255, 0, 255, 0), viewPort2);
// Now render to the first viewport.
driver->setViewPort(viewPort1);
smgr->drawAll();
// And render the same scene to the second viewport, with a different pixel resolution.
driver->setViewPort(viewPort2);
smgr->drawAll();
// Note that in both viewports, the billboard takes up the same proportion of the 'screen'
// and is at the same relative position.
driver->endScene();
}
device->drop();
return 0;
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Posts: 54
- Joined: Thu Oct 25, 2007 1:38 pm
- Location: Montreal, Canada
great !
Wow great !
For sure I will try this. This is what I am looking for, keeping good looking, good sizing, proportionnal design, etc. even if we change the resolution of the screen.
Thank you a lot !
For sure I will try this. This is what I am looking for, keeping good looking, good sizing, proportionnal design, etc. even if we change the resolution of the screen.
Thank you a lot !
Re: Board game (like card game or Monopoly), CAMERA ISSUE
for the 3d scene, yes...Danny Gilbert wrote:In all game, we need a CAMERA to see the scene.
if you only use gui and 2d elements, then no...
but you choose 3d elements, so yes...
so the board is "standing" before the camera and you move back...Danny Gilbert wrote:In my case, I put the board in a 3D world on Z = 0, so everything is easy to me to put all graphical object in the plan XY (z = 0). My camera is somewhere like Z = -100 in order to see the board and all elements.
you're not looking top-down, in Irrlicht Y is up !!!
no, I would not, it's OK...Danny Gilbert wrote:Is it other way to do it ?
maybe if you want to use physics, but even then not neccessarily...
why not give the user the option to zoom in-out, maybe with the mouse wheel !?!?!Danny Gilbert wrote:I design it in order to see all elements in 1440x900 pixels format and the camera is fixed. I am not sure what I am supposed to do if the player changes the resolution... like going in 800x600 mode. Do I need to move the camera ?
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 54
- Joined: Thu Oct 25, 2007 1:38 pm
- Location: Montreal, Canada
Screen resolution ratio
Ok I did the code proposed by rogerborg... it's very fine. Now my question or comments is the following. When we change the screen resolution, the ratio is not always the same. A screen of about 1440x900 pixel has a ratio of 1.6 and a screen resolution of 800x600 is 1.33.
I execute the code of Rogerborg and all images are at the good position (the game keep its "global form" because it uses percentage or relative position. But, when I changed the RATIO (the screen resolution), all image are DIFFORMED. I think I must have a second set of TEXTURE or I need to "resize" all my components with the good ratio in order to keep a good looking.
Is it true or I don't understand something ?
I am trying now to create a "virtual world" of size 2048x2048.
As an exemple: I have a card of 256x512. My "maximum resolution" that I want to support is 1440x900 (my laptop screen), so a CreateDevice() with a size of 1440x900. I create only ONE VIEWPORT of 1440x900 and my card picture is perfect. If I change the size of the CreateDevice() like 800x600 and also the viewport to 800x600, the GAME "architecture" is the same (my drawings are at good position) but they are "DIFFORMED". The aspect of the billboard and its texture is not good like the original one.
There is something that I am not sure to understand....
Sorry for my english.
Thanks for your help !
I think this is a good TOPIC for anybody who wants to design game.
I execute the code of Rogerborg and all images are at the good position (the game keep its "global form" because it uses percentage or relative position. But, when I changed the RATIO (the screen resolution), all image are DIFFORMED. I think I must have a second set of TEXTURE or I need to "resize" all my components with the good ratio in order to keep a good looking.
Is it true or I don't understand something ?
I am trying now to create a "virtual world" of size 2048x2048.
As an exemple: I have a card of 256x512. My "maximum resolution" that I want to support is 1440x900 (my laptop screen), so a CreateDevice() with a size of 1440x900. I create only ONE VIEWPORT of 1440x900 and my card picture is perfect. If I change the size of the CreateDevice() like 800x600 and also the viewport to 800x600, the GAME "architecture" is the same (my drawings are at good position) but they are "DIFFORMED". The aspect of the billboard and its texture is not good like the original one.
There is something that I am not sure to understand....
Sorry for my english.
Thanks for your help !
I think this is a good TOPIC for anybody who wants to design game.
maybe set the aspect ratio of the camera to the one the screen has ???
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 54
- Joined: Thu Oct 25, 2007 1:38 pm
- Location: Montreal, Canada