00001 /* 00002 Implementation of the simplest server portion 00003 of the liveViz3d library. 00004 00005 Orion Sky Lawlor, olawlor@acm.org, 2003/9/13 00006 */ 00007 #include "lv3d0.h" 00008 00009 #ifdef CMK_LIVEVIZ3D_CLIENT 00010 # include "ogl/main.h" 00011 # include "ogl/util.h" 00012 #endif 00013 00015 class LV3D_Universe_Table { 00016 CkHashtableT<CkViewableID,CkView *> table; 00017 public: 00018 void add(CkView *v) { 00019 delete table.get(v->id); 00020 table.put(v->id)=v; 00021 } 00022 00023 CkView *lookup(const CkViewableID &src) { 00024 return table.get(src); 00025 } 00026 00027 void render(const CkViewpoint &vp) { 00028 #ifdef CMK_LIVEVIZ3D_CLIENT 00029 CkHashtableIterator *it=table.iterator(); 00030 void *obj; 00031 while (NULL!=(obj=it->next())) { 00032 CkView *v=*(CkView **)obj; 00033 v->render(1.0,0); 00034 } 00035 delete it; 00036 #endif 00037 } 00038 }; 00039 00040 LV3D_Universe::~LV3D_Universe() { 00041 if (object_table) delete object_table; 00042 } 00043 void LV3D_Universe::pup(PUP::er &p) { 00044 PUP::able::pup(p); 00045 if (object_table) CkAbort("Cannot migrate a LV3D_Universe with objects!\n"); 00046 } 00047 00048 #ifdef CMK_LIVEVIZ3D_CLIENT 00049 00054 void LV3D_Universe::setupClient(oglOptions &i) 00055 { 00056 /* nothing */ 00057 } 00058 void LV3D_Universe::setupGL(void) {} 00059 00064 oglController *LV3D_Universe::makeController(void) 00065 { 00066 return new oglTrackballController(3.0,40.0, CkVector3d(0.5,0.5,0.5)); 00067 } 00068 00074 void LV3D_Universe::viewResponse(CkView *v) { 00075 if (!object_table) { 00076 object_table=new LV3D_Universe_Table; 00077 } 00078 v->ref(); 00079 object_table->add(v); 00080 oglRepaint(10); 00081 } 00082 00083 CkView *LV3D_Universe::lookup(const CkViewableID &src) { 00084 if (object_table) 00085 return object_table->lookup(src); 00086 else 00087 return NULL; 00088 } 00089 00094 void LV3D_Universe::render(const CkViewpoint &vp) { 00095 if (object_table) object_table->render(vp); 00096 } 00097 00098 00099 #endif 00100 00101 00102 PUPable_def(LV3D_Universe) 00103