| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# imesh/thing.h

Go to the documentation of this file.

    00001 /*
    00002     Copyright (C) 1998-2003 by Jorrit Tyberghein
    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 __CS_IMESH_THING_H__
    00020 #define __CS_IMESH_THING_H__
    00021
    00022 #include "csutil/scf.h"
    00023 #include "igraphic/image.h"
    00024
    00033 struct iMaterialWrapper;
    00034 struct iMeshObject;
    00035 struct iMeshObjectFactory;
    00036 struct iRenderBuffer;
    00037 struct iThingState;
    00038 struct iThingFactoryState;
    00039
    00040 class csFlags;
    00041 class csMatrix3;
    00042 class csPlane3;
    00043 class csVector2;
    00044 class csVector3;
    00045
    00049 struct csPolygonRange
    00050 {
    00051   int start, end;
    00052   csPolygonRange (int start, int end)
    00053   {
    00054     csPolygonRange::start = start;
    00055     csPolygonRange::end = end;
    00056   }
    00057   void Set (int start, int end)
    00058   {
    00059     csPolygonRange::start = start;
    00060     csPolygonRange::end = end;
    00061   }
    00062   void Set (int idx)
    00063   {
    00064     csPolygonRange::start = idx;
    00065     csPolygonRange::end = idx;
    00066   }
    00067 };
    00068
    00075 #define CS_POLY_LIGHTING 0x00000001
    00076
    00080 #define CS_POLY_COLLDET 0x00000002
    00081
    00085 #define CS_POLY_VISCULL 0x00000004
    00086
    00094 #define CS_POLYRANGE(s1,s2) csPolygonRange (s1, s2)
    00095
    00098 #define CS_POLYRANGE_SINGLE(idx) csPolygonRange (idx, idx)
    00099
    00102 #define CS_POLYRANGE_LAST csPolygonRange (-1, -1)
    00103
    00106 #define CS_POLYRANGE_ALL csPolygonRange (0, 2000000000)
    00107
    00112 #define CS_POLYINDEX_LAST -1
    00113
    00122 #define CS_THING_NOCOMPRESS 0x00010000
    00123
    00131 #define CS_THING_MOVE_NEVER 0
    00132 #define CS_THING_MOVE_OCCASIONAL 2
    00133
    00152 struct iPolygonHandle : public virtual iBase
    00153 {
    00154   SCF_INTERFACE (iPolygonHandle, 1, 0, 0);
    00155
    00160   virtual iThingFactoryState* GetThingFactoryState () const = 0;
    00161
    00166   virtual iMeshObjectFactory* GetMeshObjectFactory () const = 0;
    00167
    00172   virtual iThingState* GetThingState () const = 0;
    00173
    00178   virtual iMeshObject* GetMeshObject () const = 0;
    00179
    00183   virtual int GetIndex () const = 0;
    00184 };
    00185
    00186
    00203 struct iThingFactoryState : public virtual iBase
    00204 {
    00205   SCF_INTERFACE(iThingFactoryState, 2, 0, 1);
    00206
    00215   virtual void CompressVertices () = 0;
    00216
    00218   virtual int GetPolygonCount () = 0;
    00220   virtual void RemovePolygon (int idx) = 0;
    00222   virtual void RemovePolygons () = 0;
    00223
    00225   virtual int FindPolygonByName (const char* name) = 0;
    00226
    00231   virtual int AddEmptyPolygon () = 0;
    00232
    00243   virtual int AddTriangle (const csVector3& v1, const csVector3& v2,
    00244         const csVector3& v3) = 0;
    00256   virtual int AddQuad (const csVector3& v1, const csVector3& v2,
    00257         const csVector3& v3, const csVector3& v4) = 0;
    00258
    00269   virtual int AddPolygon (csVector3* vertices, int num) = 0;
    00270
    00281   virtual int AddPolygon (int num, ...) = 0;
    00282
    00293   virtual int AddOutsideBox (const csVector3& bmin, const csVector3& bmax) = 0;
    00294
    00305   virtual int AddInsideBox (const csVector3& bmin, const csVector3& bmax) = 0;
    00306
    00313   virtual void SetPolygonName (const csPolygonRange& range,
    00314         const char* name) = 0;
    00315
    00321   virtual const char* GetPolygonName (int polygon_idx) = 0;
    00322
    00333   virtual csPtr<iPolygonHandle> CreatePolygonHandle (int polygon_idx) = 0;
    00334
    00341   virtual void SetPolygonMaterial (const csPolygonRange& range,
    00342         iMaterialWrapper* material) = 0;
    00343
    00349   virtual iMaterialWrapper* GetPolygonMaterial (int polygon_idx) = 0;
    00350
    00357   virtual void AddPolygonVertex (const csPolygonRange& range,
    00358         const csVector3& vt) = 0;
    00359
    00366   virtual void AddPolygonVertex (const csPolygonRange& range, int vt) = 0;
    00367
    00377   virtual void SetPolygonVertexIndices (const csPolygonRange& range,
    00378         int num, int* indices) = 0;
    00379
    00385   virtual int GetPolygonVertexCount (int polygon_idx) = 0;
    00386
    00393   virtual const csVector3& GetPolygonVertex (int polygon_idx,
    00394         int vertex_idx) = 0;
    00395
    00401   virtual int* GetPolygonVertexIndices (int polygon_idx) = 0;
    00402
    00416   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
    00417         const csMatrix3& m, const csVector3& v) = 0;
    00418
    00430   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
    00431         const csVector2& uv1, const csVector2& uv2, const csVector2& uv3) = 0;
    00432
    00449   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
    00450         const csVector3& p1, const csVector2& uv1,
    00451         const csVector3& p2, const csVector2& uv2,
    00452         const csVector3& p3, const csVector2& uv3) = 0;
    00453
    00472   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
    00473         const csVector3& v_orig, const csVector3& v, float len) = 0;
    00474
    00495   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
    00496         const csVector3& v_orig,
    00497         const csVector3& v1, float len1,
    00498         const csVector3& v2, float len2) = 0;
    00499
    00517   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
    00518         float len) = 0;
    00519
    00527   virtual void GetPolygonTextureMapping (int polygon_idx,
    00528         csMatrix3& m, csVector3& v) = 0;
    00529
    00537   virtual void SetPolygonTextureMappingEnabled (const csPolygonRange& range,
    00538         bool enabled) = 0;
    00539
    00545   virtual bool IsPolygonTextureMappingEnabled (int polygon_idx) const = 0;
    00546
    00554   virtual void SetPolygonFlags (const csPolygonRange& range, uint32 flags) = 0;
    00555
    00566   virtual void SetPolygonFlags (const csPolygonRange& range, uint32 mask,
    00567         uint32 flags) = 0;
    00568
    00576   virtual void ResetPolygonFlags (const csPolygonRange& range,
    00577         uint32 flags) = 0;
    00578
    00584   virtual csFlags& GetPolygonFlags (int polygon_idx) = 0;
    00585
    00591   virtual const csPlane3& GetPolygonObjectPlane (int polygon_idx) = 0;
    00592
    00598   virtual bool IsPolygonTransparent (int polygon_idx) = 0;
    00599
    00607   virtual bool PointOnPolygon (int polygon_idx, const csVector3& v) = 0;
    00608
    00610   virtual int GetVertexCount () const = 0;
    00612   virtual const csVector3 &GetVertex (int idx) const = 0;
    00614   virtual const csVector3* GetVertices () const = 0;
    00616   virtual int CreateVertex (const csVector3& vt) = 0;
    00618   virtual void SetVertex (int idx, const csVector3& vt) = 0;
    00624   virtual void DeleteVertex (int idx) = 0;
    00632   virtual void DeleteVertices (int from, int to) = 0;
    00633
    00637   virtual void SetSmoothingFlag (bool smoothing) = 0;
    00638
    00642   virtual bool GetSmoothingFlag () = 0;
    00643
    00647   virtual csVector3* GetNormals () = 0;
    00648
    00652   virtual float GetCosinusFactor () const = 0;
    00658   virtual void SetCosinusFactor (float cosfact) = 0;
    00659
    00660   virtual bool AddPolygonRenderBuffer (int polygon_idx, const char* name,
    00661     iRenderBuffer* buffer) = 0;
    00662
    00674   virtual bool GetLightmapLayout (int polygon_idx, size_t& slm,
    00675     csRect& slmSubRect, float* slmCoord) = 0;
    00677 };
    00678
    00694 struct iThingState : public virtual iBase
    00695 {
    00696   SCF_INTERFACE (iThingState, 1, 0, 2);
    00697
    00699   virtual const csVector3 &GetVertexW (int idx) const = 0;
    00701   virtual const csVector3* GetVerticesW () const = 0;
    00702
    00706   virtual int GetMovingOption () const = 0;
    00707
    00733   virtual void SetMovingOption (int opt) = 0;
    00734
    00743   virtual void Prepare () = 0;
    00744
    00749   virtual void Unprepare () = 0;
    00750
    00758   virtual void ReplaceMaterial (iMaterialWrapper* oldmat,
    00759         iMaterialWrapper* newmat) = 0;
    00760
    00765   virtual void ClearReplacedMaterials () = 0;
    00766
    00768   virtual void SetMixMode (uint mode) = 0;
    00770   virtual uint GetMixMode () const = 0;
    00771
    00781   virtual csPtr<iPolygonHandle> CreatePolygonHandle (int polygon_idx) = 0;
    00782
    00788   virtual const csPlane3& GetPolygonWorldPlane (int polygon_idx) = 0;
    00789
    00792
    00793   virtual csPtr<iImage> GetPolygonLightmap (int polygon_idx) = 0;
    00795   virtual bool GetPolygonPDLight (int polygon_idx, size_t pdlight_index,
    00796     csRef<iImage>& map, iLight*& light) = 0;
    00802   virtual iMaterialWrapper* GetReplacedMaterial (iMaterialWrapper* oldMat) = 0;
    00803 };
    00804
    00816 struct iThingEnvironment : public virtual iBase
    00817 {
    00818   SCF_INTERFACE (iThingEnvironment, 1, 0, 0);
    00819
    00823   virtual void Clear () = 0;
    00824
    00826   virtual int GetLightmapCellSize () const = 0;
    00828   virtual void SetLightmapCellSize (int Size) = 0;
    00830   virtual int GetDefaultLightmapCellSize () const = 0;
    00831 };
    00832
    00835 #endif // __CS_IMESH_THING_H__