From Geoff Michel, updates to the Geo plugin.
Removed osg::uint reference form the pfb plugin.
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <osg/Sequence>
|
||||
#include <osg/Switch>
|
||||
#include <osg/Geode>
|
||||
#include <osg/LineWidth>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osg/Material>
|
||||
@@ -44,10 +45,7 @@
|
||||
#include "osgGeoStructs.h"
|
||||
#include "osgGeoNodes.h"
|
||||
#include "osgGeoAction.h"
|
||||
|
||||
#ifdef USETEXT // buggy text feb 2003
|
||||
#include <osgText/Text> // needed for text nodes
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
@@ -305,17 +303,19 @@ private:
|
||||
class geoInfo { // identifies properties required to make a new Geometry, and holds collection of vertices, indices, etc
|
||||
public:
|
||||
geoInfo(const int txidx=-2, const int sm=1, const bool bs=true) { texture=txidx; // will be -1 or 0-number of textures
|
||||
geom=NULL; nstart=0;
|
||||
geom=NULL; nstart=0; linewidth=1;
|
||||
bothsides=bs; shademodel=sm;
|
||||
}
|
||||
virtual ~geoInfo() { };
|
||||
inline int getShademodel() const { return shademodel;}
|
||||
inline bool getBothsides() const { return bothsides;}
|
||||
inline int getTexture() const { return texture;}
|
||||
inline vertexInfo *getVinf() { return &vinf;}
|
||||
inline int getShademodel(void) const { return shademodel;}
|
||||
inline bool getBothsides(void) const { return bothsides;}
|
||||
inline int getTexture(void) const { return texture;}
|
||||
inline vertexInfo *getVinf(void) { return &vinf;}
|
||||
void setPools(const std::vector<osg::Vec3> *coord_pool, const std::vector<osg::Vec3> *normal_pool) {
|
||||
vinf.setPools(coord_pool,normal_pool);
|
||||
}
|
||||
float getlinewidth(void) const { return linewidth;}
|
||||
void setlineWidth(const int w) { linewidth=w;}
|
||||
void setGeom(osg::Geometry *nugeom) { geom=nugeom;}
|
||||
osg::Geometry *getGeom() const { return geom;}
|
||||
osg::Geometry *getGeom() { return geom;}
|
||||
@@ -331,6 +331,7 @@ private:
|
||||
int texture; // texture index
|
||||
bool bothsides;
|
||||
int shademodel;
|
||||
int linewidth;
|
||||
vertexInfo vinf;
|
||||
uint nstart; // start vertex for a primitive
|
||||
osg::Geometry *geom; // the geometry created for this vinf and texture
|
||||
@@ -358,7 +359,6 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::ifstream fin(fileName.c_str(), std::ios::binary | std::ios::in );
|
||||
//std::ofstream fdup("geodup.geo", std::ios::binary | std::ios::out );
|
||||
if (fin.is_open() )
|
||||
{ // read the input file.
|
||||
typedef std::vector<osg::Node*> NodeList;
|
||||
@@ -372,7 +372,7 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
{
|
||||
georecord gr;
|
||||
gr.readfile(fin);
|
||||
//if (gr.getType() != DB_DSK_INSTANCE) gr.writefile(fdup); // create a duplicate file
|
||||
// osg::notify(osg::WARN) << "end of record " << (int)gr.getType() << std::endl;
|
||||
if (gr.getType() == DB_DSK_NORMAL_POOL) {
|
||||
geoField *gfff=gr.getModField(GEO_DB_NORMAL_POOL_VALUES);
|
||||
gfff->uncompress();// uncompress the normals
|
||||
@@ -380,19 +380,15 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
recs.push_back(gr); // add to a list of all records
|
||||
}
|
||||
fin.close();
|
||||
//fdup.close();
|
||||
// now sort the records so that any record followed by a PUSh has a child set = next record, etc
|
||||
std::vector<georecord *> sorted=sort(recs); // tree-list of sorted record pointers
|
||||
//#ifdef _DEBUG
|
||||
/*#ifdef _DEBUG
|
||||
osgDB::Output fout("georex.txt"); //, std::ios_base::out );
|
||||
fout << "Debug file " << fileName << std::endl;
|
||||
output(fout,sorted);
|
||||
fout.close();
|
||||
//#endif
|
||||
|
||||
nodeList=makeosg(sorted); // make a list of osg nodes
|
||||
|
||||
|
||||
#endif */
|
||||
nodeList=makeosg(sorted); // make a list of osg nodes
|
||||
recs.clear();
|
||||
geotxlist.clear();
|
||||
geomatlist.clear();
|
||||
@@ -642,6 +638,9 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
}
|
||||
}
|
||||
}
|
||||
osg::LineWidth *lw=new osg::LineWidth;
|
||||
lw->setWidth(ginf.getlinewidth());
|
||||
dstate->setAttributeAndModes(lw,osg::StateAttribute::ON);
|
||||
nug->setStateSet( dstate );
|
||||
ginf.setGeom(nug);
|
||||
return nug;
|
||||
@@ -702,7 +701,6 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
}
|
||||
osg::MatrixTransform *makeText(georecord *gr) { // make transform, geode & text
|
||||
osg::MatrixTransform *numt=NULL;
|
||||
#ifdef USETEXT // buggy text feb 2003
|
||||
std::string ttfPath("fonts/times.ttf");
|
||||
int gFontSize1=2;
|
||||
osgText::PolygonFont* polygonFont= new osgText::PolygonFont(ttfPath,
|
||||
@@ -777,7 +775,6 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return numt;
|
||||
}
|
||||
void addPolyActions(std::vector< georecord *>bhv, geoInfo &gi , const uint nv) {
|
||||
@@ -973,6 +970,11 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
int shademodel=gfd ? gfd->getInt() : GEO_POLY_SHADEMODEL_LIT_GOURAUD;
|
||||
geoInfo gi(txidx,shademodel, bothsides);
|
||||
gi.setPools(&coord_pool, &normal_pool);
|
||||
gfd=grec->getField(GEO_DB_POLY_LINE_WIDTH); // integer line width...
|
||||
if (gfd) {
|
||||
int w=gfd->getInt();
|
||||
gi.setlineWidth(w);
|
||||
}
|
||||
osg::Geometry *nugeom=makeNewGeometry(grec, gi, imat);
|
||||
nug->addDrawable(nugeom);
|
||||
igeom=ia->size();
|
||||
@@ -1058,7 +1060,6 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
igeom++;
|
||||
}
|
||||
}
|
||||
// osg::notify(osg::WARN) << vinf;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1666,6 +1667,12 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
holder=makePage(gr);
|
||||
(*itr)->setNode(holder);
|
||||
break;
|
||||
case DB_DSK_PERSPECTIVE_GRID_INFO:
|
||||
{ // relates to how model is viewed in Geo modeller
|
||||
osg::Group *gp=new Group;
|
||||
holder=gp;
|
||||
}
|
||||
break;
|
||||
case DB_DSK_FLOAT_VAR:
|
||||
case DB_DSK_INT_VAR:
|
||||
case DB_DSK_LONG_VAR:
|
||||
@@ -1691,8 +1698,8 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
case DB_DSK_STRING_CONTENT_ACTION:
|
||||
default: {
|
||||
osg::Group *gp=new Group;
|
||||
std::cout << "Unhandled item " << gr->getType() << std::endl;
|
||||
std::cout << "Unhandled item " << (*itr) << std::endl;
|
||||
std::cout << "Unhandled item " << gr->getType() <<
|
||||
"address " << (*itr) << std::endl;
|
||||
holder=gp;
|
||||
}
|
||||
break;
|
||||
@@ -1784,11 +1791,12 @@ class ReaderWriterGEO : public ReaderWriter
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
geoRecordList recs; // the records read from file
|
||||
std::vector<osg::Vec3> coord_pool; // current vertex ooords
|
||||
std::vector<osg::Vec3> normal_pool; // current pool of normal vectors
|
||||
geoHeaderGeo *theHeader; // has animation vars etc
|
||||
geoHeaderGeo *theHeader; // an OSG class - has animation vars etc
|
||||
std::vector<georecord *> geotxlist; // list of geo::textures for this model
|
||||
std::vector<georecord *> geomatlist; // list of geo::materials for this model
|
||||
std::vector<osg::Texture2D *> txlist; // list of osg::textures for this model
|
||||
@@ -1919,6 +1927,63 @@ void internalVars::update(const osg::FrameStamp *_frameStamp) {
|
||||
// std::cout<<"update callback - post traverse"<< (float)_frameStamp->getReferenceTime() <<std::endl;
|
||||
}
|
||||
|
||||
void geoField::parseExt(std::ifstream &fin) const { // Feb 2003 parse onme extension fields
|
||||
static int nread=0; // debug only
|
||||
geoExtensionDefRec *geoExt=(geoExtensionDefRec *)storage;
|
||||
for (uint i=0; i<numItems; i++) {
|
||||
geoExtensionDefRec rec;
|
||||
fin.read((char *)&rec,sizeof(rec));
|
||||
geoField ginner; // inside reading
|
||||
ginner.readfile(fin,0);
|
||||
}
|
||||
nread++;
|
||||
}
|
||||
void geoField::readfile(std::ifstream &fin, const uint id) { // is part of a record id
|
||||
unsigned char tokid, type;
|
||||
unsigned short nits;
|
||||
if (!fin.eof()) {
|
||||
fin.read((char *)&tokid,1);fin.read((char *)&type,1);
|
||||
fin.read((char *)&nits,sizeof(unsigned short));
|
||||
// osg::notify(osg::WARN) << "geoField " << (int)tokid << " type " << (int)type << " nit " << (int)nits << std::endl;
|
||||
if (type == GEO_DB_EXTENDED_FIELD) { // change for true extended type
|
||||
fin.read((char *)&tokenId,sizeof(tokenId));fin.read((char *)&TypeId,sizeof(TypeId));
|
||||
fin.read((char *)&numItems,sizeof(unsigned int));
|
||||
} else {
|
||||
tokenId=tokid; TypeId=type;
|
||||
numItems=nits;
|
||||
}
|
||||
if (id== 0 && tokenId == GEO_DB_USER_EXT_VALUE_FIELD && numItems==1) { // Feb 2003 parse extension template records
|
||||
if (TypeId == DB_SHORT ||
|
||||
TypeId == DB_USHORT) {
|
||||
short upad;
|
||||
fin.read((char *)&upad,SIZEOF_SHORT); // skip the padding on extension template
|
||||
upad=1;
|
||||
} else if (TypeId == DB_CHAR ||
|
||||
TypeId == DB_UCHAR) {
|
||||
char cpad[4];
|
||||
fin.read(cpad,SIZEOF_CHAR); // skip the padding
|
||||
} else {
|
||||
}
|
||||
}
|
||||
if (id== DB_DSK_HEADER && tokenId == GEO_DB_HDR_EXT_TEMPLATE) { // Feb 2003 parse extension records
|
||||
// osg::notify(osg::WARN) << "header extension template " << (int)getType() << std::endl;
|
||||
parseExt(fin); // multiple structs occur here
|
||||
} else {
|
||||
if (numItems>0) {
|
||||
storageRead(fin); // allocate & fill the storage
|
||||
if (tokenId == GEO_DB_USER_EXT_VALUE_FIELD) {
|
||||
if (id==DB_DSK_POLYGON || id==DB_DSK_GEODE || id==DB_DSK_GROUP
|
||||
|| id==DB_DSK_LOD || id==DB_DSK_MESH || id==DB_DSK_CUBE
|
||||
|| id==DB_DSK_SPHERE || id==DB_DSK_CONE || id==DB_DSK_CYLINDER
|
||||
|| id==DB_DSK_TEXTURE || id==DB_DSK_MATERIAL || id==DB_DSK_VIEW) {
|
||||
if (TypeId == DB_SHORT ||TypeId == DB_USHORT) fin.ignore(2); // skip padding
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// now register with Registry to instantiate the above
|
||||
// reader/writer.
|
||||
osgDB::RegisterReaderWriterProxy<ReaderWriterGEO> gReaderWriter_GEO_Proxy;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <osg/Timer>
|
||||
|
||||
|
||||
void geoArithBehaviour::setType(uint iop) {
|
||||
void geoArithBehaviour::setType(unsigned int iop) {
|
||||
switch (iop) {
|
||||
case 1: op=addv; break; /* op=addv; addv is a function so the operation can be accessed without a switch(type)... */
|
||||
case 2: op=subv; break;
|
||||
@@ -64,7 +64,7 @@ bool geoArithBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeade
|
||||
out=theHeader->getVar(fid); // returns address of output var with fid
|
||||
//std::cout<< " Output " << fid << " : " << theHeader->getVarname(fid) << std::endl;
|
||||
gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OP_TYPE);
|
||||
uint iop=gfd?gfd->getUInt():1;
|
||||
unsigned int iop=gfd?gfd->getUInt():1;
|
||||
setType(iop); // default add?
|
||||
gfd=grec->getField(GEO_DB_ARITHMETIC_ACTION_OPERAND_VALUE);
|
||||
if (gfd) {
|
||||
@@ -82,7 +82,7 @@ bool geoArithBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeade
|
||||
return ok;
|
||||
}
|
||||
|
||||
void geoAr3Behaviour::setType(uint iact) {
|
||||
void geoAr3Behaviour::setType(unsigned int iact) {
|
||||
switch (iact) {
|
||||
case DB_DSK_LINEAR_ACTION: op=linear; break; /* op=addv; */
|
||||
case DB_DSK_INVERSE_ACTION: op=lininv; break;
|
||||
@@ -122,7 +122,7 @@ void geoAr3Behaviour::doaction(osg::Node *) { // do math operation
|
||||
bool geoAr3Behaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const geoField *gfd=grec->getField(GEO_DB_EQUATION_ACTION_INPUT_VAR);
|
||||
const uint act=grec->getType();
|
||||
const unsigned int act=grec->getType();
|
||||
if (gfd) {
|
||||
unsigned fid= gfd->getUInt(); // field identifier
|
||||
in=theHeader->getVar(fid); // returns address of input var with fid
|
||||
@@ -172,7 +172,7 @@ bool geoAr3Behaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader)
|
||||
return ok;
|
||||
}
|
||||
|
||||
void geoCompareBehaviour::setType(uint iop) {
|
||||
void geoCompareBehaviour::setType(unsigned int iop) {
|
||||
switch (iop) {
|
||||
case 1: oper=LESS;break;
|
||||
case 2: oper=LESSOREQ; break;
|
||||
@@ -207,7 +207,7 @@ bool geoCompareBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHea
|
||||
fid= gfd->getUInt(); // field identifier
|
||||
out=theHeader->getVar(fid); // returns address of output var with fid
|
||||
gfd=grec->getField(GEO_DB_COMPARE_ACTION_OP_TYPE);
|
||||
uint iop=gfd?gfd->getUInt():1;
|
||||
unsigned int iop=gfd?gfd->getUInt():1;
|
||||
setType(iop); // default add?
|
||||
gfd=grec->getField(GEO_DB_COMPARE_ACTION_OPERAND_VALUE);
|
||||
if (gfd) {
|
||||
@@ -313,8 +313,8 @@ bool geoDiscreteBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHe
|
||||
fid= gfd->getUInt(); // field identifier
|
||||
out=theHeader->getVar(fid); // returns address of output var with fid
|
||||
gfd=grec->getField(GEO_DB_DISCRETE_ACTION_NUM_ITEMS);
|
||||
uint nr=gfd?gfd->getUInt():1;
|
||||
uint i;
|
||||
unsigned int nr=gfd?gfd->getUInt():1;
|
||||
unsigned int i;
|
||||
for (i=0; i<nr; i++) {
|
||||
geoRange gr;
|
||||
rangelist.push_back(gr);
|
||||
@@ -364,7 +364,7 @@ void geoMoveBehaviour::doaction(osg::Node *node) {
|
||||
|
||||
bool geoMoveBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const uint act=grec->getType();
|
||||
const unsigned int act=grec->getType();
|
||||
setType(act);
|
||||
if (act==DB_DSK_ROTATE_ACTION) {
|
||||
const geoField *gfd=grec->getField(GEO_DB_ROTATE_ACTION_INPUT_VAR);
|
||||
@@ -433,7 +433,7 @@ void geoMoveVertexBehaviour::doaction(osg::Matrix *mtr) {
|
||||
|
||||
bool geoMoveVertexBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader)
|
||||
{
|
||||
const uint act=grec->getType();
|
||||
const unsigned int act=grec->getType();
|
||||
bool ok=false;
|
||||
setType(act);
|
||||
if (act==DB_DSK_ROTATE_ACTION) {
|
||||
@@ -524,14 +524,14 @@ void geoColourBehaviour::doaction(osg::Drawable *dr)
|
||||
{ // do visibility operation on Node
|
||||
if (getVar()) {
|
||||
double val=getValue();
|
||||
uint idx=(uint)val;
|
||||
unsigned int idx=(unsigned int)val;
|
||||
osg::Geometry *gm=dynamic_cast<osg::Geometry *>(dr);
|
||||
if (gm) {
|
||||
osg::Vec4Array* cla = dynamic_cast<osg::Vec4Array*>(gm->getColorArray());
|
||||
if (cla) { // traps a colour behaviour added when using material for colour.
|
||||
for (uint i=nstart; i<(nend); i++) {
|
||||
for (unsigned int i=nstart; i<(nend); i++) {
|
||||
unsigned char col[4];
|
||||
uint idxtop=idx/128;
|
||||
unsigned int idxtop=idx/128;
|
||||
(*colours)[idxtop].get(col); // from the colour palette
|
||||
float frac=(float)(idx-idxtop*128)/128.0f;
|
||||
(*cla)[i].set(col[0]*frac/255.0,col[1]*frac/255.0,col[2]*frac/255.0,1);
|
||||
@@ -564,7 +564,7 @@ void geoStrContentBehaviour::doaction(osg::Drawable *node) { // do new text
|
||||
txt->setText(std::string(content));
|
||||
#endif
|
||||
}
|
||||
bool geoStrContentBehaviour::makeBehave(const georecord *grec, geoHeaderGeo *theHeader) {
|
||||
bool geoStrContentBehaviour::makeBehave(const georecord *grec, const geoHeaderGeo *theHeader) {
|
||||
bool ok=false;
|
||||
const geoField *gfd=grec->getField(GEO_DB_STRING_CONTENT_ACTION_INPUT_VAR);
|
||||
if (gfd) {
|
||||
|
||||
@@ -238,7 +238,7 @@ public:
|
||||
geoVisibBehaviour() { }
|
||||
virtual ~geoVisibBehaviour() { }
|
||||
|
||||
bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader);
|
||||
virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader);
|
||||
virtual void doaction(osg::Node *node);
|
||||
private:
|
||||
};
|
||||
@@ -267,7 +267,7 @@ public:
|
||||
PAD_FOR_SIGN=0; vt=UNKNOWN; }
|
||||
virtual ~geoStrContentBehaviour() { delete [] format;}
|
||||
virtual void doaction(osg::Drawable *node); // do new text
|
||||
virtual bool makeBehave(const georecord *grec, geoHeaderGeo *theHeader);
|
||||
virtual bool makeBehave(const georecord *grec, const geoHeaderGeo *theHeader);
|
||||
enum valuetype {UNKNOWN, INT, FLOAT, DOUBLE, CHAR};
|
||||
private:
|
||||
char *format;
|
||||
|
||||
@@ -14,15 +14,18 @@ AUTHOR: Geoff Michel
|
||||
|
||||
|
||||
#ifndef _GEO_STRUCTS_H_
|
||||
#define _GEO_STRUCTS_H_
|
||||
#define _GEO_STRUCTS_H_ 1
|
||||
|
||||
typedef std::vector< geoExtensionDefRec > geoExtensionDefList;
|
||||
|
||||
class geoField { // holds one field of data as read from the disk of a GEO file
|
||||
public:
|
||||
geoField() {
|
||||
tokenId=TypeId=0; numItems=0;storeSize=0;
|
||||
tokenId=TypeId=0; numItems=0;storeSize=0; storage=NULL;
|
||||
}
|
||||
void init() {
|
||||
tokenId=TypeId=0; numItems=0;storeSize=0; storage=NULL;
|
||||
}
|
||||
|
||||
unsigned char *readStorage(std::ifstream &fin, const unsigned sz) {
|
||||
unsigned char *st=new unsigned char[numItems*sz];
|
||||
storeSize=sz;
|
||||
@@ -129,22 +132,8 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void readfile(std::ifstream &fin) {
|
||||
unsigned char tokid, type;
|
||||
unsigned short nits;
|
||||
if (!fin.eof()) {
|
||||
fin.read((char *)&tokid,1);fin.read((char *)&type,1);
|
||||
fin.read((char *)&nits,sizeof(unsigned short));
|
||||
if (TypeId == GEO_DB_EXTENDED_FIELD) {
|
||||
fin.read((char *)&tokenId,sizeof(tokenId));fin.read((char *)&TypeId,sizeof(TypeId));
|
||||
fin.read((char *)&numItems,sizeof(unsigned int));
|
||||
} else {
|
||||
tokenId=tokid; TypeId=type;
|
||||
numItems=nits;
|
||||
}
|
||||
storageRead(fin); // allocate & fill the storage
|
||||
}
|
||||
}
|
||||
void readfile(std::ifstream &fin, const uint id); // is part of a record id
|
||||
void parseExt(std::ifstream &fin) const; // Feb 2003 parse node extension fields
|
||||
void writefile(std::ofstream &fout) { // write binary file
|
||||
if (numItems<32767 && tokenId<256) {
|
||||
unsigned char tokid=tokenId, type=TypeId;
|
||||
@@ -216,6 +205,9 @@ public:
|
||||
<< " num its " << gf.numItems << " size " << gf.storeSize << std::endl;
|
||||
if (gf.TypeId==DB_CHAR) output.indent();
|
||||
for (uint i=0; i<gf.numItems; i++) {
|
||||
if (gf.storage==NULL) {
|
||||
output.indent() << "No storage" << std::endl;
|
||||
} else {
|
||||
int j,k;
|
||||
union {
|
||||
unsigned char *uch;
|
||||
@@ -229,129 +221,130 @@ public:
|
||||
unsigned long *uln;
|
||||
double *dbl;
|
||||
} st;
|
||||
st.uch=gf.storage+i*gf.storeSize;
|
||||
switch (gf.TypeId) {
|
||||
case DB_CHAR:
|
||||
if (st.ch[0]) output << st.ch[0];
|
||||
break;
|
||||
case DB_SHORT:
|
||||
output.indent() << st.sh[0] << std::endl;
|
||||
break;
|
||||
case DB_INT:
|
||||
output.indent() << gf.getInt() << std::endl;
|
||||
break;
|
||||
case DB_FLOAT:
|
||||
output.indent() << gf.getFloat() << std::endl;
|
||||
break;
|
||||
case DB_LONG:
|
||||
output.indent() << st.ln[0] << std::endl;
|
||||
break;
|
||||
case DB_ULONG:
|
||||
output.indent() << st.uln[0] << std::endl;
|
||||
break;
|
||||
case DB_DOUBLE:
|
||||
output.indent() << st.dbl[0] << std::endl;
|
||||
break;
|
||||
case DB_VEC2F:
|
||||
output.indent() << st.ft[0] << " " << st.ft[1];
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC3F:
|
||||
output.indent();
|
||||
for (j=0; j<3; j++) output << st.ft[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4F:
|
||||
output.indent();
|
||||
for (j=0; j<4; j++) output << st.ft[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC16F:
|
||||
for (j=0; j<4; j++) {
|
||||
output.indent();
|
||||
for (k=0; k<4; k++) output << st.ft[j*4+k] << " ";
|
||||
st.uch=gf.storage+i*gf.storeSize;
|
||||
switch (gf.TypeId) {
|
||||
case DB_CHAR:
|
||||
if (st.ch[0]) output << st.ch[0];
|
||||
break;
|
||||
case DB_SHORT:
|
||||
output.indent() << st.sh[0] << std::endl;
|
||||
break;
|
||||
case DB_INT:
|
||||
output.indent() << gf.getInt() << std::endl;
|
||||
break;
|
||||
case DB_FLOAT:
|
||||
output.indent() << gf.getFloat() << std::endl;
|
||||
break;
|
||||
case DB_LONG:
|
||||
output.indent() << st.ln[0] << std::endl;
|
||||
break;
|
||||
case DB_ULONG:
|
||||
output.indent() << st.uln[0] << std::endl;
|
||||
break;
|
||||
case DB_DOUBLE:
|
||||
output.indent() << st.dbl[0] << std::endl;
|
||||
break;
|
||||
case DB_VEC2F:
|
||||
output.indent() << st.ft[0] << " " << st.ft[1];
|
||||
output << std::endl;
|
||||
}
|
||||
break;
|
||||
case DB_VEC2I:
|
||||
output.indent() << st.in[0] << " " << st.in[1] << std::endl;
|
||||
break;
|
||||
case DB_VEC3I:
|
||||
output.indent();
|
||||
for ( j=0; j<3; j++) output << " " << st.in[j];
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4I:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << st.in[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC2D:
|
||||
output.indent();
|
||||
for ( j=0; j<2; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC3D:
|
||||
output.indent();
|
||||
for ( j=0; j<3; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4D:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC16D:
|
||||
for (j=0; j<4; j++) {
|
||||
break;
|
||||
case DB_VEC3F:
|
||||
output.indent();
|
||||
for (k=0; k<4; k++) output << st.dbl[j*4+k] << " ";
|
||||
for (j=0; j<3; j++) output << st.ft[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4F:
|
||||
output.indent();
|
||||
for (j=0; j<4; j++) output << st.ft[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC16F:
|
||||
for (j=0; j<4; j++) {
|
||||
output.indent();
|
||||
for (k=0; k<4; k++) output << st.ft[j*4+k] << " ";
|
||||
output << std::endl;
|
||||
}
|
||||
break;
|
||||
case DB_VEC2I:
|
||||
output.indent() << st.in[0] << " " << st.in[1] << std::endl;
|
||||
break;
|
||||
case DB_VEC3I:
|
||||
output.indent();
|
||||
for ( j=0; j<3; j++) output << " " << st.in[j];
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4I:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << st.in[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC2D:
|
||||
output.indent();
|
||||
for ( j=0; j<2; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC3D:
|
||||
output.indent();
|
||||
for ( j=0; j<3; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC4D:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << st.dbl[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_VEC16D:
|
||||
for (j=0; j<4; j++) {
|
||||
output.indent();
|
||||
for (k=0; k<4; k++) output << st.dbl[j*4+k] << " ";
|
||||
output << std::endl;
|
||||
}
|
||||
break;
|
||||
case DB_VRTX_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_UINT:
|
||||
output.indent() << st.uin[0] << std::endl;
|
||||
break;
|
||||
case DB_USHORT:
|
||||
output.indent() << st.ush[0] << std::endl;
|
||||
break;
|
||||
case DB_UCHAR:
|
||||
output.indent() << (int)st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_EXT_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_SHORT_WITH_PADDING:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_CHAR_WITH_PADDING:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_USHORT_WITH_PADDING:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_UCHAR_WITH_PADDING:
|
||||
output.indent() << (int)st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_BOOL_WITH_PADDING:
|
||||
output.indent() << (gf.getBool()?"True":"False") << std::endl;
|
||||
break;
|
||||
case DB_EXTENDED_FIELD_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_VEC4UC:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << (int)st.uch[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_DISCRETE_MAPPING_STRUCT:
|
||||
output.indent() << st.ch[i] << std::endl;
|
||||
break;
|
||||
case DB_BITFLAGS:
|
||||
output.indent() << st.ch[i] << std::endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DB_VRTX_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_UINT:
|
||||
output.indent() << st.uin[0] << std::endl;
|
||||
break;
|
||||
case DB_USHORT:
|
||||
output.indent() << st.ush[0] << std::endl;
|
||||
break;
|
||||
case DB_UCHAR:
|
||||
output.indent() << (int)st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_EXT_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_SHORT_WITH_PADDING:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_CHAR_WITH_PADDING:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_USHORT_WITH_PADDING:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_UCHAR_WITH_PADDING:
|
||||
output.indent() << (int)st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_BOOL_WITH_PADDING:
|
||||
output.indent() << (gf.getBool()?"True":"False") << std::endl;
|
||||
break;
|
||||
case DB_EXTENDED_FIELD_STRUCT:
|
||||
output.indent() << st.ch[0] << std::endl;
|
||||
break;
|
||||
case DB_VEC4UC:
|
||||
output.indent();
|
||||
for ( j=0; j<4; j++) output << (int)st.uch[j] << " ";
|
||||
output << std::endl;
|
||||
break;
|
||||
case DB_DISCRETE_MAPPING_STRUCT:
|
||||
output.indent() << st.ch[i] << std::endl;
|
||||
break;
|
||||
case DB_BITFLAGS:
|
||||
output.indent() << st.ch[i] << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -456,7 +449,8 @@ public:
|
||||
} else { // get the fields
|
||||
geoField gf;
|
||||
do {
|
||||
gf.readfile(fin);
|
||||
gf.init();
|
||||
gf.readfile(fin, id);
|
||||
// if (id == DB_DSK_NORMAL_POOL && gf.getToken()==GEO_DB_NORMAL_POOL_VALUES) {
|
||||
// uncompress the normals
|
||||
// gf.uncompress();
|
||||
|
||||
@@ -60,6 +60,18 @@ bool Billboard_readLocalData(Object& obj, Input& fr)
|
||||
}
|
||||
}
|
||||
|
||||
if (fr[0].matchWord("Normal"))
|
||||
{
|
||||
float x,y,z;
|
||||
if (fr[1].getFloat(x) && fr[2].getFloat(y) && fr[3].getFloat(z))
|
||||
{
|
||||
billboard.setNormal(Vec3(x,y,z));
|
||||
fr+=4;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// read the position data.
|
||||
bool matchFirst = false;
|
||||
if ((matchFirst=fr.matchSequence("Positions {")) || fr.matchSequence("Positions %i {"))
|
||||
@@ -119,9 +131,13 @@ bool Billboard_writeLocalData(const Object& obj, Output& fw)
|
||||
const Vec3& axis = billboard.getAxis();
|
||||
fw.indent() << "Axis " << axis[0] << " "<<axis[1]<<" "<<axis[2]<<std::endl;
|
||||
|
||||
const Vec3& normal = billboard.getNormal();
|
||||
fw.indent() << "Normal " << normal[0] << " "<<normal[1]<<" "<<normal[2]<<std::endl;
|
||||
|
||||
fw.indent() << "Positions {"<<std::endl;
|
||||
fw.moveIn();
|
||||
|
||||
|
||||
|
||||
Billboard::PositionList positionList = billboard.getPositionList();
|
||||
for(Billboard::PositionList::iterator piter = positionList.begin();
|
||||
piter != positionList.end();
|
||||
|
||||
@@ -522,7 +522,7 @@ pfGeoState* ConvertToPerformer::visitStateSet(osg::StateSet* stateset)
|
||||
img->getPixelFormat() == GL_RGB ? 3 :
|
||||
img->getPixelFormat() == GL_RGBA ? 4 : 3;
|
||||
|
||||
uint *uim = (uint *)pfMalloc( ns * nt * ncomp, pfGetSharedArena() );
|
||||
unsigned int *uim = (unsigned int *)pfMalloc( ns * nt * ncomp, pfGetSharedArena() );
|
||||
|
||||
memcpy( uim, img->data(), ns * nt * ncomp );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user