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