Release SHMUP


mcobit

Advanced Member
Joined
Jul 28, 2008
Messages
6,910
I was able to rotate the 2D stuff with this, but the 3D stuff is drawn with GLU and I have no clue how that works.
 

lunixbochs

Moderator
Staff member
Joined
Sep 18, 2011
Messages
742
Try swapping the right and up vectors in camera.c - looks like that's the only place they're defined.
 

mcobit

Advanced Member
Joined
Jul 28, 2008
Messages
6,910
I just really realized, that I would need to swap the axis of all the logic in the game, too to make it playable... might take a bit longer...
 

crow_riot

Well-Known Member
Joined
Sep 21, 2009
Messages
1,763
Location
.at
there are 2 steps required:

you need to rotate the projection matrix ... thats what i do in apkenv for cut the rope and also on my iphone projects. and you also need to swap width and height when calculating pixel aspect.

looking into the source, it's not as easy adding 'glRotatef', cause SHMUP is using its own matrix calculations. the function that should be modified is in renderer.c:

void gluPerspective(float fovy,float aspect, float zNear, float zFar,matrix_t projectionMatrix);to something like this

Code:
//http://en.wikipedia.org/wiki/Rotation_matrix]http://en.wikipedia.org/wiki/Rotation_matrix

static void createRotationMatrixZ(float angle, matrix_t rotation_matrix)
{
  float radians = angle * M_PI / 180.f;

  float c = cos(radians);
  float s = sin(radians);

  rotationMatrix[0]= c; rotationMatrix[4] = -s; rotationMatrix[ 8] = 0; rotationMatrix[12] = 0;
  rotationMatrix[1]= s; rotationMatrix[5] = c; rotationMatrix[ 9] = 0; rotationMatrix[13] = 0;
  rotationMatrix[2]= 0; rotationMatrix[6] = 0; rotationMatrix[10] = 1; rotationMatrix[14] = 0;
  rotationMatrix[3]= 0; rotationMatrix[7] = 0; rotationMatrix[11] = 0; rotationMatrix[15] = 1;
}

// "optimized" versions
static void createRotationMatrixRotateLeft(matrix_t rotation_matrix)
{
  rotationMatrix[0]= 0; rotationMatrix[4] = -1; rotationMatrix[ 8] = 0; rotationMatrix[12] = 0;
  rotationMatrix[1]= 1; rotationMatrix[5] = 0; rotationMatrix[ 9] = 0; rotationMatrix[13] = 0;
  rotationMatrix[2]= 0; rotationMatrix[6] = 0; rotationMatrix[10] = 1; rotationMatrix[14] = 0;
  rotationMatrix[3]= 0; rotationMatrix[7] = 0; rotationMatrix[11] = 0; rotationMatrix[15] = 1;
}

static void createRotationMatrixRotateRight(matrix_t rotation_matrix)
{
  rotationMatrix[0]= 0; rotationMatrix[4] = 1; rotationMatrix[ 8] = 0; rotationMatrix[12] = 0;
  rotationMatrix[1]=-1; rotationMatrix[5] = 0; rotationMatrix[ 9] = 0; rotationMatrix[13] = 0;
  rotationMatrix[2]= 0; rotationMatrix[6] = 0; rotationMatrix[10] = 1; rotationMatrix[14] = 0;
  rotationMatrix[3]= 0; rotationMatrix[7] = 0; rotationMatrix[11] = 0; rotationMatrix[15] = 1;
}

void gluPerspective(float fovy, float aspect, float zNear, float zFar,matrix_t projectionMatrixRotated)
{
  aspect = 1/aspect; //swap with/height

  matrix_t rotation_matrix; //holds the rotation matrix
  matrix_t projectionMatrix;
  createRotationMatrixRotateLeft(rotation_matrix);
  // could also be:
  // createRotationMatrixRotateRight(rotation_matrix);


  float f = (float)(1 / tan(fovy*DEG_TO_RAD/2));
  projectionMatrix[0]= f/aspect; projectionMatrix[4]= 0; projectionMatrix[ 8]= 0; projectionMatrix[12]= 0;
  projectionMatrix[1]= 0; projectionMatrix[5]= f; projectionMatrix[ 9]= 0; projectionMatrix[13]= 0;
  projectionMatrix[2]= 0; projectionMatrix[6]= 0; projectionMatrix[10]=(zFar+zNear)/(zNear-zFar) ; projectionMatrix[14]= 2*(zFar*zNear)/(zNear-zFar);
  projectionMatrix[3]= 0; projectionMatrix[7]= 0; projectionMatrix[11]=-1; projectionMatrix[15]= 0;


  matrix_multiply(rotation_matrix, projectionMatrix, projectionMatrixRotated);
  // could also be:
  // matrix_multiply(projectionMatrix, rotationMatrix, projectionMatrixRotated);

}
i don't know if that works out, but it's worth a try?
additionally you might want to swap input axis, too ...
 
Last edited by a moderator:

mcobit

Advanced Member
Joined
Jul 28, 2008
Messages
6,910
I just really realized, that I would need to swap the axis of all the logic in the game, too to make it playable... might take a bit longer...
Nope, do as Linuxbochs said (line 146 to 158) and it should work.
Unfortunately this is not enough as most of the stuff is rotated than, but enemies are not. Will try crowriots suggestion.

The input is also not rotated.
 
Last edited by a moderator:

sebt3

homebrew player (P. & C.)
Joined
Sep 9, 2008
Messages
4,885
Age
42
Location
France
Website
sebt3.openpandora.org
Unfortunately this is not enough as most of the stuff is rotated than, but enemies are not. Will try crowriots suggestion.

The input is also not rotated.
Arf :( From my look at the sources, I would have done the same bet as linuxbochs. but crow's idea sound good too.
The input rotation should'nt be too hard, especially when *you* have written a good part of it
 

mcobit

Advanced Member
Joined
Jul 28, 2008
Messages
6,910
Well, it is not only the input logic, but the whole game logic. From what I think, the picture will be rotated, but all the ships will still have the same orientation and bullets, that are drawn will not hit them.

Everything seems to be drawn seperately...

With the cameravectors swapped, the 2D stuff doesn't get rotated, and only a portion of the 3D stuff.

It is easy to change the aspect ratio to have a stretched fullscreen but well, it looks stretched.
 
Last edited by a moderator:

crow_riot

Well-Known Member
Joined
Sep 21, 2009
Messages
1,763
Location
.at
if you rotate the projection matrix, the game logic is not touched. everything should work, it's just rotated.

i haven't found the part of the code where the 2d stuff gets set up, but you can apply the same method i suggested for the orthographic projection.
 
Last edited by a moderator:

Monkfish

Active Member
Joined
May 8, 2012
Messages
724
Age
38
Location
England
really good fun, i love the difficulty - i'd say its less of a curve and more of a line straight up but thats how i like this kind of game. For some reason it reminds me of Ikaruga, i loved that game too! i really hope i get some more free time to play this its addictive as hell (even moreso than Transdimensional Hellspiders). Great stuff!
 

Monkfish

Active Member
Joined
May 8, 2012
Messages
724
Age
38
Location
England
got no easy way of recording vids otherwise i'd take you up on that score attack challenge, might even be worthy of a new thread.
 
Top