CrystalSpace

Public API Reference

imesh/genmesh.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2002 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_GENMESH_H__
00020 #define __CS_IMESH_GENMESH_H__
00021 
00026 #include "csutil/scf_interface.h"
00027 
00028 struct iDocumentNode;
00029 struct iGenMeshAnimationControl;
00030 struct iGenMeshAnimationControlFactory;
00031 struct iMaterialWrapper;
00032 struct iRenderBuffer;
00033 struct iMeshObject;
00034 struct iString;
00035 
00039 class csBox3;
00040 class csColor;
00041 class csColor4;
00042 struct csTriangle;
00043 class csVector2;
00044 class csVector3;
00045 class csEllipsoid;
00046 
00047 struct iGeneralMeshSubMesh : public virtual iBase
00048 {
00049   SCF_INTERFACE (iGeneralMeshSubMesh, 1, 0, 1);
00050   
00052   virtual iRenderBuffer* GetIndices () const = 0;
00053 
00055   virtual iMaterialWrapper* GetMaterial () const = 0;
00056   
00058   virtual const char* GetName () const = 0;
00059   
00061   virtual uint GetMixmode () const = 0;
00062 
00064   virtual void SetMaterial (iMaterialWrapper* material) = 0;
00065 };
00066 
00072 struct iGeneralMeshCommonState : public virtual iBase
00073 {
00074   SCF_INTERFACE (iGeneralMeshCommonState, 1, 2, 0);
00075   
00077   virtual void SetLighting (bool l) = 0;
00079   virtual bool IsLighting () const = 0;
00085   virtual void SetManualColors (bool m) = 0;
00087   virtual bool IsManualColors () const = 0;
00092   virtual void SetShadowCasting (bool m) = 0;
00094   virtual bool IsShadowCasting () const = 0;
00103   virtual void SetShadowReceiving (bool m) = 0;
00105   virtual bool IsShadowReceiving () const = 0;
00106 
00112   virtual bool AddRenderBuffer (const char *name, iRenderBuffer* buffer) = 0;
00113 
00117   virtual bool RemoveRenderBuffer (const char *name) = 0;
00118 
00122   virtual int GetRenderBufferCount () const = 0;
00123 
00127   virtual csRef<iRenderBuffer> GetRenderBuffer (int index) = 0;
00128 
00132   virtual csRef<iString> GetRenderBufferName (int index) const = 0;
00134 };
00135 
00150 struct iGeneralMeshState : public virtual iGeneralMeshCommonState
00151 {
00152   SCF_INTERFACE (iGeneralMeshState, 1, 1, 1);
00153   
00158   virtual void SetAnimationControl (iGenMeshAnimationControl* anim_ctrl) = 0;
00159 
00163   virtual iGenMeshAnimationControl* GetAnimationControl () const = 0;
00164   
00176   virtual iGeneralMeshSubMesh* FindSubMesh (const char* name) const = 0;
00194   CS_DEPRECATED_METHOD_MSG("Use AddSubMesh from iGeneralFactoryState instead")
00195   virtual void AddSubMesh (unsigned int *triangles,
00196     int tricount,
00197     iMaterialWrapper *material) = 0;
00198 
00213   CS_DEPRECATED_METHOD_MSG("Use AddSubMesh from iGeneralFactoryState instead")
00214   virtual void AddSubMesh (unsigned int *triangles,
00215     int tricount,
00216     iMaterialWrapper *material, uint mixmode) = 0;
00218 };
00219 
00242 struct iGeneralFactoryState : public virtual iGeneralMeshCommonState
00243 {
00244   SCF_INTERFACE (iGeneralFactoryState, 1, 1, 1);
00245   
00247   virtual void SetColor (const csColor& col) = 0;
00249   virtual const csColor& GetColor () const = 0;
00250   
00256   virtual void AddVertex (const csVector3& v,
00257       const csVector2& uv, const csVector3& normal,
00258       const csColor4& color) = 0;
00259 
00267   virtual void SetVertexCount (int n) = 0;
00269   virtual int GetVertexCount () const = 0;
00275   virtual csVector3* GetVertices () = 0;
00281   virtual csVector2* GetTexels () = 0;
00290   virtual csVector3* GetNormals () = 0;
00298   virtual csColor4* GetColors () = 0;
00299 
00305   virtual void AddTriangle (const csTriangle& tri) = 0;
00306 
00314   virtual void SetTriangleCount (int n) = 0;
00316   virtual int GetTriangleCount () const = 0;
00322   virtual csTriangle* GetTriangles () = 0;
00323 
00330   virtual void Invalidate () = 0;
00331 
00337   virtual void CalculateNormals (bool compress = true) = 0;
00338 
00343   virtual void Compress () = 0;
00344 
00350   virtual void GenerateBox (const csBox3& box) = 0;
00351 
00358   virtual void GenerateCapsule (float l, float r, uint sides) = 0;
00359 
00371   virtual void GenerateSphere (const csEllipsoid& ellips, int rim_vertices,
00372       bool cyl_mapping = false,
00373       bool toponly = false,
00374       bool reversed = false) = 0;
00375 
00376   //virtual void GeneratePlane (const csPlane3& plane) = 0;
00377 
00383   virtual void SetBack2Front (bool b2f) = 0;
00384 
00388   virtual bool IsAutoNormals () const = 0;
00389 
00393   virtual bool IsBack2Front () const = 0;
00394 
00399   virtual void SetAnimationControlFactory (
00400         iGenMeshAnimationControlFactory* anim_ctrl) = 0;
00401 
00405   virtual iGenMeshAnimationControlFactory* GetAnimationControlFactory ()
00406         const = 0;
00407   
00413   virtual void ClearSubMeshes () = 0;
00431   virtual iGeneralMeshSubMesh* AddSubMesh (iRenderBuffer* indices, 
00432     iMaterialWrapper *material, const char* name, uint mixmode = (uint)~0) = 0;
00433 
00438   virtual iGeneralMeshSubMesh* FindSubMesh (const char* name) const = 0;
00439   
00443   virtual void DeleteSubMesh (iGeneralMeshSubMesh* mesh) = 0;
00444   
00446   virtual size_t GetSubMeshCount () const = 0;
00447 
00449   virtual iGeneralMeshSubMesh* GetSubMesh (size_t index) const = 0;
00458   virtual void DisableAutoNormals () = 0;
00459 };
00460 
00479 struct iGenMeshAnimationControl : public virtual iBase
00480 {
00481   SCF_INTERFACE(iGenMeshAnimationControl, 2, 0, 0);
00482 
00484   virtual bool AnimatesVertices () const = 0;
00486   virtual bool AnimatesTexels () const = 0;
00488   virtual bool AnimatesNormals () const = 0;
00490   virtual bool AnimatesColors () const = 0;
00491 
00495   virtual void Update (csTicks current) = 0;
00496 
00506   virtual const csVector3* UpdateVertices (csTicks current,
00507         const csVector3* verts, int num_verts, uint32 version_id) = 0;
00508 
00518   virtual const csVector2* UpdateTexels (csTicks current,
00519         const csVector2* texels, int num_texels, uint32 version_id) = 0;
00520 
00530   virtual const csVector3* UpdateNormals (csTicks current,
00531         const csVector3* normals, int num_normals, uint32 version_id) = 0;
00532 
00544   virtual const csColor4* UpdateColors (csTicks current,
00545         const csColor4* colors, int num_colors, uint32 version_id) = 0;
00546 };
00547 
00560 struct iGenMeshAnimationControlFactory : public virtual iBase
00561 {
00562   SCF_INTERFACE(iGenMeshAnimationControlFactory, 2, 0, 0);
00563 
00567   virtual csPtr<iGenMeshAnimationControl> CreateAnimationControl (
00568         iMeshObject *mesh) = 0;
00569 
00574   virtual const char* Load (iDocumentNode* node) = 0;
00575 
00580   virtual const char* Save (iDocumentNode* parent) = 0;
00581 };
00582 
00597 struct iGenMeshAnimationControlType : public virtual iBase
00598 {
00599   SCF_INTERFACE(iGenMeshAnimationControlType, 2, 0, 0);
00600 
00604   virtual csPtr<iGenMeshAnimationControlFactory> CreateAnimationControlFactory
00605         () = 0;
00606 };
00607 
00610 #endif // __CS_IMESH_GENMESH_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3