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
/**********************************************************************
*
* 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());
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());
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.");
}
}
#include <osgSim/LightPointNode>
#include <osgSim/LightPoint>
#include <osg/ref_ptr>
#include "IO_LightPoint.h"
#include <iostream>
#include <string>
#include <osgDB/Registry>
#include <osgDB/Input>
#include <osgDB/Output>
#include <osgDB/ParameterOutput>
using namespace osgSim;
bool LightPointNode_readLocalData(osg::Object &obj, osgDB::Input &fr);
bool LightPointNode_writeLocalData(const osg::Object &obj, osgDB::Output &fw);
osgDB::RegisterDotOsgWrapperProxy LightPointNode_Proxy
(
new LightPointNode,
"LightPointNode",
"Object Node LightPointNode",
&LightPointNode_readLocalData,
&LightPointNode_writeLocalData
);
bool LightPointNode_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
LightPointNode &lightpointnode = static_cast<LightPointNode &>(obj);
bool itAdvanced = false;
if (fr.matchSequence("num_lightpoints %d")) {
// Could allocate space for lightpoints here
fr += 2;
itAdvanced = true;
}
if (fr.matchSequence("minPixelSize %f")) {
float size = 0.0f;
fr[1].getFloat(size);
lightpointnode.setMinPixelSize(size);
fr += 2;
itAdvanced = true;
}
if (fr.matchSequence("maxPixelSize %f")) {
float size = 30.0f;
fr[1].getFloat(size);
lightpointnode.setMaxPixelSize(size);
fr += 2;
itAdvanced = true;
}
if (fr.matchSequence("maxVisibleDistance2 %f")) {
float distance = FLT_MAX;
fr[1].getFloat(distance);
lightpointnode.setMaxVisibleDistance2(distance);
fr += 2;
itAdvanced = true;
}
if (fr[0].matchWord("pointSprite"))
{
if (fr[1].matchWord("FALSE"))
{
lightpointnode.setPointSprite(false);
fr+=2;
itAdvanced = true;
}
else if (fr[1].matchWord("TRUE"))
{
lightpointnode.setPointSprite(true);
fr+=2;
itAdvanced = true;
}
}
if (fr[0].matchWord("lightPoint")) {
LightPoint lp;
if (readLightPoint(lp, fr)) {
lightpointnode.addLightPoint(lp);
itAdvanced = true;
}
}
return itAdvanced;
}
bool LightPointNode_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
{
const LightPointNode &lightpointnode = static_cast<const LightPointNode
&>(obj);
fw.indent() << "num_lightpoints " << lightpointnode.getNumLightPoints() <<
std::endl;
fw.indent() << "minPixelSize " << lightpointnode.getMinPixelSize() <<
std::endl;
fw.indent() << "maxPixelSize " << lightpointnode.getMaxPixelSize() <<
std::endl;
fw.indent() << "maxVisibleDistance2 " <<
lightpointnode.getMaxVisibleDistance2() << std::endl;
fw.indent() << "pointSprite " << ( lightpointnode.getPointSprite() ?
"TRUE" : "FALSE" ) << std::endl;
LightPointNode::LightPointList const lightpointlist =
lightpointnode.getLightPointList();
LightPointNode::LightPointList::const_iterator itr;
for (itr = lightpointlist.begin(); itr != lightpointlist.end(); itr++) {
writeLightPoint((*itr), fw);
}
return true;
}
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org