From 795d481ca621613376517ab72db89d9fea1a516b Mon Sep 17 00:00:00 2001 From: frohlich Date: Mon, 7 Sep 2009 21:42:50 +0000 Subject: [PATCH] Switch to new vector conversion functions. Modified Files: simgear/math/SGGeod.cxx simgear/math/SGQuat.hxx simgear/math/SGVec2.hxx simgear/math/SGVec3.hxx simgear/math/SGVec4.hxx simgear/scene/material/Effect.cxx simgear/scene/model/SGInteractionAnimation.cxx simgear/scene/model/SGMaterialAnimation.cxx simgear/scene/model/SGRotateTransform.cxx simgear/scene/model/SGScaleTransform.cxx simgear/scene/model/SGTranslateTransform.cxx simgear/scene/model/animation.cxx simgear/scene/model/particles.cxx simgear/scene/model/placement.cxx simgear/scene/model/shadanim.cxx simgear/scene/sky/CloudShaderGeometry.cxx simgear/scene/sky/cloud.cxx simgear/scene/sky/cloudfield.cxx simgear/scene/sky/dome.cxx simgear/scene/sky/sky.cxx simgear/scene/tgdb/GroundLightManager.cxx simgear/scene/tgdb/SGOceanTile.cxx simgear/scene/tgdb/SGTexturedTriangleBin.hxx simgear/scene/tgdb/SGVasiDrawable.cxx simgear/scene/tgdb/TreeBin.cxx simgear/scene/tgdb/obj.cxx simgear/scene/tgdb/pt_lights.cxx simgear/scene/util/SGUpdateVisitor.hxx --- simgear/math/SGGeod.cxx | 6 ++-- simgear/math/SGQuat.hxx | 9 ------ simgear/math/SGVec2.hxx | 11 ------- simgear/math/SGVec3.hxx | 11 ------- simgear/math/SGVec4.hxx | 11 ------- simgear/scene/material/Effect.cxx | 10 +++--- .../scene/model/SGInteractionAnimation.cxx | 4 +-- simgear/scene/model/SGMaterialAnimation.cxx | 2 +- simgear/scene/model/SGRotateTransform.cxx | 6 ++-- simgear/scene/model/SGScaleTransform.cxx | 4 +-- simgear/scene/model/SGTranslateTransform.cxx | 12 +++---- simgear/scene/model/animation.cxx | 2 +- simgear/scene/model/particles.cxx | 4 +-- simgear/scene/model/placement.cxx | 4 +-- simgear/scene/model/shadanim.cxx | 8 ++--- simgear/scene/sky/CloudShaderGeometry.cxx | 2 +- simgear/scene/sky/cloud.cxx | 6 ++-- simgear/scene/sky/cloudfield.cxx | 6 ++-- simgear/scene/sky/dome.cxx | 12 +++---- simgear/scene/sky/sky.cxx | 4 +-- simgear/scene/tgdb/GroundLightManager.cxx | 6 ++-- simgear/scene/tgdb/SGOceanTile.cxx | 10 +++--- simgear/scene/tgdb/SGTexturedTriangleBin.hxx | 18 +++++------ simgear/scene/tgdb/SGVasiDrawable.cxx | 4 +-- simgear/scene/tgdb/TreeBin.cxx | 8 ++--- simgear/scene/tgdb/obj.cxx | 6 ++-- simgear/scene/tgdb/pt_lights.cxx | 32 +++++++++---------- simgear/scene/util/SGUpdateVisitor.hxx | 2 +- 28 files changed, 89 insertions(+), 131 deletions(-) diff --git a/simgear/math/SGGeod.cxx b/simgear/math/SGGeod.cxx index 370b9725..15468707 100644 --- a/simgear/math/SGGeod.cxx +++ b/simgear/math/SGGeod.cxx @@ -22,7 +22,7 @@ osg::Matrix SGGeod::makeSimulationFrameRelative() const { SGQuatd hlOr = SGQuatd::fromLonLat(*this); - return osg::Matrix(hlOr.osg()); + return osg::Matrix(toOsg(hlOr)); } osg::Matrix SGGeod::makeSimulationFrame() const @@ -30,7 +30,7 @@ osg::Matrix SGGeod::makeSimulationFrame() const osg::Matrix result(makeSimulationFrameRelative()); SGVec3d coord; SGGeodesy::SGGeodToCart(*this, coord); - result.setTrans(coord.osg()); + result.setTrans(toOsg(coord)); return result; } @@ -48,7 +48,7 @@ osg::Matrix SGGeod::makeZUpFrame() const osg::Matrix result(makeZUpFrameRelative()); SGVec3d coord; SGGeodesy::SGGeodToCart(*this, coord); - result.setTrans(coord.osg()); + result.setTrans(toOsg(coord)); return result; } diff --git a/simgear/math/SGQuat.hxx b/simgear/math/SGQuat.hxx index b466d896..a48cbf1a 100644 --- a/simgear/math/SGQuat.hxx +++ b/simgear/math/SGQuat.hxx @@ -55,10 +55,6 @@ public: /// make sure it has at least 4 elements explicit SGQuat(const T* d) { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; data()[3] = d[3]; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - explicit SGQuat(const osg::Quat& d) - { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; data()[3] = d[3]; } -#endif /// Return a unit quaternion static SGQuat unit(void) @@ -376,11 +372,6 @@ public: T (&data(void))[4] { return _data; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - osg::Quat osg() const - { return osg::Quat(data()[0], data()[1], data()[2], data()[3]); } -#endif - /// Inplace addition SGQuat& operator+=(const SGQuat& v) { data()[0]+=v(0);data()[1]+=v(1);data()[2]+=v(2);data()[3]+=v(3);return *this; } diff --git a/simgear/math/SGVec2.hxx b/simgear/math/SGVec2.hxx index 1e683b49..5024e2c1 100644 --- a/simgear/math/SGVec2.hxx +++ b/simgear/math/SGVec2.hxx @@ -55,12 +55,6 @@ public: template explicit SGVec2(const SGVec2& d) { data()[0] = d[0]; data()[1] = d[1]; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - explicit SGVec2(const osg::Vec2f& d) - { data()[0] = d[0]; data()[1] = d[1]; } - explicit SGVec2(const osg::Vec2d& d) - { data()[0] = d[0]; data()[1] = d[1]; } -#endif /// Access by index, the index is unchecked const T& operator()(unsigned i) const @@ -96,11 +90,6 @@ public: T (&data(void))[2] { return _data; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - osg::Vec2d osg() const - { return osg::Vec2d(data()[0], data()[1]); } -#endif - /// Inplace addition SGVec2& operator+=(const SGVec2& v) { data()[0] += v(0); data()[1] += v(1); return *this; } diff --git a/simgear/math/SGVec3.hxx b/simgear/math/SGVec3.hxx index f2b7406a..cbdf0fa2 100644 --- a/simgear/math/SGVec3.hxx +++ b/simgear/math/SGVec3.hxx @@ -53,12 +53,6 @@ public: { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; } explicit SGVec3(const SGVec2& v2, const T& v3 = 0) { data()[0] = v2[0]; data()[1] = v2[1]; data()[2] = v3; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - explicit SGVec3(const osg::Vec3f& d) - { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; } - explicit SGVec3(const osg::Vec3d& d) - { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; } -#endif /// Access by index, the index is unchecked const T& operator()(unsigned i) const @@ -100,11 +94,6 @@ public: T (&data(void))[3] { return _data; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - osg::Vec3d osg() const - { return osg::Vec3d(data()[0], data()[1], data()[2]); } -#endif - /// Inplace addition SGVec3& operator+=(const SGVec3& v) { data()[0] += v(0); data()[1] += v(1); data()[2] += v(2); return *this; } diff --git a/simgear/math/SGVec4.hxx b/simgear/math/SGVec4.hxx index 335393fb..baf9137d 100644 --- a/simgear/math/SGVec4.hxx +++ b/simgear/math/SGVec4.hxx @@ -53,12 +53,6 @@ public: { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; data()[3] = d[3]; } explicit SGVec4(const SGVec3& v3, const T& v4 = 0) { data()[0] = v3[0]; data()[1] = v3[1]; data()[2] = v3[2]; data()[3] = v4; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - explicit SGVec4(const osg::Vec4f& d) - { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; data()[3] = d[3]; } - explicit SGVec4(const osg::Vec4d& d) - { data()[0] = d[0]; data()[1] = d[1]; data()[2] = d[2]; data()[3] = d[3]; } -#endif /// Access by index, the index is unchecked const T& operator()(unsigned i) const @@ -106,11 +100,6 @@ public: T (&data(void))[4] { return _data; } -#ifndef NO_OPENSCENEGRAPH_INTERFACE - osg::Vec4d osg() const - { return osg::Vec4d(data()[0], data()[1], data()[2], data()[3]); } -#endif - /// Inplace addition SGVec4& operator+=(const SGVec4& v) { data()[0]+=v(0);data()[1]+=v(1);data()[2]+=v(2);data()[3]+=v(3);return *this; } diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index f812f57a..b36702ad 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -168,9 +168,9 @@ osg::Vec4f getColor(const SGPropertyNode* prop) { if (prop->nChildren() == 0) { if (prop->getType() == props::VEC4D) { - return osg::Vec4f(prop->getValue().osg()); + return osg::Vec4f(toOsg(prop->getValue())); } else if (prop->getType() == props::VEC3D) { - return osg::Vec4f(prop->getValue().osg(), 1.0f); + return osg::Vec4f(toOsg(prop->getValue()), 1.0f); } else { SG_LOG(SG_INPUT, SG_ALERT, "invalid color property " << prop->getName() << " " @@ -417,7 +417,7 @@ TexEnv* buildTexEnv(Effect* effect, const SGPropertyNode* prop) } TexEnv* env = new TexEnv(mode); if (colorProp) - env->setColor(colorProp->getValue().osg()); + env->setColor(toOsg(colorProp->getValue())); return env; } @@ -623,10 +623,10 @@ struct UniformBuilder :public PassAttributeBuilder uniform->set(valProp->getValue()); break; case Uniform::FLOAT_VEC3: - uniform->set(Vec3f(valProp->getValue().osg())); + uniform->set(toOsg(valProp->getValue())); break; case Uniform::FLOAT_VEC4: - uniform->set(Vec4f(valProp->getValue().osg())); + uniform->set(toOsg(valProp->getValue())); break; case Uniform::SAMPLER_1D: case Uniform::SAMPLER_2D: diff --git a/simgear/scene/model/SGInteractionAnimation.cxx b/simgear/scene/model/SGInteractionAnimation.cxx index 956d7b69..9e7987e9 100644 --- a/simgear/scene/model/SGInteractionAnimation.cxx +++ b/simgear/scene/model/SGInteractionAnimation.cxx @@ -80,8 +80,8 @@ public: // Trick to get the ends in the right order. // Use the x axis in the original coordinate system. Choose the // most negative x-axis as the one pointing forward - SGVec3f tv1(_matrix.preMult(v1)); - SGVec3f tv2(_matrix.preMult(v2)); + SGVec3f tv1(toSG(_matrix.preMult(v1))); + SGVec3f tv2(toSG(_matrix.preMult(v2))); if (tv1[0] > tv2[0]) _lineSegments.push_back(SGLineSegmentf(tv1, tv2)); else diff --git a/simgear/scene/model/SGMaterialAnimation.cxx b/simgear/scene/model/SGMaterialAnimation.cxx index 1e7afdd9..ca9ac364 100644 --- a/simgear/scene/model/SGMaterialAnimation.cxx +++ b/simgear/scene/model/SGMaterialAnimation.cxx @@ -100,7 +100,7 @@ struct ColorSpec { osg::Vec4 rgbaVec4() { - return rgba().osg(); + return toOsg(rgba()); } SGVec4f &initialRgba() { diff --git a/simgear/scene/model/SGRotateTransform.cxx b/simgear/scene/model/SGRotateTransform.cxx index 0b79f59e..d5474839 100644 --- a/simgear/scene/model/SGRotateTransform.cxx +++ b/simgear/scene/model/SGRotateTransform.cxx @@ -128,7 +128,7 @@ osg::BoundingSphere SGRotateTransform::computeBound() const { osg::BoundingSphere bs = osg::Group::computeBound(); - osg::BoundingSphere centerbs(_center.osg(), bs.radius()); + osg::BoundingSphere centerbs(toOsg(_center), bs.radius()); centerbs.expandBy(bs); return centerbs; } @@ -147,7 +147,7 @@ bool RotateTransform_readLocalData(osg::Object& obj, osgDB::Input& fr) fr += 3; else return false; - rot.setCenter(SGVec3d(center)); + rot.setCenter(toSG(center)); } if (fr[0].matchWord("axis")) { ++fr; @@ -156,7 +156,7 @@ bool RotateTransform_readLocalData(osg::Object& obj, osgDB::Input& fr) fr += 3; else return false; - rot.setCenter(SGVec3d(axis)); + rot.setCenter(toSG(axis)); } if (fr[0].matchWord("angle")) { ++fr; diff --git a/simgear/scene/model/SGScaleTransform.cxx b/simgear/scene/model/SGScaleTransform.cxx index 4907cbd9..ab9d6215 100644 --- a/simgear/scene/model/SGScaleTransform.cxx +++ b/simgear/scene/model/SGScaleTransform.cxx @@ -112,7 +112,7 @@ bool ScaleTransform_readLocalData(osg::Object& obj, osgDB::Input& fr) fr += 3; else return false; - scale.setCenter(SGVec3d(center)); + scale.setCenter(toSG(center)); } if (fr[0].matchWord("scaleFactor")) { ++fr; @@ -121,7 +121,7 @@ bool ScaleTransform_readLocalData(osg::Object& obj, osgDB::Input& fr) fr += 3; else return false; - scale.setScaleFactor(SGVec3d(scaleFactor)); + scale.setScaleFactor(toSG(scaleFactor)); } return true; } diff --git a/simgear/scene/model/SGTranslateTransform.cxx b/simgear/scene/model/SGTranslateTransform.cxx index 8fc30d90..182c30bf 100644 --- a/simgear/scene/model/SGTranslateTransform.cxx +++ b/simgear/scene/model/SGTranslateTransform.cxx @@ -49,9 +49,9 @@ SGTranslateTransform::computeLocalToWorldMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const { if (_referenceFrame == RELATIVE_RF) { - matrix.preMultTranslate((_value*_axis).osg()); + matrix.preMultTranslate(toOsg(_value*_axis)); } else { - matrix.setTrans((_value*_axis).osg()); + matrix.setTrans(toOsg(_value*_axis)); } return true; } @@ -61,9 +61,9 @@ SGTranslateTransform::computeWorldToLocalMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const { if (_referenceFrame == RELATIVE_RF) { - matrix.postMultTranslate((-_value*_axis).osg()); + matrix.postMultTranslate(toOsg(-_value*_axis)); } else { - matrix.setTrans((-_value*_axis).osg()); + matrix.setTrans(toOsg(-_value*_axis)); } return true; } @@ -72,7 +72,7 @@ osg::BoundingSphere SGTranslateTransform::computeBound() const { osg::BoundingSphere bs = osg::Group::computeBound(); - bs._center += _axis.osg()*_value; + bs._center += toOsg(_axis)*_value; return bs; } @@ -89,7 +89,7 @@ bool TranslateTransform_readLocalData(osg::Object& obj, osgDB::Input& fr) fr += 3; else return false; - trans.setAxis(SGVec3d(axis)); + trans.setAxis(toSG(axis)); } if (fr[0].matchWord("value")) { ++fr; diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index e62c2675..a52174d3 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -1024,7 +1024,7 @@ private: if (!nv) return 1; - double scale_factor = (_center.osg() - nv->getEyePoint()).length(); + double scale_factor = (toOsg(_center) - nv->getEyePoint()).length(); if (_table == 0) { scale_factor = _factor * scale_factor + _offset; } else { diff --git a/simgear/scene/model/particles.cxx b/simgear/scene/model/particles.cxx index 9f3aeb7d..b5687ed4 100644 --- a/simgear/scene/model/particles.cxx +++ b/simgear/scene/model/particles.cxx @@ -59,7 +59,7 @@ void GlobalParticleCallback::operator()(osg::Node* node, osg::NodeVisitor* nv) SGQuatd q = SGQuatd::fromLonLatDeg(modelRoot->getFloatValue("/position/longitude-deg",0), modelRoot->getFloatValue("/position/latitude-deg",0)); - osg::Matrix om(q.osg()); + osg::Matrix om(toOsg(q)); osg::Vec3 v(0,0,9.81); gravity = om.preMult(v); const osg::Vec3& zUpWind = Particles::getWindVector(); @@ -552,7 +552,7 @@ void Particles::operator()(osg::Node* node, osg::NodeVisitor* nv) if (displace * displace > 10000.0 * 10000.0) { // Make new frame for particle system, coincident with // the emitter frame, but oriented with local Z. - SGGeod geod = SGGeod::fromCart(SGVec3d(emitOrigin)); + SGGeod geod = SGGeod::fromCart(toSG(emitOrigin)); Matrix newParticleMat = geod.makeZUpFrame(); Matrix changeParticleFrame = particleMat * Matrix::inverse(newParticleMat); diff --git a/simgear/scene/model/placement.cxx b/simgear/scene/model/placement.cxx index 486113d8..cd38181e 100644 --- a/simgear/scene/model/placement.cxx +++ b/simgear/scene/model/placement.cxx @@ -46,7 +46,7 @@ SGModelPlacement::update() { // The cartesian position SGVec3d position = SGVec3d::fromGeod(_position); - _transform->setPosition(position.osg()); + _transform->setPosition(toOsg(position)); // The orientation, composed from the horizontal local orientation and the // orientation wrt the horizontal local frame @@ -56,7 +56,7 @@ SGModelPlacement::update() // the y axis 180 degrees. orient *= SGQuatd::fromRealImag(0, SGVec3d(0, 1, 0)); - _transform->setAttitude(orient.osg()); + _transform->setAttitude(toOsg(orient)); } bool diff --git a/simgear/scene/model/shadanim.cxx b/simgear/scene/model/shadanim.cxx index 6c0ad494..cb9270a3 100644 --- a/simgear/scene/model/shadanim.cxx +++ b/simgear/scene/model/shadanim.cxx @@ -107,8 +107,8 @@ public: // FIXME: need an update or callback ... // generate the six highlight map images (light direction = [1, 1, -1]) osg::ref_ptr mapgen; - mapgen = new osgUtil::HighlightMapGenerator(_lastLightDirection.osg(), - _lastLightColor.osg(), 5); + mapgen = new osgUtil::HighlightMapGenerator(toOsg(_lastLightDirection), + toOsg(_lastLightColor), 5); mapgen->generateMap(); // assign the six images to the texture object @@ -209,8 +209,8 @@ public: if (!combine) return; // An approximation for light reflected back by chrome. - osg::Vec4 globalColor = (updateVisitor->getAmbientLight().osg() * .4f - + updateVisitor->getDiffuseLight().osg()); + osg::Vec4 globalColor = toOsg(updateVisitor->getAmbientLight() * .4f + + updateVisitor->getDiffuseLight()); globalColor.a() = 1.0f; combine->setConstantColor(globalColor); } diff --git a/simgear/scene/sky/CloudShaderGeometry.cxx b/simgear/scene/sky/CloudShaderGeometry.cxx index 53e1b3d4..49244faf 100755 --- a/simgear/scene/sky/CloudShaderGeometry.cxx +++ b/simgear/scene/sky/CloudShaderGeometry.cxx @@ -74,7 +74,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const itr != end; ++itr) { Vec4f projPos - = Vec4f(_cloudsprites[itr->idx].position.osg(), 1.0f) * mvp; + = Vec4f(toOsg(_cloudsprites[itr->idx].position), 1.0f) * mvp; itr->depth = projPos.z() / projPos.w(); } // Already sorted? diff --git a/simgear/scene/sky/cloud.cxx b/simgear/scene/sky/cloud.cxx index 50376314..68e41deb 100644 --- a/simgear/scene/sky/cloud.cxx +++ b/simgear/scene/sky/cloud.cxx @@ -605,7 +605,7 @@ SGCloudLayer::rebuild() // repaint the cloud layer colors bool SGCloudLayer::repaint( const SGVec3f& fog_color ) { - osg::Vec4f combineColor(fog_color.osg(), cloud_alpha); + osg::Vec4f combineColor(toOsg(fog_color), cloud_alpha); osg::TexEnvCombine* combiner = dynamic_cast(layer_root->getStateSet() ->getTextureAttribute(1, osg::StateAttribute::TEXENV)); @@ -625,7 +625,7 @@ bool SGCloudLayer::reposition( const SGVec3f& p, const SGVec3f& up, double lon, double alt, double dt ) { // combine p and asl (meters) to get translation offset - osg::Vec3 asl_offset(up.osg()); + osg::Vec3 asl_offset(toOsg(up)); asl_offset.normalize(); if ( alt <= layer_asl ) { asl_offset *= layer_asl; @@ -635,7 +635,7 @@ bool SGCloudLayer::reposition( const SGVec3f& p, const SGVec3f& up, double lon, // cout << "asl_offset = " << asl_offset[0] << "," << asl_offset[1] // << "," << asl_offset[2] << endl; - asl_offset += p.osg(); + asl_offset += toOsg(p); // cout << " asl_offset = " << asl_offset[0] << "," << asl_offset[1] // << "," << asl_offset[2] << endl; diff --git a/simgear/scene/sky/cloudfield.cxx b/simgear/scene/sky/cloudfield.cxx index 7ecd4292..770f4da0 100644 --- a/simgear/scene/sky/cloudfield.cxx +++ b/simgear/scene/sky/cloudfield.cxx @@ -96,7 +96,7 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon, // First time or very large distance SGVec3 cart; SGGeodesy::SGGeodToCart(SGGeod::fromRad(lon, lat), cart); - T.makeTranslate(cart.osg()); + T.makeTranslate(toOsg(cart)); LON.makeRotate(lon, osg::Vec3(0, 0, 1)); LAT.makeRotate(90.0 * SGD_DEGREES_TO_RADIANS - lat, osg::Vec3(0, 1, 0)); @@ -129,7 +129,7 @@ bool SGCloudField::reposition( const SGVec3f& p, const SGVec3f& up, double lon, SGVec3 cart; SGGeodesy::SGGeodToCart(SGGeod::fromRad(cld_pos.getLongitudeRad(), cld_pos.getLatitudeRad()), cart); - T.makeTranslate(cart.osg()); + T.makeTranslate(toOsg(cart)); LON.makeRotate(cld_pos.getLongitudeRad(), osg::Vec3(0, 0, 1)); LAT.makeRotate(90.0 * SGD_DEGREES_TO_RADIANS - cld_pos.getLatitudeRad(), osg::Vec3(0, 1, 0)); @@ -274,7 +274,7 @@ void SGCloudField::addCloud( SGVec3f& pos, SGNewCloud *cloud) { osg::ref_ptr transform = new osg::PositionAttitudeTransform; - transform->setPosition(pos.osg()); + transform->setPosition(toOsg(pos)); transform->addChild(geode.get()); field_group[x][y]->addChild(transform.get(), true); diff --git a/simgear/scene/sky/dome.cxx b/simgear/scene/sky/dome.cxx index 3bdb48ab..cea4b6cf 100644 --- a/simgear/scene/sky/dome.cxx +++ b/simgear/scene/sky/dome.cxx @@ -258,7 +258,7 @@ SGSkyDome::repaint( const SGVec3f& sun_color, const SGVec3f& sky_color, const float upperVisFactor = 1.0 - vis_factor * (0.7 + 0.3 * cvf/45000); const float middleVisFactor = 1.0 - vis_factor * (0.1 + 0.85 * cvf/45000); - (*dome_cl)[0] = sky_color.osg(); + (*dome_cl)[0] = toOsg(sky_color); simgear::VectorArrayAdapter colors(*dome_cl, numBands, 1); const double saif = sun_angle/SG_PI; static const SGVec3f blueShift(0.8, 1.0, 1.2); @@ -271,9 +271,9 @@ SGSkyDome::repaint( const SGVec3f& sun_color, const SGVec3f& sky_color, for (int i = 0; i < halfBands+1; i++) { SGVec3f diff = mult(skyFogDelta, blueShift); diff *= (0.8 + saif - ((halfBands-i)/10)); - colors(2, i) = (sky_color - upperVisFactor * diff).osg(); - colors(3, i) = (sky_color - middleVisFactor * diff + middle_amt).osg(); - colors(4, i) = (fog_color + outer_amt).osg(); + colors(2, i) = toOsg(sky_color - upperVisFactor * diff); + colors(3, i) = toOsg(sky_color - middleVisFactor * diff + middle_amt); + colors(4, i) = toOsg(fog_color + outer_amt); colors(0, i) = simgear::math::lerp(toOsg(sky_color), colors(2, i), .3942); colors(1, i) = simgear::math::lerp(toOsg(sky_color), colors(2, i), .7885); for (int j = 0; j < numRings - 1; ++j) @@ -292,7 +292,7 @@ SGSkyDome::repaint( const SGVec3f& sun_color, const SGVec3f& sky_color, numBands); for ( int i = 0; i < numBands; i++ ) - colors(numRings - 1, i) = fog_color.osg(); + colors(numRings - 1, i) = toOsg(fog_color); dome_cl->dirty(); return true; } @@ -313,7 +313,7 @@ SGSkyDome::reposition( const SGVec3f& p, double _asl, // Translate to view position // Point3D zero_elev = current_view.get_cur_zero_elev(); // xglTranslatef( zero_elev.x(), zero_elev.y(), zero_elev.z() ); - T.makeTranslate( p.osg() ); + T.makeTranslate( toOsg(p) ); // printf(" Translated to %.2f %.2f %.2f\n", // zero_elev.x, zero_elev.y, zero_elev.z ); diff --git a/simgear/scene/sky/sky.cxx b/simgear/scene/sky/sky.cxx index 7714dd0a..5367550b 100644 --- a/simgear/scene/sky/sky.cxx +++ b/simgear/scene/sky/sky.cxx @@ -131,7 +131,7 @@ bool SGSky::repaint( const SGSkyColor &sc, const SGEphemeris& eph ) disable(); } SGCloudField::updateFog((double)effective_visibility, - osg::Vec4f(sc.fog_color.osg(), 1.0f)); + osg::Vec4f(toOsg(sc.fog_color), 1.0f)); return true; } @@ -150,7 +150,7 @@ bool SGSky::reposition( const SGSkyState &st, const SGEphemeris& eph, double dt dome->reposition( st.zero_elev, st.alt, st.lon, st.lat, st.spin ); osg::Matrix m = osg::Matrix::rotate(angleRad, osg::Vec3(0, 0, -1)); - m.postMultTranslate(st.view_pos.osg()); + m.postMultTranslate(toOsg(st.view_pos)); _ephTransform->setMatrix(m); double sun_ra = eph.getSunRightAscension(); diff --git a/simgear/scene/tgdb/GroundLightManager.cxx b/simgear/scene/tgdb/GroundLightManager.cxx index e35e638e..9be3f6de 100644 --- a/simgear/scene/tgdb/GroundLightManager.cxx +++ b/simgear/scene/tgdb/GroundLightManager.cxx @@ -35,15 +35,15 @@ void GroundLightManager::update(const SGUpdateVisitor* updateVisitor) SGVec4f fogColor = updateVisitor->getFogColor(); fog = static_cast(runwayLightSS ->getAttribute(StateAttribute::FOG)); - fog->setColor(fogColor.osg()); + fog->setColor(toOsg(fogColor)); fog->setDensity(updateVisitor->getRunwayFogExp2Density()); fog = static_cast(taxiLightSS ->getAttribute(StateAttribute::FOG)); - fog->setColor(fogColor.osg()); + fog->setColor(toOsg(fogColor)); fog->setDensity(updateVisitor->getTaxiFogExp2Density()); fog = static_cast(groundLightSS ->getAttribute(StateAttribute::FOG)); - fog->setColor(fogColor.osg()); + fog->setColor(toOsg(fogColor)); fog->setDensity(updateVisitor->getGroundLightsFogExp2Density()); } diff --git a/simgear/scene/tgdb/SGOceanTile.cxx b/simgear/scene/tgdb/SGOceanTile.cxx index 9ff60f3e..34a0bba7 100644 --- a/simgear/scene/tgdb/SGOceanTile.cxx +++ b/simgear/scene/tgdb/SGOceanTile.cxx @@ -140,9 +140,9 @@ void OceanMesh::calcMesh(const SGVec3d& cartCenter, const SGQuatd& orient, for (int j = 0; j < latPoints; j++) { for (int i = 0; i < lonPoints; ++i) { - vlArray(j, i) = rel[j][i].osg(); - nlArray(j, i) = normals[j][i].osg(); - tlArray(j, i) = texsArray(j, i).toSGVec2f().osg(); + vlArray(j, i) = toOsg(rel[j][i]); + nlArray(j, i) = toOsg(normals[j][i]); + tlArray(j, i) = toOsg(texsArray(j, i).toSGVec2f()); } } @@ -313,8 +313,8 @@ osg::Node* SGOceanTile(const SGBucket& b, SGMaterialLib *matlib) osg::MatrixTransform* transform = new osg::MatrixTransform; transform->setName("Ocean"); - transform->setMatrix(osg::Matrix::rotate(hlOr.osg())* - osg::Matrix::translate(cartCenter.osg())); + transform->setMatrix(osg::Matrix::rotate(toOsg(hlOr))* + osg::Matrix::translate(toOsg(cartCenter))); transform->addChild(geode); return transform; diff --git a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx index 97e1aebc..3df4280a 100644 --- a/simgear/scene/tgdb/SGTexturedTriangleBin.hxx +++ b/simgear/scene/tgdb/SGTexturedTriangleBin.hxx @@ -309,25 +309,25 @@ public: triangle_ref triangle = triangles[i]; if (indexMap[triangle[0]] == invalid) { indexMap[triangle[0]] = vertices->size(); - vertices->push_back(getVertex(triangle[0]).vertex.osg()); - normals->push_back(getVertex(triangle[0]).normal.osg()); - texCoords->push_back(getVertex(triangle[0]).texCoord.osg()); + vertices->push_back(toOsg(getVertex(triangle[0]).vertex)); + normals->push_back(toOsg(getVertex(triangle[0]).normal)); + texCoords->push_back(toOsg(getVertex(triangle[0]).texCoord)); } deFacade.push_back(indexMap[triangle[0]]); if (indexMap[triangle[1]] == invalid) { indexMap[triangle[1]] = vertices->size(); - vertices->push_back(getVertex(triangle[1]).vertex.osg()); - normals->push_back(getVertex(triangle[1]).normal.osg()); - texCoords->push_back(getVertex(triangle[1]).texCoord.osg()); + vertices->push_back(toOsg(getVertex(triangle[1]).vertex)); + normals->push_back(toOsg(getVertex(triangle[1]).normal)); + texCoords->push_back(toOsg(getVertex(triangle[1]).texCoord)); } deFacade.push_back(indexMap[triangle[1]]); if (indexMap[triangle[2]] == invalid) { indexMap[triangle[2]] = vertices->size(); - vertices->push_back(getVertex(triangle[2]).vertex.osg()); - normals->push_back(getVertex(triangle[2]).normal.osg()); - texCoords->push_back(getVertex(triangle[2]).texCoord.osg()); + vertices->push_back(toOsg(getVertex(triangle[2]).vertex)); + normals->push_back(toOsg(getVertex(triangle[2]).normal)); + texCoords->push_back(toOsg(getVertex(triangle[2]).texCoord)); } deFacade.push_back(indexMap[triangle[2]]); } diff --git a/simgear/scene/tgdb/SGVasiDrawable.cxx b/simgear/scene/tgdb/SGVasiDrawable.cxx index 24e55388..bc9b662c 100644 --- a/simgear/scene/tgdb/SGVasiDrawable.cxx +++ b/simgear/scene/tgdb/SGVasiDrawable.cxx @@ -94,7 +94,7 @@ SGVasiDrawable::drawImplementation(osg::RenderInfo& renderInfo) const // Retrieve the eye point in local coords osg::Matrix m; m.invert(renderInfo.getState()->getModelViewMatrix()); - SGVec3f eyePoint(m.preMult(osg::Vec3(0, 0, 0))); + SGVec3f eyePoint(toSG(m.preMult(osg::Vec3(0, 0, 0)))); // paint the points for (unsigned i = 0; i < _lights.size(); ++i) @@ -106,7 +106,7 @@ SGVasiDrawable::computeBound() const { osg::BoundingBox bb; for (unsigned i = 0; i < _lights.size(); ++i) - bb.expandBy(_lights[i].position.osg()); + bb.expandBy(toOsg(_lights[i].position)); // blow up to avoid being victim to small feature culling ... bb.expandBy(bb._min - osg::Vec3(1, 1, 1)); diff --git a/simgear/scene/tgdb/TreeBin.cxx b/simgear/scene/tgdb/TreeBin.cxx index b02307db..8c639139 100644 --- a/simgear/scene/tgdb/TreeBin.cxx +++ b/simgear/scene/tgdb/TreeBin.cxx @@ -181,7 +181,7 @@ Geode* createTreeGeode(float width, float height, int varieties) void addTreeToLeafGeode(Geode* geode, const SGVec3f& p) { - const Vec3& pos = p.osg(); + Vec3 pos = toOsg(p); unsigned int numDrawables = geode->getNumDrawables(); Geometry* geom = static_cast(geode->getDrawable(numDrawables - 1)); @@ -287,7 +287,7 @@ struct GetTreeCoord { Vec3 operator() (const TreeBin::Tree& tree) const { - return tree.position.osg(); + return toOsg(tree.position); } }; @@ -300,8 +300,8 @@ struct TreeTransformer TreeTransformer(Matrix& mat_) : mat(mat_) {} TreeBin::Tree operator()(const TreeBin::Tree& tree) const { - const Vec3& pos = tree.position.osg(); - return TreeBin::Tree(SGVec3f(pos * mat)); + Vec3 pos = toOsg(tree.position); + return TreeBin::Tree(toSG(pos * mat)); } Matrix mat; }; diff --git a/simgear/scene/tgdb/obj.cxx b/simgear/scene/tgdb/obj.cxx index 54e3ef16..74b4a071 100644 --- a/simgear/scene/tgdb/obj.cxx +++ b/simgear/scene/tgdb/obj.cxx @@ -616,7 +616,7 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool // location, and then apply the rotation matrix created // above, with an additional random heading rotation if appropriate. osg::Matrix transformMat; - transformMat = osg::Matrix::translate(obj.position.osg()); + transformMat = osg::Matrix::translate(toOsg(obj.position)); if (obj.model->get_heading_type() == SGMatModel::HEADING_RANDOM) { // Rotate the object around the z axis. double hdg = mt_rand(&seed) * M_PI * 2; @@ -758,8 +758,8 @@ SGLoadBTG(const std::string& path, SGMaterialLib *matlib, bool calc_lights, bool // The toplevel transform for that tile. osg::MatrixTransform* transform = new osg::MatrixTransform; transform->setName(path); - transform->setMatrix(osg::Matrix::rotate(hlOr.osg())* - osg::Matrix::translate(center.osg())); + transform->setMatrix(osg::Matrix::rotate(toOsg(hlOr))* + osg::Matrix::translate(toOsg(center))); transform->addChild(terrainGroup); if (lightGroup->getNumChildren() > 0) { osg::LOD* lightLOD = new osg::LOD; diff --git a/simgear/scene/tgdb/pt_lights.cxx b/simgear/scene/tgdb/pt_lights.cxx index e15b7bea..bfe3c5ae 100644 --- a/simgear/scene/tgdb/pt_lights.cxx +++ b/simgear/scene/tgdb/pt_lights.cxx @@ -237,8 +237,8 @@ SGLightFactory::getLightDrawable(const SGLightBin::Light& light) osg::Vec3Array* vertices = new osg::Vec3Array; osg::Vec4Array* colors = new osg::Vec4Array; - vertices->push_back(light.position.osg()); - colors->push_back(light.color.osg()); + vertices->push_back(toOsg(light.position)); + colors->push_back(toOsg(light.color)); osg::Geometry* geometry = new osg::Geometry; geometry->setVertexArray(vertices); @@ -270,12 +270,12 @@ SGLightFactory::getLightDrawable(const SGDirectionalLightBin::Light& light) SGVec3f perp1 = perpendicular(normal); SGVec3f perp2 = cross(normal, perp1); SGVec3f position = light.position; - vertices->push_back(position.osg()); - vertices->push_back((position + perp1).osg()); - vertices->push_back((position + perp2).osg()); - colors->push_back(visibleColor.osg()); - colors->push_back(invisibleColor.osg()); - colors->push_back(invisibleColor.osg()); + vertices->push_back(toOsg(position)); + vertices->push_back(toOsg(position + perp1)); + vertices->push_back(toOsg(position + perp2)); + colors->push_back(toOsg(visibleColor)); + colors->push_back(toOsg(invisibleColor)); + colors->push_back(toOsg(invisibleColor)); osg::Geometry* geometry = new osg::Geometry; geometry->setVertexArray(vertices); @@ -307,10 +307,10 @@ SGLightFactory::getLights(const SGLightBin& lights, unsigned inc, float alphaOff osg::Vec4Array* colors = new osg::Vec4Array; for (unsigned i = 0; i < lights.getNumLights(); i += inc) { - vertices->push_back(lights.getLight(i).position.osg()); + vertices->push_back(toOsg(lights.getLight(i).position)); SGVec4f color = lights.getLight(i).color; color[3] = SGMiscf::max(0, SGMiscf::min(1, color[3] + alphaOff)); - colors->push_back(color.osg()); + colors->push_back(toOsg(color)); } osg::Geometry* geometry = new osg::Geometry; @@ -358,12 +358,12 @@ SGLightFactory::getLights(const SGDirectionalLightBin& lights) SGVec3f perp1 = perpendicular(normal); SGVec3f perp2 = cross(normal, perp1); SGVec3f position = lights.getLight(i).position; - vertices->push_back(position.osg()); - vertices->push_back((position + perp1).osg()); - vertices->push_back((position + perp2).osg()); - colors->push_back(visibleColor.osg()); - colors->push_back(invisibleColor.osg()); - colors->push_back(invisibleColor.osg()); + vertices->push_back(toOsg(position)); + vertices->push_back(toOsg(position + perp1)); + vertices->push_back(toOsg(position + perp2)); + colors->push_back(toOsg(visibleColor)); + colors->push_back(toOsg(invisibleColor)); + colors->push_back(toOsg(invisibleColor)); } osg::Geometry* geometry = new osg::Geometry; diff --git a/simgear/scene/util/SGUpdateVisitor.hxx b/simgear/scene/util/SGUpdateVisitor.hxx index 0f640b66..251459a7 100644 --- a/simgear/scene/util/SGUpdateVisitor.hxx +++ b/simgear/scene/util/SGUpdateVisitor.hxx @@ -40,7 +40,7 @@ public: const SGQuatd& globalViewOrientation) { mGlobalGeodEyePos = SGGeod::fromCart(globalEyePos); - _currentEyePos = globalEyePos.osg(); + _currentEyePos = toOsg(globalEyePos); mGlobalEyePos = globalEyePos; mGlobalViewOr = globalViewOrientation; mGlobalHorizLocalOr = SGQuatd::fromLonLat(mGlobalGeodEyePos); -- 2.39.5