From bc82855d2185d6a1c50ea7e90459c569a8a7d0fa Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 24 Apr 2001 23:08:44 +0000 Subject: [PATCH] *** empty log message *** --- pandatool/src/lwo/Sources.pp | 16 +++++ pandatool/src/lwo/config_lwo.cxx | 16 +++++ pandatool/src/lwo/lwoSurface.h | 2 +- pandatool/src/lwo/lwoSurfaceBlock.cxx | 21 +++++++ pandatool/src/lwo/lwoSurfaceBlockAxis.cxx | 41 +++++++++++++ pandatool/src/lwo/lwoSurfaceBlockAxis.h | 53 +++++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockChannel.cxx | 41 +++++++++++++ pandatool/src/lwo/lwoSurfaceBlockChannel.h | 47 +++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx | 41 +++++++++++++ pandatool/src/lwo/lwoSurfaceBlockEnabled.h | 47 +++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockHeader.cxx | 31 ++++------ pandatool/src/lwo/lwoSurfaceBlockImage.cxx | 41 +++++++++++++ pandatool/src/lwo/lwoSurfaceBlockImage.h | 47 +++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx | 45 ++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockOpacity.h | 59 +++++++++++++++++++ .../src/lwo/lwoSurfaceBlockProjection.cxx | 41 +++++++++++++ pandatool/src/lwo/lwoSurfaceBlockProjection.h | 56 ++++++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx | 43 ++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockRepeat.h | 50 ++++++++++++++++ pandatool/src/lwo/lwoSurfaceBlockWrap.cxx | 41 +++++++++++++ pandatool/src/lwo/lwoSurfaceBlockWrap.h | 52 ++++++++++++++++ 21 files changed, 809 insertions(+), 22 deletions(-) create mode 100644 pandatool/src/lwo/lwoSurfaceBlockAxis.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockAxis.h create mode 100644 pandatool/src/lwo/lwoSurfaceBlockChannel.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockChannel.h create mode 100644 pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockEnabled.h create mode 100644 pandatool/src/lwo/lwoSurfaceBlockImage.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockImage.h create mode 100644 pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockOpacity.h create mode 100644 pandatool/src/lwo/lwoSurfaceBlockProjection.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockProjection.h create mode 100644 pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockRepeat.h create mode 100644 pandatool/src/lwo/lwoSurfaceBlockWrap.cxx create mode 100644 pandatool/src/lwo/lwoSurfaceBlockWrap.h diff --git a/pandatool/src/lwo/Sources.pp b/pandatool/src/lwo/Sources.pp index 746bfbf747..43f4ec2109 100644 --- a/pandatool/src/lwo/Sources.pp +++ b/pandatool/src/lwo/Sources.pp @@ -26,8 +26,16 @@ lwoStillImage.h lwoStillImage.cxx \ lwoSurface.h lwoSurface.cxx \ lwoSurfaceBlock.h lwoSurfaceBlock.cxx \ + lwoSurfaceBlockAxis.h lwoSurfaceBlockAxis.cxx \ + lwoSurfaceBlockChannel.h lwoSurfaceBlockChannel.cxx \ + lwoSurfaceBlockEnabled.h lwoSurfaceBlockEnabled.cxx \ + lwoSurfaceBlockImage.h lwoSurfaceBlockImage.cxx \ + lwoSurfaceBlockOpacity.h lwoSurfaceBlockOpacity.cxx \ + lwoSurfaceBlockProjection.h lwoSurfaceBlockProjection.cxx \ lwoSurfaceBlockHeader.h lwoSurfaceBlockHeader.cxx \ + lwoSurfaceBlockRepeat.h lwoSurfaceBlockRepeat.cxx \ lwoSurfaceBlockTMap.h lwoSurfaceBlockTMap.cxx \ + lwoSurfaceBlockWrap.h lwoSurfaceBlockWrap.cxx \ lwoSurfaceColor.h lwoSurfaceColor.cxx \ lwoSurfaceParameter.h lwoSurfaceParameter.cxx \ lwoSurfaceSidedness.h lwoSurfaceSidedness.cxx \ @@ -52,8 +60,16 @@ lwoStillImage.h \ lwoSurface.h \ lwoSurfaceBlock.h \ + lwoSurfaceBlockAxis.h \ + lwoSurfaceBlockChannel.h \ + lwoSurfaceBlockEnabled.h \ + lwoSurfaceBlockImage.h \ + lwoSurfaceBlockOpacity.h \ + lwoSurfaceBlockProjection.h \ lwoSurfaceBlockHeader.h \ + lwoSurfaceBlockRepeat.h \ lwoSurfaceBlockTMap.h \ + lwoSurfaceBlockWrap.h \ lwoSurfaceColor.h \ lwoSurfaceParameter.h \ lwoSurfaceSidedness.h \ diff --git a/pandatool/src/lwo/config_lwo.cxx b/pandatool/src/lwo/config_lwo.cxx index 95f4092bab..1afc3cc0cb 100644 --- a/pandatool/src/lwo/config_lwo.cxx +++ b/pandatool/src/lwo/config_lwo.cxx @@ -21,8 +21,16 @@ #include "lwoStillImage.h" #include "lwoSurface.h" #include "lwoSurfaceBlock.h" +#include "lwoSurfaceBlockAxis.h" +#include "lwoSurfaceBlockChannel.h" +#include "lwoSurfaceBlockEnabled.h" +#include "lwoSurfaceBlockImage.h" +#include "lwoSurfaceBlockOpacity.h" +#include "lwoSurfaceBlockProjection.h" #include "lwoSurfaceBlockHeader.h" +#include "lwoSurfaceBlockRepeat.h" #include "lwoSurfaceBlockTMap.h" +#include "lwoSurfaceBlockWrap.h" #include "lwoSurfaceColor.h" #include "lwoSurfaceParameter.h" #include "lwoSurfaceSidedness.h" @@ -53,8 +61,16 @@ ConfigureFn(config_lwo) { LwoStillImage::init_type(); LwoSurface::init_type(); LwoSurfaceBlock::init_type(); + LwoSurfaceBlockAxis::init_type(); + LwoSurfaceBlockChannel::init_type(); + LwoSurfaceBlockEnabled::init_type(); + LwoSurfaceBlockImage::init_type(); + LwoSurfaceBlockOpacity::init_type(); + LwoSurfaceBlockProjection::init_type(); LwoSurfaceBlockHeader::init_type(); + LwoSurfaceBlockRepeat::init_type(); LwoSurfaceBlockTMap::init_type(); + LwoSurfaceBlockWrap::init_type(); LwoSurfaceColor::init_type(); LwoSurfaceParameter::init_type(); LwoSurfaceSidedness::init_type(); diff --git a/pandatool/src/lwo/lwoSurface.h b/pandatool/src/lwo/lwoSurface.h index 1256961933..852e8fee65 100644 --- a/pandatool/src/lwo/lwoSurface.h +++ b/pandatool/src/lwo/lwoSurface.h @@ -14,7 +14,7 @@ // Class : LwoSurface // Description : Describes the shading attributes of a surface. This // is similar to the concept usually called a "material" -// in other file formats. +// or "shader" in other file formats. //////////////////////////////////////////////////////////////////// class LwoSurface : public LwoGroupChunk { public: diff --git a/pandatool/src/lwo/lwoSurfaceBlock.cxx b/pandatool/src/lwo/lwoSurfaceBlock.cxx index 27393d6e23..ce8eea5b6a 100644 --- a/pandatool/src/lwo/lwoSurfaceBlock.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlock.cxx @@ -5,8 +5,13 @@ #include "lwoSurfaceBlock.h" #include "iffInputFile.h" +#include "lwoSurfaceBlockAxis.h" +#include "lwoSurfaceBlockImage.h" #include "lwoSurfaceBlockHeader.h" +#include "lwoSurfaceBlockProjection.h" +#include "lwoSurfaceBlockRepeat.h" #include "lwoSurfaceBlockTMap.h" +#include "lwoSurfaceBlockWrap.h" #include @@ -60,6 +65,22 @@ make_new_chunk(IffInputFile *in, IffId id) { } else if (id == IffId("TMAP")) { return new LwoSurfaceBlockTMap; + } else if (id == IffId("PROJ")) { + return new LwoSurfaceBlockProjection; + + } else if (id == IffId("AXIS")) { + return new LwoSurfaceBlockAxis; + + } else if (id == IffId("IMAG")) { + return new LwoSurfaceBlockImage; + + } else if (id == IffId("WRAP")) { + return new LwoSurfaceBlockWrap; + + } else if (id == IffId("WRPH") || + id == IffId("WRPW")) { + return new LwoSurfaceBlockRepeat; + } else { return IffChunk::make_new_chunk(in, id); } diff --git a/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx new file mode 100644 index 0000000000..497e7c8d1a --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockAxis.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockAxis.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockAxis.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockAxis::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockAxis::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 LwoSurfaceBlockAxis:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _axis = (Axis)lin->get_be_uint16(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockAxis::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockAxis:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { axis = " << (int)_axis << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockAxis.h b/pandatool/src/lwo/lwoSurfaceBlockAxis.h new file mode 100644 index 0000000000..914a101e2d --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockAxis.h @@ -0,0 +1,53 @@ +// Filename: lwoSurfaceBlockAxis.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKAXIS_H +#define LWOSURFACEBLOCKAXIS_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockAxis +// Description : Indicates the axis for this particular shader's +// projection. This works in conjunction with +// LwoSurfaceBlockProjection. This is a subchunk of +// LwoSurfaceBlock. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockAxis : public LwoChunk { +public: + enum Axis { + M_x = 0, + M_y = 1, + M_z = 2 + }; + Axis _axis; + +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, "LwoSurfaceBlockAxis", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx new file mode 100644 index 0000000000..4913a3c881 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockChannel.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockChannel.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockChannel.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockChannel::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockChannel::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 LwoSurfaceBlockChannel:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _channel_id = lin->get_id(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockChannel::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockChannel:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { channel_id = " << _channel_id << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockChannel.h b/pandatool/src/lwo/lwoSurfaceBlockChannel.h new file mode 100644 index 0000000000..8e54108190 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockChannel.h @@ -0,0 +1,47 @@ +// Filename: lwoSurfaceBlockChannel.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKCHANNEL_H +#define LWOSURFACEBLOCKCHANNEL_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockChannel +// Description : Indicates which channel the texture in this +// LwoSurfaceBlock is applied to. This is a subchunk of +// LwoSurfaceBlockHeader. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockChannel : public LwoChunk { +public: + IffId _channel_id; + +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, "LwoSurfaceBlockChannel", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx new file mode 100644 index 0000000000..2f4eeb6d3e --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockEnabled.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockEnabled.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockEnabled.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockEnabled::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockEnabled::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 LwoSurfaceBlockEnabled:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _enabled = (lin->get_be_uint16() != 0); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockEnabled::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockEnabled:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { enabled = " << _enabled << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockEnabled.h b/pandatool/src/lwo/lwoSurfaceBlockEnabled.h new file mode 100644 index 0000000000..0ee76416cb --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockEnabled.h @@ -0,0 +1,47 @@ +// Filename: lwoSurfaceBlockEnabled.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKENABLED_H +#define LWOSURFACEBLOCKENABLED_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockEnabled +// Description : Indicates whether this particular layer or shader +// should be rendered or not. This is a subchunk of +// LwoSurfaceBlockHeader. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockEnabled : public LwoChunk { +public: + bool _enabled; + +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, "LwoSurfaceBlockEnabled", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx index 074c5d32a3..b1f71e7c5d 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockHeader.cxx @@ -5,6 +5,9 @@ #include "lwoSurfaceBlockHeader.h" #include "lwoInputFile.h" +#include "lwoSurfaceBlockChannel.h" +#include "lwoSurfaceBlockEnabled.h" +#include "lwoSurfaceBlockOpacity.h" #include @@ -63,30 +66,16 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// IffChunk *LwoSurfaceBlockHeader:: 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; + if (id == IffId("CHAN")) { + return new LwoSurfaceBlockChannel; - } else if (id == IffId("SIDE")) { - return new LwoSurfaceSidedness; + } else if (id == IffId("ENAB")) { + return new LwoSurfaceBlockEnabled; - } else if (id == IffId("SMAN")) { - return new LwoSurfaceSmoothingAngle; + } else if (id == IffId("OPAC")) { + return new LwoSurfaceBlockOpacity; - } else */ { + } else { return IffChunk::make_new_chunk(in, id); } } diff --git a/pandatool/src/lwo/lwoSurfaceBlockImage.cxx b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx new file mode 100644 index 0000000000..2da6d7e93c --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockImage.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockImage.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockImage.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockImage::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockImage::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 LwoSurfaceBlockImage:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _index = lin->get_vx(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockImage::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockImage:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { index = " << _index << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockImage.h b/pandatool/src/lwo/lwoSurfaceBlockImage.h new file mode 100644 index 0000000000..5c4e499898 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockImage.h @@ -0,0 +1,47 @@ +// Filename: lwoSurfaceBlockImage.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKIMAGE_H +#define LWOSURFACEBLOCKIMAGE_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockImage +// Description : Specifies the particular image that is being applied +// as a texture. This references a recently-defined +// CLIP image by index number. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockImage : public LwoChunk { +public: + int _index; + +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, "LwoSurfaceBlockImage", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx new file mode 100644 index 0000000000..045b03bae0 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.cxx @@ -0,0 +1,45 @@ +// Filename: lwoSurfaceBlockOpacity.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockOpacity.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockOpacity::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockOpacity::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 LwoSurfaceBlockOpacity:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _type = (Type)lin->get_be_uint16(); + _opacity = lin->get_be_float32(); + _envelope = lin->get_vx(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockOpacity::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockOpacity:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { type = " << (int)_type + << ", opacity = " << _opacity * 100.0 << "%, envelope = " << _envelope + << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockOpacity.h b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h new file mode 100644 index 0000000000..355d11348b --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockOpacity.h @@ -0,0 +1,59 @@ +// Filename: lwoSurfaceBlockOpacity.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKOPACITY_H +#define LWOSURFACEBLOCKOPACITY_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockOpacity +// Description : Indicates how transparent or opaque this particular +// layer is in relation to the layers beneath it. This +// is a subchunk of LwoSurfaceBlockHeader. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockOpacity : public LwoChunk { +public: + enum Type { + T_additive = 0, + T_subtractive = 1, + T_difference = 2, + T_multiply = 3, + T_divide = 4, + T_alpha = 5, + T_texture_displacement = 6 + }; + + Type _type; + float _opacity; + 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, "LwoSurfaceBlockOpacity", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx new file mode 100644 index 0000000000..c7f4a644ae --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockProjection.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockProjection.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockProjection.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockProjection::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockProjection::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 LwoSurfaceBlockProjection:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _mode = (Mode)lin->get_be_uint16(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockProjection::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockProjection:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { mode = " << (int)_mode << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockProjection.h b/pandatool/src/lwo/lwoSurfaceBlockProjection.h new file mode 100644 index 0000000000..157bf2bf96 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockProjection.h @@ -0,0 +1,56 @@ +// Filename: lwoSurfaceBlockProjection.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKPROJECTION_H +#define LWOSURFACEBLOCKPROJECTION_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockProjection +// Description : Indicates the projection mode for this particular +// shader. This determines how UV coordinates should be +// computed based on the vertex positions. This is a +// subchunk of LwoSurfaceBlock. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockProjection : public LwoChunk { +public: + enum Mode { + M_planar = 0, + M_cylindrical = 1, + M_spherical = 2, + M_cubic = 3, + M_front = 4, + M_uv = 5 + }; + Mode _mode; + +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, "LwoSurfaceBlockProjection", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx new file mode 100644 index 0000000000..f256898a01 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.cxx @@ -0,0 +1,43 @@ +// Filename: lwoSurfaceBlockRepeat.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockRepeat.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockRepeat::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockRepeat::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 LwoSurfaceBlockRepeat:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _cycles = lin->get_be_float32(); + _envelope = lin->get_vx(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockRepeat::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockRepeat:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { cycles = " << _cycles + << ", envelope = " << _envelope << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockRepeat.h b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h new file mode 100644 index 0000000000..1192a16572 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockRepeat.h @@ -0,0 +1,50 @@ +// Filename: lwoSurfaceBlockRepeat.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKREPEAT_H +#define LWOSURFACEBLOCKREPEAT_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockRepeat +// Description : For cylindrical and spherical projections, this +// parameter controls how many times the image repeats +// over each full interval, in either dimension. The +// dimension is specified by the id of the chunk, either +// WRPW or WRPH. This is a subchunk of LwoSurfaceBlock. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockRepeat : public LwoChunk { +public: + float _cycles; + 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, "LwoSurfaceBlockRepeat", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx new file mode 100644 index 0000000000..124138a3d7 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockWrap.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockWrap.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockWrap.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockWrap::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockWrap::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 LwoSurfaceBlockWrap:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _mode = (Mode)lin->get_be_uint16(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockWrap::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockWrap:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { mode = " << (int)_mode << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockWrap.h b/pandatool/src/lwo/lwoSurfaceBlockWrap.h new file mode 100644 index 0000000000..02818b1834 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockWrap.h @@ -0,0 +1,52 @@ +// Filename: lwoSurfaceBlockWrap.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKWRAP_H +#define LWOSURFACEBLOCKWRAP_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockWrap +// Description : Specifies how the texture image appears for areas +// outside the image. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockWrap : public LwoChunk { +public: + enum Mode { + M_reset = 0, // black outside + M_repeat = 1, // standard repeat + M_mirror = 2, // repeat with reflection + M_edge = 3 // GL-style clamping + }; + Mode _mode; + +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, "LwoSurfaceBlockWrap", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + +