00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_THING_H__
00020 #define __CS_THING_H__
00021
00022 #include "csgeom/transfrm.h"
00023 #include "csutil/csobject.h"
00024 #include "csutil/nobjvec.h"
00025 #include "csengine/bsp.h"
00026 #include "csutil/util.h"
00027 #include "csutil/flags.h"
00028 #include "csutil/cscolor.h"
00029 #include "csutil/csvector.h"
00030 #include "csutil/garray.h"
00031 #include "ivaria/polymesh.h"
00032 #include "iengine/viscull.h"
00033 #include "iengine/mesh.h"
00034 #include "iengine/rview.h"
00035 #include "imesh/thing/thing.h"
00036 #include "imesh/object.h"
00037 #include "imesh/lighting.h"
00038 #include "iutil/eventh.h"
00039 #include "iutil/comp.h"
00040
00041 class csSector;
00042 class csEngine;
00043 class csStatLight;
00044 class csMaterialWrapper;
00045 class csMaterialList;
00046 class csThing;
00047 class csPolygon3D;
00048 class csPolygonInt;
00049 class csPolygonTree;
00050 class csPolygon2D;
00051 class csPolygon2DQueue;
00052 class csFrustumList;
00053 struct iShadowBlockList;
00054 struct csVisObjInfo;
00055 struct iGraphics3D;
00056 struct iRenderView;
00057 struct iMovable;
00058 struct iFrustumView;
00059 struct iMaterialWrapper;
00060 struct iPolygonBuffer;
00061
00078 struct csThingBBox
00079 {
00080 int i1, i2, i3, i4, i5, i6, i7, i8;
00081 };
00082
00088 struct csThingEdge
00089 {
00090 int num_polygons;
00091 int* polygon_indices;
00092 };
00093
00115 class csThing : public csObject
00116 {
00117 private:
00119 unsigned int thing_id;
00121 static int last_thing_id;
00123 unsigned long last_polygon_id;
00125 char* cachename;
00126
00128 int num_vertices;
00130 int max_vertices;
00131
00133 csVector3* obj_verts;
00139 csVector3* wor_verts;
00141 csVector3* cam_verts;
00143 int num_cam_verts;
00145 long cameranr;
00146
00152 long movablenr;
00156 iMovable* cached_movable;
00161 int cfg_moving;
00162
00164 csPolygonArray polygons;
00170 csVector portal_polygons;
00171
00176 iPolygonBuffer* polybuf;
00180 iMaterialWrapper** polybuf_materials;
00181 int polybuf_material_count;
00182
00184 CS_DECLARE_GROWING_ARRAY (thing_edges, csThingEdge);
00186 bool thing_edges_valid;
00187
00189 csCurvesArray curves;
00194 bool curves_transf_ok;
00195
00197 csThingBBox* bbox;
00198
00200 csBox3 obj_bbox;
00206 csBox3 wor_bbox;
00208 long wor_bbox_movablenr;
00209
00211 bool obj_bbox_valid;
00212
00214 csVector3 obj_radius;
00216 float max_obj_radius;
00217
00222 long light_frame_number;
00223
00225 csFog fog;
00226
00231 csVector visobjects;
00232
00237 csPolygonTree* static_tree;
00238
00240 int center_idx;
00241
00243 csThing* ParentTemplate;
00245 iBase* logparent;
00246
00248 bool prepared;
00249
00254 csVector3 curves_center;
00259 float curves_scale;
00260
00262 csVector3* curve_vertices;
00264 csVector2* curve_texels;
00265
00267 int num_curve_vertices;
00269 int max_curve_vertices;
00270
00271 float current_lod;
00272 uint32 current_features;
00273
00274 public:
00276 csFlags flags;
00277
00284 static long current_light_frame_number;
00285
00292 int draw_busy;
00293
00294 private:
00300 void PreparePolygonBuffer ();
00301
00306 void InvalidateThing ();
00307
00314 void DrawPolygonArrayDPM (csPolygonInt** polygon, int num,
00315 iRenderView* rview, iMovable* movable, csZBufMode zMode);
00316
00320 static void DrawPolygonArray (csPolygonInt** polygon, int num,
00321 iRenderView* rview, csZBufMode zMode);
00322
00328 static void* TestQueuePolygonArray (csPolygonInt** polygon, int num,
00329 iRenderView* d, csPolygon2DQueue* poly_queue, bool pvs);
00330
00335 static void DrawOnePolygon (csPolygon3D* p, csPolygon2D* poly,
00336 iRenderView* d, csZBufMode zMode);
00337
00342 static void* TestQueuePolygons (csThing*, csPolygonInt** polygon,
00343 int num, bool same_plane, void* data);
00344
00349 void DrawPolygonsFromQueue (csPolygon2DQueue* queue, iRenderView* rview);
00350
00355 static void* DrawPolygons (csThing*, csPolygonInt** polygon,
00356 int num, bool same_plane, void* data);
00357
00362 void CheckVisUpdate (csVisObjInfo* vinf);
00363
00368 void UpdateCurveTransform (const csReversibleTransform& movtrans);
00369
00375 void UpdateCurveTransform ();
00376
00378 void CleanupThingEdgeTable ();
00379
00381 void ComputeThingEdgeTable ();
00382
00384 void GenerateCacheName ();
00385
00386 public:
00390 csThing (iBase* parent);
00391
00393 virtual ~csThing ();
00394
00395
00396
00397
00398
00400 int AddVertex (const csVector3& v) { return AddVertex (v.x, v.y, v.z); }
00401
00403 int AddVertex (float x, float y, float z);
00404
00413 int AddVertexSmart (const csVector3& v)
00414 {
00415 return AddVertexSmart (v.x, v.y, v.z);
00416 }
00417
00426 int AddVertexSmart (float x, float y, float z);
00427
00438 void CompressVertices ();
00439
00445 void RemoveUnusedVertices ();
00446
00448 const csVector3& Vobj (int idx) const { return obj_verts[idx]; }
00449
00455 const csVector3& Vwor (int idx) const { return wor_verts[idx]; }
00456
00462 const csVector3& Vcam (int idx) const { return cam_verts[idx]; }
00463
00465 int GetVertexCount () const { return num_vertices; }
00466
00468 void SetVertex (int idx, const csVector3& vt);
00469
00471 void DeleteVertex (int idx);
00472
00474 void DeleteVertices (int from, int to);
00475
00476
00477
00478
00479
00481 void AddPolygon (csPolygonInt* spoly);
00482
00484 csPolygon3D* NewPolygon (csMaterialWrapper* material);
00485
00487 int GetPolygonCount ()
00488 { return polygons.Length (); }
00489
00491 csPolygonInt* GetPolygonInt (int idx);
00492
00494 csPolygon3D *GetPolygon3D (int idx)
00495 { return polygons.Get (idx); }
00496
00498 csPolygon3D *GetPolygon3D (const char* name);
00499
00501 csPolygonArray& GetPolygonArray () { return polygons; }
00502
00506 unsigned long GetNewPolygonID ()
00507 {
00508 last_polygon_id++;
00509 return last_polygon_id;
00510 }
00511
00513 int FindPolygonIndex (iPolygon3D* polygon) const;
00514
00516 void RemovePolygon (int idx);
00517
00519 void RemovePolygons ();
00520
00521
00522
00523
00524
00526 void AddCurve (csCurve* curve);
00527
00529 int GetCurveCount () const
00530 { return curves.Length (); }
00531
00533 csCurve* GetCurve (int idx) const
00534 { return curves.Get (idx); }
00535
00537 iCurve* CreateCurve (iCurveTemplate* tmpl);
00538
00540 int FindCurveIndex (iCurve* curve) const;
00541
00543 void RemoveCurve (int idx);
00544
00546 void RemoveCurves ();
00547
00549 csCurve* GetCurve (char* name) const;
00550
00552 int GetCurveVertexCount () const { return num_curve_vertices; }
00553
00555 csVector3& GetCurveVertex (int i) const { return curve_vertices[i]; }
00556
00558 csVector3* GetCurveVertices () const { return curve_vertices; }
00559
00561 csVector2& GetCurveTexel (int i) const { return curve_texels[i]; }
00562
00564 void SetCurveVertex (int idx, const csVector3& vt);
00565
00567 void SetCurveTexel (int idx, const csVector2& vt);
00568
00570 void ClearCurveVertices ();
00571
00573 int AddCurveVertex (const csVector3& v, const csVector2& t);
00574
00576 float GetCurvesScale () const { return curves_scale; }
00577
00579 void SetCurvesScale (float f) { curves_scale = f; }
00580
00582 const csVector3& GetCurvesCenter () const { return curves_center; }
00583
00585 void SetCurvesCenter (csVector3& v) { curves_center = v; }
00586
00587
00588
00589
00590
00598 void Prepare ();
00599
00606 void Merge (csThing* other);
00607
00611 void MergeTemplate (iThingState* tpl,
00612 iMaterialWrapper* default_material = NULL,
00613 csVector3* shift = NULL, csMatrix3* transform = NULL);
00614
00622 void ReplaceMaterials (iMaterialList* matList, const char* prefix);
00623
00625 void SetTemplate (csThing *t)
00626 { ParentTemplate = t; }
00627
00629 csThing *GetTemplate () const
00630 { return ParentTemplate; }
00631
00632
00633
00634
00635
00645 void CreateBoundingBox ();
00646
00648 csThingBBox* GetBoundingBox ()
00649 {
00650 if (!bbox) CreateBoundingBox ();
00651 return bbox;
00652 }
00653
00657 void GetTransformedBoundingBox (
00658 const csReversibleTransform& trans, csBox3& cbox);
00659
00663 float GetScreenBoundingBox (
00664 float fov, float sx, float sy,
00665 const csReversibleTransform& trans, csBox2& sbox, csBox3& cbox);
00666
00671 void GetBoundingBox (csBox3& box);
00672
00676 void GetBoundingBox (iMovable* movable, csBox3& box);
00677
00681 void GetRadius (csVector3& rad, csVector3& cent);
00682
00688 void AddPortalPolygon (csPolygon3D* poly);
00689
00693 void RemovePortalPolygon (csPolygon3D* poly);
00694
00695
00696
00697
00698
00702 csPolygonTree* GetStaticTree () { return static_tree; }
00703
00710 void BuildStaticTree (const char* name, int mode = BSP_MINIMIZE_SPLITS);
00711
00713 void RegisterVisObject (iVisibilityObject* visobj);
00715 void UnregisterVisObject (iVisibilityObject* visobj);
00716
00722 bool VisTest (iRenderView* irview);
00723
00724
00725
00726
00727
00729 void RegisterShadowReceiver (iShadowReceiver* receiver);
00731 void UnregisterShadowReceiver (iShadowReceiver* receiver);
00732
00736 void CastShadows (iFrustumView* fview);
00737
00738
00739
00740
00741
00745 bool DrawTest (iRenderView* rview, iMovable* movable);
00746
00750 bool Draw (iRenderView* rview, iMovable* movable, csZBufMode zMode);
00751
00755 bool DrawCurves (iRenderView* rview, iMovable* movable, csZBufMode zMode);
00756
00761 bool DrawFoggy (iRenderView* rview, iMovable* movable);
00762
00763
00764
00765
00766
00770 void InitializeDefault ();
00771
00775 bool ReadFromCache (iCacheManager* cache_mgr, int id);
00776
00780 bool WriteToCache (iCacheManager* cache_mgr, int id);
00781
00786 void PrepareLighting ();
00787
00789 void SetCacheName (const char* n)
00790 {
00791 delete[] cachename;
00792 cachename = n ? csStrNew (n) : 0;
00793 }
00795 const char* GetCacheName ();
00796
00797
00798
00799
00800
00809 csPolygon3D* IntersectSphere (csVector3& center, float radius,
00810 float* pr = NULL);
00811
00823 csPolygon3D* IntersectSegment (const csVector3& start,
00824 const csVector3& end, csVector3& isect,
00825 float* pr = NULL, bool only_portals = false);
00826
00841 csPolygon3D* IntersectSegmentFull (const csVector3& start,
00842 const csVector3& end, csVector3& isect,
00843 float* pr = NULL, csMeshWrapper** p_mesh = NULL);
00844
00848 void RealCheckFrustum (iFrustumView* lview, iMovable* movable);
00849
00854 void CheckFrustum (iFrustumView* lview, iMovable* movable);
00855
00863 void AppendShadows (iMovable* movable, iShadowBlockList* shadows,
00864 csVector3& origin);
00865
00866
00867
00868
00869
00874 void UpdateTransformation (const csTransform& c, long cam_cameranr);
00875
00877 void WorUpdate ();
00878
00886 void HardTransform (const csReversibleTransform& t);
00887
00889 csVector3* GetCameraVertices (const csTransform& c, long cam_cameranr)
00890 {
00891 UpdateTransformation (c, cam_cameranr);
00892 return cam_verts;
00893 }
00894
00895
00896
00897
00898
00902 void SetMovingOption (int opt);
00903
00907 int GetMovingOption () const { return cfg_moving; }
00908
00914 void SetConvex (bool c);
00915
00921 int GetCenter () { return center_idx; }
00922
00924 bool HasFog () { return fog.enabled; }
00925
00927 csFog& GetFog () { return fog; }
00928
00930 void SetFog (float density, const csColor& color)
00931 {
00932 fog.enabled = true;
00933 fog.density = density;
00934 fog.red = color.red;
00935 fog.green = color.green;
00936 fog.blue = color.blue;
00937 }
00938
00940 void DisableFog () { fog.enabled = false; }
00941
00942 SCF_DECLARE_IBASE_EXT (csObject);
00943
00944
00945 struct ThingState : public iThingState
00946 {
00947 SCF_DECLARE_EMBEDDED_IBASE (csThing);
00948 virtual void* GetPrivateObject () { return (void*)scfParent; }
00949 virtual iObject* QueryObject () { return scfParent; }
00950 virtual void CompressVertices () { scfParent->CompressVertices(); }
00951
00952 virtual int GetPolygonCount () { return scfParent->polygons.Length (); }
00953 virtual iPolygon3D *GetPolygon (int idx);
00954 virtual iPolygon3D *GetPolygon (const char* name);
00955 virtual iPolygon3D *CreatePolygon (const char *iName);
00956 virtual int FindPolygonIndex (iPolygon3D* polygon) const
00957 { return scfParent->FindPolygonIndex (polygon); }
00958 virtual void RemovePolygon (int idx)
00959 { scfParent->RemovePolygon (idx); }
00960 virtual void RemovePolygons ()
00961 { scfParent->RemovePolygons (); }
00962
00963 virtual int GetPortalCount () const;
00964 virtual iPortal* GetPortal (int idx) const;
00965 virtual iPolygon3D* GetPortalPolygon (int idx) const;
00966
00967 virtual int GetVertexCount () const { return scfParent->num_vertices; }
00968 virtual const csVector3 &GetVertex (int i) const
00969 { return scfParent->obj_verts[i]; }
00970 virtual const csVector3* GetVertices () const
00971 { return scfParent->obj_verts; }
00972 virtual const csVector3 &GetVertexW (int i) const
00973 { return scfParent->wor_verts[i]; }
00974 virtual const csVector3* GetVerticesW () const
00975 { return scfParent->wor_verts; }
00976 virtual const csVector3 &GetVertexC (int i) const
00977 { return scfParent->cam_verts[i]; }
00978 virtual const csVector3* GetVerticesC () const
00979 { return scfParent->cam_verts; }
00980 virtual int CreateVertex (const csVector3 &iVertex)
00981 { return scfParent->AddVertex (iVertex.x, iVertex.y, iVertex.z); }
00982 virtual void SetVertex (int idx, const csVector3& vt)
00983 { scfParent->SetVertex (idx, vt); }
00984 virtual void DeleteVertex (int idx)
00985 { scfParent->DeleteVertex (idx); }
00986 virtual void DeleteVertices (int from, int to)
00987 { scfParent->DeleteVertices (from, to); }
00988
00989 virtual void CheckFrustum (iFrustumView* fview, iMovable* movable)
00990 { scfParent->CheckFrustum (fview, movable); }
00991 virtual csFlags& GetFlags () { return scfParent->flags; }
00992 virtual int GetMovingOption () const
00993 { return scfParent->GetMovingOption (); }
00994 virtual void SetMovingOption (int opt)
00995 { scfParent->SetMovingOption (opt); }
00996
00997 virtual const csVector3& GetCurvesCenter () const
00998 { return scfParent->curves_center; }
00999 virtual void SetCurvesCenter (const csVector3& cen)
01000 { scfParent->curves_center = cen; }
01001 virtual float GetCurvesScale () const
01002 { return scfParent->curves_scale; }
01003 virtual void SetCurvesScale (float scale)
01004 { scfParent->curves_scale = scale; }
01005 virtual int GetCurveCount () const
01006 { return scfParent->GetCurveCount (); }
01007 virtual int GetCurveVertexCount () const
01008 { return scfParent->GetCurveVertexCount (); }
01009 virtual csVector3& GetCurveVertex (int i) const
01010 { return scfParent->GetCurveVertex (i); }
01011 virtual csVector3* GetCurveVertices () const
01012 { return scfParent->GetCurveVertices (); }
01013 virtual csVector2& GetCurveTexel (int i) const
01014 { return scfParent->GetCurveTexel (i); }
01015 virtual void SetCurveVertex (int idx, const csVector3& vt)
01016 { scfParent->SetCurveVertex (idx, vt); }
01017 virtual void SetCurveTexel (int idx, const csVector2& vt)
01018 { scfParent->SetCurveTexel (idx, vt); }
01019 virtual void ClearCurveVertices ()
01020 { scfParent->ClearCurveVertices (); }
01021 virtual iCurve* GetCurve (int idx) const;
01022 virtual iCurve* CreateCurve (iCurveTemplate* tmpl)
01023 { return scfParent->CreateCurve (tmpl); }
01024 virtual int FindCurveIndex (iCurve* curve) const
01025 { return scfParent->FindCurveIndex (curve); }
01026 virtual void RemoveCurve (int idx)
01027 { scfParent->RemoveCurve (idx); }
01028 virtual void RemoveCurves ()
01029 { scfParent->RemoveCurves (); }
01030
01031 virtual void MergeTemplate (iThingState* tpl,
01032 iMaterialWrapper* default_material = NULL,
01033 csVector3* shift = NULL, csMatrix3* transform = NULL)
01034 {
01035 scfParent->MergeTemplate (tpl, default_material, shift, transform);
01036 }
01037 virtual void ReplaceMaterials (iMaterialList* materials,
01038 const char* prefix)
01039 {
01040 scfParent->ReplaceMaterials (materials, prefix);
01041 }
01042 virtual void AddCurveVertex (const csVector3& v, const csVector2& uv)
01043 {
01044 scfParent->AddCurveVertex (v, uv);
01045 }
01046 virtual bool HasFog () const
01047 { return scfParent->HasFog (); }
01048 virtual csFog *GetFog () const
01049 { return &scfParent->GetFog (); }
01050 } scfiThingState;
01051 friend struct ThingState;
01052
01053
01054 struct LightingInfo : public iLightingInfo
01055 {
01056 SCF_DECLARE_EMBEDDED_IBASE (csThing);
01057 virtual void InitializeDefault ()
01058 {
01059 scfParent->InitializeDefault ();
01060 }
01061 virtual bool ReadFromCache (iCacheManager* cache_mgr, int id)
01062 {
01063 return scfParent->ReadFromCache (cache_mgr, id);
01064 }
01065 virtual bool WriteToCache (iCacheManager* cache_mgr, int id)
01066 {
01067 return scfParent->WriteToCache (cache_mgr, id);
01068 }
01069 virtual void PrepareLighting ()
01070 {
01071 scfParent->PrepareLighting ();
01072 }
01073 virtual void SetCacheName (const char* cachename)
01074 {
01075 scfParent->SetCacheName (cachename);
01076 }
01077 virtual const char* GetCacheName () const
01078 {
01079 return scfParent->GetCacheName ();
01080 }
01081 } scfiLightingInfo;
01082 friend struct LightingInfo;
01083
01084
01085 struct PolyMesh : public iPolygonMesh
01086 {
01087 PolyMesh () : polygons (NULL), vertices (NULL), alloc_vertices (NULL) { }
01088 virtual ~PolyMesh () { Cleanup (); }
01089 void Setup ();
01090
01091 SCF_DECLARE_EMBEDDED_IBASE (csThing);
01092
01093 virtual int GetVertexCount ()
01094 {
01095 Setup ();
01096 return num_verts;
01097 }
01098 virtual csVector3* GetVertices ()
01099 {
01100 Setup ();
01101 return vertices;
01102 }
01103 virtual int GetPolygonCount ()
01104 {
01105 Setup ();
01106 return num_poly;
01107 }
01108 virtual csMeshedPolygon* GetPolygons ()
01109 {
01110 Setup ();
01111 return polygons;
01112 }
01113 virtual void Cleanup ();
01114
01115 csMeshedPolygon* polygons;
01116 csVector3* vertices;
01117
01118 csVector3* alloc_vertices;
01119
01120
01121 int num_poly;
01122 int curve_poly_start;
01123
01124
01125 int num_verts;
01126 } scfiPolygonMesh;
01127 friend struct PolyMesh;
01128
01129
01130 struct VisCull : public iVisibilityCuller
01131 {
01132 SCF_DECLARE_EMBEDDED_IBASE (csThing);
01133 virtual void Setup (const char* name)
01134 {
01135 scfParent->BuildStaticTree (name, BSP_MINIMIZE_SPLITS);
01136 }
01137 virtual void RegisterVisObject (iVisibilityObject* visobj)
01138 {
01139 scfParent->RegisterVisObject (visobj);
01140 }
01141 virtual void UnregisterVisObject (iVisibilityObject* visobj)
01142 {
01143 scfParent->UnregisterVisObject (visobj);
01144 }
01145 virtual bool VisTest (iRenderView* irview)
01146 {
01147 return scfParent->VisTest (irview);
01148 }
01149 virtual iPolygon3D* IntersectSegment (const csVector3& start,
01150 const csVector3& end, csVector3& isect, float* pr = NULL,
01151 iMeshWrapper** p_mesh = NULL);
01152 virtual bool SupportsShadowCasting ()
01153 {
01154 return true;
01155 }
01156 virtual void RegisterShadowReceiver (iShadowReceiver* receiver)
01157 {
01158 scfParent->RegisterShadowReceiver (receiver);
01159 }
01160 virtual void UnregisterShadowReceiver (iShadowReceiver* receiver)
01161 {
01162 scfParent->UnregisterShadowReceiver (receiver);
01163 }
01164 virtual void CastShadows (iFrustumView* fview)
01165 {
01166 scfParent->CastShadows (fview);
01167 }
01168 } scfiVisibilityCuller;
01169 friend struct VisCull;
01170
01171
01172 struct MeshObject : public iMeshObject
01173 {
01174 SCF_DECLARE_EMBEDDED_IBASE (csThing);
01175 virtual iMeshObjectFactory* GetFactory () const;
01176 virtual bool DrawTest (iRenderView* rview, iMovable* movable)
01177 {
01178 return scfParent->DrawTest (rview, movable);
01179 }
01180 virtual void UpdateLighting (iLight** , int ,
01181 iMovable* ) { }
01182 virtual bool Draw (iRenderView* rview, iMovable* movable,
01183 csZBufMode zMode)
01184 {
01185 return scfParent->Draw (rview, movable, zMode);
01186 }
01187 virtual void SetVisibleCallback (iMeshObjectDrawCallback* ) { }
01188 virtual iMeshObjectDrawCallback* GetVisibleCallback () const
01189 { return NULL; }
01190 virtual void GetObjectBoundingBox (csBox3& bbox,
01191 int )
01192 {
01193 scfParent->GetBoundingBox (bbox);
01194 }
01195 virtual void GetRadius ( csVector3& rad, csVector3& cent)
01196 { scfParent->GetRadius (rad,cent); }
01197 virtual void NextFrame (csTicks ) { }
01198 virtual bool WantToDie () const { return false; }
01199 virtual void HardTransform (const csReversibleTransform& t)
01200 {
01201 scfParent->HardTransform (t);
01202 }
01203 virtual bool SupportsHardTransform () const { return true; }
01204 virtual bool HitBeamOutline (const csVector3&, const csVector3&,
01205 csVector3&, float*)
01206 { return false; }
01207 virtual bool HitBeamObject (const csVector3& ,
01208 const csVector3& ,
01209 csVector3& , float* ) { return false; }
01210 virtual long GetShapeNumber () const { return 0; }
01211 virtual void SetLogicalParent (iBase* lp) { scfParent->logparent = lp; }
01212 virtual iBase* GetLogicalParent () const { return scfParent->logparent; }
01213 } scfiMeshObject;
01214 friend struct MeshObject;
01215
01216
01217 struct MeshObjectFactory : public iMeshObjectFactory
01218 {
01219 SCF_DECLARE_EMBEDDED_IBASE (csThing);
01220 virtual iMeshObject* NewInstance ();
01221 virtual void HardTransform (const csReversibleTransform& t)
01222 {
01223 scfParent->HardTransform (t);
01224 }
01225 virtual bool SupportsHardTransform () const { return true; }
01226 virtual void SetLogicalParent (iBase* lp) { scfParent->logparent = lp; }
01227 virtual iBase* GetLogicalParent () const { return scfParent->logparent; }
01228 } scfiMeshObjectFactory;
01229 friend struct MeshObjectFactory;
01230 };
01231
01236 class csThingObjectType : public iMeshObjectType
01237 {
01238 private:
01239 iObjectRegistry* object_reg;
01240
01247 csNamedObjVector planes;
01248
01253 csNamedObjVector curve_templates;
01254
01255 public:
01256 SCF_DECLARE_IBASE;
01257
01259 csThingObjectType (iBase*);
01260
01262 virtual ~csThingObjectType ();
01263
01265 virtual bool Initialize (iObjectRegistry *object_reg);
01266
01268 virtual iMeshObjectFactory* NewFactory ();
01269
01270 iPolyTxtPlane* CreatePolyTxtPlane (const char* name = NULL);
01271 iPolyTxtPlane* FindPolyTxtPlane (const char* name);
01272 iCurveTemplate* CreateBezierTemplate (const char* name = NULL);
01273 iCurveTemplate* FindCurveTemplate (const char *iName);
01274 void RemovePolyTxtPlane (iPolyTxtPlane* pl);
01275 void RemoveCurveTemplate (iCurveTemplate* ct);
01276 void ClearPolyTxtPlanes ();
01277 void ClearCurveTemplates ();
01278
01279 struct eiThingEnvironment : public iThingEnvironment
01280 {
01281 SCF_DECLARE_EMBEDDED_IBASE(csThingObjectType);
01282 virtual iPolyTxtPlane* CreatePolyTxtPlane (const char* name = NULL)
01283 {
01284 return scfParent->CreatePolyTxtPlane (name);
01285 }
01286 virtual iPolyTxtPlane* FindPolyTxtPlane (const char* name)
01287 {
01288 return scfParent->FindPolyTxtPlane (name);
01289 }
01290 virtual iCurveTemplate* CreateBezierTemplate (const char* name = NULL)
01291 {
01292 return scfParent->CreateBezierTemplate (name);
01293 }
01294 virtual iCurveTemplate* FindCurveTemplate (const char* name)
01295 {
01296 return scfParent->FindCurveTemplate (name);
01297 }
01298 virtual void RemovePolyTxtPlane (iPolyTxtPlane* pl)
01299 {
01300 scfParent->RemovePolyTxtPlane (pl);
01301 }
01302 virtual void RemoveCurveTemplate (iCurveTemplate* ct)
01303 {
01304 scfParent->RemoveCurveTemplate (ct);
01305 }
01306 virtual void ClearPolyTxtPlanes ()
01307 {
01308 scfParent->ClearPolyTxtPlanes ();
01309 }
01310 virtual void ClearCurveTemplates ()
01311 {
01312 scfParent->ClearCurveTemplates ();
01313 }
01314 } scfiThingEnvironment;
01315
01316 struct eiComponent : public iComponent
01317 {
01318 SCF_DECLARE_EMBEDDED_IBASE(csThingObjectType);
01319 virtual bool Initialize (iObjectRegistry* p)
01320 { return scfParent->Initialize(p); }
01321 } scfiComponent;
01322 };
01323
01324 #endif // __CS_THING_H__