Matrices - Strange results

Hello, I have spent a while writing a sort of game engine to learn more about OpenGL. About a month ago I started changing the way the system rendered and performed transformations and ended up making my own matrices class to handle the transformations. I don’t want to use any libraries as this will not help me learn about matrices. I posted a question on this with more information here: java - OpenGL Matrices Strange Transformations - Stack Overflow but haven’t got a single answer. I am using Java and LWJGL but the problem is more to do with the matrices themselves. When I try to render a cube, it ends up being completely distorted, I can never go be hind it and it just stretches in weird ways, translation doesn’t work, nor does rotation. Thank you.

Hey i’ve recently done the same thing as you but i initially used the built in Matric4f libraries. I changed my mesh rotation to use Quaternions instead of euler rotation because im implementing skeletal animations and it just makes my life easier. Here’s a very helpful link that will teach you about Quaternions. www.cprogramming.com/tutorial/3d/quaternions.html. Instead of the matrix libraries doing the work. you manually have to do the math. Youl see what i mean. Good luck!

if you calculate your matrics very well make sure that you are using this equation

Position = ProjectionMatrix * ViewMatrix * Transform

don’t change the organization of equation (ProjectionMatrix * ViewMatrix * Transform)

Thank you, I will need to look into it but it looks like it will be very useful and this will fix an issue I the rotation. However I have tried removing the rotation all together using comments and it doesn’t seem to cause all of the stretching and strange behavior caused by translating the view any where, I am wondering whether it might be caused by the projection matrix being calculated in the wrong way.

[QUOTE=DragonForce99;1262372]if you calculate your matrics very well make sure that you are using this equation

Position = ProjectionMatrix * ViewMatrix * Transform

don’t change the organization of equation (ProjectionMatrix * ViewMatrix * Transform)
[/QUOTE]

I have looked into it, currently I am using this:

	Matrix4D projectionViewMatrix = Matrix.multiplyMatrices(Matrix.projectionMatrix, Matrix.viewMatrix);
	Matrix.modelViewProjectionMatrix = (Matrix.multiplyMatrices(projectionViewMatrix, Matrix.modelMatrix));

to calculate the final matrix before passing it to the shader, is it possible this is the wrong way round?

i dont know about your matrix you may need to transpose it … what ever you got a problem and you have to makesure that you final resulat is currently
i recomend you to use GLM library its vary good math for opengl

Thank you for helping, I finally fixed it. Firstly the matrix needed to be transposed, but my own code to do that was slightly wrong, and secondly the znear value of the perspective matrix was set to 0.1 which works when using GLU but not when using these sorts of matrices, thank you so much for your help. :smiley:

good for you :smiley: