Sign in to follow this  
LackOfGrace

2D matrix warp

Recommended Posts

im developing a simple 2d space game for simple testing of parallax backgrounds and space limitation ( more on that later ) in my 2d engine. getting a quick draft up was easy ( the math isn't too hard ;) ) so, i got the parallax functionality up and running and i got the limitation to work by limitation i mean that as an example a star should warp to the other side of the screen if it went outside creating an illusion of an endless star field problems arose when i started rotating the camera the stars would get all jumbled up ( looked like a snowstorm ) i found that the problem was my render state matrix ( which is a 4x4 transformation matrix ), and i cant for the moment wrap my head around how to elegantly solve this problem. the current solution i have is to transform a vector with the current matrix, check if it is outside the min/max for the globally vertical and horizontal axis, and then reflect this vector for the given axis. finally plugging this vector back into the matrix. but this really looks quite bad and it gives me pretty many costly matrix operations since i want to separate the horizontal and vertical warping to different values effectively doubling the amount of matrix calculations. anyway, im sure you guys here could shed some light or just give me some criticism

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this