Panda3D

Loading...
Searching...
No Matches
lwoHeader.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 lwoHeader.cxx
10 * @author drose
11 * @date 2001-04-24
12 */
13
14#include "lwoHeader.h"
15#include "lwoInputFile.h"
16
17#include "dcast.h"
18#include "indent.h"
19
20 TypeHandle LwoHeader::_type_handle;
21
22/**
23 *
24 */
25LwoHeader::
26LwoHeader() {
27 _valid = false;
28 _version = 0.0;
29}
30
31/**
32 * Reads the data of the chunk in from the given input file, if possible. The
33 * ID and length of the chunk have already been read. stop_at is the byte
34 * position of the file to stop at (based on the current position at
35 * in->get_bytes_read()). Returns true on success, false otherwise.
36 */
37 bool LwoHeader::
38 read_iff(IffInputFile *in, size_t stop_at) {
39 LwoInputFile *lin = DCAST(LwoInputFile, in);
40
41 _lwid = lin->get_id();
42
43 if (_lwid == IffId("LWO2")) {
44 _valid = true;
45 _version = 6.0;
46 } else if (_lwid == IffId("LWOB")) {
47 _valid = true;
48 _version = 5.0;
49 }
50
51 if (_valid) {
52 lin->set_lwo_version(_version);
53 }
54
55 read_chunks_iff(lin, stop_at);
56
57 return true;
58}
59
60/**
61 *
62 */
63 void LwoHeader::
64write(std::ostream &out, int indent_level) const {
65 indent(out, indent_level)
66 << get_id() << " {\n";
67 indent(out, indent_level + 2)
68 << "id = " << _lwid << "\n";
69 write_chunks(out, indent_level + 2);
70 indent(out, indent_level)
71 << "}\n";
72}
IffChunk::get_id
IffId get_id() const
Returns the ID associated with this chunk.
Definition iffChunk.I:25
IffId
A four-byte chunk ID appearing in an "IFF" file.
Definition iffId.h:26
IffInputFile
A wrapper around an istream used for reading an IFF file.
Definition iffInputFile.h:30
IffInputFile::get_id
IffId get_id()
Extracts a 4-character IFF ID.
Definition iffInputFile.cxx:196
LwoHeader::read_iff
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 lwoHeader.cxx:38
LwoInputFile
A specialization of IffInputFile to handle reading a Lightwave Object file.
Definition lwoInputFile.h:26
LwoInputFile::set_lwo_version
void set_lwo_version(double version)
Changes the version number reported for the Lightwave file.
Definition lwoInputFile.I:29
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
dcast.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
indent
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
indent.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoHeader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoInputFile.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.