00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef VMDLINKEDLIST_H__
00023 #define VMDLINKEDLIST_H__
00024
00025 #include <string.h>
00026 #include "Matrix4.h"
00027
00029 struct VMDClipPlane {
00030 float center[3];
00031 float normal[3];
00032 float color[3];
00033 int mode;
00034
00036 VMDClipPlane() {
00037 center[0] = center[1] = center[2] = 0;
00038 normal[0] = normal[1] = 0; normal[2] = 1;
00039 color[0] = color[1] = color[2] = 0.5;
00040 mode = 0;
00041 }
00042 };
00043
00044 #define VMD_MAX_CLIP_PLANE 6
00045
00048 #define PBC_NONE 0x00 // don't draw any PBC images
00049 #define PBC_X 0x01 // +X images
00050 #define PBC_Y 0x02 // +Y images
00051 #define PBC_Z 0x04 // +Z images
00052 #define PBC_OPX 0x08 // -X images
00053 #define PBC_OPY 0x10 // -Y images
00054 #define PBC_OPZ 0x20 // -Z images
00055 #define PBC_NOSELF 0x40 // set this flag to NOT draw the original image
00056
00057
00060 class VMDDisplayList {
00061 private:
00062 struct CommandHeader {
00063 int code;
00064 int size;
00065 };
00066
00067 public:
00068 VMDDisplayList();
00069 ~VMDDisplayList();
00070
00071 void *operator new(size_t);
00072 void operator delete(void *, size_t);
00073
00074 Matrix4 mat;
00075 unsigned long serial;
00076 int cacheskip;
00077 int pbc;
00078 int npbc;
00079 Matrix4 transX, transY, transZ;
00080 Matrix4 transXinv, transYinv, transZinv;
00081
00083
00084 float ambient, specular, diffuse, shininess, opacity;
00085 int materialtag;
00086
00087
00088 VMDClipPlane clipplanes[VMD_MAX_CLIP_PLANE];
00089
00091 void *append(int code, int size);
00092
00093
00094
00095 void reset_and_free(unsigned long newserial);
00096
00098 const VMDClipPlane *clipplane(int i) {
00099 if (i < 0 || i >= VMD_MAX_CLIP_PLANE) return NULL;
00100 return clipplanes+i;
00101 }
00102
00104
00105
00106 int set_clip_center(int i, const float *);
00107 int set_clip_normal(int i, const float *);
00108 int set_clip_color(int i, const float *);
00109 int set_clip_status(int i, int);
00111
00112 struct VMDLinkIter {
00113 char *ptr;
00114 int ncmds;
00115 };
00116
00118 void first(VMDLinkIter *it) const {
00119 it->ptr = pool;
00120 it->ncmds = listsize;
00121 }
00122
00124 int next(VMDLinkIter *it, char *&d) const {
00125 if (!(it->ncmds--)) return -1;
00126 CommandHeader *header = (CommandHeader *)(it->ptr);
00127 int code = header->code;
00128 int size = header->size;
00129 d = it->ptr + sizeof(CommandHeader);
00130 it->ptr += size;
00131 return code;
00132 }
00133
00134 private:
00135
00136 int listsize;
00137
00138
00139 unsigned long poolsize;
00140
00141
00142 unsigned long poolused;
00143
00144
00145 char *pool;
00146 };
00147
00148 #endif