From 8c65920c1fe873c78a5b7fb4b277de937d114775 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Aug 2003 09:24:17 +0000 Subject: [PATCH] Fixes for Java build. --- include/osg/Texture | 2 +- include/osgParticle/ParticleSystem | 3 +- include/osgUtil/PickVisitor | 69 ---------------- include/osgUtil/Statistics | 18 ++-- src/osgUtil/PickVisitor.cpp | 128 ----------------------------- 5 files changed, 14 insertions(+), 206 deletions(-) delete mode 100644 include/osgUtil/PickVisitor delete mode 100644 src/osgUtil/PickVisitor.cpp diff --git a/include/osg/Texture b/include/osg/Texture index 8d0521c36..1bba25be4 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -481,7 +481,7 @@ class SG_EXPORT Texture : public osg::StateAttribute mutable TextureObjectBuffer _textureObjectBuffer; - class TextureObjectManager : public osg::Referenced + class SG_EXPORT TextureObjectManager : public osg::Referenced { public: diff --git a/include/osgParticle/ParticleSystem b/include/osgParticle/ParticleSystem index b0d111b3e..3b4a33448 100644 --- a/include/osgParticle/ParticleSystem +++ b/include/osgParticle/ParticleSystem @@ -151,6 +151,8 @@ namespace osgParticle /// Update the particles. Don't call this directly, use a ParticleSystemUpdater instead. virtual void update(double dt); + virtual void drawImplementation(osg::State &state) const; + protected: virtual ~ParticleSystem(); @@ -158,7 +160,6 @@ namespace osgParticle ParticleSystem &operator=(const ParticleSystem &) { return *this; } inline virtual bool computeBound() const; - virtual void drawImplementation(osg::State &state) const; inline void update_bounds(const osg::Vec3 &p, float r); void single_pass_render(osg::State &state, const osg::Matrix &modelview) const; diff --git a/include/osgUtil/PickVisitor b/include/osgUtil/PickVisitor deleted file mode 100644 index c51877418..000000000 --- a/include/osgUtil/PickVisitor +++ /dev/null @@ -1,69 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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. -*/ -// PickIntersectVisitor == Pick visitor - used for screen based picking -// based on osgUtil::IntersectVisitor BUT -// traversing into Projection Nodes using the modified projections. -// also supplies high level intersector for 'what is under a pixel in a sceneview' -// GWM Feb 2003. - - -#ifndef OSGUTIL_PICKINTERSECTVISITOR -#define OSGUTIL_PICKINTERSECTVISITOR 1 - -#include -#include - -namespace osgUtil { - -// PickIntersectVisitor simplifies picking - routines take x,y mouse pixel & detect hits -class OSGUTIL_EXPORT PickIntersectVisitor : public IntersectVisitor -{ -public: - PickIntersectVisitor() - { - setNodeMaskOverride(0xffffffff); // need to make the visitor override the nodemask to visit invisible actions - } - ~PickIntersectVisitor() { } - HitList& getHits(osgUtil::SceneView *, int x, int y); - HitList& PickIntersectVisitor::getIntersections(osg::Node *scene, osg::Vec3 nr, osg::Vec3 fr); -private: - osg::ref_ptr _lineSegment; - friend class osgUtil::IntersectVisitor; -}; - -// PickVisitor traverses whole scene and checks below all Projection nodes -class OSGUTIL_EXPORT PickVisitor : public osg::NodeVisitor -{ -public: - PickVisitor() - { - xp=yp=0; - setNodeMaskOverride(0xffffffff); // need to make the visitor override the nodemask to visit invisible actions - setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN); - } - ~PickVisitor() { } - virtual void apply(osg::Projection& pr); - osgUtil::IntersectVisitor::HitList& getHits(osg::Node *nd, const osg::Matrix &projm, const float x, const float y); - osgUtil::IntersectVisitor::HitList& getHits(osgUtil::SceneView *, double x, double y); - osgUtil::IntersectVisitor::HitList & getHits(osg::Node *nd, const osg::Vec3 near_point, const osg::Vec3 far_point); - osgUtil::IntersectVisitor::HitList& getHits(void); - inline void setxy(float xpt, float ypt) { xp=xpt; yp=ypt; } - inline bool hits() { return _PIVsegHitList.size()>0;} -private: - PickIntersectVisitor _piv; - float xp, yp; // start point in viewport fraction coordiantes - osgUtil::IntersectVisitor::HitList _PIVsegHitList; -}; -}// namespace osgUtil - -#endif // match OSGUTIL_PICKINTERSECTVISITOR diff --git a/include/osgUtil/Statistics b/include/osgUtil/Statistics index 2b8598e9e..b635ddb39 100644 --- a/include/osgUtil/Statistics +++ b/include/osgUtil/Statistics @@ -74,6 +74,8 @@ class Statistics : public osg::Drawable::PrimitiveFunctor void setType(statsType t) {stattype=t;} virtual void setVertexArray(unsigned int count,const osg::Vec3*) { _vertexCount += count; } + virtual void setVertexArray(unsigned int count,const osg::Vec2*) { _vertexCount += count; } + virtual void setVertexArray(unsigned int count,const osg::Vec4*) { _vertexCount += count; } virtual void drawArrays(GLenum mode,GLint,GLsizei count) { @@ -111,18 +113,20 @@ class Statistics : public osg::Drawable::PrimitiveFunctor ++prim.first; _number_of_vertexes = 0; } - virtual void vertex(const osg::Vec3&) + + inline void vertex() { PrimitivePair& prim = _primitiveCount[_currentPrimtiveFunctorMode]; ++prim.second; _number_of_vertexes++; } - virtual void vertex(float,float,float) - { - PrimitivePair& prim = _primitiveCount[_currentPrimtiveFunctorMode]; - ++prim.second; - _number_of_vertexes++; - } + virtual void vertex(float,float,float) { vertex(); } + virtual void vertex(const osg::Vec3&) { vertex(); } + virtual void vertex(const osg::Vec2& vert) { vertex(); } + virtual void vertex(const osg::Vec4& vert) { vertex(); } + virtual void vertex(float x,float y) { vertex(); } + virtual void vertex(float x,float y,float z,float w) { vertex(); } + virtual void end() { _primitives_count[_currentPrimtiveFunctorMode] += diff --git a/src/osgUtil/PickVisitor.cpp b/src/osgUtil/PickVisitor.cpp deleted file mode 100644 index 7f5319489..000000000 --- a/src/osgUtil/PickVisitor.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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. -*/ - - -#include -#include -#include - -using namespace osg; -using namespace osgUtil; - -osgUtil::IntersectVisitor::HitList & PickIntersectVisitor::getHits(osgUtil::SceneView *scv, int x, int y) -{ // High level get intersection with sceneview using a ray from x,y on the screen - int x0,y0,width,height; - scv->getViewport(x0, y0, width, height); -// setxy(-1+2*(float)(x-x0)/(float)width, 1-2*(float)(y-y0)/(float)height); - // sets xp,yp as pixels scaled to a mapping of (-1,1, -1,1); needed for Projection from x,y pixels - osg::Vec3 near_point,far_point; - // get ends of line segment perpendicular to screen: - if (!scv->projectWindowXYIntoObject(x,height-y,near_point,far_point)) - { - osg::notify(osg::NOTICE) << "PickIntersect failed to calculate intersection ray."<< std::endl; - return getHitList(NULL); // empty; - } - - return getIntersections(scv->getSceneData(),near_point,far_point); -} - -osgUtil::IntersectVisitor::HitList & PickIntersectVisitor::getIntersections(osg::Node *scene, - osg::Vec3 near_point,osg::Vec3 far_point) -{ - // option for non-sceneView users: you need to get the screen perp line and call getIntersections - // if you are using Projection nodes you should also call setxy to define the xp,yp positions for use with - // the ray transformed by Projection - _lineSegment = new osg::LineSegment; - _lineSegment->set(near_point,far_point); // make a line segment - addLineSegment(_lineSegment.get()); - - scene->accept(*this); - return getHitList(_lineSegment.get()); -} - -// pickvisitor - top level; test main scenegraph than traverse to lower Projections -osgUtil::IntersectVisitor::HitList & PickVisitor::getHits(osg::Node *nd, const osg::Vec3 near_point, const osg::Vec3 far_point) -{ - // High level get intersection with sceneview using a ray from x,y on the screen - // sets xp,yp as pixels scaled to a mapping of (-1,1, -1,1); needed for Projection from x,y pixels - - // first get the standard hits in un-projected nodes - _PIVsegHitList=_piv.getIntersections(nd,near_point,far_point); // fill hitlist - - // then get hits in projection nodes - traverse(*(nd)); // check for projection nodes - return _PIVsegHitList; -} - -osgUtil::IntersectVisitor::HitList & PickVisitor::getHits(osgUtil::SceneView *scv, const double x, const double y) -{ - // High level get intersection with sceneview using a ray from x,y on the screen - int x0,y0,width,height; - scv->getViewport(x0, y0, width, height); - setxy(-1+2*(float)(x-x0)/(float)width, 1-2*(float)(y-y0)/(float)height); - // sets xp,yp as pixels scaled to a mapping of (-1,1, -1,1); needed for Projection from x,y pixels - osg::Vec3 near_point,far_point; - // get ends of line segment perpendicular to screen: - if (!scv->projectWindowXYIntoObject(x,height-y,near_point,far_point)) - { - osg::notify(osg::NOTICE) << "PickIntersect failed to calculate intersection ray."<< std::endl; - return _piv.getHitList(NULL); // empty; - } - osg::Node *nd=scv->getSceneData(); - getHits(nd, near_point,far_point); - return _PIVsegHitList; -} - -osgUtil::IntersectVisitor::HitList & PickVisitor::getHits(void) -{ - // High level return current intersections - return _PIVsegHitList; -} - -osgUtil::IntersectVisitor::HitList& PickVisitor::getHits(osg::Node *scene, - const osg::Matrix &projm, const float x, const float y) -{ - // utility for non=sceneview viewers - // x,y are values returned by - osg::Matrix inverseMVPW; - inverseMVPW.invert(projm); -// float ix=0.5f+0.5f*x, iy=0.5f+0.5f*y; // for this purpose, range from 0-1 - osg::Vec3 near_point = osg::Vec3(x,y,1.0f)*inverseMVPW; - osg::Vec3 far_point = osg::Vec3(x,y,-1.0f)*inverseMVPW; - setxy(x,y); - getHits(scene,near_point,far_point); - return _PIVsegHitList; -} - -void PickVisitor::apply(osg::Projection& pr) -{ // stack the intersect rays, transform to new projection, traverse - // Assumes that the Projection is an absolute projection - osg::Matrix mt; - mt.invert(pr.getMatrix()); - osg::Vec3 npt=osg::Vec3(xp,yp,1.0f) * mt, farpt=osg::Vec3(xp,yp,-1.0f) * mt; - - // traversing the nodes children, using the projection direction - for (unsigned int i=0; i