*** empty log message ***
This commit is contained in:
parent
4354172623
commit
03c8bcc4f5
|
|
@ -11,7 +11,9 @@
|
|||
config_lwo.cxx config_lwo.h iffChunk.I iffChunk.cxx iffChunk.h \
|
||||
iffGenericChunk.I iffGenericChunk.cxx iffGenericChunk.h iffId.I \
|
||||
iffId.cxx iffId.h iffInputFile.I iffInputFile.cxx iffInputFile.h \
|
||||
lwoBoundingBox.I lwoBoundingBox.cxx lwoBoundingBox.h \
|
||||
lwoChunk.I lwoChunk.cxx lwoChunk.h \
|
||||
lwoClip.I lwoClip.cxx lwoClip.h \
|
||||
lwoDiscontinuousVertexMap.I lwoDiscontinuousVertexMap.cxx lwoDiscontinuousVertexMap.h \
|
||||
lwoGroupChunk.I lwoGroupChunk.cxx lwoGroupChunk.h \
|
||||
lwoHeader.I lwoHeader.cxx \
|
||||
|
|
@ -21,12 +23,18 @@
|
|||
lwoPolygons.h lwoPolygons.I lwoPolygons.cxx \
|
||||
lwoPolygonTags.h lwoPolygonTags.I lwoPolygonTags.cxx \
|
||||
lwoTags.h lwoTags.I lwoTags.cxx \
|
||||
lwoStillImage.h lwoStillImage.I lwoStillImage.cxx \
|
||||
lwoSurface.h lwoSurface.I lwoSurface.cxx \
|
||||
lwoSurfaceColor.h lwoSurfaceColor.I lwoSurfaceColor.cxx \
|
||||
lwoSurfaceParameter.h lwoSurfaceParameter.I lwoSurfaceParameter.cxx \
|
||||
lwoVertexMap.h lwoVertexMap.I lwoVertexMap.cxx
|
||||
|
||||
#define INSTALL_HEADERS \
|
||||
iffChunk.I iffChunk.h iffGenericChunk.I iffGenericChunk.h iffId.I \
|
||||
iffId.h iffInputFile.I iffInputFile.h \
|
||||
lwoBoundingBox.I lwoBoundingBox.h \
|
||||
lwoChunk.I lwoChunk.h \
|
||||
lwoClip.I lwoClip.h \
|
||||
lwoDiscontinuousVertexMap.I lwoDiscontinuousVertexMap.h \
|
||||
lwoGroupChunk.I lwoGroupChunk.h \
|
||||
lwoHeader.I lwoHeader.h \
|
||||
|
|
@ -36,6 +44,10 @@
|
|||
lwoPolygons.I lwoPolygons.h \
|
||||
lwoPolygonTags.I lwoPolygonTags.h \
|
||||
lwoTags.I lwoTags.h \
|
||||
lwoStillImage.I lwoStillImage.h \
|
||||
lwoSurface.I lwoSurface.h \
|
||||
lwoSurfaceColor.I lwoSurfaceColor.h \
|
||||
lwoSurfaceParameter.I lwoSurfaceParameter.h \
|
||||
lwoVertexMap.I lwoVertexMap.h
|
||||
|
||||
#end ss_lib_target
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
#include "iffChunk.h"
|
||||
#include "iffGenericChunk.h"
|
||||
#include "iffInputFile.h"
|
||||
#include "lwoBoundingBox.h"
|
||||
#include "lwoChunk.h"
|
||||
#include "lwoClip.h"
|
||||
#include "lwoDiscontinuousVertexMap.h"
|
||||
#include "lwoGroupChunk.h"
|
||||
#include "lwoHeader.h"
|
||||
|
|
@ -16,6 +18,10 @@
|
|||
#include "lwoPoints.h"
|
||||
#include "lwoPolygons.h"
|
||||
#include "lwoPolygonTags.h"
|
||||
#include "lwoStillImage.h"
|
||||
#include "lwoSurface.h"
|
||||
#include "lwoSurfaceColor.h"
|
||||
#include "lwoSurfaceParameter.h"
|
||||
#include "lwoTags.h"
|
||||
#include "lwoVertexMap.h"
|
||||
|
||||
|
|
@ -27,7 +33,9 @@ ConfigureFn(config_lwo) {
|
|||
IffChunk::init_type();
|
||||
IffGenericChunk::init_type();
|
||||
IffInputFile::init_type();
|
||||
LwoBoundingBox::init_type();
|
||||
LwoChunk::init_type();
|
||||
LwoClip::init_type();
|
||||
LwoDiscontinuousVertexMap::init_type();
|
||||
LwoGroupChunk::init_type();
|
||||
LwoHeader::init_type();
|
||||
|
|
@ -37,6 +45,10 @@ ConfigureFn(config_lwo) {
|
|||
LwoPolygons::init_type();
|
||||
LwoPolygonTags::init_type();
|
||||
LwoTags::init_type();
|
||||
LwoStillImage::init_type();
|
||||
LwoSurface::init_type();
|
||||
LwoSurfaceColor::init_type();
|
||||
LwoSurfaceParameter::init_type();
|
||||
LwoVertexMap::init_type();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ get_chunk() {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: IffInputFile::get_sub_chunk
|
||||
// Function: IffInputFile::get_subchunk
|
||||
// Access: Public
|
||||
// Description: Similar to get_chunk(), except the chunk size is only
|
||||
// a 16-bit number instead of 32-bit, and it takes a
|
||||
|
|
@ -266,7 +266,7 @@ get_chunk() {
|
|||
// id's encountered.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PT(IffChunk) IffInputFile::
|
||||
get_sub_chunk(IffChunk *context) {
|
||||
get_subchunk(IffChunk *context) {
|
||||
IffId id = get_id();
|
||||
PN_uint16 length = get_be_uint16();
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public:
|
|||
IffId get_id();
|
||||
|
||||
PT(IffChunk) get_chunk();
|
||||
PT(IffChunk) get_sub_chunk(IffChunk *context);
|
||||
PT(IffChunk) get_subchunk(IffChunk *context);
|
||||
|
||||
bool read_byte(char &byte);
|
||||
bool read_bytes(Datagram &datagram, size_t length);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: lwoGroupChunk.I
|
||||
// Filename: lwoBoundingBox.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
// Filename: lwoBoundingBox.cxx
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lwoBoundingBox.h"
|
||||
#include "lwoInputFile.h"
|
||||
|
||||
#include <indent.h>
|
||||
|
||||
TypeHandle LwoBoundingBox::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoBoundingBox::read_iff
|
||||
// Access: Public, Virtual
|
||||
// Description: Reads the data of the chunk in from the given input
|
||||
// file, if possible. The ID and length of the chunk
|
||||
// have already been read. stop_at is the byte position
|
||||
// of the file to stop at (based on the current position
|
||||
// at in->get_bytes_read()). Returns true on success,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoBoundingBox::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
LwoInputFile *lin = DCAST(LwoInputFile, in);
|
||||
|
||||
_min = lin->get_vec3();
|
||||
_max = lin->get_vec3();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoBoundingBox::write
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void LwoBoundingBox::
|
||||
write(ostream &out, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< get_id() << " { min = " << _min << ", max = " << _max << " }\n";
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Filename: lwoBoundingBox.h
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LWOBOUNDINGBOX_H
|
||||
#define LWOBOUNDINGBOX_H
|
||||
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include "lwoChunk.h"
|
||||
|
||||
#include <luse.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : LwoBoundingBox
|
||||
// Description : Stores the bounding box for the vertex data in a
|
||||
// layer. Optional.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class LwoBoundingBox : public LwoChunk {
|
||||
public:
|
||||
LVecBase3f _min;
|
||||
LVecBase3f _max;
|
||||
|
||||
public:
|
||||
virtual bool read_iff(IffInputFile *in, size_t stop_at);
|
||||
virtual void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
LwoChunk::init_type();
|
||||
register_type(_type_handle, "LwoBoundingBox",
|
||||
LwoChunk::get_class_type());
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoBoundingBox.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -39,8 +39,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoChunk.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: lwoTags.I
|
||||
// Filename: lwoClip.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
// Filename: lwoClip.cxx
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lwoClip.h"
|
||||
#include "iffInputFile.h"
|
||||
#include "lwoStillImage.h"
|
||||
|
||||
#include <indent.h>
|
||||
|
||||
TypeHandle LwoClip::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoClip::read_iff
|
||||
// Access: Public, Virtual
|
||||
// Description: Reads the data of the chunk in from the given input
|
||||
// file, if possible. The ID and length of the chunk
|
||||
// have already been read. stop_at is the byte position
|
||||
// of the file to stop at (based on the current position
|
||||
// at in->get_bytes_read()). Returns true on success,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoClip::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
_index = in->get_be_int32();
|
||||
return read_subchunks_iff(in, stop_at);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoClip::write
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void LwoClip::
|
||||
write(ostream &out, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< get_id() << " {\n";
|
||||
indent(out, indent_level + 2)
|
||||
<< "index = " << _index << "\n";
|
||||
write_chunks(out, indent_level + 2);
|
||||
indent(out, indent_level)
|
||||
<< "}\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoClip::make_new_chunk
|
||||
// Access: Protected, Virtual
|
||||
// Description: Allocates and returns a new chunk of the appropriate
|
||||
// type based on the given ID, according to the context
|
||||
// given by this chunk itself.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
IffChunk *LwoClip::
|
||||
make_new_chunk(IffInputFile *in, IffId id) {
|
||||
if (id == IffId("STIL")) {
|
||||
return new LwoStillImage;
|
||||
|
||||
} else {
|
||||
return IffChunk::make_new_chunk(in, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Filename: lwoClip.h
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LWOCLIP_H
|
||||
#define LWOCLIP_H
|
||||
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include "lwoGroupChunk.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : LwoClip
|
||||
// Description : A single image file, or a numbered sequence of images
|
||||
// (e.g. a texture-flip animation).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class LwoClip : public LwoGroupChunk {
|
||||
public:
|
||||
int _index;
|
||||
|
||||
public:
|
||||
virtual bool read_iff(IffInputFile *in, size_t stop_at);
|
||||
virtual void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id);
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoClip.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
// Filename: lwoDiscontinuousVertexMap.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -54,8 +54,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoDiscontinuousVertexMap.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,28 +11,28 @@
|
|||
TypeHandle LwoGroupChunk::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoGroupChunk::get_num_children
|
||||
// Function: LwoGroupChunk::get_num_chunks
|
||||
// Access: Public
|
||||
// Description: Returns the number of child chunks of this group.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int LwoGroupChunk::
|
||||
get_num_children() const {
|
||||
return _children.size();
|
||||
get_num_chunks() const {
|
||||
return _chunks.size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoGroupChunk::get_child
|
||||
// Function: LwoGroupChunk::get_chunk
|
||||
// Access: Public
|
||||
// Description: Returns the nth child chunk of this group.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
IffChunk *LwoGroupChunk::
|
||||
get_child(int n) const {
|
||||
nassertr(n >= 0 && n < (int)_children.size(), (IffChunk *)NULL);
|
||||
return _children[n];
|
||||
get_chunk(int n) const {
|
||||
nassertr(n >= 0 && n < (int)_chunks.size(), (IffChunk *)NULL);
|
||||
return _chunks[n];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoGroupChunk::read_children_iff
|
||||
// Function: LwoGroupChunk::read_chunks_iff
|
||||
// Access: Public
|
||||
// Description: Reads a sequence of child chunks, until byte stop_at
|
||||
// has been been reached, and stores them as the
|
||||
|
|
@ -41,28 +41,47 @@ get_child(int n) const {
|
|||
// otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoGroupChunk::
|
||||
read_children_iff(IffInputFile *in, size_t stop_at) {
|
||||
read_chunks_iff(IffInputFile *in, size_t stop_at) {
|
||||
while (in->get_bytes_read() < stop_at && !in->is_eof()) {
|
||||
PT(IffChunk) chunk = in->get_chunk();
|
||||
if (chunk == (IffChunk *)NULL) {
|
||||
return false;
|
||||
}
|
||||
_children.push_back(chunk);
|
||||
_chunks.push_back(chunk);
|
||||
}
|
||||
|
||||
return (in->get_bytes_read() == stop_at);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoGroupChunk::write_children
|
||||
// Function: LwoGroupChunk::read_subchunks_iff
|
||||
// Access: Public
|
||||
// Description: Formats the list of children for output to the user
|
||||
// Description: Similar to read_chunks_iff(), but reads them as
|
||||
// subchunks.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoGroupChunk::
|
||||
read_subchunks_iff(IffInputFile *in, size_t stop_at) {
|
||||
while (in->get_bytes_read() < stop_at && !in->is_eof()) {
|
||||
PT(IffChunk) chunk = in->get_subchunk(this);
|
||||
if (chunk == (IffChunk *)NULL) {
|
||||
return false;
|
||||
}
|
||||
_chunks.push_back(chunk);
|
||||
}
|
||||
|
||||
return (in->get_bytes_read() == stop_at);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoGroupChunk::write_chunks
|
||||
// Access: Public
|
||||
// Description: Formats the list of chunks for output to the user
|
||||
// (primarily for debugging), one per line.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void LwoGroupChunk::
|
||||
write_children(ostream &out, int indent_level) const {
|
||||
Children::const_iterator ci;
|
||||
for (ci = _children.begin(); ci != _children.end(); ++ci) {
|
||||
write_chunks(ostream &out, int indent_level) const {
|
||||
Chunks::const_iterator ci;
|
||||
for (ci = _chunks.begin(); ci != _chunks.end(); ++ci) {
|
||||
(*ci)->write(out, indent_level);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,16 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
class LwoGroupChunk : public LwoChunk {
|
||||
public:
|
||||
int get_num_children() const;
|
||||
IffChunk *get_child(int n) const;
|
||||
int get_num_chunks() const;
|
||||
IffChunk *get_chunk(int n) const;
|
||||
|
||||
protected:
|
||||
bool read_children_iff(IffInputFile *in, size_t stop_at);
|
||||
void write_children(ostream &out, int indent_level) const;
|
||||
bool read_chunks_iff(IffInputFile *in, size_t stop_at);
|
||||
bool read_subchunks_iff(IffInputFile *in, size_t stop_at);
|
||||
void write_chunks(ostream &out, int indent_level) const;
|
||||
|
||||
typedef vector< PT(IffChunk) > Children;
|
||||
Children _children;
|
||||
typedef vector< PT(IffChunk) > Chunks;
|
||||
Chunks _chunks;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
|
|
|
|||
|
|
@ -2,15 +2,3 @@
|
|||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoHeader::get_lwid
|
||||
// Access: Public
|
||||
// Description: Returns the Lightwave ID of the file. This is the
|
||||
// first ID read within the header, and indicates the
|
||||
// version of the Lightwave file in some mysterious way.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
IffId LwoHeader::
|
||||
get_lwid() const {
|
||||
return _lwid;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ TypeHandle LwoHeader::_type_handle;
|
|||
bool LwoHeader::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
_lwid = in->get_id();
|
||||
return read_children_iff(in, stop_at);
|
||||
return read_chunks_iff(in, stop_at);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -36,8 +36,8 @@ write(ostream &out, int indent_level) const {
|
|||
indent(out, indent_level)
|
||||
<< get_id() << " {\n";
|
||||
indent(out, indent_level + 2)
|
||||
<< _lwid << "\n";
|
||||
write_children(out, indent_level + 2);
|
||||
<< "id = " << _lwid << "\n";
|
||||
write_chunks(out, indent_level + 2);
|
||||
indent(out, indent_level)
|
||||
<< "}\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,11 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
class LwoHeader : public LwoGroupChunk {
|
||||
public:
|
||||
INLINE IffId get_lwid() const;
|
||||
IffId _lwid;
|
||||
|
||||
public:
|
||||
virtual bool read_iff(IffInputFile *in, size_t stop_at);
|
||||
virtual void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
private:
|
||||
IffId _lwid;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lwoInputFile.h"
|
||||
#include "lwoBoundingBox.h"
|
||||
#include "lwoClip.h"
|
||||
#include "lwoDiscontinuousVertexMap.h"
|
||||
#include "lwoHeader.h"
|
||||
#include "lwoLayer.h"
|
||||
#include "lwoPoints.h"
|
||||
#include "lwoPolygons.h"
|
||||
#include "lwoPolygonTags.h"
|
||||
#include "lwoVertexMap.h"
|
||||
#include "lwoTags.h"
|
||||
#include "lwoSurface.h"
|
||||
#include "lwoVertexMap.h"
|
||||
|
||||
TypeHandle LwoInputFile::_type_handle;
|
||||
|
||||
|
|
@ -123,6 +126,15 @@ make_new_chunk(IffId id) {
|
|||
} else if (id == IffId("PTAG")) {
|
||||
return new LwoPolygonTags;
|
||||
|
||||
} else if (id == IffId("CLIP")) {
|
||||
return new LwoClip;
|
||||
|
||||
} else if (id == IffId("SURF")) {
|
||||
return new LwoSurface;
|
||||
|
||||
} else if (id == IffId("BBOX")) {
|
||||
return new LwoBoundingBox;
|
||||
|
||||
} else {
|
||||
return IffInputFile::make_new_chunk(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoInputFile.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ TypeHandle LwoLayer::_type_handle;
|
|||
bool LwoLayer::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
LwoInputFile *lin = DCAST(LwoInputFile, in);
|
||||
|
||||
_number = lin->get_be_uint16();
|
||||
_flags = lin->get_be_uint16();
|
||||
_pivot = lin->get_vec3();
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoLayer.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
// Filename: lwoPoints.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -48,8 +48,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoPoints.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
// Filename: lwoPolygonTags.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -50,8 +50,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoPolygonTags.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
// Filename: lwoPolygons.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -65,8 +65,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoPolygons.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: lwoLayer.I
|
||||
// Filename: lwoStillImage.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// Filename: lwoStillImage.cxx
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lwoStillImage.h"
|
||||
#include "lwoInputFile.h"
|
||||
|
||||
#include <indent.h>
|
||||
|
||||
TypeHandle LwoStillImage::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoStillImage::read_iff
|
||||
// Access: Public, Virtual
|
||||
// Description: Reads the data of the chunk in from the given input
|
||||
// file, if possible. The ID and length of the chunk
|
||||
// have already been read. stop_at is the byte position
|
||||
// of the file to stop at (based on the current position
|
||||
// at in->get_bytes_read()). Returns true on success,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoStillImage::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
LwoInputFile *lin = DCAST(LwoInputFile, in);
|
||||
|
||||
_filename = lin->get_filename();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoStillImage::write
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void LwoStillImage::
|
||||
write(ostream &out, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< get_id() << " { filename = \"" << _filename << "\" }\n";
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// Filename: lwoStillImage.h
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LWOSTILLIMAGE_H
|
||||
#define LWOSTILLIMAGE_H
|
||||
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include "lwoChunk.h"
|
||||
|
||||
#include <filename.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : LwoStillImage
|
||||
// Description : A single still image associated with a LwoClip chunk.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class LwoStillImage : public LwoChunk {
|
||||
public:
|
||||
Filename _filename;
|
||||
|
||||
public:
|
||||
virtual bool read_iff(IffInputFile *in, size_t stop_at);
|
||||
virtual void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
LwoChunk::init_type();
|
||||
register_type(_type_handle, "LwoStillImage",
|
||||
LwoChunk::get_class_type());
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoStillImage.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: lwoChunk.I
|
||||
// Filename: lwoSurface.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
// Filename: lwoSurface.cxx
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lwoSurface.h"
|
||||
#include "iffInputFile.h"
|
||||
#include "lwoSurfaceColor.h"
|
||||
#include "lwoSurfaceParameter.h"
|
||||
|
||||
#include <indent.h>
|
||||
|
||||
TypeHandle LwoSurface::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoSurface::read_iff
|
||||
// Access: Public, Virtual
|
||||
// Description: Reads the data of the chunk in from the given input
|
||||
// file, if possible. The ID and length of the chunk
|
||||
// have already been read. stop_at is the byte position
|
||||
// of the file to stop at (based on the current position
|
||||
// at in->get_bytes_read()). Returns true on success,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoSurface::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
_name = in->get_string();
|
||||
_source = in->get_string();
|
||||
return read_subchunks_iff(in, stop_at);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoSurface::write
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void LwoSurface::
|
||||
write(ostream &out, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< get_id() << " {\n";
|
||||
indent(out, indent_level + 2)
|
||||
<< "name = \"" << _name << "\", source = \"" << _source << "\"\n";
|
||||
write_chunks(out, indent_level + 2);
|
||||
indent(out, indent_level)
|
||||
<< "}\n";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoSurface::make_new_chunk
|
||||
// Access: Protected, Virtual
|
||||
// Description: Allocates and returns a new chunk of the appropriate
|
||||
// type based on the given ID, according to the context
|
||||
// given by this chunk itself.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
IffChunk *LwoSurface::
|
||||
make_new_chunk(IffInputFile *in, IffId id) {
|
||||
if (id == IffId("COLR")) {
|
||||
return new LwoSurfaceColor;
|
||||
|
||||
} else if (id == IffId("DIFF") ||
|
||||
id == IffId("LUMI") ||
|
||||
id == IffId("SPEC") ||
|
||||
id == IffId("REFL") ||
|
||||
id == IffId("TRAN") ||
|
||||
id == IffId("TRNL") ||
|
||||
id == IffId("GLOS") ||
|
||||
id == IffId("SHRP") ||
|
||||
id == IffId("BUMP") ||
|
||||
id == IffId("RSAN") ||
|
||||
id == IffId("RIND")) {
|
||||
return new LwoSurfaceParameter;
|
||||
|
||||
} else {
|
||||
return IffChunk::make_new_chunk(in, id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
// Filename: lwoSurface.h
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LWOSURFACE_H
|
||||
#define LWOSURFACE_H
|
||||
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include "lwoGroupChunk.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : LwoSurface
|
||||
// Description : Describes the shading attributes of a surface. This
|
||||
// is similar to the concept usually called a "material"
|
||||
// in other file formats.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class LwoSurface : public LwoGroupChunk {
|
||||
public:
|
||||
string _name;
|
||||
string _source;
|
||||
|
||||
public:
|
||||
virtual bool read_iff(IffInputFile *in, size_t stop_at);
|
||||
virtual void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
virtual IffChunk *make_new_chunk(IffInputFile *in, IffId id);
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoSurface.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
// Filename: lwoInputFile.I
|
||||
// Filename: lwoSurfaceColor.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
// Filename: lwoSurfaceColor.cxx
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lwoSurfaceColor.h"
|
||||
#include "lwoInputFile.h"
|
||||
|
||||
#include <indent.h>
|
||||
|
||||
TypeHandle LwoSurfaceColor::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoSurfaceColor::read_iff
|
||||
// Access: Public, Virtual
|
||||
// Description: Reads the data of the chunk in from the given input
|
||||
// file, if possible. The ID and length of the chunk
|
||||
// have already been read. stop_at is the byte position
|
||||
// of the file to stop at (based on the current position
|
||||
// at in->get_bytes_read()). Returns true on success,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoSurfaceColor::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
LwoInputFile *lin = DCAST(LwoInputFile, in);
|
||||
|
||||
_color = lin->get_vec3();
|
||||
_envelope = lin->get_vx();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoSurfaceColor::write
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void LwoSurfaceColor::
|
||||
write(ostream &out, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< get_id() << " { color = " << _color
|
||||
<< ", envelope = " << _envelope << " }\n";
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Filename: lwoSurfaceColor.h
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LWOSURFACECOLOR_H
|
||||
#define LWOSURFACECOLOR_H
|
||||
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include "lwoChunk.h"
|
||||
|
||||
#include <luse.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : LwoSurfaceColor
|
||||
// Description : Records the base color of a surface, as an entry
|
||||
// within a LwoSurface chunk.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class LwoSurfaceColor : public LwoChunk {
|
||||
public:
|
||||
RGBColorf _color;
|
||||
int _envelope;
|
||||
|
||||
public:
|
||||
virtual bool read_iff(IffInputFile *in, size_t stop_at);
|
||||
virtual void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
LwoChunk::init_type();
|
||||
register_type(_type_handle, "LwoSurfaceColor",
|
||||
LwoChunk::get_class_type());
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoSurfaceColor.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
// Filename: lwoSurfaceParameter.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
// Filename: lwoSurfaceParameter.cxx
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "lwoSurfaceParameter.h"
|
||||
#include "lwoInputFile.h"
|
||||
|
||||
#include <indent.h>
|
||||
|
||||
TypeHandle LwoSurfaceParameter::_type_handle;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoSurfaceParameter::read_iff
|
||||
// Access: Public, Virtual
|
||||
// Description: Reads the data of the chunk in from the given input
|
||||
// file, if possible. The ID and length of the chunk
|
||||
// have already been read. stop_at is the byte position
|
||||
// of the file to stop at (based on the current position
|
||||
// at in->get_bytes_read()). Returns true on success,
|
||||
// false otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool LwoSurfaceParameter::
|
||||
read_iff(IffInputFile *in, size_t stop_at) {
|
||||
LwoInputFile *lin = DCAST(LwoInputFile, in);
|
||||
|
||||
_value = lin->get_be_float32();
|
||||
_envelope = lin->get_vx();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: LwoSurfaceParameter::write
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void LwoSurfaceParameter::
|
||||
write(ostream &out, int indent_level) const {
|
||||
indent(out, indent_level)
|
||||
<< get_id() << " { value = " << _value
|
||||
<< ", envelope = " << _envelope << " }\n";
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
// Filename: lwoSurfaceParameter.h
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef LWOSURFACEPARAMETER_H
|
||||
#define LWOSURFACEPARAMETER_H
|
||||
|
||||
#include <pandatoolbase.h>
|
||||
|
||||
#include "lwoChunk.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : LwoSurfaceParameter
|
||||
// Description : Records some parameter value of a surface material,
|
||||
// as an entry within a LwoSurface chunk. The meaning
|
||||
// of the value is determined by the id of this chunk.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
class LwoSurfaceParameter : public LwoChunk {
|
||||
public:
|
||||
float _value;
|
||||
int _envelope;
|
||||
|
||||
public:
|
||||
virtual bool read_iff(IffInputFile *in, size_t stop_at);
|
||||
virtual void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
public:
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
LwoChunk::init_type();
|
||||
register_type(_type_handle, "LwoSurfaceParameter",
|
||||
LwoChunk::get_class_type());
|
||||
}
|
||||
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoSurfaceParameter.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -65,10 +65,10 @@ write(ostream &out, int indent_level) const {
|
|||
|
||||
if (!_tags.empty()) {
|
||||
Tags::const_iterator ti = _tags.begin();
|
||||
out << *ti;
|
||||
out << '"' << *ti << '"';
|
||||
++ti;
|
||||
while (ti != _tags.end()) {
|
||||
out << ", " << *ti;
|
||||
out << ", \"" << *ti << '"';
|
||||
++ti;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoTags.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
// Filename: lwoVertexMap.I
|
||||
// Created by: drose (24Apr01)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -53,8 +53,6 @@ private:
|
|||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "lwoVertexMap.I"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue