Hi,
As Lars mentioned, this seems to have been a typo in the OpenFlight
specification, rather than a change in the OpenFlight format. Actually,
all 64 bit doubles seem to begin at even 8 bytes in the ATTR file
format, that's why we need the added padding of 4 bytes, and I think
this has always been the case. So I'm pretty convinced that it doesn't
break older versions. Have a look at the following conversation for this
and a couple of other discrepancies in the OpenFlight specification:
http://www.multigen-paradigm.com/ubb/Forum8/HTML/000253.html
The other changes include another 4 bytes of padding after the comments.
The attached file contains this change and is based on the file modified
by Lars. The remaining issues discussed in the link above are probably
of no great interest right now.
Funny, I thought I submitted those changes long ago, but perhaps it was
for the old OpenFlight reader. Anyway, thanks to Lars for the spotting
this and submitting the correction!
Regards,
Andreas Ekstrand
Robert Osfield wrote:
Hi Lars,
I've just reviewed you change and it looks like to me that it changes
the assumed format for all version of OpenFlight files, not just a
specific version and later as I was expecting, and therefore would
suspect this change might break older versions of OpenFlight.
As this submissions might break backwards compatibility with
OpenFlight files I am not going to merge right now. This issue needs
to be fleshed out by others more knowledge of OpenFlight than myself.
Calling Brede Johansen and Paul Martz... could you guys have a review
of this submissions.
Cheers,
Robert.
On Tue, Feb 19, 2008 at 4:44 PM, Lars Nilsson
<[EMAIL PROTECTED]> wrote:
Hi,
The change in this submission is for Texture Attribute File as described
from version 16.1 of OpenFlight documentation.
In fact, I believe that it is only the documentation that has been
corrected, the file format was even before that the same.
The attached file is based on OpenSceneGraph 2.3.4.
Regards,
Lars Nilsson
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
--
______________________________________________________________
Andreas Ekstrand
Remograph
Norrbergavägen 58
SE-590 54 Sturefors
SWEDEN
Website: http://www.remograph.com/
E-mail: [EMAIL PROTECTED]
Phone: +46 708 490 697
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//
// OpenFlight® loader for OpenSceneGraph
//
// Copyright (C) 2005-2007 Brede Johansen
//
#include <osg/Notify>
#include <osg/TexEnv>
#include <osg/Texture2D>
#include <osg/StateSet>
#include <osg/GL>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/Registry>
#include "AttrData.h"
#include "DataInputStream.h"
using namespace osg;
using namespace osgDB;
using namespace flt;
class ReaderWriterATTR : public osgDB::ReaderWriter
{
public:
virtual const char* className() const { return "ATTR Image Attribute Reader/Writer"; }
virtual bool acceptsExtension(const std::string& extension) const
{
return equalCaseInsensitive(extension,"attr");
}
virtual ReadResult readObject(const std::string& fileName, const ReaderWriter::Options*) const;
};
ReaderWriter::ReadResult ReaderWriterATTR::readObject(const std::string& file, const ReaderWriter::Options* options) const
{
using std::ios;
std::string ext = osgDB::getLowerCaseFileExtension(file);
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
std::string fileName = osgDB::findDataFile( file, options );
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
std::ifstream fin;
fin.imbue(std::locale::classic());
fin.open(fileName.c_str(), std::ios::in | std::ios::binary);
if ( fin.fail())
return ReadResult::ERROR_IN_READING_FILE;
flt::DataInputStream in(fin.rdbuf());
AttrData* attr = new AttrData;
try
{
attr->texels_u = in.readInt32();
attr->textel_v = in.readInt32();
attr->direction_u = in.readInt32();
attr->direction_v = in.readInt32();
attr->x_up = in.readInt32();
attr->y_up = in.readInt32();
attr->fileFormat = in.readInt32();
attr->minFilterMode = in.readInt32();
attr->magFilterMode = in.readInt32();
attr->wrapMode = in.readInt32(AttrData::WRAP_REPEAT);
attr->wrapMode_u = in.readInt32();
if (attr->wrapMode_u == AttrData::WRAP_NONE)
attr->wrapMode_u = attr->wrapMode;
attr->wrapMode_v = in.readInt32();
if (attr->wrapMode_v == AttrData::WRAP_NONE)
attr->wrapMode_v = attr->wrapMode;
attr->modifyFlag = in.readInt32();
attr->pivot_x = in.readInt32();
attr->pivot_y = in.readInt32();
// v11 ends here
// if (in.eof() || (_flt_version <= 11)) return true;
#if 1
attr->texEnvMode = in.readInt32(AttrData::TEXENV_MODULATE);
attr->intensityAsAlpha = in.readInt32();
in.forward(4*8);
in.forward(4);
attr->size_u = in.readFloat64();
attr->size_v = in.readFloat64();
attr->originCode = in.readInt32();
attr->kernelVersion = in.readInt32();
attr->intFormat = in.readInt32();
attr->extFormat = in.readInt32();
attr->useMips = in.readInt32();
for (int n=0; n<8; n++)
attr->of_mips[n] = in.readFloat32();
attr->useLodScale = in.readInt32();
attr->lod0 = in.readFloat32();
attr->scale0 = in.readFloat32();
attr->lod1 = in.readFloat32();
attr->scale1 = in.readFloat32();
attr->lod2 = in.readFloat32();
attr->scale2 = in.readFloat32();
attr->lod3 = in.readFloat32();
attr->scale3 = in.readFloat32();
attr->lod4 = in.readFloat32();
attr->scale4 = in.readFloat32();
attr->lod5 = in.readFloat32();
attr->scale5 = in.readFloat32();
attr->lod6 = in.readFloat32();
attr->scale6 = in.readFloat32();
attr->lod7 = in.readFloat32();
attr->scale7 = in.readFloat32();
attr->clamp = in.readFloat32();
attr->magFilterAlpha = in.readInt32();
attr->magFilterColor = in.readInt32();
in.forward(4);
in.forward(4*8);
attr->lambertMeridian = in.readFloat64();
attr->lambertUpperLat = in.readFloat64();
attr->lambertlowerLat = in.readFloat64();
in.forward(8);
in.forward(4*5);
attr->useDetail = in.readInt32( );
attr->txDetail_j = in.readInt32();
attr->txDetail_k = in.readInt32();
attr->txDetail_m = in.readInt32();
attr->txDetail_n = in.readInt32();
attr->txDetail_s = in.readInt32( );
attr->useTile = in.readInt32();
attr->txTile_ll_u= in.readFloat32();
attr->txTile_ll_v = in.readFloat32();
attr->txTile_ur_u = in.readFloat32();
attr->txTile_ur_v = in.readFloat32();
attr->projection = in.readInt32();
attr->earthModel = in.readInt32();
in.forward(4);
attr->utmZone = in.readInt32();
attr->imageOrigin = in.readInt32();
attr->geoUnits = in.readInt32();
in.forward(4);
in.forward(4);
attr->hemisphere = in.readInt32();
in.forward(4);
in.forward(4);
in.forward(149*4);
attr->comments = in.readString(512);
// v12 ends here
// if (in.eof() || (_flt_version <= 12)) return true;
in.forward(14*4);
attr->attrVersion = in.readInt32();
attr->controlPoints = in.readInt32();
in.forward(4);
#endif
}
catch(...)
{
if (!fin.eof())
{
throw;
}
}
fin.close();
return attr;
}
// now register with Registry to instantiate the above
// reader/writer.
REGISTER_OSGPLUGIN(attr, ReaderWriterATTR)
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org