Panda3D
Loading...
Searching...
No Matches
lwoSurfaceBlock.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 lwoSurfaceBlock.cxx
10 * @author drose
11 * @date 2001-04-24
12 */
13
14#include "lwoSurfaceBlock.h"
15#include "iffInputFile.h"
16#include "lwoSurfaceBlockAxis.h"
21#include "lwoSurfaceBlockTMap.h"
22#include "lwoSurfaceBlockWrap.h"
24
25#include "dcast.h"
26#include "indent.h"
27
28TypeHandle LwoSurfaceBlock::_type_handle;
29
30/**
31 * Reads the data of the chunk in from the given input file, if possible. The
32 * ID and length of the chunk have already been read. stop_at is the byte
33 * position of the file to stop at (based on the current position at
34 * in->get_bytes_read()). Returns true on success, false otherwise.
35 */
37read_iff(IffInputFile *in, size_t stop_at) {
38 PT(IffChunk) chunk = in->get_subchunk(this);
39 if (chunk == nullptr) {
40 return false;
41 }
42 if (!chunk->is_of_type(LwoSurfaceBlockHeader::get_class_type())) {
43 nout << "Invalid chunk for header of surface block: " << *chunk << "\n";
44 return false;
45 }
46
47 _header = DCAST(LwoSurfaceBlockHeader, chunk);
48
49 read_subchunks_iff(in, stop_at);
50 return true;
51}
52
53/**
54 *
55 */
56void LwoSurfaceBlock::
57write(std::ostream &out, int indent_level) const {
58 indent(out, indent_level)
59 << get_id() << " {\n";
60 _header->write(out, indent_level + 2);
61 out << "\n";
62 write_chunks(out, indent_level + 2);
63 indent(out, indent_level)
64 << "}\n";
65}
66
67/**
68 * Allocates and returns a new chunk of the appropriate type based on the
69 * given ID, according to the context given by this chunk itself.
70 */
73 if (id == IffId("IMAP") ||
74 id == IffId("PROC") ||
75 id == IffId("GRAD") ||
76 id == IffId("SHDR")) {
77 return new LwoSurfaceBlockHeader;
78
79 } else if (id == IffId("TMAP")) {
80 return new LwoSurfaceBlockTMap;
81
82 } else if (id == IffId("PROJ")) {
84
85 } else if (id == IffId("AXIS")) {
86 return new LwoSurfaceBlockAxis;
87
88 } else if (id == IffId("IMAG")) {
89 return new LwoSurfaceBlockImage;
90
91 } else if (id == IffId("WRAP")) {
92 return new LwoSurfaceBlockWrap;
93
94 } else if (id == IffId("WRPH") ||
95 id == IffId("WRPW")) {
96 return new LwoSurfaceBlockRepeat;
97
98 } else if (id == IffId("VMAP")) {
99 return new LwoSurfaceBlockVMapName;
100
101 } else {
102 return IffChunk::make_new_chunk(in, id);
103 }
104}
The basic kind of record in an EA "IFF" file, which the LightWave object file is based on.
Definition iffChunk.h:30
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
IffId get_id() const
Returns the ID associated with this chunk.
Definition iffChunk.I:25
A four-byte chunk ID appearing in an "IFF" file.
Definition iffId.h:26
A wrapper around an istream used for reading an IFF file.
Indicates the axis for this particular shader's projection.
The header chunk within a LwoSurfaceBlock chunk.
Specifies the particular image that is being applied as a texture.
Indicates the projection mode for this particular shader.
For cylindrical and spherical projections, this parameter controls how many times the image repeats o...
The tMap chunk within a LwoSurfaceBlock chunk.
Specifies the name of a set of UV's defined on the polygons that use this model.
Specifies how the texture image appears for areas outside the image.
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...
virtual bool read_iff(IffInputFile *in, size_t stop_at)
Reads the data of the chunk in from the given input file, if possible.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.