Panda3D
lwoSurfaceBlockTMap.cxx
1 // Filename: lwoSurfaceBlockTMap.cxx
2 // Created by: drose (24Apr01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "lwoSurfaceBlockTMap.h"
16 #include "lwoInputFile.h"
17 #include "lwoSurfaceBlockCoordSys.h"
18 #include "lwoSurfaceBlockTransform.h"
19 #include "lwoSurfaceBlockRefObj.h"
20 
21 #include "dcast.h"
22 #include "indent.h"
23 
24 TypeHandle LwoSurfaceBlockTMap::_type_handle;
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: LwoSurfaceBlockTMap::read_iff
28 // Access: Public, Virtual
29 // Description: Reads the data of the chunk in from the given input
30 // file, if possible. The ID and length of the chunk
31 // have already been read. stop_at is the byte position
32 // of the file to stop at (based on the current position
33 // at in->get_bytes_read()). Returns true on success,
34 // false otherwise.
35 ////////////////////////////////////////////////////////////////////
37 read_iff(IffInputFile *in, size_t stop_at) {
38  LwoInputFile *lin = DCAST(LwoInputFile, in);
39 
40  read_subchunks_iff(lin, stop_at);
41 
42  return true;
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: LwoSurfaceBlockTMap::write
47 // Access: Public, Virtual
48 // Description:
49 ////////////////////////////////////////////////////////////////////
50 void LwoSurfaceBlockTMap::
51 write(ostream &out, int indent_level) const {
52  indent(out, indent_level)
53  << get_id() << " {\n";
54  write_chunks(out, indent_level + 2);
55  indent(out, indent_level)
56  << "}\n";
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: LwoSurfaceBlockTMap::make_new_chunk
61 // Access: Protected, Virtual
62 // Description: Allocates and returns a new chunk of the appropriate
63 // type based on the given ID, according to the context
64 // given by this chunk itself.
65 ////////////////////////////////////////////////////////////////////
68  if (id == IffId("CNTR") ||
69  id == IffId("SIZE") ||
70  id == IffId("ROTA")) {
71  return new LwoSurfaceBlockTransform;
72 
73  } else if (id == IffId("OREF")) {
74  return new LwoSurfaceBlockRefObj;
75 
76  } else if (id == IffId("CSYS")) {
77  return new LwoSurfaceBlockCoordSys;
78 
79  } else {
80  return IffChunk::make_new_chunk(in, id);
81  }
82 }
83 
virtual IffChunk * make_new_chunk(IffInputFile *in, IffId id)
Allocates and returns a new chunk of the appropriate type based on the given ID, according to the con...
Definition: iffChunk.cxx:50
Specifies whether texture coordinates are computed based on the vertices&#39; world coordinates or local ...
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on...
Definition: iffChunk.h:32
virtual bool read_iff(IffInputFile *in, size_t stop_at)
Reads the data of the chunk in from the given input file, if possible.
A wrapper around an istream used for reading an IFF file.
Definition: iffInputFile.h:33
Specifies a center point, scale, or rotation for the texture coordinates in this shader&#39;s texture map...
A specialization of IffInputFile to handle reading a Lightwave Object file.
Definition: lwoInputFile.h:29
Specifies a reference object that the texture UV&#39;s are to be computed relative to.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
virtual IffChunk * make_new_chunk(IffInputFile *in, IffId id)
Allocates and returns a new chunk of the appropriate type based on the given ID, according to the con...
A four-byte chunk ID appearing in an "IFF" file.
Definition: iffId.h:29
IffId get_id() const
Returns the ID associated with this chunk.
Definition: iffChunk.I:31