ItemSorter.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2003-2005 The Pentagram team
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef ITEMSORTER_H
00020 #define ITEMSORTER_H
00021 
00022 #include <vector>
00023 
00024 class MainShapeArchive;
00025 class Item;
00026 class RenderSurface;
00027 struct SortItem;
00028 
00029 class ItemSorter
00030 {
00031         MainShapeArchive        *shapes;
00032         RenderSurface   *surf;
00033 
00034         uint32          max_items;
00035         uint32          num_items;
00036         uint32          num_extra;
00037         SortItem        *items;
00038         sint32          sort_limit;
00039 
00040         sint32          order_counter;
00041 
00042         sint32          cam_sx, cam_sy;
00043 
00044 public:
00045         ItemSorter(int Max_Items = 2048);
00046         ~ItemSorter();
00047 
00048         enum HitFace {
00049                 X_FACE, Y_FACE, Z_FACE
00050         };
00051 
00052         // Begin creating the display list
00053         void BeginDisplayList(RenderSurface*,
00054                                                   sint32 camx, sint32 camy, sint32 camz);
00055 
00056         void AddItem(sint32 x, sint32 y, sint32 z, uint32 shape_num, uint32 frame_num, uint32 item_flags, uint32 ext_flags, uint16 item_num=0);
00057         void AddItem(Item *);                                   // Add an Item. SetupLerp() MUST have been called
00058 
00059         void PaintDisplayList(bool item_highlight=false);                               // Finishes the display list and Paints
00060 
00061         // Trace and find an object. Returns objid.
00062         // If face is non-NULL, also return the face of the 3d bbox (x,y) is on
00063         uint16 Trace(sint32 x, sint32 y, HitFace* face = 0, bool item_highlight=false );
00064 
00065         void IncSortLimit() { sort_limit++; }
00066         void DecSortLimit() { if (sort_limit > 0) sort_limit--; }
00067 
00068 private:
00069         bool PaintSortItem(SortItem     *);
00070         bool NullPaintSortItem(SortItem *);
00071 };
00072 
00073 
00074 #endif //ITEMSORTER_H

Generated on Fri Jul 27 22:27:22 2007 for pentagram by  doxygen 1.4.7