diff --git a/pandatool/src/lwo/Sources.pp b/pandatool/src/lwo/Sources.pp index 43f4ec2109..3aae66d3f0 100644 --- a/pandatool/src/lwo/Sources.pp +++ b/pandatool/src/lwo/Sources.pp @@ -28,13 +28,16 @@ lwoSurfaceBlock.h lwoSurfaceBlock.cxx \ lwoSurfaceBlockAxis.h lwoSurfaceBlockAxis.cxx \ lwoSurfaceBlockChannel.h lwoSurfaceBlockChannel.cxx \ + lwoSurfaceBlockCoordSys.h lwoSurfaceBlockCoordSys.cxx \ lwoSurfaceBlockEnabled.h lwoSurfaceBlockEnabled.cxx \ lwoSurfaceBlockImage.h lwoSurfaceBlockImage.cxx \ lwoSurfaceBlockOpacity.h lwoSurfaceBlockOpacity.cxx \ lwoSurfaceBlockProjection.h lwoSurfaceBlockProjection.cxx \ lwoSurfaceBlockHeader.h lwoSurfaceBlockHeader.cxx \ + lwoSurfaceBlockRefObj.h lwoSurfaceBlockRefObj.cxx \ lwoSurfaceBlockRepeat.h lwoSurfaceBlockRepeat.cxx \ lwoSurfaceBlockTMap.h lwoSurfaceBlockTMap.cxx \ + lwoSurfaceBlockTransform.h lwoSurfaceBlockTransform.cxx \ lwoSurfaceBlockWrap.h lwoSurfaceBlockWrap.cxx \ lwoSurfaceColor.h lwoSurfaceColor.cxx \ lwoSurfaceParameter.h lwoSurfaceParameter.cxx \ @@ -62,13 +65,16 @@ lwoSurfaceBlock.h \ lwoSurfaceBlockAxis.h \ lwoSurfaceBlockChannel.h \ + lwoSurfaceBlockCoordSys.h \ lwoSurfaceBlockEnabled.h \ lwoSurfaceBlockImage.h \ lwoSurfaceBlockOpacity.h \ lwoSurfaceBlockProjection.h \ lwoSurfaceBlockHeader.h \ + lwoSurfaceBlockRefObj.h \ lwoSurfaceBlockRepeat.h \ lwoSurfaceBlockTMap.h \ + lwoSurfaceBlockTransform.h \ lwoSurfaceBlockWrap.h \ lwoSurfaceColor.h \ lwoSurfaceParameter.h \ diff --git a/pandatool/src/lwo/config_lwo.cxx b/pandatool/src/lwo/config_lwo.cxx index 1afc3cc0cb..a11061199b 100644 --- a/pandatool/src/lwo/config_lwo.cxx +++ b/pandatool/src/lwo/config_lwo.cxx @@ -23,13 +23,16 @@ #include "lwoSurfaceBlock.h" #include "lwoSurfaceBlockAxis.h" #include "lwoSurfaceBlockChannel.h" +#include "lwoSurfaceBlockCoordSys.h" #include "lwoSurfaceBlockEnabled.h" #include "lwoSurfaceBlockImage.h" #include "lwoSurfaceBlockOpacity.h" #include "lwoSurfaceBlockProjection.h" #include "lwoSurfaceBlockHeader.h" +#include "lwoSurfaceBlockRefObj.h" #include "lwoSurfaceBlockRepeat.h" #include "lwoSurfaceBlockTMap.h" +#include "lwoSurfaceBlockTransform.h" #include "lwoSurfaceBlockWrap.h" #include "lwoSurfaceColor.h" #include "lwoSurfaceParameter.h" @@ -63,13 +66,16 @@ ConfigureFn(config_lwo) { LwoSurfaceBlock::init_type(); LwoSurfaceBlockAxis::init_type(); LwoSurfaceBlockChannel::init_type(); + LwoSurfaceBlockCoordSys::init_type(); LwoSurfaceBlockEnabled::init_type(); LwoSurfaceBlockImage::init_type(); LwoSurfaceBlockOpacity::init_type(); LwoSurfaceBlockProjection::init_type(); LwoSurfaceBlockHeader::init_type(); + LwoSurfaceBlockRefObj::init_type(); LwoSurfaceBlockRepeat::init_type(); LwoSurfaceBlockTMap::init_type(); + LwoSurfaceBlockTransform::init_type(); LwoSurfaceBlockWrap::init_type(); LwoSurfaceColor::init_type(); LwoSurfaceParameter::init_type(); diff --git a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx new file mode 100644 index 0000000000..bc6b5ee473 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockCoordSys.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockCoordSys.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockCoordSys::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockCoordSys::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 LwoSurfaceBlockCoordSys:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _type = (Type)lin->get_be_uint16(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockCoordSys::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockCoordSys:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { type = " << (int)_type << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h new file mode 100644 index 0000000000..412bb08c43 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockCoordSys.h @@ -0,0 +1,52 @@ +// Filename: lwoSurfaceBlockCoordSys.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKCOORDSYS_H +#define LWOSURFACEBLOCKCOORDSYS_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockCoordSys +// Description : Specifies whether texture coordinates are computed +// based on the vertices' world coordinates or local +// coordinates. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockCoordSys : public LwoChunk { +public: + enum Type { + T_object = 0, + T_world = 1 + }; + + Type _type; + +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, "LwoSurfaceBlockCoordSys", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx new file mode 100644 index 0000000000..8308a560ed --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockRefObj.cxx @@ -0,0 +1,41 @@ +// Filename: lwoSurfaceBlockRefObj.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockRefObj.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockRefObj::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockRefObj::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 LwoSurfaceBlockRefObj:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _name = lin->get_string(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockRefObj::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockRefObj:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { name = \"" << _name << "\" }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockRefObj.h b/pandatool/src/lwo/lwoSurfaceBlockRefObj.h new file mode 100644 index 0000000000..844ff4c14d --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockRefObj.h @@ -0,0 +1,46 @@ +// Filename: lwoSurfaceBlockRefObj.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKREFOBJ_H +#define LWOSURFACEBLOCKREFOBJ_H + +#include + +#include "lwoChunk.h" + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockRefObj +// Description : Specifies a reference object that the texture UV's +// are to be computed relative to. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockRefObj : public LwoChunk { +public: + string _name; + +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, "LwoSurfaceBlockRefObj", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + + diff --git a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx index dbb947e8d4..7c6e084928 100644 --- a/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx +++ b/pandatool/src/lwo/lwoSurfaceBlockTMap.cxx @@ -5,6 +5,9 @@ #include "lwoSurfaceBlockTMap.h" #include "lwoInputFile.h" +#include "lwoSurfaceBlockCoordSys.h" +#include "lwoSurfaceBlockTransform.h" +#include "lwoSurfaceBlockRefObj.h" #include @@ -52,30 +55,18 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// IffChunk *LwoSurfaceBlockTMap:: 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("CNTR") || + id == IffId("SIZE") || + id == IffId("ROTA")) { + return new LwoSurfaceBlockTransform; - } else if (id == IffId("SIDE")) { - return new LwoSurfaceSidedness; + } else if (id == IffId("OREF")) { + return new LwoSurfaceBlockRefObj; - } else if (id == IffId("SMAN")) { - return new LwoSurfaceSmoothingAngle; + } else if (id == IffId("CSYS")) { + return new LwoSurfaceBlockCoordSys; - } else */ { + } else { return IffChunk::make_new_chunk(in, id); } } diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx new file mode 100644 index 0000000000..7c1346081c --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.cxx @@ -0,0 +1,43 @@ +// Filename: lwoSurfaceBlockTransform.cxx +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "lwoSurfaceBlockTransform.h" +#include "lwoInputFile.h" + +#include + +TypeHandle LwoSurfaceBlockTransform::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockTransform::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 LwoSurfaceBlockTransform:: +read_iff(IffInputFile *in, size_t stop_at) { + LwoInputFile *lin = DCAST(LwoInputFile, in); + + _vec = lin->get_vec3(); + _envelope = lin->get_vx(); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LwoSurfaceBlockTransform::write +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +void LwoSurfaceBlockTransform:: +write(ostream &out, int indent_level) const { + indent(out, indent_level) + << get_id() << " { vec = " << _vec + << ", envelope = " << _envelope << " }\n"; +} diff --git a/pandatool/src/lwo/lwoSurfaceBlockTransform.h b/pandatool/src/lwo/lwoSurfaceBlockTransform.h new file mode 100644 index 0000000000..d04b125085 --- /dev/null +++ b/pandatool/src/lwo/lwoSurfaceBlockTransform.h @@ -0,0 +1,52 @@ +// Filename: lwoSurfaceBlockTransform.h +// Created by: drose (24Apr01) +// +//////////////////////////////////////////////////////////////////// + +#ifndef LWOSURFACEBLOCKTRANSFORM_H +#define LWOSURFACEBLOCKTRANSFORM_H + +#include + +#include "lwoChunk.h" + +#include + +//////////////////////////////////////////////////////////////////// +// Class : LwoSurfaceBlockTransform +// Description : Specifies a center point, scale, or rotation for the +// texture coordinates in this shader's texture mapping. +// The type of transform is specified by the ID of the +// chunk; either CNTR, SIZE, or ROTA. This is a +// subchunk of LwoSurfaceBlockTMap. +//////////////////////////////////////////////////////////////////// +class LwoSurfaceBlockTransform : public LwoChunk { +public: + LVecBase3f _vec; + 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, "LwoSurfaceBlockTransform", + LwoChunk::get_class_type()); + } + +private: + static TypeHandle _type_handle; +}; + +#endif + +