CrystalSpace

Public API Reference

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 
00032 struct iMaterialWrapper;
00033 struct iMeshObject;
00034 struct iMeshObjectFactory;
00035 struct iRenderBuffer;
00036 struct iThingState;
00037 struct iThingFactoryState;
00038 
00039 class csFlags;
00040 class csMatrix3;
00041 class csPlane3;
00042 class csVector2;
00043 class csVector3;
00044 
00048 struct csPolygonRange
00049 {
00050   int start, end;
00051   csPolygonRange (int start, int end)
00052   {
00053     csPolygonRange::start = start;
00054     csPolygonRange::end = end;
00055   }
00056   void Set (int start, int end)
00057   {
00058     csPolygonRange::start = start;
00059     csPolygonRange::end = end;
00060   }
00061   void Set (int idx)
00062   {
00063     csPolygonRange::start = idx;
00064     csPolygonRange::end = idx;
00065   }
00066 };
00067 
00074 #define CS_POLY_LIGHTING 0x00000001
00075 
00079 #define CS_POLY_COLLDET 0x00000002
00080 
00084 #define CS_POLY_VISCULL 0x00000004
00085 
00093 #define CS_POLYRANGE(s1,s2) csPolygonRange (s1, s2)
00094 
00097 #define CS_POLYRANGE_SINGLE(idx) csPolygonRange (idx, idx)
00098 
00101 #define CS_POLYRANGE_LAST csPolygonRange (-1, -1)
00102 
00105 #define CS_POLYRANGE_ALL csPolygonRange (0, 2000000000)
00106 
00111 #define CS_POLYINDEX_LAST -1
00112 
00121 #define CS_THING_NOCOMPRESS 0x00010000
00122 
00130 #define CS_THING_MOVE_NEVER 0
00131 #define CS_THING_MOVE_OCCASIONAL 2
00132 
00151 struct iPolygonHandle : public virtual iBase
00152 {
00153   SCF_INTERFACE (iPolygonHandle, 1, 0, 0);
00154 
00159   virtual iThingFactoryState* GetThingFactoryState () const = 0;
00160 
00165   virtual iMeshObjectFactory* GetMeshObjectFactory () const = 0;
00166 
00171   virtual iThingState* GetThingState () const = 0;
00172 
00177   virtual iMeshObject* GetMeshObject () const = 0;
00178 
00182   virtual int GetIndex () const = 0;
00183 };
00184 
00185 
00202 struct iThingFactoryState : public virtual iBase
00203 {
00204   SCF_INTERFACE(iThingFactoryState, 2, 0, 0);
00205 
00214   virtual void CompressVertices () = 0;
00215 
00217   virtual int GetPolygonCount () = 0;
00219   virtual void RemovePolygon (int idx) = 0;
00221   virtual void RemovePolygons () = 0;
00222 
00224   virtual int FindPolygonByName (const char* name) = 0;
00225 
00230   virtual int AddEmptyPolygon () = 0;
00231 
00242   virtual int AddTriangle (const csVector3& v1, const csVector3& v2,
00243         const csVector3& v3) = 0;
00255   virtual int AddQuad (const csVector3& v1, const csVector3& v2,
00256         const csVector3& v3, const csVector3& v4) = 0;
00257 
00268   virtual int AddPolygon (csVector3* vertices, int num) = 0;
00269 
00280   virtual int AddPolygon (int num, ...) = 0;
00281 
00292   virtual int AddOutsideBox (const csVector3& bmin, const csVector3& bmax) = 0;
00293 
00304   virtual int AddInsideBox (const csVector3& bmin, const csVector3& bmax) = 0;
00305 
00312   virtual void SetPolygonName (const csPolygonRange& range,
00313         const char* name) = 0;
00314 
00320   virtual const char* GetPolygonName (int polygon_idx) = 0;
00321 
00332   virtual csPtr<iPolygonHandle> CreatePolygonHandle (int polygon_idx) = 0;
00333 
00340   virtual void SetPolygonMaterial (const csPolygonRange& range,
00341         iMaterialWrapper* material) = 0;
00342 
00348   virtual iMaterialWrapper* GetPolygonMaterial (int polygon_idx) = 0;
00349 
00356   virtual void AddPolygonVertex (const csPolygonRange& range,
00357         const csVector3& vt) = 0;
00358 
00365   virtual void AddPolygonVertex (const csPolygonRange& range, int vt) = 0;
00366 
00376   virtual void SetPolygonVertexIndices (const csPolygonRange& range,
00377         int num, int* indices) = 0;
00378 
00384   virtual int GetPolygonVertexCount (int polygon_idx) = 0;
00385 
00392   virtual const csVector3& GetPolygonVertex (int polygon_idx,
00393         int vertex_idx) = 0;
00394 
00400   virtual int* GetPolygonVertexIndices (int polygon_idx) = 0;
00401 
00415   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
00416         const csMatrix3& m, const csVector3& v) = 0;
00417 
00429   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
00430         const csVector2& uv1, const csVector2& uv2, const csVector2& uv3) = 0;
00431 
00448   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
00449         const csVector3& p1, const csVector2& uv1,
00450         const csVector3& p2, const csVector2& uv2,
00451         const csVector3& p3, const csVector2& uv3) = 0;
00452 
00471   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
00472         const csVector3& v_orig, const csVector3& v, float len) = 0;
00473 
00494   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
00495         const csVector3& v_orig,
00496         const csVector3& v1, float len1,
00497         const csVector3& v2, float len2) = 0;
00498 
00516   virtual bool SetPolygonTextureMapping (const csPolygonRange& range,
00517         float len) = 0;
00518 
00526   virtual void GetPolygonTextureMapping (int polygon_idx,
00527         csMatrix3& m, csVector3& v) = 0;
00528 
00536   virtual void SetPolygonTextureMappingEnabled (const csPolygonRange& range,
00537         bool enabled) = 0;
00538 
00544   virtual bool IsPolygonTextureMappingEnabled (int polygon_idx) const = 0;
00545 
00553   virtual void SetPolygonFlags (const csPolygonRange& range, uint32 flags) = 0;
00554 
00565   virtual void SetPolygonFlags (const csPolygonRange& range, uint32 mask,
00566         uint32 flags) = 0;
00567 
00575   virtual void ResetPolygonFlags (const csPolygonRange& range,
00576         uint32 flags) = 0;
00577 
00583   virtual csFlags& GetPolygonFlags (int polygon_idx) = 0;
00584 
00590   virtual const csPlane3& GetPolygonObjectPlane (int polygon_idx) = 0;
00591 
00597   virtual bool IsPolygonTransparent (int polygon_idx) = 0;
00598 
00606   virtual bool PointOnPolygon (int polygon_idx, const csVector3& v) = 0;
00607 
00609   virtual int GetVertexCount () const = 0;
00611   virtual const csVector3 &GetVertex (int idx) const = 0;
00613   virtual const csVector3* GetVertices () const = 0;
00615   virtual int CreateVertex (const csVector3& vt) = 0;
00617   virtual void SetVertex (int idx, const csVector3& vt) = 0;
00623   virtual void DeleteVertex (int idx) = 0;
00631   virtual void DeleteVertices (int from, int to) = 0;
00632 
00636   virtual void SetSmoothingFlag (bool smoothing) = 0;
00637 
00641   virtual bool GetSmoothingFlag () = 0;
00642   
00646   virtual csVector3* GetNormals () = 0;
00647 
00651   virtual float GetCosinusFactor () const = 0;
00657   virtual void SetCosinusFactor (float cosfact) = 0;
00658 
00659   virtual bool AddPolygonRenderBuffer (int polygon_idx, const char* name,
00660     iRenderBuffer* buffer) = 0;
00661 
00663   virtual void SetMixMode (uint mode) = 0;
00665   virtual uint GetMixMode () const = 0;
00666 };
00667 
00683 struct iThingState : public virtual iBase
00684 {
00685   SCF_INTERFACE (iThingState, 1, 0, 0);
00686 
00688   virtual const csVector3 &GetVertexW (int idx) const = 0;
00690   virtual const csVector3* GetVerticesW () const = 0;
00691 
00695   virtual int GetMovingOption () const = 0;
00696 
00722   virtual void SetMovingOption (int opt) = 0;
00723 
00732   virtual void Prepare () = 0;
00733 
00738   virtual void Unprepare () = 0;
00739 
00747   virtual void ReplaceMaterial (iMaterialWrapper* oldmat,
00748         iMaterialWrapper* newmat) = 0;
00749 
00754   virtual void ClearReplacedMaterials () = 0;
00755 
00757   virtual void SetMixMode (uint mode) = 0;
00759   virtual uint GetMixMode () const = 0;
00760 
00770   virtual csPtr<iPolygonHandle> CreatePolygonHandle (int polygon_idx) = 0;
00771 
00777   virtual const csPlane3& GetPolygonWorldPlane (int polygon_idx) = 0;
00778 };
00779 
00791 struct iThingEnvironment : public virtual iBase
00792 {
00793   SCF_INTERFACE (iThingEnvironment, 1, 0, 0);
00794 
00798   virtual void Clear () = 0;
00799 
00801   virtual int GetLightmapCellSize () const = 0;
00803   virtual void SetLightmapCellSize (int Size) = 0;
00805   virtual int GetDefaultLightmapCellSize () const = 0;
00806 };
00807 
00810 #endif // __CS_IMESH_THING_H__

Generated for Crystal Space by doxygen 1.4.6