Panda3D
lwoClip.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 lwoClip.cxx
10  * @author drose
11  * @date 2001-04-24
12  */
13 
14 #include "lwoClip.h"
15 #include "iffInputFile.h"
16 #include "lwoStillImage.h"
17 
18 #include "indent.h"
19 
20 TypeHandle LwoClip::_type_handle;
21 
22 /**
23  * Reads the data of the chunk in from the given input file, if possible. The
24  * ID and length of the chunk have already been read. stop_at is the byte
25  * position of the file to stop at (based on the current position at
26  * in->get_bytes_read()). Returns true on success, false otherwise.
27  */
28 bool LwoClip::
29 read_iff(IffInputFile *in, size_t stop_at) {
30  _index = in->get_be_int32();
31  read_subchunks_iff(in, stop_at);
32  return true;
33 }
34 
35 /**
36  *
37  */
38 void LwoClip::
39 write(std::ostream &out, int indent_level) const {
40  indent(out, indent_level)
41  << get_id() << " {\n";
42  indent(out, indent_level + 2)
43  << "index = " << _index << "\n";
44  write_chunks(out, indent_level + 2);
45  indent(out, indent_level)
46  << "}\n";
47 }
48 
49 /**
50  * Allocates and returns a new chunk of the appropriate type based on the
51  * given ID, according to the context given by this chunk itself.
52  */
55  if (id == IffId("STIL")) {
56  return new LwoStillImage;
57 
58  } else {
59  return IffChunk::make_new_chunk(in, id);
60  }
61 }
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: lwoClip.cxx:54
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
int32_t get_be_int32()
Extracts a signed 32-bit big-endian integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on.
Definition: iffChunk.h:30
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
A single still image associated with a LwoClip chunk.
Definition: lwoStillImage.h:26
virtual bool read_iff(IffInputFile *in, size_t stop_at)
Reads the data of the chunk in from the given input file, if possible.
Definition: lwoClip.cxx:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
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.