Hi Wojciech,

I've now merged your changes, and added version testing into the .ive
code, I've attached the the files I changed for you future reference.
The .osg plugin doesn't require versioning as its ASCII based parsing
is very flexible w.r.t versioning.

Robert.

On Mon, Feb 25, 2008 at 3:58 PM, Wojciech Lewandowski
<[EMAIL PROTECTED]> wrote:
>
>
> Hi, Robert
>
> I have found that ive and osg does not store/read pointSprite selection flag
> for osgSim::LightPointNode. Attached are modifications in ive & osg osgSim
> plugins.
> I susppose this modification breaks backward compatibility. I don't know
> whats your policy in such cases. Is there an option to test file version and
> parse & interpret data conditionally ?
>
> Cheers,
> Wojtek
> _______________________________________________
>  osg-submissions mailing list
>  [email protected]
>
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
>
#ifndef IVE_VERSION
#define IVE_VERSION 1


/* The VERSION tag should be updated any time the
   IVE format changes in order to support backward
   compatibility (if implemented).  VERSION is 
   stored in the 2nd 4 bytes of the file */

#define VERSION_0001 1
#define VERSION_0002 2
#define VERSION_0003 3
#define VERSION_0004 4
#define VERSION_0005 5
#define VERSION_0006 6
#define VERSION_0007 7

#define VERSION_0008 8
#define VERSION_0009 9
#define VERSION_0010 10
#define VERSION_0011 11
#define VERSION_0012 12
#define VERSION_0013 13
#define VERSION_0014 14
#define VERSION_0015 15
#define VERSION_0016 16
#define VERSION_0017 17
#define VERSION_0018 18
#define VERSION_0019 19
#define VERSION_0020 20
#define VERSION_0021 21
#define VERSION_0022 22
#define VERSION_0023 23
#define VERSION_0024 24

#define VERSION VERSION_0024

/* The BYTE_SEX tag is used to check the endian
   of the IVE file being read in.  The IVE format
   is always written in the native endian of the
   machine to provide optimum reading of the file.
   BYTE_SEX is stored in the first 4 bytes of the 
   file */
#define ENDIAN_TYPE 0x01020304
#define OPPOSITE_ENDIAN_TYPE 0x04030201


#endif
/**********************************************************************
 *
 *    FILE:            LightPointNode.cpp
 *
 *    DESCRIPTION:    Read/Write osgSim::LightPointNode in binary format to disk.
 *
 *    CREATED BY:        Auto generated by iveGenerator.exe
 *                    and later modified by Rune Schmidt Jensen.
 *
 *    HISTORY:        Created 14.9.2003
 *
 **********************************************************************/

#include "Exception.h"
#include "LightPointNode.h"
#include "LightPoint.h"
#include "Node.h"

using namespace ive;

void LightPointNode::write(DataOutputStream* out){
    // Write LightPointNode's identification.
    out->writeInt(IVELIGHTPOINTNODE);
    // If the osgSim class is inherited by any other class we should also write this to file.
    osg::Node*  node = dynamic_cast<osg::Node*>(this);
    if(node){
        ((ive::Node*)(node))->write(out);
    }
    else
        throw Exception("LightPointNode::write(): Could not cast this osgSim::LightPointNode to an osg::Node.");

    // Write LightPointNode's properties.
    out->writeFloat(getMinPixelSize());
    out->writeFloat(getMaxPixelSize());
    out->writeFloat(getMaxVisibleDistance2());

    if (out->getVersion() >= VERSION_0024)
    {
        out->writeBool(getPointSprite());
    }

    // Write out LightPoints.
    unsigned int size = getNumLightPoints();
    out->writeUInt(size);
    for(unsigned int i=0; i<size; i++){
        ((ive::LightPoint*)(&getLightPoint(i)))->write(out);
    }
}

void LightPointNode::read(DataInputStream* in){
    // Peek on LightPointNode's identification.
    int id = in->peekInt();
    if(id == IVELIGHTPOINTNODE){
        // Read LightPointNode's identification.
        id = in->readInt();
        // If the osgSim class is inherited by any other class we should also read this from file.
        osg::Node*  node = dynamic_cast<osg::Node*>(this);
        if(node){
            ((ive::Node*)(node))->read(in);
        }
        else
            throw Exception("LightPointNode::read(): Could not cast this osgSim::LightPointNode to an osg::Object.");
        // Read LightPointNode's properties
        setMinPixelSize(in->readFloat());
        setMaxPixelSize(in->readFloat());
        setMaxVisibleDistance2(in->readFloat());

        if (in->getVersion() >= VERSION_0024)
        {
            setPointSprite(in->readBool());
        }
        
        // Read in lightpoints.
        unsigned int size = in->readUInt();
        for(unsigned int i=0; i<size; i++ ){
            osgSim::LightPoint lightPoint;
            ((ive::LightPoint*)(&lightPoint))->read(in);
            addLightPoint(lightPoint);
        }
    }
    else{
        throw Exception("LightPointNode::read(): Expected LightPointNode identification.");
    }
}
#ifndef IVE_VERSION
#define IVE_VERSION 1


/* The VERSION tag should be updated any time the
   IVE format changes in order to support backward
   compatibility (if implemented).  VERSION is 
   stored in the 2nd 4 bytes of the file */

#define VERSION_0001 1
#define VERSION_0002 2
#define VERSION_0003 3
#define VERSION_0004 4
#define VERSION_0005 5
#define VERSION_0006 6
#define VERSION_0007 7

#define VERSION_0008 8
#define VERSION_0009 9
#define VERSION_0010 10
#define VERSION_0011 11
#define VERSION_0012 12
#define VERSION_0013 13
#define VERSION_0014 14
#define VERSION_0015 15
#define VERSION_0016 16
#define VERSION_0017 17
#define VERSION_0018 18
#define VERSION_0019 19
#define VERSION_0020 20
#define VERSION_0021 21
#define VERSION_0022 22
#define VERSION_0023 23
#define VERSION_0024 24

#define VERSION VERSION_0024

/* The BYTE_SEX tag is used to check the endian
   of the IVE file being read in.  The IVE format
   is always written in the native endian of the
   machine to provide optimum reading of the file.
   BYTE_SEX is stored in the first 4 bytes of the 
   file */
#define ENDIAN_TYPE 0x01020304
#define OPPOSITE_ENDIAN_TYPE 0x04030201


#endif
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to