00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "lwoSurfaceBlock.h"
00020 #include "iffInputFile.h"
00021 #include "lwoSurfaceBlockAxis.h"
00022 #include "lwoSurfaceBlockImage.h"
00023 #include "lwoSurfaceBlockHeader.h"
00024 #include "lwoSurfaceBlockProjection.h"
00025 #include "lwoSurfaceBlockRepeat.h"
00026 #include "lwoSurfaceBlockTMap.h"
00027 #include "lwoSurfaceBlockWrap.h"
00028 #include "lwoSurfaceBlockVMapName.h"
00029
00030 #include "dcast.h"
00031 #include "indent.h"
00032
00033 TypeHandle LwoSurfaceBlock::_type_handle;
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 bool LwoSurfaceBlock::
00046 read_iff(IffInputFile *in, size_t stop_at) {
00047 PT(IffChunk) chunk = in->get_subchunk(this);
00048 if (chunk == (IffChunk *)NULL) {
00049 return false;
00050 }
00051 if (!chunk->is_of_type(LwoSurfaceBlockHeader::get_class_type())) {
00052 nout << "Invalid chunk for header of surface block: " << *chunk << "\n";
00053 return false;
00054 }
00055
00056 _header = DCAST(LwoSurfaceBlockHeader, chunk);
00057
00058 read_subchunks_iff(in, stop_at);
00059 return true;
00060 }
00061
00062
00063
00064
00065
00066
00067 void LwoSurfaceBlock::
00068 write(ostream &out, int indent_level) const {
00069 indent(out, indent_level)
00070 << get_id() << " {\n";
00071 _header->write(out, indent_level + 2);
00072 out << "\n";
00073 write_chunks(out, indent_level + 2);
00074 indent(out, indent_level)
00075 << "}\n";
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085 IffChunk *LwoSurfaceBlock::
00086 make_new_chunk(IffInputFile *in, IffId id) {
00087 if (id == IffId("IMAP") ||
00088 id == IffId("PROC") ||
00089 id == IffId("GRAD") ||
00090 id == IffId("SHDR")) {
00091 return new LwoSurfaceBlockHeader;
00092
00093 } else if (id == IffId("TMAP")) {
00094 return new LwoSurfaceBlockTMap;
00095
00096 } else if (id == IffId("PROJ")) {
00097 return new LwoSurfaceBlockProjection;
00098
00099 } else if (id == IffId("AXIS")) {
00100 return new LwoSurfaceBlockAxis;
00101
00102 } else if (id == IffId("IMAG")) {
00103 return new LwoSurfaceBlockImage;
00104
00105 } else if (id == IffId("WRAP")) {
00106 return new LwoSurfaceBlockWrap;
00107
00108 } else if (id == IffId("WRPH") ||
00109 id == IffId("WRPW")) {
00110 return new LwoSurfaceBlockRepeat;
00111
00112 } else if (id == IffId("VMAP")) {
00113 return new LwoSurfaceBlockVMapName;
00114
00115 } else {
00116 return IffChunk::make_new_chunk(in, id);
00117 }
00118 }
00119