Planeshift
|
00001 /* 00002 * pawsobjectview.h - Author: Andrew Craig 00003 * 00004 * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 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 00020 #ifndef PAWS_OBJECT_VIEW_HEADER 00021 #define PAWS_OBJECT_VIEW_HEADER 00022 00023 #include <iengine/rendermanager.h> 00024 #include <iengine/camera.h> 00025 #include <iengine/engine.h> 00026 #include <iengine/light.h> 00027 #include <iengine/material.h> 00028 #include <iengine/mesh.h> 00029 #include <iengine/movable.h> 00030 #include <iengine/sector.h> 00031 00032 #include <imesh/object.h> 00033 00034 #include <cstool/csview.h> 00035 #include <csutil/csstring.h> 00036 #include <csutil/leakguard.h> 00037 #include <ibgloader.h> 00038 #include "pawswidget.h" 00039 00040 class psCharAppearance; 00041 struct iBgLoader; 00042 00049 class pawsObjectView : public pawsWidget 00050 { 00051 public: 00052 pawsObjectView(); 00053 ~pawsObjectView(); 00054 00058 void View(iMeshWrapper* wrapper); 00059 00063 void View(iMeshFactoryWrapper* wrapper); 00064 00068 bool View(const char* factName); 00069 00072 bool Setup(iDocumentNode* node); 00073 00082 bool LoadMap(const char* map, const char* sector); 00083 00087 bool ContinueLoad(bool onlyMesh = false); 00088 00093 bool CreateMap(); 00094 00095 void Clear(); 00096 00097 void Draw(); 00098 void Draw3D(iGraphics3D*); 00099 00100 void OnResize(); 00101 00102 iMeshWrapper* GetObject() 00103 { 00104 return mesh; 00105 } 00106 00107 bool OnMouseDown(int button,int mod, int x, int y); 00108 bool OnMouseUp(int button,int mod, int x, int y); 00109 bool OnMouseExit(); 00110 00111 void Rotate(int speed,float radians); // Starts a rotate each {SPEED} ms, taking {RADIANS} radians steps 00112 void Rotate(float radians); // Rotate the object "staticly" 00113 00114 void EnableMouseControl(bool v) 00115 { 00116 mouseControlled = v; 00117 } 00118 00119 void SetCameraPosModifier(csVector3 &mod) 00120 { 00121 cameraMod = mod; 00122 } 00123 csVector3 &GetCameraPosModifier() 00124 { 00125 return cameraMod; 00126 } 00127 00128 void LockCamera(csVector3 where, csVector3 at, bool mouseDownUnlock = false, bool mouseDownRotate = false); 00129 void UnlockCamera(); 00130 00132 void SetID(unsigned int id) 00133 { 00134 ID = id; 00135 } 00136 unsigned int GetID() 00137 { 00138 return ID; 00139 } 00140 00141 void SetCharApp(psCharAppearance* cApp) 00142 { 00143 charApp = cApp; 00144 } 00145 psCharAppearance* GetCharApp() 00146 { 00147 return charApp; 00148 } 00149 00150 private: 00151 void DrawRotate(); 00152 void DrawNoRotate(); 00153 00154 bool needsDraw; 00155 bool cameraLocked; 00156 bool doRotate; 00157 bool mouseDownUnlock; 00158 bool mouseDownRotate; 00159 csVector3 cameraPosition; 00160 csVector3 lookingAt; 00161 00162 csVector3 oldPosition; 00163 csVector3 oldLookAt; 00164 00165 bool CreateArea(); 00166 00167 bool spinMouse; 00168 csVector2 downPos; 00169 float orgRadians; 00170 int orgTime; 00171 int downTime; 00172 bool mouseControlled; 00173 00174 csRef<iBgLoader> loader; 00175 csRef<iSector> stage; 00176 csRef<iView> view; 00177 csRef<iEngine> engine; 00178 csRef<iRenderManagerTargets> rmTargets; 00179 csRef<iMeshWrapper> mesh; 00180 csRef<iSector> meshSector; 00181 csRef<iView> meshView; 00182 csRef<iTextureHandle> stageTarget; 00183 csRef<iTextureHandle> meshTarget; 00184 psCharAppearance* charApp; 00185 00186 csVector3 objectPos; 00187 csVector3 cameraMod; 00188 00189 void RotateDef(); // Used to reset to the values given by the controlling widget 00190 void RotateTemp(int speed,float radians); // Used to for example stop the rotate but not write the def values 00191 00192 float distance; 00193 float origDistance; 00194 00195 int rotateTime; 00196 float rotateRadians; 00197 float camRotate; 00198 00199 unsigned int ID; 00200 00201 csRef<iThreadReturn> meshFactory; 00202 }; 00203 CREATE_PAWS_FACTORY(pawsObjectView); 00204 00205 00208 #endif