Why is my screen centered 0,0 in the middle of screen?

Started by
20 comments, last by MARS_999 10 years, 10 months ago

I would expect [0, 0] to be the upper-left, not the lower-left.

In any case, using the new projection matrix, [400, 300] is exactly the same as [0, 0] in the previous projection matrix (center of the screen).

I would suggest using that as your test case as it may very well be that your particles are all shooting upwards and since your Y is 0, all particles start at the top of the screen and fly even further off the top of the screen, meaning you can never see them.

L. Spiro

I don't think so, I changed to Z axis and tried 0,0,0 for the position and it's still at center of screen... If I use 10,0,0 it move way over to the right side barely visible...

So for some reason the uploaded projection matrix isn't working?

Advertisement

I see a bunch of preparation code but no draw call. By the time the draw call is issued you probably have a perspective matrix applied. If the particles get small as you increase/decrease their Z then you have a perspective projection.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

I see a bunch of preparation code but no draw call. By the time the draw call is issued you probably have a perspective matrix applied. If the particles get small as you increase/decrease their Z then you have a perspective projection.

L. Spiro

i am using this example.

http://irrlicht.sourceforge.net/docu/example008.html

they have no draw*() calls...

thanks

That example creates a camera. If you are creating a camera in your code as well (following the example) then the camera will probably overwrite your direct driver::setTransform() calls during scene rendering. Why are you trying to bypass the built-in camera system and setting driver transform state directly? Just create an ICameraSceneNode as in the example, and manipulate that to get your desired perspective and view transforms. ICameraSceneNode even includes a method for setting the projection matrix directly.

I am not using any camera at all in my code. I am just keeping the camera at 0,0,0 and rendering a screen and just want to work with the screen coordinates in x,y ortho view. This is a simple 2d game that never moves the camera...

Hello Josh!!!

Yes, but the scene manager applies the camera's projection before rendering the scene, so any projection mucking you've done prior the the scene being rendered gets undone. You need to set the camera's projection matrix to ortho instead of mucking about with the device directly as JTippetts pointed out.

I am using this code.

    irr::core::matrix4 projMatrix;
    projMatrix = projMatrix.buildProjectionMatrixOrthoRH(config.screenSize.Width, config.screenSize.Height, 1.0f, 100.0f);
    camera->setProjectionMatrix(projMatrix, true);

and no luck...

Thanks!

The main point is that we don’t know what happens inside the camera class in Irrlicht, so we don’t know what to make of the evidence, frankly.

There could be a number of things that would cause that matrix to be overwritten by the camera class itself.

Evidence suggests that a perspective projection is what gets fed to the graphics card at the end of the day, so you need to be searching by yourself for how that could possibly happen. While you continue trying things to correct this problem, if they don’t work you need to think about “what else” could cause the problem to persist. In this case, my first reaction would be to say that something is overwriting the camera matrix afterwards. After all, you are changing things on your end, but the visual result is the same, so it must follow that your changes have either no meaning to the end result or are overwritten.

All you can do from there is keep reading about Irrlicht and keep trying your own experiments.

The secondary point is that “projMatrix = ” is superfluous. Since I have seen the source code I know that that method modifies itself, and then returns itself. Then you make a copy of itself into itself. It’s not necessary to receive the return value from projMatrix.buildProjectionMatrixOrthoRH(); by the time it returns, projMatrix has already been filled with the correct values.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

http://irrlicht.sourceforge.net/forum/viewtopic.php?f=1&t=48813

I have made some progress, but please look at the link above and read the last two posts.... It seems like I have to use half width to get the object on screen now... and Y is upside down DX upper left 0,0 vs. GL bottom left 0,0

I think you need some clarification. If your view and projection matricies are identities (not set), you get an orthogonal observation and your screen will contain only objects that are in -1 , 1 scope. That is, that if you have object of 4 verticies with values in object space (the object space equals your projection space now) such as 1.0,0.0, it will be placed at vertical center and at right edge of screen, and 0.0,0.0 will be placed at the center, -1.0,1.0 is the upper left corner. Do not confuse this with placing at screen resolution coordinates, 100,100 will place the thing 100 screens to the right up! If you want to place by screen pixel width height, divide by dimensions of screen then. Also realize that ortho camera has its certain scope of view, so if you devide everything by some value, say 1000, then you will be observing 1000.0,-1000.0 square, thus then -1000.0,1000.0 is your upper left corner. You cans still apply some world matricies to the objects. Also finaly, ortho camera may have rotation but this is often not desired, but ortho camera may need translation. So you should set up a view matrix with translation only, and apply that matrix. So in the end you are using only world matrcies per object, view matrix with only translation, and a projection matrix that only scales thing down by a single division. Possibly

This topic is closed to new replies.

Advertisement