Panda3D

Loading...
Searching...
No Matches
lwoSurfaceBlockHeader.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 lwoSurfaceBlockHeader.cxx
10 * @author drose
11 * @date 2001-04-24
12 */
13
14#include "lwoSurfaceBlockHeader.h"
15#include "lwoInputFile.h"
16#include "lwoSurfaceBlockChannel.h"
17#include "lwoSurfaceBlockEnabled.h"
18#include "lwoSurfaceBlockOpacity.h"
19#include "lwoSurfaceBlockAxis.h"
20
21#include "dcast.h"
22#include "indent.h"
23
24 TypeHandle LwoSurfaceBlockHeader::_type_handle;
25
26/**
27 * Reads the data of the chunk in from the given input file, if possible. The
28 * ID and length of the chunk have already been read. stop_at is the byte
29 * position of the file to stop at (based on the current position at
30 * in->get_bytes_read()). Returns true on success, false otherwise.
31 */
32 bool LwoSurfaceBlockHeader::
33 read_iff(IffInputFile *in, size_t stop_at) {
34 LwoInputFile *lin = DCAST(LwoInputFile, in);
35
36 _ordinal = lin->get_string();
37 read_subchunks_iff(lin, stop_at);
38
39 return true;
40}
41
42/**
43 *
44 */
45 void LwoSurfaceBlockHeader::
46write(std::ostream &out, int indent_level) const {
47 indent(out, indent_level)
48 << get_id() << " {\n";
49 indent(out, indent_level + 2)
50 << "ordinal = 0x" << std::hex << std::setfill('0');
51
52 std::string::const_iterator si;
53 for (si = _ordinal.begin(); si != _ordinal.end(); ++si) {
54 out << std::setw(2) << (int)(unsigned char)(*si);
55 }
56
57 out << std::dec << std::setfill(' ') << "\n";
58
59 write_chunks(out, indent_level + 2);
60 indent(out, indent_level)
61 << "}\n";
62}
63
64/**
65 * Allocates and returns a new chunk of the appropriate type based on the
66 * given ID, according to the context given by this chunk itself.
67 */
68IffChunk *LwoSurfaceBlockHeader::
69 make_new_chunk(IffInputFile *in, IffId id) {
70 if (id == IffId("CHAN")) {
71 return new LwoSurfaceBlockChannel;
72
73 } else if (id == IffId("ENAB")) {
74 return new LwoSurfaceBlockEnabled;
75
76 } else if (id == IffId("OPAC")) {
77 return new LwoSurfaceBlockOpacity;
78
79 } else if (id == IffId("AXIS")) {
80 return new LwoSurfaceBlockAxis;
81
82 } else {
83 return IffChunk::make_new_chunk(in, id);
84 }
85}
IffChunk::make_new_chunk
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
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_string
std::string get_string()
Extracts a null-terminated string.
Definition iffInputFile.cxx:178
LwoInputFile
A specialization of IffInputFile to handle reading a Lightwave Object file.
Definition lwoInputFile.h:26
LwoSurfaceBlockAxis
Indicates the axis for this particular shader's projection.
Definition lwoSurfaceBlockAxis.h:26
LwoSurfaceBlockChannel
Indicates which channel the texture in this LwoSurfaceBlock is applied to.
Definition lwoSurfaceBlockChannel.h:25
LwoSurfaceBlockEnabled
Indicates whether this particular layer or shader should be rendered or not.
Definition lwoSurfaceBlockEnabled.h:25
LwoSurfaceBlockHeader::make_new_chunk
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 lwoSurfaceBlockHeader.cxx:69
LwoSurfaceBlockHeader::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 lwoSurfaceBlockHeader.cxx:33
LwoSurfaceBlockOpacity
Indicates how transparent or opaque this particular layer is in relation to the layers beneath it.
Definition lwoSurfaceBlockOpacity.h:25
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.
lwoInputFile.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoSurfaceBlockAxis.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoSurfaceBlockChannel.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoSurfaceBlockEnabled.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoSurfaceBlockHeader.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
lwoSurfaceBlockOpacity.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.