|
3D Version of "al_transform_coordinates()"? |
RPG Hacker
Member #12,492
January 2011
|
Hey there! I was looking a lot into the transformation system of Allegro 5.1 lately (especially the 3D transformations). I thought it would be fun to use this system to make some kind of pseudo 3D game, comparable to those on the SNES (like Mario Kart or maybe the overworld in some RPGs). However, this could be quite difficult since you would have to combine a lot of different transformations and stuff (basically, levels would have to be rotated by 90° degrees, whereas sprites would have to be standing upright). The only thing I could successfully do so far was to draw a 2D image, rotate it by 90° around the X-axis and move the camera around. I thought that a 3D version of al_transform_coordinates() could be really useful for this (to place sprites on the map correctly). So does someone know how to make such a function easily? Or alternatively: Does someone know a good way to combine different transformations for this kind of 3D view? Also, is there an easy way to tile some graphic "infinitely" using these transformations to fill the area that lies outside of your image, or do you have to do that manually? Just think about how Mario Kart filled the space outside the map with grass or animated water. EDIT: EDIT: 1void transform_coordinates_3d(const ALLEGRO_TRANSFORM *trans, float *x, float *y, float *z)
2{
3 float t;
4
5 t = *x;
6
7 *x = t * trans->m[0][0] + *y * trans->m[1][0] + trans->m[3][0];
8 *y = t * trans->m[0][1] + *y * trans->m[1][1] + trans->m[3][1];
9 *z = t * trans->m[0][2] + *y * trans->m[1][2] + trans->m[3][2];
10}
I just added the last line. Don't know if this is really correct, but so far it seems to be working. Now I just hope I did the hot-linking to the docs correctly so that people will find this in the future... Testing: EDIT:
|
|