Panda3D
 All Classes Functions Variables Enumerations
lwoClip.cxx
1 // Filename: lwoClip.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 "lwoClip.h"
16 #include "iffInputFile.h"
17 #include "lwoStillImage.h"
18 
19 #include "indent.h"
20 
21 TypeHandle LwoClip::_type_handle;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: LwoClip::read_iff
25 // Access: Public, Virtual
26 // Description: Reads the data of the chunk in from the given input
27 // file, if possible. The ID and length of the chunk
28 // have already been read. stop_at is the byte position
29 // of the file to stop at (based on the current position
30 // at in->get_bytes_read()). Returns true on success,
31 // false otherwise.
32 ////////////////////////////////////////////////////////////////////
33 bool LwoClip::
34 read_iff(IffInputFile *in, size_t stop_at) {
35  _index = in->get_be_int32();
36  read_subchunks_iff(in, stop_at);
37  return true;
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: LwoClip::write
42 // Access: Public, Virtual
43 // Description:
44 ////////////////////////////////////////////////////////////////////
45 void LwoClip::
46 write(ostream &out, int indent_level) const {
47  indent(out, indent_level)
48  << get_id() << " {\n";
49  indent(out, indent_level + 2)
50  << "index = " << _index << "\n";
51  write_chunks(out, indent_level + 2);
52  indent(out, indent_level)
53  << "}\n";
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: LwoClip::make_new_chunk
58 // Access: Protected, Virtual
59 // Description: Allocates and returns a new chunk of the appropriate
60 // type based on the given ID, according to the context
61 // given by this chunk itself.
62 ////////////////////////////////////////////////////////////////////
65  if (id == IffId("STIL")) {
66  return new LwoStillImage;
67 
68  } else {
69  return IffChunk::make_new_chunk(in, id);
70  }
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: lwoClip.cxx:64
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
PN_int32 get_be_int32()
Extracts a signed 32-bit big-endian integer.
The basic kind of record in an EA &quot;IFF&quot; file, which the LightWave object file is based on...
Definition: iffChunk.h:32
A wrapper around an istream used for reading an IFF file.
Definition: iffInputFile.h:33
IffId get_id() const
Returns the ID associated with this chunk.
Definition: iffChunk.I:31
A single still image associated with a LwoClip chunk.
Definition: lwoStillImage.h:28
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:34
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A four-byte chunk ID appearing in an &quot;IFF&quot; file.
Definition: iffId.h:29