Planeshift
texfactory.h
Go to the documentation of this file.
1 /*
2  * texfactory.h by Keith Fulton <keith@paqrat.com>
3  *
4  * Copyright (C) 2002 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 #ifndef __TEXFACT_H__
20 #define __TEXFACT_H__
21 
22 #include <csutil/parray.h>
23 #include <igraphic/image.h>
24 #include <iutil/objreg.h>
25 
26 #include "util/psxmlparser.h"
27 
28 
29 class psImageRegion;
30 
42 {
43 protected:
44 
45  iObjectRegistry* object_reg;
46 
47  csPDelArray<psImageRegion> regions; // List of psImageRegions, loaded from racelib.xml file.
48  csPDelArray<iImage> imagecache; // List of iImage's, loaded on demand and saved in a list for future use
49 
54  bool LoadRace(iDocumentNode * raceNode);
55 
60  psImageRegion *GetRegion(const char *race,const char *part);
61 
68  csPtr<iImage> GetImage(const char *race,const char *filename);
69 
70 public:
71 
74 
79  bool Initialize(iObjectRegistry* object_reg,const char *xmlfilename);
80 
87  csPtr<iImage> CreateTextureImage(const char *xmlspec);
88 };
89 
90 
95 struct psScanline
96 {
97  int x1,x2,y;
98 
99  psScanline() { x1=x2=y=0; }
100 
101  psScanline(int l,int r, int h)
102  {
103  x1=l;
104  x2=r;
105  y=h;
106  };
107 };
108 
109 
110 
119 {
120 protected:
121  csPDelArray<psScanline> scanlines;
122 
123 public:
124  csString race;
125  csString part;
126 
127  psImageRegion(const char *racename,const char *partname);
129 
130  ~psImageRegion();
131 
136  bool CreateRegion(iDocumentNode* node);
137  void AddScanline( psScanline* line ) { scanlines.Push(line); }
138 
139  psScanline* GetLine(int x);
140 
145  bool CreateRectRegion(int left, int top, int right, int bottom);
146 
154  void OverlayRegion(iImage *dest, iImage *src,int bitmode=0);
155 };
156 
159 #endif
160 
bool LoadRace(iDocumentNode *raceNode)
Loads an XML section of zero or more region tags.
iObjectRegistry * object_reg
Definition: texfactory.h:45
csPtr< iImage > GetImage(const char *race, const char *filename)
Returns a pointer to an iImage specified by the race and filename.
csString race
Definition: texfactory.h:124
csPtr< iImage > CreateTextureImage(const char *xmlspec)
Takes an xml string specifying race textures and part textures, finds the relevant regions and images...
This class stores all required info for a particular region.
Definition: texfactory.h:118
csString part
Definition: texfactory.h:125
This class reads in the xml file defining regions and maintains the preload list of textures...
Definition: texfactory.h:41
void AddScanline(psScanline *line)
Definition: texfactory.h:137
psImageRegion * GetRegion(const char *race, const char *part)
Returns a pointer to a race-specific texture region.
csPDelArray< psImageRegion > regions
Definition: texfactory.h:47
psScanline(int l, int r, int h)
Definition: texfactory.h:101
csPDelArray< iImage > imagecache
Definition: texfactory.h:48
csPDelArray< psScanline > scanlines
Definition: texfactory.h:121
bool Initialize(iObjectRegistry *object_reg, const char *xmlfilename)
This function loads the xml file and cycles through the race tags, calling LoadRace() for each one to...
This struct just stores the left and right side of each line in a psRegion.
Definition: texfactory.h:95