Main Page   Class Hierarchy   Compound List   File List   Compound Members  

iso.h

00001 /*
00002     Copyright (C) 2001 by W.C.A. Wijngaards
00003   
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008   
00009     This library 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 GNU
00012     Library General Public License for more details.
00013   
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __IISO_H__
00020 #define __IISO_H__
00021 
00022 #include "csutil/scf.h"
00023 #include "csutil/cscolor.h"
00024 #include "csutil/flags.h"
00025 #include "csgeom/csrect.h"
00026 #include "csgeom/math2d.h"
00027 #include "csgeom/math3d.h"
00028 #include "ivideo/graph3d.h"
00029 
00030 class csMatrix3;
00031 struct iObjectRegistry;
00032 struct iEvent;
00033 struct iGraphics2D;
00034 struct iGraphics3D;
00035 struct iTextureManager;
00036 struct iMaterial;
00037 struct iMaterialHandle;
00038 struct iMaterialWrapper;
00039 struct iClipper2D;
00040 struct iIsoWorld;
00041 struct iIsoView;
00042 struct iIsoRenderView;
00043 struct iIsoSprite;
00044 struct iIsoMeshSprite;
00045 struct iIsoGrid;
00046 struct iIsoCell;
00047 struct iIsoLight;
00048 struct G3DPolygonDPFX;
00049 struct iMeshObject;
00050 struct iCamera;
00051 struct iLight;
00052 struct iMeshObjectFactory;
00053 
00054 SCF_VERSION (iGridChangeCallback, 0, 0, 1);
00055 
00059 struct iGridChangeCallback : public iBase
00060 {
00062   virtual void GridChange (iIsoSprite* spr) = 0;
00063 };
00064 
00065 SCF_VERSION (iIsoEngine, 0, 0, 2);
00066 
00070 struct iIsoEngine : public iBase
00071 {
00073   virtual iObjectRegistry* GetObjectRegistry() const = 0;
00075   virtual iGraphics2D* GetG2D() const = 0;
00077   virtual iGraphics3D* GetG3D() const = 0;
00079   virtual iTextureManager* GetTextureManager() const = 0;
00080 
00082   virtual int GetBeginDrawFlags () const = 0;
00083 
00085   virtual iIsoWorld* CreateWorld() = 0;
00087   virtual iIsoView* CreateView(iIsoWorld *world) = 0;
00089   virtual iIsoLight* CreateLight() = 0;
00091   virtual iIsoSprite* CreateSprite() = 0;
00093   virtual iIsoMeshSprite* CreateMeshSprite() = 0;
00095   virtual iIsoSprite* CreateFloorSprite(const csVector3& pos, float w, 
00096     float h) = 0;
00098   virtual iIsoSprite* CreateFrontSprite(const csVector3& pos, float w, 
00099     float h) = 0;
00101   virtual iIsoSprite* CreateZWallSprite(const csVector3& pos, float w, 
00102     float h) = 0;
00104   virtual iIsoSprite* CreateXWallSprite(const csVector3& pos, float w, 
00105     float h) = 0;
00106 
00108   virtual iMaterialWrapper *CreateMaterialWrapper(iMaterial *material,
00109     const char *name) = 0;
00114   virtual iMaterialWrapper *CreateMaterialWrapper(iMaterialHandle *handle,
00115     const char *name) = 0;
00120   virtual iMaterialWrapper *CreateMaterialWrapper(const char *vfsfilename,
00121     const char *materialname) = 0;
00123   virtual iMaterialWrapper *FindMaterial(const char *name) = 0;
00125   virtual iMaterialWrapper *FindMaterial(int index) = 0;
00127   virtual void RemoveMaterial(const char *name) = 0;
00129   virtual void RemoveMaterial(int index) = 0;
00131   virtual int GetMaterialCount() const = 0;
00132 
00134   virtual iMeshObjectFactory *CreateMeshFactory(const char* classId,
00135     const char *name) = 0;
00137   virtual void AddMeshFactory(iMeshObjectFactory *fact, const char *name) = 0;
00139   virtual iMeshObjectFactory *FindMeshFactory(const char *name) = 0;
00141   virtual void RemoveMeshFactory(const char *name) = 0;
00142 };
00143 
00144 SCF_VERSION (iIsoWorld, 0, 0, 1);
00145 
00149 struct iIsoWorld : public iBase
00150 {
00152   virtual void AddSprite(iIsoSprite *sprite) = 0;
00154   virtual void RemoveSprite(iIsoSprite *sprite) = 0;
00156   virtual void MoveSprite(iIsoSprite *sprite, const csVector3& oldpos,
00157     const csVector3& newpos) = 0;
00158 
00160   virtual iIsoGrid* CreateGrid(int width, int height) = 0;
00162   virtual iIsoGrid* FindGrid(const csVector3& pos) = 0;
00163 
00165   virtual void Draw(iIsoRenderView *rview) = 0;
00166 };
00167 
00168 SCF_VERSION (iIsoGrid, 0, 0, 1);
00169 
00176 struct iIsoGrid : public iBase
00177 {
00179   virtual iIsoWorld* GetWorld() const = 0;
00187   virtual void SetSpace(int minx, int minz, float miny = -1.0, 
00188     float maxy = +10.0) = 0;
00190   virtual bool Contains(const csVector3& pos) = 0;
00192   virtual const csBox3& GetBox() const = 0;
00194   virtual int GetWidth() const = 0;
00196   virtual int GetHeight() const = 0;
00198   virtual void GetGridOffset(int& minx, int& miny) const = 0;
00200   virtual iIsoCell* GetGridCell(int x, int y) = 0;
00201 
00206   virtual void SetGroundMult(int multx, int multy) = 0;
00208   virtual int GetGroundMultX() const = 0;
00210   virtual int GetGroundMultY() const = 0;
00215   virtual void SetGroundValue(int x, int y, int gr_x, int gr_y, float val) = 0;
00217   virtual float GetGroundValue(int x, int y, int gr_x, int gr_y) = 0;
00219   virtual float GetGroundValue(int x, int y) = 0;
00221   virtual bool GroundHitBeam(const csVector3& src, const csVector3& dest) = 0;
00222 
00224   virtual void SetAllLight(const csColor& color) = 0;
00226   virtual void SetAllStaticLight(const csColor& color) = 0;
00228   virtual void RegisterLight(iIsoLight *light) = 0;
00230   virtual void UnRegisterLight(iIsoLight *light) = 0;
00232   virtual void RegisterDynamicLight(iIsoLight *light) = 0;
00234   virtual void UnRegisterDynamicLight(iIsoLight *light) = 0;
00236   virtual void GetFakeLights(const csVector3& pos, iLight **& flights, 
00237     int& num) = 0;
00238 
00240   virtual void AddSprite(iIsoSprite *sprite) = 0;
00242   virtual void AddSprite(iIsoSprite *sprite, const csVector3& pos) = 0;
00244   virtual void RemoveSprite(iIsoSprite *sprite) = 0;
00249   virtual void MoveSprite(iIsoSprite *sprite, const csVector3& oldpos,
00250     const csVector3& newpos) = 0;
00251     
00253   virtual void Draw(iIsoRenderView *rview) = 0;
00254 };
00255 
00256 SCF_VERSION (iIsoCellTraverseCallback, 0, 0, 1);
00257 
00261 struct iIsoCellTraverseCallback : public iBase
00262 {
00264   virtual void Traverse (iIsoSprite* spr) = 0;
00265 };
00266 
00267 SCF_VERSION (iIsoCell, 0, 0, 2);
00268 
00272 struct iIsoCell : public iBase
00273 {
00275   virtual void AddSprite(iIsoSprite *sprite, const csVector3& pos) = 0;
00277   virtual void RemoveSprite(iIsoSprite *sprite, const csVector3& pos) = 0;
00279   virtual void Draw(iIsoRenderView *rview) = 0;
00281   virtual void Traverse(iIsoCellTraverseCallback* func) = 0;
00282 };
00283 
00284 SCF_VERSION (iIsoView, 0, 0, 1);
00285 
00301 struct iIsoView : public iBase
00302 {
00304   virtual iIsoEngine *GetEngine() const = 0;
00305 
00307   virtual void SetWorld(iIsoWorld* world) = 0;
00309   virtual iIsoWorld* GetWorld() const = 0;
00310 
00312   virtual void SetRect(const csRect& rect) = 0;
00314   virtual const csRect& GetRect() const = 0;
00315 
00326   virtual void SetAxes(float xscale, float yscale, float zscale,
00327     float zskew, float xskew) = 0;
00328 
00330   virtual const csVector2& GetScroll() const = 0;
00332   virtual csVector3 GetViewScroll() const = 0;
00334   virtual void SetScroll(const csVector3& worldpos, const csVector2& coord) = 0;
00336   virtual void MoveScroll(const csVector3& delta) = 0;
00337 
00339   virtual void W2S(const csVector3& world, csVector2& screen) const = 0;
00345   virtual void W2S(const csVector3& world, csVector3& screen) const = 0;
00350   virtual void S2W(const csVector2& screen, csVector3& world) const = 0;
00351 
00356   virtual void Draw() = 0;
00357 
00363   virtual iCamera* GetFakeCamera(const csVector3& center,
00364     iIsoRenderView *rview) = 0;
00365 };
00366 
00367 SCF_VERSION (iIsoRenderView, 0, 0, 1);
00368 
00370 #define CSISO_RENDERPASS_PRE    0
00371 
00372 #define CSISO_RENDERPASS_BG     1
00373 
00374 #define CSISO_RENDERPASS_MAIN   2
00375 
00376 #define CSISO_RENDERPASS_FG     3
00377 
00378 #define CSISO_RENDERPASS_POST   4
00379 
00383 struct iIsoRenderView : public iBase
00384 {
00386   virtual iIsoView* GetView() const = 0;
00388   virtual iGraphics3D* GetG3D() const = 0;
00390   virtual int GetRenderPass() const = 0;
00392   virtual iClipper2D* GetClipper() const = 0;
00394   virtual void GetPrecalcGrid(int& startx, int& starty, int& scanw, 
00395     int& scanh, float& cellpery) const = 0;
00397   virtual float GetMinZ() const = 0;
00399   virtual void SetMinZ(float val) = 0;
00401   virtual void AddPolyFX(int materialindex, G3DPolygonDPFX *g3dpolyfx, 
00402     UInt mixmode) = 0;
00403 };
00404 
00405 SCF_VERSION (iIsoSprite, 0, 0, 1);
00406 
00410 struct iIsoSprite : public iBase
00411 {
00413   virtual int GetVertexCount() const = 0;
00415   virtual void AddVertex(const csVector3& coord, float u, float v) = 0;
00417   virtual const csVector3& GetVertexPosition(int i) = 0;
00419   virtual void SetAllColors(const csColor& color) = 0;
00421   virtual void AddToVertexColor(int i, const csColor& color) = 0;
00423   virtual void ResetAllColors() = 0;
00425   virtual void SetAllStaticColors(const csColor& color) = 0;
00427   virtual void AddToVertexStaticColor(int i, const csColor& color) = 0;
00428 
00430   virtual const csVector3& GetPosition() const = 0;
00432   virtual void SetPosition(const csVector3& pos) = 0;
00434   virtual void MovePosition(const csVector3& delta) = 0;
00440   virtual void ForcePosition(const csVector3& pos) = 0;
00441 
00443   virtual void SetMaterialWrapper(iMaterialWrapper *material) = 0;
00445   virtual iMaterialWrapper* GetMaterialWrapper() const = 0;
00447   virtual void SetMixMode (UInt mode) = 0;
00449   virtual UInt GetMixMode () const = 0;
00450 
00452   virtual void Draw(iIsoRenderView *rview) = 0;
00453 
00455   virtual void SetGrid(iIsoGrid *grid) = 0;
00457   virtual iIsoGrid *GetGrid() const = 0;
00459   virtual void SetGridChangeCallback (iGridChangeCallback* cb) = 0;
00461   virtual iGridChangeCallback* GetGridChangeCallback () const = 0;
00462 };
00463 
00464 
00465 
00466 SCF_VERSION (iIsoMeshSprite, 0, 0, 1);
00467 
00472 struct iIsoMeshSprite : iIsoSprite {
00474   virtual void SetMeshObject(iMeshObject *mesh) = 0;
00476   virtual iMeshObject* GetMeshObject() const = 0;
00477 
00479   virtual void SetTransform(const csMatrix3& transform) = 0;
00481   virtual const csMatrix3& GetTransform() const = 0;
00482 
00484   virtual void SetZBufMode(csZBufMode mode) = 0;
00486   virtual csZBufMode GetZBufMode() const = 0;
00487 };
00488 
00489 
00500 #define CSISO_ATTN_NONE      0
00501 #define CSISO_ATTN_LINEAR    1
00502 #define CSISO_ATTN_INVERSE   2
00503 #define CSISO_ATTN_REALISTIC 3
00504 
00506 #define CSISO_LIGHT_STATIC 0x0000
00507 
00508 #define CSISO_LIGHT_DYNAMIC 0x0001
00509 
00510 SCF_VERSION (iIsoLight, 0, 0, 1);
00511 
00515 struct iIsoLight : public iBase
00516 {
00518   virtual void SetGrid(iIsoGrid *grid) = 0;
00520   virtual iIsoGrid* GetGrid() const = 0;
00522   virtual csFlags& Flags() = 0;
00524   virtual void SetAttenuation(int attn) = 0;
00526   virtual int GetAttenuation() const = 0;
00528   virtual void SetPosition(const csVector3& pos) = 0;
00530   virtual const csVector3& GetPosition() const = 0;
00532   virtual void SetColor(const csColor& col) = 0;
00534   virtual const csColor& GetColor() const = 0;
00536   virtual void SetRadius(float radius) = 0;
00538   virtual float GetRadius() const = 0;
00539 
00541   virtual void ShineGrid() = 0;
00543   virtual void ShineSprite(iIsoSprite *sprite) = 0;
00545   virtual iLight* GetFakeLight() = 0;
00547   virtual float GetVis(int gridx, int gridy) const = 0;
00548 };
00549 
00550 SCF_VERSION (iIsoMaterialWrapperIndex, 0, 0, 1);
00551 
00557 struct iIsoMaterialWrapperIndex: public iBase
00558 {
00560   virtual int GetIndex() const = 0;
00562   virtual void SetIndex(int i) = 0;
00563 };
00564 #endif

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000