- Main Page
- Classes
- Files
- Directories
- Related Pages

# glisomath.h

    00001 /*
    00002 Copyright (c) 2000-2003 Lee Thomason (www.grinninglizard.com)
    00003
    00004 Grinning Lizard Utilities. Note that software that uses the
    00005 utility package (including Lilith3D and Kyra) have more restrictive
    00006 licences which applies to code outside of the utility package.
    00007
    00008
    00009 This software is provided 'as-is', without any express or implied
    00010 warranty. In no event will the authors be held liable for any
    00011 damages arising from the use of this software.
    00012
    00013 Permission is granted to anyone to use this software for any
    00014 purpose, including commercial applications, and to alter it and
    00015 redistribute it freely, subject to the following restrictions:
    00016
    00017 1. The origin of this software must not be misrepresented; you must
    00018 not claim that you wrote the original software. If you use this
    00019 software in a product, an acknowledgment in the product documentation
    00020 would be appreciated but is not required.
    00021
    00022 2. Altered source versions must be plainly marked as such, and
    00023 must not be misrepresented as being the original software.
    00024
    00025 3. This notice may not be removed or altered from any source
    00026 distribution.
    00027 */
    00028
    00029 #ifndef ISOMATH_INCLUDED
    00030 #define ISOMATH_INCLUDED
    00031
    00032 #include "../../grinliz/gldebug.h"
    00033
    00034 /*
    00035         "Front" View, screen
    00036
    00037
    00038              ViewY
    00039   offset   |
    00040         +----------------> ScreenX
    00041         |          |            |
    00042         |          |            |
    00043         |          |            |
    00044         |----------------
    00045     v      |
    00046    SceenY  |
    00047                    |
    00048   ---------+------------> ViewX
    00049           Oview
    00050
    00051         The offset (screen offset) is measured in view coordinates
    00052         from the view origin to the offset point.
    00053
    00054
    00055         "Side" View, word
    00056
    00057         WorldZ
    00058         |
    00059         |
    00060         |     ViewY
    00061         |     /
    00062         |    /
    00063         |   /
    00064         |  /
    00065         | /
    00066         |/
    00067         +---------------------WorldY
    00068         |\_
    00069         |  \_
    00070         |    \_ ViewZ
    00071
    00072
    00073         "Top" View, Map (Should be right angles)
    00074
    00075                           WorldY
    00076                            /|\
    00077                           /     | \
    00078                          /      |  \
    00079                 MapY \  |  /Mapx
    00080                           \     | /
    00081                            \|/
    00082         ---------------------- WorldX
    00083 */
    00084
    00085 #include "../../grinliz/gltypes.h"
    00086 #include "glfixed.h"
    00087
    00088
    00114 class GlIsoMath
    00115 {
    00116   public:
    00119         static void TileToScreen(       GlFixed tileX, GlFixed tileY, GlFixed tileZ,
    00120                                                                 int tileWidth, int tileHeight,
    00121                                                                 int screenOffsetX, int screenOffsetY,
    00122                                                                 GlFixed* screenX, GlFixed* screenY );
    00123
    00127         static void ScreenToFlatTile(   GlFixed screenX, GlFixed screenY, GlFixed tileZ,
    00128                                                                         int tileWidth, int tileHeight,
    00129                                                                         int screenOffsetX, int screenOffsetY,
    00130                                                                         GlFixed* tileX, GlFixed* tileY );
    00131
    00135         static void TileToWorld(        GlFixed tileX, GlFixed tileY, GlFixed tileZ,
    00136                                                                 GlFixed* worldX, GlFixed* worldY, GlFixed* worldZ );
    00137
    00138 //      /** Tile to view.
    00139 //      */
    00140 //      static void TileToView(         GlFixed tileX, GlFixed tileY, GlFixed tileZ,
    00141 //                                                              int tileWidth, int tileHeight,
    00142 //                                                              int* viewX, int* viewY, int* viewZ );
    00143 //
    00144
    00148         GlIsoMath( int tileWidth, int tileHeight );
    00149
    00153         void SetScreenBaseToOrigin( int screenW, int screenH );
    00154
    00156         void SetScreenCenterToTile( int screenW, int screenH,
    00157                                                                 int tileX, int tileY, int tileZ );
    00158
    00160         void SetScreenToTile( int screenX, int screenY,
    00161                                                   int tileX, int tileY, int tileZ );
    00162
    00164         void TileToScreen(      GlFixed tileX, GlFixed tileY, GlFixed tileZ,
    00165                                                 int* screenX, int* screenY ) const;
    00166
    00170         void ScreenToFlatTile(  int screenX, int screenY, GlFixed tileZ,
    00171                                                         GlFixed* tileX, GlFixed* tileY ) const;
    00172
    00173   private:
    00174         int tileWidth, tileHeight;
    00175         int screenOffsetX, screenOffsetY;
    00176 };
    00177
    00178 #endif