Planeshift
pawsobjectview.h
Go to the documentation of this file.
1 /*
2  * pawsobjectview.h - Author: Andrew Craig
3  *
4  * Copyright (C) 2003 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 
20 #ifndef PAWS_OBJECT_VIEW_HEADER
21 #define PAWS_OBJECT_VIEW_HEADER
22 
23 #include <iengine/rendermanager.h>
24 #include <iengine/camera.h>
25 #include <iengine/engine.h>
26 #include <iengine/light.h>
27 #include <iengine/material.h>
28 #include <iengine/mesh.h>
29 #include <iengine/movable.h>
30 #include <iengine/sector.h>
31 
32 #include <imesh/object.h>
33 
34 #include <cstool/csview.h>
35 #include <csutil/csstring.h>
36 #include <csutil/leakguard.h>
37 #include <ibgloader.h>
38 #include "pawswidget.h"
39 
40 class psCharAppearance;
41 struct iBgLoader;
42 
49 class pawsObjectView : public pawsWidget
50 {
51 public:
54 
58  void View(iMeshWrapper* wrapper);
59 
63  void View(iMeshFactoryWrapper* wrapper);
64 
68  bool View(const char* factName);
69 
72  bool Setup(iDocumentNode* node);
73 
82  bool LoadMap(const char* map, const char* sector);
83 
87  bool ContinueLoad(bool onlyMesh = false);
88 
93  bool CreateMap();
94 
95  void Clear();
96 
97  void Draw();
98  void Draw3D(iGraphics3D*);
99 
100  void OnResize();
101 
102  iMeshWrapper* GetObject()
103  {
104  return mesh;
105  }
106 
107  bool OnMouseDown(int button,int mod, int x, int y);
108  bool OnMouseUp(int button,int mod, int x, int y);
109  bool OnMouseExit();
110 
111  void Rotate(int speed,float radians); // Starts a rotate each {SPEED} ms, taking {RADIANS} radians steps
112  void Rotate(float radians); // Rotate the object "staticly"
113 
114  void EnableMouseControl(bool v)
115  {
116  mouseControlled = v;
117  }
118 
119  void SetCameraPosModifier(csVector3 &mod)
120  {
121  cameraMod = mod;
122  }
123  csVector3 &GetCameraPosModifier()
124  {
125  return cameraMod;
126  }
127 
128  void LockCamera(csVector3 where, csVector3 at, bool mouseDownUnlock = false, bool mouseDownRotate = false);
129  void UnlockCamera();
130 
132  void SetID(unsigned int id)
133  {
134  ID = id;
135  }
136  unsigned int GetID()
137  {
138  return ID;
139  }
140 
142  {
143  charApp = cApp;
144  }
146  {
147  return charApp;
148  }
149 
150 private:
151  void DrawRotate();
152  void DrawNoRotate();
153 
154  bool needsDraw;
155  bool cameraLocked;
156  bool doRotate;
157  bool mouseDownUnlock;
158  bool mouseDownRotate;
159  csVector3 cameraPosition;
160  csVector3 lookingAt;
161 
162  csVector3 oldPosition;
163  csVector3 oldLookAt;
164 
165  bool CreateArea();
166 
167  bool spinMouse;
168  csVector2 downPos;
169  float orgRadians;
170  int orgTime;
171  int downTime;
172  bool mouseControlled;
173 
174  csRef<iBgLoader> loader;
175  csRef<iSector> stage;
176  csRef<iView> view;
177  csRef<iEngine> engine;
178  csRef<iRenderManagerTargets> rmTargets;
179  csRef<iMeshWrapper> mesh;
180  csRef<iSector> meshSector;
181  csRef<iView> meshView;
182  csRef<iTextureHandle> stageTarget;
183  csRef<iTextureHandle> meshTarget;
184  psCharAppearance* charApp;
185 
186  csVector3 objectPos;
187  csVector3 cameraMod;
188 
189  void RotateDef(); // Used to reset to the values given by the controlling widget
190  void RotateTemp(int speed,float radians); // Used to for example stop the rotate but not write the def values
191 
192  float distance;
193  float origDistance;
194 
195  int rotateTime;
196  float rotateRadians;
197  float camRotate;
198 
199  unsigned int ID;
200 
201  csRef<iThreadReturn> meshFactory;
202 };
204 
205 
208 #endif
void Draw()
Draws the widget and all of it&#39;s children.
int id
The id of the widget.
Definition: pawswidget.h:127
CREATE_PAWS_FACTORY(pawsObjectView)
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
bool CreateMap()
Creates a default map.
This widget is used to view a mesh in it&#39;s own seperate world.
void SetCharApp(psCharAppearance *cApp)
bool OnMouseDown(int button, int mod, int x, int y)
Manage mouse down event to test for and apply window changes.
bool OnMouseExit()
Called whenever the mouse leaves this widget.
bool LoadMap(const char *map, const char *sector)
Loads a map to use as the backdrop.
bool Setup(iDocumentNode *node)
Creates the room ( world ) for the mesh to be placed.
A manager class that handles all the details of a characters appearance.
Definition: charapp.h:65
void SetID(unsigned int id)
Assign this view an ID.
void Draw3D(iGraphics3D *)
void LockCamera(csVector3 where, csVector3 at, bool mouseDownUnlock=false, bool mouseDownRotate=false)
void UnlockCamera()
void EnableMouseControl(bool v)
psCharAppearance * GetCharApp()
void OnResize()
Sets the new position of the close button.
iMeshWrapper * GetObject()
unsigned int GetID()
bool OnMouseUp(int button, int mod, int x, int y)
Manage mouse up event.
void View(iMeshWrapper *wrapper)
Make a copy of this mesh to view.
csVector3 & GetCameraPosModifier()
void Rotate(int speed, float radians)
void SetCameraPosModifier(csVector3 &mod)
bool ContinueLoad(bool onlyMesh=false)
Continues an existing map load.