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