Property API clean to smooth the task of generating wrappers.

This commit is contained in:
Robert Osfield
2004-12-17 01:06:33 +00:00
parent 4383655fcd
commit a0ba625cb0
39 changed files with 253 additions and 229 deletions

View File

@@ -106,7 +106,7 @@ void AnimationPath::write(std::ostream& fout) const
++tcpmitr)
{
const ControlPoint& cp = tcpmitr->second;
fout<<tcpmitr->first<<" "<<cp._position<<" "<<cp._rotation<<std::endl;
fout<<tcpmitr->first<<" "<<cp.getPosition()<<" "<<cp.getRotation()<<std::endl;
}
fout.precision(prec);
@@ -139,16 +139,16 @@ class AnimationPathCallbackVisitor : public NodeVisitor
Matrix matrix;
_cp.getInverse(matrix);
pat.setPosition(matrix.getTrans());
pat.setAttitude(_cp._rotation.inverse());
pat.setScale(osg::Vec3(1.0f/_cp._scale.x(),1.0f/_cp._scale.y(),1.0f/_cp._scale.z()));
pat.setAttitude(_cp.getRotation().inverse());
pat.setScale(osg::Vec3(1.0f/_cp.getScale().x(),1.0f/_cp.getScale().y(),1.0f/_cp.getScale().z()));
pat.setPivotPoint(_pivotPoint);
}
else
{
pat.setPosition(_cp._position);
pat.setAttitude(_cp._rotation);
pat.setScale(_cp._scale);
pat.setPosition(_cp.getPosition());
pat.setAttitude(_cp.getRotation());
pat.setScale(_cp.getScale());
pat.setPivotPoint(_pivotPoint);
}
}

View File

@@ -17,10 +17,7 @@ using namespace osg;
ClipPlane::ClipPlane()
{
_clipPlane[0] = 0.0;
_clipPlane[1] = 0.0;
_clipPlane[2] = 0.0;
_clipPlane[3] = 0.0;
_clipPlane.set(0.0,0.0,0.0,0.0);
_clipPlaneNum = 0;
}
@@ -29,61 +26,6 @@ ClipPlane::~ClipPlane()
{
}
void ClipPlane::setClipPlane(const Vec4& plane)
{
_clipPlane[0] = plane[0];
_clipPlane[1] = plane[1];
_clipPlane[2] = plane[2];
_clipPlane[3] = plane[3];
}
void ClipPlane::setClipPlane(const Plane& plane)
{
_clipPlane[0] = plane[0];
_clipPlane[1] = plane[1];
_clipPlane[2] = plane[2];
_clipPlane[3] = plane[3];
}
void ClipPlane::setClipPlane(const double* plane)
{
if (plane)
{
_clipPlane[0] = plane[0];
_clipPlane[1] = plane[1];
_clipPlane[2] = plane[2];
_clipPlane[3] = plane[3];
}
else
{
notify(WARN)<<"Warning: ClipPlane::setClipPlane() passed NULL plane array, ignoring operation."<<std::endl;
}
}
void ClipPlane::getClipPlane(Vec4& plane) const
{
plane[0] = (float)_clipPlane[0];
plane[1] = (float)_clipPlane[1];
plane[2] = (float)_clipPlane[2];
plane[3] = (float)_clipPlane[3];
}
void ClipPlane::getClipPlane(Plane& plane) const
{
plane[0] = _clipPlane[0];
plane[1] = _clipPlane[1];
plane[2] = _clipPlane[2];
plane[3] = _clipPlane[3];
}
void ClipPlane::getClipPlane(double* plane) const
{
plane[0] = _clipPlane[0];
plane[1] = _clipPlane[1];
plane[2] = _clipPlane[2];
plane[3] = _clipPlane[3];
}
void ClipPlane::setClipPlaneNum(unsigned int num)
{
_clipPlaneNum = num;
@@ -96,6 +38,6 @@ unsigned int ClipPlane::getClipPlaneNum() const
void ClipPlane::apply(State&) const
{
glClipPlane((GLenum)(GL_CLIP_PLANE0+_clipPlaneNum),_clipPlane);
glClipPlane((GLenum)(GL_CLIP_PLANE0+_clipPlaneNum),_clipPlane.ptr());
}

View File

@@ -18,7 +18,6 @@ using namespace osg;
PolygonMode::PolygonMode()
{
_frontAndBack = true;
_modeFront = FILL;
_modeBack = FILL;
}
@@ -33,15 +32,12 @@ void PolygonMode::setMode(Face face,Mode mode)
switch(face)
{
case(FRONT):
_frontAndBack = false;
_modeFront = mode;
break;
case(BACK):
_frontAndBack = false;
_modeBack = mode;
break;
case(FRONT_AND_BACK):
_frontAndBack = true;
_modeFront = mode;
_modeBack = mode;
break;
@@ -65,7 +61,7 @@ PolygonMode::Mode PolygonMode::getMode(Face face) const
void PolygonMode::apply(State&) const
{
if (_frontAndBack)
if (_modeFront==_modeBack)
{
glPolygonMode(GL_FRONT_AND_BACK,(GLenum)_modeFront);
}

View File

@@ -457,7 +457,7 @@ void DrawShapeVisitor::apply(const Box& box)
if (!box.zeroRotation())
{
Matrix rotation(box.getRotationMatrix());
Matrix rotation(box.computeRotationMatrix());
glMultMatrix(rotation.ptr());
}
@@ -573,7 +573,7 @@ void DrawShapeVisitor::apply(const Cone& cone)
if (!cone.zeroRotation())
{
Matrix rotation(cone.getRotationMatrix());
Matrix rotation(cone.computeRotationMatrix());
glMultMatrix(rotation.ptr());
}
@@ -691,7 +691,7 @@ void DrawShapeVisitor::apply(const Cylinder& cylinder)
if (!cylinder.zeroRotation())
{
Matrix rotation(cylinder.getRotationMatrix());
Matrix rotation(cylinder.computeRotationMatrix());
glMultMatrix(rotation.ptr());
}
@@ -790,7 +790,7 @@ void DrawShapeVisitor::apply(const Capsule& capsule)
if (!capsule.zeroRotation())
{
Matrix rotation(capsule.getRotationMatrix());
Matrix rotation(capsule.computeRotationMatrix());
glMultMatrix(rotation.ptr());
}
@@ -876,7 +876,7 @@ void DrawShapeVisitor::apply(const HeightField& field)
if (!field.zeroRotation())
{
Matrix rotation(field.getRotationMatrix());
Matrix rotation(field.computeRotationMatrix());
glMultMatrix(rotation.ptr());
}
@@ -1087,7 +1087,7 @@ void ComputeBoundShapeVisitor::apply(const Box& box)
Vec3 top_3(Vec3(x,y,z));
Vec3 top_4(Vec3(-x,y,z));
Matrix matrix = box.getRotationMatrix();
Matrix matrix = box.computeRotationMatrix();
_bb.expandBy(box.getCenter()+base_1*matrix);
_bb.expandBy(box.getCenter()+base_2*matrix);
_bb.expandBy(box.getCenter()+base_3*matrix);
@@ -1116,7 +1116,7 @@ void ComputeBoundShapeVisitor::apply(const Cone& cone)
Vec3 base_3(Vec3(cone.getRadius(),cone.getRadius(),cone.getBaseOffset()));
Vec3 base_4(Vec3(-cone.getRadius(),cone.getRadius(),cone.getBaseOffset()));
Matrix matrix = cone.getRotationMatrix();
Matrix matrix = cone.computeRotationMatrix();
_bb.expandBy(cone.getCenter()+base_1*matrix);
_bb.expandBy(cone.getCenter()+base_2*matrix);
_bb.expandBy(cone.getCenter()+base_3*matrix);
@@ -1149,7 +1149,7 @@ void ComputeBoundShapeVisitor::apply(const Cylinder& cylinder)
Vec3 top_3(Vec3(r,r,z));
Vec3 top_4(Vec3(-r,r,z));
Matrix matrix = cylinder.getRotationMatrix();
Matrix matrix = cylinder.computeRotationMatrix();
_bb.expandBy(cylinder.getCenter()+base_1*matrix);
_bb.expandBy(cylinder.getCenter()+base_2*matrix);
_bb.expandBy(cylinder.getCenter()+base_3*matrix);
@@ -1186,7 +1186,7 @@ void ComputeBoundShapeVisitor::apply(const Capsule& capsule)
Vec3 top_3(Vec3(r,r,z));
Vec3 top_4(Vec3(-r,r,z));
Matrix matrix = capsule.getRotationMatrix();
Matrix matrix = capsule.computeRotationMatrix();
_bb.expandBy(capsule.getCenter()+base_1*matrix);
_bb.expandBy(capsule.getCenter()+base_2*matrix);
_bb.expandBy(capsule.getCenter()+base_3*matrix);
@@ -1269,7 +1269,7 @@ void ComputeBoundShapeVisitor::apply(const HeightField& field)
Vec3 top_3(Vec3(x,y,zMax));
Vec3 top_4(Vec3(0,y,zMax));
Matrix matrix = field.getRotationMatrix();
Matrix matrix = field.computeRotationMatrix();
_bb.expandBy(field.getOrigin()+base_1*matrix);
_bb.expandBy(field.getOrigin()+base_2*matrix);
_bb.expandBy(field.getOrigin()+base_3*matrix);
@@ -1424,7 +1424,7 @@ void PrimitiveShapeVisitor::apply(const Box& box)
}
else
{
Matrix matrix = box.getRotationMatrix();
Matrix matrix = box.computeRotationMatrix();
matrix.setTrans(box.getCenter());
base_1 = base_1*matrix;
@@ -1476,7 +1476,7 @@ void PrimitiveShapeVisitor::apply(const Box& box)
void PrimitiveShapeVisitor::apply(const Cone& cone)
{
Matrix matrix = cone.getRotationMatrix();
Matrix matrix = cone.computeRotationMatrix();
matrix.setTrans(cone.getCenter());
@@ -1567,7 +1567,7 @@ void PrimitiveShapeVisitor::apply(const Cone& cone)
void PrimitiveShapeVisitor::apply(const Cylinder& cylinder)
{
Matrix matrix = cylinder.getRotationMatrix();
Matrix matrix = cylinder.computeRotationMatrix();
matrix.setTrans(cylinder.getCenter());
unsigned int numSegments = 40;
@@ -1697,7 +1697,7 @@ void PrimitiveShapeVisitor::apply(const HeightField& field)
{
if (field.getNumColumns()==0 || field.getNumRows()==0) return;
Matrix matrix = field.getRotationMatrix();
Matrix matrix = field.computeRotationMatrix();
matrix.setTrans(field.getOrigin());
float dx = field.getXInterval();

View File

@@ -410,7 +410,7 @@ osg::Image* ReadDDSFile(std::istream& _istream)
osgImage->setImage(s,t,r, internalFormat, pixelFormat, dataType, 0, osg::Image::USE_NEW_DELETE);
if (mipmaps.size()>0) osgImage->setMipmapData(mipmaps);
if (mipmaps.size()>0) osgImage->setMipmapLevels(mipmaps);
unsigned int size = osgImage->getTotalSizeInBytesIncludingMipmaps();
if(size <= 0)
@@ -428,7 +428,7 @@ osg::Image* ReadDDSFile(std::istream& _istream)
_istream.read((char*)imageData, size);
osgImage->setImage(s,t,r, internalFormat, pixelFormat, dataType, imageData, osg::Image::USE_NEW_DELETE);
if (mipmaps.size()>0) osgImage->setMipmapData(mipmaps);
if (mipmaps.size()>0) osgImage->setMipmapLevels(mipmaps);
@@ -463,10 +463,10 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout)
// Initialize ddsd structure and its members
DDSURFACEDESC2 ddsd;
DDPIXELFORMAT ddpf;
DDCOLORKEY ddckCKDestOverlay;
DDCOLORKEY ddckCKDestBlt;
DDCOLORKEY ddckCKSrcOverlay;
DDCOLORKEY ddckCKSrcBlt;
//DDCOLORKEY ddckCKDestOverlay;
//DDCOLORKEY ddckCKDestBlt;
//DDCOLORKEY ddckCKSrcOverlay;
//DDCOLORKEY ddckCKSrcBlt;
DDSCAPS2 ddsCaps;
ddsd.dwSize = sizeof(ddsd);
@@ -647,7 +647,7 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout)
if(img->isMipmap())
{
dataPtr += imageSize;
unsigned char *mmdPtr, *next_mmdPtr;
const unsigned char *mmdPtr, *next_mmdPtr;
int offset;
unsigned int mipmaps = img->getNumMipmapLevels();
unsigned int blockSize;

View File

@@ -37,9 +37,9 @@ void AnimationPath::write(DataOutputStream* out){
out->writeInt(tcpm.size());
for(AnimationPath::TimeControlPointMap::iterator itr=tcpm.begin(); itr!=tcpm.end(); ++itr){
out->writeFloat(itr->first);
out->writeVec3(itr->second._position);
out->writeQuat(itr->second._rotation);
out->writeVec3(itr->second._scale);
out->writeVec3(itr->second.getPosition());
out->writeQuat(itr->second.getRotation());
out->writeVec3(itr->second.getScale());
}
}

View File

@@ -31,16 +31,7 @@ void ClipPlane::write(DataOutputStream* out){
// write ClipPlane's properties
double plane[4];
getClipPlane(plane);
out->writeDouble(plane[0]);
out->writeDouble(plane[1]);
out->writeDouble(plane[2]);
out->writeDouble(plane[3]);
out->writeVec4d(getClipPlane());
out->writeUInt(getClipPlaneNum());
@@ -62,15 +53,7 @@ void ClipPlane::read(DataInputStream* in){
else
throw Exception("ClipPlane::read(): Could not cast this osg::ClipPlane to an osg::Object.");
// Read ClipPlane's properties
double plane[4];
plane[0] = in->readDouble();
plane[1] = in->readDouble();
plane[2] = in->readDouble();
plane[3] = in->readDouble();
setClipPlane(plane);
setClipPlane(in->readVec4d());
setClipPlaneNum(in->readUInt());
}

View File

@@ -313,6 +313,39 @@ osg::Vec4 DataInputStream::readVec4(){
return v;
}
osg::Vec2d DataInputStream::readVec2d()
{
osg::Vec2d v;
v.x()=readDouble();
v.y()=readDouble();
if (_verboseOutput) std::cout<<"read/writeVec2d() ["<<v<<"]"<<std::endl;
return v;
}
osg::Vec3d DataInputStream::readVec3d(){
osg::Vec3d v;
v.x()=readDouble();
v.y()=readDouble();
v.z()=readDouble();
if (_verboseOutput) std::cout<<"read/writeVec3d() ["<<v<<"]"<<std::endl;
return v;
}
osg::Vec4d DataInputStream::readVec4d(){
osg::Vec4d v;
v.x()=readDouble();
v.y()=readDouble();
v.z()=readDouble();
v.w()=readDouble();
if (_verboseOutput) std::cout<<"read/writeVec4d() ["<<v<<"]"<<std::endl;
return v;
}
osg::Plane DataInputStream::readPlane(){
osg::Plane v;

View File

@@ -9,6 +9,9 @@
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
#include <osg/Vec2d>
#include <osg/Vec3d>
#include <osg/Vec4d>
#include <osg/Quat>
#include <osg/Array>
#include <osg/Matrix>
@@ -54,6 +57,9 @@ public:
osg::Vec2 readVec2();
osg::Vec3 readVec3();
osg::Vec4 readVec4();
osg::Vec2d readVec2d();
osg::Vec3d readVec3d();
osg::Vec4d readVec4d();
osg::Plane readPlane();
osg::UByte4 readUByte4();
osg::Quat readQuat();

View File

@@ -182,6 +182,30 @@ void DataOutputStream::writeVec4(const osg::Vec4& v){
if (_verboseOutput) std::cout<<"read/writeVec4() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeVec2d(const osg::Vec2d& v){
writeDouble(v.x());
writeDouble(v.y());
if (_verboseOutput) std::cout<<"read/writeVec2() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeVec3d(const osg::Vec3d& v){
writeDouble(v.x());
writeDouble(v.y());
writeDouble(v.z());
if (_verboseOutput) std::cout<<"read/writeVec3d() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writeVec4d(const osg::Vec4d& v){
writeDouble(v.x());
writeDouble(v.y());
writeDouble(v.z());
writeDouble(v.w());
if (_verboseOutput) std::cout<<"read/writeVec4d() ["<<v<<"]"<<std::endl;
}
void DataOutputStream::writePlane(const osg::Plane& v)
{
writeFloat(v[0]);

View File

@@ -46,6 +46,9 @@ public:
void writeVec2(const osg::Vec2& v);
void writeVec3(const osg::Vec3& v);
void writeVec4(const osg::Vec4& v);
void writeVec2d(const osg::Vec2d& v);
void writeVec3d(const osg::Vec3d& v);
void writeVec4d(const osg::Vec4d& v);
void writePlane(const osg::Plane& v);
void writeUByte4(const osg::UByte4& v);
void writeQuat(const osg::Quat& q);

View File

@@ -86,11 +86,7 @@ bool AnimationPath_readLocalData(osg::Object &obj, osgDB::Input &fr)
{
osg::AnimationPath::ControlPoint ctrlPoint;
ctrlPoint._position = position;
ctrlPoint._rotation = rotation;
ctrlPoint._scale = scale;
osg::AnimationPath::ControlPoint ctrlPoint(position,rotation,scale);
ap->insert(time, ctrlPoint);
fr+=11;
@@ -138,7 +134,7 @@ bool AnimationPath_writeLocalData(const osg::Object &obj, osgDB::Output &fw)
itr!=tcpm.end();
++itr)
{
fw.indent() << itr->first << " " << itr->second._position << " " << itr->second._rotation << " " << itr->second._scale << std::endl;
fw.indent() << itr->first << " " << itr->second.getPosition() << " " << itr->second.getRotation() << " " <<itr->second.getScale() << std::endl;
}

View File

@@ -50,7 +50,7 @@ bool ClipPlane_readLocalData(Object& obj, Input& fr)
fr[2].getFloat(plane[1]);
fr[3].getFloat(plane[2]);
fr[4].getFloat(plane[3]);
clipplane.setClipPlane(plane);
clipplane.setClipPlane(plane[0],plane[1],plane[2],plane[3]);
fr+=5;
iteratorAdvanced = true;
@@ -66,9 +66,7 @@ bool ClipPlane_writeLocalData(const Object& obj,Output& fw)
fw.indent() << "clipPlaneNum " << clipplane.getClipPlaneNum() <<std::endl;
double plane[4];
clipplane.getClipPlane(plane);
fw.indent() << "plane " << plane[0] << ' ' << plane[1] << ' ' << plane[2] << ' ' << plane[3] << std::endl;
fw.indent() << "plane " << clipplane.getClipPlane()<< std::endl;
return true;
}

View File

@@ -1526,7 +1526,7 @@ osg::Texture2D* txp::getLocalTexture(trpgrImageHelper& image_helper, const trpgT
{
mipmaps[k-1] = tmp_tex->MipLevelOffset(k);
}
image->setMipmapData(mipmaps);
image->setMipmapLevels(mipmaps);
}
@@ -1601,7 +1601,7 @@ osg::Texture2D* txp::getTemplateTexture(trpgrImageHelper& image_helper, trpgLoca
{
mipmaps[k-1] = tmp_tex->MipLevelOffset(k);
}
image->setMipmapData(mipmaps);
image->setMipmapLevels(mipmaps);
}

View File

@@ -1083,7 +1083,7 @@ void CullVisitor::apply(Impostor& node)
float distance2 = (eyeLocal-bs.center()).length2();
if (!_impostorActive ||
distance2*_LODScale*_LODScale<node.getImpostorThreshold2() ||
distance2*_LODScale*_LODScale<osg::square(node.getImpostorThreshold()) ||
distance2<bs.radius2()*2.0f)
{
// outwith the impostor distance threshold therefore simple