## Public API Reference

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

- File List
- File Members

# 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
    00363   virtual void GenerateSphere (const csEllipsoid& ellips, int rim_vertices,
    00364       bool cyl_mapping = false,
    00365       bool toponly = false,
    00366       bool reversed = false) = 0;
    00367
    00368   //virtual void GeneratePlane (const csPlane3& plane) = 0;
    00369
    00375   virtual void SetBack2Front (bool b2f) = 0;
    00376
    00380   virtual bool IsAutoNormals () const = 0;
    00381
    00385   virtual bool IsBack2Front () const = 0;
    00386
    00391   virtual void SetAnimationControlFactory (
    00392         iGenMeshAnimationControlFactory* anim_ctrl) = 0;
    00393
    00397   virtual iGenMeshAnimationControlFactory* GetAnimationControlFactory ()
    00398         const = 0;
    00399
    00405   virtual void ClearSubMeshes () = 0;
    00423   virtual iGeneralMeshSubMesh* AddSubMesh (iRenderBuffer* indices,
    00424     iMaterialWrapper *material, const char* name, uint mixmode = (uint)~0) = 0;
    00425
    00430   virtual iGeneralMeshSubMesh* FindSubMesh (const char* name) const = 0;
    00431
    00435   virtual void DeleteSubMesh (iGeneralMeshSubMesh* mesh) = 0;
    00436
    00438   virtual size_t GetSubMeshCount () const = 0;
    00439
    00441   virtual iGeneralMeshSubMesh* GetSubMesh (size_t index) const = 0;
    00450   virtual void DisableAutoNormals () = 0;
    00451 };
    00452
    00471 struct iGenMeshAnimationControl : public virtual iBase
    00472 {
    00473   SCF_INTERFACE(iGenMeshAnimationControl, 2, 0, 0);
    00474
    00476   virtual bool AnimatesVertices () const = 0;
    00478   virtual bool AnimatesTexels () const = 0;
    00480   virtual bool AnimatesNormals () const = 0;
    00482   virtual bool AnimatesColors () const = 0;
    00483
    00487   virtual void Update (csTicks current) = 0;
    00488
    00498   virtual const csVector3* UpdateVertices (csTicks current,
    00499         const csVector3* verts, int num_verts, uint32 version_id) = 0;
    00500
    00510   virtual const csVector2* UpdateTexels (csTicks current,
    00511         const csVector2* texels, int num_texels, uint32 version_id) = 0;
    00512
    00522   virtual const csVector3* UpdateNormals (csTicks current,
    00523         const csVector3* normals, int num_normals, uint32 version_id) = 0;
    00524
    00534   virtual const csColor4* UpdateColors (csTicks current,
    00535         const csColor4* colors, int num_colors, uint32 version_id) = 0;
    00536 };
    00537
    00550 struct iGenMeshAnimationControlFactory : public virtual iBase
    00551 {
    00552   SCF_INTERFACE(iGenMeshAnimationControlFactory, 2, 0, 0);
    00553
    00557   virtual csPtr<iGenMeshAnimationControl> CreateAnimationControl (
    00558         iMeshObject *mesh) = 0;
    00559
    00564   virtual const char* Load (iDocumentNode* node) = 0;
    00565
    00570   virtual const char* Save (iDocumentNode* parent) = 0;
    00571 };
    00572
    00587 struct iGenMeshAnimationControlType : public virtual iBase
    00588 {
    00589   SCF_INTERFACE(iGenMeshAnimationControlType, 2, 0, 0);
    00590
    00594   virtual csPtr<iGenMeshAnimationControlFactory> CreateAnimationControlFactory
    00595         () = 0;
    00596 };
    00597
    00600 #endif // __CS_IMESH_GENMESH_H__