00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "lwoInputFile.h"
00016 #include "lwoBoundingBox.h"
00017 #include "lwoClip.h"
00018 #include "lwoDiscontinuousVertexMap.h"
00019 #include "lwoHeader.h"
00020 #include "lwoLayer.h"
00021 #include "lwoPoints.h"
00022 #include "lwoPolygons.h"
00023 #include "lwoPolygonTags.h"
00024 #include "lwoTags.h"
00025 #include "lwoSurface.h"
00026 #include "lwoVertexMap.h"
00027
00028 TypeHandle LwoInputFile::_type_handle;
00029
00030
00031
00032
00033
00034
00035 LwoInputFile::
00036 LwoInputFile() {
00037 }
00038
00039
00040
00041
00042
00043
00044 LwoInputFile::
00045 ~LwoInputFile() {
00046 }
00047
00048
00049
00050
00051
00052
00053
00054 int LwoInputFile::
00055 get_vx() {
00056 PN_uint16 top = get_be_uint16();
00057 if ((top & 0xff00) == 0xff00) {
00058
00059
00060 PN_uint16 bottom = get_be_uint16();
00061 return ((int)(top & 0xff) << 16) | bottom;
00062 }
00063
00064
00065
00066 return top;
00067 }
00068
00069
00070
00071
00072
00073
00074 LVecBase3 LwoInputFile::
00075 get_vec3() {
00076 LVecBase3 result;
00077 result[0] = get_be_float32();
00078 result[1] = get_be_float32();
00079 result[2] = get_be_float32();
00080 return result;
00081 }
00082
00083
00084
00085
00086
00087
00088
00089 Filename LwoInputFile::
00090 get_filename() {
00091 string name = get_string();
00092 size_t colon = name.find(':');
00093 if (colon == string::npos) {
00094
00095 return Filename(name);
00096 }
00097
00098
00099 string device = name.substr(0, colon);
00100 string path = name.substr(colon + 1);
00101
00102 nout << "Ignoring filename device " << device << "\n";
00103 return Filename("/", path);
00104 }
00105
00106
00107
00108
00109
00110
00111
00112 IffChunk *LwoInputFile::
00113 make_new_chunk(IffId id) {
00114 if (id == IffId("FORM")) {
00115 return new LwoHeader;
00116
00117 } else if (id == IffId("LAYR")) {
00118 return new LwoLayer;
00119
00120 } else if (id == IffId("PNTS")) {
00121 return new LwoPoints;
00122
00123 } else if (id == IffId("VMAP")) {
00124 return new LwoVertexMap;
00125
00126 } else if (id == IffId("VMAD")) {
00127 return new LwoDiscontinuousVertexMap;
00128
00129 } else if (id == IffId("POLS")) {
00130 return new LwoPolygons;
00131
00132 } else if (id == IffId("TAGS") ||
00133 id == IffId("SRFS")) {
00134 return new LwoTags;
00135
00136 } else if (id == IffId("PTAG")) {
00137 return new LwoPolygonTags;
00138
00139 } else if (id == IffId("CLIP")) {
00140 return new LwoClip;
00141
00142 } else if (id == IffId("SURF")) {
00143 return new LwoSurface;
00144
00145 } else if (id == IffId("BBOX")) {
00146 return new LwoBoundingBox;
00147
00148 } else {
00149 return IffInputFile::make_new_chunk(id);
00150 }
00151 }